Skip to content

Commit 77a614f

Browse files
Michael Chankuba-moo
authored andcommitted
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: Michael Chan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0895926 commit 77a614f

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,32 @@ static int bnxt_get_rxfh(struct net_device *dev,
17781778
return 0;
17791779
}
17801780

1781+
static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
1782+
struct ethtool_rxfh_param *rxfh)
1783+
{
1784+
if (rxfh->key) {
1785+
if (rss_ctx) {
1786+
memcpy(rss_ctx->vnic.rss_hash_key, rxfh->key,
1787+
HW_HASH_KEY_SIZE);
1788+
} else {
1789+
memcpy(bp->rss_hash_key, rxfh->key, HW_HASH_KEY_SIZE);
1790+
bp->rss_hash_key_updated = true;
1791+
}
1792+
}
1793+
if (rxfh->indir) {
1794+
u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(bp->dev);
1795+
u16 *indir_tbl = bp->rss_indir_tbl;
1796+
1797+
if (rss_ctx)
1798+
indir_tbl = rss_ctx->rss_indir_tbl;
1799+
for (i = 0; i < tbl_size; i++)
1800+
indir_tbl[i] = rxfh->indir[i];
1801+
pad = bp->rss_indir_tbl_entries - tbl_size;
1802+
if (pad)
1803+
memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16));
1804+
}
1805+
}
1806+
17811807
static int bnxt_set_rxfh(struct net_device *dev,
17821808
struct ethtool_rxfh_param *rxfh,
17831809
struct netlink_ext_ack *extack)
@@ -1788,20 +1814,8 @@ static int bnxt_set_rxfh(struct net_device *dev,
17881814
if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP)
17891815
return -EOPNOTSUPP;
17901816

1791-
if (rxfh->key) {
1792-
memcpy(bp->rss_hash_key, rxfh->key, HW_HASH_KEY_SIZE);
1793-
bp->rss_hash_key_updated = true;
1794-
}
1795-
1796-
if (rxfh->indir) {
1797-
u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(dev);
1817+
bnxt_modify_rss(bp, NULL, rxfh);
17981818

1799-
for (i = 0; i < tbl_size; i++)
1800-
bp->rss_indir_tbl[i] = rxfh->indir[i];
1801-
pad = bp->rss_indir_tbl_entries - tbl_size;
1802-
if (pad)
1803-
memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16));
1804-
}
18051819
bnxt_clear_usr_fltrs(bp, false);
18061820
if (netif_running(bp->dev)) {
18071821
bnxt_close_nic(bp, false, false);

0 commit comments

Comments
 (0)