Commit 77a614f7 authored by Michael Chan's avatar Michael Chan Committed by Jakub Kicinski

bnxt_en: Refactor bnxt_set_rxfh()

Add a new bnxt_modify_rss() function to modify the RSS key and RSS
indirection table.  The new function can modify the parameters for
the default context or additional contexts.
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20240325222902.220712-10-michael.chan@broadcom.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0895926f
...@@ -1778,30 +1778,44 @@ static int bnxt_get_rxfh(struct net_device *dev, ...@@ -1778,30 +1778,44 @@ static int bnxt_get_rxfh(struct net_device *dev,
return 0; return 0;
} }
static int bnxt_set_rxfh(struct net_device *dev, static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
struct ethtool_rxfh_param *rxfh, struct ethtool_rxfh_param *rxfh)
struct netlink_ext_ack *extack)
{ {
struct bnxt *bp = netdev_priv(dev);
int rc = 0;
if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP)
return -EOPNOTSUPP;
if (rxfh->key) { if (rxfh->key) {
if (rss_ctx) {
memcpy(rss_ctx->vnic.rss_hash_key, rxfh->key,
HW_HASH_KEY_SIZE);
} else {
memcpy(bp->rss_hash_key, rxfh->key, HW_HASH_KEY_SIZE); memcpy(bp->rss_hash_key, rxfh->key, HW_HASH_KEY_SIZE);
bp->rss_hash_key_updated = true; bp->rss_hash_key_updated = true;
} }
}
if (rxfh->indir) { if (rxfh->indir) {
u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(dev); u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(bp->dev);
u16 *indir_tbl = bp->rss_indir_tbl;
if (rss_ctx)
indir_tbl = rss_ctx->rss_indir_tbl;
for (i = 0; i < tbl_size; i++) for (i = 0; i < tbl_size; i++)
bp->rss_indir_tbl[i] = rxfh->indir[i]; indir_tbl[i] = rxfh->indir[i];
pad = bp->rss_indir_tbl_entries - tbl_size; pad = bp->rss_indir_tbl_entries - tbl_size;
if (pad) if (pad)
memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16));
} }
}
static int bnxt_set_rxfh(struct net_device *dev,
struct ethtool_rxfh_param *rxfh,
struct netlink_ext_ack *extack)
{
struct bnxt *bp = netdev_priv(dev);
int rc = 0;
if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP)
return -EOPNOTSUPP;
bnxt_modify_rss(bp, NULL, rxfh);
bnxt_clear_usr_fltrs(bp, false); bnxt_clear_usr_fltrs(bp, false);
if (netif_running(bp->dev)) { if (netif_running(bp->dev)) {
bnxt_close_nic(bp, false, false); bnxt_close_nic(bp, false, false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment