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 4C478A0561; Wed, 3 Mar 2021 12:52:52 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0827840683; Wed, 3 Mar 2021 12:52:52 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 656214067B for ; Wed, 3 Mar 2021 12:52:50 +0100 (CET) IronPort-SDR: aAjkgVFV5fhLO5T699aniQ/gOdjN+UjK9ZEq1rjGoYCFskP5SsEcysPWkWxVZUCcmdLgupmlQm SJM5WvV3Jf6A== X-IronPort-AV: E=McAfee;i="6000,8403,9911"; a="248582538" X-IronPort-AV: E=Sophos;i="5.81,219,1610438400"; d="scan'208";a="248582538" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2021 03:52:49 -0800 IronPort-SDR: a3zeB2/PeX5dt0FwdzuCsUKS3PESvW3ZppMvWMc75w16QgBdKgd8DocGx/zOLp2F9aJVPvLvjK mwqIf6rZtSuQ== X-IronPort-AV: E=Sophos;i="5.81,219,1610438400"; d="scan'208";a="383957389" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.213.255.10]) ([10.213.255.10]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2021 03:52:46 -0800 To: Conor Walsh , jerinj@marvell.com, stephen@networkplumber.org, bernard.iremonger@intel.com, konstantin.ananyev@intel.com, vladimir.medvedkin@intel.com Cc: dev@dpdk.org References: <20210218152056.1893590-1-conor.walsh@intel.com> <20210219150945.2071651-1-conor.walsh@intel.com> <20210219150945.2071651-5-conor.walsh@intel.com> From: "Burakov, Anatoly" Message-ID: <94472bc7-a475-cc60-8343-6d605945eae5@intel.com> Date: Wed, 3 Mar 2021 11:52:42 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20210219150945.2071651-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 v3 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" On 19-Feb-21 3:09 PM, 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 > --- > + || defined RTE_ARCH_PPC_64 > +#define FIB_SEND_MULTI > +#endif > + > +static struct rte_fib *ipv4_l3fwd_fib_lookup_struct[NB_SOCKETS]; > +static struct rte_fib6 *ipv6_l3fwd_fib_lookup_struct[NB_SOCKETS]; > + > +/* Parse packet type and ip address. */ > +static inline void > +fib_parse_packet(struct rte_mbuf *mbuf, > + uint32_t *ipv4, uint32_t *ipv4_cnt, > + uint8_t ipv6[RTE_FIB6_IPV6_ADDR_SIZE], > + uint32_t *ipv6_cnt, uint8_t *ip_type) Nitpicking, but here and in a bunch of other places, the indentation is quite odd :) > + > +/* 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_reassem = 0, ipv6_reassem = 0; I don't quite follow the naming here - this looks like it's "reassembling" something but i don't see any IP reassembly going on? Artifacts of copy-paste? > + 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]) { > + if (hopsv4[ipv4_reassem] != FIB_DEFAULT_HOP) > + hops[i] = (uint16_t)hopsv4[ipv4_reassem]; > + else > + hops[i] = portid; > + ipv4_reassem++; Nitpicking, but could be made slightly more concise and readable: const uint16_t nh = (uint16_t)hopsv4[ipv4_reassem++]; hops[i] = nh != FIB_DEFAULT_HOP ? nh : portid; Same for IPv6. -- Thanks, Anatoly