Skip to content

Commit

Permalink
bnxt_en: Add support for user configured RSS key
Browse files Browse the repository at this point in the history
Store the user configured or generated Toeplitz key in
bp->rss_hash_key.  The key stays constant across ifdown/ifup
unless updated by the user.

Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20240205223202.25341-12-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Pavan Chebbi authored and Jakub Kicinski committed Feb 9, 2024
1 parent 44af4b6 commit 5de1fce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
18 changes: 16 additions & 2 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -4246,9 +4246,23 @@ static void bnxt_init_vnics(struct bnxt *bp)
u8 *key = (void *)vnic->rss_hash_key;
int k;

if (!bp->rss_hash_key_valid &&
!bp->rss_hash_key_updated) {
get_random_bytes(bp->rss_hash_key,
HW_HASH_KEY_SIZE);
bp->rss_hash_key_updated = true;
}

memcpy(vnic->rss_hash_key, bp->rss_hash_key,
HW_HASH_KEY_SIZE);

if (!bp->rss_hash_key_updated)
continue;

bp->rss_hash_key_updated = false;
bp->rss_hash_key_valid = true;

bp->toeplitz_prefix = 0;
get_random_bytes(vnic->rss_hash_key,
HW_HASH_KEY_SIZE);
for (k = 0; k < 8; k++) {
bp->toeplitz_prefix <<= 8;
bp->toeplitz_prefix |= key[k];
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,10 @@ struct bnxt {
#define BNXT_RSS_CAP_NEW_RSS_CAP BIT(2)
#define BNXT_RSS_CAP_RSS_TCAM BIT(3)

u8 rss_hash_key[HW_HASH_KEY_SIZE];
u8 rss_hash_key_valid:1;
u8 rss_hash_key_updated:1;

u16 max_mtu;
u8 max_tc;
u8 max_lltc; /* lossless TCs */
Expand Down
6 changes: 4 additions & 2 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1755,8 +1755,10 @@ static int bnxt_set_rxfh(struct net_device *dev,
if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP)
return -EOPNOTSUPP;

if (rxfh->key)
return -EOPNOTSUPP;
if (rxfh->key) {
memcpy(bp->rss_hash_key, rxfh->key, HW_HASH_KEY_SIZE);
bp->rss_hash_key_updated = true;
}

if (rxfh->indir) {
u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(dev);
Expand Down

0 comments on commit 5de1fce

Please sign in to comment.