Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/virtio/network/if_vtnet.c
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/taskqueue.h> | #include <sys/taskqueue.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <machine/smp.h> | #include <machine/smp.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <net/debugnet.h> | |||||
#include <net/ethernet.h> | #include <net/ethernet.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/if_dl.h> | #include <net/if_dl.h> | ||||
#include <net/if_types.h> | #include <net/if_types.h> | ||||
#include <net/if_media.h> | #include <net/if_media.h> | ||||
#include <net/if_vlan_var.h> | #include <net/if_vlan_var.h> | ||||
#include <net/bpf.h> | #include <net/bpf.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/ip6.h> | #include <netinet/ip6.h> | ||||
#include <netinet6/ip6_var.h> | #include <netinet6/ip6_var.h> | ||||
#include <netinet/udp.h> | #include <netinet/udp.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/virtio/virtio.h> | #include <dev/virtio/virtio.h> | ||||
#include <dev/virtio/virtqueue.h> | #include <dev/virtio/virtqueue.h> | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | |||||
static void vtnet_enable_tx_interrupts(struct vtnet_softc *); | static void vtnet_enable_tx_interrupts(struct vtnet_softc *); | ||||
static void vtnet_enable_interrupts(struct vtnet_softc *); | static void vtnet_enable_interrupts(struct vtnet_softc *); | ||||
static void vtnet_disable_rx_interrupts(struct vtnet_softc *); | static void vtnet_disable_rx_interrupts(struct vtnet_softc *); | ||||
static void vtnet_disable_tx_interrupts(struct vtnet_softc *); | static void vtnet_disable_tx_interrupts(struct vtnet_softc *); | ||||
static void vtnet_disable_interrupts(struct vtnet_softc *); | static void vtnet_disable_interrupts(struct vtnet_softc *); | ||||
static int vtnet_tunable_int(struct vtnet_softc *, const char *, int); | static int vtnet_tunable_int(struct vtnet_softc *, const char *, int); | ||||
NETDUMP_DEFINE(vtnet); | DEBUGNET_DEFINE(vtnet); | ||||
/* Tunables. */ | /* Tunables. */ | ||||
static SYSCTL_NODE(_hw, OID_AUTO, vtnet, CTLFLAG_RD, 0, "VNET driver parameters"); | static SYSCTL_NODE(_hw, OID_AUTO, vtnet, CTLFLAG_RD, 0, "VNET driver parameters"); | ||||
static int vtnet_csum_disable = 0; | static int vtnet_csum_disable = 0; | ||||
TUNABLE_INT("hw.vtnet.csum_disable", &vtnet_csum_disable); | TUNABLE_INT("hw.vtnet.csum_disable", &vtnet_csum_disable); | ||||
SYSCTL_INT(_hw_vtnet, OID_AUTO, csum_disable, CTLFLAG_RDTUN, | SYSCTL_INT(_hw_vtnet, OID_AUTO, csum_disable, CTLFLAG_RDTUN, | ||||
&vtnet_csum_disable, 0, "Disables receive and send checksum offload"); | &vtnet_csum_disable, 0, "Disables receive and send checksum offload"); | ||||
static int vtnet_tso_disable = 0; | static int vtnet_tso_disable = 0; | ||||
▲ Show 20 Lines • Show All 778 Lines • ▼ Show 20 Lines | sc->vtnet_vlan_attach = EVENTHANDLER_REGISTER(vlan_config, | ||||
vtnet_register_vlan, sc, EVENTHANDLER_PRI_FIRST); | vtnet_register_vlan, sc, EVENTHANDLER_PRI_FIRST); | ||||
sc->vtnet_vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig, | sc->vtnet_vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig, | ||||
vtnet_unregister_vlan, sc, EVENTHANDLER_PRI_FIRST); | vtnet_unregister_vlan, sc, EVENTHANDLER_PRI_FIRST); | ||||
} | } | ||||
vtnet_set_rx_process_limit(sc); | vtnet_set_rx_process_limit(sc); | ||||
vtnet_set_tx_intr_threshold(sc); | vtnet_set_tx_intr_threshold(sc); | ||||
NETDUMP_SET(ifp, vtnet); | DEBUGNET_SET(ifp, vtnet); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
vtnet_change_mtu(struct vtnet_softc *sc, int new_mtu) | vtnet_change_mtu(struct vtnet_softc *sc, int new_mtu) | ||||
{ | { | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
▲ Show 20 Lines • Show All 2,930 Lines • ▼ Show 20 Lines | vtnet_tunable_int(struct vtnet_softc *sc, const char *knob, int def) | ||||
snprintf(path, sizeof(path), | snprintf(path, sizeof(path), | ||||
"hw.vtnet.%d.%s", device_get_unit(sc->vtnet_dev), knob); | "hw.vtnet.%d.%s", device_get_unit(sc->vtnet_dev), knob); | ||||
TUNABLE_INT_FETCH(path, &def); | TUNABLE_INT_FETCH(path, &def); | ||||
return (def); | return (def); | ||||
} | } | ||||
#ifdef NETDUMP | #ifdef DEBUGNET | ||||
static void | static void | ||||
vtnet_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize) | vtnet_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize) | ||||
{ | { | ||||
struct vtnet_softc *sc; | struct vtnet_softc *sc; | ||||
sc = if_getsoftc(ifp); | sc = if_getsoftc(ifp); | ||||
VTNET_CORE_LOCK(sc); | VTNET_CORE_LOCK(sc); | ||||
*nrxr = sc->vtnet_max_vq_pairs; | *nrxr = sc->vtnet_max_vq_pairs; | ||||
*ncl = NETDUMP_MAX_IN_FLIGHT; | *ncl = DEBUGNET_MAX_IN_FLIGHT; | ||||
*clsize = sc->vtnet_rx_clsize; | *clsize = sc->vtnet_rx_clsize; | ||||
VTNET_CORE_UNLOCK(sc); | VTNET_CORE_UNLOCK(sc); | ||||
/* | /* | ||||
* We need to allocate from this zone in the transmit path, so ensure | * We need to allocate from this zone in the transmit path, so ensure | ||||
* that we have at least one item per header available. | * that we have at least one item per header available. | ||||
* XXX add a separate zone like we do for mbufs? otherwise we may alloc | * XXX add a separate zone like we do for mbufs? otherwise we may alloc | ||||
* buckets | * buckets | ||||
*/ | */ | ||||
uma_zone_reserve(vtnet_tx_header_zone, NETDUMP_MAX_IN_FLIGHT * 2); | uma_zone_reserve(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2); | ||||
uma_prealloc(vtnet_tx_header_zone, NETDUMP_MAX_IN_FLIGHT * 2); | uma_prealloc(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2); | ||||
} | } | ||||
static void | static void | ||||
vtnet_netdump_event(struct ifnet *ifp __unused, enum netdump_ev event __unused) | vtnet_debugnet_event(struct ifnet *ifp __unused, enum debugnet_ev event __unused) | ||||
{ | { | ||||
} | } | ||||
static int | static int | ||||
vtnet_netdump_transmit(struct ifnet *ifp, struct mbuf *m) | vtnet_debugnet_transmit(struct ifnet *ifp, struct mbuf *m) | ||||
{ | { | ||||
struct vtnet_softc *sc; | struct vtnet_softc *sc; | ||||
struct vtnet_txq *txq; | struct vtnet_txq *txq; | ||||
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 (EBUSY); | return (EBUSY); | ||||
txq = &sc->vtnet_txqs[0]; | txq = &sc->vtnet_txqs[0]; | ||||
error = vtnet_txq_encap(txq, &m, M_NOWAIT | M_USE_RESERVE); | error = vtnet_txq_encap(txq, &m, M_NOWAIT | M_USE_RESERVE); | ||||
if (error == 0) | if (error == 0) | ||||
(void)vtnet_txq_notify(txq); | (void)vtnet_txq_notify(txq); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
vtnet_netdump_poll(struct ifnet *ifp, int count) | vtnet_debugnet_poll(struct ifnet *ifp, int count) | ||||
{ | { | ||||
struct vtnet_softc *sc; | struct vtnet_softc *sc; | ||||
int i; | int i; | ||||
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 (EBUSY); | return (EBUSY); | ||||
(void)vtnet_txq_eof(&sc->vtnet_txqs[0]); | (void)vtnet_txq_eof(&sc->vtnet_txqs[0]); | ||||
for (i = 0; i < sc->vtnet_max_vq_pairs; i++) | for (i = 0; i < sc->vtnet_max_vq_pairs; i++) | ||||
(void)vtnet_rxq_eof(&sc->vtnet_rxqs[i]); | (void)vtnet_rxq_eof(&sc->vtnet_rxqs[i]); | ||||
return (0); | return (0); | ||||
} | } | ||||
#endif /* NETDUMP */ | #endif /* DEBUGNET */ |