The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split. However, it shows inner-ipv6 as inner-ipv4.
This patch fixes that by redefining rx_pkt_hdr_protos to hold the full ptypes, and the show and set commands therefore remain symmetrical. Fixes: 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split") Signed-off-by: Yuan Wang <yuanx.w...@intel.com> --- v5: - remove unrelated changes. v4: - redefine rx_pkt_hdr_protos to hold the full ptypes. - use single switch in get_ptype_str(). v3: - use RTE_PTYPE_*_MASK as masks. - refactor to use switch statement. v2: - add fixline. --- app/test-pmd/cmdline.c | 6 +- app/test-pmd/config.c | 140 +++++++++++++++++++++-------------------- app/test-pmd/testpmd.c | 4 +- 3 files changed, 77 insertions(+), 73 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 8dc60e9388..8ffd62cac9 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -3445,18 +3445,14 @@ parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items, unsigned int nb_item; char *cur; char *tmp; - unsigned int cur_item, prev_items = 0; nb_item = 0; char *str2 = strdup(str); cur = strtok_r(str2, ",", &tmp); while (cur != NULL) { - cur_item = get_ptype(cur); - cur_item &= ~prev_items; - parsed_items[nb_item] = cur_item; + parsed_items[nb_item] = get_ptype(cur); cur = strtok_r(NULL, ",", &tmp); nb_item++; - prev_items |= cur_item; } if (nb_item > max_items) fprintf(stderr, "Number of %s = %u > %u (maximum items)\n", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index e8a1b77c2a..84ebada8fd 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -5070,73 +5070,79 @@ show_rx_pkt_segments(void) static const char *get_ptype_str(uint32_t ptype) { - if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) == - (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) - return "ipv4-tcp"; - else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) == - (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) - return "ipv4-udp"; - else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) == - (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) - return "ipv4-sctp"; - else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) == - (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) - return "ipv6-tcp"; - else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) == - (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) - return "ipv6-udp"; - else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) == - (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) - return "ipv6-sctp"; - else if ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) - return "tcp"; - else if ((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) - return "udp"; - else if ((ptype & RTE_PTYPE_L4_SCTP) == RTE_PTYPE_L4_SCTP) - return "sctp"; - else if ((ptype & RTE_PTYPE_L3_IPV4_EXT_UNKNOWN) == RTE_PTYPE_L3_IPV4_EXT_UNKNOWN) - return "ipv4"; - else if ((ptype & RTE_PTYPE_L3_IPV6_EXT_UNKNOWN) == RTE_PTYPE_L3_IPV6_EXT_UNKNOWN) - return "ipv6"; - else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER) - return "eth"; - - else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) == - (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) - return "inner-ipv4-tcp"; - else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) == - (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) - return "inner-ipv4-udp"; - else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) == - (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) - return "inner-ipv4-sctp"; - else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) == - (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) - return "inner-ipv6-tcp"; - else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) == - (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) - return "inner-ipv6-udp"; - else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) == - (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) - return "inner-ipv6-sctp"; - else if ((ptype & RTE_PTYPE_INNER_L4_TCP) == RTE_PTYPE_INNER_L4_TCP) - return "inner-tcp"; - else if ((ptype & RTE_PTYPE_INNER_L4_UDP) == RTE_PTYPE_INNER_L4_UDP) - return "inner-udp"; - else if ((ptype & RTE_PTYPE_INNER_L4_SCTP) == RTE_PTYPE_INNER_L4_SCTP) - return "inner-sctp"; - else if ((ptype & RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN) == - RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN) - return "inner-ipv4"; - else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) == - RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN) - return "inner-ipv6"; - else if ((ptype & RTE_PTYPE_INNER_L2_ETHER) == RTE_PTYPE_INNER_L2_ETHER) - return "inner-eth"; - else if ((ptype & RTE_PTYPE_TUNNEL_GRENAT) == RTE_PTYPE_TUNNEL_GRENAT) - return "grenat"; - else - return "unsupported"; + const char *str; + + switch (ptype) { + case RTE_PTYPE_L2_ETHER: + str = "eth"; + break; + case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN: + str = "ipv4"; + break; + case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN: + str = "ipv6"; + break; + case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP: + str = "ipv4-tcp"; + break; + case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP: + str = "ipv4-udp"; + break; + case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP: + str = "ipv4-sctp"; + break; + case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP: + str = "ipv6-tcp"; + break; + case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP: + str = "ipv6-udp"; + break; + case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP: + str = "ipv6-sctp"; + break; + case RTE_PTYPE_TUNNEL_GRENAT: + str = "grenat"; + break; + case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER: + str = "inner-eth"; + break; + case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER + | RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN: + str = "inner-ipv4"; + break; + case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER + | RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN: + str = "inner-ipv6"; + break; + case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP: + str = "inner-ipv4-tcp"; + break; + case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP: + str = "inner-ipv4-udp"; + break; + case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP: + str = "inner-ipv4-sctp"; + break; + case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP: + str = "inner-ipv6-tcp"; + break; + case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP: + str = "inner-ipv6-udp"; + break; + case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP: + str = "inner-ipv6-sctp"; + break; + default: + str = "unsupported"; + } + + return str; } void diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index aa7ea29f15..401ac8b280 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2654,6 +2654,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, { union rte_eth_rxseg rx_useg[MAX_SEGS_BUFFER_SPLIT] = {}; unsigned int i, mp_n; + uint32_t prev_hdrs = 0; int ret; if (rx_pkt_nb_segs <= 1 || @@ -2679,7 +2680,8 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, rx_pkt_seg_offsets[i] : 0; rx_seg->mp = mpx ? mpx : mp; if (rx_pkt_hdr_protos[i] != 0 && rx_pkt_seg_lengths[i] == 0) { - rx_seg->proto_hdr = rx_pkt_hdr_protos[i]; + rx_seg->proto_hdr = rx_pkt_hdr_protos[i] & ~prev_hdrs; + prev_hdrs |= rx_seg->proto_hdr; } else { rx_seg->length = rx_pkt_seg_lengths[i] ? rx_pkt_seg_lengths[i] : -- 2.25.1