OSDN Git Service

net: ena: rss: store hash function as values and not bits
authorArthur Kiyanovski <akiyano@amazon.com>
Tue, 11 Feb 2020 15:17:46 +0000 (15:17 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 12 Feb 2020 01:08:31 +0000 (17:08 -0800)
commit4844470d472d660c26149ad764da2406adb13423
tree4fb7988feed9f1bdc6964c4f1acee4f6098d161b
parent0c8923c0a64fb5d14bebb9a9065d2dc25ac5e600
net: ena: rss: store hash function as values and not bits

The device receives, stores and retrieves the hash function value as bits
and not as their enum value.

The bug:
* In ena_com_set_hash_function() we set
  cmd.u.flow_hash_func.selected_func to the bit value of rss->hash_func.
 (1 << rss->hash_func)
* In ena_com_get_hash_function() we retrieve the hash function and store
  it's bit value in rss->hash_func. (Now the bit value of rss->hash_func
  is stored in rss->hash_func instead of it's enum value)

The fix:
This commit fixes the issue by converting the retrieved hash function
values from the device to the matching enum value of the set bit using
ffs(). ffs() finds the first set bit's index in a word. Since the function
returns 1 for the LSB's index, we need to subtract 1 from the returned
value (note that BIT(0) is 1).

Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amazon/ena/ena_com.c