[dpdk-dev] [PATCH v3 4/4] testpmd:rework csum forward engine

2014-11-28 Thread Jijiang Liu
The changes include:
1. use the new introduced ol_flags and fields in csumonly.c file;
2. fix an issue of outer UDP checksum check; 
3. change process logic in the process_inner_cksums();

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |   65 ++
 1 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d8c080a..f7ad3d8 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -189,11 +189,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, 
uint16_t l3_len,
} else {
if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)
ol_flags |= PKT_TX_IP_CKSUM;
-   else
+   else {
ipv4_hdr->hdr_checksum =
rte_ipv4_cksum(ipv4_hdr);
+   ol_flags |= PKT_TX_IPV4;
+   }
}
-   ol_flags |= PKT_TX_IPV4;
} else if (ethertype == _htons(ETHER_TYPE_IPv6))
ol_flags |= PKT_TX_IPV6;
else
@@ -257,27 +258,28 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
uint64_t ol_flags = 0;

if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
-   ol_flags |= PKT_TX_VXLAN_CKSUM;
+   ol_flags |= PKT_TX_UDP_TUNNEL_PKT;

if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
ipv4_hdr->hdr_checksum = 0;

-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0)
+   if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
+   ol_flags |= PKT_TX_OUTER_IP_CKSUM;
+   else
ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr);
-   }
+   } else if (outer_ethertype == _htons(ETHER_TYPE_IPv6))
+   ol_flags |= PKT_TX_OUTER_IPV6;

udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len);
/* do not recalculate udp cksum if it was 0 */
if (udp_hdr->dgram_cksum != 0) {
udp_hdr->dgram_cksum = 0;
-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0) {
-   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
-   udp_hdr->dgram_cksum =
-   rte_ipv4_udptcp_cksum(ipv4_hdr, 
udp_hdr);
-   else
-   udp_hdr->dgram_cksum =
-   rte_ipv6_udptcp_cksum(ipv6_hdr, 
udp_hdr);
-   }
+   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
+   udp_hdr->dgram_cksum =
+   rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr);
+   else
+   udp_hdr->dgram_cksum =
+   rte_ipv6_udptcp_cksum(ipv6_hdr, udp_hdr);
}

return ol_flags;
@@ -303,7 +305,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
  * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control
  * wether a checksum must be calculated in software or in hardware. The
  * IP, UDP, TCP and SCTP flags always concern the inner layer.  The
- * VxLAN flag concerns the outer IP and UDP layer (if packet is
+ * VxLAN flag concerns the outer IP(if packet is
  * recognized as a vxlan packet).
  */
 static void
@@ -320,7 +322,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint16_t i;
uint64_t ol_flags;
uint16_t testpmd_ol_flags;
-   uint8_t l4_proto;
+   uint8_t l4_proto, l4_tun_len = 0;
uint16_t ethertype = 0, outer_ethertype = 0;
uint16_t l2_len = 0, l3_len = 0, l4_len = 0;
uint16_t outer_l2_len = 0, outer_l3_len = 0;
@@ -360,6 +362,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)

ol_flags = 0;
tunnel = 0;
+   l4_tun_len = 0;
m = pkts_burst[i];

/* Update the L3/L4 checksum error packet statistics */
@@ -377,15 +380,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
/* check if it's a supported tunnel (only vxlan for now) */
if (l4_proto == IPPROTO_UDP) {
udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len);
+
+   /* check udp destination port, 4789 is the default
+* vxlan port (rfc7348) */
+   if (udp_hdr->dst_port == _htons(4789)) {
+   l4_tun_len = ETHER_VXLAN_HLEN;
+   tunnel = 1;

/* currently, this flag is set by i40e only if the
 * packet is vxlan */
-   if (((m->ol_flags & PKT_RX_TUNNEL_IPV4_HDR) ||
-   (m->ol_flags &

[dpdk-dev] [PATCH v3 4/4] testpmd:rework csum forward engine

2014-11-28 Thread Olivier MATZ
Hi Jijiang,

On 11/27/2014 06:03 PM, Jijiang Liu wrote:
> @@ -303,7 +305,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
> outer_ethertype,
>   * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control
>   * wether a checksum must be calculated in software or in hardware. The
>   * IP, UDP, TCP and SCTP flags always concern the inner layer.  The
> - * VxLAN flag concerns the outer IP and UDP layer (if packet is
> + * VxLAN flag concerns the outer IP(if packet is
>   * recognized as a vxlan packet).
>   */

Please reindent the comment properly, taking care of the space before
the parenthesis.

Another comment that concerns the whole patchset. It's maybe a question
for Thomas, but I think that having patches that don't break compilation
between each other would help when bissecting.

In this case, I wonder if it's possible to split in something like:

- change PKT_TX_IPV4 and PKT_TX_IPV6 definition
- add + rename flags (update them in mbuf + testpmd + i40)
- rename inner_l{23}, l{23} in l{23}, outer_l{23} (update them in mbuf
  + testpmd + i40)

I'm not sure it's feasible, I let Thomas give his mind about this.

Regards,
Olivier


[dpdk-dev] [PATCH v3 4/4] testpmd:rework csum forward engine

2014-11-28 Thread Thomas Monjalon
2014-11-28 10:50, Olivier MATZ:
> Hi Jijiang,
> 
> On 11/27/2014 06:03 PM, Jijiang Liu wrote:
> > @@ -303,7 +305,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
> > outer_ethertype,
> >   * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control
> >   * wether a checksum must be calculated in software or in hardware. The
> >   * IP, UDP, TCP and SCTP flags always concern the inner layer.  The
> > - * VxLAN flag concerns the outer IP and UDP layer (if packet is
> > + * VxLAN flag concerns the outer IP(if packet is
> >   * recognized as a vxlan packet).
> >   */
> 
> Please reindent the comment properly, taking care of the space before
> the parenthesis.
> 
> Another comment that concerns the whole patchset. It's maybe a question
> for Thomas, but I think that having patches that don't break compilation
> between each other would help when bissecting.
> 
> In this case, I wonder if it's possible to split in something like:
> 
> - change PKT_TX_IPV4 and PKT_TX_IPV6 definition
> - add + rename flags (update them in mbuf + testpmd + i40)
> - rename inner_l{23}, l{23} in l{23}, outer_l{23} (update them in mbuf
>   + testpmd + i40)
> 
> I'm not sure it's feasible, I let Thomas give his mind about this.

Exact, compilation must not be broken between patches.
The proposal from Olivier seems OK.

-- 
Thomas