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 A2DB745A78; Tue, 1 Oct 2024 10:19:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5736B40DF6; Tue, 1 Oct 2024 10:18:31 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 196294027A for ; Tue, 1 Oct 2024 10:18:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727770707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BivxUhni4RUfKpqV+Q7opIp+vsC/Wi+o/hBe3Y7xYUY=; b=f91PzIWhp+wC6jCCcHJIb+FdTOm4QIZLKUfAClfrGv0GBF0C6TELH5KqxzemB70e1hCB/F 5zOSjn/cmoD2F0C4WAYc5jaMeW1rke7PjzOq28LUWViRHYvg5AJxa4wFFxkGKjFoKZvfzE 2o1HDlmRBgnP1358D3DTjpHgMrlKh4U= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-L6zXwDhCPJm3ADrsao4lrA-1; Tue, 01 Oct 2024 04:18:24 -0400 X-MC-Unique: L6zXwDhCPJm3ADrsao4lrA-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B420C1944AA9; Tue, 1 Oct 2024 08:18:23 +0000 (UTC) Received: from ringo.redhat.com (unknown [10.39.208.33]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 67EB11979060; Tue, 1 Oct 2024 08:18:22 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org, Vladimir Medvedkin , Bruce Richardson Subject: [PATCH dpdk v2 14/16] rib6,fib6,lpm6: remove duplicate constants Date: Tue, 1 Oct 2024 10:17:26 +0200 Message-ID: <20241001081728.301272-15-rjarry@redhat.com> In-Reply-To: <20241001081728.301272-1-rjarry@redhat.com> References: <20240821162516.610624-17-rjarry@redhat.com> <20241001081728.301272-1-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 Replace all address size and max depth macros with common ones from rte_ip6.h. Signed-off-by: Robin Jarry --- app/test/test_fib6.c | 50 ++++++++++++++++++++++---------------------- lib/fib/rte_fib6.c | 6 +++--- lib/fib/rte_fib6.h | 4 ---- lib/fib/trie.c | 6 +++--- lib/fib/trie.h | 2 -- lib/lpm/rte_lpm6.c | 10 ++++----- lib/lpm/rte_lpm6.h | 3 --- lib/rib/rte_rib6.c | 11 +++++----- lib/rib/rte_rib6.h | 6 ++---- 9 files changed, 43 insertions(+), 55 deletions(-) diff --git a/app/test/test_fib6.c b/app/test/test_fib6.c index 7134c4d335cd..812da01d6e33 100644 --- a/app/test/test_fib6.c +++ b/app/test/test_fib6.c @@ -170,13 +170,13 @@ test_add_del_invalid(void) fib = rte_fib6_create(__func__, SOCKET_ID_ANY, &config); RTE_TEST_ASSERT(fib != NULL, "Failed to create FIB\n"); - /* rte_fib6_add: depth > RTE_FIB6_MAXDEPTH */ - ret = rte_fib6_add(fib, &ip, RTE_FIB6_MAXDEPTH + 1, nh); + /* rte_fib6_add: depth > RTE_IPV6_MAX_DEPTH */ + ret = rte_fib6_add(fib, &ip, RTE_IPV6_MAX_DEPTH + 1, nh); RTE_TEST_ASSERT(ret < 0, "Call succeeded with invalid parameters\n"); - /* rte_fib6_delete: depth > RTE_FIB6_MAXDEPTH */ - ret = rte_fib6_delete(fib, &ip, RTE_FIB6_MAXDEPTH + 1); + /* rte_fib6_delete: depth > RTE_IPV6_MAX_DEPTH */ + ret = rte_fib6_delete(fib, &ip, RTE_IPV6_MAX_DEPTH + 1); RTE_TEST_ASSERT(ret < 0, "Call succeeded with invalid parameters\n"); @@ -216,18 +216,18 @@ lookup_and_check_asc(struct rte_fib6 *fib, struct rte_ipv6_addr *ip_missing, uint64_t def_nh, uint32_t n) { - uint64_t nh_arr[RTE_FIB6_MAXDEPTH]; + uint64_t nh_arr[RTE_IPV6_MAX_DEPTH]; int ret; uint32_t i = 0; - ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_FIB6_MAXDEPTH); + ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_IPV6_MAX_DEPTH); RTE_TEST_ASSERT(ret == 0, "Failed to lookup\n"); - for (; i <= RTE_FIB6_MAXDEPTH - n; i++) + for (; i <= RTE_IPV6_MAX_DEPTH - n; i++) RTE_TEST_ASSERT(nh_arr[i] == n, "Failed to get proper nexthop\n"); - for (; i < RTE_FIB6_MAXDEPTH; i++) + for (; i < RTE_IPV6_MAX_DEPTH; i++) RTE_TEST_ASSERT(nh_arr[i] == --n, "Failed to get proper nexthop\n"); @@ -244,18 +244,18 @@ lookup_and_check_desc(struct rte_fib6 *fib, struct rte_ipv6_addr *ip_missing, uint64_t def_nh, uint32_t n) { - uint64_t nh_arr[RTE_FIB6_MAXDEPTH]; + uint64_t nh_arr[RTE_IPV6_MAX_DEPTH]; int ret; uint32_t i = 0; - ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_FIB6_MAXDEPTH); + ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_IPV6_MAX_DEPTH); RTE_TEST_ASSERT(ret == 0, "Failed to lookup\n"); for (; i < n; i++) - RTE_TEST_ASSERT(nh_arr[i] == RTE_FIB6_MAXDEPTH - i, + RTE_TEST_ASSERT(nh_arr[i] == RTE_IPV6_MAX_DEPTH - i, "Failed to get proper nexthop\n"); - for (; i < RTE_FIB6_MAXDEPTH; i++) + for (; i < RTE_IPV6_MAX_DEPTH; i++) RTE_TEST_ASSERT(nh_arr[i] == def_nh, "Failed to get proper nexthop\n"); @@ -270,7 +270,7 @@ static int check_fib(struct rte_fib6 *fib) { uint64_t def_nh = 100; - struct rte_ipv6_addr ip_arr[RTE_FIB6_MAXDEPTH]; + struct rte_ipv6_addr ip_arr[RTE_IPV6_MAX_DEPTH]; struct rte_ipv6_addr ip_add = {.a = {[0] = 128}}; struct rte_ipv6_addr ip_missing = { .a = {[0] = 127, [1 ... 15] = 255}, @@ -278,12 +278,12 @@ check_fib(struct rte_fib6 *fib) uint32_t i, j; int ret; - for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) { + for (i = 0; i < RTE_IPV6_MAX_DEPTH; i++) { rte_ipv6_addr_cpy(&ip_arr[i], &ip_add); - j = (RTE_FIB6_MAXDEPTH - i) / CHAR_BIT; - if (j < RTE_FIB6_IPV6_ADDR_SIZE) { - ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_FIB6_MAXDEPTH - i) % CHAR_BIT); - for (j++; j < RTE_FIB6_IPV6_ADDR_SIZE; j++) + j = (RTE_IPV6_MAX_DEPTH - i) / CHAR_BIT; + if (j < RTE_IPV6_ADDR_SIZE) { + ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_IPV6_MAX_DEPTH - i) % CHAR_BIT); + for (j++; j < RTE_IPV6_ADDR_SIZE; j++) ip_arr[i].a[j] = 0xff; } } @@ -291,7 +291,7 @@ check_fib(struct rte_fib6 *fib) ret = lookup_and_check_desc(fib, ip_arr, &ip_missing, def_nh, 0); RTE_TEST_ASSERT(ret == TEST_SUCCESS, "Lookup and check fails\n"); - for (i = 1; i <= RTE_FIB6_MAXDEPTH; i++) { + for (i = 1; i <= RTE_IPV6_MAX_DEPTH; i++) { ret = rte_fib6_add(fib, &ip_add, i, i); RTE_TEST_ASSERT(ret == 0, "Failed to add a route\n"); ret = lookup_and_check_asc(fib, ip_arr, &ip_missing, def_nh, i); @@ -299,7 +299,7 @@ check_fib(struct rte_fib6 *fib) "Lookup and check fails\n"); } - for (i = RTE_FIB6_MAXDEPTH; i > 1; i--) { + for (i = RTE_IPV6_MAX_DEPTH; i > 1; i--) { ret = rte_fib6_delete(fib, &ip_add, i); RTE_TEST_ASSERT(ret == 0, "Failed to delete a route\n"); ret = lookup_and_check_asc(fib, ip_arr, &ip_missing, @@ -314,9 +314,9 @@ check_fib(struct rte_fib6 *fib) RTE_TEST_ASSERT(ret == TEST_SUCCESS, "Lookup and check fails\n"); - for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) { - ret = rte_fib6_add(fib, &ip_add, RTE_FIB6_MAXDEPTH - i, - RTE_FIB6_MAXDEPTH - i); + for (i = 0; i < RTE_IPV6_MAX_DEPTH; i++) { + ret = rte_fib6_add(fib, &ip_add, RTE_IPV6_MAX_DEPTH - i, + RTE_IPV6_MAX_DEPTH - i); RTE_TEST_ASSERT(ret == 0, "Failed to add a route\n"); ret = lookup_and_check_desc(fib, ip_arr, &ip_missing, def_nh, i + 1); @@ -324,11 +324,11 @@ check_fib(struct rte_fib6 *fib) "Lookup and check fails\n"); } - for (i = 1; i <= RTE_FIB6_MAXDEPTH; i++) { + for (i = 1; i <= RTE_IPV6_MAX_DEPTH; i++) { ret = rte_fib6_delete(fib, &ip_add, i); RTE_TEST_ASSERT(ret == 0, "Failed to delete a route\n"); ret = lookup_and_check_desc(fib, ip_arr, &ip_missing, def_nh, - RTE_FIB6_MAXDEPTH - i); + RTE_IPV6_MAX_DEPTH - i); RTE_TEST_ASSERT(ret == TEST_SUCCESS, "Lookup and check fails\n"); } diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c index d95cac79cbb5..9c7d4fde433a 100644 --- a/lib/fib/rte_fib6.c +++ b/lib/fib/rte_fib6.c @@ -71,7 +71,7 @@ dummy_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip, uint8_t depth, uint64_t next_hop, int op) { struct rte_rib6_node *node; - if ((fib == NULL) || (depth > RTE_FIB6_MAXDEPTH)) + if ((fib == NULL) || (depth > RTE_IPV6_MAX_DEPTH)) return -EINVAL; node = rte_rib6_lookup_exact(fib->rib, ip, depth); @@ -123,7 +123,7 @@ rte_fib6_add(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip, uint8_t depth, uint64_t next_hop) { if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) || - (depth > RTE_FIB6_MAXDEPTH)) + (depth > RTE_IPV6_MAX_DEPTH)) return -EINVAL; return fib->modify(fib, ip, depth, next_hop, RTE_FIB6_ADD); } @@ -133,7 +133,7 @@ rte_fib6_delete(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip, uint8_t depth) { if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) || - (depth > RTE_FIB6_MAXDEPTH)) + (depth > RTE_IPV6_MAX_DEPTH)) return -EINVAL; return fib->modify(fib, ip, depth, 0, RTE_FIB6_DEL); } diff --git a/lib/fib/rte_fib6.h b/lib/fib/rte_fib6.h index d26a0c7c0b77..2e3636b3bd29 100644 --- a/lib/fib/rte_fib6.h +++ b/lib/fib/rte_fib6.h @@ -23,10 +23,6 @@ extern "C" { #endif -#define RTE_FIB6_IPV6_ADDR_SIZE 16 -/** Maximum depth value possible for IPv6 FIB. */ -#define RTE_FIB6_MAXDEPTH 128 - struct rte_fib6; struct rte_rib6; diff --git a/lib/fib/trie.c b/lib/fib/trie.c index 8a69702eabb2..7c0af20625c1 100644 --- a/lib/fib/trie.c +++ b/lib/fib/trie.c @@ -350,9 +350,9 @@ write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop, return ret; } -#define IPV6_MAX_IDX (RTE_FIB6_IPV6_ADDR_SIZE - 1) +#define IPV6_MAX_IDX (RTE_IPV6_ADDR_SIZE - 1) #define TBL24_BYTES 3 -#define TBL8_LEN (RTE_FIB6_IPV6_ADDR_SIZE - TBL24_BYTES) +#define TBL8_LEN (RTE_IPV6_ADDR_SIZE - TBL24_BYTES) static int install_to_dp(struct rte_trie_tbl *dp, const struct rte_ipv6_addr *ledge, @@ -518,7 +518,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip, uint64_t par_nh, node_nh; uint8_t tmp_depth, depth_diff = 0, parent_depth = 24; - if ((fib == NULL) || (ip == NULL) || (depth > RTE_FIB6_MAXDEPTH)) + if ((fib == NULL) || (ip == NULL) || (depth > RTE_IPV6_MAX_DEPTH)) return -EINVAL; dp = rte_fib6_get_dp(fib); diff --git a/lib/fib/trie.h b/lib/fib/trie.h index 6e235edaf89c..77f1d95f4316 100644 --- a/lib/fib/trie.h +++ b/lib/fib/trie.h @@ -17,8 +17,6 @@ /* @internal Total number of tbl24 entries. */ #define TRIE_TBL24_NUM_ENT (1 << 24) -/* Maximum depth value possible for IPv6 LPM. */ -#define TRIE_MAX_DEPTH 128 /* @internal Number of entries in a tbl8 group. */ #define TRIE_TBL8_GRP_NUM_ENT 256ULL /* @internal Total number of tbl8 groups in the tbl8. */ diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c index 642b02b32cc2..c54726483a1a 100644 --- a/lib/lpm/rte_lpm6.c +++ b/lib/lpm/rte_lpm6.c @@ -802,7 +802,7 @@ simulate_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *masked_ip, uint8_ * Inspect one by one the rest of the bytes until * the process is completed. */ - for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && ret == 1; i++) { + for (i = ADD_FIRST_BYTE; i < RTE_IPV6_ADDR_SIZE && ret == 1; i++) { tbl = tbl_next; ret = simulate_add_step(lpm, tbl, &tbl_next, masked_ip, 1, (uint8_t)(i + 1), depth, &need_tbl_nb); @@ -832,7 +832,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t depth int i; /* Check user arguments. */ - if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH)) + if ((lpm == NULL) || (depth < 1) || (depth > RTE_IPV6_MAX_DEPTH)) return -EINVAL; /* Copy the IP and mask it to avoid modifying user's input data. */ @@ -861,7 +861,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t depth * Inspect one by one the rest of the bytes until * the process is completed. */ - for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && status == 1; i++) { + for (i = ADD_FIRST_BYTE; i < RTE_IPV6_ADDR_SIZE && status == 1; i++) { tbl = tbl_next; status = add_step(lpm, tbl, tbl_next_num, &tbl_next, &tbl_next_num, &masked_ip, 1, (uint8_t)(i + 1), @@ -993,7 +993,7 @@ rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, u /* Check user arguments. */ if ((lpm == NULL) || next_hop == NULL || ip == NULL || - (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH)) + (depth < 1) || (depth > RTE_IPV6_MAX_DEPTH)) return -EINVAL; /* Copy the IP and mask it to avoid modifying user's input data. */ @@ -1267,7 +1267,7 @@ rte_lpm6_delete(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t de struct rte_lpm6_tbl_entry *from, *to; /* Check input arguments. */ - if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH)) + if ((lpm == NULL) || (depth < 1) || (depth > RTE_IPV6_MAX_DEPTH)) return -EINVAL; /* Copy the IP and mask it to avoid modifying user's input data. */ diff --git a/lib/lpm/rte_lpm6.h b/lib/lpm/rte_lpm6.h index 87392194237c..19b498a78d5d 100644 --- a/lib/lpm/rte_lpm6.h +++ b/lib/lpm/rte_lpm6.h @@ -17,9 +17,6 @@ extern "C" { #endif - -#define RTE_LPM6_MAX_DEPTH 128 -#define RTE_LPM6_IPV6_ADDR_SIZE 16 /** Max number of characters in LPM name. */ #define RTE_LPM6_NAMESIZE 32 diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c index ec46c865ddf7..207ece0507dd 100644 --- a/lib/rib/rte_rib6.c +++ b/lib/rib/rte_rib6.c @@ -20,7 +20,6 @@ #include "rib_log.h" #define RTE_RIB_VALID_NODE 1 -#define RIB6_MAXDEPTH 128 /* Maximum length of a RIB6 name. */ #define RTE_RIB6_NAMESIZE 64 @@ -89,7 +88,7 @@ static inline struct rte_rib6_node * get_nxt_node(struct rte_rib6_node *node, const struct rte_ipv6_addr *ip) { - if (node->depth == RIB6_MAXDEPTH) + if (node->depth == RTE_IPV6_MAX_DEPTH) return NULL; return (get_dir(ip, node->depth)) ? node->right : node->left; @@ -158,7 +157,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib, struct rte_rib6_node *cur; struct rte_ipv6_addr tmp_ip; - if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) { + if (unlikely(rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH)) { rte_errno = EINVAL; return NULL; } @@ -196,7 +195,7 @@ rte_rib6_get_nxt(struct rte_rib6 *rib, struct rte_rib6_node *tmp, *prev = NULL; struct rte_ipv6_addr tmp_ip; - if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) { + if (unlikely(rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH)) { rte_errno = EINVAL; return NULL; } @@ -279,7 +278,7 @@ rte_rib6_insert(struct rte_rib6 *rib, int i, d; uint8_t common_depth, ip_xor; - if (unlikely((rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH))) { + if (unlikely((rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH))) { rte_errno = EINVAL; return NULL; } @@ -341,7 +340,7 @@ rte_rib6_insert(struct rte_rib6 *rib, /* closest node found, new_node should be inserted in the middle */ common_depth = RTE_MIN(depth, (*tmp)->depth); - for (i = 0, d = 0; i < RTE_RIB6_IPV6_ADDR_SIZE; i++) { + for (i = 0, d = 0; i < RTE_IPV6_ADDR_SIZE; i++) { ip_xor = tmp_ip.a[i] ^ (*tmp)->ip.a[i]; if (ip_xor == 0) d += 8; diff --git a/lib/rib/rte_rib6.h b/lib/rib/rte_rib6.h index fcf4169ca790..0e72766876ed 100644 --- a/lib/rib/rte_rib6.h +++ b/lib/rib/rte_rib6.h @@ -22,8 +22,6 @@ extern "C" { #endif -#define RTE_RIB6_IPV6_ADDR_SIZE 16 - /** * rte_rib6_get_nxt() flags */ @@ -65,7 +63,7 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src) { if ((dst == NULL) || (src == NULL)) return; - rte_memcpy(dst, src, RTE_RIB6_IPV6_ADDR_SIZE); + rte_memcpy(dst, src, RTE_IPV6_ADDR_SIZE); } /** @@ -89,7 +87,7 @@ rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) { if ((ip1 == NULL) || (ip2 == NULL)) return 0; - for (i = 0; i < RTE_RIB6_IPV6_ADDR_SIZE; i++) { + for (i = 0; i < RTE_IPV6_ADDR_SIZE; i++) { if (ip1[i] != ip2[i]) return 0; } -- 2.46.1