* [dpdk-stable] [PATCH 19.11] net/ena/base: fix testing for supported hash function
@ 2020-05-29 10:46 Michal Krawczyk
2020-05-29 17:11 ` Luca Boccassi
0 siblings, 1 reply; 2+ messages in thread
From: Michal Krawczyk @ 2020-05-29 10:46 UTC (permalink / raw)
To: stable; +Cc: luca.boccassi, Michal Krawczyk
[ upstream commit 6e585db68903b9ef8e0a547efc8f3e71af424397 ]
There was a bug in ena_com_fill_hash_function(), which was causing bit to
be shifted left one bit too much.
To fix that, the ENA_FFS macro is being used (returning the location of
the first bit set), hash_function value is being subtracted by 1 if any
hash function is supported by the device and BIT macro is used for
shifting for better verbosity.
Fixes: 99ecfbf845b3 ("ena: import communication layer")
Signed-off-by: Michal Krawczyk <mk@semihalf.com>
---
drivers/net/ena/base/ena_com.c | 22 +++++++++++++++-------
drivers/net/ena/base/ena_plat_dpdk.h | 2 ++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c
index b3cdf712e1..147c039124 100644
--- a/drivers/net/ena/base/ena_com.c
+++ b/drivers/net/ena/base/ena_com.c
@@ -2313,7 +2313,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
if (unlikely(ret))
return ret;
- if (get_resp.u.flow_hash_func.supported_func & (1 << rss->hash_func)) {
+ if (get_resp.u.flow_hash_func.supported_func & BIT(rss->hash_func)) {
ena_trc_err("Func hash %d isn't supported by device, abort\n",
rss->hash_func);
return ENA_COM_UNSUPPORTED;
@@ -2356,12 +2356,14 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
enum ena_admin_hash_functions func,
const u8 *key, u16 key_len, u32 init_val)
{
- struct ena_rss *rss = &ena_dev->rss;
+ struct ena_admin_feature_rss_flow_hash_control *hash_key;
struct ena_admin_get_feat_resp get_resp;
- struct ena_admin_feature_rss_flow_hash_control *hash_key =
- rss->hash_key;
+ enum ena_admin_hash_functions old_func;
+ struct ena_rss *rss = &ena_dev->rss;
int rc;
+ hash_key = rss->hash_key;
+
/* Make sure size is a mult of DWs */
if (unlikely(key_len & 0x3))
return ENA_COM_INVAL;
@@ -2373,7 +2375,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
if (unlikely(rc))
return rc;
- if (!((1 << func) & get_resp.u.flow_hash_func.supported_func)) {
+ if (!(BIT(func) & get_resp.u.flow_hash_func.supported_func)) {
ena_trc_err("Flow hash function %d isn't supported\n", func);
return ENA_COM_UNSUPPORTED;
}
@@ -2398,11 +2400,13 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
return ENA_COM_INVAL;
}
+ old_func = rss->hash_func;
+ rss->hash_func = func;
rc = ena_com_set_hash_function(ena_dev);
/* Restore the old function */
if (unlikely(rc))
- ena_com_get_hash_function(ena_dev, NULL, NULL);
+ rss->hash_func = old_func;
return rc;
}
@@ -2424,7 +2428,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;
+ /* ENA_FFS returns 1 in case the lsb is set */
+ rss->hash_func = ENA_FFS(get_resp.u.flow_hash_func.selected_func);
+ if (rss->hash_func)
+ rss->hash_func--;
+
if (func)
*func = rss->hash_func;
diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index dddfe65403..da97efca46 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -297,4 +297,6 @@ extern rte_atomic32_t ena_alloc_cnt;
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+#define ENA_FFS(x) ffs(x)
+
#endif /* DPDK_ENA_COM_ENA_PLAT_DPDK_H_ */
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-stable] [PATCH 19.11] net/ena/base: fix testing for supported hash function
2020-05-29 10:46 [dpdk-stable] [PATCH 19.11] net/ena/base: fix testing for supported hash function Michal Krawczyk
@ 2020-05-29 17:11 ` Luca Boccassi
0 siblings, 0 replies; 2+ messages in thread
From: Luca Boccassi @ 2020-05-29 17:11 UTC (permalink / raw)
To: Michal Krawczyk, stable
On Fri, 2020-05-29 at 12:46 +0200, Michal Krawczyk wrote:
> [ upstream commit 6e585db68903b9ef8e0a547efc8f3e71af424397 ]
>
> There was a bug in ena_com_fill_hash_function(), which was causing bit to
> be shifted left one bit too much.
>
> To fix that, the ENA_FFS macro is being used (returning the location of
> the first bit set), hash_function value is being subtracted by 1 if any
> hash function is supported by the device and BIT macro is used for
> shifting for better verbosity.
>
> Fixes: 99ecfbf845b3 ("ena: import communication layer")
>
> Signed-off-by: Michal Krawczyk <mk@semihalf.com>
> ---
> drivers/net/ena/base/ena_com.c | 22 +++++++++++++++-------
> drivers/net/ena/base/ena_plat_dpdk.h | 2 ++
> 2 files changed, 17 insertions(+), 7 deletions(-)
Acked-By: Luca Boccassi <bluca@debian.org>
Thanks, applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-29 17:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29 10:46 [dpdk-stable] [PATCH 19.11] net/ena/base: fix testing for supported hash function Michal Krawczyk
2020-05-29 17:11 ` Luca Boccassi
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).