From: Ahmed Zaki <ahmed.zaki@intel.com>
To: Alexander H Duyck <alexander.duyck@gmail.com>, <netdev@vger.kernel.org>
Cc: <intel-wired-lan@lists.osuosl.org>, <corbet@lwn.net>,
<jesse.brandeburg@intel.com>, <anthony.l.nguyen@intel.com>,
<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <vladimir.oltean@nxp.com>, <andrew@lunn.ch>,
<horms@kernel.org>, <mkubecek@suse.cz>,
<willemdebruijn.kernel@gmail.com>, <linux-doc@vger.kernel.org>,
Wojciech Drewek <wojciech.drewek@intel.com>
Subject: Re: [PATCH net-next v4 1/6] net: ethtool: allow symmetric-xor RSS hash for any flow type
Date: Mon, 16 Oct 2023 15:08:56 -0600 [thread overview]
Message-ID: <26812a57-bdd8-4a39-8dd2-b0ebcfd1073e@intel.com> (raw)
In-Reply-To: <8d1b1494cfd733530be887806385cde70e077ed1.camel@gmail.com>
On 2023-10-16 14:17, Alexander H Duyck wrote:
> On Mon, 2023-10-16 at 09:49 -0600, Ahmed Zaki wrote:
>> Symmetric RSS hash functions are beneficial in applications that monitor
>> both Tx and Rx packets of the same flow (IDS, software firewalls, ..etc).
>> Getting all traffic of the same flow on the same RX queue results in
>> higher CPU cache efficiency.
>>
>> A NIC that supports "symmetric-xor" can achieve this RSS hash symmetry
>> by XORing the source and destination fields and pass the values to the
>> RSS hash algorithm.
>>
>> Only fields that has counterparts in the other direction can be
>> accepted; IP src/dst and L4 src/dst ports.
>>
>> The user may request RSS hash symmetry for a specific flow type, via:
>>
>> # ethtool -N|-U eth0 rx-flow-hash <flow_type> s|d|f|n symmetric-xor
>>
>> or turn symmetry off (asymmetric) by:
>>
>> # ethtool -N|-U eth0 rx-flow-hash <flow_type> s|d|f|n
>>
>> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
>> Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
>> ---
>> Documentation/networking/scaling.rst | 6 ++++++
>> include/uapi/linux/ethtool.h | 21 +++++++++++++--------
>> net/ethtool/ioctl.c | 11 +++++++++++
>> 3 files changed, 30 insertions(+), 8 deletions(-)
>>
>> diff --git a/Documentation/networking/scaling.rst b/Documentation/networking/scaling.rst
>> index 92c9fb46d6a2..64f3d7566407 100644
>> --- a/Documentation/networking/scaling.rst
>> +++ b/Documentation/networking/scaling.rst
>> @@ -44,6 +44,12 @@ by masking out the low order seven bits of the computed hash for the
>> packet (usually a Toeplitz hash), taking this number as a key into the
>> indirection table and reading the corresponding value.
>>
>> +Some NICs support symmetric RSS hashing where, if the IP (source address,
>> +destination address) and TCP/UDP (source port, destination port) tuples
>> +are swapped, the computed hash is the same. This is beneficial in some
>> +applications that monitor TCP/IP flows (IDS, firewalls, ...etc) and need
>> +both directions of the flow to land on the same Rx queue (and CPU).
>> +
>> Some advanced NICs allow steering packets to queues based on
>> programmable filters. For example, webserver bound TCP port 80 packets
>> can be directed to their own receive queue. Such “n-tuple” filters can
>> diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
>> index f7fba0dc87e5..4e8d38fb55ce 100644
>> --- a/include/uapi/linux/ethtool.h
>> +++ b/include/uapi/linux/ethtool.h
>> @@ -2018,14 +2018,19 @@ static inline int ethtool_validate_duplex(__u8 duplex)
>> #define FLOW_RSS 0x20000000
>>
>> /* L3-L4 network traffic flow hash options */
>> -#define RXH_L2DA (1 << 1)
>> -#define RXH_VLAN (1 << 2)
>> -#define RXH_L3_PROTO (1 << 3)
>> -#define RXH_IP_SRC (1 << 4)
>> -#define RXH_IP_DST (1 << 5)
>> -#define RXH_L4_B_0_1 (1 << 6) /* src port in case of TCP/UDP/SCTP */
>> -#define RXH_L4_B_2_3 (1 << 7) /* dst port in case of TCP/UDP/SCTP */
>> -#define RXH_DISCARD (1 << 31)
>> +#define RXH_L2DA (1 << 1)
>> +#define RXH_VLAN (1 << 2)
>> +#define RXH_L3_PROTO (1 << 3)
>> +#define RXH_IP_SRC (1 << 4)
>> +#define RXH_IP_DST (1 << 5)
>> +#define RXH_L4_B_0_1 (1 << 6) /* src port in case of TCP/UDP/SCTP */
>> +#define RXH_L4_B_2_3 (1 << 7) /* dst port in case of TCP/UDP/SCTP */
>> +/* XOR the corresponding source and destination fields of each specified
>> + * protocol. Both copies of the XOR'ed fields are fed into the RSS and RXHASH
>> + * calculation.
>> + */
>> +#define RXH_SYMMETRIC_XOR (1 << 30)
>> +#define RXH_DISCARD (1 << 31)
>
> I guess this has already been discussed but I am not a fan of long
> names for defines. I would prefer to see this just be something like
> RXH_SYMMETRIC or something like that. The XOR is just an implementation
> detail. I have seen the same thing accomplished by just reordering the
> fields by min/max approaches.
Correct. We discussed this and the consensus was that the user needs to
have complete control on which implementation/algorithm is used to
provide this symmetry, because each will yield different hash and may be
different performance.
>
>>
>> #define RX_CLS_FLOW_DISC 0xffffffffffffffffULL
>> #define RX_CLS_FLOW_WAKE 0xfffffffffffffffeULL
>> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
>> index 0b0ce4f81c01..b1bd0d4b48e8 100644
>> --- a/net/ethtool/ioctl.c
>> +++ b/net/ethtool/ioctl.c
>> @@ -980,6 +980,17 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
>> if (rc)
>> return rc;
>>
>> + /* If a symmetric hash is requested, then:
>> + * 1 - no other fields besides IP src/dst and/or L4 src/dst
>> + * 2 - If src is set, dst must also be set
>> + */
>> + if ((info.data & RXH_SYMMETRIC_XOR) &&
>> + ((info.data & ~(RXH_SYMMETRIC_XOR | RXH_IP_SRC | RXH_IP_DST |
>> + RXH_L4_B_0_1 | RXH_L4_B_2_3)) ||
>> + (!!(info.data & RXH_IP_SRC) ^ !!(info.data & RXH_IP_DST)) ||
>> + (!!(info.data & RXH_L4_B_0_1) ^ !!(info.data & RXH_L4_B_2_3))))
>> + return -EINVAL;
>> +
>> rc = dev->ethtool_ops->set_rxnfc(dev, &info);
>> if (rc)
>> return rc;
>
> You are pushing implementation from your device into the interface
> design here. You should probably push these requirements down into the
> driver rather than making it a part of the generic implementation.
This is the most basic check and should be applied in any symmetric RSS
implementation. Nothing specific to the XOR method. It can also be
extended to include other "RXH_SYMMETRIC_XXX" in the future.
next prev parent reply other threads:[~2023-10-16 21:09 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 15:49 [PATCH net-next v4 0/6] Support symmetric RSS (Toeplitz) hash Ahmed Zaki
2023-10-16 15:49 ` [PATCH net-next v4 1/6] net: ethtool: allow symmetric-xor RSS hash for any flow type Ahmed Zaki
2023-10-16 20:17 ` Alexander H Duyck
2023-10-16 21:08 ` Ahmed Zaki [this message]
2023-10-16 22:15 ` Alexander Duyck
2023-10-16 22:44 ` Ahmed Zaki
2023-10-16 22:55 ` Alexander Duyck
2023-10-16 23:30 ` Jakub Kicinski
2023-10-17 0:08 ` Ahmed Zaki
2023-10-17 18:42 ` Alexander Duyck
2023-10-17 19:14 ` Ahmed Zaki
2023-10-17 20:03 ` Alexander Duyck
2023-10-17 20:19 ` Jakub Kicinski
2023-10-17 20:28 ` Alexander Duyck
2023-10-17 18:37 ` Alexander Duyck
2023-10-17 20:17 ` Jakub Kicinski
2023-10-17 20:41 ` Alexander Duyck
2023-10-17 22:12 ` [Intel-wired-lan] " Ahmed Zaki
2023-10-18 0:34 ` Jakub Kicinski
2023-10-18 18:12 ` Alexander Duyck
2023-10-18 23:50 ` Jakub Kicinski
2023-10-20 21:24 ` Ahmed Zaki
2023-10-20 22:33 ` Jakub Kicinski
2023-10-20 23:14 ` [Intel-wired-lan] " Ahmed Zaki
2023-10-20 23:49 ` Jakub Kicinski
2023-10-21 0:00 ` Ahmed Zaki
2023-10-29 12:25 ` Gal Pressman
2023-10-29 12:42 ` Ahmed Zaki
2023-10-29 12:48 ` Gal Pressman
2023-10-29 16:59 ` Ahmed Zaki
2023-10-31 12:00 ` Gal Pressman
2023-10-31 14:40 ` Ahmed Zaki
2023-10-31 14:45 ` Gal Pressman
2023-10-31 15:14 ` Ahmed Zaki
2023-10-31 15:20 ` Jakub Kicinski
2023-10-31 16:13 ` Gal Pressman
2023-10-31 19:57 ` Jakub Kicinski
2023-10-31 16:12 ` Gal Pressman
2023-10-31 14:59 ` Alexander Duyck
2023-10-31 16:11 ` Gal Pressman
2023-10-16 15:49 ` [PATCH net-next v4 2/6] ice: fix ICE_AQ_VSI_Q_OPT_RSS_* register values Ahmed Zaki
2023-10-16 15:49 ` [PATCH net-next v4 3/6] ice: refactor RSS configuration Ahmed Zaki
2023-10-16 15:49 ` [PATCH net-next v4 4/6] ice: refactor the FD and RSS flow ID generation Ahmed Zaki
2023-10-16 15:49 ` [PATCH net-next v4 5/6] ice: enable symmetric RSS Toeplitz hash for any flow type Ahmed Zaki
2023-10-16 15:49 ` [PATCH net-next v4 6/6] iavf: enable symmetric RSS Toeplitz hash Ahmed Zaki
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=26812a57-bdd8-4a39-8dd2-b0ebcfd1073e@intel.com \
--to=ahmed.zaki@intel.com \
--cc=alexander.duyck@gmail.com \
--cc=andrew@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jesse.brandeburg@intel.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
--cc=willemdebruijn.kernel@gmail.com \
--cc=wojciech.drewek@intel.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).