Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | SYSCTL_UINT(_hw_hn, OID_AUTO, lro_mbufq_depth, CTLFLAG_RDTUN, | ||||
&hn_lro_mbufq_depth, 0, "Depth of LRO mbuf queue"); | &hn_lro_mbufq_depth, 0, "Depth of LRO mbuf queue"); | ||||
#endif | #endif | ||||
static u_int hn_cpu_index; | static u_int hn_cpu_index; | ||||
/* | /* | ||||
* Forward declarations | * Forward declarations | ||||
*/ | */ | ||||
static void hn_stop(hn_softc_t *sc); | static void hn_stop(struct hn_softc *sc); | ||||
static void hn_ifinit_locked(hn_softc_t *sc); | static void hn_ifinit_locked(struct hn_softc *sc); | ||||
static void hn_ifinit(void *xsc); | static void hn_ifinit(void *xsc); | ||||
static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); | static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); | ||||
static int hn_start_locked(struct hn_tx_ring *txr, int len); | static int hn_start_locked(struct hn_tx_ring *txr, int len); | ||||
static void hn_start(struct ifnet *ifp); | static void hn_start(struct ifnet *ifp); | ||||
static void hn_start_txeof(struct hn_tx_ring *); | static void hn_start_txeof(struct hn_tx_ring *); | ||||
static int hn_ifmedia_upd(struct ifnet *ifp); | static int hn_ifmedia_upd(struct ifnet *ifp); | ||||
static void hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); | static void hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); | ||||
#if __FreeBSD_version >= 1100099 | #if __FreeBSD_version >= 1100099 | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | |||||
* Standard attach entry point. | * Standard attach entry point. | ||||
* | * | ||||
* Called when the driver is loaded. It allocates needed resources, | * Called when the driver is loaded. It allocates needed resources, | ||||
* and initializes the "hardware" and software. | * and initializes the "hardware" and software. | ||||
*/ | */ | ||||
static int | static int | ||||
netvsc_attach(device_t dev) | netvsc_attach(device_t dev) | ||||
{ | { | ||||
struct hn_softc *sc = device_get_softc(dev); | |||||
struct sysctl_oid_list *child; | struct sysctl_oid_list *child; | ||||
struct sysctl_ctx_list *ctx; | struct sysctl_ctx_list *ctx; | ||||
uint8_t eaddr[ETHER_ADDR_LEN]; | uint8_t eaddr[ETHER_ADDR_LEN]; | ||||
uint32_t link_status; | uint32_t link_status; | ||||
hn_softc_t *sc; | |||||
struct ifnet *ifp = NULL; | struct ifnet *ifp = NULL; | ||||
int error, ring_cnt, tx_ring_cnt; | int error, ring_cnt, tx_ring_cnt; | ||||
#if __FreeBSD_version >= 1100045 | #if __FreeBSD_version >= 1100045 | ||||
int tso_maxlen; | int tso_maxlen; | ||||
#endif | #endif | ||||
sc = device_get_softc(dev); | |||||
sc->hn_dev = dev; | sc->hn_dev = dev; | ||||
sc->hn_prichan = vmbus_get_channel(dev); | sc->hn_prichan = vmbus_get_channel(dev); | ||||
if (hn_tx_taskq == NULL) { | if (hn_tx_taskq == NULL) { | ||||
sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, | sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, | ||||
taskqueue_thread_enqueue, &sc->hn_tx_taskq); | taskqueue_thread_enqueue, &sc->hn_tx_taskq); | ||||
if (hn_bind_tx_taskq >= 0) { | if (hn_bind_tx_taskq >= 0) { | ||||
int cpu = hn_bind_tx_taskq; | int cpu = hn_bind_tx_taskq; | ||||
▲ Show 20 Lines • Show All 1,016 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Standard ioctl entry point. Called when the user wants to configure | * Standard ioctl entry point. Called when the user wants to configure | ||||
* the interface. | * the interface. | ||||
*/ | */ | ||||
static int | static int | ||||
hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) | hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) | ||||
{ | { | ||||
hn_softc_t *sc = ifp->if_softc; | struct hn_softc *sc = ifp->if_softc; | ||||
struct ifreq *ifr = (struct ifreq *)data; | struct ifreq *ifr = (struct ifreq *)data; | ||||
#ifdef INET | #ifdef INET | ||||
struct ifaddr *ifa = (struct ifaddr *)data; | struct ifaddr *ifa = (struct ifaddr *)data; | ||||
#endif | #endif | ||||
int mask, error = 0; | int mask, error = 0; | ||||
int retry_cnt = 500; | int retry_cnt = 500; | ||||
switch(cmd) { | switch(cmd) { | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | #endif | ||||
default: | default: | ||||
error = ether_ioctl(ifp, cmd, data); | error = ether_ioctl(ifp, cmd, data); | ||||
break; | break; | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | |||||
* | |||||
*/ | |||||
static void | static void | ||||
hn_stop(hn_softc_t *sc) | hn_stop(struct hn_softc *sc) | ||||
{ | { | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
int ret, i; | int ret, i; | ||||
ifp = sc->hn_ifp; | ifp = sc->hn_ifp; | ||||
if (bootverbose) | if (bootverbose) | ||||
printf(" Closing Device ...\n"); | printf(" Closing Device ...\n"); | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | do_sched: | ||||
* flag again with the hn_tx_lock to avoid possible | * flag again with the hn_tx_lock to avoid possible | ||||
* races. | * races. | ||||
*/ | */ | ||||
atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); | atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); | ||||
taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_txeof_task); | taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_txeof_task); | ||||
} | } | ||||
} | } | ||||
/* | |||||
* | |||||
*/ | |||||
static void | static void | ||||
hn_ifinit_locked(hn_softc_t *sc) | hn_ifinit_locked(struct hn_softc *sc) | ||||
{ | { | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
int ret, i; | int ret, i; | ||||
ifp = sc->hn_ifp; | ifp = sc->hn_ifp; | ||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) { | if (ifp->if_drv_flags & IFF_DRV_RUNNING) { | ||||
return; | return; | ||||
Show All 17 Lines | |||||
} | } | ||||
/* | /* | ||||
* | * | ||||
*/ | */ | ||||
static void | static void | ||||
hn_ifinit(void *xsc) | hn_ifinit(void *xsc) | ||||
{ | { | ||||
hn_softc_t *sc = xsc; | struct hn_softc *sc = xsc; | ||||
NV_LOCK(sc); | NV_LOCK(sc); | ||||
if (sc->temp_unusable) { | if (sc->temp_unusable) { | ||||
NV_UNLOCK(sc); | NV_UNLOCK(sc); | ||||
return; | return; | ||||
} | } | ||||
sc->temp_unusable = TRUE; | sc->temp_unusable = TRUE; | ||||
NV_UNLOCK(sc); | NV_UNLOCK(sc); | ||||
▲ Show 20 Lines • Show All 1,639 Lines • ▼ Show 20 Lines | static device_method_t netvsc_methods[] = { | ||||
DEVMETHOD(device_shutdown, netvsc_shutdown), | DEVMETHOD(device_shutdown, netvsc_shutdown), | ||||
{ 0, 0 } | { 0, 0 } | ||||
}; | }; | ||||
static driver_t netvsc_driver = { | static driver_t netvsc_driver = { | ||||
NETVSC_DEVNAME, | NETVSC_DEVNAME, | ||||
netvsc_methods, | netvsc_methods, | ||||
sizeof(hn_softc_t) | sizeof(struct hn_softc) | ||||
}; | }; | ||||
static devclass_t netvsc_devclass; | static devclass_t netvsc_devclass; | ||||
DRIVER_MODULE(hn, vmbus, netvsc_driver, netvsc_devclass, 0, 0); | DRIVER_MODULE(hn, vmbus, netvsc_driver, netvsc_devclass, 0, 0); | ||||
MODULE_VERSION(hn, 1); | MODULE_VERSION(hn, 1); | ||||
MODULE_DEPEND(hn, vmbus, 1, 1, 1); | MODULE_DEPEND(hn, vmbus, 1, 1, 1); |