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 ADACDA0564; Fri, 12 Mar 2021 19:56:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 720861608DA; Fri, 12 Mar 2021 19:56:56 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id B0E8D1608D5 for ; Fri, 12 Mar 2021 19:56:54 +0100 (CET) IronPort-SDR: B8cBBN1aEY30wPR33tIJxxYYGPYJgsiLG81tPNZnmUvSt+wxJZ6pAoHdM1sw0nP3krBKBTM0U3 YocVDw2h98Gg== X-IronPort-AV: E=McAfee;i="6000,8403,9921"; a="273918763" X-IronPort-AV: E=Sophos;i="5.81,244,1610438400"; d="scan'208";a="273918763" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 10:56:53 -0800 IronPort-SDR: V2D30UZPO9Dl+WJezL4m9esQaUph4+cGAK5iBmgp34nYTzaexRRcIQL70TUFBCxpfwA7NyRiJ8 8leLdTjBGnSw== X-IronPort-AV: E=Sophos;i="5.81,244,1610438400"; d="scan'208";a="411105180" Received: from vmedvedk-mobl.ger.corp.intel.com (HELO [10.249.44.131]) ([10.249.44.131]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 10:56:51 -0800 To: Conor Walsh , jerinj@marvell.com, stephen@networkplumber.org, bernard.iremonger@intel.com, konstantin.ananyev@intel.com, anatoly.burakov@intel.com Cc: dev@dpdk.org References: <20210219150945.2071651-1-conor.walsh@intel.com> <20210311120153.186213-1-conor.walsh@intel.com> <20210311120153.186213-5-conor.walsh@intel.com> From: "Medvedkin, Vladimir" Message-ID: <3a9b25b8-6053-c236-bc61-1870f09adfd3@intel.com> Date: Fri, 12 Mar 2021 18:56:45 +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: <20210311120153.186213-5-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 v4 4/5] examples/l3fwd: implement FIB lookup method 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" Hi Conor, see comment inlined On 11/03/2021 12:01, Conor Walsh wrote: > This patch implements the Forwarding Information Base (FIB) library > in l3fwd using the function calls and infrastructure introduced in > the previous patch. > > Signed-off-by: Conor Walsh > Acked-by: Konstantin Ananyev > --- > examples/l3fwd/l3fwd_fib.c | 482 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 476 insertions(+), 6 deletions(-) > > +/* Bulk parse, fib lookup and send. */ > +static inline void > +fib_send_packets(int nb_rx, struct rte_mbuf **pkts_burst, > + uint16_t portid, struct lcore_conf *qconf) > +{ > + uint32_t ipv4_arr[nb_rx]; > + uint8_t ipv6_arr[nb_rx][RTE_FIB6_IPV6_ADDR_SIZE]; > + uint16_t hops[nb_rx]; > + uint64_t hopsv4[nb_rx], hopsv6[nb_rx]; > + uint8_t type_arr[nb_rx]; > + uint32_t ipv4_cnt = 0, ipv6_cnt = 0; > + uint32_t ipv4_arr_assem = 0, ipv6_arr_assem = 0; > + uint16_t nh; > + int32_t i; > + > + /* Prefetch first packets. */ > + for (i = 0; i < FIB_PREFETCH_OFFSET && i < nb_rx; i++) > + rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i], void *)); > + > + /* Parse packet info and prefetch. */ > + for (i = 0; i < (nb_rx - FIB_PREFETCH_OFFSET); i++) { > + /* Prefetch packet. */ > + rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[ > + i + FIB_PREFETCH_OFFSET], void *)); > + fib_parse_packet(pkts_burst[i], > + &ipv4_arr[ipv4_cnt], &ipv4_cnt, > + ipv6_arr[ipv6_cnt], &ipv6_cnt, > + &type_arr[i]); > + } > + > + /* Parse remaining packet info. */ > + for (; i < nb_rx; i++) > + fib_parse_packet(pkts_burst[i], > + &ipv4_arr[ipv4_cnt], &ipv4_cnt, > + ipv6_arr[ipv6_cnt], &ipv6_cnt, > + &type_arr[i]); > + > + /* Lookup IPv4 hops if IPv4 packets are present. */ > + if (likely(ipv4_cnt > 0)) > + rte_fib_lookup_bulk(qconf->ipv4_lookup_struct, > + ipv4_arr, hopsv4, ipv4_cnt); > + > + /* Lookup IPv6 hops if IPv6 packets are present. */ > + if (ipv6_cnt > 0) > + rte_fib6_lookup_bulk(qconf->ipv6_lookup_struct, > + ipv6_arr, hopsv6, ipv6_cnt); > + > + /* Add IPv4 and IPv6 hops to one array depending on type. */ > + for (i = 0; i < nb_rx; i++) { > + if (type_arr[i]) > + nh = (uint16_t)hopsv4[ipv4_arr_assem++]; > + else > + nh = (uint16_t)hopsv6[ipv6_arr_assem++]; > + hops[i] = (nh != FIB_DEFAULT_HOP && nh <= RTE_MAX_ETHPORTS && > + (enabled_port_mask & 1 << nh) != 0) ? nh : portid; I think you can get rid of "nh <= RTE_MAX_ETHPORTS && (enabled_port_mask & 1 << nh) != 0" because it can be controlled during initialization when installing routes to the table. So you can check it just before rte_fib_add() and install FIB_DEFAULT_HOP if needed. Apart from that LGTM. > + } > + > +#if defined FIB_SEND_MULTI > + send_packets_multi(qconf, pkts_burst, hops, nb_rx); > +#else > + fib_send_single(nb_rx, qconf, pkts_burst, hops); > +#endif > +} > + > -- Regards, Vladimir