mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Convert em(4) to use the driver API.
Submitted by: Anuranjan Shukla <anshukla@juniper.net> Obtained from: Juniper Networks, Inc.
This commit is contained in:
parent
41eb5ac39d
commit
9e11529015
File diff suppressed because it is too large
Load Diff
@ -345,7 +345,7 @@ struct rx_ring {
|
||||
|
||||
/* Our adapter structure */
|
||||
struct adapter {
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
struct e1000_hw hw;
|
||||
|
||||
/* FreeBSD operating-system-specific structures. */
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/buf_ring.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -167,14 +168,14 @@ static int lem_detach(device_t);
|
||||
static int lem_shutdown(device_t);
|
||||
static int lem_suspend(device_t);
|
||||
static int lem_resume(device_t);
|
||||
static void lem_start(struct ifnet *);
|
||||
static void lem_start_locked(struct ifnet *ifp);
|
||||
static int lem_ioctl(struct ifnet *, u_long, caddr_t);
|
||||
static void lem_start(if_t);
|
||||
static void lem_start_locked(if_t ifp);
|
||||
static int lem_ioctl(if_t, u_long, caddr_t);
|
||||
static void lem_init(void *);
|
||||
static void lem_init_locked(struct adapter *);
|
||||
static void lem_stop(void *);
|
||||
static void lem_media_status(struct ifnet *, struct ifmediareq *);
|
||||
static int lem_media_change(struct ifnet *);
|
||||
static void lem_media_status(if_t, struct ifmediareq *);
|
||||
static int lem_media_change(if_t);
|
||||
static void lem_identify_hardware(struct adapter *);
|
||||
static int lem_allocate_pci_resources(struct adapter *);
|
||||
static int lem_allocate_irq(struct adapter *adapter);
|
||||
@ -209,8 +210,8 @@ static void lem_disable_promisc(struct adapter *);
|
||||
static void lem_set_multi(struct adapter *);
|
||||
static void lem_update_link_status(struct adapter *);
|
||||
static int lem_get_buf(struct adapter *, int);
|
||||
static void lem_register_vlan(void *, struct ifnet *, u16);
|
||||
static void lem_unregister_vlan(void *, struct ifnet *, u16);
|
||||
static void lem_register_vlan(void *, if_t, u16);
|
||||
static void lem_unregister_vlan(void *, if_t, u16);
|
||||
static void lem_setup_vlan_hw_support(struct adapter *);
|
||||
static int lem_xmit(struct adapter *, struct mbuf **);
|
||||
static void lem_smartspeed(struct adapter *);
|
||||
@ -249,7 +250,7 @@ static void lem_add_rx_process_limit(struct adapter *, const char *,
|
||||
const char *, int *, int);
|
||||
|
||||
#ifdef DEVICE_POLLING
|
||||
static poll_handler_t lem_poll;
|
||||
static poll_handler_drv_t lem_poll;
|
||||
#endif /* POLLING */
|
||||
|
||||
/*********************************************************************
|
||||
@ -653,7 +654,7 @@ lem_attach(device_t dev)
|
||||
lem_get_hw_control(adapter);
|
||||
|
||||
/* Tell the stack that the interface is not active */
|
||||
adapter->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
||||
if_setdrvflagbits(adapter->ifp, 0, IFF_DRV_OACTIVE | IFF_DRV_RUNNING);
|
||||
|
||||
adapter->led_dev = led_create(lem_led_func, adapter,
|
||||
device_get_nameunit(dev));
|
||||
@ -675,8 +676,8 @@ err_rx_desc:
|
||||
lem_dma_free(adapter, &adapter->txdma);
|
||||
err_tx_desc:
|
||||
err_pci:
|
||||
if (adapter->ifp != NULL)
|
||||
if_free(adapter->ifp);
|
||||
if (adapter->ifp != (void *)NULL)
|
||||
if_free_drv(adapter->ifp);
|
||||
lem_free_pci_resources(adapter);
|
||||
free(adapter->mta, M_DEVBUF);
|
||||
EM_TX_LOCK_DESTROY(adapter);
|
||||
@ -700,19 +701,19 @@ static int
|
||||
lem_detach(device_t dev)
|
||||
{
|
||||
struct adapter *adapter = device_get_softc(dev);
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
|
||||
INIT_DEBUGOUT("em_detach: begin");
|
||||
|
||||
/* Make sure VLANS are not using driver */
|
||||
if (adapter->ifp->if_vlantrunk != NULL) {
|
||||
if (if_vlantrunkinuse(ifp)) {
|
||||
device_printf(dev,"Vlan in use, detach first\n");
|
||||
return (EBUSY);
|
||||
}
|
||||
|
||||
#ifdef DEVICE_POLLING
|
||||
if (ifp->if_capenable & IFCAP_POLLING)
|
||||
ether_poll_deregister(ifp);
|
||||
if (if_getcapenable(ifp) & IFCAP_POLLING)
|
||||
ether_poll_deregister_drv(ifp);
|
||||
#endif
|
||||
|
||||
if (adapter->led_dev != NULL)
|
||||
@ -735,7 +736,7 @@ lem_detach(device_t dev)
|
||||
if (adapter->vlan_detach != NULL)
|
||||
EVENTHANDLER_DEREGISTER(vlan_unconfig, adapter->vlan_detach);
|
||||
|
||||
ether_ifdetach(adapter->ifp);
|
||||
ether_ifdetach_drv(adapter->ifp);
|
||||
callout_drain(&adapter->timer);
|
||||
callout_drain(&adapter->tx_fifo_timer);
|
||||
|
||||
@ -744,7 +745,7 @@ lem_detach(device_t dev)
|
||||
#endif /* DEV_NETMAP */
|
||||
lem_free_pci_resources(adapter);
|
||||
bus_generic_detach(dev);
|
||||
if_free(ifp);
|
||||
if_free_drv(ifp);
|
||||
|
||||
lem_free_transmit_structures(adapter);
|
||||
lem_free_receive_structures(adapter);
|
||||
@ -805,7 +806,7 @@ static int
|
||||
lem_resume(device_t dev)
|
||||
{
|
||||
struct adapter *adapter = device_get_softc(dev);
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
|
||||
EM_CORE_LOCK(adapter);
|
||||
lem_init_locked(adapter);
|
||||
@ -818,14 +819,14 @@ lem_resume(device_t dev)
|
||||
|
||||
|
||||
static void
|
||||
lem_start_locked(struct ifnet *ifp)
|
||||
lem_start_locked(if_t ifp)
|
||||
{
|
||||
struct adapter *adapter = ifp->if_softc;
|
||||
struct adapter *adapter = if_getsoftc(ifp);
|
||||
struct mbuf *m_head;
|
||||
|
||||
EM_TX_LOCK_ASSERT(adapter);
|
||||
|
||||
if ((ifp->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) !=
|
||||
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) !=
|
||||
IFF_DRV_RUNNING)
|
||||
return;
|
||||
if (!adapter->link_active)
|
||||
@ -844,9 +845,9 @@ lem_start_locked(struct ifnet *ifp)
|
||||
}
|
||||
}
|
||||
|
||||
while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
|
||||
while (!if_sendq_empty(ifp)) {
|
||||
m_head = if_dequeue(ifp);
|
||||
|
||||
IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
|
||||
if (m_head == NULL)
|
||||
break;
|
||||
/*
|
||||
@ -856,31 +857,31 @@ lem_start_locked(struct ifnet *ifp)
|
||||
if (lem_xmit(adapter, &m_head)) {
|
||||
if (m_head == NULL)
|
||||
break;
|
||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
||||
IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
|
||||
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
|
||||
if_sendq_prepend(ifp, m_head);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Send a copy of the frame to the BPF listener */
|
||||
ETHER_BPF_MTAP(ifp, m_head);
|
||||
if_etherbpfmtap(ifp, m_head);
|
||||
|
||||
/* Set timeout in case hardware has problems transmitting. */
|
||||
adapter->watchdog_check = TRUE;
|
||||
adapter->watchdog_time = ticks;
|
||||
}
|
||||
if (adapter->num_tx_desc_avail <= EM_TX_OP_THRESHOLD)
|
||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
||||
if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
lem_start(struct ifnet *ifp)
|
||||
lem_start(if_t ifp)
|
||||
{
|
||||
struct adapter *adapter = ifp->if_softc;
|
||||
struct adapter *adapter = if_getsoftc(ifp);
|
||||
|
||||
EM_TX_LOCK(adapter);
|
||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
|
||||
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
|
||||
lem_start_locked(ifp);
|
||||
EM_TX_UNLOCK(adapter);
|
||||
}
|
||||
@ -895,9 +896,9 @@ lem_start(struct ifnet *ifp)
|
||||
**********************************************************************/
|
||||
|
||||
static int
|
||||
lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
lem_ioctl(if_t ifp, u_long command, caddr_t data)
|
||||
{
|
||||
struct adapter *adapter = ifp->if_softc;
|
||||
struct adapter *adapter = if_getsoftc(ifp);
|
||||
struct ifreq *ifr = (struct ifreq *)data;
|
||||
#if defined(INET) || defined(INET6)
|
||||
struct ifaddr *ifa = (struct ifaddr *)data;
|
||||
@ -923,15 +924,15 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
** so we avoid doing it when possible.
|
||||
*/
|
||||
if (avoid_reset) {
|
||||
ifp->if_flags |= IFF_UP;
|
||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
|
||||
if_setflagbits(ifp, IFF_UP, 0);
|
||||
if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))
|
||||
lem_init(adapter);
|
||||
#ifdef INET
|
||||
if (!(ifp->if_flags & IFF_NOARP))
|
||||
arp_ifinit(ifp, ifa);
|
||||
if (!(if_getflags(ifp) & IFF_NOARP))
|
||||
arp_ifinit_drv(ifp, ifa);
|
||||
#endif
|
||||
} else
|
||||
error = ether_ioctl(ifp, command, data);
|
||||
error = ether_ioctl_drv(ifp, command, data);
|
||||
break;
|
||||
case SIOCSIFMTU:
|
||||
{
|
||||
@ -954,9 +955,9 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
break;
|
||||
}
|
||||
|
||||
ifp->if_mtu = ifr->ifr_mtu;
|
||||
if_setmtu(ifp, ifr->ifr_mtu);
|
||||
adapter->max_frame_size =
|
||||
ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
|
||||
if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN;
|
||||
lem_init_locked(adapter);
|
||||
EM_CORE_UNLOCK(adapter);
|
||||
break;
|
||||
@ -965,9 +966,9 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
IOCTL_DEBUGOUT("ioctl rcv'd:\
|
||||
SIOCSIFFLAGS (Set Interface Flags)");
|
||||
EM_CORE_LOCK(adapter);
|
||||
if (ifp->if_flags & IFF_UP) {
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
||||
if ((ifp->if_flags ^ adapter->if_flags) &
|
||||
if (if_getflags(ifp) & IFF_UP) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
|
||||
if ((if_getflags(ifp) ^ adapter->if_flags) &
|
||||
(IFF_PROMISC | IFF_ALLMULTI)) {
|
||||
lem_disable_promisc(adapter);
|
||||
lem_set_promisc(adapter);
|
||||
@ -975,18 +976,18 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
} else
|
||||
lem_init_locked(adapter);
|
||||
} else
|
||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
||||
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
|
||||
EM_TX_LOCK(adapter);
|
||||
lem_stop(adapter);
|
||||
EM_TX_UNLOCK(adapter);
|
||||
}
|
||||
adapter->if_flags = ifp->if_flags;
|
||||
adapter->if_flags = if_getflags(ifp);
|
||||
EM_CORE_UNLOCK(adapter);
|
||||
break;
|
||||
case SIOCADDMULTI:
|
||||
case SIOCDELMULTI:
|
||||
IOCTL_DEBUGOUT("ioctl rcv'd: SIOC(ADD|DEL)MULTI");
|
||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
||||
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
|
||||
EM_CORE_LOCK(adapter);
|
||||
lem_disable_intr(adapter);
|
||||
lem_set_multi(adapter);
|
||||
@ -995,7 +996,7 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
lem_initialize_receive_unit(adapter);
|
||||
}
|
||||
#ifdef DEVICE_POLLING
|
||||
if (!(ifp->if_capenable & IFCAP_POLLING))
|
||||
if (!(if_getcapenable(ifp) & IFCAP_POLLING))
|
||||
#endif
|
||||
lem_enable_intr(adapter);
|
||||
EM_CORE_UNLOCK(adapter);
|
||||
@ -1014,7 +1015,7 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
case SIOCGIFMEDIA:
|
||||
IOCTL_DEBUGOUT("ioctl rcv'd: \
|
||||
SIOCxIFMEDIA (Get/Set Interface Media)");
|
||||
error = ifmedia_ioctl(ifp, ifr, &adapter->media, command);
|
||||
error = ifmedia_ioctl_drv(ifp, ifr, &adapter->media, command);
|
||||
break;
|
||||
case SIOCSIFCAP:
|
||||
{
|
||||
@ -1022,50 +1023,50 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
|
||||
IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFCAP (Set Capabilities)");
|
||||
reinit = 0;
|
||||
mask = ifr->ifr_reqcap ^ ifp->if_capenable;
|
||||
mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
|
||||
#ifdef DEVICE_POLLING
|
||||
if (mask & IFCAP_POLLING) {
|
||||
if (ifr->ifr_reqcap & IFCAP_POLLING) {
|
||||
error = ether_poll_register(lem_poll, ifp);
|
||||
error = ether_poll_register_drv(lem_poll, ifp);
|
||||
if (error)
|
||||
return (error);
|
||||
EM_CORE_LOCK(adapter);
|
||||
lem_disable_intr(adapter);
|
||||
ifp->if_capenable |= IFCAP_POLLING;
|
||||
if_setcapenablebit(ifp, IFCAP_POLLING, 0);
|
||||
EM_CORE_UNLOCK(adapter);
|
||||
} else {
|
||||
error = ether_poll_deregister(ifp);
|
||||
error = ether_poll_deregister_drv(ifp);
|
||||
/* Enable interrupt even in error case */
|
||||
EM_CORE_LOCK(adapter);
|
||||
lem_enable_intr(adapter);
|
||||
ifp->if_capenable &= ~IFCAP_POLLING;
|
||||
if_setcapenablebit(ifp, 0, IFCAP_POLLING);
|
||||
EM_CORE_UNLOCK(adapter);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (mask & IFCAP_HWCSUM) {
|
||||
ifp->if_capenable ^= IFCAP_HWCSUM;
|
||||
if_togglecapenable(ifp, IFCAP_HWCSUM);
|
||||
reinit = 1;
|
||||
}
|
||||
if (mask & IFCAP_VLAN_HWTAGGING) {
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
|
||||
if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING);
|
||||
reinit = 1;
|
||||
}
|
||||
if ((mask & IFCAP_WOL) &&
|
||||
(ifp->if_capabilities & IFCAP_WOL) != 0) {
|
||||
(if_getcapabilities(ifp) & IFCAP_WOL) != 0) {
|
||||
if (mask & IFCAP_WOL_MCAST)
|
||||
ifp->if_capenable ^= IFCAP_WOL_MCAST;
|
||||
if_togglecapenable(ifp, IFCAP_WOL_MCAST);
|
||||
if (mask & IFCAP_WOL_MAGIC)
|
||||
ifp->if_capenable ^= IFCAP_WOL_MAGIC;
|
||||
if_togglecapenable(ifp, IFCAP_WOL_MAGIC);
|
||||
}
|
||||
if (reinit && (ifp->if_drv_flags & IFF_DRV_RUNNING))
|
||||
if (reinit && (if_getdrvflags(ifp) & IFF_DRV_RUNNING))
|
||||
lem_init(adapter);
|
||||
VLAN_CAPABILITIES(ifp);
|
||||
if_vlancap(ifp);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
error = ether_ioctl(ifp, command, data);
|
||||
error = ether_ioctl_drv(ifp, command, data);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1087,7 +1088,7 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
static void
|
||||
lem_init_locked(struct adapter *adapter)
|
||||
{
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
device_t dev = adapter->dev;
|
||||
u32 pba;
|
||||
|
||||
@ -1134,7 +1135,7 @@ lem_init_locked(struct adapter *adapter)
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_PBA, pba);
|
||||
|
||||
/* Get the latest mac address, User can use a LAA */
|
||||
bcopy(IF_LLADDR(adapter->ifp), adapter->hw.mac.addr,
|
||||
bcopy(if_getlladdr(adapter->ifp), adapter->hw.mac.addr,
|
||||
ETHER_ADDR_LEN);
|
||||
|
||||
/* Put the address into the Receive Address Array */
|
||||
@ -1151,10 +1152,10 @@ lem_init_locked(struct adapter *adapter)
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_VET, ETHERTYPE_VLAN);
|
||||
|
||||
/* Set hardware offload abilities */
|
||||
ifp->if_hwassist = 0;
|
||||
if_clearhwassist(ifp);
|
||||
if (adapter->hw.mac.type >= e1000_82543) {
|
||||
if (ifp->if_capenable & IFCAP_TXCSUM)
|
||||
ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP);
|
||||
if (if_getcapenable(ifp) & IFCAP_TXCSUM)
|
||||
if_sethwassistbits(ifp, CSUM_TCP | CSUM_UDP, 0);
|
||||
}
|
||||
|
||||
/* Configure for OS presence */
|
||||
@ -1178,8 +1179,8 @@ lem_init_locked(struct adapter *adapter)
|
||||
lem_initialize_receive_unit(adapter);
|
||||
|
||||
/* Use real VLAN Filter support? */
|
||||
if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) {
|
||||
if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
|
||||
if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) {
|
||||
if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
|
||||
/* Use real VLAN Filter support */
|
||||
lem_setup_vlan_hw_support(adapter);
|
||||
else {
|
||||
@ -1193,8 +1194,7 @@ lem_init_locked(struct adapter *adapter)
|
||||
/* Don't lose promiscuous settings */
|
||||
lem_set_promisc(adapter);
|
||||
|
||||
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
||||
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE);
|
||||
|
||||
callout_reset(&adapter->timer, hz, lem_local_timer, adapter);
|
||||
e1000_clear_hw_cntrs_base_generic(&adapter->hw);
|
||||
@ -1204,7 +1204,7 @@ lem_init_locked(struct adapter *adapter)
|
||||
* Only enable interrupts if we are not polling, make sure
|
||||
* they are off otherwise.
|
||||
*/
|
||||
if (ifp->if_capenable & IFCAP_POLLING)
|
||||
if (if_getcapenable(ifp) & IFCAP_POLLING)
|
||||
lem_disable_intr(adapter);
|
||||
else
|
||||
#endif /* DEVICE_POLLING */
|
||||
@ -1233,13 +1233,13 @@ lem_init(void *arg)
|
||||
*
|
||||
*********************************************************************/
|
||||
static int
|
||||
lem_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
|
||||
lem_poll(if_t ifp, enum poll_cmd cmd, int count)
|
||||
{
|
||||
struct adapter *adapter = ifp->if_softc;
|
||||
struct adapter *adapter = if_getsoftc(ifp);
|
||||
u32 reg_icr, rx_done = 0;
|
||||
|
||||
EM_CORE_LOCK(adapter);
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) {
|
||||
EM_CORE_UNLOCK(adapter);
|
||||
return (rx_done);
|
||||
}
|
||||
@ -1260,7 +1260,7 @@ lem_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
|
||||
|
||||
EM_TX_LOCK(adapter);
|
||||
lem_txeof(adapter);
|
||||
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if(!if_sendq_empty(ifp))
|
||||
lem_start_locked(ifp);
|
||||
EM_TX_UNLOCK(adapter);
|
||||
return (rx_done);
|
||||
@ -1276,12 +1276,12 @@ static void
|
||||
lem_intr(void *arg)
|
||||
{
|
||||
struct adapter *adapter = arg;
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
u32 reg_icr;
|
||||
|
||||
|
||||
if ((ifp->if_capenable & IFCAP_POLLING) ||
|
||||
((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0))
|
||||
if ((if_getcapenable(ifp) & IFCAP_POLLING) ||
|
||||
((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0))
|
||||
return;
|
||||
|
||||
EM_CORE_LOCK(adapter);
|
||||
@ -1311,8 +1311,8 @@ lem_intr(void *arg)
|
||||
|
||||
EM_TX_LOCK(adapter);
|
||||
lem_txeof(adapter);
|
||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
|
||||
!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) &&
|
||||
(!if_sendq_empty(ifp)))
|
||||
lem_start_locked(ifp);
|
||||
EM_TX_UNLOCK(adapter);
|
||||
return;
|
||||
@ -1323,9 +1323,9 @@ static void
|
||||
lem_handle_link(void *context, int pending)
|
||||
{
|
||||
struct adapter *adapter = context;
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
|
||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
|
||||
if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))
|
||||
return;
|
||||
|
||||
EM_CORE_LOCK(adapter);
|
||||
@ -1343,14 +1343,14 @@ static void
|
||||
lem_handle_rxtx(void *context, int pending)
|
||||
{
|
||||
struct adapter *adapter = context;
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
|
||||
|
||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
||||
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
|
||||
bool more = lem_rxeof(adapter, adapter->rx_process_limit, NULL);
|
||||
EM_TX_LOCK(adapter);
|
||||
lem_txeof(adapter);
|
||||
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
||||
if(!if_sendq_empty(ifp))
|
||||
lem_start_locked(ifp);
|
||||
EM_TX_UNLOCK(adapter);
|
||||
if (more) {
|
||||
@ -1359,7 +1359,7 @@ lem_handle_rxtx(void *context, int pending)
|
||||
}
|
||||
}
|
||||
|
||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
|
||||
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
|
||||
lem_enable_intr(adapter);
|
||||
}
|
||||
|
||||
@ -1372,7 +1372,7 @@ static int
|
||||
lem_irq_fast(void *arg)
|
||||
{
|
||||
struct adapter *adapter = arg;
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
u32 reg_icr;
|
||||
|
||||
ifp = adapter->ifp;
|
||||
@ -1416,9 +1416,9 @@ lem_irq_fast(void *arg)
|
||||
*
|
||||
**********************************************************************/
|
||||
static void
|
||||
lem_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
lem_media_status(if_t ifp, struct ifmediareq *ifmr)
|
||||
{
|
||||
struct adapter *adapter = ifp->if_softc;
|
||||
struct adapter *adapter = if_getsoftc(ifp);
|
||||
u_char fiber_type = IFM_1000_SX;
|
||||
|
||||
INIT_DEBUGOUT("lem_media_status: begin");
|
||||
@ -1470,9 +1470,9 @@ lem_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
*
|
||||
**********************************************************************/
|
||||
static int
|
||||
lem_media_change(struct ifnet *ifp)
|
||||
lem_media_change(if_t ifp)
|
||||
{
|
||||
struct adapter *adapter = ifp->if_softc;
|
||||
struct adapter *adapter = if_getsoftc(ifp);
|
||||
struct ifmedia *ifm = &adapter->media;
|
||||
|
||||
INIT_DEBUGOUT("lem_media_change: begin");
|
||||
@ -1849,18 +1849,18 @@ lem_82547_tx_fifo_reset(struct adapter *adapter)
|
||||
static void
|
||||
lem_set_promisc(struct adapter *adapter)
|
||||
{
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
u32 reg_rctl;
|
||||
|
||||
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
||||
|
||||
if (ifp->if_flags & IFF_PROMISC) {
|
||||
if (if_getflags(ifp) & IFF_PROMISC) {
|
||||
reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
|
||||
/* Turn this on if you want to see bad packets */
|
||||
if (lem_debug_sbp)
|
||||
reg_rctl |= E1000_RCTL_SBP;
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
|
||||
} else if (ifp->if_flags & IFF_ALLMULTI) {
|
||||
} else if (if_getflags(ifp) & IFF_ALLMULTI) {
|
||||
reg_rctl |= E1000_RCTL_MPE;
|
||||
reg_rctl &= ~E1000_RCTL_UPE;
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
|
||||
@ -1870,34 +1870,17 @@ lem_set_promisc(struct adapter *adapter)
|
||||
static void
|
||||
lem_disable_promisc(struct adapter *adapter)
|
||||
{
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
u32 reg_rctl;
|
||||
int mcnt = 0;
|
||||
|
||||
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
||||
reg_rctl &= (~E1000_RCTL_UPE);
|
||||
if (ifp->if_flags & IFF_ALLMULTI)
|
||||
if (if_getflags(ifp) & IFF_ALLMULTI)
|
||||
mcnt = MAX_NUM_MULTICAST_ADDRESSES;
|
||||
else {
|
||||
struct ifmultiaddr *ifma;
|
||||
#if __FreeBSD_version < 800000
|
||||
IF_ADDR_LOCK(ifp);
|
||||
#else
|
||||
if_maddr_rlock(ifp);
|
||||
#endif
|
||||
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
|
||||
if (ifma->ifma_addr->sa_family != AF_LINK)
|
||||
continue;
|
||||
if (mcnt == MAX_NUM_MULTICAST_ADDRESSES)
|
||||
break;
|
||||
mcnt++;
|
||||
}
|
||||
#if __FreeBSD_version < 800000
|
||||
IF_ADDR_UNLOCK(ifp);
|
||||
#else
|
||||
if_maddr_runlock(ifp);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
mcnt = if_multiaddr_count(ifp, MAX_NUM_MULTICAST_ADDRESSES);
|
||||
|
||||
/* Don't disable if in MAX groups */
|
||||
if (mcnt < MAX_NUM_MULTICAST_ADDRESSES)
|
||||
reg_rctl &= (~E1000_RCTL_MPE);
|
||||
@ -1916,8 +1899,7 @@ lem_disable_promisc(struct adapter *adapter)
|
||||
static void
|
||||
lem_set_multi(struct adapter *adapter)
|
||||
{
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
struct ifmultiaddr *ifma;
|
||||
if_t ifp = adapter->ifp;
|
||||
u32 reg_rctl = 0;
|
||||
u8 *mta; /* Multicast array memory */
|
||||
int mcnt = 0;
|
||||
@ -1937,27 +1919,8 @@ lem_set_multi(struct adapter *adapter)
|
||||
msec_delay(5);
|
||||
}
|
||||
|
||||
#if __FreeBSD_version < 800000
|
||||
IF_ADDR_LOCK(ifp);
|
||||
#else
|
||||
if_maddr_rlock(ifp);
|
||||
#endif
|
||||
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
|
||||
if (ifma->ifma_addr->sa_family != AF_LINK)
|
||||
continue;
|
||||
if_multiaddr_array(ifp, mta, &mcnt, MAX_NUM_MULTICAST_ADDRESSES);
|
||||
|
||||
if (mcnt == MAX_NUM_MULTICAST_ADDRESSES)
|
||||
break;
|
||||
|
||||
bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
|
||||
&mta[mcnt * ETH_ADDR_LEN], ETH_ADDR_LEN);
|
||||
mcnt++;
|
||||
}
|
||||
#if __FreeBSD_version < 800000
|
||||
IF_ADDR_UNLOCK(ifp);
|
||||
#else
|
||||
if_maddr_runlock(ifp);
|
||||
#endif
|
||||
if (mcnt >= MAX_NUM_MULTICAST_ADDRESSES) {
|
||||
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
||||
reg_rctl |= E1000_RCTL_MPE;
|
||||
@ -2009,7 +1972,7 @@ lem_local_timer(void *arg)
|
||||
return;
|
||||
hung:
|
||||
device_printf(adapter->dev, "Watchdog timeout -- resetting\n");
|
||||
adapter->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_setdrvflagbits(adapter->ifp, 0, IFF_DRV_RUNNING);
|
||||
adapter->watchdog_events++;
|
||||
lem_init_locked(adapter);
|
||||
}
|
||||
@ -2018,7 +1981,7 @@ static void
|
||||
lem_update_link_status(struct adapter *adapter)
|
||||
{
|
||||
struct e1000_hw *hw = &adapter->hw;
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
device_t dev = adapter->dev;
|
||||
u32 link_check = 0;
|
||||
|
||||
@ -2059,17 +2022,18 @@ lem_update_link_status(struct adapter *adapter)
|
||||
"Full Duplex" : "Half Duplex"));
|
||||
adapter->link_active = 1;
|
||||
adapter->smartspeed = 0;
|
||||
ifp->if_baudrate = adapter->link_speed * 1000000;
|
||||
if_link_state_change(ifp, LINK_STATE_UP);
|
||||
if_setbaudrate(ifp, adapter->link_speed * 1000000);
|
||||
if_linkstate_change_drv(ifp, LINK_STATE_UP);
|
||||
} else if (!link_check && (adapter->link_active == 1)) {
|
||||
ifp->if_baudrate = adapter->link_speed = 0;
|
||||
if_setbaudrate(ifp, 0);
|
||||
adapter->link_speed = 0;
|
||||
adapter->link_duplex = 0;
|
||||
if (bootverbose)
|
||||
device_printf(dev, "Link is Down\n");
|
||||
adapter->link_active = 0;
|
||||
/* Link down, disable watchdog */
|
||||
adapter->watchdog_check = FALSE;
|
||||
if_link_state_change(ifp, LINK_STATE_DOWN);
|
||||
if_linkstate_change_drv(ifp, LINK_STATE_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2086,7 +2050,7 @@ static void
|
||||
lem_stop(void *arg)
|
||||
{
|
||||
struct adapter *adapter = arg;
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
|
||||
EM_CORE_LOCK_ASSERT(adapter);
|
||||
EM_TX_LOCK_ASSERT(adapter);
|
||||
@ -2098,7 +2062,7 @@ lem_stop(void *arg)
|
||||
callout_stop(&adapter->tx_fifo_timer);
|
||||
|
||||
/* Tell the stack that the interface is no longer active */
|
||||
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
||||
if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
|
||||
|
||||
e1000_reset_hw(&adapter->hw);
|
||||
if (adapter->hw.mac.type >= e1000_82544)
|
||||
@ -2349,40 +2313,39 @@ lem_hardware_init(struct adapter *adapter)
|
||||
static int
|
||||
lem_setup_interface(device_t dev, struct adapter *adapter)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
|
||||
INIT_DEBUGOUT("lem_setup_interface: begin");
|
||||
|
||||
ifp = adapter->ifp = if_alloc(IFT_ETHER);
|
||||
if (ifp == NULL) {
|
||||
ifp = adapter->ifp = if_gethandle(IFT_ETHER);
|
||||
if (ifp == (void *)NULL) {
|
||||
device_printf(dev, "can not allocate ifnet structure\n");
|
||||
return (-1);
|
||||
}
|
||||
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
||||
ifp->if_init = lem_init;
|
||||
ifp->if_softc = adapter;
|
||||
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
||||
ifp->if_ioctl = lem_ioctl;
|
||||
ifp->if_start = lem_start;
|
||||
IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 1);
|
||||
ifp->if_snd.ifq_drv_maxlen = adapter->num_tx_desc - 1;
|
||||
IFQ_SET_READY(&ifp->if_snd);
|
||||
if_initname_drv(ifp, device_get_name(dev), device_get_unit(dev));
|
||||
if_setinitfn(ifp, lem_init);
|
||||
if_setsoftc(ifp, adapter);
|
||||
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
|
||||
if_setioctlfn(ifp, lem_ioctl);
|
||||
if_setstartfn(ifp, lem_start);
|
||||
if_setsendqlen(ifp, adapter->num_tx_desc - 1);
|
||||
if_setsendqready(ifp);
|
||||
|
||||
ether_ifattach(ifp, adapter->hw.mac.addr);
|
||||
ether_ifattach_drv(ifp, adapter->hw.mac.addr);
|
||||
|
||||
ifp->if_capabilities = ifp->if_capenable = 0;
|
||||
if_setcapabilities(ifp, 0);
|
||||
|
||||
if (adapter->hw.mac.type >= e1000_82543) {
|
||||
ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
|
||||
ifp->if_capenable |= IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM, 0);
|
||||
if_setcapenablebit(ifp, IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tell the upper layer(s) we support long frames.
|
||||
*/
|
||||
ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
|
||||
ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU;
|
||||
ifp->if_capenable |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU;
|
||||
if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
|
||||
if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU, 0);
|
||||
if_setcapenablebit(ifp, IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU, 0);
|
||||
|
||||
/*
|
||||
** Dont turn this on by default, if vlans are
|
||||
@ -2392,23 +2355,23 @@ lem_setup_interface(device_t dev, struct adapter *adapter)
|
||||
** using vlans directly on the em driver you can
|
||||
** enable this and get full hardware tag filtering.
|
||||
*/
|
||||
ifp->if_capabilities |= IFCAP_VLAN_HWFILTER;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWFILTER, 0);
|
||||
|
||||
#ifdef DEVICE_POLLING
|
||||
ifp->if_capabilities |= IFCAP_POLLING;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0);
|
||||
#endif
|
||||
|
||||
/* Enable only WOL MAGIC by default */
|
||||
if (adapter->wol) {
|
||||
ifp->if_capabilities |= IFCAP_WOL;
|
||||
ifp->if_capenable |= IFCAP_WOL_MAGIC;
|
||||
if_setcapabilitiesbit(ifp, IFCAP_WOL, 0);
|
||||
if_setcapenablebit(ifp, IFCAP_WOL_MAGIC, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify the media types supported by this adapter and register
|
||||
* callbacks to update media and link information
|
||||
*/
|
||||
ifmedia_init(&adapter->media, IFM_IMASK,
|
||||
ifmedia_init_drv(&adapter->media, IFM_IMASK,
|
||||
lem_media_change, lem_media_status);
|
||||
if ((adapter->hw.phy.media_type == e1000_media_type_fiber) ||
|
||||
(adapter->hw.phy.media_type == e1000_media_type_internal_serdes)) {
|
||||
@ -2655,7 +2618,7 @@ lem_setup_transmit_structures(struct adapter *adapter)
|
||||
struct em_buffer *tx_buffer;
|
||||
#ifdef DEV_NETMAP
|
||||
/* we are already locked */
|
||||
struct netmap_adapter *na = NA(adapter->ifp);
|
||||
struct netmap_adapter *na = netmap_getna(adapter->ifp);
|
||||
struct netmap_slot *slot = netmap_reset(na, NR_TX, 0, 0);
|
||||
#endif /* DEV_NETMAP */
|
||||
|
||||
@ -2981,7 +2944,7 @@ lem_txeof(struct adapter *adapter)
|
||||
int first, last, done, num_avail;
|
||||
struct em_buffer *tx_buffer;
|
||||
struct e1000_tx_desc *tx_desc, *eop_desc;
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
|
||||
EM_TX_LOCK_ASSERT(adapter);
|
||||
|
||||
@ -3021,7 +2984,7 @@ lem_txeof(struct adapter *adapter)
|
||||
++num_avail;
|
||||
|
||||
if (tx_buffer->m_head) {
|
||||
ifp->if_opackets++;
|
||||
if_incopackets(ifp, 1);
|
||||
bus_dmamap_sync(adapter->txtag,
|
||||
tx_buffer->map,
|
||||
BUS_DMASYNC_POSTWRITE);
|
||||
@ -3062,7 +3025,7 @@ lem_txeof(struct adapter *adapter)
|
||||
* If there are no pending descriptors, clear the watchdog.
|
||||
*/
|
||||
if (adapter->num_tx_desc_avail > EM_TX_CLEANUP_THRESHOLD) {
|
||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
||||
if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
|
||||
if (adapter->num_tx_desc_avail == adapter->num_tx_desc) {
|
||||
adapter->watchdog_check = FALSE;
|
||||
return;
|
||||
@ -3219,7 +3182,7 @@ lem_setup_receive_structures(struct adapter *adapter)
|
||||
int i, error;
|
||||
#ifdef DEV_NETMAP
|
||||
/* we are already under lock */
|
||||
struct netmap_adapter *na = NA(adapter->ifp);
|
||||
struct netmap_adapter *na = netmap_getna(adapter->ifp);
|
||||
struct netmap_slot *slot = netmap_reset(na, NR_RX, 0, 0);
|
||||
#endif
|
||||
|
||||
@ -3277,7 +3240,7 @@ lem_setup_receive_structures(struct adapter *adapter)
|
||||
static void
|
||||
lem_initialize_receive_unit(struct adapter *adapter)
|
||||
{
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
u64 bus_addr;
|
||||
u32 rctl, rxcsum;
|
||||
|
||||
@ -3342,14 +3305,14 @@ lem_initialize_receive_unit(struct adapter *adapter)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ifp->if_mtu > ETHERMTU)
|
||||
if (if_getmtu(ifp) > ETHERMTU)
|
||||
rctl |= E1000_RCTL_LPE;
|
||||
else
|
||||
rctl &= ~E1000_RCTL_LPE;
|
||||
|
||||
/* Enable 82543 Receive Checksum Offload for TCP and UDP */
|
||||
if ((adapter->hw.mac.type >= e1000_82543) &&
|
||||
(ifp->if_capenable & IFCAP_RXCSUM)) {
|
||||
(if_getcapenable(ifp) & IFCAP_RXCSUM)) {
|
||||
rxcsum = E1000_READ_REG(&adapter->hw, E1000_RXCSUM);
|
||||
rxcsum |= (E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL);
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_RXCSUM, rxcsum);
|
||||
@ -3366,8 +3329,10 @@ lem_initialize_receive_unit(struct adapter *adapter)
|
||||
rctl = adapter->num_rx_desc - 1; /* default RDT value */
|
||||
#ifdef DEV_NETMAP
|
||||
/* preserve buffers already made available to clients */
|
||||
if (ifp->if_capenable & IFCAP_NETMAP)
|
||||
rctl -= nm_kr_rxspace(&NA(adapter->ifp)->rx_rings[0]);
|
||||
if (if_getcapenable(ifp) & IFCAP_NETMAP) {
|
||||
struct netmap_adapter *na = netmap_getna(adapter->ifp);
|
||||
rctl -= nm_kr_rxspace(&na->rx_rings[0]);
|
||||
}
|
||||
#endif /* DEV_NETMAP */
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), rctl);
|
||||
|
||||
@ -3439,7 +3404,7 @@ lem_free_receive_structures(struct adapter *adapter)
|
||||
static bool
|
||||
lem_rxeof(struct adapter *adapter, int count, int *done)
|
||||
{
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
struct mbuf *mp;
|
||||
u8 status = 0, accept_frame = 0, eop = 0;
|
||||
u16 len, desc_len, prev_len_adj;
|
||||
@ -3466,7 +3431,7 @@ lem_rxeof(struct adapter *adapter, int count, int *done)
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
while (count != 0 && ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
||||
while (count != 0 && if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
|
||||
struct mbuf *m = NULL;
|
||||
|
||||
status = current_desc->status;
|
||||
@ -3520,7 +3485,7 @@ lem_rxeof(struct adapter *adapter, int count, int *done)
|
||||
|
||||
if (accept_frame) {
|
||||
if (lem_get_buf(adapter, i) != 0) {
|
||||
ifp->if_iqdrops++;
|
||||
if_inciqdrops(ifp, 1);
|
||||
goto discard;
|
||||
}
|
||||
|
||||
@ -3550,8 +3515,8 @@ lem_rxeof(struct adapter *adapter, int count, int *done)
|
||||
}
|
||||
|
||||
if (eop) {
|
||||
adapter->fmp->m_pkthdr.rcvif = ifp;
|
||||
ifp->if_ipackets++;
|
||||
if_setrcvif(adapter->fmp, ifp);
|
||||
if_incipackets(ifp, 1);
|
||||
lem_receive_checksum(adapter, current_desc,
|
||||
adapter->fmp);
|
||||
#ifndef __NO_STRICT_ALIGNMENT
|
||||
@ -3603,7 +3568,7 @@ discard:
|
||||
if (m != NULL) {
|
||||
adapter->next_rx_desc_to_check = i;
|
||||
EM_RX_UNLOCK(adapter);
|
||||
(*ifp->if_input)(ifp, m);
|
||||
if_input(ifp, m);
|
||||
EM_RX_LOCK(adapter);
|
||||
rx_sent++;
|
||||
i = adapter->next_rx_desc_to_check;
|
||||
@ -3716,12 +3681,12 @@ lem_receive_checksum(struct adapter *adapter,
|
||||
* config EVENT
|
||||
*/
|
||||
static void
|
||||
lem_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
|
||||
lem_register_vlan(void *arg, if_t ifp, u16 vtag)
|
||||
{
|
||||
struct adapter *adapter = ifp->if_softc;
|
||||
struct adapter *adapter = if_getsoftc(ifp);
|
||||
u32 index, bit;
|
||||
|
||||
if (ifp->if_softc != arg) /* Not our event */
|
||||
if (if_getsoftc(ifp) != arg) /* Not our event */
|
||||
return;
|
||||
|
||||
if ((vtag == 0) || (vtag > 4095)) /* Invalid ID */
|
||||
@ -3733,7 +3698,7 @@ lem_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
|
||||
adapter->shadow_vfta[index] |= (1 << bit);
|
||||
++adapter->num_vlans;
|
||||
/* Re-init to load the changes */
|
||||
if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
|
||||
if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
|
||||
lem_init_locked(adapter);
|
||||
EM_CORE_UNLOCK(adapter);
|
||||
}
|
||||
@ -3743,12 +3708,12 @@ lem_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
|
||||
* unconfig EVENT
|
||||
*/
|
||||
static void
|
||||
lem_unregister_vlan(void *arg, struct ifnet *ifp, u16 vtag)
|
||||
lem_unregister_vlan(void *arg, if_t ifp, u16 vtag)
|
||||
{
|
||||
struct adapter *adapter = ifp->if_softc;
|
||||
struct adapter *adapter = if_getsoftc(ifp);
|
||||
u32 index, bit;
|
||||
|
||||
if (ifp->if_softc != arg)
|
||||
if (if_getsoftc(ifp) != arg)
|
||||
return;
|
||||
|
||||
if ((vtag == 0) || (vtag > 4095)) /* Invalid */
|
||||
@ -3760,7 +3725,7 @@ lem_unregister_vlan(void *arg, struct ifnet *ifp, u16 vtag)
|
||||
adapter->shadow_vfta[index] &= ~(1 << bit);
|
||||
--adapter->num_vlans;
|
||||
/* Re-init to load the changes */
|
||||
if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
|
||||
if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
|
||||
lem_init_locked(adapter);
|
||||
EM_CORE_UNLOCK(adapter);
|
||||
}
|
||||
@ -3977,7 +3942,7 @@ static void
|
||||
lem_enable_wakeup(device_t dev)
|
||||
{
|
||||
struct adapter *adapter = device_get_softc(dev);
|
||||
struct ifnet *ifp = adapter->ifp;
|
||||
if_t ifp = adapter->ifp;
|
||||
u32 pmc, ctrl, ctrl_ext, rctl;
|
||||
u16 status;
|
||||
|
||||
@ -4002,10 +3967,10 @@ lem_enable_wakeup(device_t dev)
|
||||
** Determine type of Wakeup: note that wol
|
||||
** is set with all bits on by default.
|
||||
*/
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MAGIC) == 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) == 0)
|
||||
adapter->wol &= ~E1000_WUFC_MAG;
|
||||
|
||||
if ((ifp->if_capenable & IFCAP_WOL_MCAST) == 0)
|
||||
if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) == 0)
|
||||
adapter->wol &= ~E1000_WUFC_MC;
|
||||
else {
|
||||
rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
||||
@ -4025,7 +3990,7 @@ lem_enable_wakeup(device_t dev)
|
||||
/* Request PME */
|
||||
status = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2);
|
||||
status &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
|
||||
if (ifp->if_capenable & IFCAP_WOL)
|
||||
if (if_getcapenable(ifp) & IFCAP_WOL)
|
||||
status |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
|
||||
pci_write_config(dev, pmc + PCIR_POWER_STATUS, status, 2);
|
||||
|
||||
@ -4194,7 +4159,7 @@ lem_fill_descriptors (bus_addr_t address, u32 length,
|
||||
static void
|
||||
lem_update_stats_counters(struct adapter *adapter)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
|
||||
if(adapter->hw.phy.media_type == e1000_media_type_copper ||
|
||||
(E1000_READ_REG(&adapter->hw, E1000_STATUS) & E1000_STATUS_LU)) {
|
||||
@ -4271,17 +4236,17 @@ lem_update_stats_counters(struct adapter *adapter)
|
||||
}
|
||||
ifp = adapter->ifp;
|
||||
|
||||
ifp->if_collisions = adapter->stats.colc;
|
||||
if_setcollisions(ifp, adapter->stats.colc);
|
||||
|
||||
/* Rx Errors */
|
||||
ifp->if_ierrors = adapter->dropped_pkts + adapter->stats.rxerrc +
|
||||
if_setierrors(ifp, adapter->dropped_pkts + adapter->stats.rxerrc +
|
||||
adapter->stats.crcerrs + adapter->stats.algnerrc +
|
||||
adapter->stats.ruc + adapter->stats.roc +
|
||||
adapter->stats.mpc + adapter->stats.cexterr;
|
||||
adapter->stats.mpc + adapter->stats.cexterr);
|
||||
|
||||
/* Tx Errors */
|
||||
ifp->if_oerrors = adapter->stats.ecol +
|
||||
adapter->stats.latecol + adapter->watchdog_events;
|
||||
if_setoerrors(ifp, adapter->stats.ecol + adapter->stats.latecol +
|
||||
adapter->watchdog_events);
|
||||
}
|
||||
|
||||
/* Export a single 32-bit register via a read-only sysctl. */
|
||||
|
@ -295,7 +295,7 @@ struct em_int_delay_info {
|
||||
|
||||
/* Our adapter structure */
|
||||
struct adapter {
|
||||
struct ifnet *ifp;
|
||||
if_t ifp;
|
||||
#if __FreeBSD_version >= 800000
|
||||
struct buf_ring *br;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user