diff options
author | Ahmed Zaki <ahmed.zaki@intel.com> | 2023-12-13 03:33:14 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-12-14 09:07:16 +0300 |
commit | fb6e30a72539ce28c1323aef4190d35aac106f6f (patch) | |
tree | 5fe3886113c8ddb0b4db61c4bb274234058e02c9 /drivers/net/ethernet/marvell/octeontx2/nic | |
parent | c3f687d8dfeb33cffbb8f47c30002babfc4895d2 (diff) | |
download | linux-fb6e30a72539ce28c1323aef4190d35aac106f6f.tar.xz |
net: ethtool: pass a pointer to parameters to get/set_rxfh ethtool ops
The get/set_rxfh ethtool ops currently takes the rxfh (RSS) parameters
as direct function arguments. This will force us to change the API (and
all drivers' functions) every time some new parameters are added.
This is part 1/2 of the fix, as suggested in [1]:
- First simplify the code by always providing a pointer to all params
(indir, key and func); the fact that some of them may be NULL seems
like a weird historic thing or a premature optimization.
It will simplify the drivers if all pointers are always present.
- Then make the functions take a dev pointer, and a pointer to a
single struct wrapping all arguments. The set_* should also take
an extack.
Link: https://lore.kernel.org/netdev/20231121152906.2dd5f487@kernel.org/ [1]
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Suggested-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
Link: https://lore.kernel.org/r/20231213003321.605376-2-ahmed.zaki@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/marvell/octeontx2/nic')
-rw-r--r-- | drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index 53f6258a973c..a2c182d7bfc4 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -836,8 +836,8 @@ static int otx2_rss_ctx_create(struct otx2_nic *pfvf, } /* RSS context configuration */ -static int otx2_set_rxfh_context(struct net_device *dev, const u32 *indir, - const u8 *hkey, const u8 hfunc, +static int otx2_set_rxfh_context(struct net_device *dev, + struct ethtool_rxfh_param *rxfh, u32 *rss_context, bool delete) { struct otx2_nic *pfvf = netdev_priv(dev); @@ -845,7 +845,8 @@ static int otx2_set_rxfh_context(struct net_device *dev, const u32 *indir, struct otx2_rss_info *rss; int ret, idx; - if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP) + if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && + rxfh->hfunc != ETH_RSS_HASH_TOP) return -EOPNOTSUPP; if (*rss_context != ETH_RXFH_CONTEXT_ALLOC && @@ -859,8 +860,8 @@ static int otx2_set_rxfh_context(struct net_device *dev, const u32 *indir, return -EIO; } - if (hkey) { - memcpy(rss->key, hkey, sizeof(rss->key)); + if (rxfh->key) { + memcpy(rss->key, rxfh->key, sizeof(rss->key)); otx2_set_rss_key(pfvf); } if (delete) @@ -871,28 +872,29 @@ static int otx2_set_rxfh_context(struct net_device *dev, const u32 *indir, if (ret) return ret; } - if (indir) { + if (rxfh->indir) { rss_ctx = rss->rss_ctx[*rss_context]; for (idx = 0; idx < rss->rss_size; idx++) - rss_ctx->ind_tbl[idx] = indir[idx]; + rss_ctx->ind_tbl[idx] = rxfh->indir[idx]; } otx2_set_rss_table(pfvf, *rss_context); return 0; } -static int otx2_get_rxfh_context(struct net_device *dev, u32 *indir, - u8 *hkey, u8 *hfunc, u32 rss_context) +static int otx2_get_rxfh_context(struct net_device *dev, + struct ethtool_rxfh_param *rxfh, + u32 rss_context) { struct otx2_nic *pfvf = netdev_priv(dev); struct otx2_rss_ctx *rss_ctx; struct otx2_rss_info *rss; + u32 *indir = rxfh->indir; int idx, rx_queues; rss = &pfvf->hw.rss_info; - if (hfunc) - *hfunc = ETH_RSS_HASH_TOP; + rxfh->hfunc = ETH_RSS_HASH_TOP; if (!indir) return 0; @@ -914,28 +916,29 @@ static int otx2_get_rxfh_context(struct net_device *dev, u32 *indir, for (idx = 0; idx < rss->rss_size; idx++) indir[idx] = rss_ctx->ind_tbl[idx]; } - if (hkey) - memcpy(hkey, rss->key, sizeof(rss->key)); + if (rxfh->key) + memcpy(rxfh->key, rss->key, sizeof(rss->key)); return 0; } /* Get RSS configuration */ -static int otx2_get_rxfh(struct net_device *dev, u32 *indir, - u8 *hkey, u8 *hfunc) +static int otx2_get_rxfh(struct net_device *dev, + struct ethtool_rxfh_param *rxfh) { - return otx2_get_rxfh_context(dev, indir, hkey, hfunc, + return otx2_get_rxfh_context(dev, rxfh, DEFAULT_RSS_CONTEXT_GROUP); } /* Configure RSS table and hash key */ -static int otx2_set_rxfh(struct net_device *dev, const u32 *indir, - const u8 *hkey, const u8 hfunc) +static int otx2_set_rxfh(struct net_device *dev, + struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack) { u32 rss_context = DEFAULT_RSS_CONTEXT_GROUP; - return otx2_set_rxfh_context(dev, indir, hkey, hfunc, &rss_context, 0); + return otx2_set_rxfh_context(dev, rxfh, &rss_context, 0); } static u32 otx2_get_msglevel(struct net_device *netdev) |