Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bge/if_bge.c
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/taskqueue.h> | #include <sys/taskqueue.h> | ||||
#include <net/debugnet.h> | |||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/if_arp.h> | #include <net/if_arp.h> | ||||
#include <net/ethernet.h> | #include <net/ethernet.h> | ||||
#include <net/if_dl.h> | #include <net/if_dl.h> | ||||
#include <net/if_media.h> | #include <net/if_media.h> | ||||
#include <net/bpf.h> | #include <net/bpf.h> | ||||
#include <net/if_types.h> | #include <net/if_types.h> | ||||
#include <net/if_vlan_var.h> | #include <net/if_vlan_var.h> | ||||
#include <netinet/in_systm.h> | #include <netinet/in_systm.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/ip.h> | #include <netinet/ip.h> | ||||
#include <netinet/tcp.h> | #include <netinet/tcp.h> | ||||
#include <netinet/netdump/netdump.h> | |||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#include <dev/mii/mii.h> | #include <dev/mii/mii.h> | ||||
#include <dev/mii/miivar.h> | #include <dev/mii/miivar.h> | ||||
▲ Show 20 Lines • Show All 402 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
static void bge_add_sysctls(struct bge_softc *); | static void bge_add_sysctls(struct bge_softc *); | ||||
static void bge_add_sysctl_stats_regs(struct bge_softc *, | static void bge_add_sysctl_stats_regs(struct bge_softc *, | ||||
struct sysctl_ctx_list *, struct sysctl_oid_list *); | struct sysctl_ctx_list *, struct sysctl_oid_list *); | ||||
static void bge_add_sysctl_stats(struct bge_softc *, struct sysctl_ctx_list *, | static void bge_add_sysctl_stats(struct bge_softc *, struct sysctl_ctx_list *, | ||||
struct sysctl_oid_list *); | struct sysctl_oid_list *); | ||||
static int bge_sysctl_stats(SYSCTL_HANDLER_ARGS); | static int bge_sysctl_stats(SYSCTL_HANDLER_ARGS); | ||||
NETDUMP_DEFINE(bge); | DEBUGNET_DEFINE(bge); | ||||
static device_method_t bge_methods[] = { | static device_method_t bge_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, bge_probe), | DEVMETHOD(device_probe, bge_probe), | ||||
DEVMETHOD(device_attach, bge_attach), | DEVMETHOD(device_attach, bge_attach), | ||||
DEVMETHOD(device_detach, bge_detach), | DEVMETHOD(device_detach, bge_detach), | ||||
DEVMETHOD(device_shutdown, bge_shutdown), | DEVMETHOD(device_shutdown, bge_shutdown), | ||||
DEVMETHOD(device_suspend, bge_suspend), | DEVMETHOD(device_suspend, bge_suspend), | ||||
▲ Show 20 Lines • Show All 3,447 Lines • ▼ Show 20 Lines | error = bus_setup_intr(dev, sc->bge_irq, | ||||
&sc->bge_intrhand); | &sc->bge_intrhand); | ||||
if (error) { | if (error) { | ||||
ether_ifdetach(ifp); | ether_ifdetach(ifp); | ||||
device_printf(sc->bge_dev, "couldn't set up irq\n"); | device_printf(sc->bge_dev, "couldn't set up irq\n"); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
/* Attach driver netdump methods. */ | /* Attach driver debugnet methods. */ | ||||
NETDUMP_SET(ifp, bge); | DEBUGNET_SET(ifp, bge); | ||||
fail: | fail: | ||||
if (error) | if (error) | ||||
bge_detach(dev); | bge_detach(dev); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
▲ Show 20 Lines • Show All 2,843 Lines • ▼ Show 20 Lines | return (stats->NoMoreRxBDs + stats->InputDiscards + | ||||
stats->InputErrors); | stats->InputErrors); | ||||
case IFCOUNTER_COLLISIONS: | case IFCOUNTER_COLLISIONS: | ||||
return (stats->etherStatsCollisions); | return (stats->etherStatsCollisions); | ||||
default: | default: | ||||
return (if_get_counter_default(ifp, cnt)); | return (if_get_counter_default(ifp, cnt)); | ||||
} | } | ||||
} | } | ||||
#ifdef NETDUMP | #ifdef DEBUGNET | ||||
static void | static void | ||||
bge_netdump_init(if_t ifp, int *nrxr, int *ncl, int *clsize) | bge_debugnet_init(if_t ifp, int *nrxr, int *ncl, int *clsize) | ||||
{ | { | ||||
struct bge_softc *sc; | struct bge_softc *sc; | ||||
sc = if_getsoftc(ifp); | sc = if_getsoftc(ifp); | ||||
BGE_LOCK(sc); | BGE_LOCK(sc); | ||||
*nrxr = sc->bge_return_ring_cnt; | *nrxr = sc->bge_return_ring_cnt; | ||||
*ncl = NETDUMP_MAX_IN_FLIGHT; | *ncl = DEBUGNET_MAX_IN_FLIGHT; | ||||
if ((sc->bge_flags & BGE_FLAG_JUMBO_STD) != 0 && | if ((sc->bge_flags & BGE_FLAG_JUMBO_STD) != 0 && | ||||
(if_getmtu(sc->bge_ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN + | (if_getmtu(sc->bge_ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN + | ||||
ETHER_VLAN_ENCAP_LEN > (MCLBYTES - ETHER_ALIGN))) | ETHER_VLAN_ENCAP_LEN > (MCLBYTES - ETHER_ALIGN))) | ||||
*clsize = MJUM9BYTES; | *clsize = MJUM9BYTES; | ||||
else | else | ||||
*clsize = MCLBYTES; | *clsize = MCLBYTES; | ||||
BGE_UNLOCK(sc); | BGE_UNLOCK(sc); | ||||
} | } | ||||
static void | static void | ||||
bge_netdump_event(if_t ifp __unused, enum netdump_ev event __unused) | bge_debugnet_event(if_t ifp __unused, enum debugnet_ev event __unused) | ||||
{ | { | ||||
} | } | ||||
static int | static int | ||||
bge_netdump_transmit(if_t ifp, struct mbuf *m) | bge_debugnet_transmit(if_t ifp, struct mbuf *m) | ||||
{ | { | ||||
struct bge_softc *sc; | struct bge_softc *sc; | ||||
uint32_t prodidx; | uint32_t prodidx; | ||||
int error; | int error; | ||||
sc = if_getsoftc(ifp); | sc = if_getsoftc(ifp); | ||||
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != | if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != | ||||
IFF_DRV_RUNNING) | IFF_DRV_RUNNING) | ||||
return (1); | return (1); | ||||
prodidx = sc->bge_tx_prodidx; | prodidx = sc->bge_tx_prodidx; | ||||
error = bge_encap(sc, &m, &prodidx); | error = bge_encap(sc, &m, &prodidx); | ||||
if (error == 0) | if (error == 0) | ||||
bge_start_tx(sc, prodidx); | bge_start_tx(sc, prodidx); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
bge_netdump_poll(if_t ifp, int count) | bge_debugnet_poll(if_t ifp, int count) | ||||
{ | { | ||||
struct bge_softc *sc; | struct bge_softc *sc; | ||||
uint32_t rx_prod, tx_cons; | uint32_t rx_prod, tx_cons; | ||||
sc = if_getsoftc(ifp); | sc = if_getsoftc(ifp); | ||||
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != | if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != | ||||
IFF_DRV_RUNNING) | IFF_DRV_RUNNING) | ||||
return (1); | return (1); | ||||
bus_dmamap_sync(sc->bge_cdata.bge_status_tag, | bus_dmamap_sync(sc->bge_cdata.bge_status_tag, | ||||
sc->bge_cdata.bge_status_map, | sc->bge_cdata.bge_status_map, | ||||
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); | BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); | ||||
rx_prod = sc->bge_ldata.bge_status_block->bge_idx[0].bge_rx_prod_idx; | rx_prod = sc->bge_ldata.bge_status_block->bge_idx[0].bge_rx_prod_idx; | ||||
tx_cons = sc->bge_ldata.bge_status_block->bge_idx[0].bge_tx_cons_idx; | tx_cons = sc->bge_ldata.bge_status_block->bge_idx[0].bge_tx_cons_idx; | ||||
bus_dmamap_sync(sc->bge_cdata.bge_status_tag, | bus_dmamap_sync(sc->bge_cdata.bge_status_tag, | ||||
sc->bge_cdata.bge_status_map, | sc->bge_cdata.bge_status_map, | ||||
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); | BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); | ||||
(void)bge_rxeof(sc, rx_prod, 0); | (void)bge_rxeof(sc, rx_prod, 0); | ||||
bge_txeof(sc, tx_cons); | bge_txeof(sc, tx_cons); | ||||
return (0); | return (0); | ||||
} | } | ||||
#endif /* NETDUMP */ | #endif /* DEBUGNET */ |