Skip to content

Commit b7ec78f

Browse files
azaki1NipaLocal
authored andcommitted
net: ethtool: get rid of get/set_rxfh_context functions
Add the RSS context parameters to struct ethtool_rxfh_param and use the get/set_rxfh to handle the RSS contexts as well. This is part 2/2 of the fix suggested in [1]: - Add a rss_context member to the argument struct and a capability like cap_link_lanes_supported to indicate whether driver supports rss contexts, then you can remove *et_rxfh_context functions, and instead call *et_rxfh() with a non-zero rss_context. Link: https://lore.kernel.org/netdev/[email protected]/ [1] CC: Jesse Brandeburg <[email protected]> CC: Tony Nguyen <[email protected]> CC: Marcin Wojtas <[email protected]> CC: Russell King <[email protected]> CC: Sunil Goutham <[email protected]> CC: Geetha sowjanya <[email protected]> CC: Subbaraya Sundeep <[email protected]> CC: hariprasad <[email protected]> CC: Saeed Mahameed <[email protected]> CC: Leon Romanovsky <[email protected]> CC: Edward Cree <[email protected]> CC: Martin Habets <[email protected]> Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Ahmed Zaki <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 5f5e04d commit b7ec78f

File tree

14 files changed

+205
-300
lines changed

14 files changed

+205
-300
lines changed

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3195,11 +3195,18 @@ static u32 ice_get_rxfh_indir_size(struct net_device *netdev)
31953195
return np->vsi->rss_table_size;
31963196
}
31973197

