From patchwork Fri Sep 6 16:53:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Medvedkin, Vladimir" X-Patchwork-Id: 143755 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0559F45920; Fri, 6 Sep 2024 18:53:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CC2842FF7; Fri, 6 Sep 2024 18:53:28 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by mails.dpdk.org (Postfix) with ESMTP id 3005842FCB for ; Fri, 6 Sep 2024 18:53:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725641605; x=1757177605; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QTgQh3FKL7PbQnY32ydUhbRCB/FP8eXTYKRuUucG/TI=; b=f4qTICG2XzBHpypoqKBith5rCb9RBh27hBXgF+w8JDWagpS/3hML42EB +uefb8+TqWo+xXHEcGTPmRXceUsCuu3nqiujJtycjzOpfYDl5RSlXyfFg MCi7/Poq9ezLPxx4HIi8VS0dhIW8kzDtK1JwOQrzmKIL789lhubrzKtmK XYAq2UL7GHW7zG11rlG7H2ikcrw+qReW2eqlJej1Z7rizt+PWpH4oOxLf bmxFIctzrhXgeCtwM8UHuOXqZngxKIC6q4EnDPYGtadXMX1+If3UGTV99 rnjM7FxFqOJdulLdyfekfdDuLgg/qXMs60382VySWwttej2j7i2FCJAbf Q==; X-CSE-ConnectionGUID: 6ARL7ezzQM2/2tyFAneRjA== X-CSE-MsgGUID: NTuLQgW0QamWA1+xnh0a7Q== X-IronPort-AV: E=McAfee;i="6700,10204,11187"; a="27334107" X-IronPort-AV: E=Sophos;i="6.10,208,1719903600"; d="scan'208";a="27334107" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2024 09:53:24 -0700 X-CSE-ConnectionGUID: hKwKsSDuTS+3nBU8JTgKEA== X-CSE-MsgGUID: PuqO5K9RQm6LU/8qM2sZSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,208,1719903600"; d="scan'208";a="65996786" Received: from silpixa00401176.ir.intel.com ([10.243.22.170]) by fmviesa009.fm.intel.com with ESMTP; 06 Sep 2024 09:53:23 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: Yipeng Wang , Sameh Gobriel , Bruce Richardson Subject: [RFC 3/4] hash: implement RSS hash key generation API Date: Fri, 6 Sep 2024 16:53:17 +0000 Message-Id: <20240906165318.1322550-4-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240906165318.1322550-1-vladimir.medvedkin@intel.com> References: <20240906165318.1322550-1-vladimir.medvedkin@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch implements Toeplitz hash key generation function using the new polynomial generation function. Signed-off-by: Vladimir Medvedkin --- lib/hash/rte_thash.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index f57b275a72..a452567228 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -803,11 +803,24 @@ int rte_thash_gen_key(uint8_t *key, int key_len, int reta_sz_log, int entropy_start, int entropy_sz) { - RTE_SET_USED(key); - RTE_SET_USED(key_len); - RTE_SET_USED(reta_sz_log); - RTE_SET_USED(entropy_start); - RTE_SET_USED(entropy_sz); + int i, end, start; + + /* define lfsr sequence range*/ + end = entropy_start + entropy_sz + TOEPLITZ_HASH_LEN - 1; + start = end - (entropy_sz + reta_sz_log - 1); + + if ((key == NULL) || (key_len * CHAR_BIT < entropy_start + entropy_sz) || + (entropy_sz < reta_sz_log) || (reta_sz_log > TOEPLITZ_HASH_LEN)) + return -EINVAL; + + struct thash_lfsr *lfsr = alloc_lfsr(reta_sz_log); + if (lfsr == NULL) + return -ENOMEM; + + for (i = start; i < end; i++) + set_bit(key, get_bit_lfsr(lfsr), i); + + free_lfsr(lfsr); return 0; }