From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8CB2645B04; Thu, 10 Oct 2024 14:33:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F69940663; Thu, 10 Oct 2024 14:33:40 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by mails.dpdk.org (Postfix) with ESMTP id 1F3EB402D8 for ; Thu, 10 Oct 2024 14:33:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728563618; x=1760099618; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QTgQh3FKL7PbQnY32ydUhbRCB/FP8eXTYKRuUucG/TI=; b=FyTmljST8J4wQgKrpED+Mt58837O8zg9s4dG2Awm8/uhXZzVR99ssr9b Z6Eztz7mv1X8C6pXww0ay8F53IEsVqF3LGnDEz1Jl0z9m7h2pgIBCi7ve 040f74nZR70fzDUBvl3+5uZEClvgbGZGWqafdEqcHMDZmS5lfajwZ3pzQ nuoD3E1zdpah7HriJ+TXI41Rgu7VgKmcXppP5AS6Jq0Ur1Xml+upmF2OV L3Ur5KmYMwV4cKN484xkil209ku5a2UEViltuilTlLlNLLJ7hnq9t9uPT Wzi3Bm6/77+wxQSxUqo+mdFqa3t4OzxrFIH+jiPUhYw36xPoU0mr1FMM8 A==; X-CSE-ConnectionGUID: d+WzlvxqSeyKVV/PnFIzVQ== X-CSE-MsgGUID: iZQ2kfv0QoeV29Y0794VJg== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="31712327" X-IronPort-AV: E=Sophos;i="6.11,193,1725346800"; d="scan'208";a="31712327" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 05:33:37 -0700 X-CSE-ConnectionGUID: 2JPHn8U/TWS23aS0ZlpIhA== X-CSE-MsgGUID: 4ozPNjOdQtC2dR5C6FXCeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,193,1725346800"; d="scan'208";a="81101892" Received: from unknown (HELO silpixa00401176.ir.intel.com) ([10.243.22.170]) by fmviesa005.fm.intel.com with ESMTP; 10 Oct 2024 05:33:35 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: stephen@networkplumber.org, Yipeng Wang , Sameh Gobriel , Bruce Richardson Subject: [PATCH v2 3/4] hash: implement RSS hash key generation API Date: Thu, 10 Oct 2024 12:33:30 +0000 Message-Id: <20241010123331.749004-4-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010123331.749004-1-vladimir.medvedkin@intel.com> References: <20241010123331.749004-1-vladimir.medvedkin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; } -- 2.34.1