DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/1] examples/l3fwd: fix scalar LPM compilation
@ 2022-05-10 11:58 Stanislaw Kardach
  2022-05-11 11:38 ` David Marchand
  2022-05-11 14:56 ` [PATCH v2 " Stanislaw Kardach
  0 siblings, 2 replies; 6+ messages in thread
From: Stanislaw Kardach @ 2022-05-10 11:58 UTC (permalink / raw)
  To: dev; +Cc: Stanislaw Kardach, Frank Zhao, Sam Grove, mw, upstream, pbhagavatula

The lpm_process_event_pkt() can either process a packet using an
architecture specific (defined for X86/SSE, ARM/Neon and PPC64/Altivec)
path or a scalar one. The choice is however done using an ifdef
pre-processor macro. Because of that the scalar version was apparently
not widely excersized/compiled.
Due to some copy/paste errors, the scalar logic in
lpm_process_event_pkt() retained a "continue" statement where a BAD_PORT
should be returned after refactoring of the LPM logic in the l3fwd
example.

Fixes: 99fc91d18082 ("examples/l3fwd: add event lpm main loop")
Cc: pbhagavatula@marvell.com

Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
---
 examples/l3fwd/l3fwd_lpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c
index bec22c44cd..6e1defbf7f 100644
--- a/examples/l3fwd/l3fwd_lpm.c
+++ b/examples/l3fwd/l3fwd_lpm.c
@@ -248,7 +248,7 @@ lpm_process_event_pkt(const struct lcore_conf *lconf, struct rte_mbuf *mbuf)
 		if (is_valid_ipv4_pkt(ipv4_hdr, mbuf->pkt_len)
 				< 0) {
 			mbuf->port = BAD_PORT;
-			continue;
+			return mbuf->port;
 		}
 		/* Update time to live and header checksum */
 		--(ipv4_hdr->time_to_live);
-- 
2.30.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] examples/l3fwd: fix scalar LPM compilation
  2022-05-10 11:58 [PATCH 1/1] examples/l3fwd: fix scalar LPM compilation Stanislaw Kardach
@ 2022-05-11 11:38 ` David Marchand
  2022-05-11 14:18   ` Stanisław Kardach
  2022-05-11 14:56 ` [PATCH v2 " Stanislaw Kardach
  1 sibling, 1 reply; 6+ messages in thread
From: David Marchand @ 2022-05-11 11:38 UTC (permalink / raw)
  To: Stanislaw Kardach
  Cc: dev, Frank Zhao, Sam Grove, Marcin Wojtas, upstream,
	Pavan Nikhilesh, Honnappa Nagarahalli, Konstantin Ananyev

Hello Stanislaw,

On Tue, May 10, 2022 at 1:59 PM Stanislaw Kardach <kda@semihalf.com> wrote:
>
> The lpm_process_event_pkt() can either process a packet using an
> architecture specific (defined for X86/SSE, ARM/Neon and PPC64/Altivec)
> path or a scalar one. The choice is however done using an ifdef
> pre-processor macro. Because of that the scalar version was apparently
> not widely excersized/compiled.
> Due to some copy/paste errors, the scalar logic in
> lpm_process_event_pkt() retained a "continue" statement where a BAD_PORT
> should be returned after refactoring of the LPM logic in the l3fwd
> example.
>
> Fixes: 99fc91d18082 ("examples/l3fwd: add event lpm main loop")
> Cc: pbhagavatula@marvell.com
>
> Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
> ---
>  examples/l3fwd/l3fwd_lpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c
> index bec22c44cd..6e1defbf7f 100644
> --- a/examples/l3fwd/l3fwd_lpm.c
> +++ b/examples/l3fwd/l3fwd_lpm.c
> @@ -248,7 +248,7 @@ lpm_process_event_pkt(const struct lcore_conf *lconf, struct rte_mbuf *mbuf)
>                 if (is_valid_ipv4_pkt(ipv4_hdr, mbuf->pkt_len)
>                                 < 0) {
>                         mbuf->port = BAD_PORT;
> -                       continue;
> +                       return mbuf->port;
>                 }
>                 /* Update time to live and header checksum */
>                 --(ipv4_hdr->time_to_live);

Based on the vector specific implemtations of process_packet in this
example, this code could be replaced with a call to rfc1812_process().
Eth macs updates can be moved prior to rfc1812_process.

What do you think of (untested):

diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c
index bec22c44cd..c73cbda6b5 100644
--- a/examples/l3fwd/l3fwd_lpm.c
+++ b/examples/l3fwd/l3fwd_lpm.c
@@ -234,33 +234,18 @@ lpm_process_event_pkt(const struct lcore_conf
*lconf, struct rte_mbuf *mbuf)
        || defined RTE_ARCH_PPC_64
        process_packet(mbuf, &mbuf->port);
 #else
-
        struct rte_ether_hdr *eth_hdr = rte_pktmbuf_mtod(mbuf,
                        struct rte_ether_hdr *);
-#ifdef DO_RFC_1812_CHECKS
-       struct rte_ipv4_hdr *ipv4_hdr;
-       if (RTE_ETH_IS_IPV4_HDR(mbuf->packet_type)) {
-               /* Handle IPv4 headers.*/
-               ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf,
-                               struct rte_ipv4_hdr *,
-                               sizeof(struct rte_ether_hdr));
-
-               if (is_valid_ipv4_pkt(ipv4_hdr, mbuf->pkt_len)
-                               < 0) {
-                       mbuf->port = BAD_PORT;
-                       continue;
-               }
-               /* Update time to live and header checksum */
-               --(ipv4_hdr->time_to_live);
-               ++(ipv4_hdr->hdr_checksum);
-       }
-#endif
+
        /* dst addr */
        *(uint64_t *)&eth_hdr->dst_addr = dest_eth_addr[mbuf->port];

        /* src addr */
        rte_ether_addr_copy(&ports_eth_addr[mbuf->port],
                        &eth_hdr->src_addr);
+
+       rfc1812_process((struct rte_ipv4_hdr *)(eth_hdr + 1), &mbuf->port,
+               mbuf->packet_type);
 #endif
        return mbuf->port;
 }


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] examples/l3fwd: fix scalar LPM compilation
  2022-05-11 11:38 ` David Marchand
