Mechanically convert age(4), alc(4), and ale(4) to IfAPI
Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37787
This commit is contained in:
parent
bc14c73b7b
commit
5243641267
@ -104,8 +104,8 @@ static struct age_dev {
|
||||
static int age_miibus_readreg(device_t, int, int);
|
||||
static int age_miibus_writereg(device_t, int, int, int);
|
||||
static void age_miibus_statchg(device_t);
|
||||
static void age_mediastatus(struct ifnet *, struct ifmediareq *);
|
||||
static int age_mediachange(struct ifnet *);
|
||||
static void age_mediastatus(if_t, struct ifmediareq *);
|
||||
static int age_mediachange(if_t);
|
||||
static int age_probe(device_t);
|
||||
static void age_get_macaddr(struct age_softc *);
|
||||
static void age_phy_reset(struct age_softc *);
|
||||
@ -121,10 +121,10 @@ static void age_setwol(struct age_softc *);
|
||||
static int age_suspend(device_t);
|
||||
static int age_resume(device_t);
|
||||
static int age_encap(struct age_softc *, struct mbuf **);
|
||||
static void age_start(struct ifnet *);
|
||||
static void age_start_locked(struct ifnet *);
|
||||
static void age_start(if_t);
|
||||
static void age_start_locked(if_t);
|
||||
static void age_watchdog(struct age_softc *);
|
||||
static int age_ioctl(struct ifnet *, u_long, caddr_t);
|
||||
static int age_ioctl(if_t, u_long, caddr_t);
|
||||
static void age_mac_config(struct age_softc *);
|
||||
static void age_link_task(void *, int);
|
||||
static void age_stats_update(struct age_softc *);
|
||||
@ -146,7 +146,7 @@ static void age_init_rr_ring(struct age_softc *);
|
||||
static void age_init_cmb_block(struct age_softc *);
|
||||
static void age_init_smb_block(struct age_softc *);
|
||||
#ifndef __NO_STRICT_ALIGNMENT
|
||||
static struct mbuf *age_fixup_rx(struct ifnet *, struct mbuf *);
|
||||
static struct mbuf *age_fixup_rx(if_t, struct mbuf *);
|
||||
#endif
|
||||
static int age_newbuf(struct age_softc *, struct age_rxdesc *);
|
||||
static void age_rxvlan(struct age_softc *);
|
||||
@ -276,12 +276,12 @@ age_miibus_statchg(device_t dev)
|
||||
* Get the current interface media status.
|
||||
*/
|
||||
static void
|
||||
age_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
age_mediastatus(if_t ifp, struct ifmediareq *ifmr)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
AGE_LOCK(sc);
|
||||
mii = device_get_softc(sc->age_miibus);
|
||||
|
||||
@ -295,14 +295,14 @@ age_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
* Set hardware to newly-selected media.
|
||||
*/
|
||||
static int
|
||||
age_mediachange(struct ifnet *ifp)
|
||||
age_mediachange(if_t ifp)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
int error;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
AGE_LOCK(sc);
|
||||
mii = device_get_softc(sc->age_miibus);
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
@ -461,7 +461,7 @@ static int
|
||||
age_attach(device_t dev)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint16_t burst;
|
||||
int error, i, msic, msixc, pmc;
|
||||
|
||||
@ -599,22 +599,21 @@ age_attach(device_t dev)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ifp->if_softc = sc;
|
||||
if_setsoftc(ifp, sc);
|
||||
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
||||
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
||||
ifp->if_ioctl = age_ioctl;
|
||||
ifp->if_start = age_start;
|
||||
ifp->if_init = age_init;
|
||||
ifp->if_snd.ifq_drv_maxlen = AGE_TX_RING_CNT - 1;
|
||||
IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen);
|
||||
IFQ_SET_READY(&ifp->if_snd);
|
||||
ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_TSO4;
|
||||
ifp->if_hwassist = AGE_CSUM_FEATURES | CSUM_TSO;
|
||||
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
|
||||
if_setioctlfn(ifp, age_ioctl);
|
||||
if_setstartfn(ifp, age_start);
|
||||
if_setinitfn(ifp, age_init);
|
||||
if_setsendqlen(ifp, AGE_TX_RING_CNT - 1);
|
||||
if_setsendqready(ifp);
|
||||
if_setcapabilities(ifp, IFCAP_HWCSUM | IFCAP_TSO4);
|
||||
if_sethwassist(ifp, AGE_CSUM_FEATURES | CSUM_TSO);
|
||||
if (pci_find_cap(dev, PCIY_PMG, &pmc) == 0) {
|
||||
sc->age_flags |= AGE_FLAG_PMCAP;
|
||||
ifp->if_capabilities |= IFCAP_WOL_MAGIC | IFCAP_WOL_MCAST;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_WOL_MAGIC | IFCAP_WOL_MCAST, 0);
|
||||
}
|
||||
ifp->if_capenable = ifp->if_capabilities;
|
||||
if_setcapenable(ifp, if_getcapabilities(ifp));
|
||||
|
||||
/* Set up MII bus. */
|
||||
error = mii_attach(dev, &sc->age_miibus, ifp, age_mediachange,
|
||||
@ -628,12 +627,12 @@ age_attach(device_t dev)
|
||||
ether_ifattach(ifp, sc->age_eaddr);
|
||||
|
||||
/* VLAN capability setup. */
|
||||
ifp->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
|
||||
IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO;
|
||||
ifp->if_capenable = ifp->if_capabilities;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
|
||||
IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO, 0);
|
||||
if_setcapenable(ifp, if_getcapabilities(ifp));
|
||||
|
||||
/* Tell the upper layer(s) we support long frames. */
|
||||
ifp->if_hdrlen = sizeof(struct ether_vlan_header);
|
||||
if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
|
||||
|
||||
/* Create local taskq. */
|
||||
sc->age_tq = taskqueue_create_fast("age_taskq", M_WAITOK,
|
||||
@ -679,7 +678,7 @@ static int
|
||||
age_detach(device_t dev)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
int i, msic;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
@ -1320,7 +1319,7 @@ age_shutdown(device_t dev)
|
||||
static void
|
||||
age_setwol(struct age_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct mii_data *mii;
|
||||
uint32_t reg, pmcs;
|
||||
uint16_t pmstat;
|
||||
@ -1347,7 +1346,7 @@ age_setwol(struct age_softc *sc)
|
||||
}
|
||||
|
||||
ifp = sc->age_ifp;
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0) {
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) {
|
||||
/*
|
||||
* Note, this driver resets the link speed to 10/100Mbps with
|
||||
* auto-negotiation but we don't know whether that operation
|
||||
@ -1420,15 +1419,15 @@ age_setwol(struct age_softc *sc)
|
||||
|
||||
got_link:
|
||||
pmcs = 0;
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) != 0)
|
||||
pmcs |= WOL_CFG_MAGIC | WOL_CFG_MAGIC_ENB;
|
||||
CSR_WRITE_4(sc, AGE_WOL_CFG, pmcs);
|
||||
reg = CSR_READ_4(sc, AGE_MAC_CFG);
|
||||
reg &= ~(MAC_CFG_DBG | MAC_CFG_PROMISC);
|
||||
reg &= ~(MAC_CFG_ALLMULTI | MAC_CFG_BCAST);
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MCAST) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) != 0)
|
||||
reg |= MAC_CFG_ALLMULTI | MAC_CFG_BCAST;
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0) {
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) {
|
||||
reg |= MAC_CFG_RX_ENB;
|
||||
CSR_WRITE_4(sc, AGE_MAC_CFG, reg);
|
||||
}
|
||||
@ -1436,12 +1435,12 @@ age_setwol(struct age_softc *sc)
|
||||
/* Request PME. */
|
||||
pmstat = pci_read_config(sc->age_dev, pmc + PCIR_POWER_STATUS, 2);
|
||||
pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0)
|
||||
pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
|
||||
pci_write_config(sc->age_dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
|
||||
#ifdef notyet
|
||||
/* See above for powering down PHY issues. */
|
||||
if ((ifp->if_capenable & IFCAP_WOL) == 0) {
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) == 0) {
|
||||
/* No WOL, PHY power down. */
|
||||
age_miibus_writereg(sc->age_dev, sc->age_phyaddr,
|
||||
MII_BMCR, BMCR_PDOWN);
|
||||
@ -1468,14 +1467,14 @@ static int
|
||||
age_resume(device_t dev)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
AGE_LOCK(sc);
|
||||
age_phy_reset(sc);
|
||||
ifp = sc->age_ifp;
|
||||
if ((ifp->if_flags & IFF_UP) != 0)
|
||||
if ((if_getflags(ifp) & IFF_UP) != 0)
|
||||
age_init_locked(sc);
|
||||
|
||||
AGE_UNLOCK(sc);
|
||||
@ -1720,33 +1719,33 @@ age_encap(struct age_softc *sc, struct mbuf **m_head)
|
||||
}
|
||||
|
||||
static void
|
||||
age_start(struct ifnet *ifp)
|
||||
age_start(if_t ifp)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
AGE_LOCK(sc);
|
||||
age_start_locked(ifp);
|
||||
AGE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
age_start_locked(struct ifnet *ifp)
|
||||
age_start_locked(if_t ifp)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
struct mbuf *m_head;
|
||||
int enq;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
|
||||
AGE_LOCK_ASSERT(sc);
|
||||
|
||||
if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
|
||||
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
|
||||
IFF_DRV_RUNNING || (sc->age_flags & AGE_FLAG_LINK) == 0)
|
||||
return;
|
||||
|
||||
for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) {
|
||||
IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
|
||||
for (enq = 0; !if_sendq_empty(ifp); ) {
|
||||
m_head = if_dequeue(ifp);
|
||||
if (m_head == NULL)
|
||||
break;
|
||||
/*
|
||||
@ -1757,8 +1756,8 @@ age_start_locked(struct ifnet *ifp)
|
||||
if (age_encap(sc, &m_head)) {
|
||||
if (m_head == NULL)
|
||||
break;
|
||||
IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
|
||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
||||
if_sendq_prepend(ifp, m_head);
|
||||
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1781,7 +1780,7 @@ age_start_locked(struct ifnet *ifp)
|
||||
static void
|
||||
age_watchdog(struct age_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
|
||||
AGE_LOCK_ASSERT(sc);
|
||||
|
||||
@ -1792,27 +1791,27 @@ age_watchdog(struct age_softc *sc)
|
||||
if ((sc->age_flags & AGE_FLAG_LINK) == 0) {
|
||||
if_printf(sc->age_ifp, "watchdog timeout (missed link)\n");
|
||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
age_init_locked(sc);
|
||||
return;
|
||||
}
|
||||
if (sc->age_cdata.age_tx_cnt == 0) {
|
||||
if_printf(sc->age_ifp,
|
||||
"watchdog timeout (missed Tx interrupts) -- recovering\n");
|
||||
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if (!if_sendq_empty(ifp))
|
||||
age_start_locked(ifp);
|
||||
return;
|
||||
}
|
||||
if_printf(sc->age_ifp, "watchdog timeout\n");
|
||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
age_init_locked(sc);
|
||||
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if (!if_sendq_empty(ifp))
|
||||
age_start_locked(ifp);
|
||||
}
|
||||
|
||||
static int
|
||||
age_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
age_ioctl(if_t ifp, u_long cmd, caddr_t data)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
struct ifreq *ifr;
|
||||
@ -1820,18 +1819,18 @@ age_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
uint32_t reg;
|
||||
int error, mask;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
ifr = (struct ifreq *)data;
|
||||
error = 0;
|
||||
switch (cmd) {
|
||||
case SIOCSIFMTU:
|
||||
if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > AGE_JUMBO_MTU)
|
||||
error = EINVAL;
|
||||
else if (ifp->if_mtu != ifr->ifr_mtu) {
|
||||
else if (if_getmtu(ifp) != ifr->ifr_mtu) {
|
||||
AGE_LOCK(sc);
|
||||
ifp->if_mtu = ifr->ifr_mtu;
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setmtu(ifp, ifr->ifr_mtu);
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
age_init_locked(sc);
|
||||
}
|
||||
AGE_UNLOCK(sc);
|
||||
@ -1839,9 +1838,9 @@ age_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
break;
|
||||
case SIOCSIFFLAGS:
|
||||
AGE_LOCK(sc);
|
||||
if ((ifp->if_flags & IFF_UP) != 0) {
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
||||
if (((ifp->if_flags ^ sc->age_if_flags)
|
||||
if ((if_getflags(ifp) & IFF_UP) != 0) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
if (((if_getflags(ifp) ^ sc->age_if_flags)
|
||||
& (IFF_PROMISC | IFF_ALLMULTI)) != 0)
|
||||
age_rxfilter(sc);
|
||||
} else {
|
||||
@ -1849,16 +1848,16 @@ age_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
age_init_locked(sc);
|
||||
}
|
||||
} else {
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
|
||||
age_stop(sc);
|
||||
}
|
||||
sc->age_if_flags = ifp->if_flags;
|
||||
sc->age_if_flags = if_getflags(ifp);
|
||||
AGE_UNLOCK(sc);
|
||||
break;
|
||||
case SIOCADDMULTI:
|
||||
case SIOCDELMULTI:
|
||||
AGE_LOCK(sc);
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
|
||||
age_rxfilter(sc);
|
||||
AGE_UNLOCK(sc);
|
||||
break;
|
||||
@ -1869,50 +1868,50 @@ age_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
break;
|
||||
case SIOCSIFCAP:
|
||||
AGE_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 |= AGE_CSUM_FEATURES;
|
||||
(if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
|
||||
if_togglecapenable(ifp, IFCAP_TXCSUM);
|
||||
if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0)
|
||||
if_sethwassistbits(ifp, AGE_CSUM_FEATURES, 0);
|
||||
else
|
||||
ifp->if_hwassist &= ~AGE_CSUM_FEATURES;
|
||||
if_sethwassistbits(ifp, 0, AGE_CSUM_FEATURES);
|
||||
}
|
||||
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);
|
||||
reg = CSR_READ_4(sc, AGE_MAC_CFG);
|
||||
reg &= ~MAC_CFG_RXCSUM_ENB;
|
||||
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0)
|
||||
reg |= MAC_CFG_RXCSUM_ENB;
|
||||
CSR_WRITE_4(sc, AGE_MAC_CFG, reg);
|
||||
}
|
||||
if ((mask & IFCAP_TSO4) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_TSO4) != 0) {
|
||||
ifp->if_capenable ^= IFCAP_TSO4;
|
||||
if ((ifp->if_capenable & IFCAP_TSO4) != 0)
|
||||
ifp->if_hwassist |= CSUM_TSO;
|
||||
(if_getcapabilities(ifp) & IFCAP_TSO4) != 0) {
|
||||
if_togglecapenable(ifp, IFCAP_TSO4);
|
||||
if ((if_getcapenable(ifp) & IFCAP_TSO4) != 0)
|
||||
if_sethwassistbits(ifp, CSUM_TSO, 0);
|
||||
else
|
||||
ifp->if_hwassist &= ~CSUM_TSO;
|
||||
if_sethwassistbits(ifp, 0, CSUM_TSO);
|
||||
}
|
||||
|
||||
if ((mask & IFCAP_WOL_MCAST) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_WOL_MCAST) != 0)
|
||||
ifp->if_capenable ^= IFCAP_WOL_MCAST;
|
||||
(if_getcapabilities(ifp) & IFCAP_WOL_MCAST) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_WOL_MCAST);
|
||||
if ((mask & IFCAP_WOL_MAGIC) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_WOL_MAGIC) != 0)
|
||||
ifp->if_capenable ^= IFCAP_WOL_MAGIC;
|
||||
(if_getcapabilities(ifp) & IFCAP_WOL_MAGIC) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_WOL_MAGIC);
|
||||
if ((mask & IFCAP_VLAN_HWCSUM) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_VLAN_HWCSUM) != 0)
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWCSUM;
|
||||
(if_getcapabilities(ifp) & IFCAP_VLAN_HWCSUM) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_VLAN_HWCSUM);
|
||||
if ((mask & IFCAP_VLAN_HWTSO) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_VLAN_HWTSO) != 0)
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWTSO;
|
||||
(if_getcapabilities(ifp) & IFCAP_VLAN_HWTSO) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_VLAN_HWTSO);
|
||||
if ((mask & IFCAP_VLAN_HWTAGGING) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) != 0) {
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0)
|
||||
ifp->if_capenable &= ~IFCAP_VLAN_HWTSO;
|
||||
(if_getcapabilities(ifp) & IFCAP_VLAN_HWTAGGING) != 0) {
|
||||
if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING);
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) == 0)
|
||||
if_setcapenablebit(ifp, 0, IFCAP_VLAN_HWTSO);
|
||||
age_rxvlan(sc);
|
||||
}
|
||||
AGE_UNLOCK(sc);
|
||||
@ -1967,7 +1966,7 @@ age_link_task(void *arg, int pending)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t reg;
|
||||
|
||||
sc = (struct age_softc *)arg;
|
||||
@ -1976,7 +1975,7 @@ age_link_task(void *arg, int pending)
|
||||
mii = device_get_softc(sc->age_miibus);
|
||||
ifp = sc->age_ifp;
|
||||
if (mii == NULL || ifp == NULL ||
|
||||
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
|
||||
(if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) {
|
||||
AGE_UNLOCK(sc);
|
||||
return;
|
||||
}
|
||||
@ -2017,7 +2016,7 @@ age_stats_update(struct age_softc *sc)
|
||||
{
|
||||
struct age_stats *stat;
|
||||
struct smb *smb;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
|
||||
AGE_LOCK_ASSERT(sc);
|
||||
|
||||
@ -2133,7 +2132,7 @@ static void
|
||||
age_int_task(void *arg, int pending)
|
||||
{
|
||||
struct age_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct cmb *cmb;
|
||||
uint32_t status;
|
||||
|
||||
@ -2162,7 +2161,7 @@ age_int_task(void *arg, int pending)
|
||||
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
||||
|
||||
ifp = sc->age_ifp;
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
if ((status & INTR_CMB_RX) != 0)
|
||||
sc->age_morework = age_rxintr(sc, sc->age_rr_prod,
|
||||
sc->age_process_limit);
|
||||
@ -2175,10 +2174,10 @@ age_int_task(void *arg, int pending)
|
||||
if ((status & INTR_DMA_WR_TO_RST) != 0)
|
||||
device_printf(sc->age_dev,
|
||||
"DMA write error! -- resetting\n");
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
age_init_locked(sc);
|
||||
}
|
||||
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if (!if_sendq_empty(ifp))
|
||||
age_start_locked(ifp);
|
||||
if ((status & INTR_SMB) != 0)
|
||||
age_stats_update(sc);
|
||||
@ -2204,7 +2203,7 @@ age_int_task(void *arg, int pending)
|
||||
static void
|
||||
age_txintr(struct age_softc *sc, int tpd_cons)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct age_txdesc *txd;
|
||||
int cons, prog;
|
||||
|
||||
@ -2225,7 +2224,7 @@ age_txintr(struct age_softc *sc, int tpd_cons)
|
||||
if (sc->age_cdata.age_tx_cnt <= 0)
|
||||
break;
|
||||
prog++;
|
||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
|
||||
sc->age_cdata.age_tx_cnt--;
|
||||
txd = &sc->age_cdata.age_txdesc[cons];
|
||||
/*
|
||||
@ -2263,7 +2262,7 @@ age_txintr(struct age_softc *sc, int tpd_cons)
|
||||
|
||||
#ifndef __NO_STRICT_ALIGNMENT
|
||||
static struct mbuf *
|
||||
age_fixup_rx(struct ifnet *ifp, struct mbuf *m)
|
||||
age_fixup_rx(if_t ifp, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *n;
|
||||
int i;
|
||||
@ -2304,7 +2303,7 @@ static void
|
||||
age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd)
|
||||
{
|
||||
struct age_rxdesc *rxd;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct mbuf *mp, *m;
|
||||
uint32_t status, index, vtag;
|
||||
int count, nsegs;
|
||||
@ -2407,7 +2406,7 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd)
|
||||
* assistance due to lack of data sheet. If it is
|
||||
* proven to work on L1 I'll enable it.
|
||||
*/
|
||||
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0 &&
|
||||
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0 &&
|
||||
(status & AGE_RRD_IPV4) != 0) {
|
||||
if ((status & AGE_RRD_IPCSUM_NOK) == 0)
|
||||
m->m_pkthdr.csum_flags |=
|
||||
@ -2426,7 +2425,7 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd)
|
||||
}
|
||||
|
||||
/* Check for VLAN tagged frames. */
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 &&
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0 &&
|
||||
(status & AGE_RRD_VLAN) != 0) {
|
||||
vtag = AGE_RX_VLAN(le32toh(rxrd->vtags));
|
||||
m->m_pkthdr.ether_vtag = AGE_RX_VLAN_TAG(vtag);
|
||||
@ -2439,7 +2438,7 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd)
|
||||
{
|
||||
/* Pass it on. */
|
||||
AGE_UNLOCK(sc);
|
||||
(*ifp->if_input)(ifp, m);
|
||||
if_input(ifp, m);
|
||||
AGE_LOCK(sc);
|
||||
}
|
||||
}
|
||||
@ -2563,7 +2562,7 @@ age_init(void *xsc)
|
||||
static void
|
||||
age_init_locked(struct age_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct mii_data *mii;
|
||||
uint8_t eaddr[ETHER_ADDR_LEN];
|
||||
bus_addr_t paddr;
|
||||
@ -2576,7 +2575,7 @@ age_init_locked(struct age_softc *sc)
|
||||
ifp = sc->age_ifp;
|
||||
mii = device_get_softc(sc->age_miibus);
|
||||
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
|
||||
return;
|
||||
|
||||
/*
|
||||
@ -2602,7 +2601,7 @@ age_init_locked(struct age_softc *sc)
|
||||
age_init_smb_block(sc);
|
||||
|
||||
/* Reprogram the station address. */
|
||||
bcopy(IF_LLADDR(ifp), eaddr, ETHER_ADDR_LEN);
|
||||
bcopy(if_getlladdr(ifp), eaddr, ETHER_ADDR_LEN);
|
||||
CSR_WRITE_4(sc, AGE_PAR0,
|
||||
eaddr[2] << 24 | eaddr[3] << 16 | eaddr[4] << 8 | eaddr[5]);
|
||||
CSR_WRITE_4(sc, AGE_PAR1, eaddr[0] << 8 | eaddr[1]);
|
||||
@ -2678,10 +2677,10 @@ age_init_locked(struct age_softc *sc)
|
||||
CSR_WRITE_2(sc, AGE_INTR_CLR_TIMER, AGE_USECS(1000));
|
||||
|
||||
/* Set Maximum frame size but don't let MTU be lass than ETHER_MTU. */
|
||||
if (ifp->if_mtu < ETHERMTU)
|
||||
if (if_getmtu(ifp) < ETHERMTU)
|
||||
sc->age_max_frame_size = ETHERMTU;
|
||||
else
|
||||
sc->age_max_frame_size = ifp->if_mtu;
|
||||
sc->age_max_frame_size = if_getmtu(ifp);
|
||||
sc->age_max_frame_size += ETHER_HDR_LEN +
|
||||
sizeof(struct ether_vlan_header) + ETHER_CRC_LEN;
|
||||
CSR_WRITE_4(sc, AGE_FRAME_SIZE, sc->age_max_frame_size);
|
||||
@ -2822,7 +2821,7 @@ age_init_locked(struct age_softc *sc)
|
||||
age_rxvlan(sc);
|
||||
|
||||
reg = CSR_READ_4(sc, AGE_MAC_CFG);
|
||||
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0)
|
||||
reg |= MAC_CFG_RXCSUM_ENB;
|
||||
|
||||
/* Ack all pending interrupts and clear it. */
|
||||
@ -2838,14 +2837,14 @@ age_init_locked(struct age_softc *sc)
|
||||
|
||||
callout_reset(&sc->age_tick_ch, hz, age_tick, sc);
|
||||
|
||||
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
||||
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
|
||||
}
|
||||
|
||||
static void
|
||||
age_stop(struct age_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct age_txdesc *txd;
|
||||
struct age_rxdesc *rxd;
|
||||
uint32_t reg;
|
||||
@ -2856,7 +2855,7 @@ age_stop(struct age_softc *sc)
|
||||
* Mark the interface down and cancel the watchdog timer.
|
||||
*/
|
||||
ifp = sc->age_ifp;
|
||||
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
||||
if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
|
||||
sc->age_flags &= ~AGE_FLAG_LINK;
|
||||
callout_stop(&sc->age_tick_ch);
|
||||
sc->age_watchdog_timer = 0;
|
||||
@ -3123,7 +3122,7 @@ age_newbuf(struct age_softc *sc, struct age_rxdesc *rxd)
|
||||
static void
|
||||
age_rxvlan(struct age_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t reg;
|
||||
|
||||
AGE_LOCK_ASSERT(sc);
|
||||
@ -3131,7 +3130,7 @@ age_rxvlan(struct age_softc *sc)
|
||||
ifp = sc->age_ifp;
|
||||
reg = CSR_READ_4(sc, AGE_MAC_CFG);
|
||||
reg &= ~MAC_CFG_VLAN_TAG_STRIP;
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0)
|
||||
reg |= MAC_CFG_VLAN_TAG_STRIP;
|
||||
CSR_WRITE_4(sc, AGE_MAC_CFG, reg);
|
||||
}
|
||||
@ -3151,7 +3150,7 @@ age_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
|
||||
static void
|
||||
age_rxfilter(struct age_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t mchash[2];
|
||||
uint32_t rxcfg;
|
||||
|
||||
@ -3161,12 +3160,12 @@ age_rxfilter(struct age_softc *sc)
|
||||
|
||||
rxcfg = CSR_READ_4(sc, AGE_MAC_CFG);
|
||||
rxcfg &= ~(MAC_CFG_ALLMULTI | MAC_CFG_BCAST | MAC_CFG_PROMISC);
|
||||
if ((ifp->if_flags & IFF_BROADCAST) != 0)
|
||||
if ((if_getflags(ifp) & IFF_BROADCAST) != 0)
|
||||
rxcfg |= MAC_CFG_BCAST;
|
||||
if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
|
||||
if ((ifp->if_flags & IFF_PROMISC) != 0)
|
||||
if ((if_getflags(ifp) & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
|
||||
if ((if_getflags(ifp) & IFF_PROMISC) != 0)
|
||||
rxcfg |= MAC_CFG_PROMISC;
|
||||
if ((ifp->if_flags & IFF_ALLMULTI) != 0)
|
||||
if ((if_getflags(ifp) & IFF_ALLMULTI) != 0)
|
||||
rxcfg |= MAC_CFG_ALLMULTI;
|
||||
CSR_WRITE_4(sc, AGE_MAR0, 0xFFFFFFFF);
|
||||
CSR_WRITE_4(sc, AGE_MAR1, 0xFFFFFFFF);
|
||||
|
@ -193,7 +193,7 @@ struct age_stats {
|
||||
* Software state per device.
|
||||
*/
|
||||
struct age_softc {
|
||||
struct ifnet *age_ifp;
|
||||
if_t age_ifp;
|
||||
device_t age_dev;
|
||||
device_t age_miibus;
|
||||
struct resource *age_res[1];
|
||||
|
@ -148,7 +148,7 @@ static struct alc_ident *
|
||||
alc_find_ident(device_t);
|
||||
#ifndef __NO_STRICT_ALIGNMENT
|
||||
static struct mbuf *
|
||||
alc_fixup_rx(struct ifnet *, struct mbuf *);
|
||||
alc_fixup_rx(if_t, struct mbuf *);
|
||||
#endif
|
||||
static void alc_get_macaddr(struct alc_softc *);
|
||||
static void alc_get_macaddr_813x(struct alc_softc *);
|
||||
@ -163,7 +163,7 @@ static void alc_init_smb(struct alc_softc *);
|
||||
static void alc_init_tx_ring(struct alc_softc *);
|
||||
static void alc_int_task(void *, int);
|
||||
static int alc_intr(void *);
|
||||
static int alc_ioctl(struct ifnet *, u_long, caddr_t);
|
||||
static int alc_ioctl(if_t, u_long, caddr_t);
|
||||
static void alc_mac_config(struct alc_softc *);
|
||||
static uint32_t alc_mii_readreg_813x(struct alc_softc *, int, int);
|
||||
static uint32_t alc_mii_readreg_816x(struct alc_softc *, int, int);
|
||||
@ -176,9 +176,9 @@ static uint32_t alc_miidbg_readreg(struct alc_softc *, int);
|
||||
static uint32_t alc_miidbg_writereg(struct alc_softc *, int, int);
|
||||
static uint32_t alc_miiext_readreg(struct alc_softc *, int, int);
|
||||
static uint32_t alc_miiext_writereg(struct alc_softc *, int, int, int);
|
||||
static int alc_mediachange(struct ifnet *);
|
||||
static int alc_mediachange(if_t);
|
||||
static int alc_mediachange_locked(struct alc_softc *);
|
||||
static void alc_mediastatus(struct ifnet *, struct ifmediareq *);
|
||||
static void alc_mediastatus(if_t, struct ifmediareq *);
|
||||
static int alc_newbuf(struct alc_softc *, struct alc_rxdesc *);
|
||||
static void alc_osc_reset(struct alc_softc *);
|
||||
static void alc_phy_down(struct alc_softc *);
|
||||
@ -197,8 +197,8 @@ static void alc_setwol(struct alc_softc *);
|
||||
static void alc_setwol_813x(struct alc_softc *);
|
||||
static void alc_setwol_816x(struct alc_softc *);
|
||||
static int alc_shutdown(device_t);
|
||||
static void alc_start(struct ifnet *);
|
||||
static void alc_start_locked(struct ifnet *);
|
||||
static void alc_start(if_t);
|
||||
static void alc_start_locked(if_t);
|
||||
static void alc_start_queue(struct alc_softc *);
|
||||
static void alc_start_tx(struct alc_softc *);
|
||||
static void alc_stats_clear(struct alc_softc *);
|
||||
@ -408,7 +408,7 @@ alc_miibus_statchg(device_t dev)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t reg;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
@ -416,7 +416,7 @@ alc_miibus_statchg(device_t dev)
|
||||
mii = device_get_softc(sc->alc_miibus);
|
||||
ifp = sc->alc_ifp;
|
||||
if (mii == NULL || ifp == NULL ||
|
||||
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
|
||||
(if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
|
||||
return;
|
||||
|
||||
sc->alc_flags &= ~ALC_FLAG_LINK;
|
||||
@ -603,14 +603,14 @@ alc_dsp_fixup(struct alc_softc *sc, int media)
|
||||
}
|
||||
|
||||
static void
|
||||
alc_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
alc_mediastatus(if_t ifp, struct ifmediareq *ifmr)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
ALC_LOCK(sc);
|
||||
if ((ifp->if_flags & IFF_UP) == 0) {
|
||||
if ((if_getflags(ifp) & IFF_UP) == 0) {
|
||||
ALC_UNLOCK(sc);
|
||||
return;
|
||||
}
|
||||
@ -623,12 +623,12 @@ alc_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
}
|
||||
|
||||
static int
|
||||
alc_mediachange(struct ifnet *ifp)
|
||||
alc_mediachange(if_t ifp)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
int error;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
ALC_LOCK(sc);
|
||||
error = alc_mediachange_locked(sc);
|
||||
ALC_UNLOCK(sc);
|
||||
@ -1258,7 +1258,7 @@ alc_aspm_816x(struct alc_softc *sc, int init)
|
||||
if (init != 0)
|
||||
pmcfg |= PM_CFG_ASPM_L0S_ENB | PM_CFG_ASPM_L1_ENB |
|
||||
PM_CFG_MAC_ASPM_CHK;
|
||||
else if ((sc->alc_ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
else if ((if_getdrvflags(sc->alc_ifp) & IFF_DRV_RUNNING) != 0)
|
||||
pmcfg |= PM_CFG_ASPM_L1_ENB | PM_CFG_MAC_ASPM_CHK;
|
||||
}
|
||||
CSR_WRITE_4(sc, ALC_PM_CFG, pmcfg);
|
||||
@ -1373,7 +1373,7 @@ static int
|
||||
alc_attach(device_t dev)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
int base, error, i, msic, msixc;
|
||||
uint16_t burst;
|
||||
|
||||
@ -1571,23 +1571,22 @@ alc_attach(device_t dev)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ifp->if_softc = sc;
|
||||
if_setsoftc(ifp, sc);
|
||||
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
||||
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
||||
ifp->if_ioctl = alc_ioctl;
|
||||
ifp->if_start = alc_start;
|
||||
ifp->if_init = alc_init;
|
||||
ifp->if_snd.ifq_drv_maxlen = ALC_TX_RING_CNT - 1;
|
||||
IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen);
|
||||
IFQ_SET_READY(&ifp->if_snd);
|
||||
ifp->if_capabilities = IFCAP_TXCSUM | IFCAP_TSO4;
|
||||
ifp->if_hwassist = ALC_CSUM_FEATURES | CSUM_TSO;
|
||||
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
|
||||
if_setioctlfn(ifp, alc_ioctl);
|
||||
if_setstartfn(ifp, alc_start);
|
||||
if_setinitfn(ifp, alc_init);
|
||||
if_setsendqlen(ifp, ALC_TX_RING_CNT - 1);
|
||||
if_setsendqready(ifp);
|
||||
if_setcapabilities(ifp, IFCAP_TXCSUM | IFCAP_TSO4);
|
||||
if_sethwassist(ifp, ALC_CSUM_FEATURES | CSUM_TSO);
|
||||
if (pci_find_cap(dev, PCIY_PMG, &base) == 0) {
|
||||
ifp->if_capabilities |= IFCAP_WOL_MAGIC | IFCAP_WOL_MCAST;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_WOL_MAGIC | IFCAP_WOL_MCAST, 0);
|
||||
sc->alc_flags |= ALC_FLAG_PM;
|
||||
sc->alc_pmcap = base;
|
||||
}
|
||||
ifp->if_capenable = ifp->if_capabilities;
|
||||
if_setcapenable(ifp, if_getcapabilities(ifp));
|
||||
|
||||
/* Set up MII bus. */
|
||||
error = mii_attach(dev, &sc->alc_miibus, ifp, alc_mediachange,
|
||||
@ -1601,9 +1600,9 @@ alc_attach(device_t dev)
|
||||
ether_ifattach(ifp, sc->alc_eaddr);
|
||||
|
||||
/* VLAN capability setup. */
|
||||
ifp->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
|
||||
IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO;
|
||||
ifp->if_capenable = ifp->if_capabilities;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
|
||||
IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO, 0);
|
||||
if_setcapenable(ifp, if_getcapabilities(ifp));
|
||||
/*
|
||||
* XXX
|
||||
* It seems enabling Tx checksum offloading makes more trouble.
|
||||
@ -1617,12 +1616,12 @@ alc_attach(device_t dev)
|
||||
* seems to work.
|
||||
*/
|
||||
if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) {
|
||||
ifp->if_capenable &= ~IFCAP_TXCSUM;
|
||||
ifp->if_hwassist &= ~ALC_CSUM_FEATURES;
|
||||
if_setcapenablebit(ifp, 0, IFCAP_TXCSUM);
|
||||
if_sethwassistbits(ifp, 0, ALC_CSUM_FEATURES);
|
||||
}
|
||||
|
||||
/* Tell the upper layer(s) we support long frames. */
|
||||
ifp->if_hdrlen = sizeof(struct ether_vlan_header);
|
||||
if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
|
||||
|
||||
/* Create local taskq. */
|
||||
sc->alc_tq = taskqueue_create_fast("alc_taskq", M_WAITOK,
|
||||
@ -1672,7 +1671,7 @@ static int
|
||||
alc_detach(device_t dev)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
int i, msic;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
@ -2526,7 +2525,7 @@ alc_setwol(struct alc_softc *sc)
|
||||
static void
|
||||
alc_setwol_813x(struct alc_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t reg, pmcs;
|
||||
uint16_t pmstat;
|
||||
|
||||
@ -2547,7 +2546,7 @@ alc_setwol_813x(struct alc_softc *sc)
|
||||
return;
|
||||
}
|
||||
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0) {
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) {
|
||||
if ((sc->alc_flags & ALC_FLAG_FASTETHER) == 0)
|
||||
alc_setlinkspeed(sc);
|
||||
CSR_WRITE_4(sc, ALC_MASTER_CFG,
|
||||
@ -2555,22 +2554,22 @@ alc_setwol_813x(struct alc_softc *sc)
|
||||
}
|
||||
|
||||
pmcs = 0;
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) != 0)
|
||||
pmcs |= WOL_CFG_MAGIC | WOL_CFG_MAGIC_ENB;
|
||||
CSR_WRITE_4(sc, ALC_WOL_CFG, pmcs);
|
||||
reg = CSR_READ_4(sc, ALC_MAC_CFG);
|
||||
reg &= ~(MAC_CFG_DBG | MAC_CFG_PROMISC | MAC_CFG_ALLMULTI |
|
||||
MAC_CFG_BCAST);
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MCAST) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) != 0)
|
||||
reg |= MAC_CFG_ALLMULTI | MAC_CFG_BCAST;
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0)
|
||||
reg |= MAC_CFG_RX_ENB;
|
||||
CSR_WRITE_4(sc, ALC_MAC_CFG, reg);
|
||||
|
||||
reg = CSR_READ_4(sc, ALC_PCIE_PHYMISC);
|
||||
reg |= PCIE_PHYMISC_FORCE_RCV_DET;
|
||||
CSR_WRITE_4(sc, ALC_PCIE_PHYMISC, reg);
|
||||
if ((ifp->if_capenable & IFCAP_WOL) == 0) {
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) == 0) {
|
||||
/* WOL disabled, PHY power down. */
|
||||
alc_phy_down(sc);
|
||||
CSR_WRITE_4(sc, ALC_MASTER_CFG,
|
||||
@ -2580,7 +2579,7 @@ alc_setwol_813x(struct alc_softc *sc)
|
||||
pmstat = pci_read_config(sc->alc_dev,
|
||||
sc->alc_pmcap + PCIR_POWER_STATUS, 2);
|
||||
pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0)
|
||||
pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
|
||||
pci_write_config(sc->alc_dev,
|
||||
sc->alc_pmcap + PCIR_POWER_STATUS, pmstat, 2);
|
||||
@ -2589,7 +2588,7 @@ alc_setwol_813x(struct alc_softc *sc)
|
||||
static void
|
||||
alc_setwol_816x(struct alc_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t gphy, mac, master, pmcs, reg;
|
||||
uint16_t pmstat;
|
||||
|
||||
@ -2607,21 +2606,21 @@ alc_setwol_816x(struct alc_softc *sc)
|
||||
gphy |= GPHY_CFG_PHY_IDDQ | GPHY_CFG_PWDOWN_HW;
|
||||
mac = CSR_READ_4(sc, ALC_MAC_CFG);
|
||||
} else {
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0) {
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) {
|
||||
gphy |= GPHY_CFG_EXT_RESET;
|
||||
if ((sc->alc_flags & ALC_FLAG_FASTETHER) == 0)
|
||||
alc_setlinkspeed(sc);
|
||||
}
|
||||
pmcs = 0;
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) != 0)
|
||||
pmcs |= WOL_CFG_MAGIC | WOL_CFG_MAGIC_ENB;
|
||||
CSR_WRITE_4(sc, ALC_WOL_CFG, pmcs);
|
||||
mac = CSR_READ_4(sc, ALC_MAC_CFG);
|
||||
mac &= ~(MAC_CFG_DBG | MAC_CFG_PROMISC | MAC_CFG_ALLMULTI |
|
||||
MAC_CFG_BCAST);
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MCAST) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) != 0)
|
||||
mac |= MAC_CFG_ALLMULTI | MAC_CFG_BCAST;
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0)
|
||||
mac |= MAC_CFG_RX_ENB;
|
||||
alc_miiext_writereg(sc, MII_EXT_ANEG, MII_EXT_ANEG_S3DIG10,
|
||||
ANEG_S3DIG10_SL);
|
||||
@ -2645,7 +2644,7 @@ alc_setwol_816x(struct alc_softc *sc)
|
||||
pmstat = pci_read_config(sc->alc_dev,
|
||||
sc->alc_pmcap + PCIR_POWER_STATUS, 2);
|
||||
pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0)
|
||||
pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
|
||||
pci_write_config(sc->alc_dev,
|
||||
sc->alc_pmcap + PCIR_POWER_STATUS, pmstat, 2);
|
||||
@ -2671,7 +2670,7 @@ static int
|
||||
alc_resume(device_t dev)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint16_t pmstat;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
@ -2690,8 +2689,8 @@ alc_resume(device_t dev)
|
||||
/* Reset PHY. */
|
||||
alc_phy_reset(sc);
|
||||
ifp = sc->alc_ifp;
|
||||
if ((ifp->if_flags & IFF_UP) != 0) {
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if ((if_getflags(ifp) & IFF_UP) != 0) {
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
alc_init_locked(sc);
|
||||
}
|
||||
ALC_UNLOCK(sc);
|
||||
@ -2932,24 +2931,24 @@ alc_encap(struct alc_softc *sc, struct mbuf **m_head)
|
||||
}
|
||||
|
||||
static void
|
||||
alc_start(struct ifnet *ifp)
|
||||
alc_start(if_t ifp)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
ALC_LOCK(sc);
|
||||
alc_start_locked(ifp);
|
||||
ALC_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
alc_start_locked(struct ifnet *ifp)
|
||||
alc_start_locked(if_t ifp)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
struct mbuf *m_head;
|
||||
int enq;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
|
||||
ALC_LOCK_ASSERT(sc);
|
||||
|
||||
@ -2957,12 +2956,12 @@ alc_start_locked(struct ifnet *ifp)
|
||||
if (sc->alc_cdata.alc_tx_cnt >= ALC_TX_DESC_HIWAT)
|
||||
alc_txeof(sc);
|
||||
|
||||
if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
|
||||
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
|
||||
IFF_DRV_RUNNING || (sc->alc_flags & ALC_FLAG_LINK) == 0)
|
||||
return;
|
||||
|
||||
for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) {
|
||||
IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
|
||||
for (enq = 0; !if_sendq_empty(ifp); ) {
|
||||
m_head = if_dequeue(ifp);
|
||||
if (m_head == NULL)
|
||||
break;
|
||||
/*
|
||||
@ -2973,8 +2972,8 @@ alc_start_locked(struct ifnet *ifp)
|
||||
if (alc_encap(sc, &m_head)) {
|
||||
if (m_head == NULL)
|
||||
break;
|
||||
IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
|
||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
||||
if_sendq_prepend(ifp, m_head);
|
||||
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3013,7 +3012,7 @@ alc_start_tx(struct alc_softc *sc)
|
||||
static void
|
||||
alc_watchdog(struct alc_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
|
||||
ALC_LOCK_ASSERT(sc);
|
||||
|
||||
@ -3024,27 +3023,27 @@ alc_watchdog(struct alc_softc *sc)
|
||||
if ((sc->alc_flags & ALC_FLAG_LINK) == 0) {
|
||||
if_printf(sc->alc_ifp, "watchdog timeout (lost link)\n");
|
||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
alc_init_locked(sc);
|
||||
return;
|
||||
}
|
||||
if_printf(sc->alc_ifp, "watchdog timeout -- resetting\n");
|
||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
alc_init_locked(sc);
|
||||
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if (!if_sendq_empty(ifp))
|
||||
alc_start_locked(ifp);
|
||||
}
|
||||
|
||||
static int
|
||||
alc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
alc_ioctl(if_t ifp, u_long cmd, caddr_t data)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
struct ifreq *ifr;
|
||||
struct mii_data *mii;
|
||||
int error, mask;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
ifr = (struct ifreq *)data;
|
||||
error = 0;
|
||||
switch (cmd) {
|
||||
@ -3055,14 +3054,14 @@ alc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
((sc->alc_flags & ALC_FLAG_JUMBO) == 0 &&
|
||||
ifr->ifr_mtu > ETHERMTU))
|
||||
error = EINVAL;
|
||||
else if (ifp->if_mtu != ifr->ifr_mtu) {
|
||||
else if (if_getmtu(ifp) != ifr->ifr_mtu) {
|
||||
ALC_LOCK(sc);
|
||||
ifp->if_mtu = ifr->ifr_mtu;
|
||||
if_setmtu(ifp, ifr->ifr_mtu);
|
||||
/* AR81[3567]x has 13 bits MSS field. */
|
||||
if (ifp->if_mtu > ALC_TSO_MTU &&
|
||||
(ifp->if_capenable & IFCAP_TSO4) != 0) {
|
||||
ifp->if_capenable &= ~IFCAP_TSO4;
|
||||
ifp->if_hwassist &= ~CSUM_TSO;
|
||||
if (if_getmtu(ifp) > ALC_TSO_MTU &&
|
||||
(if_getcapenable(ifp) & IFCAP_TSO4) != 0) {
|
||||
if_setcapenablebit(ifp, 0, IFCAP_TSO4);
|
||||
if_sethwassistbits(ifp, 0, CSUM_TSO);
|
||||
VLAN_CAPABILITIES(ifp);
|
||||
}
|
||||
ALC_UNLOCK(sc);
|
||||
@ -3070,22 +3069,22 @@ alc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
break;
|
||||
case SIOCSIFFLAGS:
|
||||
ALC_LOCK(sc);
|
||||
if ((ifp->if_flags & IFF_UP) != 0) {
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0 &&
|
||||
((ifp->if_flags ^ sc->alc_if_flags) &
|
||||
if ((if_getflags(ifp) & IFF_UP) != 0) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0 &&
|
||||
((if_getflags(ifp) ^ sc->alc_if_flags) &
|
||||
(IFF_PROMISC | IFF_ALLMULTI)) != 0)
|
||||
alc_rxfilter(sc);
|
||||
else
|
||||
alc_init_locked(sc);
|
||||
} else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
} else if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
|
||||
alc_stop(sc);
|
||||
sc->alc_if_flags = ifp->if_flags;
|
||||
sc->alc_if_flags = if_getflags(ifp);
|
||||
ALC_UNLOCK(sc);
|
||||
break;
|
||||
case SIOCADDMULTI:
|
||||
case SIOCDELMULTI:
|
||||
ALC_LOCK(sc);
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
|
||||
alc_rxfilter(sc);
|
||||
ALC_UNLOCK(sc);
|
||||
break;
|
||||
@ -3096,48 +3095,48 @@ alc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
break;
|
||||
case SIOCSIFCAP:
|
||||
ALC_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 |= ALC_CSUM_FEATURES;
|
||||
(if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
|
||||
if_togglecapenable(ifp, IFCAP_TXCSUM);
|
||||
if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0)
|
||||
if_sethwassistbits(ifp, ALC_CSUM_FEATURES, 0);
|
||||
else
|
||||
ifp->if_hwassist &= ~ALC_CSUM_FEATURES;
|
||||
if_sethwassistbits(ifp, 0, ALC_CSUM_FEATURES);
|
||||
}
|
||||
if ((mask & IFCAP_TSO4) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_TSO4) != 0) {
|
||||
ifp->if_capenable ^= IFCAP_TSO4;
|
||||
if ((ifp->if_capenable & IFCAP_TSO4) != 0) {
|
||||
(if_getcapabilities(ifp) & IFCAP_TSO4) != 0) {
|
||||
if_togglecapenable(ifp, IFCAP_TSO4);
|
||||
if ((if_getcapenable(ifp) & IFCAP_TSO4) != 0) {
|
||||
/* AR81[3567]x has 13 bits MSS field. */
|
||||
if (ifp->if_mtu > ALC_TSO_MTU) {
|
||||
ifp->if_capenable &= ~IFCAP_TSO4;
|
||||
ifp->if_hwassist &= ~CSUM_TSO;
|
||||
if (if_getmtu(ifp) > ALC_TSO_MTU) {
|
||||
if_setcapenablebit(ifp, 0, IFCAP_TSO4);
|
||||
if_sethwassistbits(ifp, 0, CSUM_TSO);
|
||||
} else
|
||||
ifp->if_hwassist |= CSUM_TSO;
|
||||
if_sethwassistbits(ifp, CSUM_TSO, 0);
|
||||
} else
|
||||
ifp->if_hwassist &= ~CSUM_TSO;
|
||||
if_sethwassistbits(ifp, 0, CSUM_TSO);
|
||||
}
|
||||
if ((mask & IFCAP_WOL_MCAST) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_WOL_MCAST) != 0)
|
||||
ifp->if_capenable ^= IFCAP_WOL_MCAST;
|
||||
(if_getcapabilities(ifp) & IFCAP_WOL_MCAST) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_WOL_MCAST);
|
||||
if ((mask & IFCAP_WOL_MAGIC) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_WOL_MAGIC) != 0)
|
||||
ifp->if_capenable ^= IFCAP_WOL_MAGIC;
|
||||
(if_getcapabilities(ifp) & IFCAP_WOL_MAGIC) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_WOL_MAGIC);
|
||||
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);
|
||||
alc_rxvlan(sc);
|
||||
}
|
||||
if ((mask & IFCAP_VLAN_HWCSUM) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_VLAN_HWCSUM) != 0)
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWCSUM;
|
||||
(if_getcapabilities(ifp) & IFCAP_VLAN_HWCSUM) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_VLAN_HWCSUM);
|
||||
if ((mask & IFCAP_VLAN_HWTSO) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_VLAN_HWTSO) != 0)
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWTSO;
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0)
|
||||
ifp->if_capenable &=
|
||||
~(IFCAP_VLAN_HWTSO | IFCAP_VLAN_HWCSUM);
|
||||
(if_getcapabilities(ifp) & IFCAP_VLAN_HWTSO) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_VLAN_HWTSO);
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) == 0)
|
||||
if_setcapenablebit(ifp, 0,
|
||||
IFCAP_VLAN_HWTSO | IFCAP_VLAN_HWCSUM);
|
||||
ALC_UNLOCK(sc);
|
||||
VLAN_CAPABILITIES(ifp);
|
||||
break;
|
||||
@ -3223,7 +3222,7 @@ alc_stats_update(struct alc_softc *sc)
|
||||
{
|
||||
struct alc_hw_stats *stat;
|
||||
struct smb sb, *smb;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t *reg;
|
||||
int i;
|
||||
|
||||
@ -3361,7 +3360,7 @@ static void
|
||||
alc_int_task(void *arg, int pending)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t status;
|
||||
int more;
|
||||
|
||||
@ -3381,13 +3380,13 @@ alc_int_task(void *arg, int pending)
|
||||
CSR_WRITE_4(sc, ALC_INTR_STATUS, status | INTR_DIS_INT);
|
||||
|
||||
more = 0;
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
if ((status & INTR_RX_PKT) != 0) {
|
||||
more = alc_rxintr(sc, sc->alc_process_limit);
|
||||
if (more == EAGAIN)
|
||||
sc->alc_morework = 1;
|
||||
else if (more == EIO) {
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
alc_init_locked(sc);
|
||||
ALC_UNLOCK(sc);
|
||||
return;
|
||||
@ -3404,13 +3403,13 @@ alc_int_task(void *arg, int pending)
|
||||
if ((status & INTR_TXQ_TO_RST) != 0)
|
||||
device_printf(sc->alc_dev,
|
||||
"TxQ reset! -- resetting\n");
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
alc_init_locked(sc);
|
||||
ALC_UNLOCK(sc);
|
||||
return;
|
||||
}
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0 &&
|
||||
!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0 &&
|
||||
!if_sendq_empty(ifp))
|
||||
alc_start_locked(ifp);
|
||||
}
|
||||
|
||||
@ -3422,7 +3421,7 @@ alc_int_task(void *arg, int pending)
|
||||
}
|
||||
|
||||
done:
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
/* Re-enable interrupts if we're running. */
|
||||
if (sc->alc_flags & ALC_FLAG_MT)
|
||||
CSR_WRITE_4(sc, ALC_INTR_STATUS, 0);
|
||||
@ -3435,7 +3434,7 @@ alc_int_task(void *arg, int pending)
|
||||
static void
|
||||
alc_txeof(struct alc_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct alc_txdesc *txd;
|
||||
uint32_t cons, prod;
|
||||
|
||||
@ -3469,7 +3468,7 @@ alc_txeof(struct alc_softc *sc)
|
||||
for (; cons != prod; ALC_DESC_INC(cons, ALC_TX_RING_CNT)) {
|
||||
if (sc->alc_cdata.alc_tx_cnt <= 0)
|
||||
break;
|
||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
|
||||
sc->alc_cdata.alc_tx_cnt--;
|
||||
txd = &sc->alc_cdata.alc_txdesc[cons];
|
||||
if (txd->tx_m != NULL) {
|
||||
@ -3536,7 +3535,7 @@ alc_newbuf(struct alc_softc *sc, struct alc_rxdesc *rxd)
|
||||
static int
|
||||
alc_rxintr(struct alc_softc *sc, int count)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct rx_rdesc *rrd;
|
||||
uint32_t nsegs, status;
|
||||
int rr_cons, prog;
|
||||
@ -3548,7 +3547,7 @@ alc_rxintr(struct alc_softc *sc, int count)
|
||||
sc->alc_cdata.alc_rx_ring_map, BUS_DMASYNC_POSTWRITE);
|
||||
rr_cons = sc->alc_cdata.alc_rr_cons;
|
||||
ifp = sc->alc_ifp;
|
||||
for (prog = 0; (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0;) {
|
||||
for (prog = 0; (if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0;) {
|
||||
if (count-- <= 0)
|
||||
break;
|
||||
rrd = &sc->alc_rdata.alc_rr_ring[rr_cons];
|
||||
@ -3607,7 +3606,7 @@ alc_rxintr(struct alc_softc *sc, int count)
|
||||
|
||||
#ifndef __NO_STRICT_ALIGNMENT
|
||||
static struct mbuf *
|
||||
alc_fixup_rx(struct ifnet *ifp, struct mbuf *m)
|
||||
alc_fixup_rx(if_t ifp, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *n;
|
||||
int i;
|
||||
@ -3648,7 +3647,7 @@ static void
|
||||
alc_rxeof(struct alc_softc *sc, struct rx_rdesc *rrd)
|
||||
{
|
||||
struct alc_rxdesc *rxd;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct mbuf *mp, *m;
|
||||
uint32_t rdinfo, status, vtag;
|
||||
int count, nsegs, rx_cons;
|
||||
@ -3743,7 +3742,7 @@ alc_rxeof(struct alc_softc *sc, struct rx_rdesc *rrd)
|
||||
* Due to hardware bugs, Rx checksum offloading
|
||||
* was intentionally disabled.
|
||||
*/
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 &&
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0 &&
|
||||
(status & RRD_VLAN_TAG) != 0) {
|
||||
vtag = RRD_VLAN(le32toh(rrd->vtag));
|
||||
m->m_pkthdr.ether_vtag = ntohs(vtag);
|
||||
@ -3756,7 +3755,7 @@ alc_rxeof(struct alc_softc *sc, struct rx_rdesc *rrd)
|
||||
{
|
||||
/* Pass it on. */
|
||||
ALC_UNLOCK(sc);
|
||||
(*ifp->if_input)(ifp, m);
|
||||
if_input(ifp, m);
|
||||
ALC_LOCK(sc);
|
||||
}
|
||||
}
|
||||
@ -3927,7 +3926,7 @@ alc_init(void *xsc)
|
||||
static void
|
||||
alc_init_locked(struct alc_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint8_t eaddr[ETHER_ADDR_LEN];
|
||||
bus_addr_t paddr;
|
||||
uint32_t reg, rxf_hi, rxf_lo;
|
||||
@ -3936,7 +3935,7 @@ alc_init_locked(struct alc_softc *sc)
|
||||
|
||||
ifp = sc->alc_ifp;
|
||||
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
|
||||
return;
|
||||
/*
|
||||
* Cancel any pending I/O.
|
||||
@ -3971,7 +3970,7 @@ alc_init_locked(struct alc_softc *sc)
|
||||
CSR_WRITE_4(sc, ALC_CLK_GATING_CFG, 0);
|
||||
|
||||
/* Reprogram the station address. */
|
||||
bcopy(IF_LLADDR(ifp), eaddr, ETHER_ADDR_LEN);
|
||||
bcopy(if_getlladdr(ifp), eaddr, ETHER_ADDR_LEN);
|
||||
CSR_WRITE_4(sc, ALC_PAR0,
|
||||
eaddr[2] << 24 | eaddr[3] << 16 | eaddr[4] << 8 | eaddr[5]);
|
||||
CSR_WRITE_4(sc, ALC_PAR1, eaddr[0] << 8 | eaddr[1]);
|
||||
@ -4305,8 +4304,8 @@ alc_init_locked(struct alc_softc *sc)
|
||||
CSR_WRITE_4(sc, ALC_INTR_STATUS, 0xFFFFFFFF);
|
||||
CSR_WRITE_4(sc, ALC_INTR_STATUS, 0);
|
||||
|
||||
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
||||
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
|
||||
|
||||
sc->alc_flags &= ~ALC_FLAG_LINK;
|
||||
/* Switch to the current media. */
|
||||
@ -4318,7 +4317,7 @@ alc_init_locked(struct alc_softc *sc)
|
||||
static void
|
||||
alc_stop(struct alc_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct alc_txdesc *txd;
|
||||
struct alc_rxdesc *rxd;
|
||||
uint32_t reg;
|
||||
@ -4329,7 +4328,7 @@ alc_stop(struct alc_softc *sc)
|
||||
* Mark the interface down and cancel the watchdog timer.
|
||||
*/
|
||||
ifp = sc->alc_ifp;
|
||||
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
||||
if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
|
||||
sc->alc_flags &= ~ALC_FLAG_LINK;
|
||||
callout_stop(&sc->alc_tick_ch);
|
||||
sc->alc_watchdog_timer = 0;
|
||||
@ -4573,14 +4572,14 @@ alc_init_smb(struct alc_softc *sc)
|
||||
static void
|
||||
alc_rxvlan(struct alc_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t reg;
|
||||
|
||||
ALC_LOCK_ASSERT(sc);
|
||||
|
||||
ifp = sc->alc_ifp;
|
||||
reg = CSR_READ_4(sc, ALC_MAC_CFG);
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0)
|
||||
reg |= MAC_CFG_VLAN_TAG_STRIP;
|
||||
else
|
||||
reg &= ~MAC_CFG_VLAN_TAG_STRIP;
|
||||
@ -4602,7 +4601,7 @@ alc_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
|
||||
static void
|
||||
alc_rxfilter(struct alc_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t mchash[2];
|
||||
uint32_t rxcfg;
|
||||
|
||||
@ -4613,12 +4612,12 @@ alc_rxfilter(struct alc_softc *sc)
|
||||
bzero(mchash, sizeof(mchash));
|
||||
rxcfg = CSR_READ_4(sc, ALC_MAC_CFG);
|
||||
rxcfg &= ~(MAC_CFG_ALLMULTI | MAC_CFG_BCAST | MAC_CFG_PROMISC);
|
||||
if ((ifp->if_flags & IFF_BROADCAST) != 0)
|
||||
if ((if_getflags(ifp) & IFF_BROADCAST) != 0)
|
||||
rxcfg |= MAC_CFG_BCAST;
|
||||
if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
|
||||
if ((ifp->if_flags & IFF_PROMISC) != 0)
|
||||
if ((if_getflags(ifp) & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
|
||||
if ((if_getflags(ifp) & IFF_PROMISC) != 0)
|
||||
rxcfg |= MAC_CFG_PROMISC;
|
||||
if ((ifp->if_flags & IFF_ALLMULTI) != 0)
|
||||
if ((if_getflags(ifp) & IFF_ALLMULTI) != 0)
|
||||
rxcfg |= MAC_CFG_ALLMULTI;
|
||||
mchash[0] = 0xFFFFFFFF;
|
||||
mchash[1] = 0xFFFFFFFF;
|
||||
@ -4668,7 +4667,7 @@ sysctl_hw_alc_int_mod(SYSCTL_HANDLER_ARGS)
|
||||
|
||||
#ifdef DEBUGNET
|
||||
static void
|
||||
alc_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
|
||||
alc_debugnet_init(if_t ifp, int *nrxr, int *ncl, int *clsize)
|
||||
{
|
||||
struct alc_softc *sc __diagused;
|
||||
|
||||
@ -4681,12 +4680,12 @@ alc_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
|
||||
}
|
||||
|
||||
static void
|
||||
alc_debugnet_event(struct ifnet *ifp __unused, enum debugnet_ev event __unused)
|
||||
alc_debugnet_event(if_t ifp __unused, enum debugnet_ev event __unused)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
alc_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
|
||||
alc_debugnet_transmit(if_t ifp, struct mbuf *m)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
int error;
|
||||
@ -4703,7 +4702,7 @@ alc_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
|
||||
}
|
||||
|
||||
static int
|
||||
alc_debugnet_poll(struct ifnet *ifp, int count)
|
||||
alc_debugnet_poll(if_t ifp, int count)
|
||||
{
|
||||
struct alc_softc *sc;
|
||||
|
||||
|
@ -204,7 +204,7 @@ struct alc_ident {
|
||||
* Software state per device.
|
||||
*/
|
||||
struct alc_softc {
|
||||
struct ifnet *alc_ifp;
|
||||
if_t alc_ifp;
|
||||
device_t alc_dev;
|
||||
device_t alc_miibus;
|
||||
struct resource *alc_res[1];
|
||||
|
@ -117,13 +117,13 @@ static void ale_init_rx_pages(struct ale_softc *);
|
||||
static void ale_init_tx_ring(struct ale_softc *);
|
||||
static void ale_int_task(void *, int);
|
||||
static int ale_intr(void *);
|
||||
static int ale_ioctl(struct ifnet *, u_long, caddr_t);
|
||||
static int ale_ioctl(if_t, u_long, caddr_t);
|
||||
static void ale_mac_config(struct ale_softc *);
|
||||
static int ale_miibus_readreg(device_t, int, int);
|
||||
static void ale_miibus_statchg(device_t);
|
||||
static int ale_miibus_writereg(device_t, int, int, int);
|
||||
static int ale_mediachange(struct ifnet *);
|
||||
static void ale_mediastatus(struct ifnet *, struct ifmediareq *);
|
||||
static int ale_mediachange(if_t);
|
||||
static void ale_mediastatus(if_t, struct ifmediareq *);
|
||||
static void ale_phy_reset(struct ale_softc *);
|
||||
static int ale_probe(device_t);
|
||||
static void ale_reset(struct ale_softc *);
|
||||
@ -137,8 +137,8 @@ static void ale_rxvlan(struct ale_softc *);
|
||||
static void ale_setlinkspeed(struct ale_softc *);
|
||||
static void ale_setwol(struct ale_softc *);
|
||||
static int ale_shutdown(device_t);
|
||||
static void ale_start(struct ifnet *);
|
||||
static void ale_start_locked(struct ifnet *);
|
||||
static void ale_start(if_t);
|
||||
static void ale_start_locked(if_t);
|
||||
static void ale_stats_clear(struct ale_softc *);
|
||||
static void ale_stats_update(struct ale_softc *);
|
||||
static void ale_stop(struct ale_softc *);
|
||||
@ -256,14 +256,14 @@ ale_miibus_statchg(device_t dev)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t reg;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
mii = device_get_softc(sc->ale_miibus);
|
||||
ifp = sc->ale_ifp;
|
||||
if (mii == NULL || ifp == NULL ||
|
||||
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
|
||||
(if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
|
||||
return;
|
||||
|
||||
sc->ale_flags &= ~ALE_FLAG_LINK;
|
||||
@ -297,14 +297,14 @@ ale_miibus_statchg(device_t dev)
|
||||
}
|
||||
|
||||
static void
|
||||
ale_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
ale_mediastatus(if_t ifp, struct ifmediareq *ifmr)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
ALE_LOCK(sc);
|
||||
if ((ifp->if_flags & IFF_UP) == 0) {
|
||||
if ((if_getflags(ifp) & IFF_UP) == 0) {
|
||||
ALE_UNLOCK(sc);
|
||||
return;
|
||||
}
|
||||
@ -317,14 +317,14 @@ ale_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
}
|
||||
|
||||
static int
|
||||
ale_mediachange(struct ifnet *ifp)
|
||||
ale_mediachange(if_t ifp)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
int error;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
ALE_LOCK(sc);
|
||||
mii = device_get_softc(sc->ale_miibus);
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
@ -453,7 +453,7 @@ static int
|
||||
ale_attach(device_t dev)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint16_t burst;
|
||||
int error, i, msic, msixc, pmc;
|
||||
uint32_t rxf_len, txf_len;
|
||||
@ -618,22 +618,21 @@ ale_attach(device_t dev)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ifp->if_softc = sc;
|
||||
if_setsoftc(ifp, sc);
|
||||
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
||||
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
||||
ifp->if_ioctl = ale_ioctl;
|
||||
ifp->if_start = ale_start;
|
||||
ifp->if_init = ale_init;
|
||||
ifp->if_snd.ifq_drv_maxlen = ALE_TX_RING_CNT - 1;
|
||||
IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen);
|
||||
IFQ_SET_READY(&ifp->if_snd);
|
||||
ifp->if_capabilities = IFCAP_RXCSUM | IFCAP_TXCSUM | IFCAP_TSO4;
|
||||
ifp->if_hwassist = ALE_CSUM_FEATURES | CSUM_TSO;
|
||||
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
|
||||
if_setioctlfn(ifp, ale_ioctl);
|
||||
if_setstartfn(ifp, ale_start);
|
||||
if_setinitfn(ifp, ale_init);
|
||||
if_setsendqlen(ifp, ALE_TX_RING_CNT - 1);
|
||||
if_setsendqready(ifp);
|
||||
if_setcapabilities(ifp, IFCAP_RXCSUM | IFCAP_TXCSUM | IFCAP_TSO4);
|
||||
if_sethwassist(ifp, ALE_CSUM_FEATURES | CSUM_TSO);
|
||||
if (pci_find_cap(dev, PCIY_PMG, &pmc) == 0) {
|
||||
sc->ale_flags |= ALE_FLAG_PMCAP;
|
||||
ifp->if_capabilities |= IFCAP_WOL_MAGIC | IFCAP_WOL_MCAST;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_WOL_MAGIC | IFCAP_WOL_MCAST, 0);
|
||||
}
|
||||
ifp->if_capenable = ifp->if_capabilities;
|
||||
if_setcapenable(ifp, if_getcapabilities(ifp));
|
||||
|
||||
/* Set up MII bus. */
|
||||
error = mii_attach(dev, &sc->ale_miibus, ifp, ale_mediachange,
|
||||
@ -647,9 +646,9 @@ ale_attach(device_t dev)
|
||||
ether_ifattach(ifp, sc->ale_eaddr);
|
||||
|
||||
/* VLAN capability setup. */
|
||||
ifp->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
|
||||
IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO;
|
||||
ifp->if_capenable = ifp->if_capabilities;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
|
||||
IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO, 0);
|
||||
if_setcapenable(ifp, if_getcapabilities(ifp));
|
||||
/*
|
||||
* Even though controllers supported by ale(3) have Rx checksum
|
||||
* offload bug the workaround for fragmented frames seemed to
|
||||
@ -657,10 +656,10 @@ ale_attach(device_t dev)
|
||||
* work under certain conditions. So disable Rx checksum offload
|
||||
* until I find more clue about it but allow users to override it.
|
||||
*/
|
||||
ifp->if_capenable &= ~IFCAP_RXCSUM;
|
||||
if_setcapenablebit(ifp, 0, IFCAP_RXCSUM);
|
||||
|
||||
/* Tell the upper layer(s) we support long frames. */
|
||||
ifp->if_hdrlen = sizeof(struct ether_vlan_header);
|
||||
if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
|
||||
|
||||
/* Create local taskq. */
|
||||
sc->ale_tq = taskqueue_create_fast("ale_taskq", M_WAITOK,
|
||||
@ -706,7 +705,7 @@ static int
|
||||
ale_detach(device_t dev)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
int i, msic;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
@ -1485,7 +1484,7 @@ ale_setlinkspeed(struct ale_softc *sc)
|
||||
static void
|
||||
ale_setwol(struct ale_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t reg, pmcs;
|
||||
uint16_t pmstat;
|
||||
int pmc;
|
||||
@ -1508,25 +1507,25 @@ ale_setwol(struct ale_softc *sc)
|
||||
}
|
||||
|
||||
ifp = sc->ale_ifp;
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0) {
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) {
|
||||
if ((sc->ale_flags & ALE_FLAG_FASTETHER) == 0)
|
||||
ale_setlinkspeed(sc);
|
||||
}
|
||||
|
||||
pmcs = 0;
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) != 0)
|
||||
pmcs |= WOL_CFG_MAGIC | WOL_CFG_MAGIC_ENB;
|
||||
CSR_WRITE_4(sc, ALE_WOL_CFG, pmcs);
|
||||
reg = CSR_READ_4(sc, ALE_MAC_CFG);
|
||||
reg &= ~(MAC_CFG_DBG | MAC_CFG_PROMISC | MAC_CFG_ALLMULTI |
|
||||
MAC_CFG_BCAST);
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MCAST) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) != 0)
|
||||
reg |= MAC_CFG_ALLMULTI | MAC_CFG_BCAST;
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0)
|
||||
reg |= MAC_CFG_RX_ENB;
|
||||
CSR_WRITE_4(sc, ALE_MAC_CFG, reg);
|
||||
|
||||
if ((ifp->if_capenable & IFCAP_WOL) == 0) {
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) == 0) {
|
||||
/* WOL disabled, PHY power down. */
|
||||
reg = CSR_READ_4(sc, ALE_PCIE_PHYMISC);
|
||||
reg |= PCIE_PHYMISC_FORCE_RCV_DET;
|
||||
@ -1540,7 +1539,7 @@ ale_setwol(struct ale_softc *sc)
|
||||
/* Request PME. */
|
||||
pmstat = pci_read_config(sc->ale_dev, pmc + PCIR_POWER_STATUS, 2);
|
||||
pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
|
||||
if ((ifp->if_capenable & IFCAP_WOL) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL) != 0)
|
||||
pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
|
||||
pci_write_config(sc->ale_dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
|
||||
}
|
||||
@ -1564,7 +1563,7 @@ static int
|
||||
ale_resume(device_t dev)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
int pmc;
|
||||
uint16_t pmstat;
|
||||
|
||||
@ -1584,8 +1583,8 @@ ale_resume(device_t dev)
|
||||
/* Reset PHY. */
|
||||
ale_phy_reset(sc);
|
||||
ifp = sc->ale_ifp;
|
||||
if ((ifp->if_flags & IFF_UP) != 0) {
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if ((if_getflags(ifp) & IFF_UP) != 0) {
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
ale_init_locked(sc);
|
||||
}
|
||||
ALE_UNLOCK(sc);
|
||||
@ -1869,24 +1868,24 @@ ale_encap(struct ale_softc *sc, struct mbuf **m_head)
|
||||
}
|
||||
|
||||
static void
|
||||
ale_start(struct ifnet *ifp)
|
||||
ale_start(if_t ifp)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
ALE_LOCK(sc);
|
||||
ale_start_locked(ifp);
|
||||
ALE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
ale_start_locked(struct ifnet *ifp)
|
||||
ale_start_locked(if_t ifp)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
struct mbuf *m_head;
|
||||
int enq;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
|
||||
ALE_LOCK_ASSERT(sc);
|
||||
|
||||
@ -1894,12 +1893,12 @@ ale_start_locked(struct ifnet *ifp)
|
||||
if (sc->ale_cdata.ale_tx_cnt >= ALE_TX_DESC_HIWAT)
|
||||
ale_txeof(sc);
|
||||
|
||||
if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
|
||||
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
|
||||
IFF_DRV_RUNNING || (sc->ale_flags & ALE_FLAG_LINK) == 0)
|
||||
return;
|
||||
|
||||
for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) {
|
||||
IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
|
||||
for (enq = 0; !if_sendq_empty(ifp); ) {
|
||||
m_head = if_dequeue(ifp);
|
||||
if (m_head == NULL)
|
||||
break;
|
||||
/*
|
||||
@ -1910,8 +1909,8 @@ ale_start_locked(struct ifnet *ifp)
|
||||
if (ale_encap(sc, &m_head)) {
|
||||
if (m_head == NULL)
|
||||
break;
|
||||
IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
|
||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
||||
if_sendq_prepend(ifp, m_head);
|
||||
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1935,7 +1934,7 @@ ale_start_locked(struct ifnet *ifp)
|
||||
static void
|
||||
ale_watchdog(struct ale_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
|
||||
ALE_LOCK_ASSERT(sc);
|
||||
|
||||
@ -1946,27 +1945,27 @@ ale_watchdog(struct ale_softc *sc)
|
||||
if ((sc->ale_flags & ALE_FLAG_LINK) == 0) {
|
||||
if_printf(sc->ale_ifp, "watchdog timeout (lost link)\n");
|
||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
ale_init_locked(sc);
|
||||
return;
|
||||
}
|
||||
if_printf(sc->ale_ifp, "watchdog timeout -- resetting\n");
|
||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
ale_init_locked(sc);
|
||||
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if (!if_sendq_empty(ifp))
|
||||
ale_start_locked(ifp);
|
||||
}
|
||||
|
||||
static int
|
||||
ale_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
ale_ioctl(if_t ifp, u_long cmd, caddr_t data)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
struct ifreq *ifr;
|
||||
struct mii_data *mii;
|
||||
int error, mask;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
sc = if_getsoftc(ifp);
|
||||
ifr = (struct ifreq *)data;
|
||||
error = 0;
|
||||
switch (cmd) {
|
||||
@ -1975,11 +1974,11 @@ ale_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
((sc->ale_flags & ALE_FLAG_JUMBO) == 0 &&
|
||||
ifr->ifr_mtu > ETHERMTU))
|
||||
error = EINVAL;
|
||||
else if (ifp->if_mtu != ifr->ifr_mtu) {
|
||||
else if (if_getmtu(ifp) != ifr->ifr_mtu) {
|
||||
ALE_LOCK(sc);
|
||||
ifp->if_mtu = ifr->ifr_mtu;
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setmtu(ifp, ifr->ifr_mtu);
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
ale_init_locked(sc);
|
||||
}
|
||||
ALE_UNLOCK(sc);
|
||||
@ -1987,25 +1986,25 @@ ale_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
break;
|
||||
case SIOCSIFFLAGS:
|
||||
ALE_LOCK(sc);
|
||||
if ((ifp->if_flags & IFF_UP) != 0) {
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
||||
if (((ifp->if_flags ^ sc->ale_if_flags)
|
||||
if ((if_getflags(ifp) & IFF_UP) != 0) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
if (((if_getflags(ifp) ^ sc->ale_if_flags)
|
||||
& (IFF_PROMISC | IFF_ALLMULTI)) != 0)
|
||||
ale_rxfilter(sc);
|
||||
} else {
|
||||
ale_init_locked(sc);
|
||||
}
|
||||
} else {
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
|
||||
ale_stop(sc);
|
||||
}
|
||||
sc->ale_if_flags = ifp->if_flags;
|
||||
sc->ale_if_flags = if_getflags(ifp);
|
||||
ALE_UNLOCK(sc);
|
||||
break;
|
||||
case SIOCADDMULTI:
|
||||
case SIOCDELMULTI:
|
||||
ALE_LOCK(sc);
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
|
||||
ale_rxfilter(sc);
|
||||
ALE_UNLOCK(sc);
|
||||
break;
|
||||
@ -2016,44 +2015,44 @@ ale_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
break;
|
||||
case SIOCSIFCAP:
|
||||
ALE_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 |= ALE_CSUM_FEATURES;
|
||||
(if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
|
||||
if_togglecapenable(ifp, IFCAP_TXCSUM);
|
||||
if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0)
|
||||
if_sethwassistbits(ifp, ALE_CSUM_FEATURES, 0);
|
||||
else
|
||||
ifp->if_hwassist &= ~ALE_CSUM_FEATURES;
|
||||
if_sethwassistbits(ifp, 0, ALE_CSUM_FEATURES);
|
||||
}
|
||||
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_TSO4) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_TSO4) != 0) {
|
||||
ifp->if_capenable ^= IFCAP_TSO4;
|
||||
if ((ifp->if_capenable & IFCAP_TSO4) != 0)
|
||||
ifp->if_hwassist |= CSUM_TSO;
|
||||
(if_getcapabilities(ifp) & IFCAP_TSO4) != 0) {
|
||||
if_togglecapenable(ifp, IFCAP_TSO4);
|
||||
if ((if_getcapenable(ifp) & IFCAP_TSO4) != 0)
|
||||
if_sethwassistbits(ifp, CSUM_TSO, 0);
|
||||
else
|
||||
ifp->if_hwassist &= ~CSUM_TSO;
|
||||
if_sethwassistbits(ifp, 0, CSUM_TSO);
|
||||
}
|
||||
|
||||
if ((mask & IFCAP_WOL_MCAST) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_WOL_MCAST) != 0)
|
||||
ifp->if_capenable ^= IFCAP_WOL_MCAST;
|
||||
(if_getcapabilities(ifp) & IFCAP_WOL_MCAST) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_WOL_MCAST);
|
||||
if ((mask & IFCAP_WOL_MAGIC) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_WOL_MAGIC) != 0)
|
||||
ifp->if_capenable ^= IFCAP_WOL_MAGIC;
|
||||
(if_getcapabilities(ifp) & IFCAP_WOL_MAGIC) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_WOL_MAGIC);
|
||||
if ((mask & IFCAP_VLAN_HWCSUM) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_VLAN_HWCSUM) != 0)
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWCSUM;
|
||||
(if_getcapabilities(ifp) & IFCAP_VLAN_HWCSUM) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_VLAN_HWCSUM);
|
||||
if ((mask & IFCAP_VLAN_HWTSO) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_VLAN_HWTSO) != 0)
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWTSO;
|
||||
(if_getcapabilities(ifp) & IFCAP_VLAN_HWTSO) != 0)
|
||||
if_togglecapenable(ifp, IFCAP_VLAN_HWTSO);
|
||||
if ((mask & IFCAP_VLAN_HWTAGGING) != 0 &&
|
||||
(ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) != 0) {
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0)
|
||||
ifp->if_capenable &= ~IFCAP_VLAN_HWTSO;
|
||||
(if_getcapabilities(ifp) & IFCAP_VLAN_HWTAGGING) != 0) {
|
||||
if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING);
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) == 0)
|
||||
if_setcapenablebit(ifp, 0, IFCAP_VLAN_HWTSO);
|
||||
ale_rxvlan(sc);
|
||||
}
|
||||
ALE_UNLOCK(sc);
|
||||
@ -2122,7 +2121,7 @@ ale_stats_update(struct ale_softc *sc)
|
||||
{
|
||||
struct ale_hw_stats *stat;
|
||||
struct smb sb, *smb;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t *reg;
|
||||
int i;
|
||||
|
||||
@ -2237,7 +2236,7 @@ static void
|
||||
ale_int_task(void *arg, int pending)
|
||||
{
|
||||
struct ale_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t status;
|
||||
int more;
|
||||
|
||||
@ -2255,13 +2254,13 @@ ale_int_task(void *arg, int pending)
|
||||
|
||||
ifp = sc->ale_ifp;
|
||||
more = 0;
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
more = ale_rxeof(sc, sc->ale_process_limit);
|
||||
if (more == EAGAIN)
|
||||
sc->ale_morework = 1;
|
||||
else if (more == EIO) {
|
||||
sc->ale_stats.reset_brk_seq++;
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
ale_init_locked(sc);
|
||||
ALE_UNLOCK(sc);
|
||||
return;
|
||||
@ -2274,12 +2273,12 @@ ale_int_task(void *arg, int pending)
|
||||
if ((status & INTR_DMA_WR_TO_RST) != 0)
|
||||
device_printf(sc->ale_dev,
|
||||
"DMA write error! -- resetting\n");
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
|
||||
ale_init_locked(sc);
|
||||
ALE_UNLOCK(sc);
|
||||
return;
|
||||
}
|
||||
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if (!if_sendq_empty(ifp))
|
||||
ale_start_locked(ifp);
|
||||
}
|
||||
|
||||
@ -2300,7 +2299,7 @@ ale_int_task(void *arg, int pending)
|
||||
static void
|
||||
ale_txeof(struct ale_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct ale_txdesc *txd;
|
||||
uint32_t cons, prod;
|
||||
int prog;
|
||||
@ -2332,7 +2331,7 @@ ale_txeof(struct ale_softc *sc)
|
||||
if (sc->ale_cdata.ale_tx_cnt <= 0)
|
||||
break;
|
||||
prog++;
|
||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
|
||||
sc->ale_cdata.ale_tx_cnt--;
|
||||
txd = &sc->ale_cdata.ale_txdesc[cons];
|
||||
if (txd->tx_m != NULL) {
|
||||
@ -2406,7 +2405,7 @@ ale_rx_update_page(struct ale_softc *sc, struct ale_rx_page **page,
|
||||
static void
|
||||
ale_rxcsum(struct ale_softc *sc, struct mbuf *m, uint32_t status)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct ip *ip;
|
||||
char *p;
|
||||
|
||||
@ -2430,7 +2429,7 @@ ale_rxcsum(struct ale_softc *sc, struct mbuf *m, uint32_t status)
|
||||
p += ETHER_HDR_LEN;
|
||||
if ((status & ALE_RD_802_3) != 0)
|
||||
p += LLC_SNAPFRAMELEN;
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0 &&
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) == 0 &&
|
||||
(status & ALE_RD_VLAN) != 0)
|
||||
p += ETHER_VLAN_ENCAP_LEN;
|
||||
ip = (struct ip *)p;
|
||||
@ -2454,7 +2453,7 @@ ale_rxeof(struct ale_softc *sc, int count)
|
||||
{
|
||||
struct ale_rx_page *rx_page;
|
||||
struct rx_rs *rs;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct mbuf *m;
|
||||
uint32_t length, prod, seqno, status, vtags;
|
||||
int prog;
|
||||
@ -2537,10 +2536,10 @@ ale_rxeof(struct ale_softc *sc, int count)
|
||||
ale_rx_update_page(sc, &rx_page, length, &prod);
|
||||
continue;
|
||||
}
|
||||
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0 &&
|
||||
if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0 &&
|
||||
(status & ALE_RD_IPV4) != 0)
|
||||
ale_rxcsum(sc, m, status);
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 &&
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0 &&
|
||||
(status & ALE_RD_VLAN) != 0) {
|
||||
vtags = ALE_RX_VLAN(le32toh(rs->vtags));
|
||||
m->m_pkthdr.ether_vtag = ALE_RX_VLAN_TAG(vtags);
|
||||
@ -2549,7 +2548,7 @@ ale_rxeof(struct ale_softc *sc, int count)
|
||||
|
||||
/* Pass it to upper layer. */
|
||||
ALE_UNLOCK(sc);
|
||||
(*ifp->if_input)(ifp, m);
|
||||
if_input(ifp, m);
|
||||
ALE_LOCK(sc);
|
||||
|
||||
ale_rx_update_page(sc, &rx_page, length, &prod);
|
||||
@ -2623,7 +2622,7 @@ ale_init(void *xsc)
|
||||
static void
|
||||
ale_init_locked(struct ale_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct mii_data *mii;
|
||||
uint8_t eaddr[ETHER_ADDR_LEN];
|
||||
bus_addr_t paddr;
|
||||
@ -2634,7 +2633,7 @@ ale_init_locked(struct ale_softc *sc)
|
||||
ifp = sc->ale_ifp;
|
||||
mii = device_get_softc(sc->ale_miibus);
|
||||
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
|
||||
return;
|
||||
/*
|
||||
* Cancel any pending I/O.
|
||||
@ -2649,7 +2648,7 @@ ale_init_locked(struct ale_softc *sc)
|
||||
ale_init_tx_ring(sc);
|
||||
|
||||
/* Reprogram the station address. */
|
||||
bcopy(IF_LLADDR(ifp), eaddr, ETHER_ADDR_LEN);
|
||||
bcopy(if_getlladdr(ifp), eaddr, ETHER_ADDR_LEN);
|
||||
CSR_WRITE_4(sc, ALE_PAR0,
|
||||
eaddr[2] << 24 | eaddr[3] << 16 | eaddr[4] << 8 | eaddr[5]);
|
||||
CSR_WRITE_4(sc, ALE_PAR1, eaddr[0] << 8 | eaddr[1]);
|
||||
@ -2720,10 +2719,10 @@ ale_init_locked(struct ale_softc *sc)
|
||||
CSR_WRITE_2(sc, ALE_INTR_CLR_TIMER, ALE_USECS(1000));
|
||||
|
||||
/* Set Maximum frame size of controller. */
|
||||
if (ifp->if_mtu < ETHERMTU)
|
||||
if (if_getmtu(ifp) < ETHERMTU)
|
||||
sc->ale_max_frame_size = ETHERMTU;
|
||||
else
|
||||
sc->ale_max_frame_size = ifp->if_mtu;
|
||||
sc->ale_max_frame_size = if_getmtu(ifp);
|
||||
sc->ale_max_frame_size += ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN +
|
||||
ETHER_CRC_LEN;
|
||||
CSR_WRITE_4(sc, ALE_FRAME_SIZE, sc->ale_max_frame_size);
|
||||
@ -2746,9 +2745,9 @@ ale_init_locked(struct ale_softc *sc)
|
||||
|
||||
/* Configure Tx jumbo frame parameters. */
|
||||
if ((sc->ale_flags & ALE_FLAG_JUMBO) != 0) {
|
||||
if (ifp->if_mtu < ETHERMTU)
|
||||
if (if_getmtu(ifp) < ETHERMTU)
|
||||
reg = sc->ale_max_frame_size;
|
||||
else if (ifp->if_mtu < 6 * 1024)
|
||||
else if (if_getmtu(ifp) < 6 * 1024)
|
||||
reg = (sc->ale_max_frame_size * 2) / 3;
|
||||
else
|
||||
reg = sc->ale_max_frame_size / 2;
|
||||
@ -2841,8 +2840,8 @@ ale_init_locked(struct ale_softc *sc)
|
||||
CSR_WRITE_4(sc, ALE_INTR_STATUS, 0xFFFFFFFF);
|
||||
CSR_WRITE_4(sc, ALE_INTR_STATUS, 0);
|
||||
|
||||
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
||||
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
|
||||
|
||||
sc->ale_flags &= ~ALE_FLAG_LINK;
|
||||
/* Switch to the current media. */
|
||||
@ -2854,7 +2853,7 @@ ale_init_locked(struct ale_softc *sc)
|
||||
static void
|
||||
ale_stop(struct ale_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct ale_txdesc *txd;
|
||||
uint32_t reg;
|
||||
int i;
|
||||
@ -2864,7 +2863,7 @@ ale_stop(struct ale_softc *sc)
|
||||
* Mark the interface down and cancel the watchdog timer.
|
||||
*/
|
||||
ifp = sc->ale_ifp;
|
||||
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
||||
if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
|
||||
sc->ale_flags &= ~ALE_FLAG_LINK;
|
||||
callout_stop(&sc->ale_tick_ch);
|
||||
sc->ale_watchdog_timer = 0;
|
||||
@ -2984,7 +2983,7 @@ ale_init_rx_pages(struct ale_softc *sc)
|
||||
static void
|
||||
ale_rxvlan(struct ale_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t reg;
|
||||
|
||||
ALE_LOCK_ASSERT(sc);
|
||||
@ -2992,7 +2991,7 @@ ale_rxvlan(struct ale_softc *sc)
|
||||
ifp = sc->ale_ifp;
|
||||
reg = CSR_READ_4(sc, ALE_MAC_CFG);
|
||||
reg &= ~MAC_CFG_VLAN_TAG_STRIP;
|
||||
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0)
|
||||
reg |= MAC_CFG_VLAN_TAG_STRIP;
|
||||
CSR_WRITE_4(sc, ALE_MAC_CFG, reg);
|
||||
}
|
||||
@ -3011,7 +3010,7 @@ ale_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
|
||||
static void
|
||||
ale_rxfilter(struct ale_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
uint32_t mchash[2];
|
||||
uint32_t rxcfg;
|
||||
|
||||
@ -3021,12 +3020,12 @@ ale_rxfilter(struct ale_softc *sc)
|
||||
|
||||
rxcfg = CSR_READ_4(sc, ALE_MAC_CFG);
|
||||
rxcfg &= ~(MAC_CFG_ALLMULTI | MAC_CFG_BCAST | MAC_CFG_PROMISC);
|
||||
if ((ifp->if_flags & IFF_BROADCAST) != 0)
|
||||
if ((if_getflags(ifp) & IFF_BROADCAST) != 0)
|
||||
rxcfg |= MAC_CFG_BCAST;
|
||||
if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
|
||||
if ((ifp->if_flags & IFF_PROMISC) != 0)
|
||||
if ((if_getflags(ifp) & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
|
||||
if ((if_getflags(ifp) & IFF_PROMISC) != 0)
|
||||
rxcfg |= MAC_CFG_PROMISC;
|
||||
if ((ifp->if_flags & IFF_ALLMULTI) != 0)
|
||||
if ((if_getflags(ifp) & IFF_ALLMULTI) != 0)
|
||||
rxcfg |= MAC_CFG_ALLMULTI;
|
||||
CSR_WRITE_4(sc, ALE_MAR0, 0xFFFFFFFF);
|
||||
CSR_WRITE_4(sc, ALE_MAR1, 0xFFFFFFFF);
|
||||
|
@ -183,7 +183,7 @@ struct ale_hw_stats {
|
||||
* Software state per device.
|
||||
*/
|
||||
struct ale_softc {
|
||||
struct ifnet *ale_ifp;
|
||||
if_t ale_ifp;
|
||||
device_t ale_dev;
|
||||
device_t ale_miibus;
|
||||
struct resource *ale_res[1];
|
||||
|
Loading…
Reference in New Issue
Block a user