Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jul 2016 15:44:46 GMT
From:      vincenzo@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r305831 - soc2016/vincenzo/head/sys/dev/netmap
Message-ID:  <201607081544.u68Fikd8008648@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vincenzo
Date: Fri Jul  8 15:44:45 2016
New Revision: 305831
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305831

Log:
   freebsd: ptnet_rx_eof: support VLAN decapsulation

Modified:
  soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c

Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c
==============================================================================
--- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c	Fri Jul  8 15:44:36 2016	(r305830)
+++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c	Fri Jul  8 15:44:45 2016	(r305831)
@@ -1495,6 +1495,22 @@
 	return 0;
 }
 
+/* This function should be shared with the virtio-net driver. */
+static void
+ptnet_vlan_tag_remove(struct mbuf *m)
+{
+	struct ether_vlan_header *evh;
+
+	evh = mtod(m, struct ether_vlan_header *);
+	m->m_pkthdr.ether_vtag = ntohs(evh->evl_tag);
+	m->m_flags |= M_VLANTAG;
+
+	/* Strip the 802.1Q header. */
+	bcopy((char *) evh, (char *) evh + ETHER_VLAN_ENCAP_LEN,
+	    ETHER_HDR_LEN - ETHER_TYPE_LEN);
+	m_adj(m, ETHER_VLAN_ENCAP_LEN);
+}
+
 static int
 ptnet_transmit(struct ifnet *ifp, struct mbuf *m)
 {
@@ -1733,6 +1749,21 @@
 		mhead->m_pkthdr.flowid = pq->kring_id;
 		M_HASHTYPE_SET(mhead, M_HASHTYPE_OPAQUE);
 
+		if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) {
+			struct ether_header *eh;
+
+			eh = mtod(mhead, struct ether_header *);
+			if (eh->ether_type == htons(ETHERTYPE_VLAN)) {
+				ptnet_vlan_tag_remove(mhead);
+				/*
+				 * With the 802.1Q header removed, update the
+				 * checksum starting location accordingly.
+				 */
+				if (vh->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM)
+					vh->csum_start -= ETHER_VLAN_ENCAP_LEN;
+			}
+		}
+
 		PTNET_Q_UNLOCK(pq);
 		(*ifp->if_input)(ifp, mhead);
 		PTNET_Q_LOCK(pq);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607081544.u68Fikd8008648>