Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107148739
D37796.id116594.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
13 KB
Referenced Files
None
Subscribers
None
D37796.id116594.diff
View Options
diff --git a/sys/dev/vte/if_vte.c b/sys/dev/vte/if_vte.c
--- a/sys/dev/vte/if_vte.c
+++ b/sys/dev/vte/if_vte.c
@@ -102,7 +102,7 @@
vte_find_ident(device_t);
#ifndef __NO_STRICT_ALIGNMENT
static struct mbuf *
- vte_fixup_rx(struct ifnet *, struct mbuf *);
+ vte_fixup_rx(if_t, struct mbuf *);
#endif
static void vte_get_macaddr(struct vte_softc *);
static void vte_init(void *);
@@ -110,15 +110,15 @@
static int vte_init_rx_ring(struct vte_softc *);
static int vte_init_tx_ring(struct vte_softc *);
static void vte_intr(void *);
-static int vte_ioctl(struct ifnet *, u_long, caddr_t);
-static uint64_t vte_get_counter(struct ifnet *, ift_counter);
+static int vte_ioctl(if_t, u_long, caddr_t);
+static uint64_t vte_get_counter(if_t, ift_counter);
static void vte_mac_config(struct vte_softc *);
static int vte_miibus_readreg(device_t, int, int);
static void vte_miibus_statchg(device_t);
static int vte_miibus_writereg(device_t, int, int, int);
-static int vte_mediachange(struct ifnet *);
-static int vte_mediachange_locked(struct ifnet *);
-static void vte_mediastatus(struct ifnet *, struct ifmediareq *);
+static int vte_mediachange(if_t);
+static int vte_mediachange_locked(if_t);
+static void vte_mediastatus(if_t, struct ifmediareq *);
static int vte_newbuf(struct vte_softc *, struct vte_rxdesc *);
static int vte_probe(device_t);
static void vte_reset(struct vte_softc *);
@@ -126,7 +126,7 @@
static void vte_rxeof(struct vte_softc *);
static void vte_rxfilter(struct vte_softc *);
static int vte_shutdown(device_t);
-static void vte_start(struct ifnet *);
+static void vte_start(if_t);
static void vte_start_locked(struct vte_softc *);
static void vte_start_mac(struct vte_softc *);
static void vte_stats_clear(struct vte_softc *);
@@ -219,14 +219,14 @@
{
struct vte_softc *sc;
struct mii_data *mii;
- struct ifnet *ifp;
+ if_t ifp;
uint16_t val;
sc = device_get_softc(dev);
mii = device_get_softc(sc->vte_miibus);
ifp = sc->vte_ifp;
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
return;
sc->vte_flags &= ~VTE_FLAG_LINK;
@@ -272,14 +272,14 @@
}
static void
-vte_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
+vte_mediastatus(if_t ifp, struct ifmediareq *ifmr)
{
struct vte_softc *sc;
struct mii_data *mii;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
VTE_LOCK(sc);
- if ((ifp->if_flags & IFF_UP) == 0) {
+ if ((if_getflags(ifp) & IFF_UP) == 0) {
VTE_UNLOCK(sc);
return;
}
@@ -292,12 +292,12 @@
}
static int
-vte_mediachange(struct ifnet *ifp)
+vte_mediachange(if_t ifp)
{
struct vte_softc *sc;
int error;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
VTE_LOCK(sc);
error = vte_mediachange_locked(ifp);
VTE_UNLOCK(sc);
@@ -305,14 +305,14 @@
}
static int
-vte_mediachange_locked(struct ifnet *ifp)
+vte_mediachange_locked(if_t ifp)
{
struct vte_softc *sc;
struct mii_data *mii;
struct mii_softc *miisc;
int error;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
mii = device_get_softc(sc->vte_miibus);
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
PHY_RESET(miisc);
@@ -375,7 +375,7 @@
vte_attach(device_t dev)
{
struct vte_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
uint16_t macid;
int error, rid;
@@ -444,16 +444,15 @@
goto fail;
}
- ifp->if_softc = sc;
+ if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = vte_ioctl;
- ifp->if_start = vte_start;
- ifp->if_init = vte_init;
- ifp->if_get_counter = vte_get_counter;
- ifp->if_snd.ifq_drv_maxlen = VTE_TX_RING_CNT - 1;
- IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen);
- IFQ_SET_READY(&ifp->if_snd);
+ if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
+ if_setioctlfn(ifp, vte_ioctl);
+ if_setstartfn(ifp, vte_start);
+ if_setinitfn(ifp, vte_init);
+ if_setgetcounterfn(ifp, vte_get_counter);
+ if_setsendqlen(ifp, VTE_TX_RING_CNT - 1);
+ if_setsendqready(ifp);
/*
* Set up MII bus.
@@ -479,10 +478,10 @@
ether_ifattach(ifp, sc->vte_eaddr);
/* VLAN capability setup. */
- ifp->if_capabilities |= IFCAP_VLAN_MTU;
- ifp->if_capenable = ifp->if_capabilities;
+ if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0);
+ if_setcapenable(ifp, if_getcapabilities(ifp));
/* Tell the upper layer we support VLAN over-sized frames. */
- ifp->if_hdrlen = sizeof(struct ether_vlan_header);
+ if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
error = bus_setup_intr(dev, sc->vte_irq, INTR_TYPE_NET | INTR_MPSAFE,
NULL, vte_intr, sc, &sc->vte_intrhand);
@@ -503,7 +502,7 @@
vte_detach(device_t dev)
{
struct vte_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
sc = device_get_softc(dev);
@@ -943,13 +942,13 @@
vte_suspend(device_t dev)
{
struct vte_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
sc = device_get_softc(dev);
VTE_LOCK(sc);
ifp = sc->vte_ifp;
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
vte_stop(sc);
VTE_UNLOCK(sc);
@@ -960,14 +959,14 @@
vte_resume(device_t dev)
{
struct vte_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
sc = device_get_softc(dev);
VTE_LOCK(sc);
ifp = sc->vte_ifp;
- if ((ifp->if_flags & IFF_UP) != 0) {
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if ((if_getflags(ifp) & IFF_UP) != 0) {
+ if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
vte_init_locked(sc);
}
VTE_UNLOCK(sc);
@@ -1099,11 +1098,11 @@
}
static void
-vte_start(struct ifnet *ifp)
+vte_start(if_t ifp)
{
struct vte_softc *sc;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
VTE_LOCK(sc);
vte_start_locked(sc);
VTE_UNLOCK(sc);
@@ -1112,24 +1111,24 @@
static void
vte_start_locked(struct vte_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
struct vte_txdesc *txd;
struct mbuf *m_head;
int enq;
ifp = sc->vte_ifp;
- if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
+ if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING || (sc->vte_flags & VTE_FLAG_LINK) == 0)
return;
- for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) {
+ for (enq = 0; !if_sendq_empty(ifp); ) {
/* Reserve one free TX descriptor. */
if (sc->vte_cdata.vte_tx_cnt >= VTE_TX_RING_CNT - 1) {
- ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
break;
}
- IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
+ m_head = if_dequeue(ifp);
if (m_head == NULL)
break;
/*
@@ -1139,7 +1138,7 @@
*/
if ((txd = vte_encap(sc, &m_head)) == NULL) {
if (m_head != NULL)
- IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
+ if_sendq_prepend(ifp, m_head);
break;
}
@@ -1166,7 +1165,7 @@
static void
vte_watchdog(struct vte_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
VTE_LOCK_ASSERT(sc);
@@ -1176,42 +1175,42 @@
ifp = sc->vte_ifp;
if_printf(sc->vte_ifp, "watchdog timeout -- resetting\n");
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
vte_init_locked(sc);
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (!if_sendq_empty(ifp))
vte_start_locked(sc);
}
static int
-vte_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
+vte_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
struct vte_softc *sc;
struct ifreq *ifr;
struct mii_data *mii;
int error;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
ifr = (struct ifreq *)data;
error = 0;
switch (cmd) {
case SIOCSIFFLAGS:
VTE_LOCK(sc);
- if ((ifp->if_flags & IFF_UP) != 0) {
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0 &&
- ((ifp->if_flags ^ sc->vte_if_flags) &
+ if ((if_getflags(ifp) & IFF_UP) != 0) {
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0 &&
+ ((if_getflags(ifp) ^ sc->vte_if_flags) &
(IFF_PROMISC | IFF_ALLMULTI)) != 0)
vte_rxfilter(sc);
else
vte_init_locked(sc);
- } else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+ } else if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
vte_stop(sc);
- sc->vte_if_flags = ifp->if_flags;
+ sc->vte_if_flags = if_getflags(ifp);
VTE_UNLOCK(sc);
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
VTE_LOCK(sc);
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
vte_rxfilter(sc);
VTE_UNLOCK(sc);
break;
@@ -1309,7 +1308,7 @@
}
static uint64_t
-vte_get_counter(struct ifnet *ifp, ift_counter cnt)
+vte_get_counter(if_t ifp, ift_counter cnt)
{
struct vte_softc *sc;
struct vte_hw_stats *stat;
@@ -1338,7 +1337,7 @@
vte_intr(void *arg)
{
struct vte_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
uint16_t status;
int n;
@@ -1357,7 +1356,7 @@
/* Disable interrupts. */
CSR_WRITE_2(sc, VTE_MIER, 0);
for (n = 8; (status & VTE_INTRS) != 0;) {
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
break;
if ((status & (MISR_RX_DONE | MISR_RX_DESC_UNAVAIL |
MISR_RX_FIFO_FULL)) != 0)
@@ -1366,7 +1365,7 @@
vte_txeof(sc);
if ((status & MISR_EVENT_CNT_OFLOW) != 0)
vte_stats_update(sc);
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (!if_sendq_empty(ifp))
vte_start_locked(sc);
if (--n > 0)
status = CSR_READ_2(sc, VTE_MISR);
@@ -1374,7 +1373,7 @@
break;
}
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
/* Re-enable interrupts. */
CSR_WRITE_2(sc, VTE_MIER, VTE_INTRS);
}
@@ -1384,7 +1383,7 @@
static void
vte_txeof(struct vte_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
struct vte_txdesc *txd;
uint16_t status;
int cons, prog;
@@ -1422,7 +1421,7 @@
}
if (prog > 0) {
- ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
sc->vte_cdata.vte_tx_cons = cons;
/*
* Unarm watchdog timer only when there is no pending
@@ -1478,7 +1477,7 @@
*/
#ifndef __NO_STRICT_ALIGNMENT
static struct mbuf *
-vte_fixup_rx(struct ifnet *ifp, struct mbuf *m)
+vte_fixup_rx(if_t ifp, struct mbuf *m)
{
uint16_t *src, *dst;
int i;
@@ -1496,7 +1495,7 @@
static void
vte_rxeof(struct vte_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
struct vte_rxdesc *rxd;
struct mbuf *m;
uint16_t status, total_len;
@@ -1507,7 +1506,7 @@
BUS_DMASYNC_POSTWRITE);
cons = sc->vte_cdata.vte_rx_cons;
ifp = sc->vte_ifp;
- for (prog = 0; (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; prog++,
+ for (prog = 0; (if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0; prog++,
VTE_DESC_INC(cons, VTE_RX_RING_CNT)) {
rxd = &sc->vte_cdata.vte_rxdesc[cons];
status = le16toh(rxd->rx_desc->drst);
@@ -1539,7 +1538,7 @@
vte_fixup_rx(ifp, m);
#endif
VTE_UNLOCK(sc);
- (*ifp->if_input)(ifp, m);
+ if_input(ifp, m);
VTE_LOCK(sc);
}
@@ -1648,7 +1647,7 @@
static void
vte_init_locked(struct vte_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
bus_addr_t paddr;
uint8_t *eaddr;
@@ -1656,7 +1655,7 @@
ifp = sc->vte_ifp;
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
return;
/*
* Cancel any pending I/O.
@@ -1686,7 +1685,7 @@
* configure the remaining three addresses as perfect
* multicast addresses.
*/
- eaddr = IF_LLADDR(sc->vte_ifp);
+ eaddr = if_getlladdr(sc->vte_ifp);
CSR_WRITE_2(sc, VTE_MID0L, eaddr[1] << 8 | eaddr[0]);
CSR_WRITE_2(sc, VTE_MID0M, eaddr[3] << 8 | eaddr[2]);
CSR_WRITE_2(sc, VTE_MID0H, eaddr[5] << 8 | eaddr[4]);
@@ -1764,14 +1763,14 @@
callout_reset(&sc->vte_tick_ch, hz, vte_tick, sc);
- ifp->if_drv_flags |= IFF_DRV_RUNNING;
- ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
+ if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
}
static void
vte_stop(struct vte_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
struct vte_txdesc *txd;
struct vte_rxdesc *rxd;
int i;
@@ -1781,7 +1780,7 @@
* Mark the interface down and cancel the watchdog timer.
*/
ifp = sc->vte_ifp;
- ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
+ if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
sc->vte_flags &= ~VTE_FLAG_LINK;
callout_stop(&sc->vte_tick_ch);
sc->vte_watchdog_timer = 0;
@@ -1999,7 +1998,7 @@
static void
vte_rxfilter(struct vte_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
struct vte_maddr_ctx ctx;
uint16_t mcr;
int i;
@@ -2019,12 +2018,12 @@
mcr = CSR_READ_2(sc, VTE_MCR0);
mcr &= ~(MCR0_PROMISC | MCR0_MULTICAST);
mcr |= MCR0_BROADCAST_DIS;
- if ((ifp->if_flags & IFF_BROADCAST) != 0)
+ if ((if_getflags(ifp) & IFF_BROADCAST) != 0)
mcr &= ~MCR0_BROADCAST_DIS;
- if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
- if ((ifp->if_flags & IFF_PROMISC) != 0)
+ if ((if_getflags(ifp) & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+ if ((if_getflags(ifp) & IFF_PROMISC) != 0)
mcr |= MCR0_PROMISC;
- if ((ifp->if_flags & IFF_ALLMULTI) != 0)
+ if ((if_getflags(ifp) & IFF_ALLMULTI) != 0)
mcr |= MCR0_MULTICAST;
ctx.mchash[0] = 0xFFFF;
ctx.mchash[1] = 0xFFFF;
diff --git a/sys/dev/vte/if_vtevar.h b/sys/dev/vte/if_vtevar.h
--- a/sys/dev/vte/if_vtevar.h
+++ b/sys/dev/vte/if_vtevar.h
@@ -123,7 +123,7 @@
* Software state per device.
*/
struct vte_softc {
- struct ifnet *vte_ifp;
+ if_t vte_ifp;
device_t vte_dev;
device_t vte_miibus;
struct resource *vte_res;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 11, 9:08 PM (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15757824
Default Alt Text
D37796.id116594.diff (13 KB)
Attached To
Mode
D37796: Mechanically convert if_vte(4) to DrvAPI
Attached
Detach File
Event Timeline
Log In to Comment