From nobody Wed May 15 05:07:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588943492; cv=none; d=zohomail.com; s=zohoarc; b=C83kn8t42BPf6T7ItBPTTUnqltZ2NstBHyh5xQM1Mv/R4+/FevRhH/CUy3AUgLu3+BVU0gzSvjBy2T7x+Y4xHldmmR8wmG4xHLD/qquqhP6o8iL4GyOk1XlwRCCljeCnhBfKsXqPNO7pX6HaExcsDbYMbHwJisWnxWXUrcKgpa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588943492; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=YwIUCQPxUR46SYWuzxeD5H60YNMikGD4Q4AYC6QYvnQ=; b=XW26HLJ100CdrnP8BQlCKLuWHqTNyYBYEo8bMk3wY+GN0lfH0E/LszXnDy5CTMNl0SZzbXguJ5PgN6GjBM+q/fNoz0g9mii/CrMm1GHzPFUfBPs61q19crnvz0ProBRt9coqYyACzUAaJncQLwoR1ZYvC9FN/+cuajDMR0TtSN8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588943492101247.68402175315202; Fri, 8 May 2020 06:11:32 -0700 (PDT) Received: from localhost ([::1]:34428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX2mo-0003bO-RZ for importer@patchew.org; Fri, 08 May 2020 09:11:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX2bS-0000uh-N8 for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:46 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:33822) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX2bR-0006cR-Fl for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:46 -0400 Received: by mail-wr1-x443.google.com with SMTP id y3so1751877wrt.1 for ; Fri, 08 May 2020 05:59:45 -0700 (PDT) Received: from f2.redhat.com (bzq-79-183-19-16.red.bezeqint.net. [79.183.19.16]) by smtp.gmail.com with ESMTPSA id g6sm2915974wrw.34.2020.05.08.05.59.42 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 05:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YwIUCQPxUR46SYWuzxeD5H60YNMikGD4Q4AYC6QYvnQ=; b=PqjaCd11G/XUp7oSl7SGHHpVp3pWEBgJ+4UB5b2sPAnjvDTqB2e6w4hys0rSBUmT1A w5ERzPm64efU9JsqJhLHB5B3BBu7OEtWlLV0PQQuQkhWB5mUU+S0TrXHwoVl9VizEaBZ SX5vVFKyu4jExaQVRnouKsZ9PCv1TFE0eszEHLq8tt78BojGljAVdX1weRlJTEEs1PwH UKHZBRzuGsjNhz9wnwfc8URR88hoDjbKKADZwCJyPGxVf+JGAUF4sLFPV2d3Xcd3olud EuEx1vvX/wUrLNg+ac3JkaXfNVXkfWBqtyPFZKygXUr/oqJHMSp1ZuvWwn1aWT5QxOK+ u+dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YwIUCQPxUR46SYWuzxeD5H60YNMikGD4Q4AYC6QYvnQ=; b=Kl13jtnkiHDX87/j0EZjP2MpSTlAWPQ9sfbMYc5nqQntp3MAbZRAeodhdVTubywCFT 8QB8lk1LqbSgimoDbEGH9Zwwl6yKl6pCOSpxNbywYOfp+KmO3jAA+0MWwpAnEMA8SGRB B6ytwBwIKHWpGgxgkplaQW015vPKLj52PnachC7xSHtFPlSlm82/pEgvYBLxM0q3uWJO 6tKi9ypvu21gFG2/OvRNmdx8KnNsB8jMckOMjd/yvi9IbXxMGFTJB1RXONOCnvTO1seA XifQiokFWWwX+PmW4AHjfVB+6uASiAWIGqs65j0FrxU2+J1eZ9U4tkPmKntOKjnzXfz7 Wjpg== X-Gm-Message-State: AGi0PubFFYevZj7+780+0PRKqf7iWtXYPrPQI3KZoDcj4jXKK+zIPDQ+ U83KtsPCh0Tc/ZGfWBgxjWrZYiJKTrj2AA== X-Google-Smtp-Source: APiQypL+Aj7/8IxrYScUbHe0dvJfaLdvznzrstDCfttmWye47cX4J+nh0lBNxOsGyXpHbQJQHnh1Tw== X-Received: by 2002:a05:6000:189:: with SMTP id p9mr780314wrx.187.1588942783645; Fri, 08 May 2020 05:59:43 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v8 1/7] virtio-net: implement RSS configuration command Date: Fri, 8 May 2020 15:59:28 +0300 Message-Id: <20200508125934.7861-2-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508125934.7861-1-yuri.benditovich@daynix.com> References: <20200508125934.7861-1-yuri.benditovich@daynix.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::443; envelope-from=yuri.benditovich@daynix.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Optionally report RSS feature. Handle RSS configuration command and keep RSS parameters in virtio-net device context. Signed-off-by: Yuri Benditovich --- hw/net/trace-events | 3 + hw/net/virtio-net.c | 167 +++++++++++++++++++++++++++++++-- include/hw/virtio/virtio-net.h | 13 +++ 3 files changed, 174 insertions(+), 9 deletions(-) diff --git a/hw/net/trace-events b/hw/net/trace-events index e18f883cfd..a00ef6dc1c 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -381,6 +381,9 @@ virtio_net_announce_notify(void) "" virtio_net_announce_timer(int round) "%d" virtio_net_handle_announce(int round) "%d" virtio_net_post_load_device(void) +virtio_net_rss_disable(void) +virtio_net_rss_error(const char *msg, uint32_t value) "%s, value 0x%08x" +virtio_net_rss_enable(uint32_t p1, uint16_t p2, uint8_t p3) "hashes 0x%x, = table of %d, key of %d" =20 # tulip.c tulip_reg_write(uint64_t addr, const char *name, int size, uint64_t val) "= addr 0x%02"PRIx64" (%s) size %d value 0x%08"PRIx64 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3301869d4f..75e9769f79 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -77,6 +77,16 @@ tso/gso/gro 'off'. */ #define VIRTIO_NET_RSC_DEFAULT_INTERVAL 300000 =20 +#define VIRTIO_NET_RSS_SUPPORTED_HASHES (VIRTIO_NET_RSS_HASH_TYPE_IPv4 | \ + VIRTIO_NET_RSS_HASH_TYPE_TCPv4 | \ + VIRTIO_NET_RSS_HASH_TYPE_UDPv4 | \ + VIRTIO_NET_RSS_HASH_TYPE_IPv6 | \ + VIRTIO_NET_RSS_HASH_TYPE_TCPv6 | \ + VIRTIO_NET_RSS_HASH_TYPE_UDPv6 | \ + VIRTIO_NET_RSS_HASH_TYPE_IP_EX | \ + VIRTIO_NET_RSS_HASH_TYPE_TCP_EX |= \ + VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) + /* temporary until standard header include it */ #if !defined(VIRTIO_NET_HDR_F_RSC_INFO) =20 @@ -108,6 +118,8 @@ static VirtIOFeature feature_sizes[] =3D { .end =3D endof(struct virtio_net_config, mtu)}, {.flags =3D 1ULL << VIRTIO_NET_F_SPEED_DUPLEX, .end =3D endof(struct virtio_net_config, duplex)}, + {.flags =3D 1ULL << VIRTIO_NET_F_RSS, + .end =3D endof(struct virtio_net_config, supported_hash_types)}, {} }; =20 @@ -138,6 +150,11 @@ static void virtio_net_get_config(VirtIODevice *vdev, = uint8_t *config) memcpy(netcfg.mac, n->mac, ETH_ALEN); virtio_stl_p(vdev, &netcfg.speed, n->net_conf.speed); netcfg.duplex =3D n->net_conf.duplex; + netcfg.rss_max_key_size =3D VIRTIO_NET_RSS_MAX_KEY_SIZE; + virtio_stw_p(vdev, &netcfg.rss_max_indirection_table_length, + VIRTIO_NET_RSS_MAX_TABLE_LEN); + virtio_stl_p(vdev, &netcfg.supported_hash_types, + VIRTIO_NET_RSS_SUPPORTED_HASHES); memcpy(config, &netcfg, n->config_size); } =20 @@ -701,6 +718,7 @@ static uint64_t virtio_net_get_features(VirtIODevice *v= dev, uint64_t features, return features; } =20 + virtio_clear_feature(&features, VIRTIO_NET_F_RSS); features =3D vhost_net_get_features(get_vhost_net(nc->peer), features); vdev->backend_features =3D features; =20 @@ -860,6 +878,7 @@ static void virtio_net_set_features(VirtIODevice *vdev,= uint64_t features) } =20 virtio_net_set_multiqueue(n, + virtio_has_feature(features, VIRTIO_NET_F_RS= S) || virtio_has_feature(features, VIRTIO_NET_F_MQ= )); =20 virtio_net_set_mrg_rx_bufs(n, @@ -1136,25 +1155,152 @@ static int virtio_net_handle_announce(VirtIONet *n= , uint8_t cmd, } } =20 +static void virtio_net_disable_rss(VirtIONet *n) +{ + if (n->rss_data.enabled) { + trace_virtio_net_rss_disable(); + } + n->rss_data.enabled =3D false; +} + +static uint16_t virtio_net_handle_rss(VirtIONet *n, + struct iovec *iov, unsigned int iov_= cnt) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + struct virtio_net_rss_config cfg; + size_t s, offset =3D 0, size_get; + uint16_t queues, i; + struct { + uint16_t us; + uint8_t b; + } QEMU_PACKED temp; + const char *err_msg =3D ""; + uint32_t err_value =3D 0; + + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_RSS)) { + err_msg =3D "RSS is not negotiated"; + goto error; + } + size_get =3D offsetof(struct virtio_net_rss_config, indirection_table); + s =3D iov_to_buf(iov, iov_cnt, offset, &cfg, size_get); + if (s !=3D size_get) { + err_msg =3D "Short command buffer"; + err_value =3D (uint32_t)s; + goto error; + } + n->rss_data.hash_types =3D virtio_ldl_p(vdev, &cfg.hash_types); + n->rss_data.indirections_len =3D + virtio_lduw_p(vdev, &cfg.indirection_table_mask); + n->rss_data.indirections_len++; + if (!is_power_of_2(n->rss_data.indirections_len)) { + err_msg =3D "Invalid size of indirection table"; + err_value =3D n->rss_data.indirections_len; + goto error; + } + if (n->rss_data.indirections_len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { + err_msg =3D "Too large indirection table"; + err_value =3D n->rss_data.indirections_len; + goto error; + } + n->rss_data.default_queue =3D + virtio_lduw_p(vdev, &cfg.unclassified_queue); + if (n->rss_data.default_queue >=3D n->max_queues) { + err_msg =3D "Invalid default queue"; + err_value =3D n->rss_data.default_queue; + goto error; + } + offset +=3D size_get; + size_get =3D sizeof(uint16_t) * n->rss_data.indirections_len; + g_free(n->rss_data.indirections_table); + n->rss_data.indirections_table =3D g_malloc(size_get); + if (!n->rss_data.indirections_table) { + err_msg =3D "Can't allocate indirections table"; + err_value =3D n->rss_data.indirections_len; + goto error; + } + s =3D iov_to_buf(iov, iov_cnt, offset, + n->rss_data.indirections_table, size_get); + if (s !=3D size_get) { + err_msg =3D "Short indirection table buffer"; + err_value =3D (uint32_t)s; + goto error; + } + for (i =3D 0; i < n->rss_data.indirections_len; ++i) { + uint16_t val =3D n->rss_data.indirections_table[i]; + n->rss_data.indirections_table[i] =3D virtio_lduw_p(vdev, &val); + } + offset +=3D size_get; + size_get =3D sizeof(temp); + s =3D iov_to_buf(iov, iov_cnt, offset, &temp, size_get); + if (s !=3D size_get) { + err_msg =3D "Can't get queues"; + err_value =3D (uint32_t)s; + goto error; + } + queues =3D virtio_lduw_p(vdev, &temp.us); + if (queues =3D=3D 0 || queues > n->max_queues) { + err_msg =3D "Invalid number of queues"; + err_value =3D queues; + goto error; + } + if (temp.b > VIRTIO_NET_RSS_MAX_KEY_SIZE) { + err_msg =3D "Invalid key size"; + err_value =3D temp.b; + goto error; + } + if (!temp.b && n->rss_data.hash_types) { + err_msg =3D "No key provided"; + err_value =3D 0; + goto error; + } + if (!temp.b && !n->rss_data.hash_types) { + virtio_net_disable_rss(n); + return queues; + } + offset +=3D size_get; + size_get =3D temp.b; + s =3D iov_to_buf(iov, iov_cnt, offset, n->rss_data.key, size_get); + if (s !=3D size_get) { + err_msg =3D "Can get key buffer"; + err_value =3D (uint32_t)s; + goto error; + } + n->rss_data.enabled =3D true; + trace_virtio_net_rss_enable(n->rss_data.hash_types, + n->rss_data.indirections_len, + temp.b); + return queues; +error: + trace_virtio_net_rss_error(err_msg, err_value); + virtio_net_disable_rss(n); + return 0; +} + static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd, struct iovec *iov, unsigned int iov_cnt) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); - struct virtio_net_ctrl_mq mq; - size_t s; uint16_t queues; =20 - s =3D iov_to_buf(iov, iov_cnt, 0, &mq, sizeof(mq)); - if (s !=3D sizeof(mq)) { - return VIRTIO_NET_ERR; - } + virtio_net_disable_rss(n); + if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_RSS_CONFIG) { + queues =3D virtio_net_handle_rss(n, iov, iov_cnt); + } else if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) { + struct virtio_net_ctrl_mq mq; + size_t s; + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ)) { + return VIRTIO_NET_ERR; + } + s =3D iov_to_buf(iov, iov_cnt, 0, &mq, sizeof(mq)); + if (s !=3D sizeof(mq)) { + return VIRTIO_NET_ERR; + } + queues =3D virtio_lduw_p(vdev, &mq.virtqueue_pairs); =20 - if (cmd !=3D VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) { + } else { return VIRTIO_NET_ERR; } =20 - queues =3D virtio_lduw_p(vdev, &mq.virtqueue_pairs); - if (queues < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN || queues > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX || queues > n->max_queues || @@ -3111,6 +3257,7 @@ static void virtio_net_device_unrealize(DeviceState *= dev, Error **errp) g_free(n->vqs); qemu_del_nic(n->nic); virtio_net_rsc_cleanup(n); + g_free(n->rss_data.indirections_table); virtio_cleanup(vdev); } =20 @@ -3212,6 +3359,8 @@ static Property virtio_net_properties[] =3D { DEFINE_PROP_BIT64("ctrl_guest_offloads", VirtIONet, host_features, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, true), DEFINE_PROP_BIT64("mq", VirtIONet, host_features, VIRTIO_NET_F_MQ, fal= se), + DEFINE_PROP_BIT64("rss", VirtIONet, host_features, + VIRTIO_NET_F_RSS, false), DEFINE_PROP_BIT64("guest_rsc_ext", VirtIONet, host_features, VIRTIO_NET_F_RSC_EXT, false), DEFINE_PROP_UINT32("rsc_interval", VirtIONet, rsc_timeout, diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 96c68d4a92..d3fad7c8f3 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -126,6 +126,18 @@ typedef struct VirtioNetRscChain { /* Maximum packet size we can receive from tap device: header + 64k */ #define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 * KiB)) =20 +#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 +#define VIRTIO_NET_RSS_MAX_TABLE_LEN 128 + +typedef struct VirtioNetRssData { + bool enabled; + uint32_t hash_types; + uint8_t key[VIRTIO_NET_RSS_MAX_KEY_SIZE]; + uint16_t indirections_len; + uint16_t *indirections_table; + uint16_t default_queue; +} VirtioNetRssData; + typedef struct VirtIONetQueue { VirtQueue *rx_vq; VirtQueue *tx_vq; @@ -199,6 +211,7 @@ struct VirtIONet { bool failover; DeviceListener primary_listener; Notifier migration_state; + VirtioNetRssData rss_data; }; =20 void virtio_net_set_netclient_name(VirtIONet *n, const char *name, --=20 2.17.1 From nobody Wed May 15 05:07:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588942923; cv=none; d=zohomail.com; s=zohoarc; b=ZCy9+EX3PAUTB28MVQ3GpD+/OwCWD7ThS8sXWrrVwyqHccJOLbcUpCbDijm5QXcr5R4jTIkpj9PBTYbm1meoH34tZ3WOU9b8n6GwhIitIXJnWCyw5LyNn6LMSZNN8M+APMhOsd9ZtePoI0K2SjlOa6RHcnQm5s2ru9axLPtqqnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588942923; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=touW0hq6McA5DWWhPyvzubKbZLnGrRP3iQtMaqPPHa8=; b=XpJNZWEqL+X/gGDYJEGYyAPMn32YMNQEXQWLzlSSXcQPMyijHcdqCU6Nf0TESUBL0UnRbVWFoM03W4JoSajzE8pTTL/93yBR1t6F6IcpSIko0tt3PLmtBhsEbtttRrHdnaaBxDWdTwrLFllen/QajElhl9TXmbjDL7p7URLdLhk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588942923982428.50828799901956; Fri, 8 May 2020 06:02:03 -0700 (PDT) Received: from localhost ([::1]:53560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX2de-0003xI-NR for importer@patchew.org; Fri, 08 May 2020 09:02:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX2bU-0000y8-3a for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:48 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:42470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX2bS-0006cY-Ne for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:47 -0400 Received: by mail-wr1-x442.google.com with SMTP id s8so1734787wrt.9 for ; Fri, 08 May 2020 05:59:46 -0700 (PDT) Received: from f2.redhat.com (bzq-79-183-19-16.red.bezeqint.net. [79.183.19.16]) by smtp.gmail.com with ESMTPSA id g6sm2915974wrw.34.2020.05.08.05.59.43 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 05:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=touW0hq6McA5DWWhPyvzubKbZLnGrRP3iQtMaqPPHa8=; b=juu8LFFTJQhVSsZBxbPcqi8lkMTt9R1MihsISB10ZWGgNs7J2gmR7xGmo0lBaoe+Ih 5k3ZYjJZgr7HhNiQyu/D7KPNR1ysXsz6ICFRTmqRvvW8xRfXIijxRwsq9wVjZ0VyePyb tLw6oeMlXrZ9+0n7LXYhQ1UpIQSynbWmbQ8Ux0+DNSCiBZ8reJ3sxeRA6Wlsv8drStRx Fosug6GBCeMBuf8JZYxj47fSkW32pQdyGLorPmeDg7MQTQ0AKxOXbQIBcRmdSWnDTjXl 6eN9hz/eI80n0kgCSGWOsgasdTc5+KbY9A4a8IMuD6uLOwu5G3XpJXO7amSOz0486IlE vyUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=touW0hq6McA5DWWhPyvzubKbZLnGrRP3iQtMaqPPHa8=; b=rKWoRBhw+IncN8z2hsTzTKWlbkwm5PpiUMITf/oFJF6zrAx5GBkBHg3xC0V9Ya1XNc qTiiYiZ4n/NhPww6ShFFuQ9nOyO3SofkMnJvw0riVoTagqJQcYEmaJMPDVOqKtJd5MJy j6ismVFsBbCYx6aXf6wBwjxIjrTJ0eT47Txu8nN+ne5RwwAk1NzSC7TpL4eeqW2ylKPL nWh7+FNgeCUBr75vIRu3yWpNzJZzwlzBhnD6F4VcwyYdbyEIaJLK2O122JkXeekXM4AD f+X91GrkzIimEl8KE47pm3Iv+9zG6w2OGb7MGDpCpW220ABYLG9WuDpPx13Bd9UdNDkF 9GgA== X-Gm-Message-State: AGi0PuZyAJCdjWHAVoeNpxlkco0lW/hNtQP0sXa+ElrYejVWe513Z9z1 mBZUfxTY9BBVtCstZ3jTe6649mKtAAjx2g== X-Google-Smtp-Source: APiQypIFfbgNAh309kEigWtcJYoTw+FeFkn8ojG4PrDzajz4KJHoaWCQZQRANFuBA+9r6XphPv1BLw== X-Received: by 2002:adf:9f48:: with SMTP id f8mr2884087wrg.228.1588942785199; Fri, 08 May 2020 05:59:45 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v8 2/7] virtio-net: implement RX RSS processing Date: Fri, 8 May 2020 15:59:29 +0300 Message-Id: <20200508125934.7861-3-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508125934.7861-1-yuri.benditovich@daynix.com> References: <20200508125934.7861-1-yuri.benditovich@daynix.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::442; envelope-from=yuri.benditovich@daynix.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If VIRTIO_NET_F_RSS negotiated and RSS is enabled, process incoming packets, calculate packet's hash and place the packet into respective RX virtqueue. Signed-off-by: Yuri Benditovich --- hw/net/virtio-net.c | 88 +++++++++++++++++++++++++++++++++- include/hw/virtio/virtio-net.h | 1 + 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 75e9769f79..3511ea6c13 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -42,6 +42,7 @@ #include "trace.h" #include "monitor/qdev.h" #include "hw/pci/pci.h" +#include "net_rx_pkt.h" =20 #define VIRTIO_NET_VM_VERSION 11 =20 @@ -1533,8 +1534,80 @@ static int receive_filter(VirtIONet *n, const uint8_= t *buf, int size) return 0; } =20 +static uint8_t virtio_net_get_hash_type(bool isip4, + bool isip6, + bool isudp, + bool istcp, + uint32_t types) +{ + if (isip4) { + if (istcp && (types & VIRTIO_NET_RSS_HASH_TYPE_TCPv4)) { + return NetPktRssIpV4Tcp; + } + if (isudp && (types & VIRTIO_NET_RSS_HASH_TYPE_UDPv4)) { + return NetPktRssIpV4Udp; + } + if (types & VIRTIO_NET_RSS_HASH_TYPE_IPv4) { + return NetPktRssIpV4; + } + } else if (isip6) { + uint32_t mask =3D VIRTIO_NET_RSS_HASH_TYPE_TCP_EX | + VIRTIO_NET_RSS_HASH_TYPE_TCPv6; + + if (istcp && (types & mask)) { + return (types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) ? + NetPktRssIpV6TcpEx : NetPktRssIpV6Tcp; + } + mask =3D VIRTIO_NET_RSS_HASH_TYPE_UDP_EX | VIRTIO_NET_RSS_HASH_TYP= E_UDPv6; + if (isudp && (types & mask)) { + return (types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) ? + NetPktRssIpV6UdpEx : NetPktRssIpV6Udp; + } + mask =3D VIRTIO_NET_RSS_HASH_TYPE_IP_EX | VIRTIO_NET_RSS_HASH_TYPE= _IPv6; + if (types & mask) { + return (types & VIRTIO_NET_RSS_HASH_TYPE_IP_EX) ? + NetPktRssIpV6Ex : NetPktRssIpV6; + } + } + return 0xff; +} + +static int virtio_net_process_rss(NetClientState *nc, const uint8_t *buf, + size_t size) +{ + VirtIONet *n =3D qemu_get_nic_opaque(nc); + unsigned int index =3D nc->queue_index, new_index; + struct NetRxPkt *pkt =3D n->rx_pkt; + uint8_t net_hash_type; + uint32_t hash; + bool isip4, isip6, isudp, istcp; + + net_rx_pkt_set_protocols(pkt, buf + n->host_hdr_len, + size - n->host_hdr_len); + net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp); + if (isip4 && (net_rx_pkt_get_ip4_info(pkt)->fragment)) { + istcp =3D isudp =3D false; + } + if (isip6 && (net_rx_pkt_get_ip6_info(pkt)->fragment)) { + istcp =3D isudp =3D false; + } + net_hash_type =3D virtio_net_get_hash_type(isip4, isip6, isudp, istcp, + n->rss_data.hash_types); + if (net_hash_type > NetPktRssIpV6UdpEx) { + return n->rss_data.default_queue; + } + + hash =3D net_rx_pkt_calc_rss_hash(pkt, net_hash_type, n->rss_data.key); + new_index =3D hash & (n->rss_data.indirections_len - 1); + new_index =3D n->rss_data.indirections_table[new_index]; + if (index =3D=3D new_index) { + return -1; + } + return new_index; +} + static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *b= uf, - size_t size) + size_t size, bool no_rss) { VirtIONet *n =3D qemu_get_nic_opaque(nc); VirtIONetQueue *q =3D virtio_net_get_subqueue(nc); @@ -1548,6 +1621,14 @@ static ssize_t virtio_net_receive_rcu(NetClientState= *nc, const uint8_t *buf, return -1; } =20 + if (!no_rss && n->rss_data.enabled) { + int index =3D virtio_net_process_rss(nc, buf, size); + if (index >=3D 0) { + NetClientState *nc2 =3D qemu_get_subqueue(n->nic, index); + return virtio_net_receive_rcu(nc2, buf, size, true); + } + } + /* hdr_len refers to the header we supply to the guest */ if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_l= en)) { return 0; @@ -1642,7 +1723,7 @@ static ssize_t virtio_net_do_receive(NetClientState *= nc, const uint8_t *buf, { RCU_READ_LOCK_GUARD(); =20 - return virtio_net_receive_rcu(nc, buf, size); + return virtio_net_receive_rcu(nc, buf, size, false); } =20 static void virtio_net_rsc_extract_unit4(VirtioNetRscChain *chain, @@ -3221,6 +3302,8 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) =20 QTAILQ_INIT(&n->rsc_chains); n->qdev =3D dev; + + net_rx_pkt_init(&n->rx_pkt, false); } =20 static void virtio_net_device_unrealize(DeviceState *dev, Error **errp) @@ -3258,6 +3341,7 @@ static void virtio_net_device_unrealize(DeviceState *= dev, Error **errp) qemu_del_nic(n->nic); virtio_net_rsc_cleanup(n); g_free(n->rss_data.indirections_table); + net_rx_pkt_uninit(n->rx_pkt); virtio_cleanup(vdev); } =20 diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index d3fad7c8f3..5081f3c52a 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -212,6 +212,7 @@ struct VirtIONet { DeviceListener primary_listener; Notifier migration_state; VirtioNetRssData rss_data; + struct NetRxPkt *rx_pkt; }; =20 void virtio_net_set_netclient_name(VirtIONet *n, const char *name, --=20 2.17.1 From nobody Wed May 15 05:07:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588943612; cv=none; d=zohomail.com; s=zohoarc; b=ZhDIzLsmQXCh2Pu5FW+f9U1DARMGybOQx2qdj/77IZ0VvE7EtNrPJwhD1JNH7QDUYrpDDRuMXeLfbs3obyXePjt3/DfghOy4K4POsHOVXrJKflIyoRsOly3jWNhQvTBh0okXXgrFDTLcpajSRSbrSdQbfxTWZHUYVapEusj7pSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588943612; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=jsJ4UjAj5wqZiTgR+FddDr2mcT22TfIQNXUXRnn1z7Q=; b=fPeoStxkukhVfagmJ2uHtbV3xSwwG9FZBDO1tAtp2qECGYz/k1gEyh+j+5rNChEME1Sjl1Yzimk10YyEA1kTY+b06Zbwwah6w3ft/P362cToOX/fdFq9vXRsb4j0gFTBjcdAsRs7myBl+MJJZYk4rQ0N+5MVUw6VR/0bn4j5cKQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588943612558537.5827688566882; Fri, 8 May 2020 06:13:32 -0700 (PDT) Received: from localhost ([::1]:41420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX2ol-0006UR-50 for importer@patchew.org; Fri, 08 May 2020 09:13:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX2bV-000137-Pw for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:49 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43467) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX2bV-0006cg-2s for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:49 -0400 Received: by mail-wr1-x441.google.com with SMTP id i15so1725029wrx.10 for ; Fri, 08 May 2020 05:59:47 -0700 (PDT) Received: from f2.redhat.com (bzq-79-183-19-16.red.bezeqint.net. [79.183.19.16]) by smtp.gmail.com with ESMTPSA id g6sm2915974wrw.34.2020.05.08.05.59.45 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 05:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jsJ4UjAj5wqZiTgR+FddDr2mcT22TfIQNXUXRnn1z7Q=; b=AIiq1omT5rj+S8pudhQ+XAYSkwym1yK84rFtXC62t1aEw7Rt0dVFq2u52Hv5lXsh60 NKIrIxs5LVtUt06IIEzi3ET3c2DDnSMtp7ojjIm/mBEwvqjzispJefy75KlPoKoR4Y3k cCj3fedKJACRMfGbZd6kCzkBujL/TkslRwEGNffV4INRCvR3BeCKj8BQh08E0eO3cBiF 3Rm7XeHk5WGQUh6haW7vFwkPXts43vi+lwxy+dcj2QKk9/TDbK6NiRoDjSXUWZYbVeL6 q8W4OXiCdqpcdmScculkm00u4zkszjNYhxQRKF8yMyWlV9uwxdUZEc0pTQ6DA5YGjlFl oGAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jsJ4UjAj5wqZiTgR+FddDr2mcT22TfIQNXUXRnn1z7Q=; b=NoKM1fNlg0ljOxuWVZAGSvp6H6u8amZVmvtJ42AIEew5tvYOVqBhx8IX2lSbSbnh+P zHpC1bYZSgKp8A4zN5qVublhNVlNxgShJ9yCCL3pupusNNLBWQn1ih82bQ/UL1QWEuu1 4QmbrVbC6hnVwJzl2E3p51KR0x+VbKmlF/uKoHuFm+GY4Se164IYCr1KJiB8V1Z60FST D8Fm7Glu3/OdioTIDic9Vg7zoN3PjpNfshyH5T01fWdSvAUj22FmRsLkzyDgD+gQnsCP 0ekCEiGzEDY5GOjc9Sv1iSPi+TdOHET4QnYZTAwTuK8ZuIxyHQw2lJzdIUnqE5Vlgyil 8Cjg== X-Gm-Message-State: AGi0PuYKuDTzHgdE8GFF8hnkaioY3LuC3inAroKN8m+Wfn7Dzy57yrEP nPZBVDGCGqvsmcKSQaJVWKAMLMMf1OfIdA== X-Google-Smtp-Source: APiQypIFGFYZfb1/yAx3dY50DqqP4e6r5URJ5EqVgPdJf8CIEN9pCdnwWBVH2lTA6hLyCDZxwhqJLw== X-Received: by 2002:a5d:526f:: with SMTP id l15mr2777681wrc.367.1588942786512; Fri, 08 May 2020 05:59:46 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v8 3/7] tap: allow extended virtio header with hash info Date: Fri, 8 May 2020 15:59:30 +0300 Message-Id: <20200508125934.7861-4-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508125934.7861-1-yuri.benditovich@daynix.com> References: <20200508125934.7861-1-yuri.benditovich@daynix.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::441; envelope-from=yuri.benditovich@daynix.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Yuri Benditovich --- net/tap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/tap.c b/net/tap.c index 6207f61f84..ca48f2a285 100644 --- a/net/tap.c +++ b/net/tap.c @@ -254,7 +254,8 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, in= t len) =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); assert(len =3D=3D sizeof(struct virtio_net_hdr_mrg_rxbuf) || - len =3D=3D sizeof(struct virtio_net_hdr)); + len =3D=3D sizeof(struct virtio_net_hdr) || + len =3D=3D sizeof(struct virtio_net_hdr_v1_hash)); =20 tap_fd_set_vnet_hdr_len(s->fd, len); s->host_vnet_hdr_len =3D len; --=20 2.17.1 From nobody Wed May 15 05:07:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588943696; cv=none; d=zohomail.com; s=zohoarc; b=GrDmIDezhFYjFCUUSHJNl2mOjpRBKZUtI+sAJNt3jHXFsE8YlT2Gf5IqF3Znh4nd8iI1B/3/uKL64CaNmOJ1vxJj1ebGWpdssqKUAWXAdFUQcmYjvPur+4EK2HAJzO0XFG2zQpBMjN6zGm/bCaCAtqRCDDx3f4/g18uGbno4d/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588943696; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=+bp650bbQnsCHD8PQdaLw/0ZvWnorlER0/N7ka6DFss=; b=QGGbtD+Jfp2Dy9cbJsjSskPoW03onDV71IpKDFQmMIXZzUnjv/Q+h6GjwMwzlsiio8zEP9OyISM4lP0g7f+XEmiBcZea43LKQc2W11KtVbTiMmEzXoC1G8kMMMJ8YqxnyGXdRFeG3DSA/6AsDzTTxrM+tVs141ACCISkaVuupLE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588943696439265.31522435876275; Fri, 8 May 2020 06:14:56 -0700 (PDT) Received: from localhost ([::1]:45500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX2q7-0008GS-1c for importer@patchew.org; Fri, 08 May 2020 09:14:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX2bW-00015g-SX for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:50 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:37212) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX2bV-0006cv-LE for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:50 -0400 Received: by mail-wm1-x344.google.com with SMTP id z72so863209wmc.2 for ; Fri, 08 May 2020 05:59:49 -0700 (PDT) Received: from f2.redhat.com (bzq-79-183-19-16.red.bezeqint.net. [79.183.19.16]) by smtp.gmail.com with ESMTPSA id g6sm2915974wrw.34.2020.05.08.05.59.46 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 05:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+bp650bbQnsCHD8PQdaLw/0ZvWnorlER0/N7ka6DFss=; b=hm+M4anAJ6rvR2wLlcCYVeiXdT6/hHYMAktdiYLaZz8LpaxQf559LFVlW5yg8ps4hh CRtIj4au7Gr4S+WId0gygxY1rBDyTB4UmVG/oGyPm3+QaDzn2J1JMYM4p28+R6fNG4gj 0kYtgpqOTr1NMib688A9izbS1UiDJRVE8FA5B1vY0Mlqzlpls/yiA3trgdS5/Z9zL3FU +zUMUjx6kC/4kGHkZ0vIyg731EQ/9OQmF7kPscHrXAhMS16bpV2rLMVLjjSfDejpcODo /hv4C+wPe7s4NVVGXxxFKSIwD1ZcyhZP8pzJtpYteZDsDdIBl/GwONnTGmsPfqwKm/kr 9HxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+bp650bbQnsCHD8PQdaLw/0ZvWnorlER0/N7ka6DFss=; b=PfT5uqH+jToep+KG/1rIeVIoLf/xlySsDPT39CuBzPEd5nPW3wdrAUon0Gt7W7nM7Q oyF0u4d8nIl67pp5xC99fyvLQx71ckRsP/u7EcJDDu31+9hsCekZmUzMfoCS2ovCG3Oc LWsTbeYz6lW+TLHBSTVy6/C4XUQRCiAlx1sIEJ1ridCQsm1abm3+MeI0SqRNZm/6vUxj vVPcYVpoWlNpkFsxYlu/yoi3LkLYRgZVgGUN8DuFEE2uDHfu4rptWuUccG/yrr7tj2Q/ tVQ7DisY1W0p5Ixk78m35XhT+8p2ie1Xbjka76KvFIZbk8pOYMh8uP3dE07AIOlBL0qu FLFw== X-Gm-Message-State: AGi0PubRXIDEuKmrwEIFZK0Ewq3a01JYDa9Io5ctv5wuzjlG70FTtvXD VWZZZKecxiN2h37+R9Aa0NPyK/OrwSUapQ== X-Google-Smtp-Source: APiQypKxjkujSe/5iGde1NyNrYo34TTb2geckCJLKgvVuDkpeP1kpN/3SE4au86IvMq0RO1pF0w1cQ== X-Received: by 2002:a1c:6a08:: with SMTP id f8mr15127798wmc.132.1588942787831; Fri, 08 May 2020 05:59:47 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v8 4/7] virtio-net: reference implementation of hash report Date: Fri, 8 May 2020 15:59:31 +0300 Message-Id: <20200508125934.7861-5-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508125934.7861-1-yuri.benditovich@daynix.com> References: <20200508125934.7861-1-yuri.benditovich@daynix.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::344; envelope-from=yuri.benditovich@daynix.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Suggest VIRTIO_NET_F_HASH_REPORT if specified in device parameters. If the VIRTIO_NET_F_HASH_REPORT is set, the device extends configuration space. If the feature is negotiated, the packet layout is extended to accomodate the hash information. In this case deliver packet's hash value and report type in virtio header extension. Use for configuration the same procedure as already used for RSS. We add two fields in rss_data that controls what the device does with the calculated hash if rss_data.enabled is set. If field 'populate' is set the hash is set in the packet, if field 'redirect' is set the hash is used to decide the queue to place the packet to. Signed-off-by: Yuri Benditovich --- hw/net/virtio-net.c | 99 +++++++++++++++++++++++++++------- include/hw/virtio/virtio-net.h | 2 + 2 files changed, 81 insertions(+), 20 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3511ea6c13..5facd333ce 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -119,7 +119,7 @@ static VirtIOFeature feature_sizes[] =3D { .end =3D endof(struct virtio_net_config, mtu)}, {.flags =3D 1ULL << VIRTIO_NET_F_SPEED_DUPLEX, .end =3D endof(struct virtio_net_config, duplex)}, - {.flags =3D 1ULL << VIRTIO_NET_F_RSS, + {.flags =3D (1ULL << VIRTIO_NET_F_RSS) | (1ULL << VIRTIO_NET_F_HASH_RE= PORT), .end =3D endof(struct virtio_net_config, supported_hash_types)}, {} }; @@ -153,7 +153,8 @@ static void virtio_net_get_config(VirtIODevice *vdev, u= int8_t *config) netcfg.duplex =3D n->net_conf.duplex; netcfg.rss_max_key_size =3D VIRTIO_NET_RSS_MAX_KEY_SIZE; virtio_stw_p(vdev, &netcfg.rss_max_indirection_table_length, - VIRTIO_NET_RSS_MAX_TABLE_LEN); + virtio_host_has_feature(vdev, VIRTIO_NET_F_RSS) ? + VIRTIO_NET_RSS_MAX_TABLE_LEN : 1); virtio_stl_p(vdev, &netcfg.supported_hash_types, VIRTIO_NET_RSS_SUPPORTED_HASHES); memcpy(config, &netcfg, n->config_size); @@ -579,7 +580,7 @@ static int peer_has_ufo(VirtIONet *n) } =20 static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs, - int version_1) + int version_1, int hash_report) { int i; NetClientState *nc; @@ -587,7 +588,10 @@ static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, i= nt mergeable_rx_bufs, n->mergeable_rx_bufs =3D mergeable_rx_bufs; =20 if (version_1) { - n->guest_hdr_len =3D sizeof(struct virtio_net_hdr_mrg_rxbuf); + n->guest_hdr_len =3D hash_report ? + sizeof(struct virtio_net_hdr_v1_hash) : + sizeof(struct virtio_net_hdr_mrg_rxbuf); + n->rss_data.populate_hash =3D !!hash_report; } else { n->guest_hdr_len =3D n->mergeable_rx_bufs ? sizeof(struct virtio_net_hdr_mrg_rxbuf) : @@ -708,6 +712,8 @@ static uint64_t virtio_net_get_features(VirtIODevice *v= dev, uint64_t features, virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO4); virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO6); virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ECN); + + virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); } =20 if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) { @@ -720,6 +726,7 @@ static uint64_t virtio_net_get_features(VirtIODevice *v= dev, uint64_t features, } =20 virtio_clear_feature(&features, VIRTIO_NET_F_RSS); + virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); features =3D vhost_net_get_features(get_vhost_net(nc->peer), features); vdev->backend_features =3D features; =20 @@ -886,12 +893,15 @@ static void virtio_net_set_features(VirtIODevice *vde= v, uint64_t features) virtio_has_feature(features, VIRTIO_NET_F_MRG_RXBUF), virtio_has_feature(features, - VIRTIO_F_VERSION_1)); + VIRTIO_F_VERSION_1), + virtio_has_feature(features, + VIRTIO_NET_F_HASH_REPORT= )); =20 n->rsc4_enabled =3D virtio_has_feature(features, VIRTIO_NET_F_RSC_EXT)= && virtio_has_feature(features, VIRTIO_NET_F_GUEST_TSO4); n->rsc6_enabled =3D virtio_has_feature(features, VIRTIO_NET_F_RSC_EXT)= && virtio_has_feature(features, VIRTIO_NET_F_GUEST_TSO6); + n->rss_data.redirect =3D virtio_has_feature(features, VIRTIO_NET_F_RSS= ); =20 if (n->has_vnet_hdr) { n->curr_guest_offloads =3D @@ -1165,7 +1175,9 @@ static void virtio_net_disable_rss(VirtIONet *n) } =20 static uint16_t virtio_net_handle_rss(VirtIONet *n, - struct iovec *iov, unsigned int iov_= cnt) + struct iovec *iov, + unsigned int iov_cnt, + bool do_rss) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); struct virtio_net_rss_config cfg; @@ -1178,10 +1190,14 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, const char *err_msg =3D ""; uint32_t err_value =3D 0; =20 - if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_RSS)) { + if (do_rss && !virtio_vdev_has_feature(vdev, VIRTIO_NET_F_RSS)) { err_msg =3D "RSS is not negotiated"; goto error; } + if (!do_rss && !virtio_vdev_has_feature(vdev, VIRTIO_NET_F_HASH_REPORT= )) { + err_msg =3D "Hash report is not negotiated"; + goto error; + } size_get =3D offsetof(struct virtio_net_rss_config, indirection_table); s =3D iov_to_buf(iov, iov_cnt, offset, &cfg, size_get); if (s !=3D size_get) { @@ -1193,6 +1209,9 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, n->rss_data.indirections_len =3D virtio_lduw_p(vdev, &cfg.indirection_table_mask); n->rss_data.indirections_len++; + if (!do_rss) { + n->rss_data.indirections_len =3D 1; + } if (!is_power_of_2(n->rss_data.indirections_len)) { err_msg =3D "Invalid size of indirection table"; err_value =3D n->rss_data.indirections_len; @@ -1203,8 +1222,8 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, err_value =3D n->rss_data.indirections_len; goto error; } - n->rss_data.default_queue =3D - virtio_lduw_p(vdev, &cfg.unclassified_queue); + n->rss_data.default_queue =3D do_rss ? + virtio_lduw_p(vdev, &cfg.unclassified_queue) : 0; if (n->rss_data.default_queue >=3D n->max_queues) { err_msg =3D "Invalid default queue"; err_value =3D n->rss_data.default_queue; @@ -1238,7 +1257,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, err_value =3D (uint32_t)s; goto error; } - queues =3D virtio_lduw_p(vdev, &temp.us); + queues =3D do_rss ? virtio_lduw_p(vdev, &temp.us) : n->curr_queues; if (queues =3D=3D 0 || queues > n->max_queues) { err_msg =3D "Invalid number of queues"; err_value =3D queues; @@ -1284,8 +1303,12 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_= t cmd, uint16_t queues; =20 virtio_net_disable_rss(n); + if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_HASH_CONFIG) { + queues =3D virtio_net_handle_rss(n, iov, iov_cnt, false); + return queues ? VIRTIO_NET_OK : VIRTIO_NET_ERR; + } if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_RSS_CONFIG) { - queues =3D virtio_net_handle_rss(n, iov, iov_cnt); + queues =3D virtio_net_handle_rss(n, iov, iov_cnt, true); } else if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) { struct virtio_net_ctrl_mq mq; size_t s; @@ -1572,15 +1595,34 @@ static uint8_t virtio_net_get_hash_type(bool isip4, return 0xff; } =20 +static void virtio_set_packet_hash(const uint8_t *buf, uint8_t report, + uint32_t hash) +{ + struct virtio_net_hdr_v1_hash *hdr =3D (void *)buf; + hdr->hash_value =3D hash; + hdr->hash_report =3D report; +} + static int virtio_net_process_rss(NetClientState *nc, const uint8_t *buf, size_t size) { VirtIONet *n =3D qemu_get_nic_opaque(nc); - unsigned int index =3D nc->queue_index, new_index; + unsigned int index =3D nc->queue_index, new_index =3D index; struct NetRxPkt *pkt =3D n->rx_pkt; uint8_t net_hash_type; uint32_t hash; bool isip4, isip6, isudp, istcp; + static const uint8_t reports[NetPktRssIpV6UdpEx + 1] =3D { + VIRTIO_NET_HASH_REPORT_IPv4, + VIRTIO_NET_HASH_REPORT_TCPv4, + VIRTIO_NET_HASH_REPORT_TCPv6, + VIRTIO_NET_HASH_REPORT_IPv6, + VIRTIO_NET_HASH_REPORT_IPv6_EX, + VIRTIO_NET_HASH_REPORT_TCPv6_EX, + VIRTIO_NET_HASH_REPORT_UDPv4, + VIRTIO_NET_HASH_REPORT_UDPv6, + VIRTIO_NET_HASH_REPORT_UDPv6_EX + }; =20 net_rx_pkt_set_protocols(pkt, buf + n->host_hdr_len, size - n->host_hdr_len); @@ -1594,16 +1636,24 @@ static int virtio_net_process_rss(NetClientState *n= c, const uint8_t *buf, net_hash_type =3D virtio_net_get_hash_type(isip4, isip6, isudp, istcp, n->rss_data.hash_types); if (net_hash_type > NetPktRssIpV6UdpEx) { - return n->rss_data.default_queue; + if (n->rss_data.populate_hash) { + virtio_set_packet_hash(buf, VIRTIO_NET_HASH_REPORT_NONE, 0); + } + return n->rss_data.redirect ? n->rss_data.default_queue : -1; } =20 hash =3D net_rx_pkt_calc_rss_hash(pkt, net_hash_type, n->rss_data.key); - new_index =3D hash & (n->rss_data.indirections_len - 1); - new_index =3D n->rss_data.indirections_table[new_index]; - if (index =3D=3D new_index) { - return -1; + + if (n->rss_data.populate_hash) { + virtio_set_packet_hash(buf, reports[net_hash_type], hash); } - return new_index; + + if (n->rss_data.redirect) { + new_index =3D hash & (n->rss_data.indirections_len - 1); + new_index =3D n->rss_data.indirections_table[new_index]; + } + + return (index =3D=3D new_index) ? -1 : new_index; } =20 static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *b= uf, @@ -1679,6 +1729,11 @@ static ssize_t virtio_net_receive_rcu(NetClientState= *nc, const uint8_t *buf, } =20 receive_header(n, sg, elem->in_num, buf, size); + if (n->rss_data.populate_hash) { + offset =3D sizeof(mhdr); + iov_from_buf(sg, elem->in_num, offset, + buf + offset, n->host_hdr_len - sizeof(mhdr)); + } offset =3D n->host_hdr_len; total +=3D n->guest_hdr_len; guest_offset =3D n->guest_hdr_len; @@ -2671,7 +2726,9 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) trace_virtio_net_post_load_device(); virtio_net_set_mrg_rx_bufs(n, n->mergeable_rx_bufs, virtio_vdev_has_feature(vdev, - VIRTIO_F_VERSION_1)= ); + VIRTIO_F_VERSION_1), + virtio_vdev_has_feature(vdev, + VIRTIO_NET_F_HASH_R= EPORT)); =20 /* MAC_TABLE_ENTRIES may be different from the saved image */ if (n->mac_table.in_use > MAC_TABLE_ENTRIES) { @@ -3290,7 +3347,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) =20 n->vqs[0].tx_waiting =3D 0; n->tx_burst =3D n->net_conf.txburst; - virtio_net_set_mrg_rx_bufs(n, 0, 0); + virtio_net_set_mrg_rx_bufs(n, 0, 0, 0); n->promisc =3D 1; /* for compatibility */ =20 n->mac_table.macs =3D g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN); @@ -3445,6 +3502,8 @@ static Property virtio_net_properties[] =3D { DEFINE_PROP_BIT64("mq", VirtIONet, host_features, VIRTIO_NET_F_MQ, fal= se), DEFINE_PROP_BIT64("rss", VirtIONet, host_features, VIRTIO_NET_F_RSS, false), + DEFINE_PROP_BIT64("hash", VirtIONet, host_features, + VIRTIO_NET_F_HASH_REPORT, false), DEFINE_PROP_BIT64("guest_rsc_ext", VirtIONet, host_features, VIRTIO_NET_F_RSC_EXT, false), DEFINE_PROP_UINT32("rsc_interval", VirtIONet, rsc_timeout, diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 5081f3c52a..a45ef8278e 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -131,6 +131,8 @@ typedef struct VirtioNetRscChain { =20 typedef struct VirtioNetRssData { bool enabled; + bool redirect; + bool populate_hash; uint32_t hash_types; uint8_t key[VIRTIO_NET_RSS_MAX_KEY_SIZE]; uint16_t indirections_len; --=20 2.17.1 From nobody Wed May 15 05:07:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588943791; cv=none; d=zohomail.com; s=zohoarc; b=OD35bH8P4TTjnVH/9WyEVOPunUnF7I3MgT4IcMXZDXZ2RZp98LUULqsTBxcxUa9kzJOmSjc1P0RXFglBm8hvS9mo7Iyn5tWGToxgo3YpNIWi12H8iWo3XnP5LAjoCO2qWyFh63riqA375kCGv6Jmw6EYkijqXgq1AdEVfysoOXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588943791; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=bKbcDZF4VvCdwc1Z3LgA0n0/o1l3SD8mbWQhoT1XpcI=; b=aIdSZ0CrTYrtJ1n5lAxfTu7qT9qQWmFkGHl6KwuMpzwmYVDJa7b6KNMSqesW8KxSXyj4oK9KBR8XvTZ+f4GN9p2f9kzgWXYPXbbxfxUmaBSYako1f6c03y9o5jKClhpkwsTiUbAMeEHKw+Bjgn5LmVp47nGkHkxRkDfPTY6ttDU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588943791120100.1126369772893; Fri, 8 May 2020 06:16:31 -0700 (PDT) Received: from localhost ([::1]:49216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX2rd-0001gr-M2 for importer@patchew.org; Fri, 08 May 2020 09:16:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX2bY-00019a-H0 for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:52 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43468) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX2bX-0006dE-OM for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:52 -0400 Received: by mail-wr1-x441.google.com with SMTP id i15so1725195wrx.10 for ; Fri, 08 May 2020 05:59:50 -0700 (PDT) Received: from f2.redhat.com (bzq-79-183-19-16.red.bezeqint.net. [79.183.19.16]) by smtp.gmail.com with ESMTPSA id g6sm2915974wrw.34.2020.05.08.05.59.47 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 05:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bKbcDZF4VvCdwc1Z3LgA0n0/o1l3SD8mbWQhoT1XpcI=; b=Lc8lcnksX5d3je3p49Vztr08A+MFZfIGBC/zZ5XUENKKcT6sQE5k6ekGgGUpM0VMit 5TW/HMBti6n5VTWjcIIbYn//a417AuzILpvtjyvVRiNvSCturknFgUTDqLMjqEOO+zt1 vHyJsqhytNAIQmXjTxaRbp0kjyIt9rM1t0gBzCYCln4xyR5baI1cemLEl18E/qPVJT8i SMOGy0fOzZSpE2LAlCr5/4Z/X34FK5UhtQ4S6EvPgPm0ARa3bOQ/DUa0CxXf0xxszNfv JFbFVs2GnZRW49uXpav9BQkOAHAWiZAl3wY9B6hJZffxMYGlUFVBAmb1xCOJyl8IWQ58 j24g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bKbcDZF4VvCdwc1Z3LgA0n0/o1l3SD8mbWQhoT1XpcI=; b=XA1DJrON2yXJC0S5xCeyePVXzMaLzQa6ojox3n2UZZiJOeLruQGLC0xo5IjmfLlpWj GvXTIvvjW79J96bS0W/XkNZ2+JORfEZzRmQhc1APOdJBPtBCTjMBwtRJx+aXT92R09nL Lw0xzMUmB9IRVg3IylJSMjb+WxSdwBVcpI1uqa4QSVW1USojUqs7YI+ga6eYaA+mlLcV WcDDUGiBRzg5YWy6tU7c0TMt4dB41YBSUfEv/d46fKMk+1pK3O7J6MR1F/Qv2FD7OMbA PIHxIUJ2RPFqjPdA0y6zGrgJX8iz57hRTLhpduYW1lKiD9ZHZmYkX9euGWO0ruESCFb/ DCKQ== X-Gm-Message-State: AGi0PuY4qC+TdVJyNUrFeWWV/xGG7JLDjv771BL5YSxQfCKsMoupIOzT /ZCAHLWAquxe303mwT4wULtCmeJC8ZYcqQ== X-Google-Smtp-Source: APiQypIAIFQoe7kCiC7XGBBEM2F8ki2/zqFYd4bzyZ1VfEP6M9gZ9OJK2XzC//4SWtgPGsg9aDC4+g== X-Received: by 2002:adf:a1c8:: with SMTP id v8mr2791377wrv.79.1588942789362; Fri, 08 May 2020 05:59:49 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v8 5/7] vmstate.h: provide VMSTATE_VARRAY_UINT16_ALLOC macro Date: Fri, 8 May 2020 15:59:32 +0300 Message-Id: <20200508125934.7861-6-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508125934.7861-1-yuri.benditovich@daynix.com> References: <20200508125934.7861-1-yuri.benditovich@daynix.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::441; envelope-from=yuri.benditovich@daynix.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Similar to VMSTATE_VARRAY_UINT32_ALLOC, but the size is 16-bit field. Signed-off-by: Michael S. Tsirkin Signed-off-by: Yuri Benditovich --- include/migration/vmstate.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 30667631bc..baaefb6b9b 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -432,6 +432,16 @@ extern const VMStateInfo vmstate_info_qlist; .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 +#define VMSTATE_VARRAY_UINT16_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ + .name =3D (stringify(_field)), \ + .version_id =3D (_version), \ + .num_offset =3D vmstate_offset_value(_state, _field_num, uint16_t),\ + .info =3D &(_info), \ + .size =3D sizeof(_type), \ + .flags =3D VMS_VARRAY_UINT16 | VMS_POINTER | VMS_ALLOC, \ + .offset =3D vmstate_offset_pointer(_state, _field, _type), \ +} + #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version,= _info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ --=20 2.17.1 From nobody Wed May 15 05:07:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588943074; cv=none; d=zohomail.com; s=zohoarc; b=db1VA6V7PXs0R/bD/yZHajykuTEVhu4sw93Ho1s6rJSasQtxk8I7SaQ9yAYV+P2FzQLf0Xk+RQlqNCW8ArJiUR+6wYpUfVetJ4CsS5zk1lwyo4o4ljwFlQK0pJ5+FNzwpls2+L0CENth3MIV/h5fTUBxBHNPzunL5QeVRW/6JRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588943074; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=OHvBPJe5dvk8hPuFqDgGk/yn6yHcuCjG//Dr25P1Lus=; b=J2nGpAjc6vYS0pVZvHXlt7YH7PJD+zCL20sO2eskLtWoKngd4hAPeOpH+2+jaB7pIGE7q6bE0YSLrVi/s7Id4gvL8Mb2lBlRldyLC3wphleKrp+FnMZAvzPvoHnT7376z2DOb8qCo02GY4XotA8NG11bEGz+y3e8e+1kUsN7Two= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588943074609504.00071831817604; Fri, 8 May 2020 06:04:34 -0700 (PDT) Received: from localhost ([::1]:33102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX2g5-0007UA-AU for importer@patchew.org; Fri, 08 May 2020 09:04:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX2bY-0001A8-Rr for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:52 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX2bY-0006eq-0N for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:52 -0400 Received: by mail-wr1-x443.google.com with SMTP id 50so1202727wrc.11 for ; Fri, 08 May 2020 05:59:51 -0700 (PDT) Received: from f2.redhat.com (bzq-79-183-19-16.red.bezeqint.net. [79.183.19.16]) by smtp.gmail.com with ESMTPSA id g6sm2915974wrw.34.2020.05.08.05.59.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 05:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OHvBPJe5dvk8hPuFqDgGk/yn6yHcuCjG//Dr25P1Lus=; b=hWqbJJsJSAaAvtOBPv1r0nXLKKzNxMLphVqY9czvSd4wF4smjkmr7hRG+aRarPbcSA 7NFvhiUMwqGrfaj8qcVhGyG75T/crveJCbuy5rSiHLSDkiIv613WtYKFo194xi6Y3WBZ SjOAMMLNqkSd9/xVsFU1NFUdm7JA2VE0lioMP80gdycL9h+decYjtFD1pmRB7Q1Nsblq ykIk/IWKPtb9Iu6MdaCjvErpMszuErN86d9zL5CcjEj8P8bBY9cscQ23wo2OlQY6TULA GHk7f8/ZYf7z6l15jSFgxmV5IRBg8Y+6U7uTenXut0GHaHgRl/Sqen033wqRTQkTuLxS hspA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OHvBPJe5dvk8hPuFqDgGk/yn6yHcuCjG//Dr25P1Lus=; b=HLw+HUgIgQH0tqndqVk9g0GP0jIM83vtvX0S5bV87ET7HTlXQQJwJ8Gn7rqAzGo3jK g5En84BXtsrLVpQLZEUOwOUUgfrMLwYudyW/Lv++65v0FE55TlrNOZK45glp+sPRFE77 ETzrhHsK+ayfwzErrLomn5ScX+28LomEs1tUT6bJ0LGZCSNAMh7mtHNAlX9/SHOri+cz 2+oX5R6MuQMKf7PeiM/B9Ytf47TZTPw1FVfgEjRhx16zx4meBjHeMBI8muA4CuJ0g8py 2QYioNBJBjnKKVj4Y9tu6K9bP9X+wiaF0iyMhFcnNnMSa9pL2n/fOCU2LV1TkDcH9Cd4 qB+A== X-Gm-Message-State: AGi0PuZm2ibnkC70JxSrq9ekZt80KDGn4j5yP+EQZ+r7D39JVbd6F8Sr O+15XPkILUBWyI4V4oq4ME8G7rGAFBOPfg== X-Google-Smtp-Source: APiQypKvqoqebW/EvxV2iTicGyQ1x7b9LgoDbPbml1eldSkaNb5/q2x5kQKYVoOniDkKk09PkpEC4Q== X-Received: by 2002:a05:6000:12cf:: with SMTP id l15mr2823410wrx.348.1588942790589; Fri, 08 May 2020 05:59:50 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v8 6/7] virtio-net: add migration support for RSS and hash report Date: Fri, 8 May 2020 15:59:33 +0300 Message-Id: <20200508125934.7861-7-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508125934.7861-1-yuri.benditovich@daynix.com> References: <20200508125934.7861-1-yuri.benditovich@daynix.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::443; envelope-from=yuri.benditovich@daynix.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Save and restore RSS/hash report configuration. Signed-off-by: Yuri Benditovich --- hw/net/virtio-net.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5facd333ce..c263b1511d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2777,6 +2777,13 @@ static int virtio_net_post_load_device(void *opaque,= int version_id) } } =20 + if (n->rss_data.enabled) { + trace_virtio_net_rss_enable(n->rss_data.hash_types, + n->rss_data.indirections_len, + sizeof(n->rss_data.key)); + } else { + trace_virtio_net_rss_disable(); + } return 0; } =20 @@ -2954,6 +2961,32 @@ static const VMStateDescription vmstate_virtio_net_h= as_vnet =3D { }, }; =20 +static bool virtio_net_rss_needed(void *opaque) +{ + return VIRTIO_NET(opaque)->rss_data.enabled; +} + +static const VMStateDescription vmstate_virtio_net_rss =3D { + .name =3D "virtio-net-device/rss", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D virtio_net_rss_needed, + .fields =3D (VMStateField[]) { + VMSTATE_BOOL(rss_data.enabled, VirtIONet), + VMSTATE_BOOL(rss_data.redirect, VirtIONet), + VMSTATE_BOOL(rss_data.populate_hash, VirtIONet), + VMSTATE_UINT32(rss_data.hash_types, VirtIONet), + VMSTATE_UINT16(rss_data.indirections_len, VirtIONet), + VMSTATE_UINT16(rss_data.default_queue, VirtIONet), + VMSTATE_UINT8_ARRAY(rss_data.key, VirtIONet, + VIRTIO_NET_RSS_MAX_KEY_SIZE), + VMSTATE_VARRAY_UINT16_ALLOC(rss_data.indirections_table, VirtIONet, + rss_data.indirections_len, 0, + vmstate_info_uint16, uint16_t), + VMSTATE_END_OF_LIST() + }, +}; + static const VMStateDescription vmstate_virtio_net_device =3D { .name =3D "virtio-net-device", .version_id =3D VIRTIO_NET_VM_VERSION, @@ -3004,6 +3037,10 @@ static const VMStateDescription vmstate_virtio_net_d= evice =3D { has_ctrl_guest_offloads), VMSTATE_END_OF_LIST() }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_virtio_net_rss, + NULL + } }; =20 static NetClientInfo net_virtio_info =3D { --=20 2.17.1 From nobody Wed May 15 05:07:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588943500; cv=none; d=zohomail.com; s=zohoarc; b=ULADRie25UwlPsLnCD5VjDWkPp5CDs7CIsNuehHhXB4+etES+nrK8f2QqeQu5HWjYvTM7m+5p502ElhHzikZBOwuXzuEcjJtFG26JoEPECle/rrs3zHUv+Tepdtrwkqza1mM9zlgIhnsnyAZYZQU8d4tsy0Y3+ELCBZUOrzhmGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588943500; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=/hmWHO6d7/G558em/hObj2NusDs/d8TWPYPLgPOejdI=; b=ghvmYJGzvKXpNYpeQEle4NwKg125Yg3FxQnlBPbzyDMiFvcWj+R9PvP7lFw0itFtN+S3+k943/JB+sdUrgpe0AAtGzgKCFovUwdlel7upbGurKnb/Wcp6OZBZrkkzvEcUtJ6NE7Y058D9lEyg03x3F9cp360xuDzxxsmc6FZahs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588943500366133.19105350638938; Fri, 8 May 2020 06:11:40 -0700 (PDT) Received: from localhost ([::1]:35104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX2mx-0003ru-1K for importer@patchew.org; Fri, 08 May 2020 09:11:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX2ba-0001CQ-01 for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:54 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:39006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX2bZ-0006hB-7T for qemu-devel@nongnu.org; Fri, 08 May 2020 08:59:53 -0400 Received: by mail-wr1-x443.google.com with SMTP id l18so1732272wrn.6 for ; Fri, 08 May 2020 05:59:52 -0700 (PDT) Received: from f2.redhat.com (bzq-79-183-19-16.red.bezeqint.net. [79.183.19.16]) by smtp.gmail.com with ESMTPSA id g6sm2915974wrw.34.2020.05.08.05.59.50 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 05:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/hmWHO6d7/G558em/hObj2NusDs/d8TWPYPLgPOejdI=; b=bz2GEL9NKlKov5U1IR81lsUGdhzQpjNb9u+V4wOER38/VNyrK4diko7P/mcdbi5oeO VVDCSOZb+NEEYITyfk/Y6m8naQOYtzGx8Ccgc0ceANV/TVb5npObMr+wiUlJcz5ZSdco TRGmD+s+ggSgqC7VIl02CTR5Kopg+UKQjg8WAgOVozTzQ0A2NlqWu4O92tLoCu5wwap2 a2L9ivjwKiAHHQSQ1pKM1JRaY5KI3ZZaAhY6j1Cad+b0dUxmj9t19Q0gFV3m1D8j4vdB TodKS3VB8aO+iS04dfohUwowCnol7eytpRokkD0FMZeQfR/ldKOuj7dLjBMVXJ+usylj 2FUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/hmWHO6d7/G558em/hObj2NusDs/d8TWPYPLgPOejdI=; b=sQBrFqYwhsIxCiFT5yqusnVL0htInYCo5epE5W7WkJrEuH07BqToNpk31Z8B9CzKAb XGJsxUjfQsbzhMQIwcWKHjUHUivDlCIWYP8v8t15zjEi7Ac5umM1pNaqc7cKh329DQU0 UFYApXEvc9KaE+FxaEVg13cMFJLJOZUKW0HUeuMjut2TfQkLCVTa98LlOoPn8OQ1cVn7 Re7ejx2M3awsTVrCZ6YqQexdule2ksgKg/eAzaTudTOXFtfJsHIhu8RXzX1O1IqaQHHk D75hAT81Mj4l7MNpDzSgC9gSRGORuk1CCobV77kNeIRz1n7RXHT+ixqvjcegXvg7BCJD /rxw== X-Gm-Message-State: AGi0Pub40x1FdQpoRgxPaHNVNVqRVwlDVSPEC44oionfGL01yu/mtS8s 6D07atxAX671SHF3VifkhC/LFSi0AipowQ== X-Google-Smtp-Source: APiQypIZ67c/pX1TTu07upMI6r6h0qTOc8pPA05J7U6EEy/whoVCDcwR1BNBty13NBWzSKlSJ9QzAw== X-Received: by 2002:adf:e2c2:: with SMTP id d2mr3028472wrj.55.1588942791821; Fri, 08 May 2020 05:59:51 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v8 7/7] virtio-net: align RSC fields with updated virtio-net header Date: Fri, 8 May 2020 15:59:34 +0300 Message-Id: <20200508125934.7861-8-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508125934.7861-1-yuri.benditovich@daynix.com> References: <20200508125934.7861-1-yuri.benditovich@daynix.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::443; envelope-from=yuri.benditovich@daynix.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Removal of duplicated RSC definitions. Changing names of the fields to ones defined in the Linux header. Signed-off-by: Yuri Benditovich --- hw/net/virtio-net.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index c263b1511d..10b4ba50ad 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -88,26 +88,6 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX |= \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) =20 -/* temporary until standard header include it */ -#if !defined(VIRTIO_NET_HDR_F_RSC_INFO) - -#define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc_ext data in csum_ fields */ -#define VIRTIO_NET_F_RSC_EXT 61 - -#endif - -static inline __virtio16 *virtio_net_rsc_ext_num_packets( - struct virtio_net_hdr *hdr) -{ - return &hdr->csum_start; -} - -static inline __virtio16 *virtio_net_rsc_ext_num_dupacks( - struct virtio_net_hdr *hdr) -{ - return &hdr->csum_offset; -} - static VirtIOFeature feature_sizes[] =3D { {.flags =3D 1ULL << VIRTIO_NET_F_MAC, .end =3D endof(struct virtio_net_config, mac)}, @@ -1821,15 +1801,15 @@ static size_t virtio_net_rsc_drain_seg(VirtioNetRsc= Chain *chain, VirtioNetRscSeg *seg) { int ret; - struct virtio_net_hdr *h; + struct virtio_net_hdr_v1 *h; =20 - h =3D (struct virtio_net_hdr *)seg->buf; + h =3D (struct virtio_net_hdr_v1 *)seg->buf; h->flags =3D 0; h->gso_type =3D VIRTIO_NET_HDR_GSO_NONE; =20 if (seg->is_coalesced) { - *virtio_net_rsc_ext_num_packets(h) =3D seg->packets; - *virtio_net_rsc_ext_num_dupacks(h) =3D seg->dup_ack; + h->rsc.segments =3D seg->packets; + h->rsc.dup_acks =3D seg->dup_ack; h->flags =3D VIRTIO_NET_HDR_F_RSC_INFO; if (chain->proto =3D=3D ETH_P_IP) { h->gso_type =3D VIRTIO_NET_HDR_GSO_TCPV4; --=20 2.17.1