From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AFF45A0597; Fri, 10 Apr 2020 01:07:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 814401D171; Fri, 10 Apr 2020 01:07:37 +0200 (CEST) Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by dpdk.org (Postfix) with ESMTP id 930C61C238 for ; Fri, 10 Apr 2020 01:07:36 +0200 (CEST) Received: by mail-lj1-f196.google.com with SMTP id r24so315175ljd.4 for ; Thu, 09 Apr 2020 16:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=fGKK3qIATrU2krS3gWsBAa7J6WT06l2TAFicmHsF764=; b=AAEx1TWURNTTb9wwOqbOI9UITrsojynzteUWjtuTL5lcLc+2mqEOvUXubufRTtqV6F i/IXqxkmldRsT29ElGMUsqgw0DpOD34UqfWYEyLb4zUH0ce0dKNJ+dTufx/kMa6n+P3M kdkdN32GPmIpVfdy7JxeBqggwDPYUy9kfkzytV+bD6Y3KN2AuYfde4M0DXHQeWU1N7O+ Bes0Swu9ApuaH81jz2elmuiQvIqNkWiffp/xsP0DR3yjZOp6/ES+mgGH3sAIeUqzVBqZ ulSrOuHoUfh2LmRbCVS5bRzG8fOKzJ4NflqlKGBWIYv4d08rdDe6IrNsAzVNU1EA71mk qmjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fGKK3qIATrU2krS3gWsBAa7J6WT06l2TAFicmHsF764=; b=OGc1gADQji7ERCE5AU7c3T6caqpzPqPrNvS0BCl3XDhTZ98b+dTAlGZpMhZNCn/NlC oZt9nd4pPtsckNTmycbf8hCjq6A0GPvzZZ/jLbpjSutNLIbmgi1GyCOj80QxBQWMy0Jm wOFZEV+9Q0AIRaROrp6ZQ+dtbYrh7dDjT8YsCEXXfE2SbTGlMsTOAmYIn8IN+GQAA1Uw qIzuuwmyYorO+QHBaMfK+4j9DgXP5tsJQZ9UQ2t/jFvBFmFn/wMtK1E8PND7W6JgEPDI L59WGM4AKE0gKQpcvI/HnBFGNumR/oVnporKrSMyBDmIYcKx+ZOOkvq4wN46KVqHPZh9 kNUQ== X-Gm-Message-State: AGi0PuYaUzjGemSrXjEFbYAjSk4LbTzlGp3jQm9nQPcTMzshdsrG7wY7 Ljge/7enOTx42MitmE9nJABpaxr8RRM= X-Google-Smtp-Source: APiQypIWf7JuUH//ETN9J4Qh6lxaYsCKp5DMk80w3oahX1i3WS4OJtF8bXfJdlHWppk+BmECOZpbgQ== X-Received: by 2002:a2e:4942:: with SMTP id b2mr1278423ljd.135.1586473655996; Thu, 09 Apr 2020 16:07:35 -0700 (PDT) Received: from [192.168.8.100] (user-5-173-33-152.play-internet.pl. [5.173.33.152]) by smtp.gmail.com with ESMTPSA id e1sm98582ljo.16.2020.04.09.16.07.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Apr 2020 16:07:35 -0700 (PDT) To: dev@dpdk.org References: <20200331192945.2466880-1-jerinj@marvell.com> <20200405085613.1336841-1-jerinj@marvell.com> <20200405085613.1336841-20-jerinj@marvell.com> From: Andrzej Ostruszka Message-ID: Date: Fri, 10 Apr 2020 01:07:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200405085613.1336841-20-jerinj@marvell.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 19/29] node: add generic ipv4 lookup node 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" On 4/5/20 10:56 AM, jerinj@marvell.com wrote: > From: Pavan Nikhilesh > > Add IPv4 lookup process function for ip4_lookup node. > This node performs LPM lookup using simple RTE_LPM API on every packet > received and forwards it to a next node that is identified by lookup > result. > > Signed-off-by: Pavan Nikhilesh > Signed-off-by: Nithin Dabilpuram [...] > +static uint16_t > +ip4_lookup_node_process(struct rte_graph *graph, struct rte_node *node, > + void **objs, uint16_t nb_objs) > +{ > + struct rte_ipv4_hdr *ipv4_hdr; > + void **to_next, **from; > + uint16_t last_spec = 0; > + struct rte_mbuf *mbuf; > + rte_edge_t next_index; > + struct rte_lpm *lpm; > + uint16_t held = 0; > + uint32_t drop_nh; > + int i, rc; > + > + /* Speculative next */ > + next_index = RTE_NODE_IP4_LOOKUP_NEXT_REWRITE; > + /* Drop node */ > + drop_nh = ((uint32_t)RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP) << 16; > + > + /* Get socket specific LPM from ctx */ > + lpm = *((struct rte_lpm **)node->ctx); > + from = objs; > + > + /* Get stream for the speculated next node */ > + to_next = rte_node_next_stream_get(graph, node, next_index, nb_objs); > + for (i = 0; i < nb_objs; i++) { > + uint32_t next_hop; > + uint16_t next; > + > + mbuf = (struct rte_mbuf *)objs[i]; > + > + /* Extract DIP of mbuf0 */ > + ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *, > + sizeof(struct rte_ether_hdr)); > + /* Extract cksum, ttl as ipv4 hdr is in cache */ > + rte_node_mbuf_priv1(mbuf)->cksum = ipv4_hdr->hdr_checksum; > + rte_node_mbuf_priv1(mbuf)->ttl = ipv4_hdr->time_to_live; > + > + rc = rte_lpm_lookup(lpm, rte_be_to_cpu_32(ipv4_hdr->dst_addr), > + &next_hop); > + next_hop = (rc == 0) ? next_hop : drop_nh; Maybe simple if here? I see the same in other patches. > + > + rte_node_mbuf_priv1(mbuf)->nh = (uint16_t)next_hop; > + next_hop = next_hop >> 16; > + next = (uint16_t)next_hop; > + > + if (unlikely(next_index != next)) { > + /* Copy things successfully speculated till now */ > + rte_memcpy(to_next, from, last_spec * sizeof(from[0])); > + from += last_spec; > + to_next += last_spec; > + held += last_spec; > + last_spec = 0; > + > + rte_node_enqueue_x1(graph, node, next, from[0]); > + from += 1; > + } else { > + last_spec += 1; > + } > + } > + > + /* !!! Home run !!! */ > + if (likely(last_spec == nb_objs)) { > + rte_node_next_stream_move(graph, node, next_index); > + return nb_objs; > + } > + held += last_spec; > + rte_memcpy(to_next, from, last_spec * sizeof(from[0])); > + rte_node_next_stream_put(graph, node, next_index, held); OK. Forget my comments in different mail about difference between encode/put - I got it now. > + > + return nb_objs; > +} > + [...] With regards Andrzej Ostruszka