Skip to content

Commit f66c2ea

Browse files
Sameeh Jubrandavem330
authored andcommitted
net: ena: allow setting the hash function without changing the key
Current code does not allow setting the hash function without changing the key. This commit enables it. To achieve this we separate ena_com_get_hash_function() to 2 functions: ena_com_get_hash_function() - which gets only the hash function, and ena_com_get_hash_key() - which gets only the hash key. Also return 0 instead of rc at the end of ena_get_rxfh() since all previous operations succeeded. Signed-off-by: Arthur Kiyanovski <[email protected]> Signed-off-by: Sameeh Jubran <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e9a1de3 commit f66c2ea

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,13 +2338,10 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
23382338
}
23392339

23402340
int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
2341-
enum ena_admin_hash_functions *func,
2342-
u8 *key)
2341+
enum ena_admin_hash_functions *func)
23432342
{
23442343
struct ena_rss *rss = &ena_dev->rss;
23452344
struct ena_admin_get_feat_resp get_resp;
2346-
struct ena_admin_feature_rss_flow_hash_control *hash_key =
2347-
rss->hash_key;
23482345
int rc;
23492346

23502347
if (unlikely(!func))
@@ -2364,6 +2361,14 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
23642361

23652362
*func = rss->hash_func;
23662363

2364+
return 0;
2365+
}
2366+
2367+
int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key)
2368+
{
2369+
struct ena_admin_feature_rss_flow_hash_control *hash_key =
2370+
ena_dev->rss.hash_key;
2371+
23672372
if (key)
23682373
memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);
23692374

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -695,23 +695,32 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
695695
*/
696696
int ena_com_set_hash_function(struct ena_com_dev *ena_dev);
697697

698-
/* ena_com_get_hash_function - Retrieve the hash function and the hash key
699-
* from the device.
698+
/* ena_com_get_hash_function - Retrieve the hash function from the device.
700699
* @ena_dev: ENA communication layer struct
701700
* @func: hash function
702-
* @key: hash key
703701
*
704-
* Retrieve the hash function and the hash key from the device.
702+
* Retrieve the hash function from the device.
705703
*
706704
* @note: If the caller called ena_com_fill_hash_function but didn't flash
707705
* it to the device, the new configuration will be lost.
708706
*
709707
* @return: 0 on Success and negative value otherwise.
710708
*/
711709
int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
712-
enum ena_admin_hash_functions *func,
713-
u8 *key);
710+
enum ena_admin_hash_functions *func);
714711

712+
/* ena_com_get_hash_key - Retrieve the hash key
713+
* @ena_dev: ENA communication layer struct
714+
* @key: hash key
715+
*
716+
* Retrieve the hash key.
717+
*
718+
* @note: If the caller called ena_com_fill_hash_key but didn't flash
719+
* it to the device, the new configuration will be lost.
720+
*
721+
* @return: 0 on Success and negative value otherwise.
722+
*/
723+
int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key);
715724
/* ena_com_fill_hash_ctrl - Fill RSS hash control
716725
* @ena_dev: ENA communication layer struct.
717726
* @proto: The protocol to configure.

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ static int ena_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
672672
/* We call this function in order to check if the device
673673
* supports getting/setting the hash function.
674674
*/
675-
rc = ena_com_get_hash_function(adapter->ena_dev, &ena_func, key);
675+
rc = ena_com_get_hash_function(adapter->ena_dev, &ena_func);
676676
if (rc) {
677677
if (rc == -EOPNOTSUPP) {
678678
key = NULL;
@@ -683,6 +683,10 @@ static int ena_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
683683
return rc;
684684
}
685685

686+
rc = ena_com_get_hash_key(adapter->ena_dev, key);
687+
if (rc)
688+
return rc;
689+
686690
switch (ena_func) {
687691
case ENA_ADMIN_TOEPLITZ:
688692
func = ETH_RSS_HASH_TOP;
@@ -699,15 +703,15 @@ static int ena_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
699703
if (hfunc)
700704
*hfunc = func;
701705

702-
return rc;
706+
return 0;
703707
}
704708

705709
static int ena_set_rxfh(struct net_device *netdev, const u32 *indir,
706710
const u8 *key, const u8 hfunc)
707711
{
708712
struct ena_adapter *adapter = netdev_priv(netdev);
709713
struct ena_com_dev *ena_dev = adapter->ena_dev;
710-
enum ena_admin_hash_functions func;
714+
enum ena_admin_hash_functions func = 0;
711715
int rc, i;
712716

713717
if (indir) {
@@ -746,7 +750,7 @@ static int ena_set_rxfh(struct net_device *netdev, const u32 *indir,
746750
return -EOPNOTSUPP;
747751
}
748752

749-
if (key) {
753+
if (key || func) {
750754
rc = ena_com_fill_hash_function(ena_dev, func, key,
751755
ENA_HASH_KEY_SIZE,
752756
0xFFFFFFFF);

0 commit comments

Comments
 (0)