igb: add RSS key get/set support
Subsystems (3)
cover igb: add RSS key get/set support
This series adds ethtool get/set support for the RSS hash key in the igb driver.
- ethtool -x <dev> to display the RSS key
- ethtool -X <dev> hkey <key> to configure the RSS key
Without patch:
# ethtool -x $DEV | grep key -A1 RSS hash key: Operation not supported # ethtool -X $DEV hkey 00:00:00:00:00:00:00:00:00:00:00:00:000 Cannot set RX flow hash configuration: Hash key setting not supported
With patch:
# ethtool -x $DEV | grep key -A1 RSS hash key: 86:5d:11:56:bd:6f:20:38:3b:f8:bb:df:00:3a:b0:24:95:9f:f9:f4:25:a3:01:3e:4a:15:d6:7c:4d:af:39:7e:4a:95:f2:fd:f6:b6:26:f7
# ethtool -X $DEV hkey 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 # ethtool -x $DEV | grep key -A1 RSS hash key: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
Takashi Kozu (3):
Store the RSS key inside struct igb_adapter and introduce the
igb: expose RSS key via ethtool get_rxfh
igb: allow configuring RSS key via ethtool set_rxfh
drivers/net/ethernet/intel/igb/igb.h | 4 + drivers/net/ethernet/intel/igb/igb_ethtool.c | 77 +++++++++++++------- drivers/net/ethernet/intel/igb/igb_main.c | 7 +- 3 files changed, 58 insertions(+), 30 deletions(-)
Signature · 1 line
2.51.1
PATCH 1/3 Store the RSS key inside struct igb_adapter and introduce the
Store the RSS key inside struct igb_adapter and introduce the igb_write_rss_key() helper function. This allows the driver to program the E1000 registers using a persistent RSS key, instead of using a stack-local buffer in igb_setup_mrqc().
--- drivers/net/ethernet/intel/igb/igb.h | 3 +++ drivers/net/ethernet/intel/igb/igb_ethtool.c | 12 ++++++++++++ drivers/net/ethernet/intel/igb/igb_main.c | 6 ++---- 3 files changed, 17 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +3 -0
@@ -495,6 +495,7 @@ struct hwmon_buff {#define IGB_N_PEROUT 2#define IGB_N_SDP 4#define IGB_RETA_SIZE 128 +#define IGB_RSS_KEY_SIZE 40enum igb_filter_match_flags {IGB_FILTER_FLAG_ETHER_TYPE =0x1 ,
@@ -655,6 +656,7 @@ struct igb_adapter {struct i2c_client *i2c_client;u32 rss_indir_tbl_init;u8 rss_indir_tbl[IGB_RETA_SIZE ]; +u8 rss_key[IGB_RSS_KEY_SIZE ];unsigned long link_check_timeout;int copper_tries;
@@ -735,6 +737,7 @@ void igb_down(struct igb_adapter *);void igb_reinit_locked (struct igb_adapter *);void igb_reset (struct igb_adapter *);int igb_reinit_queues (struct igb_adapter *); +void igb_write_rss_key (struct igb_adapter *adapter);void igb_write_rss_indir_tbl (struct igb_adapter *);int igb_set_spd_dplx (struct igb_adapter *,u32 ,u8 );int igb_setup_tx_resources (struct igb_ring *);
drivers/net/ethernet/intel/igb/igb_ethtool.c +12 -0
@@ -3016,6 +3016,18 @@ static int igb_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)return ret; } +void igb_write_rss_key (struct igb_adapter *adapter) +{ +struct e1000_hw *hw = &adapter->hw; +u32 val; +int i; + +for (i =0 ; i <IGB_RSS_KEY_SIZE /4 ; i++) { + val =get_unaligned_le32 (&adapter->rss_key[i *4 ]); +wr32 (E1000_RSSRK (i), val); + } +} +static int igb_get_eee (struct net_device *netdev,struct ethtool_keee *edata) {struct igb_adapter *adapter =netdev_priv (netdev);
drivers/net/ethernet/intel/igb/igb_main.c +2 -4
@@ -4525,11 +4525,9 @@ static void igb_setup_mrqc(struct igb_adapter *adapter)struct e1000_hw *hw = &adapter->hw;u32 mrqc, rxcsum;u32 j, num_rx_queues; -u32 rss_key[10 ]; -netdev_rss_key_fill (rss_key,sizeof (rss_key)); -for (j =0 ; j <10 ; j++) -wr32 (E1000_RSSRK (j), rss_key[j]); +netdev_rss_key_fill (adapter->rss_key,sizeof (adapter->rss_key)); +igb_write_rss_key (adapter); num_rx_queues = adapter->rss_queues;
Signature · 1 line
2.51.1
PATCH 2/3 igb: expose RSS key via ethtool get_rxfh
In reply to Takashi KozuImplement igc_get_rxfh_key_size() and extend igc_get_rxfh() to return the RSS key to userspace.
This can be tested using ethtool -x <dev>.
--- drivers/net/ethernet/intel/igb/igb_ethtool.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb_ethtool.c +12 -4
@@ -3285,11 +3285,13 @@ static int igb_get_rxfh(struct net_device *netdev,int i; rxfh->hfunc =ETH_RSS_HASH_TOP ; -if (!rxfh->indir) -return 0 ; -for (i =0 ; i <IGB_RETA_SIZE ; i++) - rxfh->indir[i] = adapter->rss_indir_tbl[i]; +if (rxfh->indir) +for (i =0 ; i <IGB_RETA_SIZE ; i++) + rxfh->indir[i] = adapter->rss_indir_tbl[i]; + +if (rxfh->key) +memcpy (rxfh->key, adapter->rss_key,sizeof (adapter->rss_key));return 0 ; }
@@ -3328,6 +3330,11 @@ void igb_write_rss_indir_tbl(struct igb_adapter *adapter) } } +static u32 igb_get_rxfh_key_size (struct net_device *netdev) +{ +return IGB_RSS_KEY_SIZE ; +} +static int igb_set_rxfh (struct net_device *netdev,struct ethtool_rxfh_param *rxfh,struct netlink_ext_ack *extack)
@@ -3491,6 +3498,7 @@ static const struct ethtool_ops igb_ethtool_ops = { .get_module_eeprom = igb_get_module_eeprom, .get_rxfh_indir_size = igb_get_rxfh_indir_size, .get_rxfh = igb_get_rxfh, + .get_rxfh_key_size = igb_get_rxfh_key_size, .set_rxfh = igb_set_rxfh, .get_rxfh_fields = igb_get_rxfh_fields, .set_rxfh_fields = igb_set_rxfh_fields,
Signature · 1 line
2.51.1
RE: [Intel-wired-lan] [PATCH iwl-next v1 2/3] igb: expose RSS key via ethtool get_rxfh
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Takashi Kozu
Sent: Friday, December 5, 2025 9:21 AM
To: Nguyen, Anthony L <[email protected]>
Cc: Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Takashi Kozu <[email protected]>; Kohei Enju <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v1 2/3] igb: expose RSS key via ethtoolget_rxfh
Quoted 5 lines
Implement
igc_get_rxfh_key_size()and extendigc_get_rxfh()to return the RSS key to userspace.This can be tested using
ethtool -x <dev>.
nit (commit message): s/igc_get_rxfh_key_size()/igb_get_rxfh_key_size()/; s/igc_get_rxfh()/igb_get_rxfh()/. The code implements igb_* symbols and wires them into igb_ethtool_ops, so the message should match the actual driver.
With the best regards
Alex
Quoted 54 lines
Tested-by Kohei Enju <[email protected]>Signed-off-by Takashi Kozu <[email protected]>--- drivers/net/ethernet/intel/igb/igb_ethtool.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/igb/igb_ethtool.c +6
-4@@ -3285,11 +3285,13 @@ static int igb_get_rxfh(struct net_device *netdev, int i; rxfh->hfunc =ETH_RSS_HASH_TOP ; -if (!rxfh->indir) -return 0 ; -for (i =0 ; i <IGB_RETA_SIZE ; i++) - rxfh->indir[i] = adapter->rss_indir_tbl[i]; +if (rxfh->indir) +for (i =0 ; i <IGB_RETA_SIZE ; i++) + rxfh->indir[i] = adapter->rss_indir_tbl[i]; + +if (rxfh->key) +memcpy (rxfh->key, adapter->rss_key,sizeof (adapter- >rss_key));return 0 ;}
drivers/net/ethernet/intel/igb/igb_ethtool.c +5
-0@@ -3328,6 +3330,11 @@ void igb_write_rss_indir_tbl(struct igb_adapter *adapter) } } +static u32 igb_get_rxfh_key_size (struct net_device *netdev) { +return IGB_RSS_KEY_SIZE ; +} +static int igb_set_rxfh (struct net_device *netdev,struct ethtool_rxfh_param *rxfh,struct netlink_ext_ack *extack)@@ -3491,6 +3498,7 @@ static const struct ethtool_ops igb_ethtool_ops = { .get_module_eeprom = igb_get_module_eeprom, .get_rxfh_indir_size = igb_get_rxfh_indir_size, .get_rxfh = igb_get_rxfh, + .get_rxfh_key_size = igb_get_rxfh_key_size, .set_rxfh = igb_set_rxfh, .get_rxfh_fields = igb_get_rxfh_fields,.set_rxfh_fields =
igb_set_rxfh_fields,
--
2.51.1
PATCH 3/3 igb: allow configuring RSS key via ethtool set_rxfh
In reply to Takashi KozuChange igc_set_rxfh() to accept and save a userspace-provided RSS key. When a key is provided, store it in the adapter and write the E1000 registers accordingly.
This can be tested using ethtool -X <dev> hkey <key>.
--- drivers/net/ethernet/intel/igb/igb.h | 1 + drivers/net/ethernet/intel/igb/igb_ethtool.c | 49 +++++++++++--------- drivers/net/ethernet/intel/igb/igb_main.c | 3 +- 3 files changed, 30 insertions(+), 23 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +1 -0
@@ -657,6 +657,7 @@ struct igb_adapter {u32 rss_indir_tbl_init;u8 rss_indir_tbl[IGB_RETA_SIZE ];u8 rss_key[IGB_RSS_KEY_SIZE ]; +bool has_user_rss_key;unsigned long link_check_timeout;int copper_tries;
drivers/net/ethernet/intel/igb/igb_ethtool.c +27 -22
62 lines not on this page · raw message
drivers/net/ethernet/intel/igb/igb_main.c +2 -1
@@ -4526,7 +4526,8 @@ static void igb_setup_mrqc(struct igb_adapter *adapter)u32 mrqc, rxcsum;u32 j, num_rx_queues; -netdev_rss_key_fill (adapter->rss_key,sizeof (adapter->rss_key)); +if (!adapter->has_user_rss_key) +netdev_rss_key_fill (adapter->rss_key,sizeof (adapter->rss_key));igb_write_rss_key (adapter); num_rx_queues = adapter->rss_queues;
Signature · 1 line
2.51.1
RE: [Intel-wired-lan] [PATCH iwl-next v1 3/3] igb: allow configuring RSS key via ethtool set_rxfh
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Takashi Kozu
Sent: Friday, December 5, 2025 9:21 AM
To: Nguyen, Anthony L <[email protected]>
Cc: Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Takashi Kozu <[email protected]>; Kohei Enju <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v1 3/3] igb: allow configuring RSS key via ethtoolset_rxfh
Quoted 6 lines
Change
igc_set_rxfh()to accept and save a userspace-provided RSS key. When a key is provided, store it in the adapter and write the E1000 registers accordingly.This can be tested using
ethtool -X <dev> hkey <key>.
nit (commit message): s/igc_set_rxfh()/igb_set_rxfh()/ throughout.
All modified call-sites and symbols are in drivers/net/ethernet/intel/igb/*, not igc.
Quoted 112 lines
Tested-by Kohei Enju <[email protected]>Signed-off-by Takashi Kozu <[email protected]>--- drivers/net/ethernet/intel/igb/igb.h | 1 + drivers/net/ethernet/intel/igb/igb_ethtool.c | 49 +++++++++++--------(quoted diff) +0
-1- drivers/net/ethernet/intel/igb/igb_main.c | 3 +- 3 files changed, 30 insertions(+), 23 deletions(-)drivers/net/ethernet/intel/igb/igb.h +1
-0@@ -657,6 +657,7 @@ struct igb_adapter {u32 rss_indir_tbl_init;u8 rss_indir_tbl[IGB_RETA_SIZE ];u8 rss_key[IGB_RSS_KEY_SIZE ]; +bool has_user_rss_key;unsigned long link_check_timeout;int copper_tries;drivers/net/ethernet/intel/igb/igb_ethtool.c +27
-22@@ -3345,35 +3345,40 @@ static int igb_set_rxfh(struct net_device *netdev, u32 num_queues;/* We do not allow change in unsupported parameters */ -if (rxfh->key || - (rxfh->hfunc !=ETH_RSS_HASH_NO_CHANGE && - rxfh->hfunc !=ETH_RSS_HASH_TOP )) +if (rxfh->hfunc !=ETH_RSS_HASH_NO_CHANGE && + rxfh->hfunc !=ETH_RSS_HASH_TOP )return -EOPNOTSUPP ; -if (!rxfh->indir) -return 0 ; - num_queues = adapter->rss_queues; +if (rxfh->indir) { + num_queues = adapter->rss_queues; -switch (hw->mac.type) { -case e1000_82576: -/* 82576 supports 2 RSS queues for SR-IOV */ -if (adapter->vfs_allocated_count) - num_queues =2 ; -break ; -default : -break ; - } +switch (hw->mac.type) { +case e1000_82576: +/* 82576 supports 2 RSS queues for SR-IOV */ +if (adapter->vfs_allocated_count) + num_queues =2 ; +break ; +default : +break ; + } -/* Verify user input. */ -for (i =0 ; i <IGB_RETA_SIZE ; i++) -if (rxfh->indir[i] >= num_queues) -return -EINVAL ; +/* Verify user input. */ +for (i =0 ; i <IGB_RETA_SIZE ; i++) +if (rxfh->indir[i] >= num_queues) +return -EINVAL ; -for (i =0 ; i <IGB_RETA_SIZE ; i++) - adapter->rss_indir_tbl[i] = rxfh->indir[i]; +for (i =0 ; i <IGB_RETA_SIZE ; i++) + adapter->rss_indir_tbl[i] = rxfh->indir[i]; + +igb_write_rss_indir_tbl (adapter); + } -igb_write_rss_indir_tbl (adapter); +if (rxfh->key) { + adapter->has_user_rss_key = true; +memcpy (adapter->rss_key, rxfh->key,sizeof (adapter- >rss_key)); +igb_write_rss_key (adapter); + }drivers/net/ethernet/intel/igb/igb_ethtool.c +0
-0return 0 ; }drivers/net/ethernet/intel/igb/igb_main.c +2
-1@@ -4526,7 +4526,8 @@ static void igb_setup_mrqc(struct igb_adapter *adapter)u32 mrqc, rxcsum;u32 j, num_rx_queues; -netdev_rss_key_fill (adapter->rss_key,sizeof (adapter- >rss_key)); +if (!adapter->has_user_rss_key) +netdev_rss_key_fill (adapter->rss_key,sizeof (adapter- >rss_key));drivers/net/ethernet/intel/igb/igb_main.c +0
-1igb_write_rss_key (adapter); num_rx_queues = adapter->rss_queues; --2.51.1