@ 2022-05-11 14:18   ` Stanisław Kardach
  0 siblings, 0 replies; 6+ messages in thread
From: Stanisław Kardach @ 2022-05-11 14:18 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, Frank Zhao, Sam Grove, Marcin Wojtas, upstream,
	Pavan Nikhilesh, Honnappa Nagarahalli, Konstantin Ananyev

On Wed, May 11, 2022 at 1:39 PM David Marchand
<david.marchand@redhat.com> wrote:
<snip>
> Based on the vector specific implemtations of process_packet in this
> example, this code could be replaced with a call to rfc1812_process().
> Eth macs updates can be moved prior to rfc1812_process.
>
> What do you think of (untested):
That actually looks a lot better! Though it seems safer to use
rte_pktmbuf_mtod_offset() for getting the ipv4_hdr. I'll post V2 with
this update.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/1] examples/l3fwd: fix scalar LPM compilation
  2022-05-10 11:58 [PATCH 1/1] examples/l3fwd: fix scalar LPM compilation Stanislaw Kardach
  2022-05-11 11:38 ` David Marchand
@ 2022-05-11 14:56 ` Stanislaw Kardach
  2022-05-19 14:53   ` David Marchand
  1 sibling, 1 reply; 6+ messages in thread
From: Stanislaw Kardach @ 2022-05-11 14:56 UTC (permalink / raw)
  To: dev; +Cc: Stanislaw Kardach, Frank Zhao, Sam Grove, mw, upstream, pbhagavatula

The lpm_process_event_pkt() can either process a packet using an
architecture specific (defined for X86/SSE, ARM/Neon and PPC64/Altivec)
path or a scalar one. The choice is however done using an ifdef
pre-processor macro. Because of that the scalar version was apparently
not widely excersized/compiled.
Due to some copy/paste errors, the scalar logic in
lpm_process_event_pkt() retained a "continue" statement where it should
utilize rfc1812_process() and return the port/BAD_PORT.

Fixes: 99fc91d18082 ("examples/l3fwd: add event lpm main loop")
Cc: pbhagavatula@marvell.com

Signed-off-by: Stanislaw Kardach <kda@semihalf.com>

---
v2: Replace existing logic with rfc1812_process().
---
 examples/l3fwd/l3fwd_lpm.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c
index bec22c44cd..7a1e60f6b3 100644
--- a/examples/l3fwd/l3fwd_lpm.c
+++ b/examples/l3fwd/l3fwd_lpm.c
@@ -28,6 +28,7 @@
 #include <rte_lpm6.h>
 
 #include "l3fwd.h"
+#include "l3fwd_common.h"
 #include "l3fwd_event.h"
 
 #include "lpm_route_parse.c"
@@ -237,30 +238,17 @@ lpm_process_event_pkt(const struct lcore_conf *lconf, struct rte_mbuf *mbuf)
 
 	struct rte_ether_hdr *eth_hdr = rte_pktmbuf_mtod(mbuf,
 			struct rte_ether_hdr *);
