From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 68989A0597; Wed, 8 Apr 2020 10:30:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 89DA71C0C2; Wed, 8 Apr 2020 10:29:35 +0200 (CEST) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by dpdk.org (Postfix) with ESMTP id 504BD1C06C for ; Wed, 8 Apr 2020 10:29:31 +0200 (CEST) Received: by mail-lj1-f194.google.com with SMTP id r7so6629016ljg.13 for ; Wed, 08 Apr 2020 01:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EsVCJSfEV1PCZ7mbAUW9XauUx/hx3YPHr0APShNs7Jw=; b=qYZEkjHYM2YQzlrevS79Fjh2kpmAcgD/en6whcRccpMVIiTPYrn1PSXUgwynBtbbF8 eiKTpfa9l0mlBR9juTUBupWQjqNNqCxMXOqykLPBtfoAnFDo1p3oO1P3lMur2HApd6VZ ErGGID+ahqqWEwRmK2WRB7BoULFcVONyMJ+KpOhNefbLypJUa84Gxc7nDZwz7mrZWgX6 pWaIDJKcHsunmQdAbknYRai6Ln+9+5DVx4TWdfysiK9JWzeS5i25ZSHYIA/xG+Di7jdU vNvHYhUfBTX+FrRAwg23NjQgW9sBART0rLgsgpqqmL8ZHMj7ezIMTTRI+tASkS5jLA3S OvmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EsVCJSfEV1PCZ7mbAUW9XauUx/hx3YPHr0APShNs7Jw=; b=aEmwBl9IF3w0QHrfkmPntetz3XENmGL9ZEuWCNrz0AbkndEmyexyIArFDytl/l0fUg Jaav38fAnweISTP/kRfgLoGSnBXbdVPVd0GfzGle1+wcF/j1ARnivxPg0N/Ef2Vk2vo2 KaTp4LmEwnTbHQjZzqLHhEatve2e44nW+26oBoCblHblW6zOHlWB7D2CDEWCMCJilo+M HLVHV/QRN0A+0afUTxJh6AzcZ/1TFdB0xBGybPpoQxdvlCiXGPaTpzN2xLqgQPlyAjTn ctkkP9wbKAMsfqM04s1K+OVX99yZwYMbDqLZ3VDJYqbKnH4v4+PHsdMlAmcrkyln8Trc RFWQ== X-Gm-Message-State: AGi0PubT4Eui7gvN/gJcqAuW+h0Tnqm+7C//ZJ6c3mscYOW2tiC1T/H0 BVWYckkGiU1/MlXWaLiiwru9G1Mx94c= X-Google-Smtp-Source: APiQypL645As2L+1kNObE6i3opjtHb/WiHa8rjnKcVUCMlOIJ6ayiSn4IS/10IvJIvwatBUD/pyEbA== X-Received: by 2002:a2e:a40b:: with SMTP id p11mr4216963ljn.173.1586334570697; Wed, 08 Apr 2020 01:29:30 -0700 (PDT) Received: from mkPC.semihalf.local (193-106-246-138.noc.fibertech.net.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id e8sm765685lja.3.2020.04.08.01.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 01:29:29 -0700 (PDT) From: Michal Krawczyk To: dev@dpdk.org Cc: mw@semihalf.com, mba@semihalf.com, gtzalik@amazon.com, evgenys@amazon.com, igorch@amazon.com, ferruh.yigit@intel.com, arybchenko@solarflare.com, Michal Krawczyk Date: Wed, 8 Apr 2020 10:28:56 +0200 Message-Id: <20200408082921.31000-6-mk@semihalf.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200408082921.31000-1-mk@semihalf.com> References: <20200408082921.31000-1-mk@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 05/30] net/ena/base: fix testing for supported hash func X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 ussed (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. Signed-off-by: Michal Krawczyk --- v3: * This patch was added - previously part of the v2-04 drivers/net/ena/base/ena_com.c | 19 +++++++++++++------ drivers/net/ena/base/ena_plat_dpdk.h | 2 ++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c index 38a474b1bd..04f5d21d6f 100644 --- a/drivers/net/ena/base/ena_com.c +++ b/drivers/net/ena/base/ena_com.c @@ -2394,12 +2394,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; @@ -2411,7 +2413,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; } @@ -2437,12 +2439,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; } @@ -2464,7 +2467,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 e9b33bc36c..e9b3c02270 100644 --- a/drivers/net/ena/base/ena_plat_dpdk.h +++ b/drivers/net/ena/base/ena_plat_dpdk.h @@ -301,6 +301,8 @@ extern rte_atomic32_t ena_alloc_cnt; #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +#define ENA_FFS(x) ffs(x) + void ena_rss_key_fill(void *key, size_t size); #define ENA_RSS_FILL_KEY(key, size) ena_rss_key_fill(key, size) -- 2.20.1