[PATCH 31/40] igb: Use UDP for RSS hash

Akihiko Odaki posted 40 patches 2 years, 10 months ago
There is a newer version of this series
[PATCH 31/40] igb: Use UDP for RSS hash
Posted by Akihiko Odaki 2 years, 10 months ago
e1000e does not support using UDP for RSS hash, but igb does.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 hw/net/igb_core.c | 16 ++++++++++++++++
 hw/net/igb_regs.h |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
index 569897fb99..3ad81b15d0 100644
--- a/hw/net/igb_core.c
+++ b/hw/net/igb_core.c
@@ -279,6 +279,11 @@ igb_rss_get_hash_type(IGBCore *core, struct NetRxPkt *pkt)
             return E1000_MRQ_RSS_TYPE_IPV4TCP;
         }
 
+        if (l4hdr_proto == ETH_L4_HDR_PROTO_UDP &&
+            (core->mac[MRQC] & E1000_MRQC_RSS_FIELD_IPV4_UDP)) {
+            return E1000_MRQ_RSS_TYPE_IPV4UDP;
+        }
+
         if (E1000_MRQC_EN_IPV4(core->mac[MRQC])) {
             return E1000_MRQ_RSS_TYPE_IPV4;
         }
@@ -314,6 +319,11 @@ igb_rss_get_hash_type(IGBCore *core, struct NetRxPkt *pkt)
                 return E1000_MRQ_RSS_TYPE_IPV6TCP;
             }
 
+            if (l4hdr_proto == ETH_L4_HDR_PROTO_UDP &&
+                (core->mac[MRQC] & E1000_MRQC_RSS_FIELD_IPV6_UDP)) {
+                return E1000_MRQ_RSS_TYPE_IPV6UDP;
+            }
+
             if (E1000_MRQC_EN_IPV6EX(core->mac[MRQC])) {
                 return E1000_MRQ_RSS_TYPE_IPV6EX;
             }
@@ -352,6 +362,12 @@ igb_rss_calc_hash(IGBCore *core, struct NetRxPkt *pkt, E1000E_RSSInfo *info)
     case E1000_MRQ_RSS_TYPE_IPV6EX:
         type = NetPktRssIpV6Ex;
         break;
+    case E1000_MRQ_RSS_TYPE_IPV4UDP:
+        type = NetPktRssIpV4Udp;
+        break;
+    case E1000_MRQ_RSS_TYPE_IPV6UDP:
+        type = NetPktRssIpV6Udp;
+        break;
     default:
         assert(false);
         return 0;
