net/af_packet: support 802.1Q VLAN
authorChas Williams <ciwillia@brocade.com>
Thu, 5 Jan 2017 13:53:44 +0000 (08:53 -0500)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:41:43 +0000 (19:41 +0100)
AF_PACKET has some flags to check on the receive side for 802.1Q
information.  If present, we copy into the mbuf.  For transmit, we
insert any 802.1Q information into the packet before copying to the ring.

Signed-off-by: Chas Williams <ciwillia@brocade.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/af_packet/rte_eth_af_packet.c

index 5715dcb..2f87553 100644 (file)
@@ -161,6 +161,12 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                pbuf = (uint8_t *) ppd + ppd->tp_mac;
                memcpy(rte_pktmbuf_mtod(mbuf, void *), pbuf, rte_pktmbuf_data_len(mbuf));
 
+               /* check for vlan info */
+               if (ppd->tp_status & TP_STATUS_VLAN_VALID) {
+                       mbuf->vlan_tci = ppd->tp_vlan_tci;
+                       mbuf->ol_flags |= (PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED);
+               }
+
                /* release incoming frame and advance ring buffer */
                ppd->tp_status = TP_STATUS_KERNEL;
                if (++framenum >= framecount)
@@ -214,6 +220,14 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                        continue;
                }
 
+               /* insert vlan info if necessary */
+               if (mbuf->ol_flags & PKT_TX_VLAN_PKT) {
+                       if (rte_vlan_insert(&mbuf)) {
+                               rte_pktmbuf_free(mbuf);
+                               continue;
+                       }
+               }
+
                /* point at the next incoming frame */
                if ((ppd->tp_status != TP_STATUS_AVAILABLE) &&
                    (poll(&pfd, 1, -1) < 0))