X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Fcsumonly.c;h=950ea82a1d351507d23d505d3ced37fdab43350b;hb=f3618dcbcff8ae6b2eabf982f4c4fbbc3dd66703;hp=bee652a9be73bd2f000e6fb6ea88853e2d35a9c3;hpb=9075b0f1ce764f3c998971eb987ddeeb852d423c;p=dpdk.git diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index bee652a9be..950ea82a1d 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -79,6 +78,10 @@ #define IP_HDRLEN 0x05 /* default IP header length == five 32-bits words. */ #define IP_VHL_DEF (IP_VERSION | IP_HDRLEN) +#define GRE_KEY_PRESENT 0x2000 +#define GRE_KEY_LEN 4 +#define GRE_SUPPORTED_FIELDS GRE_KEY_PRESENT + /* We cannot use rte_cpu_to_be_16() on a constant in a switch/case */ #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN #define _htons(x) ((uint16_t)((((x) & 0x00ffU) << 8) | (((x) & 0xff00U) >> 8))) @@ -101,7 +104,7 @@ struct testpmd_offload_info { uint16_t tso_segsz; }; -/* simplified GRE header (flags must be 0) */ +/* simplified GRE header */ struct simple_gre_hdr { uint16_t flags; uint16_t proto; @@ -233,11 +236,17 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) struct ether_hdr *eth_hdr; struct ipv4_hdr *ipv4_hdr; struct ipv6_hdr *ipv6_hdr; + uint8_t gre_len = 0; - /* if flags != 0; it's not supported */ - if (gre_hdr->flags != 0) + /* check which fields are supported */ + if ((gre_hdr->flags & _htons(~GRE_SUPPORTED_FIELDS)) != 0) return; + gre_len += sizeof(struct simple_gre_hdr); + + if (gre_hdr->flags & _htons(GRE_KEY_PRESENT)) + gre_len += GRE_KEY_LEN; + if (gre_hdr->proto == _htons(ETHER_TYPE_IPv4)) { info->is_tunnel = 1; info->outer_ethertype = info->ethertype; @@ -245,8 +254,7 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->outer_l3_len = info->l3_len; info->outer_l4_proto = info->l4_proto; - ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr + - sizeof(struct simple_gre_hdr)); + ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr + gre_len); parse_ipv4(ipv4_hdr, info); info->ethertype = _htons(ETHER_TYPE_IPv4); @@ -259,28 +267,26 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->outer_l3_len = info->l3_len; info->outer_l4_proto = info->l4_proto; - ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr + - sizeof(struct simple_gre_hdr)); + ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr + gre_len); info->ethertype = _htons(ETHER_TYPE_IPv6); parse_ipv6(ipv6_hdr, info); info->l2_len = 0; - } else if (gre_hdr->proto == _htons(0x6558)) { /* ETH_P_TEB in linux */ + } else if (gre_hdr->proto == _htons(ETHER_TYPE_TEB)) { info->is_tunnel = 1; info->outer_ethertype = info->ethertype; info->outer_l2_len = info->l2_len; info->outer_l3_len = info->l3_len; info->outer_l4_proto = info->l4_proto; - eth_hdr = (struct ether_hdr *)((char *)gre_hdr + - sizeof(struct simple_gre_hdr)); + eth_hdr = (struct ether_hdr *)((char *)gre_hdr + gre_len); parse_ethernet(eth_hdr, info); } else return; - info->l2_len += sizeof(struct simple_gre_hdr); + info->l2_len += gre_len; } @@ -593,6 +599,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) m->outer_l3_len = info.outer_l3_len; m->l2_len = info.l2_len; m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } else { /* if there is a outer UDP cksum @@ -699,4 +706,3 @@ struct fwd_engine csum_fwd_engine = { .port_fwd_end = NULL, .packet_fwd = pkt_burst_checksum_forward, }; -