Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | |||||
#include <machine/atomic.h> | #include <machine/atomic.h> | ||||
#include <machine/intr_machdep.h> | #include <machine/intr_machdep.h> | ||||
#include <machine/in_cksum.h> | #include <machine/in_cksum.h> | ||||
#include <dev/hyperv/include/hyperv.h> | #include <dev/hyperv/include/hyperv.h> | ||||
#include <dev/hyperv/include/hyperv_busdma.h> | #include <dev/hyperv/include/hyperv_busdma.h> | ||||
#include <dev/hyperv/include/vmbus_xact.h> | |||||
#include "hv_net_vsc.h" | #include "hv_net_vsc.h" | ||||
#include "hv_rndis.h" | #include "hv_rndis.h" | ||||
#include "hv_rndis_filter.h" | #include "hv_rndis_filter.h" | ||||
#include "vmbus_if.h" | #include "vmbus_if.h" | ||||
/* Short for Hyper-V network interface */ | /* Short for Hyper-V network interface */ | ||||
#define NETVSC_DEVNAME "hn" | #define NETVSC_DEVNAME "hn" | ||||
#define HN_XACT_REQ_SIZE (2 * PAGE_SIZE) | |||||
#define HN_XACT_RESP_SIZE (2 * PAGE_SIZE) | |||||
/* | /* | ||||
* It looks like offset 0 of buf is reserved to hold the softc pointer. | * It looks like offset 0 of buf is reserved to hold the softc pointer. | ||||
* The sc pointer evidently not needed, and is not presently populated. | * The sc pointer evidently not needed, and is not presently populated. | ||||
* The packet offset is where the netvsc_packet starts in the buffer. | * The packet offset is where the netvsc_packet starts in the buffer. | ||||
*/ | */ | ||||
#define HV_NV_SC_PTR_OFFSET_IN_BUF 0 | #define HV_NV_SC_PTR_OFFSET_IN_BUF 0 | ||||
#define HV_NV_PACKET_OFFSET_IN_BUF 16 | #define HV_NV_PACKET_OFFSET_IN_BUF 16 | ||||
▲ Show 20 Lines • Show All 402 Lines • ▼ Show 20 Lines | #endif | ||||
ifp->if_capabilities |= | ifp->if_capabilities |= | ||||
IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | | IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | | ||||
IFCAP_LRO; | IFCAP_LRO; | ||||
ifp->if_capenable |= | ifp->if_capenable |= | ||||
IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | | IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | | ||||
IFCAP_LRO; | IFCAP_LRO; | ||||
ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; | ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; | ||||
sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev), | |||||
HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE); | |||||
if (sc->hn_xact == NULL) | |||||
goto failed; | |||||
error = hv_rf_on_device_add(sc, &device_info, ring_cnt, | error = hv_rf_on_device_add(sc, &device_info, ring_cnt, | ||||
&sc->hn_rx_ring[0]); | &sc->hn_rx_ring[0]); | ||||
if (error) | if (error) | ||||
goto failed; | goto failed; | ||||
KASSERT(sc->net_dev->num_channel > 0 && | KASSERT(sc->net_dev->num_channel > 0 && | ||||
sc->net_dev->num_channel <= sc->hn_rx_ring_inuse, | sc->net_dev->num_channel <= sc->hn_rx_ring_inuse, | ||||
("invalid channel count %u, should be less than %d", | ("invalid channel count %u, should be less than %d", | ||||
sc->net_dev->num_channel, sc->hn_rx_ring_inuse)); | sc->net_dev->num_channel, sc->hn_rx_ring_inuse)); | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | netvsc_detach(device_t dev) | ||||
ifmedia_removeall(&sc->hn_media); | ifmedia_removeall(&sc->hn_media); | ||||
hn_destroy_rx_data(sc); | hn_destroy_rx_data(sc); | ||||
hn_destroy_tx_data(sc); | hn_destroy_tx_data(sc); | ||||
if (sc->hn_tx_taskq != hn_tx_taskq) | if (sc->hn_tx_taskq != hn_tx_taskq) | ||||
taskqueue_free(sc->hn_tx_taskq); | taskqueue_free(sc->hn_tx_taskq); | ||||
vmbus_xact_ctx_destroy(sc->hn_xact); | |||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Standard shutdown entry point | * Standard shutdown entry point | ||||
*/ | */ | ||||
static int | static int | ||||
netvsc_shutdown(device_t dev) | netvsc_shutdown(device_t dev) | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | |||||
hn_txeof(struct hn_tx_ring *txr) | hn_txeof(struct hn_tx_ring *txr) | ||||
{ | { | ||||
txr->hn_has_txeof = 0; | txr->hn_has_txeof = 0; | ||||
txr->hn_txeof(txr); | txr->hn_txeof(txr); | ||||
} | } | ||||
static void | static void | ||||
hn_tx_done(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, | hn_tx_done(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, | ||||
struct vmbus_channel *chan, const struct nvsp_msg_ *msg __unused) | struct vmbus_channel *chan, const struct nvsp_msg_ *msg __unused, | ||||
int dlen __unused) | |||||
{ | { | ||||
struct hn_txdesc *txd = sndc->hn_cbarg; | struct hn_txdesc *txd = sndc->hn_cbarg; | ||||
struct hn_tx_ring *txr; | struct hn_tx_ring *txr; | ||||
if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) | if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) | ||||
hn_chim_free(net_dev, sndc->hn_chim_idx); | hn_chim_free(net_dev, sndc->hn_chim_idx); | ||||
txr = txd->txr; | txr = txd->txr; | ||||
▲ Show 20 Lines • Show All 2,241 Lines • Show Last 20 Lines |