ethtool: add dynamic flag to {SG}RXFH
Subsystems (20)
PATCH 1/1 ethtool: add dynamic flag to {SG}RXFH
This patch series proposes the addition of a dynamic flag to the ethtool {SG}RXFH operations. The primary reasoning for this is so that drivers may indicate when they destroyed configured RSS settings, and can determine when they have more liberty to remove user's settings. The default mode shall be the current static mode, where drivers should make best effort to maintain the RSS table settings if possible. However, if the user sets dynamic mode flag, then the driver is free (if necessary or useful) to modify the requested settings. The primary reason for this is when queue sizes change dynamically. If you increase the number of available queues, the RSS table may be il-configured and the driver might which to change the settings. Today, most drivers attempt to maintain the RSS table when possible. This means that a user can observe functioning RSS, decrease the number of queues, and then increase them again. Under current functionality, drivers may end up never re-writing the RSS table back to the default when the queues are increased. Even worse, if a driver does do this today, they may have destroyed some specific settings the user configured in the RSS table. Instead, use the dynamic mode value which the driver will use to indicate whether or not the current settings might change due to dynamic factors.
This series includes support to fix all the driver function pointers, and a patch to enhance fm10k driver to support this feature. The previous behavior of the fm10k driver was especially problematic, and the current patch series attempts to resolve this.
It is possible to have most of the behavior handled purely in driver, but then we lose any ability to communicate this to the user via ethtool.
Jacob Keller (3):
ethtool: add dynamic flag to ETHTOOL_{GS}RXFH commands
fm10k: support dynamic mode for RSS table control
ethtool: add support for dynamic mode in {SG}RXFH commands
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 7 +++++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 7 +++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 5 ++++- drivers/net/ethernet/broadcom/tg3.c | 8 ++++++-- drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c | 7 +++++-- drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 7 +++++-- drivers/net/ethernet/cisco/enic/enic_ethtool.c | 7 +++++-- drivers/net/ethernet/emulex/benet/be_ethtool.c | 7 +++++-- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 8 ++++++-- drivers/net/ethernet/intel/fm10k/fm10k.h | 1 + drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 15 +++++++++++++-- drivers/net/ethernet/intel/fm10k/fm10k_main.c | 8 +++++--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 7 +++++-- drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 6 ++++-- drivers/net/ethernet/intel/igb/igb_ethtool.c | 6 ++++-- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 7 +++++-- drivers/net/ethernet/intel/ixgbevf/ethtool.c | 5 ++++- drivers/net/ethernet/marvell/mvneta.c | 8 ++++++-- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 7 +++++-- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 +++++-- drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c | 7 +++++-- drivers/net/ethernet/sfc/ethtool.c | 7 +++++-- include/linux/ethtool.h | 4 ++-- include/uapi/linux/ethtool.h | 8 +++++++- net/core/ethtool.c | 27 ++++++++++++++++----------- 25 files changed, 138 insertions(+), 55 deletions(-)
ethtool-copy.h | 8 +++++++- ethtool.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-)
Signature · 1 line
2.6.3.505.g5cc1fd1
PATCH 1/2 ethtool: add dynamic flag to ETHTOOL_{GS}RXFH commands
Ethtool supports a few operations for modifying and controlling a device's RSS table. Sometimes, changes in other features of the device may require (or desire) changes to the RSS table. Currently there is no method to indicate to the driver whether the current RSS table settings should be maintained or overridden.
A simple example of this is for when the number of receive queues is changed, there are two possibilities. First, the number of queues is decreased. This must result in a reprogramming of the RSS table since it will no longer match correctly and may attempt to assign traffic to a queue which is now disabled. In this case drivers have a clear indication of what to do.
The second case, is when the number of queues has increased. In this case, the current RSS table may be preserved. However, doing so would result in the new queues being unused for RSS. But if the driver chooses to destroy the RSS configuration it may result in unwanted behavior as now the user's configured changes are lost.
This patch attempts to resolve this (and other similar) issues by indicating a new flag "dynamic" which can be set by the user when calling the ethtool interface.
This flag indicates to the driver that it may overwrite settings in the RSS table. If false, it indicates the driver should do what it can to preserve the RSS table changes requested by the user. That is, for cases where it can preserve the table it must. If the value is set true, it means the driver may or may not apply the current settings and is free to change the values as necessary. The current default is set to false, as this is how most drivers appear to behave today.
--- drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 7 ++++-- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 7 ++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 5 +++- drivers/net/ethernet/broadcom/tg3.c | 8 +++++-- .../net/ethernet/cavium/thunder/nicvf_ethtool.c | 7 ++++-- drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 7 ++++-- drivers/net/ethernet/cisco/enic/enic_ethtool.c | 7 ++++-- drivers/net/ethernet/emulex/benet/be_ethtool.c | 7 ++++-- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 8 +++++-- drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 7 ++++-- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 7 ++++-- drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 6 +++-- drivers/net/ethernet/intel/igb/igb_ethtool.c | 6 +++-- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 7 ++++-- drivers/net/ethernet/intel/ixgbevf/ethtool.c | 5 +++- drivers/net/ethernet/marvell/mvneta.c | 8 +++++-- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 7 ++++-- .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 ++++-- .../net/ethernet/netronome/nfp/nfp_net_ethtool.c | 7 ++++-- drivers/net/ethernet/sfc/ethtool.c | 7 ++++-- include/linux/ethtool.h | 4 ++-- include/uapi/linux/ethtool.h | 8 ++++++- net/core/ethtool.c | 27 +++++++++++++--------- 23 files changed, 124 insertions(+), 52 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +5 -2
@@ -509,11 +509,14 @@ static u32 xgbe_get_rxfh_indir_size(struct net_device *netdev) }static int xgbe_get_rxfh (struct net_device *netdev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct xgbe_prv_data *pdata =netdev_priv (netdev);unsigned int i; +if (dynamic) + *dynamic = false; +if (indir) {for (i =0 ; i <ARRAY_SIZE (pdata->rss_table); i++) indir[i] = XGMAC_GET_BITS(pdata->rss_table[i],
@@ -530,7 +533,7 @@ static int xgbe_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, }static int xgbe_set_rxfh (struct net_device *netdev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc,const u8 dynamic) {struct xgbe_prv_data *pdata =netdev_priv (netdev);struct xgbe_hw_if *hw_if = &pdata->hw_if;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +5 -2
@@ -3417,12 +3417,15 @@ static u32 bnx2x_get_rxfh_indir_size(struct net_device *dev) }static int bnx2x_get_rxfh (struct net_device *dev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct bnx2x *bp =netdev_priv (dev);u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE ] = {0 };size_t i; +if (dynamic) + *dynamic = false; +if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;if (!indir)
@@ -3447,7 +3450,7 @@ static int bnx2x_get_rxfh(struct net_device *dev, u32 *indir, u8 *key, }static int bnx2x_set_rxfh (struct net_device *dev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc,const u8 dynamic) {struct bnx2x *bp =netdev_priv (dev);size_t i;
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +4 -1
@@ -437,12 +437,15 @@ static u32 bnxt_get_rxfh_key_size(struct net_device *dev) }static int bnxt_get_rxfh (struct net_device *dev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct bnxt *bp =netdev_priv (dev);struct bnxt_vnic_info *vnic = &bp->vnic_info[0 ];int i =0 ; +if (dynamic) + *dynamic = false; +if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;
drivers/net/ethernet/broadcom/tg3.c +6 -2
@@ -12561,11 +12561,15 @@ static u32 tg3_get_rxfh_indir_size(struct net_device *dev)return size; } -static int tg3_get_rxfh (struct net_device *dev,u32 *indir,u8 *key,u8 *hfunc) +static int tg3_get_rxfh (struct net_device *dev,u32 *indir,u8 *key,u8 *hfunc, +u8 *dynamic) {struct tg3 *tp =netdev_priv (dev);int i; +if (dynamic) + *dynamic = false; +if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;if (!indir)
@@ -12578,7 +12582,7 @@ static int tg3_get_rxfh(struct net_device *dev, u32 *indir, u8 *key, u8 *hfunc) }static int tg3_set_rxfh (struct net_device *dev,const u32 *indir,const u8 *key, -const u8 hfunc) +const u8 hfunc,const u8 dynamic) {struct tg3 *tp =netdev_priv (dev);size_t i;
drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c +5 -2
@@ -560,12 +560,15 @@ static u32 nicvf_get_rxfh_indir_size(struct net_device *dev) }static int nicvf_get_rxfh (struct net_device *dev,u32 *indir,u8 *hkey, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct nicvf *nic =netdev_priv (dev);struct nicvf_rss_info *rss = &nic->rss_info;int idx; +if (dynamic) + *dynamic = false; +if (indir) {for (idx =0 ; idx < rss->rss_size; idx++) indir[idx] = rss->ind_tbl[idx];
@@ -581,7 +584,7 @@ static int nicvf_get_rxfh(struct net_device *dev, u32 *indir, u8 *hkey, }static int nicvf_set_rxfh (struct net_device *dev,const u32 *indir, -const u8 *hkey,u8 hfunc) +const u8 *hkey,u8 hfunc,const u8 dynamic) {struct nicvf *nic =netdev_priv (dev);struct nicvf_rss_info *rss = &nic->rss_info;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +5 -2
@@ -989,11 +989,14 @@ static u32 get_rss_table_size(struct net_device *dev)return pi->rss_size; } -static int get_rss_table (struct net_device *dev,u32 *p,u8 *key,u8 *hfunc) +static int get_rss_table (struct net_device *dev,u32 *p,u8 *key,u8 *hfunc, +u8 *dynamic) {const struct port_info *pi =netdev_priv (dev);unsigned int n = pi->rss_size; +if (dynamic) + *dynamic = false;if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;if (!p)
@@ -1004,7 +1007,7 @@ static int get_rss_table(struct net_device *dev, u32 *p, u8 *key, u8 *hfunc) }static int set_rss_table (struct net_device *dev,const u32 *p,const u8 *key, -const u8 hfunc) +const u8 hfunc,const u8 dynamic) {unsigned int i;struct port_info *pi =netdev_priv (dev);
drivers/net/ethernet/cisco/enic/enic_ethtool.c +5 -2
@@ -471,10 +471,13 @@ static u32 enic_get_rxfh_key_size(struct net_device *netdev) }static int enic_get_rxfh (struct net_device *netdev,u32 *indir,u8 *hkey, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct enic *enic =netdev_priv (netdev); +if (dynamic) + *dynamic = false; +if (hkey)memcpy (hkey, enic->rss_key,ENIC_RSS_LEN );
@@ -485,7 +488,7 @@ static int enic_get_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey, }static int enic_set_rxfh (struct net_device *netdev,const u32 *indir, -const u8 *hkey,const u8 hfunc) +const u8 *hkey,const u8 hfunc,const u8 dynamic) {struct enic *enic =netdev_priv (netdev);
drivers/net/ethernet/emulex/benet/be_ethtool.c +5 -2
@@ -1200,12 +1200,15 @@ static u32 be_get_rxfh_key_size(struct net_device *netdev) }static int be_get_rxfh (struct net_device *netdev,u32 *indir,u8 *hkey, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct be_adapter *adapter =netdev_priv (netdev);int i;struct rss_info *rss = &adapter->rss_info; +if (dynamic) + *dynamic = false; +if (indir) {for (i =0 ; i <RSS_INDIR_TABLE_LEN ; i++) indir[i] = rss->rss_queue[i];
@@ -1221,7 +1224,7 @@ static int be_get_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey, }static int be_set_rxfh (struct net_device *netdev,const u32 *indir, -const u8 *hkey,const u8 hfunc) +const u8 *hkey,const u8 hfunc,const u8 dynamic) {int rc =0 , i, j;struct be_adapter *adapter =netdev_priv (netdev);
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +6 -2
@@ -1194,12 +1194,16 @@ hns_get_rss_indir_size(struct net_device *netdev) }static int -hns_get_rss (struct net_device *netdev,u32 *indir,u8 *key,u8 *hfunc) +hns_get_rss (struct net_device *netdev,u32 *indir,u8 *key,u8 *hfunc, +u8 *dynamic) {struct hns_nic_priv *priv =netdev_priv (netdev);struct hnae_ae_ops *ops;int ret; +if (dynamic) + *dynamic = false; +if (AE_IS_VER1 (priv->enet_ver)) {netdev_err (netdev,"RSS feature is not supported on this hardware\n" );
@@ -1218,7 +1222,7 @@ hns_get_rss(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc)static int hns_set_rss (struct net_device *netdev,const u32 *indir,const u8 *key, -const u8 hfunc) +const u8 hfunc,const u8 dynamic) {struct hns_nic_priv *priv =netdev_priv (netdev);struct hnae_ae_ops *ops;
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +5 -2
@@ -1091,7 +1091,7 @@ static u32 fm10k_get_rssrk_size(struct net_device __always_unused *netdev) }static int fm10k_get_rssh (struct net_device *netdev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct fm10k_intfc *interface =netdev_priv (netdev);int i, err;
@@ -1099,6 +1099,9 @@ static int fm10k_get_rssh(struct net_device *netdev, u32 *indir, u8 *key,if (hfunc) *hfunc =ETH_RSS_HASH_TOP ; +if (dynamic) + *dynamic = false; + err =fm10k_get_reta (netdev, indir);if (err || !key)return err;
@@ -1110,7 +1113,7 @@ static int fm10k_get_rssh(struct net_device *netdev, u32 *indir, u8 *key, }static int fm10k_set_rssh (struct net_device *netdev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc,const u8 dynamic) {struct fm10k_intfc *interface =netdev_priv (netdev);struct fm10k_hw *hw = &interface->hw;
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +5 -2
@@ -2630,7 +2630,7 @@ static u32 i40e_get_rxfh_indir_size(struct net_device *netdev) }static int i40e_get_rxfh (struct net_device *netdev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct i40e_netdev_priv *np =netdev_priv (netdev);struct i40e_vsi *vsi = np->vsi;
@@ -2638,6 +2638,9 @@ static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,int ret;u16 i; +if (dynamic) + *dynamic = false; +if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;
@@ -2670,7 +2673,7 @@ static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,* returns 0 after programming the table. **/ static int i40e_set_rxfh (struct net_device *netdev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc,const u8 dynamic) {struct i40e_netdev_priv *np =netdev_priv (netdev);struct i40e_vsi *vsi = np->vsi;
drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c +4 -2
@@ -643,7 +643,7 @@ static u32 i40evf_get_rxfh_indir_size(struct net_device *netdev)* Reads the indirection table directly from the hardware. Always returns 0. **/ static int i40evf_get_rxfh (struct net_device *netdev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct i40evf_adapter *adapter =netdev_priv (netdev);struct i40e_vsi *vsi = &adapter->vsi;
@@ -651,6 +651,8 @@ static int i40evf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,int ret;u16 i; +if (dynamic) + *dynamic = false;if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;if (!indir)
@@ -686,7 +688,7 @@ static int i40evf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,* returns 0 after programming the table. **/ static int i40evf_set_rxfh (struct net_device *netdev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc,const u8 dynamic) {struct i40evf_adapter *adapter =netdev_priv (netdev);struct i40e_vsi *vsi = &adapter->vsi;
drivers/net/ethernet/intel/igb/igb_ethtool.c +4 -2
@@ -3211,11 +3211,13 @@ static u32 igb_get_rxfh_indir_size(struct net_device *netdev) }static int igb_get_rxfh (struct net_device *netdev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct igb_adapter *adapter =netdev_priv (netdev);int i; +if (dynamic) + *dynamic = false;if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;if (!indir)
@@ -3262,7 +3264,7 @@ void igb_write_rss_indir_tbl(struct igb_adapter *adapter) }static int igb_set_rxfh (struct net_device *netdev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc,const u8 dynamic) {struct igb_adapter *adapter =netdev_priv (netdev);struct e1000_hw *hw = &adapter->hw;
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +5 -2
@@ -2931,10 +2931,13 @@ static void ixgbe_get_reta(struct ixgbe_adapter *adapter, u32 *indir) }static int ixgbe_get_rxfh (struct net_device *netdev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct ixgbe_adapter *adapter =netdev_priv (netdev); +if (dynamic) + *dynamic = false; +if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;
@@ -2948,7 +2951,7 @@ static int ixgbe_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, }static int ixgbe_set_rxfh (struct net_device *netdev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc,const u8 dynamic) {struct ixgbe_adapter *adapter =netdev_priv (netdev);int i;
drivers/net/ethernet/intel/ixgbevf/ethtool.c +4 -1
@@ -825,11 +825,14 @@ static u32 ixgbevf_get_rxfh_key_size(struct net_device *netdev) }static int ixgbevf_get_rxfh (struct net_device *netdev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct ixgbevf_adapter *adapter =netdev_priv (netdev);int err =0 ; +if (dynamic) + *dynamic = false; +if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;
drivers/net/ethernet/marvell/mvneta.c +6 -2
@@ -3350,7 +3350,8 @@ static int mvneta_config_rss(struct mvneta_port *pp) }static int mvneta_ethtool_set_rxfh (struct net_device *dev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc, +const u8 dynamic) {struct mvneta_port *pp =netdev_priv (dev);/* We require at least one supported parameter to be changed
@@ -3369,10 +3370,13 @@ static int mvneta_ethtool_set_rxfh(struct net_device *dev, const u32 *indir, }static int mvneta_ethtool_get_rxfh (struct net_device *dev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct mvneta_port *pp =netdev_priv (dev); +if (dynamic) + *dynamic = false; +if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +5 -2
@@ -1118,7 +1118,7 @@ static int mlx4_en_check_rxfh_func(struct net_device *dev, u8 hfunc) }static int mlx4_en_get_rxfh (struct net_device *dev,u32 *ring_index,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct mlx4_en_priv *priv =netdev_priv (dev);struct mlx4_en_rss_map *rss_map = &priv->rss_map;
@@ -1126,6 +1126,9 @@ static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key,size_t n = priv->rx_ring_num;int err =0 ; +if (dynamic) + *dynamic = false; + rss_rings = priv->prof->rss_rings ?: priv->rx_ring_num; rss_rings =1 <<ilog2 (rss_rings);
@@ -1143,7 +1146,7 @@ static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key, }static int mlx4_en_set_rxfh (struct net_device *dev,const u32 *ring_index, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc,const u8 dynamic) {struct mlx4_en_priv *priv =netdev_priv (dev);struct mlx4_en_dev *mdev = priv->mdev;
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +5 -2
@@ -685,10 +685,13 @@ static u32 mlx5e_get_rxfh_indir_size(struct net_device *netdev) }static int mlx5e_get_rxfh (struct net_device *netdev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct mlx5e_priv *priv =netdev_priv (netdev); +if (dynamic) + *dynamic = false; +if (indir)memcpy (indir, priv->params.indirection_rqt,sizeof (priv->params.indirection_rqt));
@@ -704,7 +707,7 @@ static int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, }static int mlx5e_set_rxfh (struct net_device *dev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc,const u8 dynamic) {struct mlx5e_priv *priv =netdev_priv (dev);bool close_open;
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +5 -2
@@ -454,7 +454,7 @@ static u32 nfp_net_get_rxfh_key_size(struct net_device *netdev) }static int nfp_net_get_rxfh (struct net_device *netdev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct nfp_net *nn =netdev_priv (netdev);int i;
@@ -462,6 +462,9 @@ static int nfp_net_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,if (!(nn->cap &NFP_NET_CFG_CTRL_RSS ))return -EOPNOTSUPP ; +if (dynamic) + *dynamic = false; +if (indir)for (i =0 ; i <ARRAY_SIZE (nn->rss_itbl); i++) indir[i] = nn->rss_itbl[i];
@@ -475,7 +478,7 @@ static int nfp_net_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,static int nfp_net_set_rxfh (struct net_device *netdev,const u32 *indir,const u8 *key, -const u8 hfunc) +const u8 hfunc,const u8 dynamic) {struct nfp_net *nn =netdev_priv (netdev);int i;
drivers/net/ethernet/sfc/ethtool.c +5 -2
@@ -1087,10 +1087,12 @@ static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev) }static int efx_ethtool_get_rxfh (struct net_device *net_dev,u32 *indir,u8 *key, -u8 *hfunc) +u8 *hfunc,u8 *dynamic) {struct efx_nic *efx =netdev_priv (net_dev); +if (dynamic) + *dynamic = false;if (hfunc) *hfunc =ETH_RSS_HASH_TOP ;if (indir)
@@ -1099,7 +1101,8 @@ static int efx_ethtool_get_rxfh(struct net_device *net_dev, u32 *indir, u8 *key, }static int efx_ethtool_set_rxfh (struct net_device *net_dev,const u32 *indir, -const u8 *key,const u8 hfunc) +const u8 *key,const u8 hfunc, +const u8 dynamic) {struct efx_nic *efx =netdev_priv (net_dev);
include/linux/ethtool.h +2 -2
@@ -259,9 +259,9 @@ struct ethtool_ops {u32 (*get_rxfh_key_size)(struct net_device *);u32 (*get_rxfh_indir_size)(struct net_device *);int (*get_rxfh)(struct net_device *,u32 *indir,u8 *key, -u8 *hfunc); +u8 *hfunc,u8 *dynamic);int (*set_rxfh)(struct net_device *,const u32 *indir, -const u8 *key,const u8 hfunc); +const u8 *key,const u8 hfunc,const u8 dynamic);void (*get_channels)(struct net_device *,struct ethtool_channels *);int (*set_channels)(struct net_device *,struct ethtool_channels *);int (*get_dump_flag)(struct net_device *,struct ethtool_dump *);
include/uapi/linux/ethtool.h +7 -1
@@ -923,6 +923,10 @@ struct ethtool_rxfh_indir {* hardware hash key. * @hfunc: Defines the current RSS hash function used by HW (or to be set to). * Valid values are one of the %ETH_RSS_HASH_*. +* @dynamic: Indicate whether the device driver may use dynamic RSS settings +* which change due to various run time factors, such as number of +* queues. When false driver must attempt to preserve RSS settings when +* possible. When true driver may override any requested RSS settings. * @rsvd: Reserved for future extensions. * @rss_config: RX ring/queue index for each hash value i.e., indirection table * of @indir_size __u32 elements, followed by hash key of @key_size
@@ -933,6 +937,7 @@ struct ethtool_rxfh_indir {* %ETH_RXFH_INDIR_NO_CHANGE means that indir table setting is not requested * and a @indir_size of zero means the indir table should be reset to default * values. An hfunc of zero means that hash function setting is not requested. +* If dynamic is true, driver may ignore any other settings requested. */ struct ethtool_rxfh {__u32 cmd;
@@ -940,7 +945,8 @@ struct ethtool_rxfh {__u32 indir_size;__u32 key_size;__u8 hfunc; -__u8 rsvd8[3 ]; +__u8 dynamic; +__u8 rsvd8[2 ];__u32 rsvd32;__u32 rss_config[0 ]; };
net/core/ethtool.c +16 -11
@@ -676,7 +676,7 @@ static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,if (!indir)return -ENOMEM ; - ret = dev->ethtool_ops->get_rxfh (dev, indir,NULL ,NULL ); + ret = dev->ethtool_ops->get_rxfh (dev, indir,NULL ,NULL ,NULL );if (ret) goto out;
@@ -737,7 +737,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev, goto out; } - ret = ops->set_rxfh (dev, indir,NULL ,ETH_RSS_HASH_NO_CHANGE ); + ret = ops->set_rxfh (dev, indir,NULL ,ETH_RSS_HASH_NO_CHANGE , false); out:kfree (indir);
@@ -755,7 +755,7 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,u32 total_size;u32 indir_bytes;u32 *indir =NULL ; -u8 dev_hfunc =0 ; +u8 dev_hfunc =0 , dynamic =0 ;u8 *hkey =NULL ;u8 *rss_config;
@@ -773,8 +773,7 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, user_key_size = rxfh.key_size;/* Check that reserved fields are 0 for now */ -if (rxfh.rss_context || rxfh.rsvd8[0 ] || rxfh.rsvd8[1 ] || - rxfh.rsvd8[2 ] || rxfh.rsvd32) +if (rxfh.rss_context || rxfh.rsvd8[0 ] || rxfh.rsvd8[1 ] || rxfh.rsvd32)return -EINVAL ; rxfh.indir_size = dev_indir_size;
@@ -798,7 +797,8 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,if (user_key_size) hkey = rss_config + indir_bytes; - ret = dev->ethtool_ops->get_rxfh (dev, indir, hkey, &dev_hfunc); + ret = dev->ethtool_ops->get_rxfh (dev, indir, hkey, &dev_hfunc, + &dynamic);if (ret) goto out;
@@ -809,6 +809,10 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, offsetof(struct ethtool_rxfh, rss_config[0]), rss_config, total_size)) { ret = -EFAULT ; + } else if (copy_to_user(useraddr + + offsetof(struct ethtool_rxfh, dynamic), + &dynamic, sizeof(rxfh.dynamic))) { + ret = -EFAULT ; } out:kfree (rss_config);
@@ -841,19 +845,20 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,return -EFAULT ;/* Check that reserved fields are 0 for now */ -if (rxfh.rss_context || rxfh.rsvd8[0 ] || rxfh.rsvd8[1 ] || - rxfh.rsvd8[2 ] || rxfh.rsvd32) +if (rxfh.rss_context || rxfh.rsvd8[0 ] || rxfh.rsvd8[1 ] || rxfh.rsvd32)return -EINVAL ;/* If either indir, hash key or function is valid, proceed further. -* Must request at least one change: indir size, hash key or function. +* Must request at least one change: indir size, hash key, function or +* dynamic mode. */ if ((rxfh.indir_size && rxfh.indir_size !=ETH_RXFH_INDIR_NO_CHANGE && rxfh.indir_size != dev_indir_size) || (rxfh.key_size && (rxfh.key_size != dev_key_size)) || (rxfh.indir_size ==ETH_RXFH_INDIR_NO_CHANGE && - rxfh.key_size ==0 && rxfh.hfunc ==ETH_RSS_HASH_NO_CHANGE )) + rxfh.key_size ==0 && rxfh.hfunc ==ETH_RSS_HASH_NO_CHANGE && + rxfh.dynamic ==0 ))return -EINVAL ;if (rxfh.indir_size !=ETH_RXFH_INDIR_NO_CHANGE )
@@ -896,7 +901,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, } } - ret = ops->set_rxfh (dev, indir, hkey, rxfh.hfunc); + ret = ops->set_rxfh (dev, indir, hkey, rxfh.hfunc, rxfh.dynamic); out:kfree (rss_config);
Signature · 1 line
2.6.3.505.g5cc1fd1
PATCH 2/2 fm10k: support dynamic mode for RSS table control
In reply to Jacob KellerAdd support for the new dynamic flag from set_rxfh and get_rxfh. For now the only known dynamic reason to change RSS is when number of queues is changed. The default mode for the driver will be dynamic, indicating that the driver is free to change its own default setting as it sees fit. Since the current default userspace ethtool operation will only send false as the value to dynamic this results in the behavior that the driver configured RSS settings are capable of being modified but user supplied changes will be preserved as long as possible.
In practice, this resolves an issue where decreasing the number of queues and then increasing them shall no longer break RSS unless the user has manually configured a non-dynamic RSS table setting.
If the user has configured the RSS table without setting dynamic, the driver will do its best to maintain the configuration. If this is not possible, we will indicate that the mode is now dynamic and reset to driver defaults.
--- drivers/net/ethernet/intel/fm10k/fm10k.h | 1 + drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 10 +++++++++- drivers/net/ethernet/intel/fm10k/fm10k_main.c | 8 +++++--- 3 files changed, 15 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k.h +1 -0
@@ -268,6 +268,7 @@ struct fm10k_intfc {#define FM10K_FLAG_RX_TS_ENABLED (u32)(BIT(3))#define FM10K_FLAG_SWPRI_CONFIG (u32)(BIT(4))#define FM10K_FLAG_DEBUG_STATS (u32)(BIT(5)) +#define FM10K_FLAG_STATIC_RETA_TBL (u32)(BIT(6))int xcast_mode;/* Tx fast path data */
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +9 -1
@@ -1100,7 +1100,7 @@ static int fm10k_get_rssh(struct net_device *netdev, u32 *indir, u8 *key, *hfunc =ETH_RSS_HASH_TOP ;if (dynamic) - *dynamic = false; + *dynamic = !(interface->flags &FM10K_FLAG_STATIC_RETA_TBL ); err =fm10k_get_reta (netdev, indir);if (err || !key)
@@ -1123,6 +1123,14 @@ static int fm10k_set_rssh(struct net_device *netdev, const u32 *indir,if (hfunc !=ETH_RSS_HASH_NO_CHANGE && hfunc !=ETH_RSS_HASH_TOP )return -EOPNOTSUPP ; +/* If dynamic mode is not requested, enable the static flag. We'll +* still attempt to populate the RETA table using the provided +* settings if possible. */ +if (dynamic) + interface->flags &= ~FM10K_FLAG_STATIC_RETA_TBL ; +else + interface->flags |=FM10K_FLAG_STATIC_RETA_TBL ; + err =fm10k_set_reta (netdev, indir);if (err || !key)return err;
drivers/net/ethernet/intel/fm10k/fm10k_main.c +5 -3
@@ -1932,13 +1932,13 @@ static void fm10k_assign_rings(struct fm10k_intfc *interface)fm10k_cache_ring_rss (interface); } -static void fm10k_init_reta (struct fm10k_intfc *interface) +void fm10k_init_reta (struct fm10k_intfc *interface) {u16 i, rss_i = interface->ring_feature[RING_F_RSS ].indices;u32 reta, base; -/* If the netdev is initialized we have to maintain table if possible */ -if (interface->netdev->reg_state !=NETREG_UNINITIALIZED ) { +/* Maintain static user provided table if possible. */ +if (interface->flags &FM10K_FLAG_STATIC_RETA_TBL ) {for (i =FM10K_RETA_SIZE ; i--;) { reta = interface->reta[i]; if ((((reta << 24) >> 24) < rss_i) &&
@@ -1954,6 +1954,8 @@ static void fm10k_init_reta(struct fm10k_intfc *interface) } repopulate_reta: + interface->flags &= ~FM10K_FLAG_STATIC_RETA_TBL ; +/* Populate the redirection table 4 entries at a time. To do this * we are generating the results for n and n+2 and then interleaving * those with the results with n+1 and n+3.
Signature · 1 line
2.6.3.505.g5cc1fd1
PATCH 1/1 ethtool: add support for dynamic mode in {SG}RXFH commands
In reply to Jacob Keller--- ethtool-copy.h | 8 +++++++- ethtool.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-)
ethtool-copy.h +7 -1
@@ -890,6 +890,10 @@ struct ethtool_rxfh_indir {* hardware hash key. * @hfunc: Defines the current RSS hash function used by HW (or to be set to). * Valid values are one of the %ETH_RSS_HASH_*. +* @dynamic: Indicate whether the device driver may use dynamic RSS settings +* which change due to various run time factors, such as number of +* queues. When false driver must attempt to preserve RSS settings when +* possible. When true driver may override any requested RSS settings. * @rsvd: Reserved for future extensions. * @rss_config: RX ring/queue index for each hash value i.e., indirection table * of @indir_size __u32 elements, followed by hash key of @key_size
@@ -900,6 +904,7 @@ struct ethtool_rxfh_indir {* %ETH_RXFH_INDIR_NO_CHANGE means that indir table setting is not requested * and a @indir_size of zero means the indir table should be reset to default * values. An hfunc of zero means that hash function setting is not requested. +* If dynamic is true, driver may ignore any other settings requested. */ struct ethtool_rxfh {__u32 cmd;
@@ -907,7 +912,8 @@ struct ethtool_rxfh {__u32 indir_size;__u32 key_size;__u8 hfunc; -__u8 rsvd8[3 ]; +__u8 dynamic; +__u8 rsvd8[2 ];__u32 rsvd32;__u32 rss_config[0 ]; };
ethtool.c +35 -1
@@ -917,6 +917,19 @@ static int convert_string_to_hashkey(char *rss_hkey, u32 key_size,return 2 ; } +static u8 parse_dynamic (const char *rss_dynamic,u8 *dynamic) +{ +if (!strcmp (rss_dynamic,"on" )) { + *dynamic =1 ; +return 0 ; + }else if (!strcmp (rss_dynamic,"off" )) { + *dynamic =0 ; +return 0 ; + }else { +return 2 ; + } +} +static int parse_hkey (char **rss_hkey,u32 key_size,const char *rss_hkey_string) {
@@ -3213,6 +3226,11 @@ static int do_grxfh(struct cmd_context *ctx) indir_bytes = rss->indir_size *sizeof (rss->rss_config[0 ]); hkey = ((char *)rss->rss_config + indir_bytes); +if (rss->dynamic) +printf ("Dynamic mode enabled\n" ); +else +printf ("Static mode enabled\n" ); +printf ("RSS hash key:\n" );if (!rss->key_size)printf ("Operation not supported\n" );
@@ -3326,11 +3344,13 @@ static int do_srxfh(struct cmd_context *ctx)int rxfhindir_equal =0 ;char **rxfhindir_weight =NULL ;char *rxfhindir_key =NULL ; +char *rxfh_dynamic =NULL ;char *hkey =NULL ;int err =0 ;u32 arg_num =0 , indir_bytes =0 ;u32 entry_size =sizeof (rss_head.rss_config[0 ]);u32 num_weights =0 ; +u8 dynamic =0 ;if (ctx->argc <2 )exit_bad_args ();
@@ -3357,6 +3377,12 @@ static int do_srxfh(struct cmd_context *ctx)if (!rxfhindir_key)exit_bad_args (); ++arg_num; + }else if (!strcmp (ctx->argp[arg_num],"dynamic" )) { + ++arg_num; + rxfh_dynamic = ctx->argp[arg_num]; +if (!rxfhindir_key) +exit_bad_args (); + ++arg_num; }else {exit_bad_args (); }
@@ -3392,6 +3418,12 @@ static int do_srxfh(struct cmd_context *ctx)return err; } +if (rxfh_dynamic) { + err =parse_dynamic (rxfh_dynamic, &dynamic); +if (err) +return err; + } +if (rxfhindir_equal || rxfhindir_weight) indir_bytes = rss_head.indir_size * entry_size;
@@ -3403,6 +3435,7 @@ static int do_srxfh(struct cmd_context *ctx) rss->cmd =ETHTOOL_SRSSH ; rss->indir_size = rss_head.indir_size; rss->key_size = rss_head.key_size; + rss->dynamic = dynamic;if (fill_indir_table (&rss->indir_size, rss->rss_config, rxfhindir_equal, rxfhindir_weight, num_weights)) {
@@ -4112,7 +4145,8 @@ static const struct option { {"-X|--set-rxfh-indir|--rxfh" ,1 , do_srxfh,"Set Rx flow hash indirection and/or hash key" ," [ equal N | weight W0 W1 ... ]\n" - " [ hkey %x:%x:%x:%x:%x:.... ]\n" }, +" [ hkey %x:%x:%x:%x:%x:.... ]\n" + " [ dynamic on|off ]\n" }, { "-f|--flash", 1, do_flash,"Flash firmware image from the specified file to a region on the device" , " FILENAME [ REGION-NUMBER-TO-FLASH ]\n" },
Signature · 1 line
2.6.3.505.g5cc1fd1
David Miller
maintainerRe: [PATCH 1/2] ethtool: add dynamic flag to ETHTOOL_{GS}RXFH commands
In reply to Jacob KellerFrom: Jacob Keller <[email protected]>
Date: Tue, 2 Feb 2016 15:22:06 -0800
Quoted 5 lines
Ethtool supports a few operations for modifying and controlling a device's RSS table. Sometimes, changes in other features of the device may require (or desire) changes to the RSS table. Currently there is no method to indicate to the driver whether the current RSS table settings should be maintained or overridden.
Yes, there certainly is a way to indicate this.
If the user asks for the change in the number of queues, and you cannot retain the user's requested RSS settings, then you must fail the queue setting change.
And vice versa.
You can't say to the user "I can adhere to your requested configuration change, but I might undo it for some unspecified reason"
That's unacceptable behavior, and that's exactly what this dynamic flag means.
If you cannot give the user what he asks for, precisely and reliably, you fail the operation with an error.
There is no way I am adding code which allows these "maybe" kind of configuration operations. Either you can or you can't, and you tell the user when you can't by erroring out on the operation that invalidates the requirements.
Re: [PATCH 1/2] ethtool: add dynamic flag to ETHTOOL_{GS}RXFH commands
Quoted 18 lines · David Miller
From: Jacob Keller <[email protected]>
Date: Tue, 2 Feb 2016 15:22:06 -0800Quoted 8 lines
Ethtool supports a few operations for modifying and controlling a device's RSS table. Sometimes, changes in other features of the device
may require (or desire) changes to the RSS table. Currently there is no
method to indicate to the driver whether the current RSS table settings
should be maintained or overridden.Yes, there certainly is a way to indicate this.
If the user asks for the change in the number of queues, and you cannot retain the user's requested RSS settings, then you must fail the queue setting change.
Quoted 6 lines
And vice versa.
You can't say to the user "I can adhere to your requested configuration
change, but I might undo it for some unspecified reason"
The trouble here is the case where the indirection table configurations are valid now, but a change in the number of queues happening at a later time currently causes these settings to be lost.
Quoted 12 lines
That's unacceptable behavior, and that's exactly what this dynamic flag means.
If you cannot give the user what he asks for, precisely and reliably, you fail the operation with an error.
There is no way I am adding code which allows these "maybe" kind of configuration operations. Either you can or you can't, and you tell the user when you can't by erroring out on the operation that invalidates the requirements.
So you're suggesting instead, to error when the second operation (change number of queues) would fail the current settings?
Current driver behaviors for all the drivers I checked work in one of two ways.
1) changing queues will destroy the RSS table as it will be reinitialized regardless of current settings
2) changing queues will maintain the RSS table if possible, unless the previous RSS table can't function.
No driver currently fails this operation if the RSS table settings can't be preserved. In addition it results in weird behavior when a driver sets the RSS table at load, then increases the number of queues via an ethtool op, the result is that RSS does not use the new queues added by the ethtool operation.
I can instead drop the ethtool changes and just have my driver record when the user has changed the tables, and attempt to error on queue setting operation, which may work.
Essentially the idea was to have a flag indicating "use the driver defaults" which the driver can change as necessary when the number of queues changes, or other factors that may require RSS table changes.
I can do this all hidden in the driver but then there is nothing exposing how the driver will behave under this circumstance.
I'm all for a better suggestion, because I think what we're doing now is wrong, and the proposed solutions so far don't seem right either.
If we preserve the RSS table when queues increase, then the user may be confused because RSS settings won't spread to the new queues. If we destroy the RSS settings the user will be possibly confused because their selected RSS settings do not work. If we fail the setting of queues when RSS table is not the default value, then a user might be confused as to why they can't change the number of queues. Also, I am unsure whether or not we can tell from the ethtool op function that we actually are being "reset" to the default, vs just being set. This is because the netlink message of "0 length" which indicates default simply has the ethtool core fill in a standard equal weight default, which I am not sure our driver can tell that it should now be ok to enable queue changes.
So, something is missing in the current flow to allow this. I think the best solution is simply prevent changing number of queues while we have a non-default RSS setting, and require RSS to be reset before queues can be changed.
Thoughts?
Regards,
Jake
David Miller
maintainerRe: [PATCH 1/2] ethtool: add dynamic flag to ETHTOOL_{GS}RXFH commands
From: "Keller, Jacob E" <[email protected]>
Date: Thu, 4 Feb 2016 23:09:56 +0000
Quoted 2 lines
So you're suggesting instead, to error when the second operation (change number of queues) would fail the current settings?
Yes.
This is absolutely required.
Re: [PATCH 1/2] ethtool: add dynamic flag to ETHTOOL_{GS}RXFH commands
Quoted 9 lines · David Miller
From: "Keller, Jacob E" <[email protected]>
Date: Thu, 4 Feb 2016 23:09:56 +0000Quoted 2 lines
So you're suggesting instead, to error when the second operation (change number of queues) would fail the current settings?
Yes.
This is absolutely required.
I will investigate this route. I think there needs to some way for the {GS}RXFH to pass enough information in a way the driver can clearly see as "reset to default", but otherwise I think this is pretty straight forward to implement.
Thanks,
Jake