Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrew Melnichenko <andrew@daynix.com>
To: Jason Wang <jasowang@redhat.com>
Cc: netdev@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, davem@davemloft.net,
	kuba@kernel.org, "Michael S. Tsirkin" <mst@redhat.com>,
	Yan Vugenfirer <yan@daynix.com>,
	Yuri Benditovich <yuri.benditovich@daynix.com>
Subject: Re: [PATCH 3/4] drivers/net/virtio_net: Added RSS hash report.
Date: Mon, 17 Jan 2022 09:57:14 +0200	[thread overview]
Message-ID: <CABcq3pFVPfqO6EYzWHnzDWxCW+68DHNZgxqViG2HB-3fyT-GEQ@mail.gmail.com> (raw)
In-Reply-To: <60f24351-1011-de84-b443-ff5a50c3ff7f@redhat.com>

Hi all.

> I think we should make RSS depend on CTRL_VQ.
> Need to depend on CTRL_VQ here.
I'll fix that.

> Any reason to initialize RSS feature here not the init_default_rss()?
init_default_rss() initializes virtio_net_ctrl_rss structure only, I
think it's a good idea not to mix field initializations.

On Tue, Jan 11, 2022 at 6:06 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> 在 2022/1/10 上午5:06, Andrew Melnychenko 写道:
> > 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 <andrew@daynix.com>
> > ---
> >   drivers/net/virtio_net.c | 56 ++++++++++++++++++++++++++++++++++------
> >   1 file changed, 48 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index 21794731fc75..6e7461b01f87 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -231,6 +231,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;
> > @@ -424,7 +425,9 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
> >       hdr_p = p;
> >
> >       hdr_len = vi->hdr_len;
> > -     if (vi->mergeable_rx_bufs)
> > +     if (vi->has_rss_hash_report)
> > +             hdr_padded_len = sizeof(struct virtio_net_hdr_v1_hash);
> > +     else if (vi->mergeable_rx_bufs)
> >               hdr_padded_len = sizeof(*hdr);
> >       else
> >               hdr_padded_len = sizeof(struct padded_vnet_hdr);
> > @@ -1160,6 +1163,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);
> > @@ -1186,6 +1191,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) {
> > +             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);
> > +     }
> >
> >       if (hdr->hdr.flags & VIRTIO_NET_HDR_F_DATA_VALID)
> >               skb->ip_summed = CHECKSUM_UNNECESSARY;
> > @@ -2233,7 +2261,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;
> >       }
> > @@ -3220,7 +3249,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)
> >            VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_MQ, "VIRTIO_NET_F_CTRL_VQ") ||
> >            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_RSS"))) {
> > +          VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_RSS, "VIRTIO_NET_F_RSS") ||
>
>
> I think we should make RSS depend on CTRL_VQ.
>
>
> > +          VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_HASH_REPORT,
> > +                          "VIRTIO_NET_F_HASH_REPORT"))) {
>
>
> Need to depend on CTRL_VQ here.
>
>
> >               return false;
> >       }
> >
> > @@ -3355,6 +3386,12 @@ 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_HASH_REPORT)) {
> > +             vi->has_rss_hash_report = true;
> > +             vi->rss_indir_table_size = 1;
> > +             vi->rss_key_size = VIRTIO_NET_RSS_MAX_KEY_SIZE;
>
>
> Any reason to initialize RSS feature here not the init_default_rss()?
>
> Thanks
>
>
> > +     }
> > +
> >       if (virtio_has_feature(vdev, VIRTIO_NET_F_RSS)) {
> >               vi->has_rss = true;
> >               vi->rss_indir_table_size =
> > @@ -3364,7 +3401,7 @@ static int virtnet_probe(struct virtio_device *vdev)
> >                       virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));
> >       }
> >
> > -     if (vi->has_rss) {
> > +     if (vi->has_rss || vi->has_rss_hash_report) {
> >               vi->rss_hash_types_supported =
> >                   virtio_cread32(vdev, offsetof(struct virtio_net_config, supported_hash_types));
> >               vi->rss_hash_types_supported &=
> > @@ -3374,8 +3411,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);
> > @@ -3442,7 +3482,7 @@ static int virtnet_probe(struct virtio_device *vdev)
> >               }
> >       }
> >
> > -     if (vi->has_rss) {
> > +     if (vi->has_rss || vi->has_rss_hash_report) {
> >               rtnl_lock();
> >               virtnet_init_default_rss(vi);
> >               rtnl_unlock();
> > @@ -3580,7 +3620,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,
>

  reply	other threads:[~2022-01-17  7:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09 21:06 [PATCH 0/4] RSS support for VirtioNet Andrew Melnychenko
2022-01-09 21:06 ` [PATCH 1/4] drivers/net/virtio_net: Fixed padded vheader to use v1 with hash Andrew Melnychenko
2022-01-09 22:21   ` Jakub Kicinski
2022-01-09 21:06 ` [PATCH 2/4] drivers/net/virtio_net: Added basic RSS support Andrew Melnychenko
2022-01-11  3:44   ` Jason Wang
2022-01-11 12:00   ` Michael S. Tsirkin
2022-01-17  7:49     ` Andrew Melnichenko
2022-01-09 21:06 ` [PATCH 3/4] drivers/net/virtio_net: Added RSS hash report Andrew Melnychenko
2022-01-11  4:05   ` Jason Wang
2022-01-17  7:57     ` Andrew Melnichenko [this message]
2022-01-09 21:06 ` [PATCH 4/4] drivers/net/virtio_net: Added RSS hash report control Andrew Melnychenko
2022-01-11  4:32   ` Jason Wang
2022-01-17  7:58     ` Andrew Melnichenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABcq3pFVPfqO6EYzWHnzDWxCW+68DHNZgxqViG2HB-3fyT-GEQ@mail.gmail.com \
    --to=andrew@daynix.com \
    --cc=davem@davemloft.net \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=yan@daynix.com \
    --cc=yuri.benditovich@daynix.com \
    --subject='Re: [PATCH 3/4] drivers/net/virtio_net: Added RSS hash report.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).