Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1683958pxb; Wed, 9 Feb 2022 02:06:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyo1je1HeUzrhVxtPKW36v/DnLc1tFoCU0n1xwzdtxwXreytfTs2N44ID8wSKDAHzCELPpQ X-Received: by 2002:a17:902:c652:: with SMTP id s18mr1705412pls.104.1644401213376; Wed, 09 Feb 2022 02:06:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644401213; cv=none; d=google.com; s=arc-20160816; b=rIKAUUUFGMWvAysbO90W3qcEpIImZF9Y0yX/yg3SohR74IfwUd3G/x6fQ3HhiNA7uF qTgQhun4Qsgj8bXysAacGAQ5e51nlwL4debgjaV2CMFaWDry0PALRe8/vOvjQEjlw4ZS VJSjxHFvI42GVBPq59bWQe7npWNXAe9xCDWFXgWFz/TSS9s+W1Shuw2vVGTR4EIU8Hyx gkJQrE6fV8Kl5212oBeXt1ZHZE2z004ZXQcTRT6BXl3Y4lprDBo6fjJQzoOYSNVF1fZE /I46DlhjGy39S2dINkU+uFpg0msLaoivVxlhiiV6rJDgQfsoOm+7EuzNiSrj3JB/4l6O l2Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Dav5GHwHoInVNFFUmD/+H7rFBilhhPolISX4pLfyPgs=; b=uoM2XFcABzVgQznASEdyrsxoUKH4uBq9VDVyQhIw7h1DnJ5s9eRdfjQFMxi4yz8KBu MFnXu/WO3xxeVIQ1hcgW89KY7vdHBGuDjMz/fB26omrIYnqA1wkBIl0lXmzsXKT0CRkS Y9xJgG4jl6PfyGZZOFCp7iY8Nxattr5t7z0cSvWGjwo1I5C+I9N9+OCA2vGvai01RgpM MtGcEvJBYZovJFeC8sJ0R3A4mTInnKfmff9rUu89cDWx8oZqTnMsKgCe0FY6Thv3a7SU Yv9f+iHKtMM+rbAy2vIZhgWteydcLKCr/NwLulGAX1ETe8KrxSqbHC1Q7K8M9I4bKRzP MJKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=I35aftOG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 11si15384476pfl.113.2022.02.09.02.06.40; Wed, 09 Feb 2022 02:06:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=I35aftOG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387809AbiBHW2p (ORCPT + 99 others); Tue, 8 Feb 2022 17:28:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386582AbiBHUzS (ORCPT ); Tue, 8 Feb 2022 15:55:18 -0500 Received: from mail-vk1-xa2a.google.com (mail-vk1-xa2a.google.com [IPv6:2607:f8b0:4864:20::a2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EE5EC0612B8 for ; Tue, 8 Feb 2022 12:55:16 -0800 (PST) Received: by mail-vk1-xa2a.google.com with SMTP id b2so52170vkl.1 for ; Tue, 08 Feb 2022 12:55:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Dav5GHwHoInVNFFUmD/+H7rFBilhhPolISX4pLfyPgs=; b=I35aftOGkLR/ISv6OSLuGuNra4KAzA0XXAvR3HIzqJsZ4sbzSCT6m6eUErRZTsBdRZ 5zHFtqoTfYTj0VaC44XixtJmomtIqu6M2jaGsuJVIFo9NFo73pcMfzY6Ib6daRmOQQ6G s61LlDd0JuL2BDMhfXFEtfUTzv8Gb82qMMbR0G9yretQLwALK2QmdEaFwNvtCZ+xTHcw YsKyu3HM3enCJRsm6D5qPoryva8Zw7Tulo94jtMwvcQWakEadP5Kr9mEupdTsILy1yjH aZAW1pjsKR/HlEntXIBoRge+jo1q74UJiwiUyNQKf6AdaelrV1Cb0N0B5Vj6vewPaFM1 JBSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Dav5GHwHoInVNFFUmD/+H7rFBilhhPolISX4pLfyPgs=; b=tlWZstrnbgGB+H37pN6QWDzlw6P+RHjjy+926YNDTKXoAvoDalTaazQCPzjF9LmH0x 3ZE8kIdd4iG9TpOs13AsM+vUmHNCUX5vAQWqj+e9XOPxXeSM3iT/ewKN+b5AQiE1Swop qxjRQU/Rmpak/oezglZxKvxjFgzZCf2pN0bGizV0KD+ySLNPl5+QAuZybIXjB0e09oQK DZEMCWVgSEXny+yOzxSTi+ouba0nbQUYMdX9R+DFpuCvqFGs4vKJp2r2cQjK9Y/mgAl9 nnfv8hc0hTd5j0T2cXRsK9WyUUiIFz8MGZ9eIXphe+6xvDJO8O91NPjoxsUnmxczWFXB jAgw== X-Gm-Message-State: AOAM533nzMVdhbvMfyxTI1vgR7fMEf+OxKsUw9sgwmyWOblfSWxB2DUv q5vGvX8stIl8yf2MJGUxyuA+8IRZoSEQfA== X-Received: by 2002:a05:6122:202a:: with SMTP id l42mr2456574vkd.40.1644353715549; Tue, 08 Feb 2022 12:55:15 -0800 (PST) Received: from mail-ua1-f48.google.com (mail-ua1-f48.google.com. [209.85.222.48]) by smtp.gmail.com with ESMTPSA id s15sm3164838uao.17.2022.02.08.12.55.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Feb 2022 12:55:15 -0800 (PST) Received: by mail-ua1-f48.google.com with SMTP id 60so263577uae.1 for ; Tue, 08 Feb 2022 12:55:15 -0800 (PST) X-Received: by 2002:ab0:6718:: with SMTP id q24mr1146421uam.141.1644353714675; Tue, 08 Feb 2022 12:55:14 -0800 (PST) MIME-Version: 1.0 References: <20220208181510.787069-1-andrew@daynix.com> <20220208181510.787069-4-andrew@daynix.com> In-Reply-To: <20220208181510.787069-4-andrew@daynix.com> From: Willem de Bruijn Date: Tue, 8 Feb 2022 15:54:38 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 3/4] drivers/net/virtio_net: Added RSS hash report. To: Andrew Melnychenko Cc: netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, jasowang@redhat.com, mst@redhat.com, yan@daynix.com, yuri.benditovich@daynix.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 8, 2022 at 1:19 PM Andrew Melnychenko wrote: > > Added features for RSS hash report. > If hash is provided - it sets to skb. > Added checks if rss and/or hash are enabled together. > > Signed-off-by: Andrew Melnychenko > --- > drivers/net/virtio_net.c | 51 ++++++++++++++++++++++++++++++++++------ > 1 file changed, 44 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 495aed524e33..543da2fbdd2d 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -227,6 +227,7 @@ struct virtnet_info { > > /* Host supports rss and/or hash report */ > bool has_rss; > + bool has_rss_hash_report; > u8 rss_key_size; > u16 rss_indir_table_size; > u32 rss_hash_types_supported; > @@ -421,7 +422,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi, > > hdr_len = vi->hdr_len; > if (vi->mergeable_rx_bufs) > - hdr_padded_len = sizeof(*hdr); > + hdr_padded_len = hdr_len; Belongs in patch 1? > else > hdr_padded_len = sizeof(struct padded_vnet_hdr); > > @@ -1156,6 +1157,8 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq, > struct net_device *dev = vi->dev; > struct sk_buff *skb; > struct virtio_net_hdr_mrg_rxbuf *hdr; > + struct virtio_net_hdr_v1_hash *hdr_hash; > + enum pkt_hash_types rss_hash_type; > > if (unlikely(len < vi->hdr_len + ETH_HLEN)) { > pr_debug("%s: short packet %i\n", dev->name, len); > @@ -1182,6 +1185,29 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq, > return; > > hdr = skb_vnet_hdr(skb); > + if (dev->features & NETIF_F_RXHASH && vi->has_rss_hash_report) { Can the first be true if the second is not? > + hdr_hash = (struct virtio_net_hdr_v1_hash *)(hdr); > + > + switch (hdr_hash->hash_report) { > + case VIRTIO_NET_HASH_REPORT_TCPv4: > + case VIRTIO_NET_HASH_REPORT_UDPv4: > + case VIRTIO_NET_HASH_REPORT_TCPv6: > + case VIRTIO_NET_HASH_REPORT_UDPv6: > + case VIRTIO_NET_HASH_REPORT_TCPv6_EX: > + case VIRTIO_NET_HASH_REPORT_UDPv6_EX: > + rss_hash_type = PKT_HASH_TYPE_L4; > + break; > + case VIRTIO_NET_HASH_REPORT_IPv4: > + case VIRTIO_NET_HASH_REPORT_IPv6: > + case VIRTIO_NET_HASH_REPORT_IPv6_EX: > + rss_hash_type = PKT_HASH_TYPE_L3; > + break; > + case VIRTIO_NET_HASH_REPORT_NONE: > + default: > + rss_hash_type = PKT_HASH_TYPE_NONE; > + } > + skb_set_hash(skb, hdr_hash->hash_value, rss_hash_type); > + } so many lines, perhaps deserves a helper function > > if (hdr->hdr.flags & VIRTIO_NET_HDR_F_DATA_VALID) > skb->ip_summed = CHECKSUM_UNNECESSARY; > @@ -2232,7 +2258,8 @@ static bool virtnet_commit_rss_command(struct virtnet_info *vi) > sg_set_buf(&sgs[3], vi->ctrl->rss.key, sg_buf_size); > > if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ, > - VIRTIO_NET_CTRL_MQ_RSS_CONFIG, sgs)) { > + vi->has_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG > + : VIRTIO_NET_CTRL_MQ_HASH_CONFIG, sgs)) { > dev_warn(&dev->dev, "VIRTIONET issue with committing RSS sgs\n"); > return false; > } > @@ -3230,6 +3257,8 @@ static bool virtnet_validate_features(struct virtio_device *vdev) > VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR, > "VIRTIO_NET_F_CTRL_VQ") || > VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_RSS, > + "VIRTIO_NET_F_CTRL_VQ") || > + VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_HASH_REPORT, > "VIRTIO_NET_F_CTRL_VQ"))) { > return false; > } > @@ -3365,8 +3394,13 @@ static int virtnet_probe(struct virtio_device *vdev) > if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) > vi->mergeable_rx_bufs = true; > > - if (virtio_has_feature(vdev, VIRTIO_NET_F_RSS)) { > + if (virtio_has_feature(vdev, VIRTIO_NET_F_HASH_REPORT)) > + vi->has_rss_hash_report = true; > + > + if (virtio_has_feature(vdev, VIRTIO_NET_F_RSS)) > vi->has_rss = true; > + > + if (vi->has_rss || vi->has_rss_hash_report) { > vi->rss_indir_table_size = > virtio_cread16(vdev, offsetof(struct virtio_net_config, should indir table size be zero if only hash report is enabled? > rss_max_indirection_table_length)); > @@ -3382,8 +3416,11 @@ static int virtnet_probe(struct virtio_device *vdev) > > dev->hw_features |= NETIF_F_RXHASH; > } > - if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF) || > - virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) > + > + if (vi->has_rss_hash_report) > + vi->hdr_len = sizeof(struct virtio_net_hdr_v1_hash); > + else if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF) || > + virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) > vi->hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf); > else > vi->hdr_len = sizeof(struct virtio_net_hdr); > @@ -3450,7 +3487,7 @@ static int virtnet_probe(struct virtio_device *vdev) > } > } > > - if (vi->has_rss) > + if (vi->has_rss || vi->has_rss_hash_report) > virtnet_init_default_rss(vi); > > err = register_netdev(dev); > @@ -3585,7 +3622,7 @@ static struct virtio_device_id id_table[] = { > VIRTIO_NET_F_CTRL_MAC_ADDR, \ > VIRTIO_NET_F_MTU, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, \ > VIRTIO_NET_F_SPEED_DUPLEX, VIRTIO_NET_F_STANDBY, \ > - VIRTIO_NET_F_RSS > + VIRTIO_NET_F_RSS, VIRTIO_NET_F_HASH_REPORT > > static unsigned int features[] = { > VIRTNET_FEATURES, > -- > 2.34.1 >