Skip to content

Commit 0d1c3de

Browse files
akiyanodavem330
authored andcommitted
net: ena: fix incorrect default RSS key
Bug description: When running "ethtool -x <if_name>" the key shows up as all zeros. When we use "ethtool -X <if_name> hfunc toeplitz hkey <some:random:key>" to set the key and then try to retrieve it using "ethtool -x <if_name>" then we return the correct key because we return the one we saved. Bug cause: We don't fetch the key from the device but instead return the key that we have saved internally which is by default set to zero upon allocation. Fix: This commit fixes the issue by initializing the key to a random value using netdev_rss_key_fill(). Fixes: 1738cd3 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") Signed-off-by: Sameeh Jubran <[email protected]> Signed-off-by: Arthur Kiyanovski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cf6d17f commit 0d1c3de

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/net/ethernet/amazon/ena/ena_com.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,19 @@ static int ena_com_get_feature(struct ena_com_dev *ena_dev,
10411041
feature_ver);
10421042
}
10431043

1044+
static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev)
1045+
{
1046+
struct ena_admin_feature_rss_flow_hash_control *hash_key =
1047+
(ena_dev->rss).hash_key;
1048+
1049+
netdev_rss_key_fill(&hash_key->key, sizeof(hash_key->key));
1050+
/* The key is stored in the device in u32 array
1051+
* as well as the API requires the key to be passed in this
1052+
* format. Thus the size of our array should be divided by 4
1053+
*/
1054+
hash_key->keys_num = sizeof(hash_key->key) / sizeof(u32);
1055+
}
1056+
10441057
static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev)
10451058
{
10461059
struct ena_rss *rss = &ena_dev->rss;
@@ -2631,6 +2644,8 @@ int ena_com_rss_init(struct ena_com_dev *ena_dev, u16 indr_tbl_log_size)
26312644
if (unlikely(rc))
26322645
goto err_hash_key;
26332646

2647+
ena_com_hash_key_fill_default_key(ena_dev);
2648+
26342649
rc = ena_com_hash_ctrl_init(ena_dev);
26352650
if (unlikely(rc))
26362651
goto err_hash_ctrl;

drivers/net/ethernet/amazon/ena/ena_com.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <linux/spinlock.h>
4545
#include <linux/types.h>
4646
#include <linux/wait.h>
47+
#include <linux/netdevice.h>
4748

4849
#include "ena_common_defs.h"
4950
#include "ena_admin_defs.h"

0 commit comments

Comments
 (0)