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 AB2C4A0546; Mon, 8 Mar 2021 11:42:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 90B5A22A377; Mon, 8 Mar 2021 11:42:31 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id EC5D240141 for ; Mon, 8 Mar 2021 11:42:29 +0100 (CET) IronPort-SDR: wEqxZsup3a8GVjL0Spu1EUFDODmNG+coeyaEgcrDdTwTzNEpgENPKdwu2q/XULlLfrtbhACdM9 esrRpIUKnZQQ== X-IronPort-AV: E=McAfee;i="6000,8403,9916"; a="273031756" X-IronPort-AV: E=Sophos;i="5.81,232,1610438400"; d="scan'208";a="273031756" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2021 02:42:29 -0800 IronPort-SDR: NKvduEZjAZWlKfJ0mi8Rw9g6pjK+eqD49uLucGPbYsZEUxHFK6B4A5y/g281qwEeMPwgwT8GK/ pTTpUYb5eDbA== X-IronPort-AV: E=Sophos;i="5.81,232,1610438400"; d="scan'208";a="409251340" Received: from vmedvedk-mobl.ger.corp.intel.com (HELO [10.214.231.108]) ([10.214.231.108]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2021 02:42:26 -0800 To: "Walsh, Conor" , "jerinj@marvell.com" , "stephen@networkplumber.org" , "Iremonger, Bernard" , "Ananyev, Konstantin" Cc: "dev@dpdk.org" References: <20210218152056.1893590-1-conor.walsh@intel.com> <20210219150945.2071651-1-conor.walsh@intel.com> <20210219150945.2071651-3-conor.walsh@intel.com> From: "Medvedkin, Vladimir" Message-ID: Date: Mon, 8 Mar 2021 10:42:23 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210219150945.2071651-3-conor.walsh@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 2/5] examples/l3fwd: move l3fwd routes to common header 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 Sender: "dev" On 19/02/2021 15:09, Walsh, Conor wrote: > To prevent code duplication from the addition of lookup methods > the routes specified in lpm should be moved to a common header. > > Signed-off-by: Conor Walsh > --- > examples/l3fwd/l3fwd_common_route.h | 48 +++++++++++++++++++ > examples/l3fwd/l3fwd_lpm.c | 74 +++++++---------------------- > 2 files changed, 65 insertions(+), 57 deletions(-) > create mode 100644 examples/l3fwd/l3fwd_common_route.h > > diff --git a/examples/l3fwd/l3fwd_common_route.h b/examples/l3fwd/l3fwd_common_route.h > new file mode 100644 > index 0000000000..7f0125a8a5 > --- /dev/null > +++ b/examples/l3fwd/l3fwd_common_route.h > @@ -0,0 +1,48 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2021 Intel Corporation > + */ > + > +#include > +#include > + > +struct ipv4_l3fwd_common_route { > +uint32_t ip; > +uint8_t depth; > +uint8_t if_out; > +}; > + > +struct ipv6_l3fwd_common_route { > +uint8_t ip[16]; > +uint8_t depth; > +uint8_t if_out; > +}; > + > +/* > + * 198.18.0.0/16 are set aside for RFC2544 benchmarking (RFC5735). > + * 198.18.{0-7}.0/24 = Port {0-7} > + */ > +static const struct ipv4_l3fwd_common_route ipv4_l3fwd_common_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}, > +{RTE_IPV4(198, 18, 3, 0), 24, 3}, > +{RTE_IPV4(198, 18, 4, 0), 24, 4}, > +{RTE_IPV4(198, 18, 5, 0), 24, 5}, > +{RTE_IPV4(198, 18, 6, 0), 24, 6}, > +{RTE_IPV4(198, 18, 7, 0), 24, 7}, > +}; > + > +/* > + * 2001:200::/48 is IANA reserved range for IPv6 benchmarking (RFC5180). > + * 2001:200:0:{0-7}::/64 = Port {0-7} > + */ > +static const struct ipv6_l3fwd_common_route ipv6_l3fwd_common_route_array[] = { > +{{32, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 0}, > +{{32, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 1}, > +{{32, 1, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 2}, > +{{32, 1, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 3}, > +{{32, 1, 2, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 4}, > +{{32, 1, 2, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 5}, > +{{32, 1, 2, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 6}, > +{{32, 1, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 7}, > +}; > diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c > index 1cfaf36572..818cf717d1 100644 > --- a/examples/l3fwd/l3fwd_lpm.c > +++ b/examples/l3fwd/l3fwd_lpm.c > @@ -30,47 +30,7 @@ > #include "l3fwd.h" > #include "l3fwd_event.h" > > -struct ipv4_l3fwd_lpm_route { > -uint32_t ip; > -uint8_t depth; > -uint8_t if_out; > -}; > - > -struct ipv6_l3fwd_lpm_route { > -uint8_t ip[16]; > -uint8_t depth; > -uint8_t if_out; > -}; > - > -/* > - * 198.18.0.0/16 are set aside for RFC2544 benchmarking (RFC5735). > - * 198.18.{0-7}.0/24 = Port {0-7} > - */ > -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}, > -{RTE_IPV4(198, 18, 3, 0), 24, 3}, > -{RTE_IPV4(198, 18, 4, 0), 24, 4}, > -{RTE_IPV4(198, 18, 5, 0), 24, 5}, > -{RTE_IPV4(198, 18, 6, 0), 24, 6}, > -{RTE_IPV4(198, 18, 7, 0), 24, 7}, > -}; > - > -/* > - * 2001:200::/48 is IANA reserved range for IPv6 benchmarking (RFC5180). > - * 2001:200:0:{0-7}::/64 = Port {0-7} > - */ > -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}, 64, 0}, > -{{32, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 1}, > -{{32, 1, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 2}, > -{{32, 1, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 3}, > -{{32, 1, 2, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 4}, > -{{32, 1, 2, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 5}, > -{{32, 1, 2, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 6}, > -{{32, 1, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 7}, > -}; > +#include "l3fwd_common_route.h" > > #define IPV4_L3FWD_LPM_MAX_RULES 1024 > #define IPV4_L3FWD_LPM_NUMBER_TBL8S (1 << 8) > @@ -485,18 +445,18 @@ setup_lpm(const int socketid) > socketid); > > /* populate the LPM table */ > -for (i = 0; i < RTE_DIM(ipv4_l3fwd_lpm_route_array); i++) { > +for (i = 0; i < RTE_DIM(ipv4_l3fwd_common_route_array); i++) { > struct in_addr in; > > /* skip unused ports */ > -if ((1 << ipv4_l3fwd_lpm_route_array[i].if_out & > +if ((1 << ipv4_l3fwd_common_route_array[i].if_out & > enabled_port_mask) == 0) > continue; > > ret = rte_lpm_add(ipv4_l3fwd_lpm_lookup_struct[socketid], > -ipv4_l3fwd_lpm_route_array[i].ip, > -ipv4_l3fwd_lpm_route_array[i].depth, > -ipv4_l3fwd_lpm_route_array[i].if_out); > +ipv4_l3fwd_common_route_array[i].ip, > +ipv4_l3fwd_common_route_array[i].depth, > +ipv4_l3fwd_common_route_array[i].if_out); > > if (ret < 0) { > rte_exit(EXIT_FAILURE, > @@ -504,11 +464,11 @@ setup_lpm(const int socketid) > i, socketid); > } > > -in.s_addr = htonl(ipv4_l3fwd_lpm_route_array[i].ip); > +in.s_addr = htonl(ipv4_l3fwd_common_route_array[i].ip); > printf("LPM: Adding route %s / %d (%d)\n", > inet_ntop(AF_INET, &in, abuf, sizeof(abuf)), > -ipv4_l3fwd_lpm_route_array[i].depth, > -ipv4_l3fwd_lpm_route_array[i].if_out); > +ipv4_l3fwd_common_route_array[i].depth, > +ipv4_l3fwd_common_route_array[i].if_out); > } > > /* create the LPM6 table */ > @@ -525,17 +485,17 @@ setup_lpm(const int socketid) > socketid); > > /* populate the LPM table */ > -for (i = 0; i < RTE_DIM(ipv6_l3fwd_lpm_route_array); i++) { > +for (i = 0; i < RTE_DIM(ipv6_l3fwd_common_route_array); i++) { > > /* skip unused ports */ > -if ((1 << ipv6_l3fwd_lpm_route_array[i].if_out & > +if ((1 << ipv6_l3fwd_common_route_array[i].if_out & > enabled_port_mask) == 0) > continue; > > ret = rte_lpm6_add(ipv6_l3fwd_lpm_lookup_struct[socketid], > -ipv6_l3fwd_lpm_route_array[i].ip, > -ipv6_l3fwd_lpm_route_array[i].depth, > -ipv6_l3fwd_lpm_route_array[i].if_out); > +ipv6_l3fwd_common_route_array[i].ip, > +ipv6_l3fwd_common_route_array[i].depth, > +ipv6_l3fwd_common_route_array[i].if_out); > > if (ret < 0) { > rte_exit(EXIT_FAILURE, > @@ -544,10 +504,10 @@ setup_lpm(const int socketid) > } > > printf("LPM: Adding route %s / %d (%d)\n", > - inet_ntop(AF_INET6, ipv6_l3fwd_lpm_route_array[i].ip, > + inet_ntop(AF_INET6, ipv6_l3fwd_common_route_array[i].ip, > abuf, sizeof(abuf)), > - ipv6_l3fwd_lpm_route_array[i].depth, > - ipv6_l3fwd_lpm_route_array[i].if_out); > + ipv6_l3fwd_common_route_array[i].depth, > + ipv6_l3fwd_common_route_array[i].if_out); > } > } > > -- > 2.25.1 > Acked-by: Vladimir Medvedkin -- Regards, Vladimir