aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2019-04-09 14:36:56 +0300
committerMatias Elo <matias.elo@nokia.com>2019-04-15 09:53:05 +0300
commit36009b1444af036c189046ee4edb50d13d861120 (patch)
treec74599ddc2b49a070930a1772b36d1946e8b6fd4
parent0178075e5e16e843034ac59ad4978e6a70ef86b5 (diff)
downloadodp-36009b1444af036c189046ee4edb50d13d861120.tar.gz
linux-gen: packet: print packet input flags
Print packet input flag names to improve readability of odp_packet_print() output. Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-and-tested-by: Matias Elo <matias.elo@nokia.com>
-rw-r--r--platform/linux-generic/odp_packet.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index f4c99ce15..be62557d5 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -1736,6 +1736,40 @@ int _odp_packet_cmp_data(odp_packet_t pkt, uint32_t offset,
* ********************************************************
*
*/
+static int packet_print_input_flags(odp_packet_hdr_t *hdr, char *str, int max)
+{
+ int len = 0;
+
+ if (hdr->p.input_flags.l2)
+ len += snprintf(&str[len], max - len, "l2 ");
+ if (hdr->p.input_flags.l3)
+ len += snprintf(&str[len], max - len, "l3 ");
+ if (hdr->p.input_flags.l4)
+ len += snprintf(&str[len], max - len, "l4 ");
+ if (hdr->p.input_flags.eth)
+ len += snprintf(&str[len], max - len, "eth ");
+ if (hdr->p.input_flags.vlan)
+ len += snprintf(&str[len], max - len, "vlan ");
+ if (hdr->p.input_flags.arp)
+ len += snprintf(&str[len], max - len, "arp ");
+ if (hdr->p.input_flags.ipv4)
+ len += snprintf(&str[len], max - len, "ipv4 ");
+ if (hdr->p.input_flags.ipv6)
+ len += snprintf(&str[len], max - len, "ipv6 ");
+ if (hdr->p.input_flags.ipsec)
+ len += snprintf(&str[len], max - len, "ipsec ");
+ if (hdr->p.input_flags.udp)
+ len += snprintf(&str[len], max - len, "udp ");
+ if (hdr->p.input_flags.tcp)
+ len += snprintf(&str[len], max - len, "tcp ");
+ if (hdr->p.input_flags.sctp)
+ len += snprintf(&str[len], max - len, "sctp ");
+ if (hdr->p.input_flags.icmp)
+ len += snprintf(&str[len], max - len, "icmp ");
+
+ return len;
+}
+
void odp_packet_print(odp_packet_t pkt)
{
odp_packet_seg_t seg;
@@ -1753,7 +1787,12 @@ void odp_packet_print(odp_packet_t pkt)
len += odp_buffer_snprint(&str[len], n - len, buf);
len += snprintf(&str[len], n - len, " input_flags 0x%" PRIx64 "\n",
hdr->p.input_flags.all);
- len += snprintf(&str[len], n - len, " flags 0x%" PRIx32 "\n",
+ if (hdr->p.input_flags.all) {
+ len += snprintf(&str[len], n - len, " ");
+ len += packet_print_input_flags(hdr, &str[len], n - len);
+ len += snprintf(&str[len], n - len, "\n");
+ }
+ len += snprintf(&str[len], n - len, " flags 0x%" PRIx32 "\n",
hdr->p.flags.all_flags);
len += snprintf(&str[len], n - len,
" l2_offset %" PRIu32 "\n", hdr->p.l2_offset);