Mechanically convert usb ethernet drivers to DrvAPI

Reviewed by:	zlei
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37812
This commit is contained in:
Justin Hibbits 2023-02-07 11:10:10 -05:00
parent 70510800d1
commit 935b194ded
22 changed files with 538 additions and 547 deletions

View File

@ -225,8 +225,8 @@ static uint16_t aue_eeprom_getword(struct aue_softc *, int);
static void aue_reset(struct aue_softc *);
static void aue_reset_pegasus_II(struct aue_softc *);
static int aue_ifmedia_upd(struct ifnet *);
static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static int aue_ifmedia_upd(if_t);
static void aue_ifmedia_sts(if_t, struct ifmediareq *);
static const struct usb_config aue_config[AUE_N_TRANSFER] = {
[AUE_BULK_DT_WR] = {
@ -554,13 +554,13 @@ static void
aue_setmulti(struct usb_ether *ue)
{
struct aue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint32_t i;
uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
AUE_LOCK_ASSERT(sc, MA_OWNED);
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) {
AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI);
return;
}
@ -740,7 +740,7 @@ static void
aue_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct aue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct aue_intrpkt pkt;
struct usb_page_cache *pc;
int actlen;
@ -750,7 +750,7 @@ aue_intr_callback(struct usb_xfer *xfer, usb_error_t error)
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) &&
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) &&
actlen >= (int)sizeof(pkt)) {
pc = usbd_xfer_get_frame(xfer, 0);
usbd_copy_out(pc, 0, &pkt, sizeof(pkt));
@ -783,7 +783,7 @@ aue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct aue_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct aue_rxpkt stat;
struct usb_page_cache *pc;
int actlen;
@ -847,7 +847,7 @@ static void
aue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct aue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
uint8_t buf[2];
@ -870,7 +870,7 @@ aue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
*/
return;
}
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
return;
@ -959,7 +959,7 @@ static void
aue_init(struct usb_ether *ue)
{
struct aue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
int i;
AUE_LOCK_ASSERT(sc, MA_OWNED);
@ -971,7 +971,7 @@ aue_init(struct usb_ether *ue)
/* Set MAC address */
for (i = 0; i != ETHER_ADDR_LEN; i++)
aue_csr_write_1(sc, AUE_PAR0 + i, IF_LLADDR(ifp)[i]);
aue_csr_write_1(sc, AUE_PAR0 + i, if_getlladdr(ifp)[i]);
/* update promiscuous setting */
aue_setpromisc(ue);
@ -986,7 +986,7 @@ aue_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_xfer[AUE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
aue_start(ue);
}
@ -994,12 +994,12 @@ static void
aue_setpromisc(struct usb_ether *ue)
{
struct aue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
AUE_LOCK_ASSERT(sc, MA_OWNED);
/* if we want promiscuous mode, set the allframes bit: */
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & IFF_PROMISC)
AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
else
AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
@ -1009,9 +1009,9 @@ aue_setpromisc(struct usb_ether *ue)
* Set media options.
*/
static int
aue_ifmedia_upd(struct ifnet *ifp)
aue_ifmedia_upd(if_t ifp)
{
struct aue_softc *sc = ifp->if_softc;
struct aue_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
struct mii_softc *miisc;
int error;
@ -1029,9 +1029,9 @@ aue_ifmedia_upd(struct ifnet *ifp)
* Report current media status.
*/
static void
aue_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
aue_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
{
struct aue_softc *sc = ifp->if_softc;
struct aue_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
AUE_LOCK(sc);
@ -1049,11 +1049,11 @@ static void
aue_stop(struct usb_ether *ue)
{
struct aue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
AUE_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
sc->sc_flags &= ~AUE_FLAG_LINK;
/*

View File

@ -205,8 +205,8 @@ static uether_fn_t axe_setmulti;
static uether_fn_t axe_setpromisc;
static int axe_attach_post_sub(struct usb_ether *);
static int axe_ifmedia_upd(struct ifnet *);
static void axe_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static int axe_ifmedia_upd(if_t);
static void axe_ifmedia_sts(if_t, struct ifmediareq *);
static int axe_cmd(struct axe_softc *, int, int, int, void *);
static void axe_ax88178_init(struct axe_softc *);
static void axe_ax88772_init(struct axe_softc *);
@ -214,7 +214,7 @@ static void axe_ax88772_phywake(struct axe_softc *);
static void axe_ax88772a_init(struct axe_softc *);
static void axe_ax88772b_init(struct axe_softc *);
static int axe_get_phyno(struct axe_softc *, int);
static int axe_ioctl(struct ifnet *, u_long, caddr_t);
static int axe_ioctl(if_t, u_long, caddr_t);
static int axe_rx_frame(struct usb_ether *, struct usb_page_cache *, int);
static int axe_rxeof(struct usb_ether *, struct usb_page_cache *,
unsigned offset, unsigned, struct axe_csum_hdr *);
@ -373,7 +373,7 @@ axe_miibus_statchg(device_t dev)
{
struct axe_softc *sc = device_get_softc(dev);
struct mii_data *mii = GET_MII(sc);
struct ifnet *ifp;
if_t ifp;
uint16_t val;
int err, locked;
@ -383,7 +383,7 @@ axe_miibus_statchg(device_t dev)
ifp = uether_getifp(&sc->sc_ue);
if (mii == NULL || ifp == NULL ||
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
(if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
goto done;
sc->sc_flags &= ~AXE_FLAG_LINK;
@ -448,9 +448,9 @@ axe_miibus_statchg(device_t dev)
* Set media options.
*/
static int
axe_ifmedia_upd(struct ifnet *ifp)
axe_ifmedia_upd(if_t ifp)
{
struct axe_softc *sc = ifp->if_softc;
struct axe_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
struct mii_softc *miisc;
int error;
@ -467,9 +467,9 @@ axe_ifmedia_upd(struct ifnet *ifp)
* Report current media status.
*/
static void
axe_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
axe_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
{
struct axe_softc *sc = ifp->if_softc;
struct axe_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
AXE_LOCK(sc);
@ -495,7 +495,7 @@ static void
axe_setmulti(struct usb_ether *ue)
{
struct axe_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint16_t rxmode;
uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
@ -504,7 +504,7 @@ axe_setmulti(struct usb_ether *ue)
axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode);
rxmode = le16toh(rxmode);
if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
if (if_getflags(ifp) & (IFF_ALLMULTI | IFF_PROMISC)) {
rxmode |= AXE_RXCMD_ALLMULTI;
axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
return;
@ -865,25 +865,24 @@ static int
axe_attach_post_sub(struct usb_ether *ue)
{
struct axe_softc *sc;
struct ifnet *ifp;
if_t ifp;
u_int adv_pause;
int error;
sc = uether_getsc(ue);
ifp = ue->ue_ifp;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_start = uether_start;
ifp->if_ioctl = axe_ioctl;
ifp->if_init = uether_init;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
IFQ_SET_READY(&ifp->if_snd);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setstartfn(ifp, uether_start);
if_setioctlfn(ifp, axe_ioctl);
if_setinitfn(ifp, uether_init);
if_setsendqlen(ifp, ifqmaxlen);
if_setsendqready(ifp);
if (AXE_IS_178_FAMILY(sc))
ifp->if_capabilities |= IFCAP_VLAN_MTU;
if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0);
if (sc->sc_flags & AXE_FLAG_772B) {
ifp->if_capabilities |= IFCAP_TXCSUM | IFCAP_RXCSUM;
ifp->if_hwassist = AXE_CSUM_FEATURES;
if_setcapabilitiesbit(ifp, IFCAP_TXCSUM | IFCAP_RXCSUM, 0);
if_sethwassist(ifp, AXE_CSUM_FEATURES);
/*
* Checksum offloading of AX88772B also works with VLAN
* tagged frames but there is no way to take advantage
@ -894,7 +893,7 @@ axe_attach_post_sub(struct usb_ether *ue)
* not possible to announce IFCAP_VLAN_HWTAGGING.
*/
}
ifp->if_capenable = ifp->if_capabilities;
if_setcapenable(ifp, if_getcapabilities(ifp));
if (sc->sc_flags & (AXE_FLAG_772A | AXE_FLAG_772B | AXE_FLAG_178))
adv_pause = MIIF_DOPAUSE;
else
@ -1106,7 +1105,7 @@ static int
axe_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, unsigned offset,
unsigned len, struct axe_csum_hdr *csum_hdr)
{
struct ifnet *ifp = ue->ue_ifp;
if_t ifp = ue->ue_ifp;
struct mbuf *m;
if (len < ETHER_HDR_LEN || len > MCLBYTES - ETHER_ALIGN) {
@ -1157,7 +1156,7 @@ axe_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct axe_softc *sc = usbd_xfer_softc(xfer);
struct axe_sframe_hdr hdr;
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
int nframes, pos;
@ -1165,12 +1164,12 @@ axe_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
DPRINTFN(11, "transfer complete\n");
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
if ((sc->sc_flags & AXE_FLAG_LINK) == 0 ||
(ifp->if_drv_flags & IFF_DRV_OACTIVE) != 0) {
(if_getdrvflags(ifp) & IFF_DRV_OACTIVE) != 0) {
/*
* Don't send anything if there is no link or
* controller is busy.
@ -1179,8 +1178,8 @@ axe_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
}
for (nframes = 0; nframes < 16 &&
!IFQ_DRV_IS_EMPTY(&ifp->if_snd); nframes++) {
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
!if_sendq_empty(ifp); nframes++) {
m = if_dequeue(ifp);
if (m == NULL)
break;
usbd_xfer_set_frame_offset(xfer, nframes * MCLBYTES,
@ -1196,7 +1195,7 @@ axe_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
* computed checksum for checksum offloading
* enabled controller.
*/
if (ifp->if_capabilities & IFCAP_TXCSUM) {
if (if_getcapabilities(ifp) & IFCAP_TXCSUM) {
if ((m->m_pkthdr.csum_flags &
AXE_CSUM_FEATURES) != 0)
hdr.len |= htole16(
@ -1246,7 +1245,7 @@ axe_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
if (nframes != 0) {
usbd_xfer_set_frames(xfer, nframes);
usbd_transfer_submit(xfer);
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
}
return;
/* NOTREACHED */
@ -1255,7 +1254,7 @@ axe_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
usbd_errstr(error));
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
@ -1298,7 +1297,7 @@ static void
axe_csum_cfg(struct usb_ether *ue)
{
struct axe_softc *sc;
struct ifnet *ifp;
if_t ifp;
uint16_t csum1, csum2;
sc = uether_getsc(ue);
@ -1308,13 +1307,13 @@ axe_csum_cfg(struct usb_ether *ue)
ifp = uether_getifp(ue);
csum1 = 0;
csum2 = 0;
if ((ifp->if_capenable & IFCAP_TXCSUM) != 0)
if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0)
csum1 |= AXE_TXCSUM_IP | AXE_TXCSUM_TCP |
AXE_TXCSUM_UDP;
axe_cmd(sc, AXE_772B_CMD_WRITE_TXCSUM, csum2, csum1, NULL);
csum1 = 0;
csum2 = 0;
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0)
csum1 |= AXE_RXCSUM_IP | AXE_RXCSUM_IPVE |
AXE_RXCSUM_TCP | AXE_RXCSUM_UDP | AXE_RXCSUM_ICMP |
AXE_RXCSUM_IGMP;
@ -1326,12 +1325,12 @@ static void
axe_init(struct usb_ether *ue)
{
struct axe_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint16_t rxmode;
AXE_LOCK_ASSERT(sc, MA_OWNED);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
return;
/* Cancel pending I/O */
@ -1341,11 +1340,11 @@ axe_init(struct usb_ether *ue)
/* Set MAC address and transmitter IPG values. */
if (AXE_IS_178_FAMILY(sc)) {
axe_cmd(sc, AXE_178_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
axe_cmd(sc, AXE_178_CMD_WRITE_NODEID, 0, 0, if_getlladdr(ifp));
axe_cmd(sc, AXE_178_CMD_WRITE_IPG012, sc->sc_ipgs[2],
(sc->sc_ipgs[1] << 8) | (sc->sc_ipgs[0]), NULL);
} else {
axe_cmd(sc, AXE_172_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
axe_cmd(sc, AXE_172_CMD_WRITE_NODEID, 0, 0, if_getlladdr(ifp));
axe_cmd(sc, AXE_172_CMD_WRITE_IPG0, 0, sc->sc_ipgs[0], NULL);
axe_cmd(sc, AXE_172_CMD_WRITE_IPG1, 0, sc->sc_ipgs[1], NULL);
axe_cmd(sc, AXE_172_CMD_WRITE_IPG2, 0, sc->sc_ipgs[2], NULL);
@ -1354,7 +1353,7 @@ axe_init(struct usb_ether *ue)
if (AXE_IS_178_FAMILY(sc)) {
sc->sc_flags &= ~(AXE_FLAG_STD_FRAME | AXE_FLAG_CSUM_FRAME);
if ((sc->sc_flags & AXE_FLAG_772B) != 0 &&
(ifp->if_capenable & IFCAP_RXCSUM) != 0) {
(if_getcapenable(ifp) & IFCAP_RXCSUM) != 0) {
sc->sc_lenmask = AXE_CSUM_HDR_LEN_MASK;
sc->sc_flags |= AXE_FLAG_CSUM_FRAME;
} else {
@ -1388,7 +1387,7 @@ axe_init(struct usb_ether *ue)
* header size.
*/
rxmode |= AXE_772B_RXCMD_HDR_TYPE_1;
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0)
rxmode |= AXE_772B_RXCMD_IPHDR_ALIGN;
} else {
/*
@ -1402,10 +1401,10 @@ axe_init(struct usb_ether *ue)
}
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & IFF_PROMISC)
rxmode |= AXE_RXCMD_PROMISC;
if (ifp->if_flags & IFF_BROADCAST)
if (if_getflags(ifp) & IFF_BROADCAST)
rxmode |= AXE_RXCMD_BROADCAST;
axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
@ -1415,7 +1414,7 @@ axe_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_xfer[AXE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
/* Switch to selected media. */
axe_ifmedia_upd(ifp);
}
@ -1424,14 +1423,14 @@ static void
axe_setpromisc(struct usb_ether *ue)
{
struct axe_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint16_t rxmode;
axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode);
rxmode = le16toh(rxmode);
if (ifp->if_flags & IFF_PROMISC) {
if (if_getflags(ifp) & IFF_PROMISC) {
rxmode |= AXE_RXCMD_PROMISC;
} else {
rxmode &= ~AXE_RXCMD_PROMISC;
@ -1446,11 +1445,11 @@ static void
axe_stop(struct usb_ether *ue)
{
struct axe_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
AXE_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
sc->sc_flags &= ~AXE_FLAG_LINK;
/*
@ -1461,9 +1460,9 @@ axe_stop(struct usb_ether *ue)
}
static int
axe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
axe_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
struct usb_ether *ue = ifp->if_softc;
struct usb_ether *ue = if_getsoftc(ifp);
struct axe_softc *sc;
struct ifreq *ifr;
int error, mask, reinit;
@ -1474,23 +1473,23 @@ axe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
reinit = 0;
if (cmd == SIOCSIFCAP) {
AXE_LOCK(sc);
mask = ifr->ifr_reqcap ^ ifp->if_capenable;
mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
if ((mask & IFCAP_TXCSUM) != 0 &&
(ifp->if_capabilities & IFCAP_TXCSUM) != 0) {
ifp->if_capenable ^= IFCAP_TXCSUM;
if ((ifp->if_capenable & IFCAP_TXCSUM) != 0)
ifp->if_hwassist |= AXE_CSUM_FEATURES;
(if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
if_togglecapenable(ifp, IFCAP_TXCSUM);
if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0)
if_sethwassistbits(ifp, AXE_CSUM_FEATURES, 0);
else
ifp->if_hwassist &= ~AXE_CSUM_FEATURES;
if_sethwassistbits(ifp, 0, AXE_CSUM_FEATURES);
reinit++;
}
if ((mask & IFCAP_RXCSUM) != 0 &&
(ifp->if_capabilities & IFCAP_RXCSUM) != 0) {
ifp->if_capenable ^= IFCAP_RXCSUM;
(if_getcapabilities(ifp) & IFCAP_RXCSUM) != 0) {
if_togglecapenable(ifp, IFCAP_RXCSUM);
reinit++;
}
if (reinit > 0 && ifp->if_drv_flags & IFF_DRV_RUNNING)
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if (reinit > 0 && if_getdrvflags(ifp) & IFF_DRV_RUNNING)
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
else
reinit = 0;
AXE_UNLOCK(sc);

View File

@ -130,9 +130,9 @@ static void axge_chip_init(struct axge_softc *);
static void axge_reset(struct axge_softc *);
static int axge_attach_post_sub(struct usb_ether *);
static int axge_ifmedia_upd(struct ifnet *);
static void axge_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static int axge_ioctl(struct ifnet *, u_long, caddr_t);
static int axge_ifmedia_upd(if_t);
static void axge_ifmedia_sts(if_t, struct ifmediareq *);
static int axge_ioctl(if_t, u_long, caddr_t);
static void axge_rx_frame(struct usb_ether *, struct usb_page_cache *, int);
static void axge_rxeof(struct usb_ether *, struct usb_page_cache *,
unsigned, unsigned, uint32_t);
@ -328,7 +328,7 @@ axge_miibus_statchg(device_t dev)
{
struct axge_softc *sc;
struct mii_data *mii;
struct ifnet *ifp;
if_t ifp;
uint8_t link_status, tmp[5];
uint16_t val;
int locked;
@ -341,7 +341,7 @@ axge_miibus_statchg(device_t dev)
ifp = uether_getifp(&sc->sc_ue);
if (mii == NULL || ifp == NULL ||
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
(if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
goto done;
sc->sc_flags &= ~AXGE_FLAG_LINK;
@ -450,21 +450,20 @@ axge_attach_post(struct usb_ether *ue)
static int
axge_attach_post_sub(struct usb_ether *ue)
{
struct ifnet *ifp;
if_t ifp;
int error;
ifp = ue->ue_ifp;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_start = uether_start;
ifp->if_ioctl = axge_ioctl;
ifp->if_init = uether_init;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
IFQ_SET_READY(&ifp->if_snd);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setstartfn(ifp, uether_start);
if_setioctlfn(ifp, axge_ioctl);
if_setinitfn(ifp, uether_init);
if_setsendqlen(ifp, ifqmaxlen);
if_setsendqready(ifp);
ifp->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_TXCSUM | IFCAP_RXCSUM;
ifp->if_hwassist = AXGE_CSUM_FEATURES;
ifp->if_capenable = ifp->if_capabilities;
if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU | IFCAP_TXCSUM | IFCAP_RXCSUM, 0);
if_sethwassist(ifp, AXGE_CSUM_FEATURES);
if_setcapenable(ifp, if_getcapabilities(ifp));
bus_topo_lock();
error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp,
@ -479,14 +478,14 @@ axge_attach_post_sub(struct usb_ether *ue)
* Set media options.
*/
static int
axge_ifmedia_upd(struct ifnet *ifp)
axge_ifmedia_upd(if_t ifp)
{
struct axge_softc *sc;
struct mii_data *mii;
struct mii_softc *miisc;
int error;
sc = ifp->if_softc;
sc = if_getsoftc(ifp);
mii = GET_MII(sc);
AXGE_LOCK_ASSERT(sc, MA_OWNED);
@ -501,12 +500,12 @@ axge_ifmedia_upd(struct ifnet *ifp)
* Report current media status.
*/
static void
axge_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
axge_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
{
struct axge_softc *sc;
struct mii_data *mii;
sc = ifp->if_softc;
sc = if_getsoftc(ifp);
mii = GET_MII(sc);
AXGE_LOCK(sc);
mii_pollstat(mii);
@ -655,7 +654,7 @@ static void
axge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct axge_softc *sc;
struct ifnet *ifp;
if_t ifp;
struct usb_page_cache *pc;
struct mbuf *m;
struct axge_frame_txhdr txhdr;
@ -666,12 +665,12 @@ axge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
if ((sc->sc_flags & AXGE_FLAG_LINK) == 0 ||
(ifp->if_drv_flags & IFF_DRV_OACTIVE) != 0) {
(if_getdrvflags(ifp) & IFF_DRV_OACTIVE) != 0) {
/*
* Don't send anything if there is no link or
* controller is busy.
@ -680,8 +679,8 @@ axge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
}
for (nframes = 0; nframes < AXGE_N_FRAMES &&
!IFQ_DRV_IS_EMPTY(&ifp->if_snd); nframes++) {
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
!if_sendq_empty(ifp); nframes++) {
m = if_dequeue(ifp);
if (m == NULL)
break;
usbd_xfer_set_frame_offset(xfer, nframes * MCLBYTES,
@ -689,7 +688,7 @@ axge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
pc = usbd_xfer_get_frame(xfer, nframes);
txhdr.mss = 0;
txhdr.len = htole32(AXGE_TXBYTES(m->m_pkthdr.len));
if ((ifp->if_capenable & IFCAP_TXCSUM) != 0 &&
if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0 &&
(m->m_pkthdr.csum_flags & AXGE_CSUM_FEATURES) == 0)
txhdr.len |= htole32(AXGE_CSUM_DISABLE);
@ -723,13 +722,13 @@ axge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
if_inc_counter(ifp, IFCOUNTER_OPACKETS, nframes);
usbd_xfer_set_frames(xfer, nframes);
usbd_transfer_submit(xfer);
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
}
return;
/* NOTREACHED */
default:
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
@ -768,7 +767,7 @@ static void
axge_rxfilter(struct usb_ether *ue)
{
struct axge_softc *sc;
struct ifnet *ifp;
if_t ifp;
uint16_t rxmode;
uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
@ -785,10 +784,10 @@ axge_rxfilter(struct usb_ether *ue)
* to worry about alignment.
*/
rxmode = RCR_DROP_CRCERR | RCR_START;
if (ifp->if_flags & IFF_BROADCAST)
if (if_getflags(ifp) & IFF_BROADCAST)
rxmode |= RCR_ACPT_BCAST;
if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & (IFF_ALLMULTI | IFF_PROMISC)) {
if (if_getflags(ifp) & IFF_PROMISC)
rxmode |= RCR_PROMISC;
rxmode |= RCR_ACPT_ALL_MCAST;
axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR, rxmode);
@ -819,13 +818,13 @@ static void
axge_init(struct usb_ether *ue)
{
struct axge_softc *sc;
struct ifnet *ifp;
if_t ifp;
sc = uether_getsc(ue);
ifp = uether_getifp(ue);
AXGE_LOCK_ASSERT(sc, MA_OWNED);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
return;
/*
@ -837,7 +836,7 @@ axge_init(struct usb_ether *ue)
/* Set MAC address. */
axge_write_mem(sc, AXGE_ACCESS_MAC, ETHER_ADDR_LEN, AXGE_NIDR,
IF_LLADDR(ifp), ETHER_ADDR_LEN);
if_getlladdr(ifp), ETHER_ADDR_LEN);
axge_write_cmd_1(sc, AXGE_ACCESS_MAC, AXGE_PWLLR, 0x34);
axge_write_cmd_1(sc, AXGE_ACCESS_MAC, AXGE_PWLHR, 0x52);
@ -864,7 +863,7 @@ axge_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_xfer[AXGE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
/* Switch to selected media. */
axge_ifmedia_upd(ifp);
}
@ -873,7 +872,7 @@ static void
axge_stop(struct usb_ether *ue)
{
struct axge_softc *sc;
struct ifnet *ifp;
if_t ifp;
uint16_t val;
sc = uether_getsc(ue);
@ -886,7 +885,7 @@ axge_stop(struct usb_ether *ue)
axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_MSR, val);
if (ifp != NULL)
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
sc->sc_flags &= ~AXGE_FLAG_LINK;
/*
@ -897,37 +896,37 @@ axge_stop(struct usb_ether *ue)
}
static int
axge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
axge_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
struct usb_ether *ue;
struct axge_softc *sc;
struct ifreq *ifr;
int error, mask, reinit;
ue = ifp->if_softc;
ue = if_getsoftc(ifp);
sc = uether_getsc(ue);
ifr = (struct ifreq *)data;
error = 0;
reinit = 0;
if (cmd == SIOCSIFCAP) {
AXGE_LOCK(sc);
mask = ifr->ifr_reqcap ^ ifp->if_capenable;
mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
if ((mask & IFCAP_TXCSUM) != 0 &&
(ifp->if_capabilities & IFCAP_TXCSUM) != 0) {
ifp->if_capenable ^= IFCAP_TXCSUM;
if ((ifp->if_capenable & IFCAP_TXCSUM) != 0)
ifp->if_hwassist |= AXGE_CSUM_FEATURES;
(if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
if_togglecapenable(ifp, IFCAP_TXCSUM);
if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0)
if_sethwassistbits(ifp, AXGE_CSUM_FEATURES, 0);
else
ifp->if_hwassist &= ~AXGE_CSUM_FEATURES;
if_sethwassistbits(ifp, 0, AXGE_CSUM_FEATURES);
reinit++;
}
if ((mask & IFCAP_RXCSUM) != 0 &&
(ifp->if_capabilities & IFCAP_RXCSUM) != 0) {
ifp->if_capenable ^= IFCAP_RXCSUM;
(if_getcapabilities(ifp) & IFCAP_RXCSUM) != 0) {
if_togglecapenable(ifp, IFCAP_RXCSUM);
reinit++;
}
if (reinit > 0 && ifp->if_drv_flags & IFF_DRV_RUNNING)
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if (reinit > 0 && if_getdrvflags(ifp) & IFF_DRV_RUNNING)
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
else
reinit = 0;
AXGE_UNLOCK(sc);
@ -1000,7 +999,7 @@ static void
axge_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, unsigned offset,
unsigned len, uint32_t status)
{
struct ifnet *ifp;
if_t ifp;
struct mbuf *m;
ifp = ue->ue_ifp;
@ -1023,7 +1022,7 @@ axge_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, unsigned offset,
usbd_copy_out(pc, offset, mtod(m, uint8_t *), len);
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) {
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0) {
if ((status & AXGE_RX_L3_CSUM_ERR) == 0 &&
(status & AXGE_RX_L3_TYPE_MASK) == AXGE_RX_L3_TYPE_IPV4)
m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED |
@ -1045,7 +1044,7 @@ static void
axge_csum_cfg(struct usb_ether *ue)
{
struct axge_softc *sc;
struct ifnet *ifp;
if_t ifp;
uint8_t csum;
sc = uether_getsc(ue);
@ -1053,12 +1052,12 @@ axge_csum_cfg(struct usb_ether *ue)
ifp = uether_getifp(ue);
csum = 0;
if ((ifp->if_capenable & IFCAP_TXCSUM) != 0)
if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0)
csum |= CTCR_IP | CTCR_TCP | CTCR_UDP;
axge_write_cmd_1(sc, AXGE_ACCESS_MAC, AXGE_CTCR, csum);
csum = 0;
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0)
csum |= CRCR_IP | CRCR_TCP | CRCR_UDP;
axge_write_cmd_1(sc, AXGE_ACCESS_MAC, AXGE_CRCR, csum);
}

View File

@ -112,9 +112,9 @@ static uether_fn_t cdce_start;
static uether_fn_t cdce_setmulti;
static uether_fn_t cdce_setpromisc;
static int cdce_attach_post_sub(struct usb_ether *);
static int cdce_ioctl(struct ifnet *, u_long, caddr_t);
static int cdce_media_change_cb(struct ifnet *);
static void cdce_media_status_cb(struct ifnet *, struct ifmediareq *);
static int cdce_ioctl(if_t, u_long, caddr_t);
static int cdce_media_change_cb(if_t);
static void cdce_media_status_cb(if_t, struct ifmediareq *);
static uint32_t cdce_m_crc32(struct mbuf *, uint32_t, uint32_t);
static void cdce_set_filter(struct usb_ether *);
@ -574,16 +574,15 @@ static int
cdce_attach_post_sub(struct usb_ether *ue)
{
struct cdce_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
/* mostly copied from usb_ethernet.c */
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_start = uether_start;
ifp->if_ioctl = cdce_ioctl;
ifp->if_init = uether_init;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
IFQ_SET_READY(&ifp->if_snd);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setstartfn(ifp, uether_start);
if_setioctlfn(ifp, cdce_ioctl);
if_setinitfn(ifp, uether_init);
if_setsendqlen(ifp, ifqmaxlen);
if_setsendqready(ifp);
if ((sc->sc_flags & CDCE_FLAG_VLAN) == CDCE_FLAG_VLAN)
if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0);
@ -811,9 +810,9 @@ cdce_start(struct usb_ether *ue)
}
static int
cdce_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
cdce_ioctl(if_t ifp, u_long command, caddr_t data)
{
struct usb_ether *ue = ifp->if_softc;
struct usb_ether *ue = if_getsoftc(ifp);
struct cdce_softc *sc = uether_getsc(ue);
struct ifreq *ifr = (struct ifreq *)data;
int error;
@ -846,14 +845,14 @@ cdce_free_queue(struct mbuf **ppm, uint8_t n)
}
static int
cdce_media_change_cb(struct ifnet *ifp)
cdce_media_change_cb(if_t ifp)
{
return (EOPNOTSUPP);
}
static void
cdce_media_status_cb(struct ifnet *ifp, struct ifmediareq *ifmr)
cdce_media_status_cb(if_t ifp, struct ifmediareq *ifmr)
{
if ((if_getflags(ifp) & IFF_UP) == 0)
@ -862,14 +861,14 @@ cdce_media_status_cb(struct ifnet *ifp, struct ifmediareq *ifmr)
ifmr->ifm_active = IFM_ETHER;
ifmr->ifm_status = IFM_AVALID;
ifmr->ifm_status |=
ifp->if_link_state == LINK_STATE_UP ? IFM_ACTIVE : 0;
if_getlinkstate(ifp) == LINK_STATE_UP ? IFM_ACTIVE : 0;
}
static void
cdce_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct cdce_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct mbuf *m;
struct mbuf *mt;
uint32_t crc;
@ -894,7 +893,7 @@ cdce_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
case USB_ST_SETUP:
tr_setup:
for (x = 0; x != CDCE_FRAMES_MAX; x++) {
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
break;
@ -985,11 +984,11 @@ static void
cdce_init(struct usb_ether *ue)
{
struct cdce_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
CDCE_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
/* start interrupt transfer */
usbd_transfer_start(sc->sc_xfer[CDCE_INTR_RX]);
@ -1012,11 +1011,11 @@ static void
cdce_stop(struct usb_ether *ue)
{
struct cdce_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
CDCE_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
/*
* stop all the transfers, if not already stopped:
@ -1045,7 +1044,7 @@ static void
cdce_set_filter(struct usb_ether *ue)
{
struct cdce_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct usb_device_request req;
uint16_t value;
@ -1170,7 +1169,7 @@ cdce_intr_read_callback(struct usb_xfer *xfer, usb_error_t error)
u_char buf[CDCE_IND_SIZE_MAX];
struct usb_cdc_notification ucn;
struct cdce_softc *sc;
struct ifnet *ifp;
if_t ifp;
struct usb_page_cache *pc;
int off, actlen;
uint32_t downrate, uprate;
@ -1380,7 +1379,7 @@ static uint8_t
cdce_ncm_fill_tx_frames(struct usb_xfer *xfer, uint8_t index)
{
struct cdce_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, index);
struct mbuf *m;
uint32_t rem;
@ -1417,7 +1416,7 @@ cdce_ncm_fill_tx_frames(struct usb_xfer *xfer, uint8_t index)
rem = sc->sc_ncm.tx_max - offset;
IFQ_DRV_DEQUEUE(&(ifp->if_snd), m);
m = if_dequeue(ifp);
if (m == NULL) {
/* buffer not full */
@ -1435,7 +1434,7 @@ cdce_ncm_fill_tx_frames(struct usb_xfer *xfer, uint8_t index)
continue;
}
/* Wait till next buffer becomes ready */
IFQ_DRV_PREPEND(&(ifp->if_snd), m);
if_sendq_prepend(ifp, m);
break;
}
usbd_m_copy_in(pc, offset, m, 0, m->m_pkthdr.len);
@ -1532,7 +1531,7 @@ static void
cdce_ncm_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct cdce_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
uint16_t x;
uint8_t temp;
int actlen;
@ -1590,7 +1589,7 @@ cdce_ncm_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct cdce_softc *sc = usbd_xfer_softc(xfer);
struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, 0);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct mbuf *m;
int sumdata __usbdebug_used;
int sumlen;

View File

@ -423,7 +423,7 @@ cdceem_handle_data(struct usb_xfer *xfer, uint16_t hdr, int *offp)
struct cdceem_softc *sc;
struct usb_page_cache *pc;
struct usb_ether *ue;
struct ifnet *ifp;
if_t ifp;
struct mbuf *m;
uint32_t computed_crc, received_crc;
int pktlen;
@ -646,7 +646,7 @@ cdceem_send_data(struct usb_xfer *xfer, int *offp)
{
struct cdceem_softc *sc;
struct usb_page_cache *pc;
struct ifnet *ifp;
if_t ifp;
struct mbuf *m;
int maxlen __diagused, off;
uint32_t crc;
@ -658,7 +658,7 @@ cdceem_send_data(struct usb_xfer *xfer, int *offp)
ifp = uether_getifp(&sc->sc_ue);
maxlen = usbd_xfer_max_len(xfer);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL) {
CDCEEM_DEBUG(sc, "no Data packets to send");
return;
@ -711,7 +711,7 @@ static void
cdceem_bulk_write_callback(struct usb_xfer *xfer, usb_error_t usb_error)
{
struct cdceem_softc *sc;
struct ifnet *ifp;
if_t ifp;
int actlen, aframes, maxlen __diagused, off;
sc = usbd_xfer_softc(xfer);
@ -804,12 +804,12 @@ static void
cdceem_init(struct usb_ether *ue)
{
struct cdceem_softc *sc;
struct ifnet *ifp;
if_t ifp;
sc = uether_getsc(ue);
ifp = uether_getifp(ue);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
if (cdceem_send_echoes)
sc->sc_flags = CDCEEM_SC_FLAGS_ECHO_PENDING;
@ -832,12 +832,12 @@ static void
cdceem_stop(struct usb_ether *ue)
{
struct cdceem_softc *sc;
struct ifnet *ifp;
if_t ifp;
sc = uether_getsc(ue);
ifp = uether_getifp(ue);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
usbd_transfer_stop(sc->sc_xfer[CDCEEM_BULK_RX]);
usbd_transfer_stop(sc->sc_xfer[CDCEEM_BULK_TX]);

View File

@ -291,12 +291,12 @@ static void
cue_setpromisc(struct usb_ether *ue)
{
struct cue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
CUE_LOCK_ASSERT(sc, MA_OWNED);
/* if we want promiscuous mode, set the allframes bit */
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & IFF_PROMISC)
CUE_SETBIT(sc, CUE_ETHCTL, CUE_ETHCTL_PROMISC);
else
CUE_CLRBIT(sc, CUE_ETHCTL, CUE_ETHCTL_PROMISC);
@ -321,13 +321,13 @@ static void
cue_setmulti(struct usb_ether *ue)
{
struct cue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint32_t h, i;
uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
CUE_LOCK_ASSERT(sc, MA_OWNED);
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) {
for (i = 0; i < 8; i++)
hashtbl[i] = 0xff;
cue_mem(sc, CUE_CMD_WRITESRAM, CUE_MCAST_TABLE_ADDR,
@ -342,8 +342,8 @@ cue_setmulti(struct usb_ether *ue)
* Also include the broadcast address in the filter
* so we can receive broadcast frames.
*/
if (ifp->if_flags & IFF_BROADCAST) {
h = cue_mchash(ifp->if_broadcastaddr);
if (if_getflags(ifp) & IFF_BROADCAST) {
h = cue_mchash(if_getbroadcastaddr(ifp));
hashtbl[h >> 3] |= 1 << (h & 0x7);
}
@ -454,7 +454,7 @@ cue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct cue_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct usb_page_cache *pc;
uint8_t buf[2];
int len;
@ -501,7 +501,7 @@ static void
cue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct cue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
uint8_t buf[2];
@ -514,7 +514,7 @@ cue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
return;
@ -562,7 +562,7 @@ static void
cue_tick(struct usb_ether *ue)
{
struct cue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
CUE_LOCK_ASSERT(sc, MA_OWNED);
@ -590,7 +590,7 @@ static void
cue_init(struct usb_ether *ue)
{
struct cue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
int i;
CUE_LOCK_ASSERT(sc, MA_OWNED);
@ -604,7 +604,7 @@ cue_init(struct usb_ether *ue)
#endif
/* Set MAC address */
for (i = 0; i < ETHER_ADDR_LEN; i++)
cue_csr_write_1(sc, CUE_PAR0 - i, IF_LLADDR(ifp)[i]);
cue_csr_write_1(sc, CUE_PAR0 - i, if_getlladdr(ifp)[i]);
/* Enable RX logic. */
cue_csr_write_1(sc, CUE_ETHCTL, CUE_ETHCTL_RX_ON | CUE_ETHCTL_MCAST_ON);
@ -628,7 +628,7 @@ cue_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_xfer[CUE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
cue_start(ue);
}
@ -640,11 +640,11 @@ static void
cue_stop(struct usb_ether *ue)
{
struct cue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
CUE_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
/*
* stop all the transfers, if not already stopped:

View File

@ -343,11 +343,11 @@ static void
ipheth_init(struct usb_ether *ue)
{
struct ipheth_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
IPHETH_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
/* stall data write direction, which depends on USB mode */
usbd_xfer_set_stall(sc->sc_xfer[IPHETH_BULK_TX]);
@ -385,7 +385,7 @@ static void
ipheth_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct ipheth_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
uint8_t x;
@ -410,7 +410,7 @@ ipheth_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
case USB_ST_SETUP:
tr_setup:
for (x = 0; x != IPHETH_TX_FRAMES_MAX; x++) {
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
break;

View File

@ -342,11 +342,11 @@ static void
kue_setpromisc(struct usb_ether *ue)
{
struct kue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
KUE_LOCK_ASSERT(sc, MA_OWNED);
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & IFF_PROMISC)
sc->sc_rxfilt |= KUE_RXFILT_PROMISC;
else
sc->sc_rxfilt &= ~KUE_RXFILT_PROMISC;
@ -371,12 +371,12 @@ static void
kue_setmulti(struct usb_ether *ue)
{
struct kue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
int i;
KUE_LOCK_ASSERT(sc, MA_OWNED);
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) {
sc->sc_rxfilt |= KUE_RXFILT_ALLMULTI;
sc->sc_rxfilt &= ~KUE_RXFILT_MULTICAST;
kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->sc_rxfilt);
@ -534,7 +534,7 @@ kue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct kue_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct usb_page_cache *pc;
uint8_t buf[2];
int len;
@ -581,7 +581,7 @@ static void
kue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct kue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
int total_len;
@ -596,7 +596,7 @@ kue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
return;
@ -660,13 +660,13 @@ static void
kue_init(struct usb_ether *ue)
{
struct kue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
KUE_LOCK_ASSERT(sc, MA_OWNED);
/* set MAC address */
kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SET_MAC,
0, IF_LLADDR(ifp), ETHER_ADDR_LEN);
0, if_getlladdr(ifp), ETHER_ADDR_LEN);
/* I'm not sure how to tune these. */
#if 0
@ -683,7 +683,7 @@ kue_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_xfer[KUE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
kue_start(ue);
}
@ -691,11 +691,11 @@ static void
kue_stop(struct usb_ether *ue)
{
struct kue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
KUE_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
/*
* stop all the transfers, if not already stopped:

View File

@ -180,8 +180,8 @@ static void mos_stop(struct usb_ether *);
static int mos_miibus_readreg(device_t, int, int);
static int mos_miibus_writereg(device_t, int, int, int);
static void mos_miibus_statchg(device_t);
static int mos_ifmedia_upd(struct ifnet *);
static void mos_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static int mos_ifmedia_upd(if_t);
static void mos_ifmedia_sts(if_t, struct ifmediareq *);
static void mos_reset(struct mos_softc *sc);
static int mos_reg_read_1(struct mos_softc *, int);
@ -529,9 +529,9 @@ mos_miibus_statchg(device_t dev)
* Set media options.
*/
static int
mos_ifmedia_upd(struct ifnet *ifp)
mos_ifmedia_upd(if_t ifp)
{
struct mos_softc *sc = ifp->if_softc;
struct mos_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
struct mii_softc *miisc;
int error;
@ -549,9 +549,9 @@ mos_ifmedia_upd(struct ifnet *ifp)
* Report current media status.
*/
static void
mos_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
mos_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
{
struct mos_softc *sc = ifp->if_softc;
struct mos_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
MOS_LOCK(sc);
@ -566,7 +566,7 @@ static void
mos_setpromisc(struct usb_ether *ue)
{
struct mos_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint8_t rxmode;
@ -575,7 +575,7 @@ mos_setpromisc(struct usb_ether *ue)
rxmode = mos_reg_read_1(sc, MOS_CTL);
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC) {
if (if_getflags(ifp) & IFF_PROMISC) {
rxmode |= MOS_CTL_RX_PROMISC;
} else {
rxmode &= ~MOS_CTL_RX_PROMISC;
@ -600,7 +600,7 @@ static void
mos_setmulti(struct usb_ether *ue)
{
struct mos_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint8_t rxmode;
uint8_t hashtbl[8] = {0, 0, 0, 0, 0, 0, 0, 0};
int allmulti = 0;
@ -609,7 +609,7 @@ mos_setmulti(struct usb_ether *ue)
rxmode = mos_reg_read_1(sc, MOS_CTL);
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC)
allmulti = 1;
/* get all new ones */
@ -773,7 +773,7 @@ mos_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct mos_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint8_t rxstat = 0;
uint32_t actlen;
@ -845,7 +845,7 @@ static void
mos_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct mos_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
@ -859,7 +859,7 @@ mos_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
/*
* XXX: don't send anything if there is no link?
*/
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
return;
@ -925,7 +925,7 @@ static void
mos_init(struct usb_ether *ue)
{
struct mos_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint8_t rxmode;
MOS_LOCK_ASSERT(sc, MA_OWNED);
@ -934,7 +934,7 @@ mos_init(struct usb_ether *ue)
mos_reset(sc);
/* Write MAC address */
mos_writemac(sc, IF_LLADDR(ifp));
mos_writemac(sc, if_getlladdr(ifp));
/* Read and set transmitter IPG values */
sc->mos_ipgs[0] = mos_reg_read_1(sc, MOS_IPG0);
@ -958,7 +958,7 @@ mos_init(struct usb_ether *ue)
/* Load the multicast filter. */
mos_setmulti(ue);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
mos_start(ue);
}
@ -966,7 +966,7 @@ static void
mos_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct mos_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
uint32_t pkt;
int actlen;
@ -1002,12 +1002,12 @@ static void
mos_stop(struct usb_ether *ue)
{
struct mos_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
mos_reset(sc);
MOS_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
/* stop all the transfers, if not already stopped */
usbd_transfer_stop(sc->sc_xfer[MOS_ENDPT_TX]);

View File

@ -217,11 +217,11 @@ static uether_fn_t muge_tick;
static uether_fn_t muge_setmulti;
static uether_fn_t muge_setpromisc;
static int muge_ifmedia_upd(struct ifnet *);
static void muge_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static int muge_ifmedia_upd(if_t);
static void muge_ifmedia_sts(if_t, struct ifmediareq *);
static int lan78xx_chip_init(struct muge_softc *sc);
static int muge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
static int muge_ioctl(if_t ifp, u_long cmd, caddr_t data);
static const struct usb_config muge_config[MUGE_N_TRANSFER] = {
[MUGE_BULK_DT_WR] = {
@ -759,7 +759,7 @@ lan78xx_miibus_statchg(device_t dev)
{
struct muge_softc *sc = device_get_softc(dev);
struct mii_data *mii = uether_getmii(&sc->sc_ue);
struct ifnet *ifp;
if_t ifp;
int err;
uint32_t flow = 0;
uint32_t fct_flow = 0;
@ -771,7 +771,7 @@ lan78xx_miibus_statchg(device_t dev)
ifp = uether_getifp(&sc->sc_ue);
if (mii == NULL || ifp == NULL ||
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
(if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
goto done;
/* Use the MII status to determine link status */
@ -1164,7 +1164,7 @@ muge_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct muge_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct mbuf *m;
struct usb_page_cache *pc;
uint32_t rx_cmd_a, rx_cmd_b;
@ -1262,7 +1262,7 @@ muge_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
* Check if RX checksums are computed, and
* offload them
*/
if ((ifp->if_capenable & IFCAP_RXCSUM) &&
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) &&
!(rx_cmd_a & RX_CMD_A_ICSM_)) {
/*
* Remove the extra 2 bytes of the csum
@ -1357,7 +1357,7 @@ static void
muge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct muge_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
int nframes;
@ -1367,19 +1367,19 @@ muge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
case USB_ST_TRANSFERRED:
muge_dbg_printf(sc,
"USB TRANSFER status: USB_ST_TRANSFERRED\n");
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
/* FALLTHROUGH */
case USB_ST_SETUP:
muge_dbg_printf(sc, "USB TRANSFER status: USB_ST_SETUP\n");
tr_setup:
if ((sc->sc_flags & MUGE_FLAG_LINK) == 0 ||
(ifp->if_drv_flags & IFF_DRV_OACTIVE) != 0) {
(if_getdrvflags(ifp) & IFF_DRV_OACTIVE) != 0) {
muge_dbg_printf(sc,
"sc->sc_flags & MUGE_FLAG_LINK: %d\n",
(sc->sc_flags & MUGE_FLAG_LINK));
muge_dbg_printf(sc,
"ifp->if_drv_flags & IFF_DRV_OACTIVE: %d\n",
(ifp->if_drv_flags & IFF_DRV_OACTIVE));
"if_getdrvflags(ifp) & IFF_DRV_OACTIVE: %d",
(if_getdrvflags(ifp) & IFF_DRV_OACTIVE));
muge_dbg_printf(sc,
"USB TRANSFER not sending: no link or controller is busy \n");
/*
@ -1389,9 +1389,9 @@ muge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
return;
}
for (nframes = 0;
nframes < 16 && !IFQ_DRV_IS_EMPTY(&ifp->if_snd);
nframes < 16 && !if_sendq_empty(ifp);
nframes++) {
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
break;
usbd_xfer_set_frame_offset(xfer, nframes * MCLBYTES,
@ -1438,13 +1438,13 @@ muge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
muge_dbg_printf(sc, "USB TRANSFER submit attempt\n");
usbd_xfer_set_frames(xfer, nframes);
usbd_transfer_submit(xfer);
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
}
return;
default:
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
if (error != USB_ERR_CANCELLED) {
muge_err_printf(sc,
@ -1592,30 +1592,29 @@ static int
muge_attach_post_sub(struct usb_ether *ue)
{
struct muge_softc *sc;
struct ifnet *ifp;
if_t ifp;
sc = uether_getsc(ue);
muge_dbg_printf(sc, "Calling muge_attach_post_sub.\n");
ifp = ue->ue_ifp;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_start = uether_start;
ifp->if_ioctl = muge_ioctl;
ifp->if_init = uether_init;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
IFQ_SET_READY(&ifp->if_snd);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setstartfn(ifp, uether_start);
if_setioctlfn(ifp, muge_ioctl);
if_setinitfn(ifp, uether_init);
if_setsendqlen(ifp, ifqmaxlen);
if_setsendqready(ifp);
/*
* The chip supports TCP/UDP checksum offloading on TX and RX paths,
* however currently only RX checksum is supported in the driver
* (see top of file).
*/
ifp->if_capabilities |= IFCAP_VLAN_MTU;
ifp->if_hwassist = 0;
ifp->if_capabilities |= IFCAP_RXCSUM;
if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0);
if_sethwassist(ifp, 0);
if_setcapabilitiesbit(ifp, IFCAP_RXCSUM, 0);
if (MUGE_DEFAULT_TX_CSUM_ENABLE)
ifp->if_capabilities |= IFCAP_TXCSUM;
if_setcapabilitiesbit(ifp, IFCAP_TXCSUM, 0);
/*
* In the Linux driver they also enable scatter/gather (NETIF_F_SG)
@ -1623,16 +1622,16 @@ muge_attach_post_sub(struct usb_ether *ue)
* FreeBSD doesn't have that as an interface feature.
*/
if (MUGE_DEFAULT_TSO_ENABLE)
ifp->if_capabilities |= IFCAP_TSO4 | IFCAP_TSO6;
if_setcapabilitiesbit(ifp, IFCAP_TSO4 | IFCAP_TSO6, 0);
#if 0
/* TX checksuming is disabled since not yet implemented. */
ifp->if_capabilities |= IFCAP_TXCSUM;
ifp->if_capenable |= IFCAP_TXCSUM;
ifp->if_hwassist = CSUM_TCP | CSUM_UDP;
if_setcapabilitiesbit(ifp, IFCAP_TXCSUM, 0);
if_setcapenablebit(ifp, IFCAP_TXCSUM, 0);
if_sethwassist(ifp, CSUM_TCP | CSUM_UDP);
#endif
ifp->if_capenable = ifp->if_capabilities;
if_setcapenable(ifp, if_getcapabilities(ifp));
bus_topo_lock();
mii_attach(ue->ue_dev, &ue->ue_miibus, ifp, uether_ifmedia_upd,
@ -1673,9 +1672,9 @@ muge_start(struct usb_ether *ue)
* 0 on success and an error code on failure.
*/
static int
muge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
muge_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
struct usb_ether *ue = ifp->if_softc;
struct usb_ether *ue = if_getsoftc(ifp);
struct muge_softc *sc;
struct ifreq *ifr;
int rc;
@ -1691,15 +1690,15 @@ muge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
rc = 0;
reinit = 0;
mask = ifr->ifr_reqcap ^ ifp->if_capenable;
mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
/* Modify the RX CSUM enable bits. */
if ((mask & IFCAP_RXCSUM) != 0 &&
(ifp->if_capabilities & IFCAP_RXCSUM) != 0) {
ifp->if_capenable ^= IFCAP_RXCSUM;
(if_getcapabilities(ifp) & IFCAP_RXCSUM) != 0) {
if_togglecapenable(ifp, IFCAP_RXCSUM);
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
reinit = 1;
}
}
@ -1886,7 +1885,7 @@ static void
muge_setmulti(struct usb_ether *ue)
{
struct muge_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint8_t i;
MUGE_LOCK_ASSERT(sc, MA_OWNED);
@ -1905,10 +1904,10 @@ muge_setmulti(struct usb_ether *ue)
sc->sc_rfe_ctl |= ETH_RFE_CTL_BCAST_EN_;
if (ifp->if_flags & IFF_PROMISC) {
if (if_getflags(ifp) & IFF_PROMISC) {
muge_dbg_printf(sc, "promiscuous mode enabled\n");
sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_EN_ | ETH_RFE_CTL_UCAST_EN_;
} else if (ifp->if_flags & IFF_ALLMULTI) {
} else if (if_getflags(ifp) & IFF_ALLMULTI) {
muge_dbg_printf(sc, "receive all multicast enabled\n");
sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_EN_;
} else {
@ -1929,14 +1928,14 @@ static void
muge_setpromisc(struct usb_ether *ue)
{
struct muge_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
muge_dbg_printf(sc, "promiscuous mode %sabled\n",
(ifp->if_flags & IFF_PROMISC) ? "en" : "dis");
(if_getflags(ifp) & IFF_PROMISC) ? "en" : "dis");
MUGE_LOCK_ASSERT(sc, MA_OWNED);
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & IFF_PROMISC)
sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_EN_ | ETH_RFE_CTL_UCAST_EN_;
else
sc->sc_rfe_ctl &= ~(ETH_RFE_CTL_MCAST_EN_);
@ -1957,7 +1956,7 @@ muge_setpromisc(struct usb_ether *ue)
static int
muge_sethwcsum(struct muge_softc *sc)
{
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
int err;
if (!ifp)
@ -1965,7 +1964,7 @@ muge_sethwcsum(struct muge_softc *sc)
MUGE_LOCK_ASSERT(sc, MA_OWNED);
if (ifp->if_capenable & IFCAP_RXCSUM) {
if (if_getcapenable(ifp) & IFCAP_RXCSUM) {
sc->sc_rfe_ctl |= ETH_RFE_CTL_IGMP_COE_ | ETH_RFE_CTL_ICMP_COE_;
sc->sc_rfe_ctl |= ETH_RFE_CTL_TCPUDP_COE_ | ETH_RFE_CTL_IP_COE_;
} else {
@ -2002,9 +2001,9 @@ muge_sethwcsum(struct muge_softc *sc)
* Returns 0 on success or a negative error code.
*/
static int
muge_ifmedia_upd(struct ifnet *ifp)
muge_ifmedia_upd(if_t ifp)
{
struct muge_softc *sc = ifp->if_softc;
struct muge_softc *sc = if_getsoftc(ifp);
muge_dbg_printf(sc, "Calling muge_ifmedia_upd.\n");
struct mii_data *mii = uether_getmii(&sc->sc_ue);
struct mii_softc *miisc;
@ -2033,13 +2032,13 @@ muge_init(struct usb_ether *ue)
{
struct muge_softc *sc = uether_getsc(ue);
muge_dbg_printf(sc, "Calling muge_init.\n");
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
MUGE_LOCK_ASSERT(sc, MA_OWNED);
if (lan78xx_setmacaddress(sc, IF_LLADDR(ifp)))
if (lan78xx_setmacaddress(sc, if_getlladdr(ifp)))
muge_dbg_printf(sc, "setting MAC address failed\n");
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
return;
/* Cancel pending I/O. */
@ -2057,7 +2056,7 @@ muge_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_xfer[MUGE_BULK_DT_WR]);
/* Indicate we are up and running. */
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
/* Switch to selected media. */
muge_ifmedia_upd(ifp);
@ -2072,11 +2071,11 @@ static void
muge_stop(struct usb_ether *ue)
{
struct muge_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
MUGE_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
sc->sc_flags &= ~MUGE_FLAG_LINK;
/*
@ -2123,9 +2122,9 @@ muge_tick(struct usb_ether *ue)
* Internally takes and releases the device lock.
*/
static void
muge_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
muge_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
{
struct muge_softc *sc = ifp->if_softc;
struct muge_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = uether_getmii(&sc->sc_ue);
MUGE_LOCK(sc);

View File

@ -158,8 +158,8 @@ static int rue_csr_write_2(struct rue_softc *, uint16_t, uint16_t);
static int rue_csr_write_4(struct rue_softc *, int, uint32_t);
static void rue_reset(struct rue_softc *);
static int rue_ifmedia_upd(struct ifnet *);
static void rue_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static int rue_ifmedia_upd(if_t);
static void rue_ifmedia_sts(if_t, struct ifmediareq *);
static const struct usb_config rue_config[RUE_N_TRANSFER] = {
[RUE_BULK_DT_WR] = {
@ -459,12 +459,12 @@ static void
rue_setpromisc(struct usb_ether *ue)
{
struct rue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
RUE_LOCK_ASSERT(sc, MA_OWNED);
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & IFF_PROMISC)
RUE_SETBIT(sc, RUE_RCR, RUE_RCR_AAP);
else
RUE_CLRBIT(sc, RUE_RCR, RUE_RCR_AAP);
@ -492,7 +492,7 @@ static void
rue_setmulti(struct usb_ether *ue)
{
struct rue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint16_t rxcfg;
uint32_t hashes[2] = { 0, 0 };
int mcnt;
@ -501,7 +501,7 @@ rue_setmulti(struct usb_ether *ue)
rxcfg = rue_csr_read_2(sc, RUE_RCR);
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) {
rxcfg |= (RUE_RCR_AAM | RUE_RCR_AAP);
rxcfg &= ~RUE_RCR_AM;
rue_csr_write_2(sc, RUE_RCR, rxcfg);
@ -638,7 +638,7 @@ static void
rue_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct rue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct rue_intrpkt pkt;
struct usb_page_cache *pc;
int actlen;
@ -648,7 +648,7 @@ rue_intr_callback(struct usb_xfer *xfer, usb_error_t error)
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
if (ifp && (ifp->if_drv_flags & IFF_DRV_RUNNING) &&
if (ifp && (if_getdrvflags(ifp) & IFF_DRV_RUNNING) &&
actlen >= (int)sizeof(pkt)) {
pc = usbd_xfer_get_frame(xfer, 0);
usbd_copy_out(pc, 0, &pkt, sizeof(pkt));
@ -679,7 +679,7 @@ rue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct rue_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct usb_page_cache *pc;
uint16_t status;
int actlen;
@ -729,7 +729,7 @@ static void
rue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct rue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
int temp_len;
@ -748,7 +748,7 @@ rue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
*/
return;
}
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
return;
@ -832,7 +832,7 @@ static void
rue_init(struct usb_ether *ue)
{
struct rue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
RUE_LOCK_ASSERT(sc, MA_OWNED);
@ -842,7 +842,7 @@ rue_init(struct usb_ether *ue)
rue_reset(sc);
/* Set MAC address */
rue_write_mem(sc, RUE_IDR0, IF_LLADDR(ifp), ETHER_ADDR_LEN);
rue_write_mem(sc, RUE_IDR0, if_getlladdr(ifp), ETHER_ADDR_LEN);
rue_stop(ue);
@ -862,7 +862,7 @@ rue_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_xfer[RUE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
rue_start(ue);
}
@ -870,9 +870,9 @@ rue_init(struct usb_ether *ue)
* Set media options.
*/
static int
rue_ifmedia_upd(struct ifnet *ifp)
rue_ifmedia_upd(if_t ifp)
{
struct rue_softc *sc = ifp->if_softc;
struct rue_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
struct mii_softc *miisc;
int error;
@ -890,9 +890,9 @@ rue_ifmedia_upd(struct ifnet *ifp)
* Report current media status.
*/
static void
rue_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
rue_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
{
struct rue_softc *sc = ifp->if_softc;
struct rue_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
RUE_LOCK(sc);
@ -906,11 +906,11 @@ static void
rue_stop(struct usb_ether *ue)
{
struct rue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
RUE_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
sc->sc_flags &= ~RUE_FLAG_LINK;
/*

View File

@ -201,11 +201,11 @@ static uether_fn_t smsc_tick;
static uether_fn_t smsc_setmulti;
static uether_fn_t smsc_setpromisc;
static int smsc_ifmedia_upd(struct ifnet *);
static void smsc_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static int smsc_ifmedia_upd(if_t);
static void smsc_ifmedia_sts(if_t, struct ifmediareq *);
static int smsc_chip_init(struct smsc_softc *sc);
static int smsc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
static int smsc_ioctl(if_t ifp, u_long cmd, caddr_t data);
static const struct usb_config smsc_config[SMSC_N_TRANSFER] = {
[SMSC_BULK_DT_WR] = {
@ -537,7 +537,7 @@ smsc_miibus_statchg(device_t dev)
{
struct smsc_softc *sc = device_get_softc(dev);
struct mii_data *mii = uether_getmii(&sc->sc_ue);
struct ifnet *ifp;
if_t ifp;
int locked;
int err;
uint32_t flow;
@ -549,7 +549,7 @@ smsc_miibus_statchg(device_t dev)
ifp = uether_getifp(&sc->sc_ue);
if (mii == NULL || ifp == NULL ||
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
(if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
goto done;
/* Use the MII status to determine link status */
@ -631,9 +631,9 @@ smsc_miibus_statchg(device_t dev)
* Returns 0 on success or a negative error code.
*/
static int
smsc_ifmedia_upd(struct ifnet *ifp)
smsc_ifmedia_upd(if_t ifp)
{
struct smsc_softc *sc = ifp->if_softc;
struct smsc_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = uether_getmii(&sc->sc_ue);
struct mii_softc *miisc;
int err;
@ -658,9 +658,9 @@ smsc_ifmedia_upd(struct ifnet *ifp)
* Internally takes and releases the device lock.
*/
static void
smsc_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
smsc_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
{
struct smsc_softc *sc = ifp->if_softc;
struct smsc_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = uether_getmii(&sc->sc_ue);
SMSC_LOCK(sc);
@ -712,12 +712,12 @@ static void
smsc_setmulti(struct usb_ether *ue)
{
struct smsc_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint32_t hashtbl[2] = { 0, 0 };
SMSC_LOCK_ASSERT(sc, MA_OWNED);
if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
if (if_getflags(ifp) & (IFF_ALLMULTI | IFF_PROMISC)) {
smsc_dbg_printf(sc, "receive all multicast enabled\n");
sc->sc_mac_csr |= SMSC_MAC_CSR_MCPAS;
sc->sc_mac_csr &= ~SMSC_MAC_CSR_HPFILT;
@ -761,14 +761,14 @@ static void
smsc_setpromisc(struct usb_ether *ue)
{
struct smsc_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
smsc_dbg_printf(sc, "promiscuous mode %sabled\n",
(ifp->if_flags & IFF_PROMISC) ? "en" : "dis");
(if_getflags(ifp) & IFF_PROMISC) ? "en" : "dis");
SMSC_LOCK_ASSERT(sc, MA_OWNED);
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & IFF_PROMISC)
sc->sc_mac_csr |= SMSC_MAC_CSR_PRMS;
else
sc->sc_mac_csr &= ~SMSC_MAC_CSR_PRMS;
@ -788,7 +788,7 @@ smsc_setpromisc(struct usb_ether *ue)
*/
static int smsc_sethwcsum(struct smsc_softc *sc)
{
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
uint32_t val;
int err;
@ -804,13 +804,13 @@ static int smsc_sethwcsum(struct smsc_softc *sc)
}
/* Enable/disable the Rx checksum */
if ((ifp->if_capabilities & ifp->if_capenable) & IFCAP_RXCSUM)
if ((if_getcapabilities(ifp) & if_getcapenable(ifp)) & IFCAP_RXCSUM)
val |= SMSC_COE_CTRL_RX_EN;
else
val &= ~SMSC_COE_CTRL_RX_EN;
/* Enable/disable the Tx checksum (currently not supported) */
if ((ifp->if_capabilities & ifp->if_capenable) & IFCAP_TXCSUM)
if ((if_getcapabilities(ifp) & if_getcapenable(ifp)) & IFCAP_TXCSUM)
val |= SMSC_COE_CTRL_TX_EN;
else
val &= ~SMSC_COE_CTRL_TX_EN;
@ -901,14 +901,14 @@ static void
smsc_init(struct usb_ether *ue)
{
struct smsc_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
SMSC_LOCK_ASSERT(sc, MA_OWNED);
if (smsc_setmacaddress(sc, IF_LLADDR(ifp)))
if (smsc_setmacaddress(sc, if_getlladdr(ifp)))
smsc_dbg_printf(sc, "setting MAC address failed\n");
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
return;
/* Cancel pending I/O */
@ -926,7 +926,7 @@ smsc_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_xfer[SMSC_BULK_DT_WR]);
/* Indicate we are up and running. */
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
/* Switch to selected media. */
smsc_ifmedia_upd(ifp);
@ -949,7 +949,7 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct smsc_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct mbuf *m;
struct usb_page_cache *pc;
uint32_t rxhdr;
@ -1019,7 +1019,7 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
usbd_copy_out(pc, off, mtod(m, uint8_t *), pktlen);
/* Check if RX TCP/UDP checksumming is being offloaded */
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) {
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0) {
struct ether_header *eh;
eh = mtod(m, struct ether_header *);
@ -1119,7 +1119,7 @@ static void
smsc_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct smsc_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
uint32_t txhdr;
@ -1128,20 +1128,20 @@ smsc_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
if ((sc->sc_flags & SMSC_FLAG_LINK) == 0 ||
(ifp->if_drv_flags & IFF_DRV_OACTIVE) != 0) {
(if_getdrvflags(ifp) & IFF_DRV_OACTIVE) != 0) {
/* Don't send anything if there is no link or controller is busy. */
return;
}
for (nframes = 0; nframes < 16 &&
!IFQ_DRV_IS_EMPTY(&ifp->if_snd); nframes++) {
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
!if_sendq_empty(ifp); nframes++) {
m = if_dequeue(ifp);
if (m == NULL)
break;
usbd_xfer_set_frame_offset(xfer, nframes * MCLBYTES,
@ -1180,13 +1180,13 @@ smsc_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
if (nframes != 0) {
usbd_xfer_set_frames(xfer, nframes);
usbd_transfer_submit(xfer);
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
}
return;
default:
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
if (error != USB_ERR_CANCELLED) {
smsc_err_printf(sc, "usb error on tx: %s\n", usbd_errstr(error));
@ -1252,11 +1252,11 @@ static void
smsc_stop(struct usb_ether *ue)
{
struct smsc_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
SMSC_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
sc->sc_flags &= ~SMSC_FLAG_LINK;
/*
@ -1498,9 +1498,9 @@ smsc_chip_init(struct smsc_softc *sc)
* 0 on success and an error code on failure.
*/
static int
smsc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
smsc_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
struct usb_ether *ue = ifp->if_softc;
struct usb_ether *ue = if_getsoftc(ifp);
struct smsc_softc *sc;
struct ifreq *ifr;
int rc;
@ -1516,15 +1516,15 @@ smsc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
rc = 0;
reinit = 0;
mask = ifr->ifr_reqcap ^ ifp->if_capenable;
mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
/* Modify the RX CSUM enable bits */
if ((mask & IFCAP_RXCSUM) != 0 &&
(ifp->if_capabilities & IFCAP_RXCSUM) != 0) {
ifp->if_capenable ^= IFCAP_RXCSUM;
(if_getcapabilities(ifp) & IFCAP_RXCSUM) != 0) {
if_togglecapenable(ifp, IFCAP_RXCSUM);
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
reinit = 1;
}
}
@ -1614,32 +1614,31 @@ static int
smsc_attach_post_sub(struct usb_ether *ue)
{
struct smsc_softc *sc;
struct ifnet *ifp;
if_t ifp;
int error;
sc = uether_getsc(ue);
ifp = ue->ue_ifp;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_start = uether_start;
ifp->if_ioctl = smsc_ioctl;
ifp->if_init = uether_init;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
IFQ_SET_READY(&ifp->if_snd);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setstartfn(ifp, uether_start);
if_setioctlfn(ifp, smsc_ioctl);
if_setinitfn(ifp, uether_init);
if_setsendqlen(ifp, ifqmaxlen);
if_setsendqready(ifp);
/* The chip supports TCP/UDP checksum offloading on TX and RX paths, however
* currently only RX checksum is supported in the driver (see top of file).
*/
ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_VLAN_MTU;
ifp->if_hwassist = 0;
if_setcapabilitiesbit(ifp, IFCAP_RXCSUM | IFCAP_VLAN_MTU, 0);
if_sethwassist(ifp, 0);
/* TX checksuming is disabled (for now?)
ifp->if_capabilities |= IFCAP_TXCSUM;
ifp->if_capenable |= IFCAP_TXCSUM;
ifp->if_hwassist = CSUM_TCP | CSUM_UDP;
if_setcapabilitiesbit(ifp, IFCAP_TXCSUM, 0);
if_setcapenablebit(ifp, IFCAP_TXCSUM, 0);
if_sethwassist(ifp, CSUM_TCP | CSUM_UDP);
*/
ifp->if_capenable = ifp->if_capabilities;
if_setcapenable(ifp, if_getcapabilities(ifp));
bus_topo_lock();
error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp,

View File

@ -112,8 +112,8 @@ static int udav_csr_write(struct udav_softc *, uint16_t, void *, int);
static uint8_t udav_csr_read1(struct udav_softc *, uint16_t);
static int udav_csr_write1(struct udav_softc *, uint16_t, uint8_t);
static void udav_reset(struct udav_softc *);
static int udav_ifmedia_upd(struct ifnet *);
static void udav_ifmedia_status(struct ifnet *, struct ifmediareq *);
static int udav_ifmedia_upd(if_t);
static void udav_ifmedia_status(if_t, struct ifmediareq *);
static miibus_readreg_t udav_miibus_readreg;
static miibus_writereg_t udav_miibus_writereg;
@ -435,7 +435,7 @@ static void
udav_init(struct usb_ether *ue)
{
struct udav_softc *sc = ue->ue_sc;
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
UDAV_LOCK_ASSERT(sc, MA_OWNED);
@ -445,7 +445,7 @@ udav_init(struct usb_ether *ue)
udav_stop(ue);
/* set MAC address */
udav_csr_write(sc, UDAV_PAR, IF_LLADDR(ifp), ETHER_ADDR_LEN);
udav_csr_write(sc, UDAV_PAR, if_getlladdr(ifp), ETHER_ADDR_LEN);
/* initialize network control register */
@ -467,7 +467,7 @@ udav_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_xfer[UDAV_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
udav_start(ue);
}
@ -518,12 +518,12 @@ static void
udav_setmulti(struct usb_ether *ue)
{
struct udav_softc *sc = ue->ue_sc;
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
UDAV_LOCK_ASSERT(sc, MA_OWNED);
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) {
UDAV_SETBIT(sc, UDAV_RCR, UDAV_RCR_ALL|UDAV_RCR_PRMSC);
return;
}
@ -547,15 +547,15 @@ static void
udav_setpromisc(struct usb_ether *ue)
{
struct udav_softc *sc = ue->ue_sc;
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
uint8_t rxmode;
rxmode = udav_csr_read1(sc, UDAV_RCR);
rxmode &= ~(UDAV_RCR_ALL | UDAV_RCR_PRMSC);
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & IFF_PROMISC)
rxmode |= UDAV_RCR_ALL | UDAV_RCR_PRMSC;
else if (ifp->if_flags & IFF_ALLMULTI)
else if (if_getflags(ifp) & IFF_ALLMULTI)
rxmode |= UDAV_RCR_ALL;
/* write new mode bits */
@ -579,7 +579,7 @@ static void
udav_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct udav_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
int extra_len;
@ -600,7 +600,7 @@ udav_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
*/
return;
}
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
return;
@ -661,7 +661,7 @@ udav_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct udav_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct usb_page_cache *pc;
struct udav_rxpkt stat;
int len;
@ -737,11 +737,11 @@ static void
udav_stop(struct usb_ether *ue)
{
struct udav_softc *sc = ue->ue_sc;
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
UDAV_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
if (!(sc->sc_flags & UDAV_FLAG_NO_PHY))
sc->sc_flags &= ~UDAV_FLAG_LINK;
@ -756,9 +756,9 @@ udav_stop(struct usb_ether *ue)
}
static int
udav_ifmedia_upd(struct ifnet *ifp)
udav_ifmedia_upd(if_t ifp)
{
struct udav_softc *sc = ifp->if_softc;
struct udav_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
struct mii_softc *miisc;
int error;
@ -773,9 +773,9 @@ udav_ifmedia_upd(struct ifnet *ifp)
}
static void
udav_ifmedia_status(struct ifnet *ifp, struct ifmediareq *ifmr)
udav_ifmedia_status(if_t ifp, struct ifmediareq *ifmr)
{
struct udav_softc *sc = ifp->if_softc;
struct udav_softc *sc = if_getsoftc(ifp);
struct mii_data *mii = GET_MII(sc);
UDAV_LOCK(sc);

View File

@ -154,12 +154,12 @@ static int ure_sysctl_chipver(SYSCTL_HANDLER_ARGS);
static void ure_read_chipver(struct ure_softc *);
static int ure_attach_post_sub(struct usb_ether *);
static void ure_reset(struct ure_softc *);
static int ure_ifmedia_upd(struct ifnet *);
static void ure_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static int ure_ifmedia_upd(if_t);
static void ure_ifmedia_sts(if_t, struct ifmediareq *);
static void ure_add_media_types(struct ure_softc *);
static void ure_link_state(struct ure_softc *sc);
static int ure_get_link_status(struct ure_softc *);
static int ure_ioctl(struct ifnet *, u_long, caddr_t);
static int ure_ioctl(if_t, u_long, caddr_t);
static void ure_rtl8152_init(struct ure_softc *);
static void ure_rtl8152_nic_reset(struct ure_softc *);
static void ure_rtl8153_init(struct ure_softc *);
@ -438,7 +438,7 @@ ure_miibus_statchg(device_t dev)
{
struct ure_softc *sc;
struct mii_data *mii;
struct ifnet *ifp;
if_t ifp;
int locked;
sc = device_get_softc(dev);
@ -449,7 +449,7 @@ ure_miibus_statchg(device_t dev)
ifp = uether_getifp(&sc->sc_ue);
if (mii == NULL || ifp == NULL ||
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
(if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
goto done;
sc->sc_flags &= ~URE_FLAG_LINK;
@ -636,7 +636,7 @@ ure_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct ure_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct usb_page_cache *pc;
struct mbuf *m;
struct ure_rxpkt pkt;
@ -741,7 +741,7 @@ static void
ure_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct ure_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct usb_page_cache *pc;
struct mbuf *m;
struct ure_txpkt txpkt;
@ -753,7 +753,7 @@ ure_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
DPRINTFN(11, "transfer complete\n");
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
/* FALLTHROUGH */
case USB_ST_SETUP:
@ -769,7 +769,7 @@ ure_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
pos = 0;
rem = URE_TX_BUFSZ;
while (rem > sizeof(txpkt)) {
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
break;
@ -790,7 +790,7 @@ ure_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
if (sizeof(txpkt) +
roundup(len, URE_TXPKT_ALIGN) > rem) {
/* out of space */
IFQ_DRV_PREPEND(&ifp->if_snd, m);
if_sendq_prepend(ifp, m);
m = NULL;
break;
}
@ -852,7 +852,7 @@ ure_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
usbd_errstr(error));
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
if (error == USB_ERR_TIMEOUT) {
DEVPRINTFN(12, sc->sc_ue.ue_dev,
@ -988,22 +988,21 @@ ure_attach_post_sub(struct usb_ether *ue)
struct sysctl_ctx_list *sctx;
struct sysctl_oid *soid;
struct ure_softc *sc;
struct ifnet *ifp;
if_t ifp;
int error;
sc = uether_getsc(ue);
ifp = ue->ue_ifp;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_start = uether_start;
ifp->if_ioctl = ure_ioctl;
ifp->if_init = uether_init;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setstartfn(ifp, uether_start);
if_setioctlfn(ifp, ure_ioctl);
if_setinitfn(ifp, uether_init);
/*
* Try to keep two transfers full at a time.
* ~(TRANSFER_SIZE / 80 bytes/pkt * 2 buffers in flight)
*/
ifp->if_snd.ifq_drv_maxlen = 512;
IFQ_SET_READY(&ifp->if_snd);
if_setsendqlen(ifp, 512);
if_setsendqready(ifp);
if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0);
if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWTAGGING, 0);
@ -1044,13 +1043,13 @@ static void
ure_init(struct usb_ether *ue)
{
struct ure_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint16_t cpcr;
uint32_t reg;
URE_LOCK_ASSERT(sc, MA_OWNED);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
return;
/* Cancel pending I/O. */
@ -1064,7 +1063,7 @@ ure_init(struct usb_ether *ue)
/* Set MAC address. */
ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG);
ure_write_mem(sc, URE_PLA_IDR, URE_MCU_TYPE_PLA | URE_BYTE_EN_SIX_BYTES,
IF_LLADDR(ifp), 8);
if_getlladdr(ifp), 8);
ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML);
/* Set RX EARLY timeout and size */
@ -1134,7 +1133,7 @@ ure_init(struct usb_ether *ue)
usbd_xfer_set_stall(sc->sc_tx_xfer[0]);
/* Indicate we are up and running. */
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
/* Switch to selected media. */
ure_ifmedia_upd(ifp);
@ -1144,7 +1143,7 @@ static void
ure_tick(struct usb_ether *ue)
{
struct ure_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
struct mii_data *mii;
URE_LOCK_ASSERT(sc, MA_OWNED);
@ -1193,7 +1192,7 @@ static void
ure_rxfilter(struct usb_ether *ue)
{
struct ure_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
uint32_t rxmode;
uint32_t h, hashes[2] = { 0, 0 };
@ -1203,8 +1202,8 @@ ure_rxfilter(struct usb_ether *ue)
rxmode &= ~(URE_RCR_AAP | URE_RCR_AM);
rxmode |= URE_RCR_APM; /* accept physical match packets */
rxmode |= URE_RCR_AB; /* always accept broadcasts */
if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
if (ifp->if_flags & IFF_PROMISC)
if (if_getflags(ifp) & (IFF_ALLMULTI | IFF_PROMISC)) {
if (if_getflags(ifp) & IFF_PROMISC)
rxmode |= URE_RCR_AAP;
rxmode |= URE_RCR_AM;
hashes[0] = hashes[1] = 0xffffffff;
@ -1266,9 +1265,9 @@ ure_reset(struct ure_softc *sc)
* Set media options.
*/
static int
ure_ifmedia_upd(struct ifnet *ifp)
ure_ifmedia_upd(if_t ifp)
{
struct ure_softc *sc = ifp->if_softc;
struct ure_softc *sc = if_getsoftc(ifp);
struct ifmedia *ifm;
struct mii_data *mii;
struct mii_softc *miisc;
@ -1300,20 +1299,20 @@ ure_ifmedia_upd(struct ifnet *ifp)
anar |= ANAR_TX_FD | ANAR_TX | ANAR_10_FD | ANAR_10;
gig |= GTCR_ADV_1000TFDX | GTCR_ADV_1000THDX;
reg |= URE_ADV_2500TFDX;
ifp->if_baudrate = IF_Mbps(2500);
if_setbaudrate(ifp, IF_Mbps(2500));
break;
case IFM_1000_T:
anar |= ANAR_TX_FD | ANAR_TX | ANAR_10_FD | ANAR_10;
gig |= GTCR_ADV_1000TFDX | GTCR_ADV_1000THDX;
ifp->if_baudrate = IF_Gbps(1);
if_setbaudrate(ifp, IF_Gbps(1));
break;
case IFM_100_TX:
anar |= ANAR_TX | ANAR_TX_FD;
ifp->if_baudrate = IF_Mbps(100);
if_setbaudrate(ifp, IF_Mbps(100));
break;
case IFM_10_T:
anar |= ANAR_10 | ANAR_10_FD;
ifp->if_baudrate = IF_Mbps(10);
if_setbaudrate(ifp, IF_Mbps(10));
break;
default:
device_printf(sc->sc_ue.ue_dev, "unsupported media type\n");
@ -1346,13 +1345,13 @@ ure_ifmedia_upd(struct ifnet *ifp)
* Report current media status.
*/
static void
ure_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
ure_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
{
struct ure_softc *sc;
struct mii_data *mii;
uint16_t status;
sc = ifp->if_softc;
sc = if_getsoftc(ifp);
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) {
URE_LOCK(sc);
ifmr->ifm_status = IFM_AVALID;
@ -1401,10 +1400,10 @@ ure_add_media_types(struct ure_softc *sc)
static void
ure_link_state(struct ure_softc *sc)
{
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
if (ure_get_link_status(sc)) {
if (ifp->if_link_state != LINK_STATE_UP) {
if (if_getlinkstate(ifp) != LINK_STATE_UP) {
if_link_state_change(ifp, LINK_STATE_UP);
/* Enable transmit and receive. */
URE_SETBIT_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, URE_CR_RE | URE_CR_TE);
@ -1416,7 +1415,7 @@ ure_link_state(struct ure_softc *sc)
URE_SETBIT_2(sc, URE_PLA_MAC_PWR_CTRL4, URE_MCU_TYPE_PLA, 0x40);
}
} else {
if (ifp->if_link_state != LINK_STATE_DOWN) {
if (if_getlinkstate(ifp) != LINK_STATE_DOWN) {
if_link_state_change(ifp, LINK_STATE_DOWN);
}
}
@ -1436,9 +1435,9 @@ ure_get_link_status(struct ure_softc *sc)
}
static int
ure_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
ure_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
struct usb_ether *ue = ifp->if_softc;
struct usb_ether *ue = if_getsoftc(ifp);
struct ure_softc *sc;
struct ifreq *ifr;
int error, mask, reinit;
@ -1450,30 +1449,30 @@ ure_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
switch (cmd) {
case SIOCSIFCAP:
URE_LOCK(sc);
mask = ifr->ifr_reqcap ^ ifp->if_capenable;
mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
if ((mask & IFCAP_VLAN_HWTAGGING) != 0 &&
(ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) != 0) {
ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
(if_getcapabilities(ifp) & IFCAP_VLAN_HWTAGGING) != 0) {
if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING);
reinit++;
}
if ((mask & IFCAP_TXCSUM) != 0 &&
(ifp->if_capabilities & IFCAP_TXCSUM) != 0) {
ifp->if_capenable ^= IFCAP_TXCSUM;
(if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
if_togglecapenable(ifp, IFCAP_TXCSUM);
}
if ((mask & IFCAP_RXCSUM) != 0 &&
(ifp->if_capabilities & IFCAP_RXCSUM) != 0) {
ifp->if_capenable ^= IFCAP_RXCSUM;
(if_getcapabilities(ifp) & IFCAP_RXCSUM) != 0) {
if_togglecapenable(ifp, IFCAP_RXCSUM);
}
if ((mask & IFCAP_TXCSUM_IPV6) != 0 &&
(ifp->if_capabilities & IFCAP_TXCSUM_IPV6) != 0) {
ifp->if_capenable ^= IFCAP_TXCSUM_IPV6;
(if_getcapabilities(ifp) & IFCAP_TXCSUM_IPV6) != 0) {
if_togglecapenable(ifp, IFCAP_TXCSUM_IPV6);
}
if ((mask & IFCAP_RXCSUM_IPV6) != 0 &&
(ifp->if_capabilities & IFCAP_RXCSUM_IPV6) != 0) {
ifp->if_capenable ^= IFCAP_RXCSUM_IPV6;
(if_getcapabilities(ifp) & IFCAP_RXCSUM_IPV6) != 0) {
if_togglecapenable(ifp, IFCAP_RXCSUM_IPV6);
}
if (reinit > 0 && ifp->if_drv_flags & IFF_DRV_RUNNING)
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if (reinit > 0 && if_getdrvflags(ifp) & IFF_DRV_RUNNING)
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
else
reinit = 0;
URE_UNLOCK(sc);
@ -1852,7 +1851,7 @@ ure_rtl8153b_init(struct ure_softc *sc)
static void
ure_rtl8153b_nic_reset(struct ure_softc *sc)
{
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
uint16_t val;
int i;
@ -1907,7 +1906,7 @@ ure_rtl8153b_nic_reset(struct ure_softc *sc)
/* Configure rxvlan */
val = ure_read_2(sc, 0xc012, URE_MCU_TYPE_PLA);
val &= ~0x00c0;
if (ifp->if_capabilities & IFCAP_VLAN_HWTAGGING)
if (if_getcapabilities(ifp) & IFCAP_VLAN_HWTAGGING)
val |= 0x00c0;
ure_write_2(sc, 0xc012, URE_MCU_TYPE_PLA, val);
@ -1974,11 +1973,11 @@ static void
ure_stop(struct usb_ether *ue)
{
struct ure_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
URE_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
sc->sc_flags &= ~URE_FLAG_LINK;
sc->sc_rxstarted = 0;

View File

@ -369,11 +369,11 @@ static void
urndis_init(struct usb_ether *ue)
{
struct urndis_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
URNDIS_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
/* stall data write direction, which depends on USB mode */
usbd_xfer_set_stall(sc->sc_xfer[URNDIS_BULK_TX]);
@ -386,11 +386,11 @@ static void
urndis_stop(struct usb_ether *ue)
{
struct urndis_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
if_t ifp = uether_getifp(ue);
URNDIS_LOCK_ASSERT(sc, MA_OWNED);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
/*
* stop all the transfers, if not already stopped:
@ -818,7 +818,7 @@ urndis_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct urndis_softc *sc = usbd_xfer_softc(xfer);
struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, 0);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct rndis_packet_msg msg;
struct mbuf *m;
int actlen;
@ -947,7 +947,7 @@ urndis_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct rndis_packet_msg msg;
struct urndis_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
if_t ifp = uether_getifp(&sc->sc_ue);
struct mbuf *m;
unsigned x;
int actlen;
@ -974,7 +974,7 @@ urndis_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
usbd_xfer_set_frame_offset(xfer, x * RNDIS_TX_MAXLEN, x);
next_pkt:
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
break;

View File

@ -128,12 +128,12 @@ static void usie_if_sync_to(void *);
static void usie_if_sync_cb(void *, int);
static void usie_if_status_cb(void *, int);
static void usie_if_start(struct ifnet *);
static int usie_if_output(struct ifnet *, struct mbuf *,
static void usie_if_start(if_t);
static int usie_if_output(if_t, struct mbuf *,
const struct sockaddr *, struct route *);
static void usie_if_init(void *);
static void usie_if_stop(struct usie_softc *);
static int usie_if_ioctl(struct ifnet *, u_long, caddr_t);
static int usie_if_ioctl(if_t, u_long, caddr_t);
static int usie_do_request(struct usie_softc *, struct usb_device_request *, void *);
static int usie_if_cmd(struct usie_softc *, uint8_t);
@ -295,7 +295,7 @@ usie_attach(device_t self)
{
struct usie_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
struct ifnet *ifp;
if_t ifp;
struct usb_interface *iface;
struct usb_interface_descriptor *id;
struct usb_device_request req;
@ -440,16 +440,15 @@ usie_attach(device_t self)
}
if_initname(ifp, "usie", device_get_unit(self));
ifp->if_softc = sc;
ifp->if_mtu = USIE_MTU_MAX;
ifp->if_flags |= IFF_NOARP;
ifp->if_init = usie_if_init;
ifp->if_ioctl = usie_if_ioctl;
ifp->if_start = usie_if_start;
ifp->if_output = usie_if_output;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
IFQ_SET_READY(&ifp->if_snd);
if_setsoftc(ifp, sc);
if_setmtu(ifp, USIE_MTU_MAX);
if_setflagbits(ifp, IFF_NOARP, 0);
if_setinitfn(ifp, usie_if_init);
if_setioctlfn(ifp, usie_if_ioctl);
if_setstartfn(ifp, usie_if_start);
if_setoutputfn(ifp, usie_if_output);
if_setsendqlen(ifp, ifqmaxlen);
if_setsendqready(ifp);
if_attach(ifp);
bpfattach(ifp, DLT_RAW, 0);
@ -772,7 +771,7 @@ usie_if_rx_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct epoch_tracker et;
struct usie_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
if_t ifp = sc->sc_ifp;
struct mbuf *m0;
struct mbuf *m = NULL;
struct usie_desc *rxd;
@ -930,24 +929,24 @@ usie_if_tx_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct usie_softc *sc = usbd_xfer_softc(xfer);
struct usb_page_cache *pc;
struct ifnet *ifp = sc->sc_ifp;
if_t ifp = sc->sc_ifp;
struct mbuf *m;
uint16_t size;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
DPRINTFN(11, "transfer complete\n");
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
/* fall though */
case USB_ST_SETUP:
tr_setup:
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
break;
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
break;
@ -1064,7 +1063,7 @@ static void
usie_if_status_cb(void *arg, int pending)
{
struct usie_softc *sc = arg;
struct ifnet *ifp = sc->sc_ifp;
if_t ifp = sc->sc_ifp;
struct usb_device_request req;
struct usie_hip *hip;
struct usie_lsi *lsi;
@ -1143,8 +1142,8 @@ usie_if_status_cb(void *arg, int pending)
memcpy(&sc->sc_net.dns2_addr, &lsi->dns2_addr, 16);
memcpy(sc->sc_net.pdp_addr, lsi->pdp_addr, 16);
memcpy(sc->sc_net.gw_addr, lsi->gw_addr, 16);
ifp->if_flags |= IFF_UP;
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setflagbits(ifp, IFF_UP, 0);
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
device_printf(sc->sc_dev, "IP Addr=%d.%d.%d.%d\n",
*lsi->pdp_addr, *(lsi->pdp_addr + 1),
@ -1174,11 +1173,11 @@ usie_if_status_cb(void *arg, int pending)
}
static void
usie_if_start(struct ifnet *ifp)
usie_if_start(if_t ifp)
{
struct usie_softc *sc = ifp->if_softc;
struct usie_softc *sc = if_getsoftc(ifp);
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
DPRINTF("Not running\n");
return;
}
@ -1190,7 +1189,7 @@ usie_if_start(struct ifnet *ifp)
}
static int
usie_if_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
usie_if_output(if_t ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
{
int err;
@ -1216,7 +1215,7 @@ usie_if_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
return (EAFNOSUPPORT);
}
err = (ifp->if_transmit)(ifp, m);
err = if_transmit(ifp, m);
if (err) {
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
return (ENOBUFS);
@ -1230,7 +1229,7 @@ static void
usie_if_init(void *arg)
{
struct usie_softc *sc = arg;
struct ifnet *ifp = sc->sc_ifp;
if_t ifp = sc->sc_ifp;
uint8_t i;
mtx_lock(&sc->sc_mtx);
@ -1248,7 +1247,7 @@ usie_if_init(void *arg)
usbd_transfer_start(sc->sc_if_xfer[USIE_IF_RX]);
/* if not running, initiate the modem */
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))
usie_cns_req(sc, USIE_CNS_ID_INIT, USIE_CNS_OB_LINK_UPDATE);
mtx_unlock(&sc->sc_mtx);
@ -1277,26 +1276,26 @@ usie_if_stop(struct usie_softc *sc)
}
static int
usie_if_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
usie_if_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
struct usie_softc *sc = ifp->if_softc;
struct usie_softc *sc = if_getsoftc(ifp);
struct ieee80211req *ireq;
struct ieee80211req_sta_info si;
struct ifmediareq *ifmr;
switch (cmd) {
case SIOCSIFFLAGS:
if (ifp->if_flags & IFF_UP) {
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
if (if_getflags(ifp) & IFF_UP) {
if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))
usie_if_init(sc);
} else {
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
usie_if_stop(sc);
}
break;
case SIOCSIFCAP:
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
device_printf(sc->sc_dev,
"Connect to the network first.\n");
break;
@ -1387,7 +1386,7 @@ usie_if_cmd(struct usie_softc *sc, uint8_t cmd)
static void
usie_cns_req(struct usie_softc *sc, uint32_t id, uint16_t obj)
{
struct ifnet *ifp = sc->sc_ifp;
if_t ifp = sc->sc_ifp;
struct mbuf *m;
struct usb_xfer *xfer;
struct usie_hip *hip;
@ -1469,7 +1468,7 @@ usie_cns_req(struct usie_softc *sc, uint32_t id, uint16_t obj)
static void
usie_cns_rsp(struct usie_softc *sc, struct usie_cns *cns)
{
struct ifnet *ifp = sc->sc_ifp;
if_t ifp = sc->sc_ifp;
DPRINTF("received CnS\n");
@ -1478,9 +1477,9 @@ usie_cns_rsp(struct usie_softc *sc, struct usie_cns *cns)
if (be32toh(cns->id) & USIE_CNS_ID_INIT)
usie_if_sync_to(sc);
else if (be32toh(cns->id) & USIE_CNS_ID_STOP) {
ifp->if_flags &= ~IFF_UP;
ifp->if_drv_flags &=
~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
if_setflagbits(ifp, 0, IFF_UP);
if_setdrvflagbits(ifp, 0,
IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
} else
DPRINTF("undefined link update\n");
break;

View File

@ -229,7 +229,7 @@ struct usie_softc {
struct usb_xfer *sc_uc_xfer[USIE_UCOM_MAX][USIE_UC_N_XFER];
struct usb_xfer *sc_if_xfer[USIE_IF_N_XFER];
struct ifnet *sc_ifp;
if_t sc_ifp;
struct usb_device *sc_udev;
device_t sc_dev;

View File

@ -95,7 +95,7 @@ struct uhso_softc {
/* Network */
struct usb_xfer *sc_if_xfer[2];
struct ifnet *sc_ifp;
if_t sc_ifp;
struct mbuf *sc_mwait; /* Partial packet */
size_t sc_waitlen; /* No. of outstanding bytes */
struct mbufq sc_rxq;
@ -470,10 +470,10 @@ static void uhso_ucom_cfg_get_status(struct ucom_softc *, uint8_t *, uint8_t *);
static void uhso_ucom_cfg_set_dtr(struct ucom_softc *, uint8_t);
static void uhso_ucom_cfg_set_rts(struct ucom_softc *, uint8_t);
static void uhso_if_init(void *);
static void uhso_if_start(struct ifnet *);
static void uhso_if_start(if_t);
static void uhso_if_stop(struct uhso_softc *);
static int uhso_if_ioctl(struct ifnet *, u_long, caddr_t);
static int uhso_if_output(struct ifnet *, struct mbuf *,
static int uhso_if_ioctl(if_t, u_long, caddr_t);
static int uhso_if_output(if_t, struct mbuf *,
const struct sockaddr *, struct route *);
static void uhso_if_rxflush(void *);
@ -687,7 +687,7 @@ uhso_detach(device_t self)
if (sc->sc_ifp != NULL) {
callout_drain(&sc->sc_c);
free_unr(uhso_ifnet_unit, sc->sc_ifp->if_dunit);
free_unr(uhso_ifnet_unit, if_getdunit(sc->sc_ifp));
mtx_lock(&sc->sc_mtx);
uhso_if_stop(sc);
mtx_unlock(&sc->sc_mtx);
@ -1552,7 +1552,7 @@ uhso_ucom_stop_write(struct ucom_softc *ucom)
static int
uhso_attach_ifnet(struct uhso_softc *sc, struct usb_interface *iface, int type)
{
struct ifnet *ifp;
if_t ifp;
usb_error_t uerr;
struct sysctl_ctx_list *sctx;
struct sysctl_oid *soid;
@ -1586,16 +1586,15 @@ uhso_attach_ifnet(struct uhso_softc *sc, struct usb_interface *iface, int type)
devunit = alloc_unr(uhso_ifnet_unit);
if_initname(ifp, device_get_name(sc->sc_dev), devunit);
ifp->if_mtu = UHSO_MAX_MTU;
ifp->if_ioctl = uhso_if_ioctl;
ifp->if_init = uhso_if_init;
ifp->if_start = uhso_if_start;
ifp->if_output = uhso_if_output;
ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_NOARP;
ifp->if_softc = sc;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
IFQ_SET_READY(&ifp->if_snd);
if_setmtu(ifp, UHSO_MAX_MTU);
if_setioctlfn(ifp, uhso_if_ioctl);
if_setinitfn(ifp, uhso_if_init);
if_setstartfn(ifp, uhso_if_start);
if_setoutputfn(ifp, uhso_if_output);
if_setflags(ifp, IFF_BROADCAST | IFF_MULTICAST | IFF_NOARP);
if_setsoftc(ifp, sc);
if_setsendqlen(ifp, ifqmaxlen);
if_setsendqready(ifp);
if_attach(ifp);
bpfattach(ifp, DLT_RAW, 0);
@ -1603,8 +1602,8 @@ uhso_attach_ifnet(struct uhso_softc *sc, struct usb_interface *iface, int type)
sctx = device_get_sysctl_ctx(sc->sc_dev);
soid = device_get_sysctl_tree(sc->sc_dev);
/* Unlocked read... */
SYSCTL_ADD_STRING(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "netif",
CTLFLAG_RD, ifp->if_xname, 0, "Attached network interface");
SYSCTL_ADD_CONST_STRING(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "netif",
CTLFLAG_RD, if_name(ifp), "Attached network interface");
return (0);
}
@ -1623,7 +1622,7 @@ uhso_ifnet_read_callback(struct usb_xfer *xfer, usb_error_t error)
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
if (actlen > 0 && (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)) {
if (actlen > 0 && (if_getdrvflags(sc->sc_ifp) & IFF_DRV_RUNNING)) {
pc = usbd_xfer_get_frame(xfer, 0);
if (mbufq_full(&sc->sc_rxq))
break;
@ -1664,7 +1663,7 @@ uhso_if_rxflush(void *arg)
{
struct epoch_tracker et;
struct uhso_softc *sc = arg;
struct ifnet *ifp = sc->sc_ifp;
if_t ifp = sc->sc_ifp;
uint8_t *cp;
struct mbuf *m, *m0, *mwait;
struct ip *ip;
@ -1782,7 +1781,7 @@ uhso_if_rxflush(void *arg)
/* Dispatch to IP layer */
BPF_MTAP(sc->sc_ifp, m);
M_SETFIB(m, ifp->if_fib);
M_SETFIB(m, if_getfib(ifp));
netisr_dispatch(isr, m);
m = m0 != NULL ? m0 : NULL;
mtx_lock(&sc->sc_mtx);
@ -1795,7 +1794,7 @@ static void
uhso_ifnet_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct uhso_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
if_t ifp = sc->sc_ifp;
struct usb_page_cache *pc;
struct mbuf *m;
int actlen;
@ -1807,14 +1806,14 @@ uhso_ifnet_write_callback(struct usb_xfer *xfer, usb_error_t error)
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
case USB_ST_SETUP:
tr_setup:
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
m = if_dequeue(ifp);
if (m == NULL)
break;
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
if (m->m_pkthdr.len > MCLBYTES)
m->m_pkthdr.len = MCLBYTES;
@ -1837,21 +1836,21 @@ uhso_ifnet_write_callback(struct usb_xfer *xfer, usb_error_t error)
}
static int
uhso_if_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
uhso_if_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
struct uhso_softc *sc;
sc = ifp->if_softc;
sc = if_getsoftc(ifp);
switch (cmd) {
case SIOCSIFFLAGS:
if (ifp->if_flags & IFF_UP) {
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
if (if_getflags(ifp) & IFF_UP) {
if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
uhso_if_init(sc);
}
}
else {
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
mtx_lock(&sc->sc_mtx);
uhso_if_stop(sc);
mtx_unlock(&sc->sc_mtx);
@ -1872,20 +1871,20 @@ static void
uhso_if_init(void *priv)
{
struct uhso_softc *sc = priv;
struct ifnet *ifp = sc->sc_ifp;
if_t ifp = sc->sc_ifp;
mtx_lock(&sc->sc_mtx);
uhso_if_stop(sc);
ifp = sc->sc_ifp;
ifp->if_flags |= IFF_UP;
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_setflagbits(ifp, IFF_UP, 0);
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
mtx_unlock(&sc->sc_mtx);
UHSO_DPRINTF(2, "ifnet initialized\n");
}
static int
uhso_if_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
uhso_if_output(if_t ifp, struct mbuf *m0, const struct sockaddr *dst,
struct route *ro)
{
int error;
@ -1899,7 +1898,7 @@ uhso_if_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
return (EAFNOSUPPORT);
}
error = (ifp->if_transmit)(ifp, m0);
error = if_transmit(ifp, m0);
if (error) {
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
return (ENOBUFS);
@ -1909,11 +1908,11 @@ uhso_if_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
}
static void
uhso_if_start(struct ifnet *ifp)
uhso_if_start(if_t ifp)
{
struct uhso_softc *sc = ifp->if_softc;
struct uhso_softc *sc = if_getsoftc(ifp);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) {
UHSO_DPRINTF(1, "Not running\n");
return;
}
@ -1931,5 +1930,5 @@ uhso_if_stop(struct uhso_softc *sc)
usbd_transfer_stop(sc->sc_if_xfer[UHSO_IFNET_READ]);
usbd_transfer_stop(sc->sc_if_xfer[UHSO_IFNET_WRITE]);
sc->sc_ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
if_setdrvflagbits(sc->sc_ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
}

View File

@ -68,11 +68,11 @@
static void usbpf_init(void *);
static void usbpf_uninit(void *);
static int usbpf_ioctl(struct ifnet *, u_long, caddr_t);
static int usbpf_ioctl(if_t, u_long, caddr_t);
static int usbpf_clone_match(struct if_clone *, const char *);
static int usbpf_clone_create(struct if_clone *, char *, size_t,
struct ifc_data *, struct ifnet **);
static int usbpf_clone_destroy(struct if_clone *, struct ifnet *, uint32_t);
struct ifc_data *, if_t *);
static int usbpf_clone_destroy(struct if_clone *, if_t, uint32_t);
static struct usb_bus *usbpf_ifname2ubus(const char *);
static uint32_t usbpf_aggregate_xferflags(struct usb_xfer_flags *);
static uint32_t usbpf_aggregate_status(struct usb_xfer_flags_int *);
@ -124,7 +124,7 @@ usbpf_uninit(void *arg)
}
static int
usbpf_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
usbpf_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
/* No configuration allowed. */
@ -170,11 +170,11 @@ usbpf_clone_match(struct if_clone *ifc, const char *name)
static int
usbpf_clone_create(struct if_clone *ifc, char *name, size_t len,
struct ifc_data *ifd, struct ifnet **ifpp)
struct ifc_data *ifd, if_t *ifpp)
{
int error;
int unit;
struct ifnet *ifp;
if_t ifp;
struct usb_bus *ubus;
error = ifc_name2unit(name, &unit);
@ -202,13 +202,12 @@ usbpf_clone_create(struct if_clone *ifc, char *name, size_t len,
"instance\n");
return (ENOSPC);
}
strlcpy(ifp->if_xname, name, sizeof(ifp->if_xname));
ifp->if_softc = ubus;
ifp->if_dname = usbusname;
ifp->if_dunit = unit;
ifp->if_ioctl = usbpf_ioctl;
if_setsoftc(ifp, ubus);
if_initname(ifp, usbusname, unit);
if_setname(ifp, name);
if_setioctlfn(ifp, usbpf_ioctl);
if_attach(ifp);
ifp->if_flags |= IFF_UP;
if_setflagbits(ifp, IFF_UP, 0);
rt_ifmsg(ifp, IFF_UP);
/*
* XXX According to the specification of DLT_USB, it indicates
@ -222,13 +221,13 @@ usbpf_clone_create(struct if_clone *ifc, char *name, size_t len,
}
static int
usbpf_clone_destroy(struct if_clone *ifc, struct ifnet *ifp, uint32_t flags)
usbpf_clone_destroy(struct if_clone *ifc, if_t ifp, uint32_t flags)
{
struct usb_bus *ubus;
int unit;
ubus = ifp->if_softc;
unit = ifp->if_dunit;
ubus = if_getsoftc(ifp);
unit = if_getdunit(ifp);
/*
* Lock USB before clearing the "ifp" pointer, to avoid
@ -410,9 +409,9 @@ usbpf_xfertap(struct usb_xfer *xfer, int type)
bus = xfer->xroot->bus;
/* sanity checks */
if (bus->ifp == NULL || bus->ifp->if_bpf == NULL)
if (bus->ifp == NULL || if_getbpf(bus->ifp) == NULL)
return;
if (!bpf_peers_present(bus->ifp->if_bpf))
if (!bpf_peers_present(if_getbpf(bus->ifp)))
return;
totlen = usbpf_xfer_precompute_size(xfer, type);
@ -535,7 +534,7 @@ usbpf_xfertap(struct usb_xfer *xfer, int type)
}
}
bpf_tap(bus->ifp->if_bpf, buf, totlen);
bpf_tap_if(bus->ifp, buf, totlen);
free(buf, M_TEMP);
}

View File

@ -684,7 +684,7 @@ rsu_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
struct rsu_softc *sc = ic->ic_softc;
struct rsu_vap *uvp;
struct ieee80211vap *vap;
struct ifnet *ifp;
if_t ifp;
if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */
return (NULL);
@ -700,10 +700,10 @@ rsu_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
}
ifp = vap->iv_ifp;
ifp->if_capabilities = IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6;
if_setcapabilities(ifp, IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6);
RSU_LOCK(sc);
if (sc->sc_rx_checksum_enable)
ifp->if_capenable |= IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6;
if_setcapenablebit(ifp, IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6, 0);
RSU_UNLOCK(sc);
/* override state transition machine */
@ -3036,11 +3036,11 @@ rsu_ioctl_net(struct ieee80211com *ic, u_long cmd, void *data)
IEEE80211_LOCK(ic); /* XXX */
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
struct ifnet *ifp = vap->iv_ifp;
if_t ifp = vap->iv_ifp;
ifp->if_capenable &=
~(IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6);
ifp->if_capenable |= rxmask;
if_setcapenablebit(ifp, 0,
IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6);
if_setcapenablebit(ifp, rxmask, 0);
}
IEEE80211_UNLOCK(ic);
break;

View File

@ -414,7 +414,7 @@ static void run_get_txpower(struct run_softc *);
static int run_read_eeprom(struct run_softc *);
static struct ieee80211_node *run_node_alloc(struct ieee80211vap *,
const uint8_t mac[IEEE80211_ADDR_LEN]);
static int run_media_change(struct ifnet *);
static int run_media_change(if_t);
static int run_newstate(struct ieee80211vap *, enum ieee80211_state, int);
static int run_wme_update(struct ieee80211com *);
static void run_key_set_cb(void *);
@ -2116,9 +2116,9 @@ run_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN])
}
static int
run_media_change(struct ifnet *ifp)
run_media_change(if_t ifp)
{
struct ieee80211vap *vap = ifp->if_softc;
struct ieee80211vap *vap = if_getsoftc(ifp);
struct ieee80211com *ic = vap->iv_ic;
const struct ieee80211_txparam *tp;
struct run_softc *sc = ic->ic_softc;
@ -2154,8 +2154,8 @@ run_media_change(struct ifnet *ifp)
}
#if 0
if ((ifp->if_flags & IFF_UP) &&
(ifp->if_drv_flags & RUN_RUNNING)){
if ((if_getflags(ifp) & IFF_UP) &&
(if_getdrvflags(ifp) & RUN_RUNNING)){
run_init_locked(sc);
}
#endif

View File

@ -2192,7 +2192,7 @@ upgt_tx_start(struct upgt_softc *sc, struct mbuf *m, struct ieee80211_node *ni,
* will stall. It's strange, but it works, so we keep reading
* the statistics here. *shrug*
*/
if (!(vap->iv_ifp->if_get_counter(vap->iv_ifp, IFCOUNTER_OPACKETS) %
if (!(if_getcounter(vap->iv_ifp, IFCOUNTER_OPACKETS) %
UPGT_TX_STAT_INTERVAL))
upgt_get_stats(sc);