Skip to content

Commit 6a4f7dc

Browse files
Sameeh Jubrandavem330
authored andcommitted
net: ena: rss: do not allocate key when not supported
Currently we allocate the key whether the device supports setting the key or not. This commit adds a check to the allocation function and handles the error accordingly. Fixes: 1738cd3 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") Signed-off-by: Sameeh Jubran <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0d1c3de commit 6a4f7dc

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,20 @@ static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev)
10571057
static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev)
10581058
{
10591059
struct ena_rss *rss = &ena_dev->rss;
1060+
struct ena_admin_feature_rss_flow_hash_control *hash_key;
1061+
struct ena_admin_get_feat_resp get_resp;
1062+
int rc;
1063+
1064+
hash_key = (ena_dev->rss).hash_key;
1065+
1066+
rc = ena_com_get_feature_ex(ena_dev, &get_resp,
1067+
ENA_ADMIN_RSS_HASH_FUNCTION,
1068+
ena_dev->rss.hash_key_dma_addr,
1069+
sizeof(ena_dev->rss.hash_key), 0);
1070+
if (unlikely(rc)) {
1071+
hash_key = NULL;
1072+
return -EOPNOTSUPP;
1073+
}
10601074

10611075
rss->hash_key =
10621076
dma_alloc_coherent(ena_dev->dmadev, sizeof(*rss->hash_key),
@@ -2640,11 +2654,15 @@ int ena_com_rss_init(struct ena_com_dev *ena_dev, u16 indr_tbl_log_size)
26402654
if (unlikely(rc))
26412655
goto err_indr_tbl;
26422656

2657+
/* The following function might return unsupported in case the
2658+
* device doesn't support setting the key / hash function. We can safely
2659+
* ignore this error and have indirection table support only.
2660+
*/
26432661
rc = ena_com_hash_key_allocate(ena_dev);
2644-
if (unlikely(rc))
2662+
if (unlikely(rc) && rc != -EOPNOTSUPP)
26452663
goto err_hash_key;
2646-
2647-
ena_com_hash_key_fill_default_key(ena_dev);
2664+
else if (rc != -EOPNOTSUPP)
2665+
ena_com_hash_key_fill_default_key(ena_dev);
26482666

26492667
rc = ena_com_hash_ctrl_init(ena_dev);
26502668
if (unlikely(rc))

0 commit comments

Comments
 (0)