3198+
/**
3199+
* ice_get_rxfh - get the Rx flow hash indirection table
3200+
* @netdev: network interface device structure
3201+
* @rxfh: pointer to param struct (indir, key, hfunc)
3202+
*
3203+
* Reads the indirection table directly from the hardware.
3204+
*/
31983205
static int
3199-
ice_get_rxfh_context(struct net_device *netdev,
3200-
struct ethtool_rxfh_param *rxfh, u32 rss_context)
3206+
ice_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
32013207
{
32023208
struct ice_netdev_priv *np = netdev_priv(netdev);
3209+
u32 rss_context = rxfh->rss_context;
32033210
struct ice_vsi *vsi = np->vsi;
32043211
struct ice_pf *pf = vsi->back;
32053212
u16 qcount, offset;
@@ -3261,19 +3268,6 @@ ice_get_rxfh_context(struct net_device *netdev,
32613268
return err;
32623269
}
32633270

3264-
/**
3265-
* ice_get_rxfh - get the Rx flow hash indirection table
3266-
* @netdev: network interface device structure
3267-
* @rxfh: pointer to param struct (indir, key, hfunc)
3268-
*
3269-
* Reads the indirection table directly from the hardware.
3270-
*/
3271-
static int
3272-
ice_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
3273-
{
3274-
return ice_get_rxfh_context(netdev, rxfh, 0);
3275-
}
3276-
32773271
/**
32783272
* ice_set_rxfh - set the Rx flow hash indirection table
32793273
* @netdev: network interface device structure
@@ -3298,6 +3292,9 @@ ice_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
32983292
rxfh->hfunc != ETH_RSS_HASH_TOP)
32993293
return -EOPNOTSUPP;
33003294

3295+
if (rxfh->rss_context)
3296+
return -EOPNOTSUPP;
3297+
33013298
if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
33023299
/* RSS not supported return error here */
33033300
netdev_warn(netdev, "RSS is not configured on this VSI!\n");
@@ -4215,6 +4212,7 @@ ice_get_module_eeprom(struct net_device *netdev,
42154212
}
42164213

42174214
static const struct ethtool_ops ice_ethtool_ops = {
4215+
.cap_rss_ctx_supported = true,
42184216
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
42194217
ETHTOOL_COALESCE_USE_ADAPTIVE |
42204218
ETHTOOL_COALESCE_RX_USECS_HIGH,
@@ -4248,7 +4246,6 @@ static const struct ethtool_ops ice_ethtool_ops = {
42484246
.set_pauseparam = ice_set_pauseparam,
42494247
.get_rxfh_key_size = ice_get_rxfh_key_size,
42504248
.get_rxfh_indir_size = ice_get_rxfh_indir_size,
4251-
.get_rxfh_context = ice_get_rxfh_context,
42524249
.get_rxfh = ice_get_rxfh,
42534250
.set_rxfh = ice_set_rxfh,
42544251
.get_channels = ice_get_channels,

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5650,47 +5650,7 @@ static int mvpp2_ethtool_get_rxfh(struct net_device *dev,
56505650
struct ethtool_rxfh_param *rxfh)
56515651
{
56525652
struct mvpp2_port *port = netdev_priv(dev);
5653-
int ret = 0;
5654-
5655-
if (!mvpp22_rss_is_supported(port))
5656-
return -EOPNOTSUPP;
5657-
5658-
if (rxfh->indir)
5659-
ret = mvpp22_port_rss_ctx_indir_get(port, 0, rxfh->indir);
5660-
5661-
rxfh->hfunc = ETH_RSS_HASH_CRC32;
5662-
5663-
return ret;
5664-
}
5665-
5666-
static int mvpp2_ethtool_set_rxfh(struct net_device *dev,
5667-
struct ethtool_rxfh_param *rxfh,
5668-
struct netlink_ext_ack *extack)
5669-
{
5670-
struct mvpp2_port *port = netdev_priv(dev);
5671-
int ret = 0;
5672-
5673-
if (!mvpp22_rss_is_supported(port))
5674-
return -EOPNOTSUPP;
5675-
5676-
if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
5677-
rxfh->hfunc != ETH_RSS_HASH_CRC32)
5678-
return -EOPNOTSUPP;
5679-
5680-
if (rxfh->key)
5681-
return -EOPNOTSUPP;
5682-
5683-
if (rxfh->indir)
5684-
ret = mvpp22_port_rss_ctx_indir_set(port, 0, rxfh->indir);
5685-
5686-
return ret;
5687-
}
5688-
5689-
static int mvpp2_ethtool_get_rxfh_context(struct net_device *dev,
5690-
struct ethtool_rxfh_param *rxfh,
5691-
u32 rss_context)
5692-
{
5693-
struct mvpp2_port *port = netdev_priv(dev);
5653+
u32 rss_context = rxfh->rss_context;
56945654
int ret = 0;
56955655

56965656
if (!mvpp22_rss_is_supported(port))
@@ -5707,12 +5667,13 @@ static int mvpp2_ethtool_get_rxfh_context(struct net_device *dev,
57075667
return ret;
57085668
}
57095669

5710-
static int mvpp2_ethtool_set_rxfh_context(struct net_device *dev,
5711-
struct ethtool_rxfh_param *rxfh,
5712-
u32 *rss_context, bool delete)
5670+
static int mvpp2_ethtool_set_rxfh(struct net_device *dev,
5671+
struct ethtool_rxfh_param *rxfh,
5672+
struct netlink_ext_ack *extack)
57135673
{
57145674
struct mvpp2_port *port = netdev_priv(dev);
5715-
int ret;
5675+
u32 *rss_context = &rxfh->rss_context;
5676+
int ret = 0;
57165677

57175678
if (!mvpp22_rss_is_supported(port))
57185679
return -EOPNOTSUPP;
@@ -5724,7 +5685,7 @@ static int mvpp2_ethtool_set_rxfh_context(struct net_device *dev,
57245685
if (rxfh->key)
57255686
return -EOPNOTSUPP;
57265687

5727-
if (delete)
5688+
if (*rss_context && rxfh->rss_delete)
57285689
return mvpp22_port_rss_ctx_delete(port, *rss_context);
57295690

57305691
if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) {
@@ -5733,8 +5694,13 @@ static int mvpp2_ethtool_set_rxfh_context(struct net_device *dev,
57335694
return ret;
57345695
}
57355696

5736-
return mvpp22_port_rss_ctx_indir_set(port, *rss_context, rxfh->indir);
5697+
if (rxfh->indir)
5698+
ret = mvpp22_port_rss_ctx_indir_set(port, *rss_context,
5699+
rxfh->indir);
5700+
5701+
return ret;
57375702
}
5703+
57385704
/* Device ops */
57395705

57405706
static const struct net_device_ops mvpp2_netdev_ops = {
@@ -5754,6 +5720,7 @@ static const struct net_device_ops mvpp2_netdev_ops = {
57545720
};
57555721

57565722
static const struct ethtool_ops mvpp2_eth_tool_ops = {
5723+
.cap_rss_ctx_supported = true,
57575724
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
57585725
ETHTOOL_COALESCE_MAX_FRAMES,
57595726
.nway_reset = mvpp2_ethtool_nway_reset,
@@ -5776,8 +5743,6 @@ static const struct ethtool_ops mvpp2_eth_tool_ops = {
57765743
.get_rxfh_indir_size = mvpp2_ethtool_get_rxfh_indir_size,
57775744
.get_rxfh = mvpp2_ethtool_get_rxfh,
57785745
.set_rxfh = mvpp2_ethtool_set_rxfh,
5779-
.get_rxfh_context = mvpp2_ethtool_get_rxfh_context,
5780-
.set_rxfh_context = mvpp2_ethtool_set_rxfh_context,
57815746
};
57825747

57835748
/* Used for PPv2.1, or PPv2.2 with the old Device Tree binding that

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -835,11 +835,12 @@ static int otx2_rss_ctx_create(struct otx2_nic *pfvf,
835835
return 0;
836836
}
837837

838-
/* RSS context configuration */
839-
static int otx2_set_rxfh_context(struct net_device *dev,
840-
struct ethtool_rxfh_param *rxfh,
841-
u32 *rss_context, bool delete)
838+
/* Configure RSS table and hash key */
839+
static int otx2_set_rxfh(struct net_device *dev,
840+
struct ethtool_rxfh_param *rxfh,
841+
struct netlink_ext_ack *extack)
842842
{
843+
u32 rss_context = DEFAULT_RSS_CONTEXT_GROUP;
843844
struct otx2_nic *pfvf = netdev_priv(dev);
844845
struct otx2_rss_ctx *rss_ctx;
845846
struct otx2_rss_info *rss;
@@ -849,8 +850,11 @@ static int otx2_set_rxfh_context(struct net_device *dev,
849850
rxfh->hfunc != ETH_RSS_HASH_TOP)
850851
return -EOPNOTSUPP;
851852

852-
if (*rss_context != ETH_RXFH_CONTEXT_ALLOC &&
853-
*rss_context >= MAX_RSS_GROUPS)
853+
if (rxfh->rss_context)
854+
rss_context = rxfh->rss_context;
855+
856+
if (rss_context != ETH_RXFH_CONTEXT_ALLOC &&
857+
rss_context >= MAX_RSS_GROUPS)
854858
return -EINVAL;
855859

856860
rss = &pfvf->hw.rss_info;
@@ -864,28 +868,30 @@ static int otx2_set_rxfh_context(struct net_device *dev,
864868
memcpy(rss->key, rxfh->key, sizeof(rss->key));
865869
otx2_set_rss_key(pfvf);
866870
}
867-
if (delete)
868-
return otx2_rss_ctx_delete(pfvf, *rss_context);
871+
if (rxfh->rss_delete)
872+
return otx2_rss_ctx_delete(pfvf, rss_context);
869873

870-
if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) {
871-
ret = otx2_rss_ctx_create(pfvf, rss_context);
874+
if (rss_context == ETH_RXFH_CONTEXT_ALLOC) {
875+
ret = otx2_rss_ctx_create(pfvf, &rss_context);
876+
rxfh->rss_context = rss_context;
872877
if (ret)
873878
return ret;
874879
}
875880
if (rxfh->indir) {
876-
rss_ctx = rss->rss_ctx[*rss_context];
881+
rss_ctx = rss->rss_ctx[rss_context];
877882
for (idx = 0; idx < rss->rss_size; idx++)
878883
rss_ctx->ind_tbl[idx] = rxfh->indir[idx];
879884
}
880-
otx2_set_rss_table(pfvf, *rss_context);
885+
otx2_set_rss_table(pfvf, rss_context);
881886

882887
return 0;
883888
}
884889

885-
static int otx2_get_rxfh_context(struct net_device *dev,
886-
struct ethtool_rxfh_param *rxfh,
887-
u32 rss_context)
890+
/* Get RSS configuration */
891+
static int otx2_get_rxfh(struct net_device *dev,
892+
struct ethtool_rxfh_param *rxfh)
888893
{
894+
u32 rss_context = DEFAULT_RSS_CONTEXT_GROUP;
889895
struct otx2_nic *pfvf = netdev_priv(dev);
890896
struct otx2_rss_ctx *rss_ctx;
891897
struct otx2_rss_info *rss;
@@ -895,6 +901,8 @@ static int otx2_get_rxfh_context(struct net_device *dev,
895901
rss = &pfvf->hw.rss_info;
896902

897903
rxfh->hfunc = ETH_RSS_HASH_TOP;
904+
if (rxfh->rss_context)
905+
rss_context = rxfh->rss_context;
898906

899907
if (!indir)
900908
return 0;
@@ -922,25 +930,6 @@ static int otx2_get_rxfh_context(struct net_device *dev,
922930
return 0;
923931
}
924932

925-
/* Get RSS configuration */
926-
static int otx2_get_rxfh(struct net_device *dev,
927-
struct ethtool_rxfh_param *rxfh)
928-
{
929-
return otx2_get_rxfh_context(dev, rxfh,
930-
DEFAULT_RSS_CONTEXT_GROUP);
931-
}
932-
933-
/* Configure RSS table and hash key */
934-
static int otx2_set_rxfh(struct net_device *dev,
935-
struct ethtool_rxfh_param *rxfh,
936-
struct netlink_ext_ack *extack)
937-
{
938-
939-
u32 rss_context = DEFAULT_RSS_CONTEXT_GROUP;
940-
941-
return otx2_set_rxfh_context(dev, rxfh, &rss_context, 0);
942-
}
943-
944933
static u32 otx2_get_msglevel(struct net_device *netdev)
945934
{
946935
struct otx2_nic *pfvf = netdev_priv(netdev);
@@ -1321,6 +1310,7 @@ static void otx2_get_fec_stats(struct net_device *netdev,
13211310
}
13221311

13231312
static const struct ethtool_ops otx2_ethtool_ops = {
1313+
.cap_rss_ctx_supported = true,
13241314
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
13251315
ETHTOOL_COALESCE_MAX_FRAMES |
13261316
ETHTOOL_COALESCE_USE_ADAPTIVE,
@@ -1343,8 +1333,6 @@ static const struct ethtool_ops otx2_ethtool_ops = {
13431333
.get_rxfh_indir_size = otx2_get_rxfh_indir_size,
13441334
.get_rxfh = otx2_get_rxfh,
13451335
.set_rxfh = otx2_set_rxfh,
1346-
.get_rxfh_context = otx2_get_rxfh_context,
1347-
.set_rxfh_context = otx2_set_rxfh_context,
13481336
.get_msglevel = otx2_get_msglevel,
13491337
.set_msglevel = otx2_set_msglevel,
13501338
.get_pauseparam = otx2_get_pauseparam,
@@ -1444,6 +1432,7 @@ static int otx2vf_get_link_ksettings(struct net_device *netdev,
14441432
}
14451433

14461434
static const struct ethtool_ops otx2vf_ethtool_ops = {
1435+
.cap_rss_ctx_supported = true,
14471436
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
14481437
ETHTOOL_COALESCE_MAX_FRAMES |
14491438
ETHTOOL_COALESCE_USE_ADAPTIVE,
@@ -1462,8 +1451,6 @@ static const struct ethtool_ops otx2vf_ethtool_ops = {
14621451
.get_rxfh_indir_size = otx2_get_rxfh_indir_size,
14631452
.get_rxfh = otx2_get_rxfh,
14641453
.set_rxfh = otx2_set_rxfh,
1465-
.get_rxfh_context = otx2_get_rxfh_context,
1466-
.set_rxfh_context = otx2_set_rxfh_context,
14671454
.get_ringparam = otx2_get_ringparam,
14681455
.set_ringparam = otx2_set_ringparam,
14691456
.get_coalesce = otx2_get_coalesce,

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,11 +1262,10 @@ static u32 mlx5e_get_rxfh_indir_size(struct net_device *netdev)
12621262
return mlx5e_ethtool_get_rxfh_indir_size(priv);
12631263
}
12641264

1265-
static int mlx5e_get_rxfh_context(struct net_device *dev,
1266-
struct ethtool_rxfh_param *rxfh,
1267-
u32 rss_context)
1265+
int mlx5e_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
12681266
{
1269-
struct mlx5e_priv *priv = netdev_priv(dev);
1267+
struct mlx5e_priv *priv = netdev_priv(netdev);
1268+
u32 rss_context = rxfh->rss_context;
12701269
int err;
12711270

12721271
mutex_lock(&priv->state_lock);
@@ -1276,16 +1275,16 @@ static int mlx5e_get_rxfh_context(struct net_device *dev,
12761275
return err;
12771276
}
12781277

1279-
static int mlx5e_set_rxfh_context(struct net_device *dev,
1280-
struct ethtool_rxfh_param *rxfh,
1281-
u32 *rss_context, bool delete)
1278+
int mlx5e_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxfh,
1279+
struct netlink_ext_ack *extack)
12821280
{
12831281
struct mlx5e_priv *priv = netdev_priv(dev);
1282+
u32 *rss_context = &rxfh->rss_context;
12841283
u8 hfunc = rxfh->hfunc;
12851284
int err;
12861285

12871286
mutex_lock(&priv->state_lock);
1288-
if (delete) {
1287+
if (*rss_context && rxfh->rss_delete) {
12891288
err = mlx5e_rx_res_rss_destroy(priv->rx_res, *rss_context);
12901289
goto unlock;
12911290
}
@@ -1307,25 +1306,6 @@ static int mlx5e_set_rxfh_context(struct net_device *dev,
13071306
return err;
13081307
}
13091308

1310-
int mlx5e_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
1311-
{
1312-
return mlx5e_get_rxfh_context(netdev, rxfh, 0);
1313-
}
1314-
1315-
int mlx5e_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxfh,
1316-
struct netlink_ext_ack *extack)
1317-
{
1318-
struct mlx5e_priv *priv = netdev_priv(dev);
1319-
u8 hfunc = rxfh->hfunc;
1320-
int err;
1321-
1322-
mutex_lock(&priv->state_lock);
1323-
err = mlx5e_rx_res_rss_set_rxfh(priv->rx_res, 0, rxfh->indir, rxfh->key,
1324-
hfunc == ETH_RSS_HASH_NO_CHANGE ? NULL : &hfunc);
1325-
mutex_unlock(&priv->state_lock);
1326-
return err;
1327-
}
1328-
13291309
#define MLX5E_PFC_PREVEN_AUTO_TOUT_MSEC 100
13301310
#define MLX5E_PFC_PREVEN_TOUT_MAX_MSEC 8000
13311311
#define MLX5E_PFC_PREVEN_MINOR_PRECENT 85
@@ -2402,6 +2382,7 @@ static void mlx5e_get_rmon_stats(struct net_device *netdev,
24022382
}
24032383

24042384
const struct ethtool_ops mlx5e_ethtool_ops = {
2385+
.cap_rss_ctx_supported = true,
24052386
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
24062387
ETHTOOL_COALESCE_MAX_FRAMES |
24072388
ETHTOOL_COALESCE_USE_ADAPTIVE |
@@ -2424,8 +2405,6 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
24242405
.get_rxfh_indir_size = mlx5e_get_rxfh_indir_size,
24252406
.get_rxfh = mlx5e_get_rxfh,
24262407
.set_rxfh = mlx5e_set_rxfh,
2427-
.get_rxfh_context = mlx5e_get_rxfh_context,
2428-
.set_rxfh_context = mlx5e_set_rxfh_context,
24292408
.get_rxnfc = mlx5e_get_rxnfc,
24302409
.set_rxnfc = mlx5e_set_rxnfc,
24312410
.get_tunable = mlx5e_get_tunable,

0 commit comments

Comments
 (0)