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 2A56641C33; Tue, 7 Feb 2023 21:45:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1750242D77; Tue, 7 Feb 2023 21:44:52 +0100 (CET) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id 5EDF142D17 for ; Tue, 7 Feb 2023 21:44:48 +0100 (CET) Received: by mail-pj1-f54.google.com with SMTP id v18-20020a17090ae99200b00230f079dcd9so1880596pjy.1 for ; Tue, 07 Feb 2023 12:44:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7/bsfRkvtO8I1DbmodtJVt9YSnv9beAIXypDVjVTT8Y=; b=0OZ+gCzqBaCBdZbicQkOnh4pT/1jLOAD9V5dhkYb9J9vTmmPE7hhiGiM09Fnv28mmA Uw44X3yRV7bfrPaOTnlVzlq7CVRUoR4G83rxwHP7MSOuH9uZ23kkglw7eV+GAb5TZaea FeItAX6tC2X6FTuIGgonohWWV90Q2dqFYJH/99b7/0VNIKCchZdLrUQIL48MJL5elylf WUrGa2uONp09M1eQzSZqZUWAdB8VO16D1wEM68Pgs9xeOmlu8axPX7WsHe6pdbUGLa3t /NcfVW+b0BEi+xmnwVhQdAeDR0rz8I+BpCItee2evilCupgF3+NtD4zC7VfsFO7gP4xm Olig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7/bsfRkvtO8I1DbmodtJVt9YSnv9beAIXypDVjVTT8Y=; b=geK8UiS59oWK9qNFOOpykGjjKEdYunUs5Pivt18f1bhyv2Zfd6ceTnUUTpzsaouU8j +vlXy8iIfMjOup8C0EvFEcv8oou3j8BU3LuQ2H+T/W2/U2TyRTWStOXZtaPha3KU5yQK pWmfmPQtYs4qfYG1I/PLIedkA/vfq6CbCuhNpTxhRFGCgX3IJTkyijAN/4+5gN/cp7r7 U45lHIXGbUZTU51Zp6Y40RnKOPWm7xQjYcsYRgwcPLPcFhwyVe8oDFGQE1TzGaMTRh23 vnEiZuSq0hrrUaiqJ5tZV/3thCQJJaRLP/HZjy8nNQCWWbQLP2frOU27XhZr9R0VW65H HRWQ== X-Gm-Message-State: AO0yUKVU3TSuBdCsXzjbX9UGCMJ6W93CRTDg3J7POIuA/3pJoKA8ztFH s+dPFrnvzzuTFnasBaHfIoSWbDuHRJvjQahQoro= X-Google-Smtp-Source: AK7set+G5D996VduOKJfKsINvoc/nHiT/5LRcUTeElGosE0dj3MSZQOql6ZzR0GiEOPUQOZUqXAD5w== X-Received: by 2002:a17:902:ea05:b0:194:828d:62b0 with SMTP id s5-20020a170902ea0500b00194828d62b0mr4545232plg.48.1675802687083; Tue, 07 Feb 2023 12:44:47 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jk24-20020a170903331800b00194ab9a4febsm4725562plb.74.2023.02.07.12.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 12:44:46 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Subject: [RFC 12/13] hash: replace RTE_LOGTYPE_HASH with dynamic type Date: Tue, 7 Feb 2023 12:41:50 -0800 Message-Id: <20230207204151.1503491-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207204151.1503491-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> 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 A little more complex here since the one hash library actually has multiple routines in it. Split up the logtypes for hash and toeplitz. The hash crc file has another issue around logging. It is calling RTE_LOG during a constructor which is maybe problematic because this will all run before the DPDK library has finished initializing logging. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/hash/rte_cuckoo_hash.c | 60 ++++++++++++++++--------------- lib/hash/rte_fbk_hash.c | 10 ++++-- lib/hash/rte_hash_crc.c | 63 --------------------------------- lib/hash/rte_hash_crc.h | 6 ++-- lib/hash/rte_thash.c | 54 +++++++++++++++++++++------- lib/hash/rte_thash_gfni.h | 24 ++++--------- lib/hash/version.map | 4 +++ 9 files changed, 96 insertions(+), 128 deletions(-) delete mode 100644 lib/hash/rte_hash_crc.c diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index b0c625a02cdf..97120543d808 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,7 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 69d3d07252ec..afbd67d55b45 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -32,7 +32,7 @@ extern "C" { /* was RTE_LOGTYPE_MEMPOOL */ /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ -#define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ + /* was RTE_LOGTYPE_HASH */ /* was RTE_LOGTYPE_LPM */ /* was RTE_LOGTYPE_KNI */ /* was RTE_LOGTYPE_ACL */ diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 829b79c89a27..b2e9cd70e91b 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -26,6 +26,12 @@ #include "rte_hash.h" #include "rte_cuckoo_hash.h" +RTE_LOG_REGISTER_SUFFIX(hash_logtype, "hash", INFO); + +#define HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, hash_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + /* Mask of all flags supported by this version */ #define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \ RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \ @@ -159,7 +165,7 @@ rte_hash_create(const struct rte_hash_parameters *params) hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list); if (params == NULL) { - RTE_LOG(ERR, HASH, "rte_hash_create has no parameters\n"); + HASH_LOG(ERR, "rte_hash_create has no parameters"); return NULL; } @@ -168,13 +174,13 @@ rte_hash_create(const struct rte_hash_parameters *params) (params->entries < RTE_HASH_BUCKET_ENTRIES) || (params->key_len == 0)) { rte_errno = EINVAL; - RTE_LOG(ERR, HASH, "rte_hash_create has invalid parameters\n"); + HASH_LOG(ERR, "rte_hash_create has invalid parameters"); return NULL; } if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK) { rte_errno = EINVAL; - RTE_LOG(ERR, HASH, "rte_hash_create: unsupported extra flags\n"); + HASH_LOG(ERR, "rte_hash_create: unsupported extra flags"); return NULL; } @@ -182,8 +188,8 @@ rte_hash_create(const struct rte_hash_parameters *params) if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) && (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) { rte_errno = EINVAL; - RTE_LOG(ERR, HASH, "rte_hash_create: choose rw concurrency or " - "rw concurrency lock free\n"); + HASH_LOG(ERR, + "choose rw concurrency or rw concurrency lock free"); return NULL; } @@ -233,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params) r = rte_ring_create_elem(ring_name, sizeof(uint32_t), rte_align32pow2(num_key_slots), params->socket_id, 0); if (r == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err; } @@ -249,8 +255,8 @@ rte_hash_create(const struct rte_hash_parameters *params) params->socket_id, 0); if (r_ext == NULL) { - RTE_LOG(ERR, HASH, "ext buckets memory allocation " - "failed\n"); + HASH_LOG(ERR, + "ext buckets memory allocation failed"); goto err; } } @@ -275,7 +281,7 @@ rte_hash_create(const struct rte_hash_parameters *params) te = rte_zmalloc("HASH_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, HASH, "tailq entry allocation failed\n"); + HASH_LOG(ERR, "tailq entry allocation failed"); goto err_unlock; } @@ -283,7 +289,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (h == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err_unlock; } @@ -292,7 +298,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (buckets == NULL) { - RTE_LOG(ERR, HASH, "buckets memory allocation failed\n"); + HASH_LOG(ERR, "buckets memory allocation failed"); goto err_unlock; } @@ -302,8 +308,8 @@ rte_hash_create(const struct rte_hash_parameters *params) num_buckets * sizeof(struct rte_hash_bucket), RTE_CACHE_LINE_SIZE, params->socket_id); if (buckets_ext == NULL) { - RTE_LOG(ERR, HASH, "ext buckets memory allocation " - "failed\n"); + HASH_LOG(ERR, + "ext buckets memory allocation failed"); goto err_unlock; } /* Populate ext bkt ring. We reserve 0 similar to the @@ -318,8 +324,8 @@ rte_hash_create(const struct rte_hash_parameters *params) ext_bkt_to_free = rte_zmalloc(NULL, sizeof(uint32_t) * num_key_slots, 0); if (ext_bkt_to_free == NULL) { - RTE_LOG(ERR, HASH, "ext bkt to free memory allocation " - "failed\n"); + HASH_LOG(ERR, + "ext bkt to free memory allocation failed"); goto err_unlock; } } @@ -334,7 +340,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (k == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err_unlock; } @@ -342,7 +348,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (tbl_chng_cnt == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err_unlock; } @@ -390,7 +396,7 @@ rte_hash_create(const struct rte_hash_parameters *params) sizeof(struct lcore_cache) * RTE_MAX_LCORE, RTE_CACHE_LINE_SIZE, params->socket_id); if (local_free_slots == NULL) { - RTE_LOG(ERR, HASH, "local free slots memory allocation failed\n"); + HASH_LOG(ERR, "local free slots memory allocation failed"); goto err_unlock; } } @@ -624,7 +630,7 @@ rte_hash_reset(struct rte_hash *h) /* Reclaim all the resources */ rte_rcu_qsbr_dq_reclaim(h->dq, ~0, NULL, &pending, NULL); if (pending != 0) - RTE_LOG(ERR, HASH, "RCU reclaim all resources failed\n"); + HASH_LOG(ERR, "RCU reclaim all resources failed"); } memset(h->buckets, 0, h->num_buckets * sizeof(struct rte_hash_bucket)); @@ -1498,9 +1504,8 @@ __hash_rcu_qsbr_free_resource(void *p, void *e, unsigned int n) /* Return key indexes to free slot ring */ ret = free_slot(h, rcu_dq_entry.key_idx); if (ret < 0) { - RTE_LOG(ERR, HASH, - "%s: could not enqueue free slots in global ring\n", - __func__); + HASH_LOG(ERR, + "could not enqueue free slots in global ring"); } } @@ -1527,7 +1532,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg) hash_rcu_cfg = rte_zmalloc(NULL, sizeof(struct rte_hash_rcu_config), 0); if (hash_rcu_cfg == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); return 1; } @@ -1551,7 +1556,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg) h->dq = rte_rcu_qsbr_dq_create(¶ms); if (h->dq == NULL) { rte_free(hash_rcu_cfg); - RTE_LOG(ERR, HASH, "HASH defer queue creation failed\n"); + HASH_LOG(ERR, "HASH defer queue creation failed"); return 1; } } else { @@ -1580,9 +1585,8 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, int ret = free_slot(h, bkt->key_idx[i]); if (ret < 0) { - RTE_LOG(ERR, HASH, - "%s: could not enqueue free slots in global ring\n", - __func__); + HASH_LOG(ERR, + "could not enqueue free slots in global ring"); } } @@ -1770,7 +1774,7 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, } else if (h->dq) /* Push into QSBR FIFO if using RTE_HASH_QSBR_MODE_DQ */ if (rte_rcu_qsbr_dq_enqueue(h->dq, &rcu_dq_entry) != 0) - RTE_LOG(ERR, HASH, "Failed to push QSBR FIFO\n"); + HASH_LOG(ERR, "Failed to push QSBR FIFO"); } __hash_rw_writer_unlock(h); return ret; diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c index 538b23a4030a..7a0e4272ffa9 100644 --- a/lib/hash/rte_fbk_hash.c +++ b/lib/hash/rte_fbk_hash.c @@ -18,6 +18,12 @@ #include "rte_fbk_hash.h" +RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, "hash.fbk", INFO); + +#define HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, fbk_hash_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry); static struct rte_tailq_elem rte_fbk_hash_tailq = { @@ -114,7 +120,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params) te = rte_zmalloc("FBK_HASH_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, HASH, "Failed to allocate tailq entry\n"); + HASH_LOG(ERR, "Failed to allocate tailq entry"); goto exit; } @@ -122,7 +128,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params) ht = rte_zmalloc_socket(hash_name, mem_size, 0, params->socket_id); if (ht == NULL) { - RTE_LOG(ERR, HASH, "Failed to allocate fbk hash table\n"); + HASH_LOG(ERR, "Failed to allocate fbk hash table"); rte_free(te); goto exit; } diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c deleted file mode 100644 index c6d0c25c0709..000000000000 --- a/lib/hash/rte_hash_crc.c +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -RTE_LOG_REGISTER_SUFFIX(crc_hash_logtype, "hash.crc", INFO); - -#define HASH_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, crc_hash_logtype, \ - "%s(): " fmt "\n", __func__, ##args) -/** - * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash - * calculation. - * - * @param alg - * An OR of following flags: - * - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8]) - * - (CRC32_SSE42) Use SSE4.2 intrinsics if available - * - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86) - * - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8) - * - */ -static inline void -rte_hash_crc_set_alg(uint8_t alg) -{ - crc32_alg = CRC32_SW; - - if (alg == CRC32_SW) - return; - -#if defined RTE_ARCH_X86 - if (!(alg & CRC32_SSE42_x64)) - HASH_LOG(WARNING, - "Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42"); - if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42) - crc32_alg = CRC32_SSE42; - else - crc32_alg = CRC32_SSE42_x64; -#endif - -#if defined RTE_ARCH_ARM64 - if (!(alg & CRC32_ARM64)) - HASH_LOG(WARNING, - "Unsupported CRC32 algorithm requested using CRC32_ARM64"); - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32)) - crc32_alg = CRC32_ARM64; -#endif - - if (crc32_alg == CRC32_SW) - HASH_LOG(WARNING, - "Unsupported CRC32 algorithm requested using CRC32_SW"); -} - -/* Setting the best available algorithm */ -RTE_INIT(rte_hash_crc_init_alg) -{ -#if defined(RTE_ARCH_X86) - rte_hash_crc_set_alg(CRC32_SSE42_x64); -#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32) - rte_hash_crc_set_alg(CRC32_ARM64); -#else - rte_hash_crc_set_alg(CRC32_SW); -#endif -} diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h index 0249ad16c5b6..3bb38880c4ea 100644 --- a/lib/hash/rte_hash_crc.h +++ b/lib/hash/rte_hash_crc.h @@ -63,7 +63,7 @@ rte_hash_crc_set_alg(uint8_t alg) #if defined RTE_ARCH_X86 if (!(alg & CRC32_SSE42_x64)) - RTE_LOG(WARNING, HASH, + fprintf(stderr, "Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n"); if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42) crc32_alg = CRC32_SSE42; @@ -73,14 +73,14 @@ rte_hash_crc_set_alg(uint8_t alg) #if defined RTE_ARCH_ARM64 if (!(alg & CRC32_ARM64)) - RTE_LOG(WARNING, HASH, + fprintf(stderr, "Unsupported CRC32 algorithm requested using CRC32_ARM64\n"); if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32)) crc32_alg = CRC32_ARM64; #endif if (crc32_alg == CRC32_SW) - RTE_LOG(WARNING, HASH, + fprintf(stderr, "Unsupported CRC32 algorithm requested using CRC32_SW\n"); } diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 0249883b8d07..e4722201d358 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -13,6 +13,12 @@ #include #include +RTE_LOG_REGISTER_SUFFIX(rte_thash_logtype, "thash", INFO); + +#define HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rte_thash_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + #define THASH_NAME_LEN 64 #define TOEPLITZ_HASH_LEN 32 @@ -104,6 +110,29 @@ rte_thash_gfni_supported(void) return 0; }; +#ifndef RTE_THASH_GFNI_DEFINED +uint32_t +rte_thash_gfni(const uint64_t *mtrx __rte_unused, + const uint8_t *key __rte_unused, int len __rte_unused) +{ + HASH_LOG(ERR, "is undefined under given arch"); + return 0; +} + +__rte_experimental +void +rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused, + int len __rte_unused, uint8_t *tuple[] __rte_unused, + uint32_t val[], uint32_t num) +{ + unsigned int i; + + HASH_LOG(ERR, "is undefined under given arch"); + for (i = 0; i < num; i++) + val[i] = 0; +} +#endif + void rte_thash_complete_matrix(uint64_t *matrixes, const uint8_t *rss_key, int size) { @@ -240,8 +269,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, /* allocate tailq entry */ te = rte_zmalloc("THASH_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, HASH, - "Can not allocate tailq entry for thash context %s\n", + HASH_LOG(ERR, + "Can not allocate tailq entry for thash context %s", name); rte_errno = ENOMEM; goto exit; @@ -249,7 +278,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, ctx = rte_zmalloc(NULL, sizeof(struct rte_thash_ctx) + key_len, 0); if (ctx == NULL) { - RTE_LOG(ERR, HASH, "thash ctx %s memory allocation failed\n", + HASH_LOG(ERR, + "thash ctx %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; @@ -272,7 +302,7 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, ctx->matrices = rte_zmalloc(NULL, key_len * sizeof(uint64_t), RTE_CACHE_LINE_SIZE); if (ctx->matrices == NULL) { - RTE_LOG(ERR, HASH, "Cannot allocate matrices\n"); + HASH_LOG(ERR, "Cannot allocate matrices"); rte_errno = ENOMEM; goto free_ctx; } @@ -387,8 +417,8 @@ generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr, if (((lfsr->bits_cnt + req_bits) > (1ULL << lfsr->deg) - 1) && ((ctx->flags & RTE_THASH_IGNORE_PERIOD_OVERFLOW) != RTE_THASH_IGNORE_PERIOD_OVERFLOW)) { - RTE_LOG(ERR, HASH, - "Can't generate m-sequence due to period overflow\n"); + HASH_LOG(ERR, + "Can't generate m-sequence due to period overflow"); return -ENOSPC; } @@ -467,9 +497,9 @@ insert_before(struct rte_thash_ctx *ctx, return ret; } } else if ((next_ent != NULL) && (end > next_ent->offset)) { - RTE_LOG(ERR, HASH, - "Can't add helper %s due to conflict with existing" - " helper %s\n", ent->name, next_ent->name); + HASH_LOG(ERR, + "Can't add helper %s due to conflict with existing helper %s", + ent->name, next_ent->name); rte_free(ent); return -ENOSPC; } @@ -516,9 +546,9 @@ insert_after(struct rte_thash_ctx *ctx, int ret; if ((next_ent != NULL) && (end > next_ent->offset)) { - RTE_LOG(ERR, HASH, - "Can't add helper %s due to conflict with existing" - " helper %s\n", ent->name, next_ent->name); + HASH_LOG(ERR, + "Can't add helper %s due to conflict with existing helper %s", + ent->name, next_ent->name); rte_free(ent); return -EEXIST; } diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h index ef90faa302d1..c3a5cf7e7b2d 100644 --- a/lib/hash/rte_thash_gfni.h +++ b/lib/hash/rte_thash_gfni.h @@ -38,13 +38,8 @@ extern "C" { * Calculated Toeplitz hash value. */ __rte_experimental -static inline uint32_t -rte_thash_gfni(const uint64_t *mtrx __rte_unused, - const uint8_t *key __rte_unused, int len __rte_unused) -{ - RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__); - return 0; -} +uint32_t +rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len); /** * Bulk implementation for Toeplitz hash. @@ -67,17 +62,10 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused, * Number of tuples to hash. */ __rte_experimental -static inline void -rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused, - int len __rte_unused, uint8_t *tuple[] __rte_unused, - uint32_t val[], uint32_t num) -{ - unsigned int i; - - RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__); - for (i = 0; i < num; i++) - val[i] = 0; -} +void +rte_thash_gfni_bulk(const uint64_t *mtrx, + int len, uint8_t *tuple[], + uint32_t val[], uint32_t num); #endif /* RTE_THASH_GFNI_DEFINED */ diff --git a/lib/hash/version.map b/lib/hash/version.map index bdcebd19c29b..c30ac81307a7 100644 --- a/lib/hash/version.map +++ b/lib/hash/version.map @@ -51,4 +51,8 @@ EXPERIMENTAL { rte_thash_complete_matrix; rte_thash_get_gfni_matrices; rte_thash_gfni_supported; + + # added in 23.07 + rte_thash_gfni; + rte_thash_gfni_bulk; }; -- 2.39.1