Page MenuHomeFreeBSD

D37814.diff
No OneTemporary

D37814.diff

diff --git a/sys/dev/netmap/if_ptnet.c b/sys/dev/netmap/if_ptnet.c
--- a/sys/dev/netmap/if_ptnet.c
+++ b/sys/dev/netmap/if_ptnet.c
@@ -408,14 +408,14 @@
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
- ifp->if_baudrate = IF_Gbps(10);
- ifp->if_softc = sc;
- ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX;
- ifp->if_init = ptnet_init;
- ifp->if_ioctl = ptnet_ioctl;
- ifp->if_get_counter = ptnet_get_counter;
- ifp->if_transmit = ptnet_transmit;
- ifp->if_qflush = ptnet_qflush;
+ if_setbaudrate(ifp, IF_Gbps(10));
+ if_setsoftc(ifp, sc);
+ if_setflags(ifp, IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX);
+ if_setinitfn(ifp, ptnet_init);
+ if_setioctlfn(ifp, ptnet_ioctl);
+ if_setget_counter(ifp, ptnet_get_counter);
+ if_settransmitfn(ifp, ptnet_transmit);
+ if_setqflushfn(ifp, ptnet_qflush);
ifmedia_init(&sc->media, IFM_IMASK, ptnet_media_change,
ptnet_media_status);
@@ -433,25 +433,25 @@
ether_ifattach(ifp, sc->hwaddr);
- ifp->if_hdrlen = sizeof(struct ether_vlan_header);
- ifp->if_capabilities |= IFCAP_JUMBO_MTU | IFCAP_VLAN_MTU;
+ if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
+ if_setcapabilitiesbit(ifp, IFCAP_JUMBO_MTU | IFCAP_VLAN_MTU, 0);
if (sc->ptfeatures & PTNETMAP_F_VNET_HDR) {
/* Similarly to what the vtnet driver does, we can emulate
* VLAN offloadings by inserting and removing the 802.1Q
* header during transmit and receive. We are then able
* to do checksum offloading of VLAN frames. */
- ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6
+ if_setcapabilitiesbit(ifp, IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6
| IFCAP_VLAN_HWCSUM
| IFCAP_TSO | IFCAP_LRO
| IFCAP_VLAN_HWTSO
- | IFCAP_VLAN_HWTAGGING;
+ | IFCAP_VLAN_HWTAGGING, 0);
}
- ifp->if_capenable = ifp->if_capabilities;
+ if_setcapenable(ifp, if_getcapabilities(ifp));
#ifdef DEVICE_POLLING
/* Don't enable polling by default. */
- ifp->if_capabilities |= IFCAP_POLLING;
+ if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0);
#endif
snprintf(sc->lock_name, sizeof(sc->lock_name),
"%s", device_get_nameunit(dev));
@@ -517,7 +517,7 @@
ptnet_device_shutdown(sc);
#ifdef DEVICE_POLLING
- if (sc->ifp->if_capenable & IFCAP_POLLING) {
+ if (if_getcapenable(sc->ifp) & IFCAP_POLLING) {
ether_poll_deregister(sc->ifp);
}
#endif
@@ -761,9 +761,9 @@
switch (cmd) {
case SIOCSIFFLAGS:
- device_printf(dev, "SIOCSIFFLAGS %x\n", ifp->if_flags);
+ device_printf(dev, "SIOCSIFFLAGS %x\n", if_getflags(ifp));
PTNET_CORE_LOCK(sc);
- if (ifp->if_flags & IFF_UP) {
+ if (if_getflags(ifp) & IFF_UP) {
/* Network stack wants the iff to be up. */
err = ptnet_init_locked(sc);
} else {
@@ -777,8 +777,8 @@
case SIOCSIFCAP:
device_printf(dev, "SIOCSIFCAP %x %x\n",
- ifr->ifr_reqcap, ifp->if_capenable);
- mask = ifr->ifr_reqcap ^ ifp->if_capenable;
+ ifr->ifr_reqcap, if_getcapenable(ifp));
+ mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
#ifdef DEVICE_POLLING
if (mask & IFCAP_POLLING) {
struct ptnet_queue *pq;
@@ -790,7 +790,7 @@
break;
}
/* Stop queues and sync with taskqueues. */
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
for (i = 0; i < sc->num_rings; i++) {
pq = sc-> queues + i;
/* Make sure the worker sees the
@@ -804,7 +804,7 @@
&pq->task);
}
}
- ifp->if_drv_flags |= IFF_DRV_RUNNING;
+ if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
} else {
err = ether_poll_deregister(ifp);
for (i = 0; i < sc->num_rings; i++) {
@@ -816,7 +816,7 @@
}
}
#endif /* DEVICE_POLLING */
- ifp->if_capenable = ifr->ifr_reqcap;
+ if_setcapenable(ifp, ifr->ifr_reqcap);
break;
case SIOCSIFMTU:
@@ -826,7 +826,7 @@
err = EINVAL;
} else {
PTNET_CORE_LOCK(sc);
- ifp->if_mtu = ifr->ifr_mtu;
+ if_setmtu(ifp, ifr->ifr_mtu);
PTNET_CORE_UNLOCK(sc);
}
break;
@@ -853,22 +853,22 @@
unsigned int nm_buf_size;
int ret;
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
return 0; /* nothing to do */
}
device_printf(sc->dev, "%s\n", __func__);
/* Translate offload capabilities according to if_capenable. */
- ifp->if_hwassist = 0;
- if (ifp->if_capenable & IFCAP_TXCSUM)
- ifp->if_hwassist |= PTNET_CSUM_OFFLOAD;
- if (ifp->if_capenable & IFCAP_TXCSUM_IPV6)
- ifp->if_hwassist |= PTNET_CSUM_OFFLOAD_IPV6;
- if (ifp->if_capenable & IFCAP_TSO4)
- ifp->if_hwassist |= CSUM_IP_TSO;
- if (ifp->if_capenable & IFCAP_TSO6)
- ifp->if_hwassist |= CSUM_IP6_TSO;
+ if_sethwassist(ifp, 0);
+ if (if_getcapenable(ifp) & IFCAP_TXCSUM)
+ if_sethwassistbits(ifp, PTNET_CSUM_OFFLOAD, 0);
+ if (if_getcapenable(ifp) & IFCAP_TXCSUM_IPV6)
+ if_sethwassistbits(ifp, PTNET_CSUM_OFFLOAD_IPV6, 0);
+ if (if_getcapenable(ifp) & IFCAP_TSO4)
+ if_sethwassistbits(ifp, CSUM_IP_TSO, 0);
+ if (if_getcapenable(ifp) & IFCAP_TSO6)
+ if_sethwassistbits(ifp, CSUM_IP6_TSO, 0);
/*
* Prepare the interface for netmap mode access.
@@ -919,7 +919,7 @@
callout_reset(&sc->tick, hz, ptnet_tick, sc);
#endif
- ifp->if_drv_flags |= IFF_DRV_RUNNING;
+ if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
return 0;
@@ -946,14 +946,14 @@
device_printf(sc->dev, "%s\n", __func__);
- if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+ if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
return 0; /* nothing to do */
}
/* Clear the driver-ready flag, and synchronize with all the queues,
* so that after this loop we are sure nobody is working anymore with
* the device. This scheme is taken from the vtnet driver. */
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
callout_stop(&sc->tick);
for (i = 0; i < sc->num_rings; i++) {
PTNET_Q_LOCK(sc->queues + i);
@@ -1198,7 +1198,7 @@
pq = sc->queues + i;
pq->ktoa->kern_need_kick = 1;
pq->atok->appl_need_kick =
- (!(ifp->if_capenable & IFCAP_POLLING)
+ (!(if_getcapenable(ifp) & IFCAP_POLLING)
&& i >= sc->num_tx_rings);
}
@@ -1407,7 +1407,7 @@
return 0;
}
- if (unlikely(!(ifp->if_drv_flags & IFF_DRV_RUNNING))) {
+ if (unlikely(!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))) {
PTNET_Q_UNLOCK(pq);
nm_prlim(1, "Interface is down");
return ENETDOWN;
@@ -1609,7 +1609,7 @@
return err;
}
- if (ifp->if_capenable & IFCAP_POLLING) {
+ if (if_getcapenable(ifp) & IFCAP_POLLING) {
/* If polling is on, the transmit queues will be
* drained by the poller. */
return 0;
@@ -1693,7 +1693,7 @@
PTNET_Q_LOCK(pq);
- if (unlikely(!(ifp->if_drv_flags & IFF_DRV_RUNNING))) {
+ if (unlikely(!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))) {
goto unlock;
}
@@ -1837,7 +1837,7 @@
mhead->m_pkthdr.flowid = pq->kring_id;
M_HASHTYPE_SET(mhead, M_HASHTYPE_OPAQUE);
- if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) {
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) {
struct ether_header *eh;
eh = mtod(mhead, struct ether_header *);
@@ -1874,7 +1874,7 @@
pq->stats.bytes += mhead->m_pkthdr.len;
PTNET_Q_UNLOCK(pq);
- (*ifp->if_input)(ifp, mhead);
+ if_input(ifp, mhead);
PTNET_Q_LOCK(pq);
/* The ring->head index (and related indices) are
* updated under pq lock by ptnet_ring_update().
@@ -1883,7 +1883,7 @@
* ring from there. */
head = ring->head;
- if (unlikely(!(ifp->if_drv_flags & IFF_DRV_RUNNING))) {
+ if (unlikely(!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))) {
/* The interface has gone down while we didn't
* have the lock. Stop any processing and exit. */
goto unlock;
diff --git a/sys/dev/netmap/if_re_netmap.h b/sys/dev/netmap/if_re_netmap.h
--- a/sys/dev/netmap/if_re_netmap.h
+++ b/sys/dev/netmap/if_re_netmap.h
@@ -47,8 +47,8 @@
static int
re_netmap_reg(struct netmap_adapter *na, int onoff)
{
- struct ifnet *ifp = na->ifp;
- struct rl_softc *adapter = ifp->if_softc;
+ if_t ifp = na->ifp;
+ struct rl_softc *adapter = if_getsoftc(ifp);
RL_LOCK(adapter);
re_stop(adapter); /* also clears IFF_DRV_RUNNING */
@@ -59,7 +59,7 @@
}
re_init_locked(adapter); /* also enables intr */
RL_UNLOCK(adapter);
- return (ifp->if_drv_flags & IFF_DRV_RUNNING ? 0 : 1);
+ return (if_getdrvflags(ifp) & IFF_DRV_RUNNING ? 0 : 1);
}
@@ -70,7 +70,7 @@
re_netmap_txsync(struct netmap_kring *kring, int flags)
{
struct netmap_adapter *na = kring->na;
- struct ifnet *ifp = na->ifp;
+ if_t ifp = na->ifp;
struct netmap_ring *ring = kring->ring;
u_int nm_i; /* index into the netmap ring */
u_int nic_i; /* index into the NIC ring */
@@ -79,7 +79,7 @@
u_int const head = kring->rhead;
/* device-specific */
- struct rl_softc *sc = ifp->if_softc;
+ struct rl_softc *sc = if_getsoftc(ifp);
struct rl_txdesc *txd = sc->rl_ldata.rl_tx_desc;
bus_dmamap_sync(sc->rl_ldata.rl_tx_list_tag,
@@ -172,7 +172,7 @@
re_netmap_rxsync(struct netmap_kring *kring, int flags)
{
struct netmap_adapter *na = kring->na;
- struct ifnet *ifp = na->ifp;
+ if_t ifp = na->ifp;
struct netmap_ring *ring = kring->ring;
u_int nm_i; /* index into the netmap ring */
u_int nic_i; /* index into the NIC ring */
@@ -181,7 +181,7 @@
int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR;
/* device-specific */
- struct rl_softc *sc = ifp->if_softc;
+ struct rl_softc *sc = if_getsoftc(ifp);
struct rl_rxdesc *rxd = sc->rl_ldata.rl_rx_desc;
if (head > lim)
diff --git a/sys/dev/netmap/if_vtnet_netmap.h b/sys/dev/netmap/if_vtnet_netmap.h
--- a/sys/dev/netmap/if_vtnet_netmap.h
+++ b/sys/dev/netmap/if_vtnet_netmap.h
@@ -37,15 +37,15 @@
static int
vtnet_netmap_reg(struct netmap_adapter *na, int state)
{
- struct ifnet *ifp = na->ifp;
- struct vtnet_softc *sc = ifp->if_softc;
+ if_t ifp = na->ifp;
+ struct vtnet_softc *sc = if_getsoftc(ifp);
/*
* Trigger a device reinit, asking vtnet_init_locked() to
* also enter or exit netmap mode.
*/
VTNET_CORE_LOCK(sc);
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
vtnet_init_locked(sc, state ? VTNET_INIT_NETMAP_ENTER
: VTNET_INIT_NETMAP_EXIT);
VTNET_CORE_UNLOCK(sc);
@@ -59,7 +59,7 @@
vtnet_netmap_txsync(struct netmap_kring *kring, int flags)
{
struct netmap_adapter *na = kring->na;
- struct ifnet *ifp = na->ifp;
+ if_t ifp = na->ifp;
struct netmap_ring *ring = kring->ring;
u_int ring_nr = kring->ring_id;
u_int nm_i; /* index into the netmap ring */
@@ -67,7 +67,7 @@
u_int const head = kring->rhead;
/* device-specific */
- struct vtnet_softc *sc = ifp->if_softc;
+ struct vtnet_softc *sc = if_getsoftc(ifp);
struct vtnet_txq *txq = &sc->vtnet_txqs[ring_nr];
struct virtqueue *vq = txq->vtntx_vq;
int interrupts = !(kring->nr_kflags & NKR_NOINTR);
@@ -154,14 +154,14 @@
vtnet_netmap_kring_refill(struct netmap_kring *kring, u_int num)
{
struct netmap_adapter *na = kring->na;
- struct ifnet *ifp = na->ifp;
+ if_t ifp = na->ifp;
struct netmap_ring *ring = kring->ring;
u_int ring_nr = kring->ring_id;
u_int const lim = kring->nkr_num_slots - 1;
u_int nm_i;
/* device-specific */
- struct vtnet_softc *sc = ifp->if_softc;
+ struct vtnet_softc *sc = if_getsoftc(ifp);
struct vtnet_rxq *rxq = &sc->vtnet_rxqs[ring_nr];
struct virtqueue *vq = rxq->vtnrx_vq;
@@ -245,7 +245,7 @@
vtnet_netmap_rxsync(struct netmap_kring *kring, int flags)
{
struct netmap_adapter *na = kring->na;
- struct ifnet *ifp = na->ifp;
+ if_t ifp = na->ifp;
struct netmap_ring *ring = kring->ring;
u_int ring_nr = kring->ring_id;
u_int nm_i; /* index into the netmap ring */
@@ -256,7 +256,7 @@
int interrupts = !(kring->nr_kflags & NKR_NOINTR);
/* device-specific */
- struct vtnet_softc *sc = ifp->if_softc;
+ struct vtnet_softc *sc = if_getsoftc(ifp);
struct vtnet_rxq *rxq = &sc->vtnet_rxqs[ring_nr];
struct virtqueue *vq = rxq->vtnrx_vq;
@@ -349,7 +349,7 @@
static void
vtnet_netmap_intr(struct netmap_adapter *na, int state)
{
- struct vtnet_softc *sc = na->ifp->if_softc;
+ struct vtnet_softc *sc = if_getsoftc(na->ifp);
int i;
for (i = 0; i < sc->vtnet_max_vq_pairs; i++) {
@@ -416,7 +416,7 @@
static int
vtnet_netmap_config(struct netmap_adapter *na, struct nm_config_info *info)
{
- struct vtnet_softc *sc = na->ifp->if_softc;
+ struct vtnet_softc *sc = if_getsoftc(na->ifp);
info->num_tx_rings = sc->vtnet_act_vq_pairs;
info->num_rx_rings = sc->vtnet_act_vq_pairs;
diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c
--- a/sys/dev/netmap/netmap.c
+++ b/sys/dev/netmap/netmap.c
@@ -637,7 +637,7 @@
* onload).
*/
void
-netmap_disable_all_rings(struct ifnet *ifp)
+netmap_disable_all_rings(if_t ifp)
{
if (NM_NA_VALID(ifp)) {
netmap_set_all_rings(NA(ifp), NM_KR_LOCKED);
@@ -650,7 +650,7 @@
* napi_enable().
*/
void
-netmap_enable_all_rings(struct ifnet *ifp)
+netmap_enable_all_rings(if_t ifp)
{
if (NM_NA_VALID(ifp)) {
netmap_set_all_rings(NA(ifp), 0 /* enabled */);
@@ -658,7 +658,7 @@
}
void
-netmap_make_zombie(struct ifnet *ifp)
+netmap_make_zombie(if_t ifp)
{
if (NM_NA_VALID(ifp)) {
struct netmap_adapter *na = NA(ifp);
@@ -669,7 +669,7 @@
}
void
-netmap_undo_zombie(struct ifnet *ifp)
+netmap_undo_zombie(if_t ifp)
{
if (NM_NA_VALID(ifp)) {
struct netmap_adapter *na = NA(ifp);
@@ -764,7 +764,7 @@
struct nm_config_info info;
if (na->ifp && !nm_is_bwrap(na)) {
- strlcpy(na->name, na->ifp->if_xname, sizeof(na->name));
+ strlcpy(na->name, if_name(na->ifp), sizeof(na->name));
}
bzero(&info, sizeof(info));
@@ -1194,7 +1194,7 @@
* After this call the queue is empty.
*/
static void
-netmap_send_up(struct ifnet *dst, struct mbq *q)
+netmap_send_up(if_t dst, struct mbq *q)
{
struct mbuf *m;
struct mbuf *head = NULL, *prev = NULL;
@@ -1465,7 +1465,7 @@
*/
static void netmap_hw_dtor(struct netmap_adapter *); /* needed by NM_IS_NATIVE() */
int
-netmap_get_hw_na(struct ifnet *ifp, struct netmap_mem_d *nmd, struct netmap_adapter **na)
+netmap_get_hw_na(if_t ifp, struct netmap_mem_d *nmd, struct netmap_adapter **na)
{
/* generic support */
int i = netmap_admode; /* Take a snapshot. */
@@ -1555,7 +1555,7 @@
*/
int
netmap_get_na(struct nmreq_header *hdr,
- struct netmap_adapter **na, struct ifnet **ifp,
+ struct netmap_adapter **na, if_t *ifp,
struct netmap_mem_d *nmd, int create)
{
struct nmreq_register *req = (struct nmreq_register *)(uintptr_t)hdr->nr_body;
@@ -1671,7 +1671,7 @@
/* undo netmap_get_na() */
void
-netmap_unget_na(struct netmap_adapter *na, struct ifnet *ifp)
+netmap_unget_na(struct netmap_adapter *na, if_t ifp)
{
if (ifp)
if_rele(ifp);
@@ -2256,12 +2256,12 @@
nm_prerr("error: large MTU (%d) needed "
"but %s does not support "
"NS_MOREFRAG", mtu,
- na->ifp->if_xname);
+ if_name(na->ifp));
return EINVAL;
} else if (nbs < na->rx_buf_maxsize) {
nm_prerr("error: using NS_MOREFRAG on "
"%s requires netmap buf size "
- ">= %u", na->ifp->if_xname,
+ ">= %u", if_name(na->ifp),
na->rx_buf_maxsize);
return EINVAL;
} else {
@@ -2269,7 +2269,7 @@
"%s needs to support "
"NS_MOREFRAG "
"(MTU=%u,netmap_buf_size=%u)",
- na->ifp->if_xname, mtu, nbs);
+ if_name(na->ifp), mtu, nbs);
}
}
return 0;
@@ -2744,7 +2744,7 @@
struct mbq q; /* packets from RX hw queues to host stack */
struct netmap_adapter *na = NULL;
struct netmap_mem_d *nmd = NULL;
- struct ifnet *ifp = NULL;
+ if_t ifp = NULL;
int error = 0;
u_int i, qfirst, qlast;
struct netmap_kring **krings;
@@ -3039,7 +3039,7 @@
/* Build a nmreq_register out of the nmreq_port_hdr,
* so that we can call netmap_get_bdg_na(). */
struct nmreq_register regreq;
- struct ifnet *ifp;
+ if_t ifp;
bzero(&regreq, sizeof(regreq));
regreq.nr_mode = NR_REG_ALL_NIC;
@@ -3973,7 +3973,7 @@
#ifdef __FreeBSD__
if (na->na_flags & NAF_HOST_RINGS && na->ifp) {
- na->if_input = na->ifp->if_input; /* for netmap_send_up */
+ na->if_input = if_getinputfn(na->ifp); /* for netmap_send_up */
}
na->pdev = na; /* make sure netmap_mem_map() is called */
#endif /* __FreeBSD__ */
@@ -4063,7 +4063,7 @@
netmap_attach_ext(struct netmap_adapter *arg, size_t size, int override_reg)
{
struct netmap_hw_adapter *hwna = NULL;
- struct ifnet *ifp = NULL;
+ if_t ifp = NULL;
if (size < sizeof(struct netmap_hw_adapter)) {
if (netmap_debug & NM_DEBUG_ON)
@@ -4099,7 +4099,7 @@
goto fail;
hwna->up = *arg;
hwna->up.na_flags |= NAF_HOST_RINGS | NAF_NATIVE;
- strlcpy(hwna->up.name, ifp->if_xname, sizeof(hwna->up.name));
+ strlcpy(hwna->up.name, if_name(ifp), sizeof(hwna->up.name));
if (override_reg) {
hwna->nm_hw_register = hwna->up.nm_register;
hwna->up.nm_register = netmap_hw_reg;
@@ -4197,7 +4197,7 @@
* Called on module unload by the netmap-enabled drivers
*/
void
-netmap_detach(struct ifnet *ifp)
+netmap_detach(if_t ifp)
{
struct netmap_adapter *na;
@@ -4243,7 +4243,7 @@
* we make sure to make the mode change visible here.
*/
int
-netmap_transmit(struct ifnet *ifp, struct mbuf *m)
+netmap_transmit(if_t ifp, struct mbuf *m)
{
struct netmap_adapter *na = NA(ifp);
struct netmap_kring *kring, *tx_kring;
@@ -4483,7 +4483,7 @@
* calls the proper forwarding routine.
*/
int
-netmap_rx_irq(struct ifnet *ifp, u_int q, u_int *work_done)
+netmap_rx_irq(if_t ifp, u_int q, u_int *work_done)
{
struct netmap_adapter *na = NA(ifp);
@@ -4508,7 +4508,7 @@
void
nm_set_native_flags(struct netmap_adapter *na)
{
- struct ifnet *ifp = na->ifp;
+ if_t ifp = na->ifp;
/* We do the setup for intercepting packets only if we are the
* first user of this adapter. */
@@ -4524,7 +4524,7 @@
void
nm_clear_native_flags(struct netmap_adapter *na)
{
- struct ifnet *ifp = na->ifp;
+ if_t ifp = na->ifp;
/* We undo the setup for intercepting packets only if we are the
* last user of this adapter. */
diff --git a/sys/dev/netmap/netmap_bdg.h b/sys/dev/netmap/netmap_bdg.h
--- a/sys/dev/netmap/netmap_bdg.h
+++ b/sys/dev/netmap/netmap_bdg.h
@@ -59,7 +59,7 @@
typedef void (*bdg_dtor_fn_t)(const struct netmap_vp_adapter *);
typedef void *(*bdg_update_private_data_fn_t)(void *private_data, void *callback_data, int *error);
typedef int (*bdg_vp_create_fn_t)(struct nmreq_header *hdr,
- struct ifnet *ifp, struct netmap_mem_d *nmd,
+ if_t ifp, struct netmap_mem_d *nmd,
struct netmap_vp_adapter **ret);
typedef int (*bdg_bwrap_attach_fn_t)(const char *nr_name, struct netmap_adapter *hwna);
struct netmap_bdg_ops {
diff --git a/sys/dev/netmap/netmap_bdg.c b/sys/dev/netmap/netmap_bdg.c
--- a/sys/dev/netmap/netmap_bdg.c
+++ b/sys/dev/netmap/netmap_bdg.c
@@ -390,7 +390,7 @@
{
char *nr_name = hdr->nr_name;
const char *ifname;
- struct ifnet *ifp = NULL;
+ if_t ifp = NULL;
int error = 0;
struct netmap_vp_adapter *vpna, *hostna = NULL;
struct nm_bridge *b;
@@ -1777,7 +1777,7 @@
na->na_flags |= NAF_MOREFRAG;
nm_prdis("%s<->%s txr %d txd %d rxr %d rxd %d",
- na->name, ifp->if_xname,
+ na->name, if_name(ifp),
na->num_tx_rings, na->num_tx_desc,
na->num_rx_rings, na->num_rx_desc);
diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c
--- a/sys/dev/netmap/netmap_freebsd.c
+++ b/sys/dev/netmap/netmap_freebsd.c
@@ -171,13 +171,13 @@
}
static void
-netmap_ifnet_arrival_handler(void *arg __unused, struct ifnet *ifp)
+netmap_ifnet_arrival_handler(void *arg __unused, if_t ifp)
{
netmap_undo_zombie(ifp);
}
static void
-netmap_ifnet_departure_handler(void *arg __unused, struct ifnet *ifp)
+netmap_ifnet_departure_handler(void *arg __unused, if_t ifp)
{
netmap_make_zombie(ifp);
}
@@ -209,9 +209,9 @@
}
unsigned
-nm_os_ifnet_mtu(struct ifnet *ifp)
+nm_os_ifnet_mtu(if_t ifp)
{
- return ifp->if_mtu;
+ return if_getmtu(ifp);
}
rawsum_t
@@ -294,7 +294,7 @@
/* on FreeBSD we send up one packet at a time */
void *
-nm_os_send_up(struct ifnet *ifp, struct mbuf *m, struct mbuf *prev)
+nm_os_send_up(if_t ifp, struct mbuf *m, struct mbuf *prev)
{
NA(ifp)->if_input(ifp, m);
return NULL;
@@ -315,7 +315,7 @@
}
static void
-freebsd_generic_rx_handler(struct ifnet *ifp, struct mbuf *m)
+freebsd_generic_rx_handler(if_t ifp, struct mbuf *m)
{
int stolen;
@@ -341,7 +341,7 @@
nm_os_catch_rx(struct netmap_generic_adapter *gna, int intercept)
{
struct netmap_adapter *na = &gna->up.up;
- struct ifnet *ifp = na->ifp;
+ if_t ifp = na->ifp;
int ret = 0;
nm_os_ifnet_lock();
@@ -351,10 +351,9 @@
ret = EBUSY; /* already set */
goto out;
}
-
- ifp->if_capenable |= IFCAP_NETMAP;
- gna->save_if_input = ifp->if_input;
- ifp->if_input = freebsd_generic_rx_handler;
+ if_setcapenablebit(ifp, IFCAP_NETMAP, 0);
+ gna->save_if_input = if_getinputfn(ifp);
+ if_setinputfn(ifp, freebsd_generic_rx_handler);
} else {
if (!gna->save_if_input) {
nm_prerr("Failed to undo RX intercept on %s",
@@ -362,9 +361,8 @@
ret = EINVAL; /* not saved */
goto out;
}
-
- ifp->if_capenable &= ~IFCAP_NETMAP;
- ifp->if_input = gna->save_if_input;
+ if_setcapenablebit(ifp, 0, IFCAP_NETMAP);
+ if_setinputfn(ifp, gna->save_if_input);
gna->save_if_input = NULL;
}
out:
@@ -384,14 +382,14 @@
nm_os_catch_tx(struct netmap_generic_adapter *gna, int intercept)
{
struct netmap_adapter *na = &gna->up.up;
- struct ifnet *ifp = netmap_generic_getifp(gna);
+ if_t ifp = netmap_generic_getifp(gna);
nm_os_ifnet_lock();
if (intercept) {
- na->if_transmit = ifp->if_transmit;
- ifp->if_transmit = netmap_transmit;
+ na->if_transmit = if_gettransmitfn(ifp);
+ if_settransmitfn(ifp, netmap_transmit);
} else {
- ifp->if_transmit = na->if_transmit;
+ if_settransmitfn(ifp, na->if_transmit);
}
nm_os_ifnet_unlock();
@@ -420,7 +418,7 @@
{
int ret;
u_int len = a->len;
- struct ifnet *ifp = a->ifp;
+ if_t ifp = a->ifp;
struct mbuf *m = a->m;
/* Link the external storage to
@@ -437,7 +435,7 @@
M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE);
m->m_pkthdr.flowid = a->ring_nr;
m->m_pkthdr.rcvif = ifp; /* used for tx notification */
- CURVNET_SET(ifp->if_vnet);
+ CURVNET_SET(if_getvnet(ifp));
ret = NA(ifp)->if_transmit(ifp, m);
CURVNET_RESTORE();
return ret ? -1 : 0;
@@ -447,7 +445,7 @@
struct netmap_adapter *
netmap_getna(if_t ifp)
{
- return (NA((struct ifnet *)ifp));
+ return (NA(ifp));
}
/*
@@ -455,14 +453,14 @@
* way to extract the info from the ifp
*/
int
-nm_os_generic_find_num_desc(struct ifnet *ifp, unsigned int *tx, unsigned int *rx)
+nm_os_generic_find_num_desc(if_t ifp, unsigned int *tx, unsigned int *rx)
{
return 0;
}
void
-nm_os_generic_find_num_queues(struct ifnet *ifp, u_int *txq, u_int *rxq)
+nm_os_generic_find_num_queues(if_t ifp, u_int *txq, u_int *rxq)
{
unsigned num_rings = netmap_generic_rings ? netmap_generic_rings : 1;
@@ -513,14 +511,14 @@
}
static int
-nm_vi_dummy(struct ifnet *ifp, u_long cmd, caddr_t addr)
+nm_vi_dummy(if_t ifp, u_long cmd, caddr_t addr)
{
return EINVAL;
}
static void
-nm_vi_start(struct ifnet *ifp)
+nm_vi_start(if_t ifp)
{
panic("nm_vi_start() must not be called");
}
@@ -594,9 +592,9 @@
* increment this refcount on if_attach().
*/
int
-nm_os_vi_persist(const char *name, struct ifnet **ret)
+nm_os_vi_persist(const char *name, if_t *ret)
{
- struct ifnet *ifp;
+ if_t ifp;
u_short macaddr_hi;
uint32_t macaddr_mid;
u_char eaddr[6];
@@ -620,14 +618,14 @@
return ENOMEM;
}
if_initname(ifp, name, IF_DUNIT_NONE);
- ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_init = (void *)nm_vi_dummy;
- ifp->if_ioctl = nm_vi_dummy;
- ifp->if_start = nm_vi_start;
- ifp->if_mtu = ETHERMTU;
- IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
- ifp->if_capabilities |= IFCAP_LINKSTATE;
- ifp->if_capenable |= IFCAP_LINKSTATE;
+ if_setflags(ifp, IFF_UP | IFF_SIMPLEX | IFF_MULTICAST);
+ if_setinitfn(ifp, (void *)nm_vi_dummy);
+ if_setioctlfn(ifp, nm_vi_dummy);
+ if_setstartfn(ifp, nm_vi_start);
+ if_setmtu(ifp, ETHERMTU);
+ if_setsendqlen(ifp, ifqmaxlen);
+ if_setcapabilitiesbit(ifp, IFCAP_LINKSTATE, 0);
+ if_setcapenablebit(ifp, IFCAP_LINKSTATE, 0);
ether_ifattach(ifp, eaddr);
*ret = ifp;
@@ -636,9 +634,9 @@
/* unregister from the system and drop the final refcount */
void
-nm_os_vi_detach(struct ifnet *ifp)
+nm_os_vi_detach(if_t ifp)
{
- nm_vi_free_index(((char *)IF_LLADDR(ifp))[5]);
+ nm_vi_free_index(((char *)if_getlladdr(ifp))[5]);
ether_ifdetach(ifp);
if_free(ifp);
}
@@ -1502,28 +1500,28 @@
}
void
-nm_os_onattach(struct ifnet *ifp)
+nm_os_onattach(if_t ifp)
{
- ifp->if_capabilities |= IFCAP_NETMAP;
+ if_setcapabilitiesbit(ifp, IFCAP_NETMAP, 0);
}
void
-nm_os_onenter(struct ifnet *ifp)
+nm_os_onenter(if_t ifp)
{
struct netmap_adapter *na = NA(ifp);
- na->if_transmit = ifp->if_transmit;
- ifp->if_transmit = netmap_transmit;
- ifp->if_capenable |= IFCAP_NETMAP;
+ na->if_transmit = if_gettransmitfn(ifp);
+ if_settransmitfn(ifp, netmap_transmit);
+ if_setcapenablebit(ifp, IFCAP_NETMAP, 0);
}
void
-nm_os_onexit(struct ifnet *ifp)
+nm_os_onexit(if_t ifp)
{
struct netmap_adapter *na = NA(ifp);
- ifp->if_transmit = na->if_transmit;
- ifp->if_capenable &= ~IFCAP_NETMAP;
+ if_settransmitfn(ifp, na->if_transmit);
+ if_setcapenablebit(ifp, 0, IFCAP_NETMAP);
}
extern struct cdevsw netmap_cdevsw; /* XXX used in netmap.c, should go elsewhere */
diff --git a/sys/dev/netmap/netmap_generic.c b/sys/dev/netmap/netmap_generic.c
--- a/sys/dev/netmap/netmap_generic.c
+++ b/sys/dev/netmap/netmap_generic.c
@@ -647,7 +647,7 @@
{
struct netmap_adapter *na = kring->na;
struct netmap_generic_adapter *gna = (struct netmap_generic_adapter *)na;
- struct ifnet *ifp = na->ifp;
+ if_t ifp = na->ifp;
struct netmap_ring *ring = kring->ring;
u_int nm_i; /* index into the netmap ring */ // j
u_int const lim = kring->nkr_num_slots - 1;
@@ -811,7 +811,7 @@
* Returns 1 if the packet was stolen, 0 otherwise.
*/
int
-generic_rx_handler(struct ifnet *ifp, struct mbuf *m)
+generic_rx_handler(if_t ifp, struct mbuf *m)
{
struct netmap_adapter *na = NA(ifp);
struct netmap_generic_adapter *gna = (struct netmap_generic_adapter *)na;
@@ -1019,7 +1019,7 @@
generic_netmap_dtor(struct netmap_adapter *na)
{
struct netmap_generic_adapter *gna = (struct netmap_generic_adapter*)na;
- struct ifnet *ifp = netmap_generic_getifp(gna);
+ if_t ifp = netmap_generic_getifp(gna);
struct netmap_adapter *prev_na = gna->prev;
if (prev_na != NULL) {
@@ -1060,7 +1060,7 @@
* actual configuration.
*/
int
-generic_netmap_attach(struct ifnet *ifp)
+generic_netmap_attach(if_t ifp)
{
struct netmap_adapter *na;
struct netmap_generic_adapter *gna;
@@ -1068,7 +1068,7 @@
u_int num_tx_desc, num_rx_desc;
#ifdef __FreeBSD__
- if (ifp->if_type == IFT_LOOP) {
+ if (if_gettype(ifp) == IFT_LOOP) {
nm_prerr("if_loop is not supported by %s", __func__);
return EINVAL;
}
@@ -1097,7 +1097,7 @@
return ENOMEM;
}
na = (struct netmap_adapter *)gna;
- strlcpy(na->name, ifp->if_xname, sizeof(na->name));
+ strlcpy(na->name, if_name(ifp), sizeof(na->name));
na->ifp = ifp;
na->num_tx_desc = num_tx_desc;
na->num_rx_desc = num_rx_desc;
diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h
--- a/sys/dev/netmap/netmap_kern.h
+++ b/sys/dev/netmap/netmap_kern.h
@@ -110,7 +110,7 @@
#define NM_ATOMIC_TEST_AND_SET(p) (!atomic_cmpset_acq_int((p), 0, 1))
#define NM_ATOMIC_CLEAR(p) atomic_store_rel_int((p), 0)
-#define WNA(_ifp) (_ifp)->if_netmap
+#define WNA(_ifp) if_getnetmapadapter(_ifp)
struct netmap_adapter *netmap_getna(if_t ifp);
@@ -152,7 +152,7 @@
})
/* See explanation in nm_os_generic_xmit_frame. */
-#define GEN_TX_MBUF_IFP(m) ((struct ifnet *)skb_shinfo(m)->destructor_arg)
+#define GEN_TX_MBUF_IFP(m) ((if_t)skb_shinfo(m)->destructor_arg)
#define NM_ATOMIC_T volatile long unsigned int
@@ -297,13 +297,13 @@
void nm_os_ifnet_lock(void);
void nm_os_ifnet_unlock(void);
-unsigned nm_os_ifnet_mtu(struct ifnet *ifp);
+unsigned nm_os_ifnet_mtu(if_t ifp);
void nm_os_get_module(void);
void nm_os_put_module(void);
-void netmap_make_zombie(struct ifnet *);
-void netmap_undo_zombie(struct ifnet *);
+void netmap_make_zombie(if_t);
+void netmap_undo_zombie(if_t);
/* os independent alloc/realloc/free */
void *nm_os_malloc(size_t);
@@ -313,10 +313,10 @@
void nm_os_vfree(void *);
/* os specific attach/detach enter/exit-netmap-mode routines */
-void nm_os_onattach(struct ifnet *);
-void nm_os_ondetach(struct ifnet *);
-void nm_os_onenter(struct ifnet *);
-void nm_os_onexit(struct ifnet *);
+void nm_os_onattach(if_t);
+void nm_os_ondetach(if_t);
+void nm_os_onenter(if_t);
+void nm_os_onexit(if_t);
/* passes a packet up to the host stack.
* If the packet is sent (or dropped) immediately it returns NULL,
@@ -324,7 +324,7 @@
* In this case, a final call with m=NULL and prev != NULL will send up
* the entire chain to the host stack.
*/
-void *nm_os_send_up(struct ifnet *, struct mbuf *m, struct mbuf *prev);
+void *nm_os_send_up(if_t, struct mbuf *m, struct mbuf *prev);
int nm_os_mbuf_has_seg_offld(struct mbuf *m);
int nm_os_mbuf_has_csum_offld(struct mbuf *m);
@@ -785,14 +785,14 @@
/* copy of if_qflush and if_transmit pointers, to intercept
* packets from the network stack when netmap is active.
*/
- int (*if_transmit)(struct ifnet *, struct mbuf *);
+ int (*if_transmit)(if_t, struct mbuf *);
/* copy of if_input for netmap_send_up() */
- void (*if_input)(struct ifnet *, struct mbuf *);
+ void (*if_input)(if_t, struct mbuf *);
/* Back reference to the parent ifnet struct. Used for
* hardware ports (emulated netmap included). */
- struct ifnet *ifp; /* adapter is ifp->if_softc */
+ if_t ifp; /* adapter is if_getsoftc(ifp) */
/*---- callbacks for this netmap adapter -----*/
/*
@@ -1047,11 +1047,11 @@
* - save_if_input saves the if_input hook (FreeBSD);
* - mit implements rx interrupt mitigation;
*/
- void (*save_if_input)(struct ifnet *, struct mbuf *);
+ void (*save_if_input)(if_t, struct mbuf *);
struct nm_generic_mit *mit;
#ifdef linux
- netdev_tx_t (*save_start_xmit)(struct mbuf *, struct ifnet *);
+ netdev_tx_t (*save_start_xmit)(struct mbuf *, if_t);
#endif
/* Is the adapter able to use multiple RX slots to scatter
* each packet pushed up by the driver? */
@@ -1173,7 +1173,7 @@
struct netmap_adapter *parent; /* adapter that owns the memory */
struct netmap_pipe_adapter *peer; /* the other end of the pipe */
int peer_ref; /* 1 iff we are holding a ref to the peer */
- struct ifnet *parent_ifp; /* maybe null */
+ if_t parent_ifp; /* maybe null */
u_int parent_slot; /* index in the parent pipe array */
};
@@ -1346,8 +1346,8 @@
*/
int netmap_attach(struct netmap_adapter *);
int netmap_attach_ext(struct netmap_adapter *, size_t size, int override_reg);
-void netmap_detach(struct ifnet *);
-int netmap_transmit(struct ifnet *, struct mbuf *);
+void netmap_detach(if_t);
+int netmap_transmit(if_t, struct mbuf *);
struct netmap_slot *netmap_reset(struct netmap_adapter *na,
enum txrx tx, u_int n, u_int new_cur);
int netmap_ring_reinit(struct netmap_kring *);
@@ -1370,7 +1370,7 @@
};
/* default functions to handle rx/tx interrupts */
-int netmap_rx_irq(struct ifnet *, u_int, u_int *);
+int netmap_rx_irq(if_t, u_int, u_int *);
#define netmap_tx_irq(_n, _q) netmap_rx_irq(_n, _q, NULL)
int netmap_common_irq(struct netmap_adapter *, u_int, u_int *work_done);
@@ -1523,8 +1523,8 @@
/* set the stopped/enabled status of all rings of the adapter. */
void netmap_set_all_rings(struct netmap_adapter *, int stopped);
/* convenience wrappers for netmap_set_all_rings */
-void netmap_disable_all_rings(struct ifnet *);
-void netmap_enable_all_rings(struct ifnet *);
+void netmap_disable_all_rings(if_t);
+void netmap_enable_all_rings(if_t);
int netmap_buf_size_validate(const struct netmap_adapter *na, unsigned mtu);
int netmap_do_regif(struct netmap_priv_d *priv, struct netmap_adapter *na,
@@ -1533,9 +1533,9 @@
u_int nm_bound_var(u_int *v, u_int dflt, u_int lo, u_int hi, const char *msg);
int netmap_get_na(struct nmreq_header *hdr, struct netmap_adapter **na,
- struct ifnet **ifp, struct netmap_mem_d *nmd, int create);
-void netmap_unget_na(struct netmap_adapter *na, struct ifnet *ifp);
-int netmap_get_hw_na(struct ifnet *ifp,
+ if_t *ifp, struct netmap_mem_d *nmd, int create);
+void netmap_unget_na(struct netmap_adapter *na, if_t ifp);
+int netmap_get_hw_na(if_t ifp,
struct netmap_mem_d *nmd, struct netmap_adapter **na);
void netmap_mem_restore(struct netmap_adapter *na);
@@ -1713,14 +1713,14 @@
((uint32_t)(uintptr_t)NA(ifp) ^ NA(ifp)->magic) == NETMAP_MAGIC )
#define NM_ATTACH_NA(ifp, na) do { \
- WNA(ifp) = na; \
+ if_setnetmapadapter(ifp, na); \
if (NA(ifp)) \
NA(ifp)->magic = \
((uint32_t)(uintptr_t)NA(ifp)) ^ NETMAP_MAGIC; \
} while(0)
-#define NM_RESTORE_NA(ifp, na) WNA(ifp) = na;
+#define NM_RESTORE_NA(ifp, na) if_setnetmapadapter(ifp, na);
-#define NM_DETACH_NA(ifp) do { WNA(ifp) = NULL; } while (0)
+#define NM_DETACH_NA(ifp) do { if_setnetmapadapter(ifp, NULL); } while (0)
#define NM_NA_CLASH(ifp) (NA(ifp) && !NM_NA_VALID(ifp))
#endif /* !NM_ATTACH_NA */
@@ -2027,7 +2027,7 @@
struct netmap_if * volatile np_nifp; /* netmap if descriptor. */
struct netmap_adapter *np_na;
- struct ifnet *np_ifp;
+ if_t np_ifp;
uint32_t np_flags; /* from the ioctl */
u_int np_qfirst[NR_TXRX],
np_qlast[NR_TXRX]; /* range of tx/rx rings to scan */
@@ -2121,8 +2121,8 @@
* generic netmap emulation for devices that do not have
* native netmap support.
*/
-int generic_netmap_attach(struct ifnet *ifp);
-int generic_rx_handler(struct ifnet *ifp, struct mbuf *m);
+int generic_netmap_attach(if_t ifp);
+int generic_rx_handler(if_t ifp, struct mbuf *m);
int nm_os_catch_rx(struct netmap_generic_adapter *gna, int intercept);
int nm_os_catch_tx(struct netmap_generic_adapter *gna, int intercept);
@@ -2140,7 +2140,7 @@
* routine to send the queue and free any resources. Failure is ignored.
*/
struct nm_os_gen_arg {
- struct ifnet *ifp;
+ if_t ifp;
void *m; /* os-specific mbuf-like object */
void *head, *tail; /* tailq, if the OS-specific routine needs to build one */
void *addr; /* payload of current packet */
@@ -2150,11 +2150,11 @@
};
int nm_os_generic_xmit_frame(struct nm_os_gen_arg *);
-int nm_os_generic_find_num_desc(struct ifnet *ifp, u_int *tx, u_int *rx);
-void nm_os_generic_find_num_queues(struct ifnet *ifp, u_int *txq, u_int *rxq);
+int nm_os_generic_find_num_desc(if_t ifp, u_int *tx, u_int *rx);
+void nm_os_generic_find_num_queues(if_t ifp, u_int *txq, u_int *rxq);
void nm_os_generic_set_features(struct netmap_generic_adapter *gna);
-static inline struct ifnet*
+static inline if_t
netmap_generic_getifp(struct netmap_generic_adapter *gna)
{
if (gna->prev)
@@ -2291,8 +2291,8 @@
u_int *j, u_int lim, u_int *howmany);
/* persistent virtual port routines */
-int nm_os_vi_persist(const char *, struct ifnet **);
-void nm_os_vi_detach(struct ifnet *);
+int nm_os_vi_persist(const char *, if_t *);
+void nm_os_vi_detach(if_t);
void nm_os_vi_init_index(void);
/*
@@ -2402,7 +2402,7 @@
} while (0)
static inline struct mbuf *
-nm_os_get_mbuf(struct ifnet *ifp, int len)
+nm_os_get_mbuf(if_t ifp, int len)
{
struct mbuf *m;
diff --git a/sys/dev/netmap/netmap_kloop.c b/sys/dev/netmap/netmap_kloop.c
--- a/sys/dev/netmap/netmap_kloop.c
+++ b/sys/dev/netmap/netmap_kloop.c
@@ -1158,7 +1158,7 @@
unsigned int nifp_offset, unsigned int memid)
{
struct netmap_pt_guest_adapter *ptna;
- struct ifnet *ifp = arg ? arg->ifp : NULL;
+ if_t ifp = arg ? arg->ifp : NULL;
int error;
/* get allocator */
diff --git a/sys/dev/netmap/netmap_legacy.c b/sys/dev/netmap/netmap_legacy.c
--- a/sys/dev/netmap/netmap_legacy.c
+++ b/sys/dev/netmap/netmap_legacy.c
@@ -414,14 +414,14 @@
default: /* allow device-specific ioctls */
{
struct nmreq *nmr = (struct nmreq *)data;
- struct ifnet *ifp = ifunit_ref(nmr->nr_name);
+ if_t ifp = ifunit_ref(nmr->nr_name);
if (ifp == NULL) {
error = ENXIO;
} else {
struct socket so;
bzero(&so, sizeof(so));
- so.so_vnet = ifp->if_vnet;
+ so.so_vnet = if_getvnet(ifp);
// so->so_proto not null.
error = ifioctl(&so, cmd, data, td);
if_rele(ifp);
diff --git a/sys/dev/netmap/netmap_mem2.h b/sys/dev/netmap/netmap_mem2.h
--- a/sys/dev/netmap/netmap_mem2.h
+++ b/sys/dev/netmap/netmap_mem2.h
@@ -160,12 +160,12 @@
#endif /* WITH_EXTMEM */
#ifdef WITH_PTNETMAP
-struct netmap_mem_d* netmap_mem_pt_guest_new(struct ifnet *,
+struct netmap_mem_d* netmap_mem_pt_guest_new(if_t,
unsigned int nifp_offset,
unsigned int memid);
struct ptnetmap_memdev;
struct netmap_mem_d* netmap_mem_pt_guest_attach(struct ptnetmap_memdev *, uint16_t);
-int netmap_mem_pt_guest_ifp_del(struct netmap_mem_d *, struct ifnet *);
+int netmap_mem_pt_guest_ifp_del(struct netmap_mem_d *, if_t);
#endif /* WITH_PTNETMAP */
int netmap_mem_pools_info_get(struct nmreq_pools_info *,
diff --git a/sys/dev/netmap/netmap_mem2.c b/sys/dev/netmap/netmap_mem2.c
--- a/sys/dev/netmap/netmap_mem2.c
+++ b/sys/dev/netmap/netmap_mem2.c
@@ -2476,7 +2476,7 @@
#ifdef WITH_PTNETMAP
struct mem_pt_if {
struct mem_pt_if *next;
- struct ifnet *ifp;
+ if_t ifp;
unsigned int nifp_offset;
};
@@ -2494,7 +2494,7 @@
/* Link a passthrough interface to a passthrough netmap allocator. */
static int
-netmap_mem_pt_guest_ifp_add(struct netmap_mem_d *nmd, struct ifnet *ifp,
+netmap_mem_pt_guest_ifp_add(struct netmap_mem_d *nmd, if_t ifp,
unsigned int nifp_offset)
{
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
@@ -2517,14 +2517,14 @@
NMA_UNLOCK(nmd);
nm_prinf("ifp=%s,nifp_offset=%u",
- ptif->ifp->if_xname, ptif->nifp_offset);
+ if_name(ptif->ifp), ptif->nifp_offset);
return 0;
}
/* Called with NMA_LOCK(nmd) held. */
static struct mem_pt_if *
-netmap_mem_pt_guest_ifp_lookup(struct netmap_mem_d *nmd, struct ifnet *ifp)
+netmap_mem_pt_guest_ifp_lookup(struct netmap_mem_d *nmd, if_t ifp)
{
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
struct mem_pt_if *curr;
@@ -2540,7 +2540,7 @@
/* Unlink a passthrough interface from a passthrough netmap allocator. */
int
-netmap_mem_pt_guest_ifp_del(struct netmap_mem_d *nmd, struct ifnet *ifp)
+netmap_mem_pt_guest_ifp_del(struct netmap_mem_d *nmd, if_t ifp)
{
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
struct mem_pt_if *prev = NULL;
@@ -2557,7 +2557,7 @@
ptnmd->pt_ifs = curr->next;
}
nm_prinf("removed (ifp=%s,nifp_offset=%u)",
- curr->ifp->if_xname, curr->nifp_offset);
+ if_name(curr->ifp), curr->nifp_offset);
nm_os_free(curr);
ret = 0;
break;
@@ -2949,7 +2949,7 @@
/* Called when ptnet device is attaching */
struct netmap_mem_d *
-netmap_mem_pt_guest_new(struct ifnet *ifp,
+netmap_mem_pt_guest_new(if_t ifp,
unsigned int nifp_offset,
unsigned int memid)
{
diff --git a/sys/dev/netmap/netmap_monitor.c b/sys/dev/netmap/netmap_monitor.c
--- a/sys/dev/netmap/netmap_monitor.c
+++ b/sys/dev/netmap/netmap_monitor.c
@@ -907,7 +907,7 @@
struct nmreq_register preq;
struct netmap_adapter *pna; /* parent adapter */
struct netmap_monitor_adapter *mna;
- struct ifnet *ifp = NULL;
+ if_t ifp = NULL;
int error;
int zcopy = (req->nr_flags & NR_ZCOPY_MON);
diff --git a/sys/dev/netmap/netmap_pipe.c b/sys/dev/netmap/netmap_pipe.c
--- a/sys/dev/netmap/netmap_pipe.c
+++ b/sys/dev/netmap/netmap_pipe.c
@@ -657,7 +657,7 @@
struct nmreq_register *req = (struct nmreq_register *)(uintptr_t)hdr->nr_body;
struct netmap_adapter *pna; /* parent adapter */
struct netmap_pipe_adapter *mna, *sna, *reqna;
- struct ifnet *ifp = NULL;
+ if_t ifp = NULL;
const char *pipe_id = NULL;
int role = 0;
int error, retries = 0;
diff --git a/sys/dev/netmap/netmap_vale.c b/sys/dev/netmap/netmap_vale.c
--- a/sys/dev/netmap/netmap_vale.c
+++ b/sys/dev/netmap/netmap_vale.c
@@ -126,7 +126,7 @@
"Max number of vale bridges");
SYSEND;
-static int netmap_vale_vp_create(struct nmreq_header *hdr, struct ifnet *,
+static int netmap_vale_vp_create(struct nmreq_header *hdr, if_t,
struct netmap_mem_d *nmd, struct netmap_vp_adapter **);
static int netmap_vale_vp_bdg_attach(const char *, struct netmap_adapter *,
struct nm_bridge *);
@@ -411,7 +411,7 @@
if (na->ifp != NULL && !nm_iszombie(na)) {
NM_DETACH_NA(na->ifp);
if (vpna->autodelete) {
- nm_prdis("releasing %s", na->ifp->if_xname);
+ nm_prdis("releasing %s", if_name(na->ifp));
NMG_UNLOCK();
nm_os_vi_detach(na->ifp);
NMG_LOCK();
@@ -1139,7 +1139,7 @@
* Only persistent VALE ports have a non-null ifp.
*/
static int
-netmap_vale_vp_create(struct nmreq_header *hdr, struct ifnet *ifp,
+netmap_vale_vp_create(struct nmreq_header *hdr, if_t ifp,
struct netmap_mem_d *nmd, struct netmap_vp_adapter **ret)
{
struct nmreq_register *req = (struct nmreq_register *)(uintptr_t)hdr->nr_body;
@@ -1352,7 +1352,7 @@
int
nm_vi_destroy(const char *name)
{
- struct ifnet *ifp;
+ if_t ifp;
struct netmap_vp_adapter *vpna;
int error;
@@ -1384,7 +1384,7 @@
NMG_UNLOCK();
if (netmap_verbose)
- nm_prinf("destroying a persistent vale interface %s", ifp->if_xname);
+ nm_prinf("destroying a persistent vale interface %s", if_name(ifp));
/* Linux requires all the references are released
* before unregister
*/
@@ -1419,7 +1419,7 @@
netmap_vi_create(struct nmreq_header *hdr, int autodelete)
{
struct nmreq_register *req = (struct nmreq_register *)(uintptr_t)hdr->nr_body;
- struct ifnet *ifp;
+ if_t ifp;
struct netmap_vp_adapter *vpna;
struct netmap_mem_d *nmd = NULL;
int error;
@@ -1483,7 +1483,7 @@
if (nmd)
netmap_mem_put(nmd);
NMG_UNLOCK();
- nm_prdis("created %s", ifp->if_xname);
+ nm_prdis("created %s", if_name(ifp));
return 0;
err_2:

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 12, 12:55 PM (21 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15321759
Default Alt Text
D37814.diff (41 KB)

Event Timeline