From patchwork Sun Jan 26 01:09:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 65126 X-Patchwork-Delegate: thomas@monjalon.net 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 EAC54A0530; Sun, 26 Jan 2020 02:09:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D6DA4568A; Sun, 26 Jan 2020 02:09:24 +0100 (CET) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 74BE649E0 for ; Sun, 26 Jan 2020 02:09:21 +0100 (CET) Received: by mail-pg1-f195.google.com with SMTP id r11so3247268pgf.1 for ; Sat, 25 Jan 2020 17:09:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZjzQfkqnxcUOuvLr8Gayao+KffoLw+6HiHTiNfbitYc=; b=PmnuEZuarnpSZsCDgjuJhT0d1rMr9seMAn6o4gXG2JgQLu6LinKxTRrWwtFsPi+2Or 2hJGPuNHGmk/GaA5OVF9/F2IJxcr5Cz6XTb8FozRAo6yWwa7dMIy3mi8QpDlwclvh332 Wp5a8tuguGp/2U+0TBlSUSx14yMojzH7uhbjvvGfZwMfv6kCxbsbWqHz7JBBw/c7rFf+ IZagEb6gq7h05k+U6mafiW1ae8dwa8toGetcLOJkI/pSn0sKXkZ8M6fjzLt9hfwlmatc BTq/n0kB/A3GM3b3riPvECipbg8lx3q9JAjUUFJ7SFLdG9fYFs9tYDnEAtUPuujJ5zBz DcZg== 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=ZjzQfkqnxcUOuvLr8Gayao+KffoLw+6HiHTiNfbitYc=; b=ftH3+nT23++GjeXopgth/LuoxLWSMb826rGUywJCMJcHtWEpU/WxW7uo7Bl8W0WARO E90fp9+JBVXpS2JNY9nnO3XrCSw8ZvWIOJVaAdWxpdIQ7+RyhV5bUB6toflN16gwRmT9 l9NZzMmLCxHUEpPdIe1P3qAsOJLSuOwtTi6RkKHNYycDfBXxMrBurIrPW5/S1k4Bdgs2 O4YiJTCFsUfraIyMgeTFgJUpCmWYXQgWlsAuXhJVHH0Mlg8i0mzj42VL++Gc7oTNDqLU Rvdh1mvM0SFEHx9GMG8TcrJxcfjDndFy7pKfizKh0HqdODRnl0f8nmpsjMBVIqsX5XFs oTbw== X-Gm-Message-State: APjAAAUEMiFx4kqaRbWqKldJRQlfMcx53HUQG8LHNgv3e3QjYHT99ybK w3rS+MfErHeMsOn+G4u/Ry6QfXltHVs= X-Google-Smtp-Source: APXvYqwue4PiErsZPVndsySjyTIygXYFK4q8AZ8Fy2ZHDC4MYnfMNqTKxwwENX6dJ3KI6E9Rk8IZEw== X-Received: by 2002:a62:830b:: with SMTP id h11mr276827pfe.40.1580000960242; Sat, 25 Jan 2020 17:09:20 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t1sm11560267pgq.23.2020.01.25.17.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2020 17:09:19 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Sat, 25 Jan 2020 17:09:07 -0800 Message-Id: <20200126010911.3733-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200126010911.3733-1-stephen@networkplumber.org> References: <20200126010911.3733-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/5] lpm: make ipv6 address immutable 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" Both the table setup and lookup do no modify their arguments. Therefore the parameter should be constant. This is not actually an API breakage since programs can be recompiled without change. This is not an ABI breakage because old programs will still run. Signed-off-by: Stephen Hemminger --- lib/librte_lpm/rte_lpm6.c | 8 ++++---- lib/librte_lpm/rte_lpm6.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c index c46e557e2389..5ea818abd6e9 100644 --- a/lib/librte_lpm/rte_lpm6.c +++ b/lib/librte_lpm/rte_lpm6.c @@ -854,8 +854,8 @@ simulate_add(struct rte_lpm6 *lpm, const uint8_t *masked_ip, uint8_t depth) * Add a route */ int -rte_lpm6_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth, - uint32_t next_hop) +rte_lpm6_add(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth, + uint32_t next_hop) { struct rte_lpm6_tbl_entry *tbl; struct rte_lpm6_tbl_entry *tbl_next = NULL; @@ -913,7 +913,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth, */ static inline int lookup_step(const struct rte_lpm6 *lpm, const struct rte_lpm6_tbl_entry *tbl, - const struct rte_lpm6_tbl_entry **tbl_next, uint8_t *ip, + const struct rte_lpm6_tbl_entry **tbl_next, const uint8_t *ip, uint8_t first_byte, uint32_t *next_hop) { uint32_t tbl8_index, tbl_entry; @@ -943,7 +943,7 @@ lookup_step(const struct rte_lpm6 *lpm, const struct rte_lpm6_tbl_entry *tbl, * Looks up an IP */ int -rte_lpm6_lookup(const struct rte_lpm6 *lpm, uint8_t *ip, +rte_lpm6_lookup(const struct rte_lpm6 *lpm, const uint8_t *ip, uint32_t *next_hop) { const struct rte_lpm6_tbl_entry *tbl; diff --git a/lib/librte_lpm/rte_lpm6.h b/lib/librte_lpm/rte_lpm6.h index 37dfb20249a8..042991f8cdb7 100644 --- a/lib/librte_lpm/rte_lpm6.h +++ b/lib/librte_lpm/rte_lpm6.h @@ -94,8 +94,8 @@ rte_lpm6_free(struct rte_lpm6 *lpm); * 0 on success, negative value otherwise */ int -rte_lpm6_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth, - uint32_t next_hop); +rte_lpm6_add(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth, + uint32_t next_hop); /** * Check if a rule is present in the LPM table, @@ -171,7 +171,7 @@ rte_lpm6_delete_all(struct rte_lpm6 *lpm); * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit */ int -rte_lpm6_lookup(const struct rte_lpm6 *lpm, uint8_t *ip, uint32_t *next_hop); +rte_lpm6_lookup(const struct rte_lpm6 *lpm, const uint8_t *ip, uint32_t *next_hop); /** * Lookup multiple IP addresses in an LPM table. From patchwork Sun Jan 26 01:09:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 65127 X-Patchwork-Delegate: thomas@monjalon.net 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 5A2BFA0530; Sun, 26 Jan 2020 02:09:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B6671199BC; Sun, 26 Jan 2020 02:09:26 +0100 (CET) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 232AE4C8B for ; Sun, 26 Jan 2020 02:09:23 +0100 (CET) Received: by mail-pl1-f196.google.com with SMTP id p9so2379253plk.9 for ; Sat, 25 Jan 2020 17:09:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EHcb8pqwC+IJBPh6to8bv1paAjMJ12JgruJ3tbsoQdM=; b=bt3xG6wUS0R3vbqNAayCvcYHOkGNjeyficgqYDFvxaLBtHZtg47rWg/a5YrzqqZVnO T+NPCiNr3NDWVmj+sAHS3Eh0LP6Oiuk8OoKIuG9cJ2kTBakAUTYgLKGMMa+h4S2n7vlA xQe/n1uPDVuJ7+pftxNKRcZTjRyR5amb+yJbPjrfN9vNEtr24r6YPQ+G8fcD1gJnnud4 kd/cRv6rNUpDohl3lrh7nRsto8gDUzE8VeXNSAuJZlC4G2g8h5b8i3Uerm9Zn3Z2j4oV mWsI4jK1XNhzAOoOL8fY39dTSSejveRWZyAjrGlVi1T5tqYbGiZHJc3dtRBS/9vMdN50 ee4g== 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=EHcb8pqwC+IJBPh6to8bv1paAjMJ12JgruJ3tbsoQdM=; b=Isgu/7W8/+1aag3kabtHtuqQE2dANWSI5obeZaLgl47lS8KeImMVS7DS9GEzTTTwXO BX3y/sHiLks/RTekdox6TugUAyHBlDjNHCIOi6qHLQu9k35FccRXxb7CPGkQ+5VMA5zV j2eTTicagZ1PD5oLccXLQ2LQWFrKo9jD8pU1vSK5k7Xv0b27QngE7imPh+rGC5Gdd3hb 3ZAMpSNyEyOPHjB0FtHkEXZrX1uLuRdENnBsXMsXuqM9uK5rb8EjIWsfKIdWLUHszwmH JLJh39B09cHWk8Y59IMpfzaAG+q8ELeLZ4w+GVZ+QfNepInbaThiZE7/SMOOk/4KNRTe 9wnw== X-Gm-Message-State: APjAAAXqGf0RPBOSqFGHyG7/zp2lHXhexQByW/YJ39A7acIorzMScphf i0u3UJN6VoZHANfsjitQQSyF9ZuULxM= X-Google-Smtp-Source: APXvYqy0QZib6wQzhb/0VDR5Tmd2Ae8GSwlsQtoJFwbriXZFX9GyWwyV6EmoZivasZTSKhe+x+KNHg== X-Received: by 2002:a17:902:b40b:: with SMTP id x11mr11384145plr.268.1580000961804; Sat, 25 Jan 2020 17:09:21 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t1sm11560267pgq.23.2020.01.25.17.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2020 17:09:21 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Sat, 25 Jan 2020 17:09:08 -0800 Message-Id: <20200126010911.3733-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200126010911.3733-1-stephen@networkplumber.org> References: <20200126010911.3733-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/5] examples/l3fwd: use RTE_DIM 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" Use the standard RTE_DIM macro to compute array size. Signed-off-by: Stephen Hemminger --- examples/l3fwd/l3fwd_lpm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index 349de2703cd1..b6802d63ba1d 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -65,10 +65,8 @@ static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = { {{32, 1, 2, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0}, 48, 7}, }; -#define IPV4_L3FWD_LPM_NUM_ROUTES \ - (sizeof(ipv4_l3fwd_lpm_route_array) / sizeof(ipv4_l3fwd_lpm_route_array[0])) -#define IPV6_L3FWD_LPM_NUM_ROUTES \ - (sizeof(ipv6_l3fwd_lpm_route_array) / sizeof(ipv6_l3fwd_lpm_route_array[0])) +#define IPV4_L3FWD_LPM_NUM_ROUTES RTE_DIM(ipv4_l3fwd_lpm_route_array) +#define IPV6_L3FWD_LPM_NUM_ROUTES RTE_DIM(ipv6_l3fwd_lpm_route_array) #define IPV4_L3FWD_LPM_MAX_RULES 1024 #define IPV4_L3FWD_LPM_NUMBER_TBL8S (1 << 8) From patchwork Sun Jan 26 01:09:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 65128 X-Patchwork-Delegate: thomas@monjalon.net 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 6AD60A0530; Sun, 26 Jan 2020 02:09:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EB3871B75C; Sun, 26 Jan 2020 02:09:27 +0100 (CET) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 7F5A64C98 for ; Sun, 26 Jan 2020 02:09:24 +0100 (CET) Received: by mail-pl1-f195.google.com with SMTP id p9so2379262plk.9 for ; Sat, 25 Jan 2020 17:09:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X7argtl64QadPyPusopfCglPzIhOlGRHNClkdOL532A=; b=qmawQbcP1CHDgRZTPcspe83JBM/xuu/8fMnDJa28VmWmLCiOkD1OWFvGA9S4EyYtmR mEVNcr3/oZUD0I4+do/WpfZCq+Hi5Zejoil4cdBiquYQ39tSe3RqejasRmUWCa61MO5o qvDVJ5GUtHPh2EycbuQBbhIrw9nR85W8SZJdY+PvAw3z4zIvuBBuCk4UWjJb0WnEqzae Ksdfi1TNlCKlzpZhIM6YXrYQuoscVmMqATY+zmNDOdYbQopGGcABBZYoLuPqsrq0ddSd FAxMqX2cTNvg84ncl2dbcDmYDp9SKkZIxCvG/85B55XEqduQ8WYEJaef1yqL5WnI8MfK 4cVA== 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=X7argtl64QadPyPusopfCglPzIhOlGRHNClkdOL532A=; b=aevw69CkmdT1H8mycThic21TvC6FqOEwbVocqZsbdQrwZQPyC4kAqFcRZvOH+P3Foz LGpYQ0UKb9M07LzwkOGeVVGkxNrVdcFhWxymce85pSAEpFsdJqSUFX465VjwQ5BMEJ+8 OtFQVU2gdY/heSkUTa8wcbsCxE328adbY8PopKseLpfpI+vZJGCn2iQtv7R9C7v/YG8c UZypfDIQtADOEth7i3lcWcI99UzZemeBDmNTOqlQ0Ld170AyotjOfRJQJe3270ER5T42 6iPgrS1v8k6X9K0+WOg+FEibzd0xx2Tp5kjqrJ98GePg9jjwoznmZo1sMlUCooPJKOIx PlEA== X-Gm-Message-State: APjAAAUOtcFLq3uZkWysvwOcd6kBy0kN6yravM+X9Aqleo+6OTjyIyV9 Inqoo93gd28uINzqvI99prFDtt543KU= X-Google-Smtp-Source: APXvYqzoNOtn6AwF++JCM4BrH9CyRJzJjgZ58r7n9tl08nxdgQIETJcEwjMKKNp/K5llBiDC0cPSGw== X-Received: by 2002:a17:90a:3a86:: with SMTP id b6mr7186505pjc.96.1580000963067; Sat, 25 Jan 2020 17:09:23 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t1sm11560267pgq.23.2020.01.25.17.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2020 17:09:22 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Sat, 25 Jan 2020 17:09:09 -0800 Message-Id: <20200126010911.3733-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200126010911.3733-1-stephen@networkplumber.org> References: <20200126010911.3733-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 3/5] examples/l3fwd: make lookup struct static 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" The lookup structure is only used in the lpm code and does not have to be global. Signed-off-by: Stephen Hemminger --- examples/l3fwd/l3fwd_lpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index b6802d63ba1d..486f19963fc4 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -73,8 +73,8 @@ static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = { #define IPV6_L3FWD_LPM_MAX_RULES 1024 #define IPV6_L3FWD_LPM_NUMBER_TBL8S (1 << 16) -struct rte_lpm *ipv4_l3fwd_lpm_lookup_struct[NB_SOCKETS]; -struct rte_lpm6 *ipv6_l3fwd_lpm_lookup_struct[NB_SOCKETS]; +static struct rte_lpm *ipv4_l3fwd_lpm_lookup_struct[NB_SOCKETS]; +static struct rte_lpm6 *ipv6_l3fwd_lpm_lookup_struct[NB_SOCKETS]; static inline uint16_t lpm_get_ipv4_dst_port(void *ipv4_hdr, uint16_t portid, void *lookup_struct) From patchwork Sun Jan 26 01:09:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 65129 X-Patchwork-Delegate: thomas@monjalon.net 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 532F1A0530; Sun, 26 Jan 2020 02:09:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3D3011B952; Sun, 26 Jan 2020 02:09:29 +0100 (CET) Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by dpdk.org (Postfix) with ESMTP id B8D2F5B3A for ; Sun, 26 Jan 2020 02:09:25 +0100 (CET) Received: by mail-pj1-f67.google.com with SMTP id gv17so1576569pjb.1 for ; Sat, 25 Jan 2020 17:09:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H2MaMZyuKvOpMuKMbVqnLtAlSYhNMP3EOxzQP2E6E/4=; b=SaF345hXTdufdmAS/59g0ZcBtAx1v+67mDeRHzXLvcLDAcARRGoPlEAfDnJE7HtWyb dg/9VLbNL5NgvQ3nB05h+yDfdIqQjKS05LldbrjNtsXyofu+zvqFtND/8tmCj+ZRFBV1 SyjoQ6o2t6y9a2dDKKb82f7zz/izwO6hLYKep4mXSAf92HpIHCsDS7CBDCo3aqkRHDSK L2u4tZn/DZw+B++Qd811uTGoJ1gQkRnASnTn9VifnUs5Z3/QaAggcl0CxAVvJGFPG2s7 GzXzj64X2hRre77Z/48k9VX4GzV9GbhgGLl0iJM2aeMrXAxXYhoAAWzmHfKlb46a+A8I Xs0A== 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=H2MaMZyuKvOpMuKMbVqnLtAlSYhNMP3EOxzQP2E6E/4=; b=AaCxWKjyOxBGzEgOzWbXHgGChkNI3RP7LJGC+P2GwumEydcc+cLrL0yvPy6l/PBJRG TZzrRFoBj5VTsJWiJJBjjwQJWDPHMgmr03TwCv6WGdDYhk9BVhNTOHGfI+wCmw42Kaal y5OOIziNg5e+GS0rYxOHdbY1IxtC7EGkHvjGnIeA/qJYMogAeXgvj/y5IN7YKlV5vBiI duBhMimgRfka9Ps830ZT0MGGXJHJ/ax0P+DLxTlqSRuzWVBI07T/eVSjixQS5znFMf4Z RE7eO+FASDSdDpYtdl3i+oHceXgE93lCvjPRu5cXu9NuvXgV236NEwO0qKEmuvZeylZF Rj6Q== X-Gm-Message-State: APjAAAVYyWu7bh4yjkY0WlRc0hQJ9W8tWxTUNh1fLIJGr3rjf18Xj9Pe AWJAgXPP8e4bUpBZgyFGd5exUb3b2zM= X-Google-Smtp-Source: APXvYqxFbs9m9ZPOoRhXVyVK3BPUKMcjEcQl5dscH+VioYwjT5Z9zjsSv3FE2rgvN2ke2xzDi1fzUg== X-Received: by 2002:a17:90b:941:: with SMTP id dw1mr7216536pjb.21.1580000964393; Sat, 25 Jan 2020 17:09:24 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t1sm11560267pgq.23.2020.01.25.17.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2020 17:09:23 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Sat, 25 Jan 2020 17:09:10 -0800 Message-Id: <20200126010911.3733-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200126010911.3733-1-stephen@networkplumber.org> References: <20200126010911.3733-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 4/5] examples/l3fwd: make route array constant 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" The initial route setup array is unmodified by the lpm code and can be made constant. This depends on earlier patch to fix the rte_lpm6 to use const. Signed-off-by: Stephen Hemminger --- examples/l3fwd/l3fwd_lpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index 486f19963fc4..30f6385419ee 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -42,7 +42,7 @@ struct ipv6_l3fwd_lpm_route { }; /* 198.18.0.0/16 are set aside for RFC2544 benchmarking (RFC5735). */ -static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = { +static const struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = { {RTE_IPV4(198, 18, 0, 0), 24, 0}, {RTE_IPV4(198, 18, 1, 0), 24, 1}, {RTE_IPV4(198, 18, 2, 0), 24, 2}, @@ -54,7 +54,7 @@ static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = { }; /* 2001:0200::/48 is IANA reserved range for IPv6 benchmarking (RFC5180) */ -static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = { +static const struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = { {{32, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 48, 0}, {{32, 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, 48, 1}, {{32, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0}, 48, 2}, From patchwork Sun Jan 26 01:09:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 65130 X-Patchwork-Delegate: thomas@monjalon.net 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 C8240A0531; Sun, 26 Jan 2020 02:10:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 896441BE3D; Sun, 26 Jan 2020 02:09:30 +0100 (CET) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by dpdk.org (Postfix) with ESMTP id 1E0701B1D5 for ; Sun, 26 Jan 2020 02:09:27 +0100 (CET) Received: by mail-pj1-f66.google.com with SMTP id m4so1573407pjv.3 for ; Sat, 25 Jan 2020 17:09:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ihqtZlbjenRstaDhM+8Y6HyDQiiYQa0SXkxqKoKCfnI=; b=OqhkpsgWyVS21cOycHdbmzzd531oDffpfmT8sqHNI6RyhrRvUauf/C7dPUeqlRt9yd VtyFcvx97p9B8ksfSEGSxVpDVkvKlO4OI/z6xd9xIwvEI6BVuMah6DQnEqGrsB1dDBmm epS+yHLEX07aDV/n2cLHGkhvkX07wOsQsLZ/shsRj2L8Up+Ut0W/X+0+6PVh/WEbfDAu CuLrIQnbycAUQXaVhKrZlAeOH3wnJ3CIuImRRnG5fGEa3fLe/7gCbEJfGALGf0srtETs sR4Opz4rdZS397BxQ2IhTjjx6znTxmyGllfJpFe3YcYfIJtkczpdmQuj/Mi+dDpMvMlO I5RA== 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=ihqtZlbjenRstaDhM+8Y6HyDQiiYQa0SXkxqKoKCfnI=; b=E8W0B3D37F0ebw1fCjIkODDju0lnSyaxcw1vjvX7BHUfUHQ9qmSioZNcExCL5alQ2h RAIEWA+kinyktdKLn9ZYTy10x8AgRSj0RS/IqloA5B9SXTVawc/OXWAoda/OTCfWLsqb diKfoQlNGwddDbpGba6U7tOOcTdKr+5kuCtNGvKrV6pxSd0+MLTWDvan0fURbOtcab/c W2zLS1684enAPliHhujFUcEbcMfocb5D1fz9a9moukJS4wMYJaiSZjB7WkkmahwL+cGe 7B+vi7oOXNdEf6BaB5NdUg/zQDTkt3MwwpfzCjqQxN/CLu9YI14v4mWPYHAbAm5OthMg 6Mzw== X-Gm-Message-State: APjAAAXsh5oI/iS1h29kmAZXLZdYbUib44kIvSqy8ZNf0Segbrkp4Iix 8+oVoOCjEGzGRSLKZpr2W60DNGJh+v0= X-Google-Smtp-Source: APXvYqzPOnwjLzvGhJolc7PHzDv43oTHfIIJGHJnQxDKOUPd1UKAB69Vl4tEpJp1py6btS7AwA8M2Q== X-Received: by 2002:a17:902:ab91:: with SMTP id f17mr11118456plr.172.1580000965727; Sat, 25 Jan 2020 17:09:25 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t1sm11560267pgq.23.2020.01.25.17.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2020 17:09:24 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Sat, 25 Jan 2020 17:09:11 -0800 Message-Id: <20200126010911.3733-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200126010911.3733-1-stephen@networkplumber.org> References: <20200126010911.3733-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 5/5] examples/l3fwd: improve readability for destination lookup 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" The functions to lookup ipv4 and ipv6 were both using opaque pointers (void *) when they should use a typed pointer instead. The ip headers are not modified during lookup. Get rid of unnecessary cast on the return from the function. Replace complex trigraph expression with simple if to improve readability. Signed-off-by: Stephen Hemminger --- examples/l3fwd/l3fwd_lpm.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index 30f6385419ee..bd6e7fe03d77 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -77,27 +77,31 @@ static struct rte_lpm *ipv4_l3fwd_lpm_lookup_struct[NB_SOCKETS]; static struct rte_lpm6 *ipv6_l3fwd_lpm_lookup_struct[NB_SOCKETS]; static inline uint16_t -lpm_get_ipv4_dst_port(void *ipv4_hdr, uint16_t portid, void *lookup_struct) +lpm_get_ipv4_dst_port(const struct rte_ipv4_hdr *ipv4_hdr, + uint16_t portid, + struct rte_lpm *ipv4_l3fwd_lookup_struct) { + uint32_t dst_ip = rte_be_to_cpu_32(ipv4_hdr->dst_addr); uint32_t next_hop; - struct rte_lpm *ipv4_l3fwd_lookup_struct = - (struct rte_lpm *)lookup_struct; - return (uint16_t) ((rte_lpm_lookup(ipv4_l3fwd_lookup_struct, - rte_be_to_cpu_32(((struct rte_ipv4_hdr *)ipv4_hdr)->dst_addr), - &next_hop) == 0) ? next_hop : portid); + if (rte_lpm_lookup(ipv4_l3fwd_lookup_struct, dst_ip, &next_hop) == 0) + return next_hop; + else + return portid; } static inline uint16_t -lpm_get_ipv6_dst_port(void *ipv6_hdr, uint16_t portid, void *lookup_struct) +lpm_get_ipv6_dst_port(const struct rte_ipv6_hdr *ipv6_hdr, + uint16_t portid, + struct rte_lpm6 *ipv6_l3fwd_lookup_struct) { + const uint8_t *dst_ip = ipv6_hdr->dst_addr; uint32_t next_hop; - struct rte_lpm6 *ipv6_l3fwd_lookup_struct = - (struct rte_lpm6 *)lookup_struct; - return (uint16_t) ((rte_lpm6_lookup(ipv6_l3fwd_lookup_struct, - ((struct rte_ipv6_hdr *)ipv6_hdr)->dst_addr, - &next_hop) == 0) ? next_hop : portid); + if (rte_lpm6_lookup(ipv6_l3fwd_lookup_struct, dst_ip, &next_hop) == 0) + return next_hop; + else + return portid; } static __rte_always_inline uint16_t