History

Merge branch 'ethtool-rssh-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bwh/net-next

Ben Hutchings says: ==================== Pull request: Fixes for new ethtool RSS commands This addresses several problems I previously identified with the new ETHTOOL_{G,S}RSSH commands: 1. Missing validation of reserved parameters 2. Vague documentation 3. Use of unnamed magic number 4. No consolidation with existing driver operations I don't currently have access to suitable network hardware, but have tested these changes with a dummy driver that can support various combinations of operations and sizes, together with (a) Debian's ethtool 3.13 (b) ethtool 3.14 with the submitted patch to use ETHTOOL_{G,S}RSSH and minor adjustment for fixes 1 and 3. v2: Update RSS operations in vmxnet3 too ====================

David S. Miller committed 12 years ago

Commit 014b2012 parents a68ab98 f062a3814 files · +120 −129Browse files

Unified · Split

14 files
  1. drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +8 −7
  2. drivers/net/ethernet/broadcom/tg3.c +4 −4
  3. drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +4 −4
  4. drivers/net/ethernet/emulex/benet/be_cmds.c +1 −1
  5. drivers/net/ethernet/emulex/benet/be_cmds.h +1 −1
  6. drivers/net/ethernet/emulex/benet/be_ethtool.c +2 −1
  7. drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c +9 −6
  8. drivers/net/ethernet/intel/igb/igb_ethtool.c +5 −4
  9. drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +5 −5
  10. drivers/net/ethernet/sfc/ethtool.c +5 −5
  11. drivers/net/vmxnet3/vmxnet3_ethtool.c +4 −4
  12. include/linux/ethtool.h +10 −14
  13. include/uapi/linux/ethtool.h +14 −11
  14. net/core/ethtool.c +48 −62
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c+8−7
@@ -3316,7 +3316,7 @@ static u32 bnx2x_get_rxfh_indir_size(struct net_device *dev) · 3315 unmodified lines
33163316 return T_ETH_INDIRECTION_TABLE_SIZE;
33173317 }
33183318
3319−static int bnx2x_get_rxfh_indir(struct net_device *dev, u32 *indir)
3319+static int bnx2x_get_rxfh(struct net_device *dev, u32 *indir, u8 *key)
33203320 {
33213321 struct bnx2x *bp = netdev_priv(dev);
33223322 u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE] = {0};
@@ -3340,14 +3340,15 @@ static int bnx2x_get_rxfh_indir(struct net_device *dev, u32 *indir) · 17 unmodified lines
33403340 return 0;
33413341 }
33423342
3343−static int bnx2x_set_rxfh_indir(struct net_device *dev, const u32 *indir)
3343+static int bnx2x_set_rxfh(struct net_device *dev, const u32 *indir,
3344+ const u8 *key)
33443345 {
33453346 struct bnx2x *bp = netdev_priv(dev);
33463347 size_t i;
33473348
33483349 for (i = 0; i < T_ETH_INDIRECTION_TABLE_SIZE; i++) {
33493350 /*
3350− * The same as in bnx2x_get_rxfh_indir: we can't use a memcpy()
3351+ * The same as in bnx2x_get_rxfh: we can't use a memcpy()
33513352 * as an internal storage of an indirection table is a u8 array
33523353 * while indir->ring_index points to an array of u32.
33533354 *
@@ -3471,8 +3472,8 @@ static const struct ethtool_ops bnx2x_ethtool_ops = { · 117 unmodified lines
34713472 .get_rxnfc = bnx2x_get_rxnfc,
34723473 .set_rxnfc = bnx2x_set_rxnfc,
34733474 .get_rxfh_indir_size = bnx2x_get_rxfh_indir_size,
3474− .get_rxfh_indir = bnx2x_get_rxfh_indir,
3475− .set_rxfh_indir = bnx2x_set_rxfh_indir,
3475+ .get_rxfh = bnx2x_get_rxfh,
3476+ .set_rxfh = bnx2x_set_rxfh,
34763477 .get_channels = bnx2x_get_channels,
34773478 .set_channels = bnx2x_set_channels,
34783479 .get_module_info = bnx2x_get_module_info,
@@ -3498,8 +3499,8 @@ static const struct ethtool_ops bnx2x_vf_ethtool_ops = { · 19 unmodified lines
34983499 .get_rxnfc = bnx2x_get_rxnfc,
34993500 .set_rxnfc = bnx2x_set_rxnfc,
35003501 .get_rxfh_indir_size = bnx2x_get_rxfh_indir_size,
3501− .get_rxfh_indir = bnx2x_get_rxfh_indir,
3502− .set_rxfh_indir = bnx2x_set_rxfh_indir,
3502+ .get_rxfh = bnx2x_get_rxfh,
3503+ .set_rxfh = bnx2x_set_rxfh,
35033504 .get_channels = bnx2x_get_channels,
35043505 .set_channels = bnx2x_set_channels,
35053506 };
drivers/net/ethernet/broadcom/tg3.c+4−4
@@ -12532,7 +12532,7 @@ static u32 tg3_get_rxfh_indir_size(struct net_device *dev) · 12531 unmodified lines
1253212532 return size;
1253312533 }
1253412534
12535−static int tg3_get_rxfh_indir(struct net_device *dev, u32 *indir)
12535+static int tg3_get_rxfh(struct net_device *dev, u32 *indir, u8 *key)
1253612536 {
1253712537 struct tg3 *tp = netdev_priv(dev);
1253812538 int i;
@@ -12543,7 +12543,7 @@ static int tg3_get_rxfh_indir(struct net_device *dev, u32 *indir) · 4 unmodified lines
1254312543 return 0;
1254412544 }
1254512545
12546−static int tg3_set_rxfh_indir(struct net_device *dev, const u32 *indir)
12546+static int tg3_set_rxfh(struct net_device *dev, const u32 *indir, const u8 *key)
1254712547 {
1254812548 struct tg3 *tp = netdev_priv(dev);
1254912549 size_t i;
@@ -14075,8 +14075,8 @@ static const struct ethtool_ops tg3_ethtool_ops = { · 1525 unmodified lines
1407514075 .get_sset_count = tg3_get_sset_count,
1407614076 .get_rxnfc = tg3_get_rxnfc,
1407714077 .get_rxfh_indir_size = tg3_get_rxfh_indir_size,
14078− .get_rxfh_indir = tg3_get_rxfh_indir,
14079− .set_rxfh_indir = tg3_set_rxfh_indir,
14078+ .get_rxfh = tg3_get_rxfh,
14079+ .set_rxfh = tg3_set_rxfh,
1408014080 .get_channels = tg3_get_channels,
1408114081 .set_channels = tg3_set_channels,
1408214082 .get_ts_info = tg3_get_ts_info,
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c+4−4
@@ -2739,7 +2739,7 @@ static u32 get_rss_table_size(struct net_device *dev) · 2738 unmodified lines
27392739 return pi->rss_size;
27402740 }
27412741
2742−static int get_rss_table(struct net_device *dev, u32 *p)
2742+static int get_rss_table(struct net_device *dev, u32 *p, u8 *key)
27432743 {
27442744 const struct port_info *pi = netdev_priv(dev);
27452745 unsigned int n = pi->rss_size;
@@ -2749,7 +2749,7 @@ static int get_rss_table(struct net_device *dev, u32 *p) · 3 unmodified lines
27492749 return 0;
27502750 }
27512751
2752−static int set_rss_table(struct net_device *dev, const u32 *p)
2752+static int set_rss_table(struct net_device *dev, const u32 *p, const u8 *key)
27532753 {
27542754 unsigned int i;
27552755 struct port_info *pi = netdev_priv(dev);
@@ -2851,8 +2851,8 @@ static const struct ethtool_ops cxgb_ethtool_ops = { · 95 unmodified lines
28512851 .set_wol = set_wol,
28522852 .get_rxnfc = get_rxnfc,
28532853 .get_rxfh_indir_size = get_rss_table_size,
2854− .get_rxfh_indir = get_rss_table,
2855− .set_rxfh_indir = set_rss_table,
2854+ .get_rxfh = get_rss_table,
2855+ .set_rxfh = set_rss_table,
28562856 .flash_device = set_flash,
28572857 };
28582858
drivers/net/ethernet/emulex/benet/be_cmds.c+1−1
@@ -2065,7 +2065,7 @@ int be_cmd_reset_function(struct be_adapter *adapter) · 2064 unmodified lines
20652065 }
20662066
20672067 int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable,
2068− u32 rss_hash_opts, u16 table_size, u8 *rss_hkey)
2068+ u32 rss_hash_opts, u16 table_size, const u8 *rss_hkey)
20692069 {
20702070 struct be_mcc_wrb *wrb;
20712071 struct be_cmd_req_rss_config *req;
drivers/net/ethernet/emulex/benet/be_cmds.h+1−1
@@ -2082,7 +2082,7 @@ int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num, · 2081 unmodified lines
20822082 u32 *function_mode, u32 *function_caps, u16 *asic_rev);
20832083 int be_cmd_reset_function(struct be_adapter *adapter);
20842084 int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable,
2085− u32 rss_hash_opts, u16 table_size, u8 *rss_hkey);
2085+ u32 rss_hash_opts, u16 table_size, const u8 *rss_hkey);
20862086 int be_process_mcc(struct be_adapter *adapter);
20872087 int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, u8 beacon,
20882088 u8 status, u8 state);
drivers/net/ethernet/emulex/benet/be_ethtool.c+2−1
@@ -1117,7 +1117,8 @@ static int be_get_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey) · 1116 unmodified lines
11171117 return 0;
11181118 }
11191119
1120−static int be_set_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey)
1120+static int be_set_rxfh(struct net_device *netdev, const u32 *indir,
1121+ const u8 *hkey)
11211122 {
11221123 int rc = 0, i, j;
11231124 struct be_adapter *adapter = netdev_priv(netdev);
drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c+9−6
@@ -624,13 +624,14 @@ static u32 i40evf_get_rxfh_indir_size(struct net_device *netdev) · 623 unmodified lines
624624 }
625625
626626 /**
627− * i40evf_get_rxfh_indir - get the rx flow hash indirection table
627+ * i40evf_get_rxfh - get the rx flow hash indirection table
628628 * @netdev: network interface device structure
629629 * @indir: indirection table
630+ * @key: hash key (will be %NULL until get_rxfh_key_size is implemented)
630631 *
631632 * Reads the indirection table directly from the hardware. Always returns 0.
632633 **/
633−static int i40evf_get_rxfh_indir(struct net_device *netdev, u32 *indir)
634+static int i40evf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
634635 {
635636 struct i40evf_adapter *adapter = netdev_priv(netdev);
636637 struct i40e_hw *hw = &adapter->hw;
@@ -648,14 +649,16 @@ static int i40evf_get_rxfh_indir(struct net_device *netdev, u32 *indir) · 11 unmodified lines
648649 }
649650
650651 /**
651− * i40evf_set_rxfh_indir - set the rx flow hash indirection table
652+ * i40evf_set_rxfh - set the rx flow hash indirection table
652653 * @netdev: network interface device structure
653654 * @indir: indirection table
655+ * @key: hash key (will be %NULL until get_rxfh_key_size is implemented)
654656 *
655657 * Returns -EINVAL if the table specifies an inavlid queue id, otherwise
656658 * returns 0 after programming the table.
657659 **/
658−static int i40evf_set_rxfh_indir(struct net_device *netdev, const u32 *indir)
660+static int i40evf_set_rxfh(struct net_device *netdev, const u32 *indir,
661+ const u8 *key)
659662 {
660663 struct i40evf_adapter *adapter = netdev_priv(netdev);
661664 struct i40e_hw *hw = &adapter->hw;
@@ -689,8 +692,8 @@ static const struct ethtool_ops i40evf_ethtool_ops = { · 27 unmodified lines
689692 .get_rxnfc = i40evf_get_rxnfc,
690693 .set_rxnfc = i40evf_set_rxnfc,
691694 .get_rxfh_indir_size = i40evf_get_rxfh_indir_size,
692− .get_rxfh_indir = i40evf_get_rxfh_indir,
693− .set_rxfh_indir = i40evf_set_rxfh_indir,
695+ .get_rxfh = i40evf_get_rxfh,
696+ .set_rxfh = i40evf_set_rxfh,
694697 .get_channels = i40evf_get_channels,
695698 };
696699
drivers/net/ethernet/intel/igb/igb_ethtool.c+5−4
@@ -2830,7 +2830,7 @@ static u32 igb_get_rxfh_indir_size(struct net_device *netdev) · 2829 unmodified lines
28302830 return IGB_RETA_SIZE;
28312831 }
28322832
2833−static int igb_get_rxfh_indir(struct net_device *netdev, u32 *indir)
2833+static int igb_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
28342834 {
28352835 struct igb_adapter *adapter = netdev_priv(netdev);
28362836 int i;
@@ -2876,7 +2876,8 @@ void igb_write_rss_indir_tbl(struct igb_adapter *adapter) · 39 unmodified lines
28762876 }
28772877 }
28782878
2879−static int igb_set_rxfh_indir(struct net_device *netdev, const u32 *indir)
2879+static int igb_set_rxfh(struct net_device *netdev, const u32 *indir,
2880+ const u8 *key)
28802881 {
28812882 struct igb_adapter *adapter = netdev_priv(netdev);
28822883 struct e1000_hw *hw = &adapter->hw;
@@ -3025,8 +3026,8 @@ static const struct ethtool_ops igb_ethtool_ops = { · 142 unmodified lines
30253026 .get_module_info = igb_get_module_info,
30263027 .get_module_eeprom = igb_get_module_eeprom,
30273028 .get_rxfh_indir_size = igb_get_rxfh_indir_size,
3028− .get_rxfh_indir = igb_get_rxfh_indir,
3029− .set_rxfh_indir = igb_set_rxfh_indir,
3029+ .get_rxfh = igb_get_rxfh,
3030+ .set_rxfh = igb_set_rxfh,
30303031 .get_channels = igb_get_channels,
30313032 .set_channels = igb_set_channels,
30323033 .begin = igb_ethtool_begin,
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c+5−5
@@ -564,7 +564,7 @@ static u32 mlx4_en_get_rxfh_indir_size(struct net_device *dev) · 563 unmodified lines
564564 return priv->rx_ring_num;
565565 }
566566
567−static int mlx4_en_get_rxfh_indir(struct net_device *dev, u32 *ring_index)
567+static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key)
568568 {
569569 struct mlx4_en_priv *priv = netdev_priv(dev);
570570 struct mlx4_en_rss_map *rss_map = &priv->rss_map;
@@ -582,8 +582,8 @@ static int mlx4_en_get_rxfh_indir(struct net_device *dev, u32 *ring_index) · 11 unmodified lines
582582 return err;
583583 }
584584
585−static int mlx4_en_set_rxfh_indir(struct net_device *dev,
586− const u32 *ring_index)
585+static int mlx4_en_set_rxfh(struct net_device *dev, const u32 *ring_index,
586+ const u8 *key)
587587 {
588588 struct mlx4_en_priv *priv = netdev_priv(dev);
589589 struct mlx4_en_dev *mdev = priv->mdev;
@@ -1224,8 +1224,8 @@ const struct ethtool_ops mlx4_en_ethtool_ops = { · 634 unmodified lines
12241224 .get_rxnfc = mlx4_en_get_rxnfc,
12251225 .set_rxnfc = mlx4_en_set_rxnfc,
12261226 .get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size,
1227− .get_rxfh_indir = mlx4_en_get_rxfh_indir,
1228− .set_rxfh_indir = mlx4_en_set_rxfh_indir,
1227+ .get_rxfh = mlx4_en_get_rxfh,
1228+ .set_rxfh = mlx4_en_set_rxfh,
12291229 .get_channels = mlx4_en_get_channels,
12301230 .set_channels = mlx4_en_set_channels,
12311231 .get_ts_info = mlx4_en_get_ts_info,
drivers/net/ethernet/sfc/ethtool.c+5−5
@@ -1033,7 +1033,7 @@ static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev) · 1032 unmodified lines
10331033 0 : ARRAY_SIZE(efx->rx_indir_table));
10341034 }
10351035
1036−static int efx_ethtool_get_rxfh_indir(struct net_device *net_dev, u32 *indir)
1036+static int efx_ethtool_get_rxfh(struct net_device *net_dev, u32 *indir, u8 *key)
10371037 {
10381038 struct efx_nic *efx = netdev_priv(net_dev);
10391039
@@ -1041,8 +1041,8 @@ static int efx_ethtool_get_rxfh_indir(struct net_device *net_dev, u32 *indir) · 1 unmodified line
10411041 return 0;
10421042 }
10431043
1044−static int efx_ethtool_set_rxfh_indir(struct net_device *net_dev,
1045− const u32 *indir)
1044+static int efx_ethtool_set_rxfh(struct net_device *net_dev,
1045+ const u32 *indir, const u8 *key)
10461046 {
10471047 struct efx_nic *efx = netdev_priv(net_dev);
10481048
@@ -1125,8 +1125,8 @@ const struct ethtool_ops efx_ethtool_ops = { · 76 unmodified lines
11251125 .get_rxnfc = efx_ethtool_get_rxnfc,
11261126 .set_rxnfc = efx_ethtool_set_rxnfc,
11271127 .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size,
1128− .get_rxfh_indir = efx_ethtool_get_rxfh_indir,
1129− .set_rxfh_indir = efx_ethtool_set_rxfh_indir,
1128+ .get_rxfh = efx_ethtool_get_rxfh,
1129+ .set_rxfh = efx_ethtool_set_rxfh,
11301130 .get_ts_info = efx_ethtool_get_ts_info,
11311131 .get_module_info = efx_ethtool_get_module_info,
11321132 .get_module_eeprom = efx_ethtool_get_module_eeprom,
drivers/net/vmxnet3/vmxnet3_ethtool.c+4−4
@@ -579,7 +579,7 @@ vmxnet3_get_rss_indir_size(struct net_device *netdev) · 578 unmodified lines
579579 }
580580
581581 static int
582−vmxnet3_get_rss_indir(struct net_device *netdev, u32 *p)
582+vmxnet3_get_rss(struct net_device *netdev, u32 *p, u8 *key)
583583 {
584584 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
585585 struct UPT1_RSSConf *rssConf = adapter->rss_conf;
@@ -592,7 +592,7 @@ vmxnet3_get_rss_indir(struct net_device *netdev, u32 *p) · 6 unmodified lines
592592 }
593593
594594 static int
595−vmxnet3_set_rss_indir(struct net_device *netdev, const u32 *p)
595+vmxnet3_set_rss(struct net_device *netdev, const u32 *p, const u8 *key)
596596 {
597597 unsigned int i;
598598 unsigned long flags;
@@ -628,8 +628,8 @@ static const struct ethtool_ops vmxnet3_ethtool_ops = { · 29 unmodified lines
628628 .get_rxnfc = vmxnet3_get_rxnfc,
629629 #ifdef VMXNET3_RSS
630630 .get_rxfh_indir_size = vmxnet3_get_rss_indir_size,
631− .get_rxfh_indir = vmxnet3_get_rss_indir,
632− .set_rxfh_indir = vmxnet3_set_rss_indir,
631+ .get_rxfh = vmxnet3_get_rss,
632+ .set_rxfh = vmxnet3_set_rss,
633633 #endif
634634 };
635635
include/linux/ethtool.h+10−14
@@ -158,19 +158,16 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings) · 157 unmodified lines
158158 * Returns zero if not supported for this specific device.
159159 * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
160160 * Returns zero if not supported for this specific device.
161− * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
162− * Will not be called if @get_rxfh_indir_size returns zero.
163161 * @get_rxfh: Get the contents of the RX flow hash indirection table and hash
164162 * key.
165− * Will not be called if @get_rxfh_indir_size and @get_rxfh_key_size
166− * returns zero.
163+ * Will only be called if one or both of @get_rxfh_indir_size and
164+ * @get_rxfh_key_size are implemented and return non-zero.
167165 * Returns a negative error code or zero.
168− * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
169− * Will not be called if @get_rxfh_indir_size returns zero.
170− * @set_rxfh: Set the contents of the RX flow hash indirection table and
171− * hash key.
172− * Will not be called if @get_rxfh_indir_size and @get_rxfh_key_size
173− * returns zero.
166+ * @set_rxfh: Set the contents of the RX flow hash indirection table and/or
167+ * hash key. In case only the indirection table or hash key is to be
168+ * changed, the other argument will be %NULL.
169+ * Will only be called if one or both of @get_rxfh_indir_size and
170+ * @get_rxfh_key_size are implemented and return non-zero.
174171 * Returns a negative error code or zero.
175172 * @get_channels: Get number of channels.
176173 * @set_channels: Set number of channels. Returns a negative error code or
@@ -244,10 +241,9 @@ struct ethtool_ops { · 67 unmodified lines
244241 int (*reset)(struct net_device *, u32 *);
245242 u32 (*get_rxfh_key_size)(struct net_device *);
246243 u32 (*get_rxfh_indir_size)(struct net_device *);
247− int (*get_rxfh)(struct net_device *, u32 *, u8 *);
248− int (*set_rxfh)(struct net_device *, u32 *, u8 *);
249− int (*get_rxfh_indir)(struct net_device *, u32 *);
250− int (*set_rxfh_indir)(struct net_device *, const u32 *);
244+ int (*get_rxfh)(struct net_device *, u32 *indir, u8 *key);
245+ int (*set_rxfh)(struct net_device *, const u32 *indir,
246+ const u8 *key);
251247 void (*get_channels)(struct net_device *, struct ethtool_channels *);
252248 int (*set_channels)(struct net_device *, struct ethtool_channels *);
253249 int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
include/uapi/linux/ethtool.h+14−11
@@ -850,21 +850,23 @@ struct ethtool_rxfh_indir { · 849 unmodified lines
850850 * struct ethtool_rxfh - command to get/set RX flow hash indir or/and hash key.
851851 * @cmd: Specific command number - %ETHTOOL_GRSSH or %ETHTOOL_SRSSH
852852 * @rss_context: RSS context identifier.
853− * @indir_size: On entry, the array size of the user buffer, which may be zero.
854− * On return from %ETHTOOL_GRSSH, the array size of the hardware
855− * indirection table.
856− * @key_size: On entry, the array size of the user buffer in bytes,
857− * which may be zero.
858− * On return from %ETHTOOL_GRSSH, the size of the RSS hash key.
853+ * @indir_size: On entry, the array size of the user buffer for the
854+ * indirection table, which may be zero, or (for %ETHTOOL_SRSSH),
855+ * %ETH_RXFH_INDIR_NO_CHANGE. On return from %ETHTOOL_GRSSH,
856+ * the array size of the hardware indirection table.
857+ * @key_size: On entry, the array size of the user buffer for the hash key,
858+ * which may be zero. On return from %ETHTOOL_GRSSH, the size of the
859+ * hardware hash key.
859860 * @rsvd: Reserved for future extensions.
860861 * @rss_config: RX ring/queue index for each hash value i.e., indirection table
861− * of size @indir_size followed by hash key of size @key_size.
862+ * of @indir_size __u32 elements, followed by hash key of @key_size
863+ * bytes.
862864 *
863865 * For %ETHTOOL_GRSSH, a @indir_size and key_size of zero means that only the
864− * size should be returned. For %ETHTOOL_SRSSH, a @indir_size of 0xDEADBEEF
865− * means that indir table setting is not requested and a @indir_size of zero
866− * means the indir table should be reset to default values. This last feature
867− * is not supported by the original implementations.
866+ * size should be returned. For %ETHTOOL_SRSSH, an @indir_size of
867+ * %ETH_RXFH_INDIR_NO_CHANGE means that indir table setting is not requested
868+ * and a @indir_size of zero means the indir table should be reset to default
869+ * values.
868870 */
869871 struct ethtool_rxfh {
870872 __u32 cmd;
@@ -874,6 +876,7 @@ struct ethtool_rxfh { · 3 unmodified lines
874876 __u32 rsvd[2];
875877 __u32 rss_config[0];
876878 };
879+#define ETH_RXFH_INDIR_NO_CHANGE 0xffffffff
877880
878881 /**
879882 * struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter
net/core/ethtool.c+48−62
@@ -561,19 +561,17 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr, · 560 unmodified lines
561561 struct ethtool_rxnfc *rx_rings,
562562 u32 size)
563563 {
564− int ret = 0, i;
564+ int i;
565565
566566 if (copy_from_user(indir, useraddr, size * sizeof(indir[0])))
567− ret = -EFAULT;
567+ return -EFAULT;
568568
569569 /* Validate ring indices */
570− for (i = 0; i < size; i++) {
571− if (indir[i] >= rx_rings->data) {
572− ret = -EINVAL;
573− break;
574− }
575− }
576− return ret;
570+ for (i = 0; i < size; i++)
571+ if (indir[i] >= rx_rings->data)
572+ return -EINVAL;
573+
574+ return 0;
577575 }
578576
579577 static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
@@ -584,7 +582,7 @@ static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev, · 4 unmodified lines
584582 int ret;
585583
586584 if (!dev->ethtool_ops->get_rxfh_indir_size ||
587− !dev->ethtool_ops->get_rxfh_indir)
585+ !dev->ethtool_ops->get_rxfh)
588586 return -EOPNOTSUPP;
589587 dev_size = dev->ethtool_ops->get_rxfh_indir_size(dev);
590588 if (dev_size == 0)
@@ -610,7 +608,7 @@ static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev, · 19 unmodified lines
610608 if (!indir)
611609 return -ENOMEM;
612610
613− ret = dev->ethtool_ops->get_rxfh_indir(dev, indir);
611+ ret = dev->ethtool_ops->get_rxfh(dev, indir, NULL);
614612 if (ret)
615613 goto out;
616614
@@ -634,7 +632,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev, · 17 unmodified lines
634632 int ret;
635633 u32 ringidx_offset = offsetof(struct ethtool_rxfh_indir, ring_index[0]);
636634
637− if (!ops->get_rxfh_indir_size || !ops->set_rxfh_indir ||
635+ if (!ops->get_rxfh_indir_size || !ops->set_rxfh ||
638636 !ops->get_rxnfc)
639637 return -EOPNOTSUPP;
640638
@@ -671,7 +669,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev, · 30 unmodified lines
671669 goto out;
672670 }
673671
674− ret = ops->set_rxfh_indir(dev, indir);
672+ ret = ops->set_rxfh(dev, indir, NULL);
675673
676674 out:
677675 kfree(indir);
@@ -683,11 +681,11 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, · 5 unmodified lines
683681 {
684682 int ret;
685683 const struct ethtool_ops *ops = dev->ethtool_ops;
686− u32 user_indir_size = 0, user_key_size = 0;
684+ u32 user_indir_size, user_key_size;
687685 u32 dev_indir_size = 0, dev_key_size = 0;
686+ struct ethtool_rxfh rxfh;
688687 u32 total_size;
689− u32 indir_offset, indir_bytes;
690− u32 key_offset;
688+ u32 indir_bytes;
691689 u32 *indir = NULL;
692690 u8 *hkey = NULL;
693691 u8 *rss_config;
@@ -699,33 +697,24 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, · 5 unmodified lines
699697
700698 if (ops->get_rxfh_indir_size)
701699 dev_indir_size = ops->get_rxfh_indir_size(dev);
702−
703− indir_offset = offsetof(struct ethtool_rxfh, indir_size);
704−
705− if (copy_from_user(&user_indir_size,
706− useraddr + indir_offset,
707− sizeof(user_indir_size)))
708− return -EFAULT;
709−
710− if (copy_to_user(useraddr + indir_offset,
711− &dev_indir_size, sizeof(dev_indir_size)))
712− return -EFAULT;
713−
714700 if (ops->get_rxfh_key_size)
715701 dev_key_size = ops->get_rxfh_key_size(dev);
716702
717703 if ((dev_key_size + dev_indir_size) == 0)
718704 return -EOPNOTSUPP;
719705
720− key_offset = offsetof(struct ethtool_rxfh, key_size);
721−
722− if (copy_from_user(&user_key_size,
723− useraddr + key_offset,
724− sizeof(user_key_size)))
706+ if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
725707 return -EFAULT;
708+ user_indir_size = rxfh.indir_size;
709+ user_key_size = rxfh.key_size;
726710
727− if (copy_to_user(useraddr + key_offset,
728− &dev_key_size, sizeof(dev_key_size)))
711+ /* Check that reserved fields are 0 for now */
712+ if (rxfh.rss_context || rxfh.rsvd[0] || rxfh.rsvd[1])
713+ return -EINVAL;
714+
715+ rxfh.indir_size = dev_indir_size;
716+ rxfh.key_size = dev_key_size;
717+ if (copy_to_user(useraddr, &rxfh, sizeof(rxfh)))
729718 return -EFAULT;
730719
731720 /* If the user buffer size is 0, this is just a query for the
@@ -770,12 +759,11 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, · 38 unmodified lines
770759 int ret;
771760 const struct ethtool_ops *ops = dev->ethtool_ops;
772761 struct ethtool_rxnfc rx_rings;
773− u32 user_indir_size = 0, dev_indir_size = 0, i;
774− u32 user_key_size = 0, dev_key_size = 0;
762+ struct ethtool_rxfh rxfh;
763+ u32 dev_indir_size = 0, dev_key_size = 0, i;
775764 u32 *indir = NULL, indir_bytes = 0;
776765 u8 *hkey = NULL;
777766 u8 *rss_config;
778− u32 indir_offset, key_offset;
779767 u32 rss_cfg_offset = offsetof(struct ethtool_rxfh, rss_config[0]);
780768
781769 if (!(ops->get_rxfh_indir_size || ops->get_rxfh_key_size) ||
@@ -784,36 +772,33 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, · 2 unmodified lines
784772
785773 if (ops->get_rxfh_indir_size)
786774 dev_indir_size = ops->get_rxfh_indir_size(dev);
787−
788− indir_offset = offsetof(struct ethtool_rxfh, indir_size);
789− if (copy_from_user(&user_indir_size,
790− useraddr + indir_offset,
791− sizeof(user_indir_size)))
792− return -EFAULT;
793−
794775 if (ops->get_rxfh_key_size)
795776 dev_key_size = dev->ethtool_ops->get_rxfh_key_size(dev);
796−
797777 if ((dev_key_size + dev_indir_size) == 0)
798778 return -EOPNOTSUPP;
799779
800− key_offset = offsetof(struct ethtool_rxfh, key_size);
801− if (copy_from_user(&user_key_size,
802− useraddr + key_offset,
803− sizeof(user_key_size)))
780+ if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
804781 return -EFAULT;
805782
783+ /* Check that reserved fields are 0 for now */
784+ if (rxfh.rss_context || rxfh.rsvd[0] || rxfh.rsvd[1])
785+ return -EINVAL;
786+
806787 /* If either indir or hash key is valid, proceed further.
788+ * It is not valid to request that both be unchanged.
807789 */
808− if ((user_indir_size && ((user_indir_size != 0xDEADBEEF) &&
809− user_indir_size != dev_indir_size)) ||
810− (user_key_size && (user_key_size != dev_key_size)))
790+ if ((rxfh.indir_size &&
791+ rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE &&
792+ rxfh.indir_size != dev_indir_size) ||
793+ (rxfh.key_size && (rxfh.key_size != dev_key_size)) ||
794+ (rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE &&
795+ rxfh.key_size == 0))
811796 return -EINVAL;
812797
813− if (user_indir_size != 0xDEADBEEF)
798+ if (rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE)
814799 indir_bytes = dev_indir_size * sizeof(indir[0]);
815800
816− rss_config = kzalloc(indir_bytes + user_key_size, GFP_USER);
801+ rss_config = kzalloc(indir_bytes + rxfh.key_size, GFP_USER);
817802 if (!rss_config)
818803 return -ENOMEM;
819804
@@ -822,28 +807,29 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, · 2 unmodified lines
822807 if (ret)
823808 goto out;
824809
825− /* user_indir_size == 0 means reset the indir table to default.
826− * user_indir_size == 0xDEADBEEF means indir setting is not requested.
810+ /* rxfh.indir_size == 0 means reset the indir table to default.
811+ * rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE means leave it unchanged.
827812 */
828− if (user_indir_size && user_indir_size != 0xDEADBEEF) {
813+ if (rxfh.indir_size &&
814+ rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE) {
829815 indir = (u32 *)rss_config;
830816 ret = ethtool_copy_validate_indir(indir,
831817 useraddr + rss_cfg_offset,
832818 &rx_rings,
833− user_indir_size);
819+ rxfh.indir_size);
834820 if (ret)
835821 goto out;
836− } else if (user_indir_size == 0) {
822+ } else if (rxfh.indir_size == 0) {
837823 indir = (u32 *)rss_config;
838824 for (i = 0; i < dev_indir_size; i++)
839825 indir[i] = ethtool_rxfh_indir_default(i, rx_rings.data);
840826 }
841827
842− if (user_key_size) {
828+ if (rxfh.key_size) {
843829 hkey = rss_config + indir_bytes;
844830 if (copy_from_user(hkey,
845831 useraddr + rss_cfg_offset + indir_bytes,
846− user_key_size)) {
832+ rxfh.key_size)) {
847833 ret = -EFAULT;
848834 goto out;
849835 }