app/testpmd: add qinq stripping and insertion
[dpdk.git] / app / test-pmd / rxonly.c
index ac56090..4a9f86e 100644 (file)
@@ -160,6 +160,9 @@ pkt_burst_receive(struct fwd_stream *fs)
                }
                if (ol_flags & PKT_RX_VLAN_PKT)
                        printf(" - VLAN tci=0x%x", mb->vlan_tci);
+               if (ol_flags & PKT_RX_QINQ_PKT)
+                       printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
+                                       mb->vlan_tci, mb->vlan_tci_outer);
                if (is_encapsulation) {
                        struct ipv4_hdr *ipv4_hdr;
                        struct ipv6_hdr *ipv6_hdr;
@@ -175,22 +178,25 @@ pkt_burst_receive(struct fwd_stream *fs)
                         /* Do not support ipv4 option field */
                        if (ol_flags & PKT_RX_TUNNEL_IPV4_HDR) {
                                l3_len = sizeof(struct ipv4_hdr);
-                               ipv4_hdr = (struct ipv4_hdr *) (rte_pktmbuf_mtod(mb,
-                                               unsigned char *) + l2_len);
+                               ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
+                                                                  struct ipv4_hdr *,
+                                                                  l2_len);
                                l4_proto = ipv4_hdr->next_proto_id;
                        } else {
                                l3_len = sizeof(struct ipv6_hdr);
-                               ipv6_hdr = (struct ipv6_hdr *) (rte_pktmbuf_mtod(mb,
-                                               unsigned char *) + l2_len);
+                               ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
+                                                                  struct ipv6_hdr *,
+                                                                  l2_len);
                                l4_proto = ipv6_hdr->proto;
                        }
                        if (l4_proto == IPPROTO_UDP) {
-                               udp_hdr = (struct udp_hdr *) (rte_pktmbuf_mtod(mb,
-                                               unsigned char *) + l2_len + l3_len);
+                               udp_hdr = rte_pktmbuf_mtod_offset(mb,
+                                                                 struct udp_hdr *,
+                                                                 l2_len + l3_len);
                                l4_len = sizeof(struct udp_hdr);
-                               vxlan_hdr = (struct vxlan_hdr *) (rte_pktmbuf_mtod(mb,
-                                               unsigned char *) + l2_len + l3_len
-                                                + l4_len);
+                               vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
+                                                                   struct vxlan_hdr *,
+                                                                   l2_len + l3_len + l4_len);
 
                                printf(" - VXLAN packet: packet type =%d, "
                                        "Destination UDP port =%d, VNI = %d",