From: <sameehj@amazon.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: Arthur Kiyanovski <akiyano@amazon.com>, <dwmw@amazon.com>,
<zorik@amazon.com>, <matua@amazon.com>, <saeedb@amazon.com>,
<msw@amazon.com>, <aliguori@amazon.com>, <nafea@amazon.com>,
<gtzalik@amazon.com>, <netanel@amazon.com>, <alisaidi@amazon.com>,
<benh@amazon.com>, <sameehj@amazon.com>, <ndagan@amazon.com>
Subject: [PATCH V2 net 07/12] net: ena: rss: store hash function as values and not bits
Date: Tue, 11 Feb 2020 15:17:46 +0000 [thread overview]
Message-ID: <20200211151751.29718-8-sameehj@amazon.com> (raw)
In-Reply-To: <20200211151751.29718-1-sameehj@amazon.com>
From: Arthur Kiyanovski <akiyano@amazon.com>
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>
---
drivers/net/ethernet/amazon/ena/ena_com.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
index 6f758ece8..8ab192cb2 100644
--- a/drivers/net/ethernet/amazon/ena/ena_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_com.c
@@ -2370,7 +2370,11 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
if (unlikely(rc))
return rc;
- rss->hash_func = get_resp.u.flow_hash_func.selected_func;
+ /* ffs() returns 1 in case the lsb is set */
+ rss->hash_func = ffs(get_resp.u.flow_hash_func.selected_func);
+ if (rss->hash_func)
+ rss->hash_func--;
+
if (func)
*func = rss->hash_func;
--
2.24.1.AMZN
next prev parent reply other threads:[~2020-02-11 15:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 15:17 [PATCH V2 net 00/12] Bug fixes for ENA Ethernet driver sameehj
2020-02-11 15:17 ` [PATCH V2 net 01/12] net: ena: fix potential crash when rxfh key is NULL sameehj
2020-02-11 15:17 ` [PATCH V2 net 02/12] net: ena: fix uses of round_jiffies() sameehj
2020-02-11 15:17 ` [PATCH V2 net 03/12] net: ena: add missing ethtool TX timestamping indication sameehj
2020-02-11 15:17 ` [PATCH V2 net 04/12] net: ena: fix incorrect default RSS key sameehj
2020-02-11 15:17 ` [PATCH V2 net 05/12] net: ena: rss: do not allocate key when not supported sameehj
2020-02-11 15:17 ` [PATCH V2 net 06/12] net: ena: rss: fix failure to get indirection table sameehj
2020-02-11 15:17 ` sameehj [this message]
2020-02-11 15:17 ` [PATCH V2 net 08/12] net: ena: fix incorrectly saving queue numbers when setting RSS " sameehj
2020-02-11 15:17 ` [PATCH V2 net 09/12] net: ena: fix corruption of dev_idx_to_host_tbl sameehj
2020-02-11 15:17 ` [PATCH V2 net 10/12] net: ena: make ena rxfh support ETH_RSS_HASH_NO_CHANGE sameehj
2020-02-11 15:17 ` [PATCH V2 net 11/12] net: ena: ethtool: use correct value for crc32 hash sameehj
2020-02-11 15:17 ` [PATCH V2 net 12/12] net: ena: ena-com.c: prevent NULL pointer dereference sameehj
2020-02-12 1:10 ` [PATCH V2 net 00/12] Bug fixes for ENA Ethernet driver David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200211151751.29718-8-sameehj@amazon.com \
--to=sameehj@amazon.com \
--cc=akiyano@amazon.com \
--cc=aliguori@amazon.com \
--cc=alisaidi@amazon.com \
--cc=benh@amazon.com \
--cc=davem@davemloft.net \
--cc=dwmw@amazon.com \
--cc=gtzalik@amazon.com \
--cc=matua@amazon.com \
--cc=msw@amazon.com \
--cc=nafea@amazon.com \
--cc=ndagan@amazon.com \
--cc=netanel@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=saeedb@amazon.com \
--cc=zorik@amazon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).