diff --git a/hw/net/igb_regs.h b/hw/net/igb_regs.h
index 22ce909173..03486edb2e 100644
--- a/hw/net/igb_regs.h
+++ b/hw/net/igb_regs.h
@@ -659,6 +659,9 @@ union e1000_adv_rx_desc {
 
 #define E1000_RSS_QUEUE(reta, hash) (E1000_RETA_VAL(reta, hash) & 0x0F)
 
+#define E1000_MRQ_RSS_TYPE_IPV4UDP 7
+#define E1000_MRQ_RSS_TYPE_IPV6UDP 8
+
 #define E1000_STATUS_IOV_MODE 0x00040000
 
 #define E1000_STATUS_NUM_VFS_SHIFT 14
-- 
2.40.0
RE: [PATCH 31/40] igb: Use UDP for RSS hash
Posted by Sriram Yagnaraman 2 years, 10 months ago

> -----Original Message-----
> From: Akihiko Odaki <akihiko.odaki@daynix.com>
> Sent: Friday, 14 April 2023 13:37
> Cc: Sriram Yagnaraman <sriram.yagnaraman@est.tech>; Jason Wang
> <jasowang@redhat.com>; Dmitry Fleytman <dmitry.fleytman@gmail.com>;
> Michael S. Tsirkin <mst@redhat.com>; Alex Bennée <alex.bennee@linaro.org>;
> Philippe Mathieu-Daudé <philmd@linaro.org>; Thomas Huth
> <thuth@redhat.com>; Wainer dos Santos Moschetta
> <wainersm@redhat.com>; Beraldo Leal <bleal@redhat.com>; Cleber Rosa
> <crosa@redhat.com>; Laurent Vivier <lvivier@redhat.com>; Paolo Bonzini
> <pbonzini@redhat.com>; qemu-devel@nongnu.org; Akihiko Odaki
> <akihiko.odaki@daynix.com>
> Subject: [PATCH 31/40] igb: Use UDP for RSS hash
> 
> e1000e does not support using UDP for RSS hash, but igb does.
> 
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
>  hw/net/igb_core.c | 16 ++++++++++++++++  hw/net/igb_regs.h |  3 +++
>  2 files changed, 19 insertions(+)

Reviewed-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech>

UDP hash types look good to me, but while reviewing this patch I realized MRQC bit 18 is different between igb and e1000e.
igb: MRQC BIT(18) -> TcpIPv6Ex
igb: MRQC BIT(21) -> TcpIPv6
e1000e: MRQC BIT(18) -> TcpIPv6


> diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index
> 569897fb99..3ad81b15d0 100644
> --- a/hw/net/igb_core.c
> +++ b/hw/net/igb_core.c
> @@ -279,6 +279,11 @@ igb_rss_get_hash_type(IGBCore *core, struct
> NetRxPkt *pkt)
>              return E1000_MRQ_RSS_TYPE_IPV4TCP;
>          }
> 
> +        if (l4hdr_proto == ETH_L4_HDR_PROTO_UDP &&
> +            (core->mac[MRQC] & E1000_MRQC_RSS_FIELD_IPV4_UDP)) {
> +            return E1000_MRQ_RSS_TYPE_IPV4UDP;
> +        }
> +
>          if (E1000_MRQC_EN_IPV4(core->mac[MRQC])) {
>              return E1000_MRQ_RSS_TYPE_IPV4;
>          }
> @@ -314,6 +319,11 @@ igb_rss_get_hash_type(IGBCore *core, struct
> NetRxPkt *pkt)
>                  return E1000_MRQ_RSS_TYPE_IPV6TCP;
>              }
> 
> +            if (l4hdr_proto == ETH_L4_HDR_PROTO_UDP &&
> +                (core->mac[MRQC] & E1000_MRQC_RSS_FIELD_IPV6_UDP)) {
> +                return E1000_MRQ_RSS_TYPE_IPV6UDP;
> +            }
> +
>              if (E1000_MRQC_EN_IPV6EX(core->mac[MRQC])) {
>                  return E1000_MRQ_RSS_TYPE_IPV6EX;
>              }
> @@ -352,6 +362,12 @@ igb_rss_calc_hash(IGBCore *core, struct NetRxPkt
> *pkt, E1000E_RSSInfo *info)
>      case E1000_MRQ_RSS_TYPE_IPV6EX:
>          type = NetPktRssIpV6Ex;
>          break;
> +    case E1000_MRQ_RSS_TYPE_IPV4UDP:
> +        type = NetPktRssIpV4Udp;
> +        break;
> +    case E1000_MRQ_RSS_TYPE_IPV6UDP:
> +        type = NetPktRssIpV6Udp;
> +        break;
>      default:
>          assert(false);
>          return 0;
> diff --git a/hw/net/igb_regs.h b/hw/net/igb_regs.h index
> 22ce909173..03486edb2e 100644
> --- a/hw/net/igb_regs.h
> +++ b/hw/net/igb_regs.h
> @@ -659,6 +659,9 @@ union e1000_adv_rx_desc {
> 
>  #define E1000_RSS_QUEUE(reta, hash) (E1000_RETA_VAL(reta, hash) & 0x0F)
> 
> +#define E1000_MRQ_RSS_TYPE_IPV4UDP 7
> +#define E1000_MRQ_RSS_TYPE_IPV6UDP 8
> +
>  #define E1000_STATUS_IOV_MODE 0x00040000
> 
>  #define E1000_STATUS_NUM_VFS_SHIFT 14
> --
> 2.40.0