summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaddy <naddy@openbsd.org>2008-09-18 15:16:30 +0000
committernaddy <naddy@openbsd.org>2008-09-18 15:16:30 +0000
commit813a735f41a385058bf2de685b40100e238d480e (patch)
tree62316a0fa334da64ee378e3b5d8a30449734acd9
parentRework the drm locking to be at least halfway sane. The freebsd code (diff)
downloadwireguard-openbsd-813a735f41a385058bf2de685b40100e238d480e.tar.xz
wireguard-openbsd-813a735f41a385058bf2de685b40100e238d480e.zip
Introduce the infrastructure required to support hardware VLAN tag
stripping: Add a field to the mbuf pkthdr to hold the tag and an mbuf flag that tells if the tag is valid. Inspired by FreeBSD. Struct packing suggested by kettenis@. csum_flags is now 16 bits. Adapt to this in the drivers. ok reyk@, henning@
-rw-r--r--share/man/man9/mbuf.910
-rw-r--r--sys/dev/ic/xl.c5
-rw-r--r--sys/dev/pci/if_bge.c4
-rw-r--r--sys/dev/pci/if_san_xilinx.c8
-rw-r--r--sys/dev/pci/if_ti.c4
-rw-r--r--sys/dev/pci/if_txp.c5
-rw-r--r--sys/sys/mbuf.h9
7 files changed, 28 insertions, 17 deletions
diff --git a/share/man/man9/mbuf.9 b/share/man/man9/mbuf.9
index e6b570fc03a..1dde48fa168 100644
--- a/share/man/man9/mbuf.9
+++ b/share/man/man9/mbuf.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mbuf.9,v 1.34 2008/09/15 17:16:14 naddy Exp $
+.\" $OpenBSD: mbuf.9,v 1.35 2008/09/18 15:16:30 naddy Exp $
.\"
.\" Copyright (c) 2001 Jean-Jacques Bernard-Gundol <jjbg@openbsd.org>
.\" All rights reserved.
@@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: September 15 2008 $
+.Dd $Mdocdate: September 18 2008 $
.Dt MBUF 9
.Os
.Sh NAME
@@ -116,7 +116,8 @@ struct pkthdr {
struct ifnet *rcvif;
SLIST_HEAD(packet_tags, m_tag) tags;
int len;
- int csum_flags;
+ u_int16_t csum_flags;
+ u_int16_t ether_vtag;
struct pkthdr_pf pf;
};
@@ -260,6 +261,9 @@ for mbuf statistics.
dropped by
.Xr bpf 4
filter.
+.It Dv M_VLANTAG
+.Fa m_pkthdr.ether_vtag
+variable is valid.
.El
.Pp
An external cluster is used when the data to hold in the mbuf is
diff --git a/sys/dev/ic/xl.c b/sys/dev/ic/xl.c
index 93426ee51a1..8f426de177d 100644
--- a/sys/dev/ic/xl.c
+++ b/sys/dev/ic/xl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xl.c,v 1.80 2008/09/10 14:01:22 blambert Exp $ */
+/* $OpenBSD: xl.c,v 1.81 2008/09/18 15:16:30 naddy Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -1184,8 +1184,9 @@ xl_rxeof(struct xl_softc *sc)
struct mbuf *m;
struct ifnet *ifp;
struct xl_chain_onefrag *cur_rx;
- int total_len = 0, sumflags = 0;
+ int total_len = 0;
u_int32_t rxstat;
+ u_int16_t sumflags = 0;
ifp = &sc->sc_arpcom.ac_if;
diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c
index 1c330c05fe9..943ddcce938 100644
--- a/sys/dev/pci/if_bge.c
+++ b/sys/dev/pci/if_bge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bge.c,v 1.243 2008/09/10 14:01:22 blambert Exp $ */
+/* $OpenBSD: if_bge.c,v 1.244 2008/09/18 15:16:30 naddy Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@@ -2449,7 +2449,7 @@ bge_rxeof(struct bge_softc *sc)
u_int32_t rxidx;
struct mbuf *m = NULL;
#ifdef BGE_CHECKSUM
- int sumflags = 0;
+ u_int16_t sumflags = 0;
#endif
cur_rx = &sc->bge_rdata->
diff --git a/sys/dev/pci/if_san_xilinx.c b/sys/dev/pci/if_san_xilinx.c
index 4a4f7e87665..bc0df31f743 100644
--- a/sys/dev/pci/if_san_xilinx.c
+++ b/sys/dev/pci/if_san_xilinx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_san_xilinx.c,v 1.22 2008/09/10 14:01:22 blambert Exp $ */
+/* $OpenBSD: if_san_xilinx.c,v 1.23 2008/09/18 15:16:30 naddy Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -1977,7 +1977,8 @@ xilinx_dma_tx_complete(sdla_t *card, xilinx_softc_t *sc)
}
sc->pci_retry = 0;
- sc->tx_dma_mbuf->m_pkthdr.csum_flags = reg;
+ sc->tx_dma_mbuf->m_pkthdr.csum_flags = reg & 0xFFFF;
+ sc->tx_dma_mbuf->m_pkthdr.ether_vtag = (reg >> 16) & 0xFFFF;
IF_ENQUEUE(&sc->wp_tx_complete_list, sc->tx_dma_mbuf);
sc->tx_dma_mbuf = NULL;
@@ -1990,9 +1991,10 @@ static void
xilinx_tx_post_complete(sdla_t *card, xilinx_softc_t *sc, struct mbuf *m)
{
struct ifnet *ifp;
- unsigned long reg = m->m_pkthdr.csum_flags;
+ u_int32_t reg;
WAN_ASSERT1(sc == NULL);
+ reg = (m->m_pkthdr.ether_vtag << 16) + m->m_pkthdr.csum_flags;
ifp = (struct ifnet *)&sc->common.ifp;
if ((bit_test((u_int8_t *)&reg, TxDMA_HI_DMA_GO_READY_BIT)) ||
(reg & TxDMA_HI_DMA_DATA_LENGTH_MASK) ||
diff --git a/sys/dev/pci/if_ti.c b/sys/dev/pci/if_ti.c
index 06fd41a89a0..c1abaa89262 100644
--- a/sys/dev/pci/if_ti.c
+++ b/sys/dev/pci/if_ti.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ti.c,v 1.85 2008/06/07 19:03:13 brad Exp $ */
+/* $OpenBSD: if_ti.c,v 1.86 2008/09/18 15:16:30 naddy Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -1767,7 +1767,7 @@ ti_rxeof(struct ti_softc *sc)
struct ti_rx_desc *cur_rx;
u_int32_t rxidx;
struct mbuf *m = NULL;
- int sumflags = 0;
+ u_int16_t sumflags = 0;
bus_dmamap_t dmamap;
cur_rx =
diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c
index 37beacde363..7642e8a1183 100644
--- a/sys/dev/pci/if_txp.c
+++ b/sys/dev/pci/if_txp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_txp.c,v 1.93 2008/09/10 14:01:23 blambert Exp $ */
+/* $OpenBSD: if_txp.c,v 1.94 2008/09/18 15:16:30 naddy Exp $ */
/*
* Copyright (c) 2001
@@ -609,7 +609,8 @@ txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r,
struct mbuf *m;
struct txp_swdesc *sd;
u_int32_t roff, woff;
- int sumflags = 0, idx;
+ int idx;
+ u_int16_t sumflags = 0;
roff = letoh32(*r->r_roff);
woff = letoh32(*r->r_woff);
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index a5bcd3d8b06..615dddaef67 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.103 2008/08/29 08:13:08 jmc Exp $ */
+/* $OpenBSD: mbuf.h,v 1.104 2008/09/18 15:16:30 naddy Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -96,7 +96,8 @@ struct pkthdr {
struct ifnet *rcvif; /* rcv interface */
SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */
int len; /* total packet length */
- int csum_flags; /* checksum flags */
+ u_int16_t csum_flags; /* checksum flags */
+ u_int16_t ether_vtag; /* Ethernet 802.1p+Q vlan tag */
struct pkthdr_pf pf;
};
@@ -159,12 +160,14 @@ struct mbuf {
#define M_TUNNEL 0x1000 /* IP-in-IP added by tunnel mode IPsec */
#define M_ANYCAST6 0x4000 /* received as IPv6 anycast */
#define M_LINK0 0x8000 /* link layer specific flag */
+#define M_VLANTAG 0x0020 /* ether_vtag is valid */
#define M_LOOP 0x0040 /* for Mbuf statistics */
#define M_FILDROP 0x0080 /* dropped by bpf filter */
/* flags copied when copying m_pkthdr */
#define M_COPYFLAGS (M_PKTHDR|M_EOR|M_PROTO1|M_BCAST|M_MCAST|M_CONF|\
- M_AUTH|M_ANYCAST6|M_LOOP|M_TUNNEL|M_LINK0|M_FILDROP)
+ M_AUTH|M_ANYCAST6|M_LOOP|M_TUNNEL|M_LINK0|M_VLANTAG|\
+ M_FILDROP)
/* Checksumming flags */
#define M_IPV4_CSUM_OUT 0x0001 /* IPv4 checksum needed */