-#ifdef DO_RFC_1812_CHECKS
-	struct rte_ipv4_hdr *ipv4_hdr;
-	if (RTE_ETH_IS_IPV4_HDR(mbuf->packet_type)) {
-		/* Handle IPv4 headers.*/
-		ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf,
-				struct rte_ipv4_hdr *,
-				sizeof(struct rte_ether_hdr));
-
-		if (is_valid_ipv4_pkt(ipv4_hdr, mbuf->pkt_len)
-				< 0) {
-			mbuf->port = BAD_PORT;
-			continue;
-		}
-		/* Update time to live and header checksum */
-		--(ipv4_hdr->time_to_live);
-		++(ipv4_hdr->hdr_checksum);
-	}
-#endif
+
 	/* dst addr */
 	*(uint64_t *)&eth_hdr->dst_addr = dest_eth_addr[mbuf->port];
 
 	/* src addr */
 	rte_ether_addr_copy(&ports_eth_addr[mbuf->port],
 			&eth_hdr->src_addr);
+
+	rfc1812_process(rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,
+						sizeof(struct rte_ether_hdr)),
+			&mbuf->port, mbuf->packet_type);
 #endif
 	return mbuf->port;
 }
-- 
2.30.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/1] examples/l3fwd: fix scalar LPM compilation
  2022-05-11 14:56 ` [PATCH v2 " Stanislaw Kardach
@ 2022-05-19 14:53   ` David Marchand
  2022-05-23 13:29     ` David Marchand
  0 siblings, 1 reply; 6+ messages in thread
From: David Marchand @ 2022-05-19 14:53 UTC (permalink / raw)
  To: Stanislaw Kardach
  Cc: dev, Frank Zhao, Sam Grove, Marcin Wojtas, upstream,
	Pavan Nikhilesh, Jerin Jacob Kollanukkaran, Konstantin Ananyev,
	Vladimir Medvedkin

On Wed, May 11, 2022 at 4:57 PM Stanislaw Kardach <kda@semihalf.com> wrote:
>
> The lpm_process_event_pkt() can either process a packet using an
> architecture specific (defined for X86/SSE, ARM/Neon and PPC64/Altivec)
> path or a scalar one. The choice is however done using an ifdef
> pre-processor macro. Because of that the scalar version was apparently
> not widely excersized/compiled.
> Due to some copy/paste errors, the scalar logic in
> lpm_process_event_pkt() retained a "continue" statement where it should
> utilize rfc1812_process() and return the port/BAD_PORT.
>
> Fixes: 99fc91d18082 ("examples/l3fwd: add event lpm main loop")
> Cc: pbhagavatula@marvell.com
>
> Signed-off-by: Stanislaw Kardach <kda@semihalf.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/1] examples/l3fwd: fix scalar LPM compilation
  2022-05-19 14:53   ` David Marchand
@ 2022-05-23 13:29     ` David Marchand
  0 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2022-05-23 13:29 UTC (permalink / raw)
  To: Stanislaw Kardach
  Cc: dev, Frank Zhao, Sam Grove, Marcin Wojtas, upstream,
	Pavan Nikhilesh, Jerin Jacob Kollanukkaran, Konstantin Ananyev,
	Vladimir Medvedkin

On Thu, May 19, 2022 at 4:53 PM David Marchand
<david.marchand@redhat.com> wrote:
> On Wed, May 11, 2022 at 4:57 PM Stanislaw Kardach <kda@semihalf.com> wrote:
> >
> > The lpm_process_event_pkt() can either process a packet using an
> > architecture specific (defined for X86/SSE, ARM/Neon and PPC64/Altivec)
> > path or a scalar one. The choice is however done using an ifdef
> > pre-processor macro. Because of that the scalar version was apparently
> > not widely excersized/compiled.
> > Due to some copy/paste errors, the scalar logic in
> > lpm_process_event_pkt() retained a "continue" statement where it should
> > utilize rfc1812_process() and return the port/BAD_PORT.
> >
> > Fixes: 99fc91d18082 ("examples/l3fwd: add event lpm main loop")
Cc: stable@dpdk.org

> >
> > Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>

Applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-23 13:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 11:58 [PATCH 1/1] examples/l3fwd: fix scalar LPM compilation Stanislaw Kardach
2022-05-11 11:38 ` David Marchand
2022-05-11 14:18   ` Stanisław Kardach
2022-05-11 14:56 ` [PATCH v2 " Stanislaw Kardach
2022-05-19 14:53   ` David Marchand
2022-05-23 13:29     ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).