Commit ee5128bb authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging



# gpg: Signature made Wed 15 Jul 2020 14:49:07 BST
# gpg:                using RSA key EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  ftgmac100: fix dblac write test
  net: detect errors from probing vnet hdr flag for TAP devices
  net: check if the file descriptor is valid before using it
  qemu-options.hx: Clean up and fix typo for colo-compare
  net/colo-compare.c: Expose compare "max_queue_size" to users
  hw/net: Added CSO for IPv6
  virtio-net: fix removal of failover device

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 87463091 a134321e
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -810,16 +810,18 @@ static void ftgmac100_write(void *opaque, hwaddr addr,
        s->phydata = value & 0xffff;
        break;
    case FTGMAC100_DBLAC: /* DMA Burst Length and Arbitration Control */
        if (FTGMAC100_DBLAC_TXDES_SIZE(s->dblac) < sizeof(FTGMAC100Desc)) {
        if (FTGMAC100_DBLAC_TXDES_SIZE(value) < sizeof(FTGMAC100Desc)) {
            qemu_log_mask(LOG_GUEST_ERROR,
                          "%s: transmit descriptor too small : %d bytes\n",
                          __func__, FTGMAC100_DBLAC_TXDES_SIZE(s->dblac));
                          "%s: transmit descriptor too small: %" PRIx64
                          " bytes\n", __func__,
                          FTGMAC100_DBLAC_TXDES_SIZE(value));
            break;
        }
        if (FTGMAC100_DBLAC_RXDES_SIZE(s->dblac) < sizeof(FTGMAC100Desc)) {
        if (FTGMAC100_DBLAC_RXDES_SIZE(value) < sizeof(FTGMAC100Desc)) {
            qemu_log_mask(LOG_GUEST_ERROR,
                          "%s: receive descriptor too small : %d bytes\n",
                          __func__, FTGMAC100_DBLAC_RXDES_SIZE(s->dblac));
                          "%s: receive descriptor too small : %" PRIx64
                          " bytes\n", __func__,
                          FTGMAC100_DBLAC_RXDES_SIZE(value));
            break;
        }
        s->dblac = value;
+12 −3
Original line number Diff line number Diff line
@@ -468,8 +468,8 @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt)
    /* num of iovec without vhdr */
    uint32_t iov_len = pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1;
    uint16_t csl;
    struct ip_header *iphdr;
    size_t csum_offset = pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_offset;
    uint16_t l3_proto = eth_get_l3_proto(iov, 1, iov->iov_len);

    /* Put zero to checksum field */
    iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);
@@ -477,9 +477,18 @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt)
    /* Calculate L4 TCP/UDP checksum */
    csl = pkt->payload_len;

    csum_cntr = 0;
    cso = 0;
    /* add pseudo header to csum */
    iphdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
    csum_cntr = eth_calc_ip4_pseudo_hdr_csum(iphdr, csl, &cso);
    if (l3_proto == ETH_P_IP) {
        csum_cntr = eth_calc_ip4_pseudo_hdr_csum(
                pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base,
                csl, &cso);
    } else if (l3_proto == ETH_P_IPV6) {
        csum_cntr = eth_calc_ip6_pseudo_hdr_csum(
                pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base,
                csl, pkt->l4proto, &cso);
    }

    /* data checksum */
    csum_cntr +=
+1 −0
Original line number Diff line number Diff line
@@ -3416,6 +3416,7 @@ static void virtio_net_device_unrealize(DeviceState *dev)
    g_free(n->vlans);

    if (n->failover) {
        device_listener_unregister(&n->primary_listener);
        g_free(n->primary_device_id);
        g_free(n->standby_id);
        qobject_unref(n->primary_device_dict);
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int socket_set_cork(int fd, int v);
int socket_set_nodelay(int fd);
void qemu_set_block(int fd);
int qemu_try_set_nonblock(int fd);
void qemu_set_nonblock(int fd);
int socket_set_fast_reuse(int fd);

+42 −1
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ static bool colo_compare_active;
static QemuMutex event_mtx;
static QemuCond event_complete_cond;
static int event_unhandled_count;
static uint32_t max_queue_size;

/*
 *  + CompareState ++
@@ -222,7 +223,7 @@ static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
 */
static int colo_insert_packet(GQueue *queue, Packet *pkt, uint32_t *max_ack)
{
    if (g_queue_get_length(queue) <= MAX_QUEUE_SIZE) {
    if (g_queue_get_length(queue) <= max_queue_size) {
        if (pkt->ip->ip_p == IPPROTO_TCP) {
            fill_pkt_tcp_info(pkt, max_ack);
            g_queue_insert_sorted(queue,
@@ -1134,6 +1135,37 @@ static void compare_set_expired_scan_cycle(Object *obj, Visitor *v,
    s->expired_scan_cycle = value;
}

static void get_max_queue_size(Object *obj, Visitor *v,
                               const char *name, void *opaque,
                               Error **errp)
{
    uint32_t value = max_queue_size;

    visit_type_uint32(v, name, &value, errp);
}

static void set_max_queue_size(Object *obj, Visitor *v,
                               const char *name, void *opaque,
                               Error **errp)
{
    Error *local_err = NULL;
    uint32_t value;

    visit_type_uint32(v, name, &value, &local_err);
    if (local_err) {
        goto out;
    }
    if (!value) {
        error_setg(&local_err, "Property '%s.%s' requires a positive value",
                   object_get_typename(obj), name);
        goto out;
    }
    max_queue_size = value;

out:
    error_propagate(errp, local_err);
}

static void compare_pri_rs_finalize(SocketReadState *pri_rs)
{
    CompareState *s = container_of(pri_rs, CompareState, pri_rs);
@@ -1251,6 +1283,11 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
        s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS;
    }

    if (!max_queue_size) {
        /* Set default queue size to 1024 */
        max_queue_size = MAX_QUEUE_SIZE;
    }

    if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
        !qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
        return;
@@ -1370,6 +1407,10 @@ static void colo_compare_init(Object *obj)
                        compare_get_expired_scan_cycle,
                        compare_set_expired_scan_cycle, NULL, NULL);

    object_property_add(obj, "max_queue_size", "uint32",
                        get_max_queue_size,
                        set_max_queue_size, NULL, NULL);

    s->vnet_hdr = false;
    object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
                             compare_set_vnet_hdr);
Loading