Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/netvsc/hv_net_vsc.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/if_arp.h> | #include <net/if_arp.h> | ||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <machine/atomic.h> | #include <machine/atomic.h> | ||||
#include <dev/hyperv/include/hyperv.h> | #include <dev/hyperv/include/hyperv.h> | ||||
#include <dev/hyperv/include/vmbus_xact.h> | #include <dev/hyperv/include/vmbus_xact.h> | ||||
#include <dev/hyperv/netvsc/hv_net_vsc.h> | #include <dev/hyperv/netvsc/hv_net_vsc.h> | ||||
#include <dev/hyperv/netvsc/hv_rndis.h> | |||||
#include <dev/hyperv/netvsc/hv_rndis_filter.h> | #include <dev/hyperv/netvsc/hv_rndis_filter.h> | ||||
#include <dev/hyperv/netvsc/if_hnreg.h> | #include <dev/hyperv/netvsc/if_hnreg.h> | ||||
#include <dev/hyperv/netvsc/if_hnvar.h> | |||||
MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver"); | MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver"); | ||||
/* | /* | ||||
* Forward declarations | * Forward declarations | ||||
*/ | */ | ||||
static void hv_nv_on_channel_callback(struct vmbus_channel *chan, | static void hv_nv_on_channel_callback(struct vmbus_channel *chan, | ||||
void *xrxr); | void *xrxr); | ||||
▲ Show 20 Lines • Show All 446 Lines • ▼ Show 20 Lines | hv_nv_connect_to_vsp(struct hn_softc *sc) | ||||
int rxbuf_size; | int rxbuf_size; | ||||
/* | /* | ||||
* Negotiate the NVSP version. Try the latest NVSP first. | * Negotiate the NVSP version. Try the latest NVSP first. | ||||
*/ | */ | ||||
for (i = protocol_number - 1; i >= 0; i--) { | for (i = protocol_number - 1; i >= 0; i--) { | ||||
if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { | if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { | ||||
sc->hn_nvs_ver = protocol_list[i]; | sc->hn_nvs_ver = protocol_list[i]; | ||||
sc->hn_ndis_ver = NDIS_VERSION_6_30; | sc->hn_ndis_ver = HN_NDIS_VERSION_6_30; | ||||
if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) | if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) | ||||
sc->hn_ndis_ver = NDIS_VERSION_6_1; | sc->hn_ndis_ver = HN_NDIS_VERSION_6_1; | ||||
if (bootverbose) { | if (bootverbose) { | ||||
if_printf(sc->hn_ifp, "NVS version 0x%x, " | if_printf(sc->hn_ifp, "NVS version 0x%x, " | ||||
"NDIS version %u.%u\n", | "NDIS version %u.%u\n", | ||||
sc->hn_nvs_ver, | sc->hn_nvs_ver, | ||||
NDIS_VERSION_MAJOR(sc->hn_ndis_ver), | HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), | ||||
NDIS_VERSION_MINOR(sc->hn_ndis_ver)); | HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (i < 0) { | if (i < 0) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(dev, "failed to negotiate a valid " | device_printf(dev, "failed to negotiate a valid " | ||||
Show All 9 Lines | if (sc->hn_nvs_ver >= NVSP_PROTOCOL_VERSION_2) | ||||
ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); | ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); | ||||
/* | /* | ||||
* Initialize NDIS. | * Initialize NDIS. | ||||
*/ | */ | ||||
memset(&ndis, 0, sizeof(ndis)); | memset(&ndis, 0, sizeof(ndis)); | ||||
ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; | ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; | ||||
ndis.nvs_ndis_major = NDIS_VERSION_MAJOR(sc->hn_ndis_ver); | ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver); | ||||
ndis.nvs_ndis_minor = NDIS_VERSION_MINOR(sc->hn_ndis_ver); | ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver); | ||||
/* NOTE: No response. */ | /* NOTE: No response. */ | ||||
ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); | ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); | ||||
if (ret != 0) { | if (ret != 0) { | ||||
if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); | if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); | ||||
goto cleanup; | goto cleanup; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | hv_nv_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, | ||||
hlen = VMBUS_CHANPKT_GETLEN(pkthdr->cph_hlen); | hlen = VMBUS_CHANPKT_GETLEN(pkthdr->cph_hlen); | ||||
if (__predict_false(hlen < sizeof(*pkt))) { | if (__predict_false(hlen < sizeof(*pkt))) { | ||||
if_printf(rxr->hn_ifp, "invalid rxbuf chanpkt\n"); | if_printf(rxr->hn_ifp, "invalid rxbuf chanpkt\n"); | ||||
return; | return; | ||||
} | } | ||||
pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; | pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; | ||||
if (__predict_false(pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID)) { | if (__predict_false(pkt->cp_rxbuf_id != HN_NVS_RXBUF_SIG)) { | ||||
if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", | if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", | ||||
pkt->cp_rxbuf_id); | pkt->cp_rxbuf_id); | ||||
return; | return; | ||||
} | } | ||||
count = pkt->cp_rxbuf_cnt; | count = pkt->cp_rxbuf_cnt; | ||||
if (__predict_false(hlen < | if (__predict_false(hlen < | ||||
__offsetof(struct vmbus_chanpkt_rxbuf, cp_rxbuf[count]))) { | __offsetof(struct vmbus_chanpkt_rxbuf, cp_rxbuf[count]))) { | ||||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |