summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2001-09-05 21:10:28 +0000
committerbrooks <brooks@FreeBSD.org>2001-09-05 21:10:28 +0000
commit7da2447808dd5233fae946a91d1cbc895d9ed346 (patch)
treedb9a1b36fca844efd89c94c81d0a7b9fb126f325 /sys/dev
parent06023d7a89677d7f21d97275f61ba4e8a4d4cf69 (diff)
downloadFreeBSD-src-7da2447808dd5233fae946a91d1cbc895d9ed346.zip
FreeBSD-src-7da2447808dd5233fae946a91d1cbc895d9ed346.tar.gz
Make vlan(4) loadable, unloadable, and clonable. As a side effect,
interfaces must now always enable VLAN support. Reviewed by: jlemon MFC after: 3 weeks
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/nge/if_nge.c28
-rw-r--r--sys/dev/ti/if_ti.c31
-rw-r--r--sys/dev/txp/if_txp.c21
3 files changed, 15 insertions, 65 deletions
diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c
index 0231087..7b8fc42 100644
--- a/sys/dev/nge/if_nge.c
+++ b/sys/dev/nge/if_nge.c
@@ -87,8 +87,6 @@
* if the user selects an MTU larger than 8152 (8170 - 18).
*/
-#include "vlan.h"
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
@@ -102,11 +100,8 @@
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
-
-#if NVLAN > 0
#include <net/if_types.h>
#include <net/if_vlan_var.h>
-#endif
#include <net/bpf.h>
@@ -1335,16 +1330,14 @@ static void nge_rxeof(sc)
m->m_pkthdr.csum_data = 0xffff;
}
-#if NVLAN > 0
/*
* If we received a packet with a vlan tag, pass it
* to vlan_input() instead of ether_input().
*/
if (extsts & NGE_RXEXTSTS_VLANPKT) {
- vlan_input_tag(eh, m, extsts & NGE_RXEXTSTS_VTCI);
+ VLAN_INPUT_TAG(ifp, eh, m, extsts & NGE_RXEXTSTS_VTCI);
continue;
}
-#endif
ether_input(ifp, eh, m);
}
@@ -1539,14 +1532,12 @@ static int nge_encap(sc, m_head, txidx)
struct nge_desc *f = NULL;
struct mbuf *m;
int frag, cur, cnt = 0;
-#if NVLAN > 0
struct ifvlan *ifv = NULL;
if ((m_head->m_flags & (M_PROTO1|M_PKTHDR)) == (M_PROTO1|M_PKTHDR) &&
m_head->m_pkthdr.rcvif != NULL &&
m_head->m_pkthdr.rcvif->if_type == IFT_L2VLAN)
ifv = m_head->m_pkthdr.rcvif->if_softc;
-#endif
/*
* Start packing the mbufs in this chain into
@@ -1588,12 +1579,10 @@ static int nge_encap(sc, m_head, txidx)
NGE_TXEXTSTS_UDPCSUM;
}
-#if NVLAN > 0
if (ifv != NULL) {
sc->nge_ldata->nge_tx_list[cur].nge_extsts |=
(NGE_TXEXTSTS_VLANPKT|ifv->ifv_tag);
}
-#endif
sc->nge_ldata->nge_tx_list[cur].nge_mbuf = m_head;
sc->nge_ldata->nge_tx_list[cur].nge_ctl &= ~NGE_CMDSTS_MORE;
@@ -1754,15 +1743,13 @@ static void nge_init(xsc)
*/
CSR_WRITE_4(sc, NGE_VLAN_IP_RXCTL, NGE_VIPRXCTL_IPCSUM_ENB);
-#if NVLAN > 0
/*
- * If VLAN support is enabled, tell the chip to detect
- * and strip VLAN tag info from received frames. The tag
- * will be provided in the extsts field in the RX descriptors.
+ * Tell the chip to detect and strip VLAN tag info from
+ * received frames. The tag will be provided in the extsts
+ * field in the RX descriptors.
*/
NGE_SETBIT(sc, NGE_VLAN_IP_RXCTL,
NGE_VIPRXCTL_TAG_DETECT_ENB|NGE_VIPRXCTL_TAG_STRIP_ENB);
-#endif
/* Set TX configuration */
CSR_WRITE_4(sc, NGE_TX_CFG, NGE_TXCFG);
@@ -1772,14 +1759,11 @@ static void nge_init(xsc)
*/
CSR_WRITE_4(sc, NGE_VLAN_IP_TXCTL, NGE_VIPTXCTL_CSUM_PER_PKT);
-#if NVLAN > 0
/*
- * If VLAN support is enabled, tell the chip to insert
- * VLAN tags on a per-packet basis as dictated by the
- * code in the frame encapsulation routine.
+ * Tell the chip to insert VLAN tags on a per-packet basis as
+ * dictated by the code in the frame encapsulation routine.
*/
NGE_SETBIT(sc, NGE_VLAN_IP_TXCTL, NGE_VIPTXCTL_TAG_PER_PKT);
-#endif
/* Set full/half duplex mode. */
if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) {
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c
index 3b16fdb..996a0dd 100644
--- a/sys/dev/ti/if_ti.c
+++ b/sys/dev/ti/if_ti.c
@@ -78,8 +78,6 @@
* - Andrew Gallatin for providing FreeBSD/Alpha support.
*/
-#include "vlan.h"
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
@@ -94,13 +92,10 @@
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
-
-#include <net/bpf.h>
-
-#if NVLAN > 0
#include <net/if_types.h>
#include <net/if_vlan_var.h>
-#endif
+
+#include <net/bpf.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
@@ -1334,9 +1329,7 @@ static int ti_gibinit(sc)
if (sc->arpcom.ac_if.if_hwassist)
rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
-#if NVLAN > 0
rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
-#endif
/* Set up the jumbo receive ring. */
rcb = &sc->ti_rdata->ti_info.ti_jumbo_rx_rcb;
@@ -1347,9 +1340,7 @@ static int ti_gibinit(sc)
if (sc->arpcom.ac_if.if_hwassist)
rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
-#if NVLAN > 0
rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
-#endif
/*
* Set up the mini ring. Only activated on the
@@ -1367,9 +1358,7 @@ static int ti_gibinit(sc)
if (sc->arpcom.ac_if.if_hwassist)
rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
-#if NVLAN > 0
rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
-#endif
/*
* Set up the receive return ring.
@@ -1403,9 +1392,7 @@ static int ti_gibinit(sc)
rcb->ti_flags = 0;
else
rcb->ti_flags = TI_RCB_FLAG_HOST_RING;
-#if NVLAN > 0
rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
-#endif
if (sc->arpcom.ac_if.if_hwassist)
rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
@@ -1738,22 +1725,18 @@ static void ti_rxeof(sc)
u_int32_t rxidx;
struct ether_header *eh;
struct mbuf *m = NULL;
-#if NVLAN > 0
u_int16_t vlan_tag = 0;
int have_tag = 0;
-#endif
cur_rx =
&sc->ti_rdata->ti_rx_return_ring[sc->ti_rx_saved_considx];
rxidx = cur_rx->ti_idx;
TI_INC(sc->ti_rx_saved_considx, TI_RETURN_RING_CNT);
-#if NVLAN > 0
if (cur_rx->ti_flags & TI_BDFLAG_VLAN_TAG) {
have_tag = 1;
vlan_tag = cur_rx->ti_vlan_tag & 0xfff;
}
-#endif
if (cur_rx->ti_flags & TI_BDFLAG_JUMBO_RING) {
TI_INC(sc->ti_jumbo, TI_JUMBO_RX_RING_CNT);
@@ -1815,17 +1798,15 @@ static void ti_rxeof(sc)
m->m_pkthdr.csum_data = cur_rx->ti_tcp_udp_cksum;
}
-#if NVLAN > 0
/*
* If we received a packet with a vlan tag, pass it
* to vlan_input() instead of ether_input().
*/
if (have_tag) {
- vlan_input_tag(eh, m, vlan_tag);
+ VLAN_INPUT_TAG(ifp, eh, m, vlan_tag);
have_tag = vlan_tag = 0;
continue;
}
-#endif
ether_input(ifp, eh, m);
}
@@ -1963,14 +1944,12 @@ static int ti_encap(sc, m_head, txidx)
struct mbuf *m;
u_int32_t frag, cur, cnt = 0;
u_int16_t csum_flags = 0;
-#if NVLAN > 0
struct ifvlan *ifv = NULL;
if ((m_head->m_flags & (M_PROTO1|M_PKTHDR)) == (M_PROTO1|M_PKTHDR) &&
m_head->m_pkthdr.rcvif != NULL &&
m_head->m_pkthdr.rcvif->if_type == IFT_L2VLAN)
ifv = m_head->m_pkthdr.rcvif->if_softc;
-#endif
m = m_head;
cur = frag = *txidx;
@@ -2013,14 +1992,14 @@ static int ti_encap(sc, m_head, txidx)
TI_HOSTADDR(f->ti_addr) = vtophys(mtod(m, vm_offset_t));
f->ti_len = m->m_len;
f->ti_flags = csum_flags;
-#if NVLAN > 0
+
if (ifv != NULL) {
f->ti_flags |= TI_BDFLAG_VLAN_TAG;
f->ti_vlan_tag = ifv->ifv_tag & 0xfff;
} else {
f->ti_vlan_tag = 0;
}
-#endif
+
/*
* Sanity check: avoid coming within 16 descriptors
* of the end of the ring.
diff --git a/sys/dev/txp/if_txp.c b/sys/dev/txp/if_txp.c
index f5e72b1..d9aa0b7 100644
--- a/sys/dev/txp/if_txp.c
+++ b/sys/dev/txp/if_txp.c
@@ -39,8 +39,6 @@
* Driver for 3c990 (Typhoon) Ethernet ASIC
*/
-#include "vlan.h"
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
@@ -54,6 +52,7 @@
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_types.h>
+#include <net/if_vlan_var.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -66,10 +65,6 @@
#include <net/bpf.h>
-#if NVLAN > 0
-#include <net/if_vlan_var.h>
-#endif
-
#include <vm/vm.h> /* for vtophys */
#include <vm/pmap.h> /* for vtophys */
#include <machine/clock.h> /* for DELAY */
@@ -809,14 +804,11 @@ txp_rx_reclaim(sc, r)
/* Remove header from mbuf and pass it on. */
m_adj(m, sizeof(struct ether_header));
-#if NVLAN > 0
if (rxd->rx_stat & RX_STAT_VLAN) {
- if (vlan_input_tag(eh, m,
- htons(rxd->rx_vlan >> 16)) < 0)
- ifp->if_noproto++;
+ VLAN_INPUT_TAG(ifp, eh, m, htons(rxd->rx_vlan >> 16));
goto next;
}
-#endif
+
ether_input(ifp, eh, m);
next:
@@ -1317,9 +1309,7 @@ txp_start(ifp)
struct mbuf *m, *m0;
struct txp_swdesc *sd;
u_int32_t firstprod, firstcnt, prod, cnt;
-#if NVLAN > 0
struct ifvlan *ifv;
-#endif
if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
return;
@@ -1356,14 +1346,13 @@ txp_start(ifp)
if (++cnt >= (TX_ENTRIES - 4))
goto oactive;
-#if NVLAN > 0
if ((m->m_flags & (M_PROTO1|M_PKTHDR)) == (M_PROTO1|M_PKTHDR) &&
m->m_pkthdr.rcvif != NULL) {
ifv = m->m_pkthdr.rcvif->if_softc;
txd->tx_pflags = TX_PFLAGS_VLAN |
(htons(ifv->ifv_tag) << TX_PFLAGS_VLANTAG_S);
}
-#endif
+
if (m->m_pkthdr.csum_flags & CSUM_IP)
txd->tx_pflags |= TX_PFLAGS_IPCKSUM;
@@ -1879,12 +1868,10 @@ txp_capabilities(sc)
sc->sc_tx_capability = ext->ext_1 & OFFLOAD_MASK;
sc->sc_rx_capability = ext->ext_2 & OFFLOAD_MASK;
-#if NVLAN > 0
if (rsp->rsp_par2 & rsp->rsp_par3 & OFFLOAD_VLAN) {
sc->sc_tx_capability |= OFFLOAD_VLAN;
sc->sc_rx_capability |= OFFLOAD_VLAN;
}
-#endif
#if 0
/* not ready yet */
OpenPOWER on IntegriCloud