From nobody Fri May 17 10:44:32 2024 Delivered-To: importer@patchew.org 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; 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=1583743092; cv=none; d=zohomail.com; s=zohoarc; b=C4kHUULU1g7imWYltFbBpH9mMLAyd6owA+IZ1sDvRkGBOven1ePCSp3APBBO5IickkE+fu1SdVu9ql1yvGbzI3V0PNhbGMYxG9WsRb2eIl7VPHFzfZm9SbkN8NQNtkkMpK0T+JLMuSG7ymQET0E18AHaoV528EL36H85PVQpbp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583743092; 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=MD48WZYaJiiFtb9BWvJPqIeuYzfyj+64eoP1t2H2QsM=; b=ZPo+46diLUJCQQj3GO9fx78GiQvmvFDM2rzC5/w3REbgwr0oPPwwaRNfnESSzOpCkZ9/7siyn6kulzRNwL5ymhmUKLaDne22uHmpmH/GKJ9CuEMfxgFoUgmRLnNKCecbGa/+d8og/3Yc4RnvYYeT6selD651ZkoGq+d7U4Tx8S4= 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 1583743092305209.2861545690737; Mon, 9 Mar 2020 01:38:12 -0700 (PDT) Received: from localhost ([::1]:38588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBDvP-0006Bg-4q for importer@patchew.org; Mon, 09 Mar 2020 04:38:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47253) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBDsC-0007Zn-VK for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBDsB-0007Jf-K3 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:52 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:46630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jBDsB-0007Ib-Dh for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:51 -0400 Received: by mail-wr1-x443.google.com with SMTP id n15so9834985wrw.13 for ; Mon, 09 Mar 2020 01:34:50 -0700 (PDT) Received: from f2.redhat.com (bzq-79-177-42-131.red.bezeqint.net. [79.177.42.131]) by smtp.gmail.com with ESMTPSA id h3sm63749726wrb.23.2020.03.09.01.34.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Mar 2020 01:34: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=MD48WZYaJiiFtb9BWvJPqIeuYzfyj+64eoP1t2H2QsM=; b=cOiMMd/fFhW+XVawA2sXDUUPZiw7x2HFB7voEIJqUQIe6fpLtX64cUq4rwJdrHuuj4 lAafYGrCVF2WUbrJ3QV4ltf4goi+Q2VeuII2oUerejOBeadRjSZJS2M/AsAi1j8eEs2c ahBP0obtlrZ89agupANcru8baXLqViRwAIOipocfQQahIibWoFwv1YrSpx+aNa5oKEZp P4zKJ4BmGeR8lQfXa67DIi47wdV4Z1QLnccc/0nlppEyTWZUElcW0yiNLZbi2eSFqrCl dPoKP0W50n5fvt/gm0Q86r1vxzQjaCxSasYEfHXuq8ZZv1HOrK0Poh7P/hv5IgS9S2eH 6WqA== 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=MD48WZYaJiiFtb9BWvJPqIeuYzfyj+64eoP1t2H2QsM=; b=GlTu1P0Pm5PrAkJGnZjat/e4FLYMR1S3OhYIqcPNXabWK8cgcK/hd/YjeLOid9lUUl QCZePo9zjkQJffNYOcyLEtUYgVy4y1kUfUQ9SgVyrE+ILraROJu6MbRLtezjeS9uH48s oPri6XgwqzLDZ26liKBwuK11MGVFUpz6SLUJQVxJBhf238ZDwhKxnmnnR5Oi2oKm7zFe 3el6iYe10N/e0yTDvY6byq+1ZCea349mesawlk1wgjGTeXmEmXdPFrc6zyMsUDDbxHik zhQd+WjcDu6ap1tp4VHKSSS94T1g9SeYrPoZgGR7kRsxL2faaM/S+rcNKahd/vkirgPJ 4XRg== X-Gm-Message-State: ANhLgQ2EDSv0/6E4tgPV/KNOn4iL48vS3vAmEdQsGvllcI/MSR0/jeXA C0K1QIK2pEohB432k0ZPkeYYMSJ+oA4sCQ== X-Google-Smtp-Source: ADFU+vtRGnbbMYemX9B1Gp/bPQ2JHkdwh+fltXhVAzgewEbbHYwtwtnhwq3Mgd91fB567vU2/kHBvA== X-Received: by 2002:a5d:65c5:: with SMTP id e5mr3545340wrw.161.1583742889160; Mon, 09 Mar 2020 01:34:49 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com Subject: [PATCH v2 1/4] virtio-net: introduce RSS and hash report features Date: Mon, 9 Mar 2020 10:34:35 +0200 Message-Id: <20200309083438.2389-2-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200309083438.2389-1-yuri.benditovich@daynix.com> References: <20200309083438.2389-1-yuri.benditovich@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 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 --- hw/net/virtio-net.c | 95 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3627bb1717..9545b0e84f 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -71,6 +71,101 @@ #define VIRTIO_NET_IP6_ADDR_SIZE 32 /* ipv6 saddr + daddr */ #define VIRTIO_NET_MAX_IP6_PAYLOAD VIRTIO_NET_MAX_TCP_PAYLOAD =20 +/* TODO: remove after virtio-net header update */ +#if !defined(VIRTIO_NET_RSS_HASH_TYPE_IPv4) +#define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */ +#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ + +/* supported/enabled hash types */ +#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) +#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) +#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) +#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) +#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) + +#define __le16 uint16_t +#define __le32 uint32_t +#define __u8 uint8_t +#define __u16 uint16_t +#define __u32 uint32_t + +struct virtio_net_config_with_rss { + /* The config defining mac address (if VIRTIO_NET_F_MAC) */ + __u8 mac[ETH_ALEN]; + /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ + __u16 status; + /* + * Maximum number of each of transmit and receive queues; + * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ. + * Legal values are between 1 and 0x8000 + */ + __u16 max_virtqueue_pairs; + /* Default maximum transmit unit advice */ + __u16 mtu; + /* + * speed, in units of 1Mb. All values 0 to INT_MAX are legal. + * Any other value stands for unknown. + */ + __u32 speed; + /* + * 0x00 - half duplex + * 0x01 - full duplex + * Any other value stands for unknown. + */ + __u8 duplex; + /* maximum size of RSS key */ + __u8 rss_max_key_size; + /* maximum number of indirection table entries */ + __le16 rss_max_indirection_table_length; + /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */ + __le32 supported_hash_types; +} __attribute__((packed)); + +#define virtio_net_config virtio_net_config_with_rss + +struct virtio_net_hdr_v1_hash { + struct virtio_net_hdr_v1 hdr; + __le32 hash_value; +#define VIRTIO_NET_HASH_REPORT_NONE 0 +#define VIRTIO_NET_HASH_REPORT_IPv4 1 +#define VIRTIO_NET_HASH_REPORT_TCPv4 2 +#define VIRTIO_NET_HASH_REPORT_UDPv4 3 +#define VIRTIO_NET_HASH_REPORT_IPv6 4 +#define VIRTIO_NET_HASH_REPORT_TCPv6 5 +#define VIRTIO_NET_HASH_REPORT_UDPv6 6 +#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 +#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 +#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 + __le16 hash_report; + __le16 padding; +}; + +/* + * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as + * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures + * the receive steering to use a hash calculated for incoming packet + * to decide on receive virtqueue to place the packet. The command + * also provides parameters to calculate a hash and receive virtqueue. + */ +struct virtio_net_rss_config { + __le32 hash_types; + __le16 indirection_table_mask; + __le16 unclassified_queue; + __le16 indirection_table[1/* + indirection_table_mask */]; + __le16 max_tx_vq; + __u8 hash_key_length; + __u8 hash_key_data[/* hash_key_length */]; +}; + +#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 +#define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 + +#endif + /* Purge coalesced packets timer interval, This value affects the performa= nce a lot, and should be tuned carefully, '300000'(300us) is the recommended value to pass the WHQL test, '50000' can gain 2x netperf throughput with --=20 2.17.1 From nobody Fri May 17 10:44:32 2024 Delivered-To: importer@patchew.org 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; 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=1583743190; cv=none; d=zohomail.com; s=zohoarc; b=lTdTTeSrV1X6KvNrQN9XoLrs5hQLrAusDLieznCaCDiU126UfFHSraVL1C9ChdpxpjyOyj6bpFbbQgkggiG9Ex/6S0VtQnMH2MmAJIrulCIH5vs5HiqqebSoJ+0FI7kaKjKV8wTHyBobCm6XSkXISPUBi/ikbsRXJ/Meg8F/olo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583743190; 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=sQsNWCobnmXTK/R2xUJv6I/7W7Ysw1UAgVvh6gnFET8=; b=ltl0R2Ty3LmG+faKvCUnAcxau/mfNKHNoSTYLBv2+yeyfOSsUS/Gj4CqrMB50VV+Vs13M2eRWqUpVCciBsKT0BPCbzzeGGsGduQaedI90RunDgmURE66zJ2UpjME10C9By+smiA0p2H5WI0r8g523eM5AegBfqb4DIogQ0ZbBuw= 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 1583743190291960.6383403698571; Mon, 9 Mar 2020 01:39:50 -0700 (PDT) Received: from localhost ([::1]:38640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBDwz-0001Gp-4j for importer@patchew.org; Mon, 09 Mar 2020 04:39:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47263) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBDsD-0007bv-Or for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBDsC-0007KH-36 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:53 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:46629) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jBDsB-0007JS-Rs for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:52 -0400 Received: by mail-wr1-x441.google.com with SMTP id n15so9835079wrw.13 for ; Mon, 09 Mar 2020 01:34:51 -0700 (PDT) Received: from f2.redhat.com (bzq-79-177-42-131.red.bezeqint.net. [79.177.42.131]) by smtp.gmail.com with ESMTPSA id h3sm63749726wrb.23.2020.03.09.01.34.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Mar 2020 01:34:49 -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=sQsNWCobnmXTK/R2xUJv6I/7W7Ysw1UAgVvh6gnFET8=; b=kRExvKYe2hGBZH4xZqZ0bUVX0y73JNC2Luwxfu8jcozwKhHjzxX7OhcFMAbEpgqvLf oFbWzEfRfLw+u4eLBmQXWEaoanDPGaFb2cSsGPAEvfGbqN1b/5b2s9UjlP7fKDPXh+hV rnWZu9hw3aKe7jYNfglhs0WSd2M6NXE7rIivmFhEQyaJaXc6uyHKfZAofafu52LXDwEA tFvKycoQQKRgSEa6CPPxq13KIb2CEqnDWMXV87qbnNPN0Pi9E3rteOApgd1xLcz/GwcA HRHY0+MlF2GwQL/bgqjxstsPUU5aLXPrpi+Kk9uza0iS8qy22CGxc+Tx53EtpnqLTG7u +0zw== 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=sQsNWCobnmXTK/R2xUJv6I/7W7Ysw1UAgVvh6gnFET8=; b=I5jOk3fpJz5oHLl7qc0eaeqokg6Q7iLHV6jYBBICGDcCnQdVJXqkfmOSFrevA1pRY8 0E/k+I/0AfpX9iGomLIqQ7DbIR1ZfMCTGzJVgXk8DUfnpOreNu5zEdj+9FZRtV6VFQ5k 8sgEKOznjf1BOmEcGv2e1p4tqB48AMes82m7OeXFPZsuKrk1F8O7DjBV5w4rOz3E9IRz eGTG/mm75n/F0kbVEL40EcR6f9W0t4QS2ahoyPA74usN1+qMbY0JgV23vp9N0m1SYjMK prFflgOkjbLC7fXDI9cdMcUeSxnhFi6AJ8ovhtymxEyNgQoIDHzy5I55otepwB5yKBHJ 9IhA== X-Gm-Message-State: ANhLgQ1uR36WcI/AkmHE/zuaf1Jw7IyE7XXb9NDrwK6qshlWY9JxBXyO ZuSdU7UJTNetYKXON2D5UEV3lKMpUatn5Q== X-Google-Smtp-Source: ADFU+vtN51Kz2IboCKPentUkhFuNfSxQyhFoFGOoF5J7DSPyT5v791LHAiVEfBbg3HlSIAxu43wHew== X-Received: by 2002:adf:f9cd:: with SMTP id w13mr19463345wrr.406.1583742890451; Mon, 09 Mar 2020 01:34:50 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com Subject: [PATCH v2 2/4] virtio-net: implement RSS configuration command Date: Mon, 9 Mar 2020 10:34:36 +0200 Message-Id: <20200309083438.2389-3-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200309083438.2389-1-yuri.benditovich@daynix.com> References: <20200309083438.2389-1-yuri.benditovich@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 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 | 148 +++++++++++++++++++++++++++++++-- include/hw/virtio/virtio-net.h | 11 +++ 3 files changed, 153 insertions(+), 9 deletions(-) diff --git a/hw/net/trace-events b/hw/net/trace-events index a1da98a643..9823480d91 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -371,6 +371,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(int error_case) "case %d" +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 9545b0e84f..27071eccd2 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -172,6 +172,16 @@ struct virtio_net_rss_config { 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 @@ -203,6 +213,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 @@ -233,6 +245,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 @@ -796,6 +813,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 @@ -955,6 +973,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, @@ -1231,25 +1250,134 @@ 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; + int err; + + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_RSS)) { + err =3D 1; + 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 =3D 2; + 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 =3D 3; + goto error; + } + if (n->rss_data.indirections_len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { + err =3D 4; + 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 =3D 5; + goto error; + } + offset +=3D size_get; + size_get =3D sizeof(uint16_t) * n->rss_data.indirections_len; + s =3D iov_to_buf(iov, iov_cnt, offset, n->rss_data.indirections, size_= get); + if (s !=3D size_get) { + err =3D 10; + goto error; + } + for (i =3D 0; i < n->rss_data.indirections_len; ++i) { + uint16_t val =3D n->rss_data.indirections[i]; + n->rss_data.indirections[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 =3D 11; + goto error; + } + queues =3D virtio_lduw_p(vdev, &temp.us); + if (queues =3D=3D 0 || queues > n->max_queues) { + err =3D 12; + goto error; + } + if (temp.b > VIRTIO_NET_RSS_MAX_KEY_SIZE) { + err =3D 13; + goto error; + } + if (!temp.b && n->rss_data.hash_types) { + err =3D 20; + 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 =3D 21; + 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: + warn_report("%s: error_case %d", __func__, err); + trace_virtio_net_rss_error(err); + 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 || @@ -3304,6 +3432,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..cf16f5192e 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -126,6 +126,9 @@ 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 VirtIONetQueue { VirtQueue *rx_vq; VirtQueue *tx_vq; @@ -199,6 +202,14 @@ struct VirtIONet { bool failover; DeviceListener primary_listener; Notifier migration_state; + struct { + bool enabled; + uint32_t hash_types; + uint8_t key[VIRTIO_NET_RSS_MAX_KEY_SIZE]; + uint16_t indirections[VIRTIO_NET_RSS_MAX_TABLE_LEN]; + uint16_t indirections_len; + uint16_t default_queue; + } rss_data; }; =20 void virtio_net_set_netclient_name(VirtIONet *n, const char *name, --=20 2.17.1 From nobody Fri May 17 10:44:32 2024 Delivered-To: importer@patchew.org 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; 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=1583743522; cv=none; d=zohomail.com; s=zohoarc; b=MJgl/zUjFBW+RbKcuCFZXPzcXMvhHw2HuTDZAzxkdemYNMd57azS1aXjiH2Oz4hGMXtMf5mwfIok3XRLYIFuZySWF1+vaq9YFhq7TPintdlMR3Ba/RjsVpUXTgfqst6OO47JI89JveCNfuoKY+MISTrWiJzAa3hIfSjvuSNGX5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583743522; 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=GtBl5NGPRd3fWz+5/kWPEnRPZvuPWKDkS2vvT0gB+Y8=; b=GAzTfdF0OwaQdR6AcLVlG5zs8mCEyeWylkrEOASJqk2xtnSzwFG0mr4/1khRB3A8mMcydRFiUffpDF5LIbzmtNqzUO+PkIPcH29GbJeODPLwm6oVwJ5J33s5CdTW0/udZoV3zLMCff9gcLbWQSOt4SV+6knP6Yu6SvbF81M6pLA= 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 1583743522277789.5454275884629; Mon, 9 Mar 2020 01:45:22 -0700 (PDT) Received: from localhost ([::1]:38812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBE2L-0000wl-1U for importer@patchew.org; Mon, 09 Mar 2020 04:45:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47274) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBDsE-0007dl-FQ for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBDsD-0007MZ-3u for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:54 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:38939) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jBDsC-0007Kj-TC for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:53 -0400 Received: by mail-wr1-x442.google.com with SMTP id r15so4817921wrx.6 for ; Mon, 09 Mar 2020 01:34:52 -0700 (PDT) Received: from f2.redhat.com (bzq-79-177-42-131.red.bezeqint.net. [79.177.42.131]) by smtp.gmail.com with ESMTPSA id h3sm63749726wrb.23.2020.03.09.01.34.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Mar 2020 01:34: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=GtBl5NGPRd3fWz+5/kWPEnRPZvuPWKDkS2vvT0gB+Y8=; b=AzQp7wlG4j1Vug7B6otwVfXrbmxO6FKa1Hdz1wLgzXVqpnRcBbV4602Fy2km70c9KH J5qq6BOgA5QJIfYliiOeFEu3L+00Szawzay6+c43eb4T+TXYccjdU+NcvRMyh69cbAda hiY56rTNDMDCWo5UMp5uPNVWFqIXiRbo12Q1BBRcu1mumqIZdVKeRstlqHAkkyav9zSJ 8n5kgpPgtz1Jff8PBBAOJL4TMCnyFzsl4Ic7Z/bZ64D0hlbMLr5oWFIgSLCQpqbSjJ6J QFPmolf26nk8DkVXreRQAMY75ZLcgrutLorLjL+AdcnlDyNYBiTvnknd3yRov2LL3CyG EpHw== 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=GtBl5NGPRd3fWz+5/kWPEnRPZvuPWKDkS2vvT0gB+Y8=; b=Tit7IXJ+vLBWPDAHydeQRXfzOarPkMgv+93A+yMXIMZeYeTF3jWkGLZ9pj8tR0UbIg DtR0RNCrfp/T5Jbn7yVUV4AEAnR8VEijUdFE5ZHlfLTiCR6aCAGkDtRYIB9CPnOgDXSC wTqf4XkErwBaRLalq8KsBEbkzJ265BjmIvJtrYqZs/HdHnilVO5XieCl21jh84tQtdPl KLNBOCANGSu6zhBV61/qq4o4vMCu9ZyOgQ0sq4ar8pXkI+RA3jKos26aaioZ9mF1/3hh 10UiOHHy2WhBdSDsZwdVKqd/S5mestn+IlFgvJtYmPRqfrqlRbgLU6EQGJIF8nFeX0HW dOUw== X-Gm-Message-State: ANhLgQ3qhx6VaBwFDfGq84ogDX1ryrC3R2zYI/aoWiUmwnwrC3mEVkBL LmpYwaPDpLbnmEocmSz6UD4w2y35UFKZ8A== X-Google-Smtp-Source: ADFU+vvN56lUur+d0DJwlbJkjVd/SFS8A+y6mIhn3EQOfwCYwlWEdan96nmfk7BGKJBaIuybEoC13w== X-Received: by 2002:adf:de10:: with SMTP id b16mr18932617wrm.145.1583742891592; Mon, 09 Mar 2020 01:34:51 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com Subject: [PATCH v2 3/4] virtio-net: implement RX RSS processing Date: Mon, 9 Mar 2020 10:34:37 +0200 Message-Id: <20200309083438.2389-4-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200309083438.2389-1-yuri.benditovich@daynix.com> References: <20200309083438.2389-1-yuri.benditovich@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 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 | 86 +++++++++++++++++++++++++++++++++- include/hw/virtio/virtio-net.h | 1 + 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 27071eccd2..abc41fdb16 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 @@ -1610,8 +1611,78 @@ 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) +{ + uint32_t mask; + 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) { + mask =3D VIRTIO_NET_RSS_HASH_TYPE_TCP_EX | VIRTIO_NET_RSS_HASH_TYP= E_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->rss_data.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[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); @@ -1625,6 +1696,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; @@ -1719,7 +1798,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, @@ -3295,6 +3374,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->rss_data.pkt, false); } =20 static void virtio_net_device_unrealize(DeviceState *dev, Error **errp) @@ -3331,6 +3412,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); + net_rx_pkt_uninit(n->rss_data.pkt); virtio_cleanup(vdev); } =20 diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index cf16f5192e..45670dd054 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -209,6 +209,7 @@ struct VirtIONet { uint16_t indirections[VIRTIO_NET_RSS_MAX_TABLE_LEN]; uint16_t indirections_len; uint16_t default_queue; + struct NetRxPkt *pkt; } rss_data; }; =20 --=20 2.17.1 From nobody Fri May 17 10:44:32 2024 Delivered-To: importer@patchew.org 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; 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=1583743615; cv=none; d=zohomail.com; s=zohoarc; b=UnYjK5Q41yKDUovxoAQtqjMMBsYeUPbos6Mya3jv7nXLvWpdx4nbfImPbpjC6R/3mMw+Q/1pktXiOoHGIisL0KLyG7ptch6njPWxdP+F8NQ7C4jHYJBbKGuf+PnZg3YnVDZ7fEJv0oK7EnIBTBdNC39s8e7K7tWekUFuAUlekFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583743615; 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=qwff9geVcA9Ofl81vgC89M4fcI3BmCYQGSyZyytOdBU=; b=Zhhe/MO3H/P91X6u0W8rMWaE4hGHx3dPFF5Gp5NJmpGaLl8YlqX1sdiOZ62apYZyn37KOL5jsTr3mCoIHxzW5+XHrWi+xZIJRsB3Q9vlP5IJH98WW96R2vyUlUtq/h5LYWU5CCc79eNoUUkKJBxBUXDHpPvqdvUehK++ypyFTks= 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 1583743615442112.4233572183033; Mon, 9 Mar 2020 01:46:55 -0700 (PDT) Received: from localhost ([::1]:38884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBE3q-0002ek-4S for importer@patchew.org; Mon, 09 Mar 2020 04:46:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47285) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBDsF-0007fo-6b for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBDsE-0007Ol-3X for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:55 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39817) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jBDsD-0007NG-SL for qemu-devel@nongnu.org; Mon, 09 Mar 2020 04:34:54 -0400 Received: by mail-wm1-x342.google.com with SMTP id f7so4204401wml.4 for ; Mon, 09 Mar 2020 01:34:53 -0700 (PDT) Received: from f2.redhat.com (bzq-79-177-42-131.red.bezeqint.net. [79.177.42.131]) by smtp.gmail.com with ESMTPSA id h3sm63749726wrb.23.2020.03.09.01.34.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Mar 2020 01:34:52 -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=qwff9geVcA9Ofl81vgC89M4fcI3BmCYQGSyZyytOdBU=; b=qnltBC7yVakg4nqdoErtT2D3DClG3hrzoJeqQTbHxsSu6xjOcKmoRlZoyUPJ/FuZqC NtkbhXIliOaIO0fHOMAus7ReOo5jdLrtZVUlnxgwGzfB6dRiz3QJfYDHqfvnLwOWnK6V 4M+SEu2cj9x5ywQOJYGMVxXWJ798wxHglx8kfpioHz5LDSktiS1abDLX4N1fgXCKDT8a kfPEYmQKllM5e5FoQGGPyPEX9sN1v95+olwZRd5jN8Zx4dTijR3iwhzQATOX0SAvzY/F 0X0u84WfK5QF6vLkKBJaUHBQgCPbrautaeppeblHpvnKxu6P1DLgkN+d3MnzbAqjTdda mfGA== 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=qwff9geVcA9Ofl81vgC89M4fcI3BmCYQGSyZyytOdBU=; b=M56f2I0/15gOD1pmyIVc+Rmf2r+ho6V8nPfegzEQXC7zqIkM07ZGjKsu78dFIXYfqz dgd+mb74VC5xMmIohllLQnrYhKsDPItnbRQr6sp+Zxhywjv9NhmaYDtgSevD81Ms9IH+ 3r6jaRwbD6YPvW4pczwtSx7jdirIDqmBBPpDjbW+tRm9aYKReHzJG0Fob/OgO1dpMM5z Fsfz27HjYIO9diiiNPVIrlll7C/R+uYRfnmXpHkvI0ghFXiwbls25z8DRX+pT2mtDVrU 7FQodxTMq5iXfBNHHh0h03FeXYKCvKISklMNnDQWRPhD6nlScyZIWE7vNwOSlyZdVAXp PqAA== X-Gm-Message-State: ANhLgQ08XUKM5YOxIhOl6S7UuJ4e9fvlev2C0Nk2EU19HL/zrlgV3ZVP 6/FpoJ85liwRcfs/dvBJ8L6Jgp4wbUVi7w== X-Google-Smtp-Source: ADFU+vsWax8EvBxUUSu4b017CHsX2Y62Vq1glMujvpYYGxwHtHTxCn7b1dX/DC4aO8gS4rHq52CESQ== X-Received: by 2002:a1c:e341:: with SMTP id a62mr7003260wmh.121.1583742892693; Mon, 09 Mar 2020 01:34:52 -0700 (PDT) From: Yuri Benditovich To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com Subject: [PATCH v2 4/4] virtio-net: block migration if RSS feature negotiated Date: Mon, 9 Mar 2020 10:34:38 +0200 Message-Id: <20200309083438.2389-5-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200309083438.2389-1-yuri.benditovich@daynix.com> References: <20200309083438.2389-1-yuri.benditovich@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 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" Block migration for reference implementation of RSS feature in QEMU. When we add support for RSS on backend side, we'll implement migration of current RSS settings. Signed-off-by: Yuri Benditovich --- hw/net/virtio-net.c | 18 ++++++++++++++++++ include/hw/virtio/virtio-net.h | 1 + 2 files changed, 19 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index abc41fdb16..943d1931a2 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -37,6 +37,7 @@ #include "qapi/qapi-events-migration.h" #include "hw/virtio/virtio-access.h" #include "migration/misc.h" +#include "migration/blocker.h" #include "standard-headers/linux/ethtool.h" #include "sysemu/sysemu.h" #include "trace.h" @@ -627,6 +628,12 @@ static void virtio_net_reset(VirtIODevice *vdev) n->announce_timer.round =3D 0; n->status &=3D ~VIRTIO_NET_S_ANNOUNCE; =20 + if (n->migration_blocker) { + migrate_del_blocker(n->migration_blocker); + error_free(n->migration_blocker); + n->migration_blocker =3D NULL; + } + /* Flush any MAC and VLAN filter table state */ n->mac_table.in_use =3D 0; n->mac_table.first_multi =3D 0; @@ -1003,6 +1010,17 @@ static void virtio_net_set_features(VirtIODevice *vd= ev, uint64_t features) vhost_net_ack_features(get_vhost_net(nc->peer), features); } =20 + if (virtio_has_feature(features, VIRTIO_NET_F_RSS)) { + if (!n->migration_blocker) { + error_setg(&n->migration_blocker, "virtio-net: RSS negotiated"= ); + migrate_add_blocker(n->migration_blocker, &err); + if (err) { + error_report_err(err); + err =3D NULL; + } + } + } + if (virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) { memset(n->vlans, 0, MAX_VLAN >> 3); } else { diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 45670dd054..fba768ba9b 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -180,6 +180,7 @@ struct VirtIONet { virtio_net_conf net_conf; NICConf nic_conf; DeviceState *qdev; + Error *migration_blocker; int multiqueue; uint16_t max_queues; uint16_t curr_queues; --=20 2.17.1