* [dpdk-dev] [PATCH] examples/performance-thread: fix size of destination port ids in l3fwd-thread
@ 2016-04-20 14:45 Tomasz Kulasek
2016-04-27 15:25 ` Thomas Monjalon
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Tomasz Kulasek @ 2016-04-20 14:45 UTC (permalink / raw)
To: dev; +Cc: ian.betts, yuan.peng
After extending IPv4 next hop in lpm library, size of dst_port array was
changed from 16 to 32 bits in l3fwd-thread example, without modification
of the rest of path written for 16 bit value.
This patch uses similar approach for fix, like in commit 8353a36a9b4b
("examples/l3fwd: fix size of destination port ids"), restoring 16 bit size
for destination port ids and doing necessary conversion from 32 to 16 bit
after lpm_lookupx4.
Also fixes wrong logic in get_dst_port() on lpm path causing unpredictable
return value when ipv4/ipv6 lookup success, introduced in the same patch.
Fixes: dc81ebbacaeb ("lpm: extend IPv4 next hop field")
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
examples/performance-thread/l3fwd-thread/main.c | 45 ++++++++++++-----------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index 15c0a4d..6588c0c 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -1307,7 +1307,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid)
* to BAD_PORT value.
*/
static inline __attribute__((always_inline)) void
-rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint32_t *dp, uint32_t ptype)
+rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype)
{
uint8_t ihl;
@@ -1326,7 +1326,7 @@ rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint32_t *dp, uint32_t ptype)
}
#else
-#define rfc1812_process(mb, dp) do { } while (0)
+#define rfc1812_process(mb, dp, ptype) do { } while (0)
#endif /* DO_RFC_1812_CHECKS */
#endif /* APP_LOOKUP_LPM && ENABLE_MULTI_BUFFER_OPTIMIZE */
@@ -1343,28 +1343,27 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid)
struct ether_hdr *eth_hdr;
if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) {
- if (rte_lpm_lookup(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct,
- dst_ipv4, &next_hop_ipv4) != 0) {
- next_hop_ipv4 = portid;
- return next_hop_ipv4;
- }
+ return (uint16_t) ((rte_lpm_lookup(
+ RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, dst_ipv4,
+ &next_hop_ipv4) == 0) ? next_hop_ipv4 : portid);
+
} else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) {
+
eth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);
ipv6_hdr = (struct ipv6_hdr *)(eth_hdr + 1);
- if (rte_lpm6_lookup(RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct,
- ipv6_hdr->dst_addr, &next_hop_ipv6) != 0) {
- next_hop_ipv6 = portid;
- return next_hop_ipv6;
- }
- } else {
- next_hop_ipv4 = portid;
- return next_hop_ipv4;
+
+ return (uint16_t) ((rte_lpm6_lookup(
+ RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct,
+ ipv6_hdr->dst_addr, &next_hop_ipv6) == 0) ? next_hop_ipv6 :
+ portid);
+
}
+ return portid;
}
static inline void
-process_packet(struct rte_mbuf *pkt, uint32_t *dst_port, uint8_t portid)
+process_packet(struct rte_mbuf *pkt, uint16_t *dst_port, uint8_t portid)
{
struct ether_hdr *eth_hdr;
struct ipv4_hdr *ipv4_hdr;
@@ -1431,9 +1430,9 @@ processx4_step1(struct rte_mbuf *pkt[FWDSTEP],
static inline void
processx4_step2(__m128i dip,
uint32_t ipv4_flag,
- uint32_t portid,
+ uint8_t portid,
struct rte_mbuf *pkt[FWDSTEP],
- uint32_t dprt[FWDSTEP])
+ uint16_t dprt[FWDSTEP])
{
rte_xmm_t dst;
const __m128i bswap_mask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11,
@@ -1445,7 +1444,11 @@ processx4_step2(__m128i dip,
/* if all 4 packets are IPV4. */
if (likely(ipv4_flag)) {
rte_lpm_lookupx4(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, dip,
- dprt, portid);
+ dst.u32, portid);
+
+ /* get rid of unused upper 16 bit for each dport. */
+ dst.x = _mm_packs_epi32(dst.x, dst.x);
+ *(uint64_t *)dprt = dst.u64[0];
} else {
dst.x = dip;
dprt[0] = get_dst_port(pkt[0], dst.u32[0], portid);
@@ -1460,7 +1463,7 @@ processx4_step2(__m128i dip,
* Perform RFC1812 checks and updates for IPV4 packets.
*/
static inline void
-processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint32_t dst_port[FWDSTEP])
+processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP])
{
__m128i te[FWDSTEP];
__m128i ve[FWDSTEP];
@@ -1679,7 +1682,7 @@ process_burst(struct rte_mbuf *pkts_burst[MAX_PKT_BURST], int nb_rx,
int32_t k;
uint16_t dlp;
uint16_t *lp;
- uint32_t dst_port[MAX_PKT_BURST];
+ uint16_t dst_port[MAX_PKT_BURST];
__m128i dip[MAX_PKT_BURST / FWDSTEP];
uint32_t ipv4_flag[MAX_PKT_BURST / FWDSTEP];
uint16_t pnum[MAX_PKT_BURST + 1];
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] examples/performance-thread: fix size of destination port ids in l3fwd-thread
2016-04-20 14:45 [dpdk-dev] [PATCH] examples/performance-thread: fix size of destination port ids in l3fwd-thread Tomasz Kulasek
@ 2016-04-27 15:25 ` Thomas Monjalon
2016-04-29 16:30 ` [dpdk-dev] [PATCH v2] " Tomasz Kulasek
2016-04-29 16:30 ` [dpdk-dev] [PATCH v2] examples/performance-thread: fix logic in get_dst_port of l3fwd-thread Tomasz Kulasek
2 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2016-04-27 15:25 UTC (permalink / raw)
To: Tomasz Kulasek; +Cc: dev, ian.betts, yuan.peng
2016-04-20 16:45, Tomasz Kulasek:
> This patch uses similar approach for fix, like in commit 8353a36a9b4b
> ("examples/l3fwd: fix size of destination port ids"), restoring 16 bit size
> for destination port ids and doing necessary conversion from 32 to 16 bit
> after lpm_lookupx4.
>
> Also fixes wrong logic in get_dst_port() on lpm path causing unpredictable
> return value when ipv4/ipv6 lookup success, introduced in the same patch.
The word "Also" means that you should write 2 patches :)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] examples/performance-thread: fix size of destination port ids in l3fwd-thread
2016-04-20 14:45 [dpdk-dev] [PATCH] examples/performance-thread: fix size of destination port ids in l3fwd-thread Tomasz Kulasek
2016-04-27 15:25 ` Thomas Monjalon
@ 2016-04-29 16:30 ` Tomasz Kulasek
2016-06-08 20:25 ` Thomas Monjalon
2016-04-29 16:30 ` [dpdk-dev] [PATCH v2] examples/performance-thread: fix logic in get_dst_port of l3fwd-thread Tomasz Kulasek
2 siblings, 1 reply; 6+ messages in thread
From: Tomasz Kulasek @ 2016-04-29 16:30 UTC (permalink / raw)
To: ian.betts; +Cc: dev
After extending IPv4 next hop in lpm library, size of dst_port array was
changed from 16 to 32 bits in l3fwd-thread example, without modification
of the rest of path written for 16 bit value.
This patch uses similar approach for fix, like in commit 8353a36a9b4b
("examples/l3fwd: fix size of destination port ids"), restoring 16 bit size
for destination port ids and doing necessary conversion from 32 to 16 bit
after lpm_lookupx4.
Fixes: dc81ebbacaeb ("lpm: extend IPv4 next hop field")
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
v2:
- split into two patches
examples/performance-thread/l3fwd-thread/main.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index 4ad16ea..c008d6a 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -1307,7 +1307,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid)
* to BAD_PORT value.
*/
static inline __attribute__((always_inline)) void
-rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint32_t *dp, uint32_t ptype)
+rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype)
{
uint8_t ihl;
@@ -1326,7 +1326,7 @@ rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint32_t *dp, uint32_t ptype)
}
#else
-#define rfc1812_process(mb, dp) do { } while (0)
+#define rfc1812_process(mb, dp, ptype) do { } while (0)
#endif /* DO_RFC_1812_CHECKS */
#endif /* APP_LOOKUP_LPM && ENABLE_MULTI_BUFFER_OPTIMIZE */
@@ -1364,7 +1364,7 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid)
}
static inline void
-process_packet(struct rte_mbuf *pkt, uint32_t *dst_port, uint8_t portid)
+process_packet(struct rte_mbuf *pkt, uint16_t *dst_port, uint8_t portid)
{
struct ether_hdr *eth_hdr;
struct ipv4_hdr *ipv4_hdr;
@@ -1431,9 +1431,9 @@ processx4_step1(struct rte_mbuf *pkt[FWDSTEP],
static inline void
processx4_step2(__m128i dip,
uint32_t ipv4_flag,
- uint32_t portid,
+ uint8_t portid,
struct rte_mbuf *pkt[FWDSTEP],
- uint32_t dprt[FWDSTEP])
+ uint16_t dprt[FWDSTEP])
{
rte_xmm_t dst;
const __m128i bswap_mask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11,
@@ -1445,7 +1445,11 @@ processx4_step2(__m128i dip,
/* if all 4 packets are IPV4. */
if (likely(ipv4_flag)) {
rte_lpm_lookupx4(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, dip,
- dprt, portid);
+ dst.u32, portid);
+
+ /* get rid of unused upper 16 bit for each dport. */
+ dst.x = _mm_packs_epi32(dst.x, dst.x);
+ *(uint64_t *)dprt = dst.u64[0];
} else {
dst.x = dip;
dprt[0] = get_dst_port(pkt[0], dst.u32[0], portid);
@@ -1460,7 +1464,7 @@ processx4_step2(__m128i dip,
* Perform RFC1812 checks and updates for IPV4 packets.
*/
static inline void
-processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint32_t dst_port[FWDSTEP])
+processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP])
{
__m128i te[FWDSTEP];
__m128i ve[FWDSTEP];
@@ -1679,7 +1683,7 @@ process_burst(struct rte_mbuf *pkts_burst[MAX_PKT_BURST], int nb_rx,
int32_t k;
uint16_t dlp;
uint16_t *lp;
- uint32_t dst_port[MAX_PKT_BURST];
+ uint16_t dst_port[MAX_PKT_BURST];
__m128i dip[MAX_PKT_BURST / FWDSTEP];
uint32_t ipv4_flag[MAX_PKT_BURST / FWDSTEP];
uint16_t pnum[MAX_PKT_BURST + 1];
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] examples/performance-thread: fix size of destination port ids in l3fwd-thread
2016-04-29 16:30 ` [dpdk-dev] [PATCH v2] " Tomasz Kulasek
@ 2016-06-08 20:25 ` Thomas Monjalon
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2016-06-08 20:25 UTC (permalink / raw)
To: Tomasz Kulasek; +Cc: dev, ian.betts
2016-04-29 18:30, Tomasz Kulasek:
> After extending IPv4 next hop in lpm library, size of dst_port array was
> changed from 16 to 32 bits in l3fwd-thread example, without modification
> of the rest of path written for 16 bit value.
>
> This patch uses similar approach for fix, like in commit 8353a36a9b4b
> ("examples/l3fwd: fix size of destination port ids"), restoring 16 bit size
> for destination port ids and doing necessary conversion from 32 to 16 bit
> after lpm_lookupx4.
>
> Fixes: dc81ebbacaeb ("lpm: extend IPv4 next hop field")
>
> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] examples/performance-thread: fix logic in get_dst_port of l3fwd-thread
2016-04-20 14:45 [dpdk-dev] [PATCH] examples/performance-thread: fix size of destination port ids in l3fwd-thread Tomasz Kulasek
2016-04-27 15:25 ` Thomas Monjalon
2016-04-29 16:30 ` [dpdk-dev] [PATCH v2] " Tomasz Kulasek
@ 2016-04-29 16:30 ` Tomasz Kulasek
2016-06-08 20:25 ` Thomas Monjalon
2 siblings, 1 reply; 6+ messages in thread
From: Tomasz Kulasek @ 2016-04-29 16:30 UTC (permalink / raw)
To: ian.betts; +Cc: dev
This fixes wrong logic in get_dst_port() on lpm path causing unpredictable
return value when ipv4/ipv6 lookup success (return with no value).
Fixes: dc81ebbacaeb ("lpm: extend IPv4 next hop field")
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
v2:
- split into two patches
examples/performance-thread/l3fwd-thread/main.c | 25 +++++++++++------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index c008d6a..7d90a16 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -1343,24 +1343,23 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid)
struct ether_hdr *eth_hdr;
if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) {
- if (rte_lpm_lookup(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct,
- dst_ipv4, &next_hop_ipv4) != 0) {
- next_hop_ipv4 = portid;
- return next_hop_ipv4;
- }
+ return (uint16_t) ((rte_lpm_lookup(
+ RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, dst_ipv4,
+ &next_hop_ipv4) == 0) ? next_hop_ipv4 : portid);
+
} else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) {
+
eth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);
ipv6_hdr = (struct ipv6_hdr *)(eth_hdr + 1);
- if (rte_lpm6_lookup(RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct,
- ipv6_hdr->dst_addr, &next_hop_ipv6) != 0) {
- next_hop_ipv6 = portid;
- return next_hop_ipv6;
- }
- } else {
- next_hop_ipv4 = portid;
- return next_hop_ipv4;
+
+ return (uint16_t) ((rte_lpm6_lookup(
+ RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct,
+ ipv6_hdr->dst_addr, &next_hop_ipv6) == 0) ? next_hop_ipv6 :
+ portid);
+
}
+ return portid;
}
static inline void
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-06-08 20:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-20 14:45 [dpdk-dev] [PATCH] examples/performance-thread: fix size of destination port ids in l3fwd-thread Tomasz Kulasek
2016-04-27 15:25 ` Thomas Monjalon
2016-04-29 16:30 ` [dpdk-dev] [PATCH v2] " Tomasz Kulasek
2016-06-08 20:25 ` Thomas Monjalon
2016-04-29 16:30 ` [dpdk-dev] [PATCH v2] examples/performance-thread: fix logic in get_dst_port of l3fwd-thread Tomasz Kulasek
2016-06-08 20:25 ` Thomas Monjalon
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).