From patchwork Thu Sep 17 05:30:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Krawczyk X-Patchwork-Id: 77969 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 00045A04B6; Thu, 17 Sep 2020 07:32:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D46EA1D569; Thu, 17 Sep 2020 07:31:06 +0200 (CEST) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by dpdk.org (Postfix) with ESMTP id D45ED1D559 for ; Thu, 17 Sep 2020 07:31:01 +0200 (CEST) Received: by mail-lf1-f53.google.com with SMTP id z19so779646lfr.4 for ; Wed, 16 Sep 2020 22:31:01 -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=bfUlrcp2N1NI8HoziMKy7pnA6K0CJi1FC33JD3KhABE=; b=RcdbytBoiGEvFs28shv1WG2k3s8igxVePwteo9JXwlwCUSIxlSRyFV/PqXciRSsmYL IR+p6V6oELByAZfrn7QN2G99J4Rx5Ynlb7lTGVsFIoydd8yMy0TrMCG9eVWdK26+xiWp qijrP5/3AoxbQu15wOGJJnWi9JPeGlXZUDhicRSPLVDlaxTF9W5x2vbXIgn38Ps4ZbK2 lDnbIMhhHHdfCPB6MKjBjvX77uOAYbRgttRrNjgr2qJ1qpXGcFFTZK8WOUItGsPvzcQb QtBMmM4jTyTj4NCv/kSQavCnse/5mxa7InwKa0PWeUucbgwYlzxhy0Jn1OPXoY/RTxxp 6WIw== 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=bfUlrcp2N1NI8HoziMKy7pnA6K0CJi1FC33JD3KhABE=; b=rJ8tqFizuUhGd0cg8BD/rOM2rc847KLzwWSWObIQsxbTeiTnn0uDuV7V7aSKtKGg8w XB23QDAGZ/upXZAyPhKDfdnwBCPtiNrOkJp5T62HvbHGkq7ALrc0R/oW9Gpkc34uolOn NSk50w7dkRBV4EZZCoQgwlRgqzMKVR/cE/QrNkArESY58NBCiYXvekDSCDzne7MeCwUe L/egEmQQS00E9ml2/8Zi9pAkFsmI6MqQpJT0ZAeYFPggx3n0AxUJRyYPu/PxnT1mBKpz ZRjq1+Eh2ekAhtdi16Gr29d7988Eew0NP9bi3DMBBqDHZyJrxqAp5VkRDj/120gDLaXQ LCEA== X-Gm-Message-State: AOAM530gVaqphe8Ppu9GdI9PoititeNXoVQFwK0zLd+ccitlcje8as9i sSDyOQlcza+Cxex8PlCdtTCV1PTXeTtM2NKD X-Google-Smtp-Source: ABdhPJzb7zKSBD37Q1fHG0/1ARJfzJVWzjAYyuhLq218y3eTvrXZ2TcOZ3uoOQ0Nbc/bN9uUvppwZA== X-Received: by 2002:ac2:5298:: with SMTP id q24mr8551477lfm.164.1600320661143; Wed, 16 Sep 2020 22:31:01 -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 j3sm5033686lfb.185.2020.09.16.22.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 22:31:00 -0700 (PDT) From: Michal Krawczyk To: dev@dpdk.org Cc: gtzalik@amazon.com, igorch@amazon.com, Michal Krawczyk , Marcin Wojtas , Evgeny Schemeilin Date: Thu, 17 Sep 2020 07:30:24 +0200 Message-Id: <20200917053035.1889989-10-mk@semihalf.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200917053035.1889989-1-mk@semihalf.com> References: <20200917053035.1889989-1-mk@semihalf.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 09/20] net/ena/base: split RSS function and hash getters 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 is no need to keep single function for both hash function and the key. If the caller want's to get only single value, then it had to pass NULL as one of the values, making the API harder to use. Except reading functions from the device, one can also use function ena_com_get_current_hash_function() to get the integer value, which is represeting current hash function stored in the ena_com layer. Signed-off-by: Michal Krawczyk Reviewed-by: Igor Chauskin Reviewed-by: Guy Tzalik --- drivers/net/ena/base/ena_com.c | 26 +++++++++++++++++++------- drivers/net/ena/base/ena_com.h | 31 ++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c index 1463f5f1d4..bf1de09c5c 100644 --- a/drivers/net/ena/base/ena_com.c +++ b/drivers/net/ena/base/ena_com.c @@ -1062,6 +1062,11 @@ static int ena_com_get_feature(struct ena_com_dev *ena_dev, feature_ver); } +int ena_com_get_current_hash_function(struct ena_com_dev *ena_dev) +{ + return ena_dev->rss.hash_func; +} + static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev) { struct ena_admin_feature_rss_flow_hash_control *hash_key = @@ -2408,15 +2413,15 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev, } int ena_com_get_hash_function(struct ena_com_dev *ena_dev, - enum ena_admin_hash_functions *func, - u8 *key) + enum ena_admin_hash_functions *func) { struct ena_rss *rss = &ena_dev->rss; struct ena_admin_get_feat_resp get_resp; - struct ena_admin_feature_rss_flow_hash_control *hash_key = - rss->hash_key; int rc; + if (unlikely(!func)) + return ENA_COM_INVAL; + rc = ena_com_get_feature_ex(ena_dev, &get_resp, ENA_ADMIN_RSS_HASH_FUNCTION, rss->hash_key_dma_addr, @@ -2424,13 +2429,20 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev, if (unlikely(rc)) return rc; - /* ENA_FFS returns 1 in case the lsb is set */ + /* 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; + *func = rss->hash_func; + + return 0; +} + +int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key) +{ + struct ena_admin_feature_rss_flow_hash_control *hash_key = + ena_dev->rss.hash_key; if (key) memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2); diff --git a/drivers/net/ena/base/ena_com.h b/drivers/net/ena/base/ena_com.h index 751bfcdd7e..ba367b4ca0 100644 --- a/drivers/net/ena/base/ena_com.h +++ b/drivers/net/ena/base/ena_com.h @@ -645,6 +645,14 @@ int ena_com_rss_init(struct ena_com_dev *ena_dev, u16 log_size); */ void ena_com_rss_destroy(struct ena_com_dev *ena_dev); +/* ena_com_get_current_hash_function - Get RSS hash function + * @ena_dev: ENA communication layer struct + * + * Return the current hash function. + * @return: 0 or one of the ena_admin_hash_functions values. + */ +int ena_com_get_current_hash_function(struct ena_com_dev *ena_dev); + /* ena_com_fill_hash_function - Fill RSS hash function * @ena_dev: ENA communication layer struct * @func: The hash function (Toeplitz or crc) @@ -676,23 +684,32 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev, */ int ena_com_set_hash_function(struct ena_com_dev *ena_dev); -/* ena_com_get_hash_function - Retrieve the hash function and the hash key - * from the device. +/* ena_com_get_hash_function - Retrieve the hash function from the device. * @ena_dev: ENA communication layer struct * @func: hash function - * @key: hash key * - * Retrieve the hash function and the hash key from the device. + * Retrieve the hash function from the device. * - * @note: If the caller called ena_com_fill_hash_function but didn't flash + * @note: If the caller called ena_com_fill_hash_function but didn't flush * it to the device, the new configuration will be lost. * * @return: 0 on Success and negative value otherwise. */ int ena_com_get_hash_function(struct ena_com_dev *ena_dev, - enum ena_admin_hash_functions *func, - u8 *key); + enum ena_admin_hash_functions *func); +/* ena_com_get_hash_key - Retrieve the hash key + * @ena_dev: ENA communication layer struct + * @key: hash key + * + * Retrieve the hash key. + * + * @note: If the caller called ena_com_fill_hash_key but didn't flush + * it to the device, the new configuration will be lost. + * + * @return: 0 on Success and negative value otherwise. + */ +int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key); /* ena_com_fill_hash_ctrl - Fill RSS hash control * @ena_dev: ENA communication layer struct. * @proto: The protocol to configure.