Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/netvsc/hv_net_vsc.c
Show First 20 Lines • Show All 587 Lines • ▼ Show 20 Lines | hv_nv_connect_to_vsp(struct hn_softc *sc) | ||||
net_dev = hv_nv_get_outbound_net_device(sc); | net_dev = hv_nv_get_outbound_net_device(sc); | ||||
/* | /* | ||||
* 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, net_dev, | if (hv_nv_negotiate_nvsp_protocol(sc, net_dev, | ||||
protocol_list[i]) == 0) { | protocol_list[i]) == 0) { | ||||
net_dev->nvsp_version = protocol_list[i]; | sc->hn_nvs_ver = protocol_list[i]; | ||||
if (bootverbose) | if (bootverbose) { | ||||
device_printf(dev, "Netvsc: got version 0x%x\n", | device_printf(dev, "NVS version 0x%x\n", | ||||
net_dev->nvsp_version); | sc->hn_nvs_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 " | ||||
"protocol.\n"); | "protocol.\n"); | ||||
return (EPROTO); | return (EPROTO); | ||||
} | } | ||||
/* | /* | ||||
* Set the MTU if supported by this NVSP protocol version | * Set the MTU if supported by this NVSP protocol version | ||||
* This needs to be right after the NVSP init message per Haiyang | * This needs to be right after the NVSP init message per Haiyang | ||||
*/ | */ | ||||
if (net_dev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) | 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_6; | ndis.nvs_ndis_major = NDIS_VERSION_MAJOR_6; | ||||
if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_4) | if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) | ||||
ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_1; | ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_1; | ||||
else | else | ||||
ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; | ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; | ||||
/* NOTE: No response. */ | /* NOTE: No response. */ | ||||
ret = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, | ret = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, | ||||
&ndis, sizeof(ndis), &hn_send_ctx_none); | &ndis, sizeof(ndis), &hn_send_ctx_none); | ||||
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; | ||||
} | } | ||||
/* Post the big receive buffer to NetVSP */ | /* Post the big receive buffer to NetVSP */ | ||||
if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_2) | if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_2) | ||||
net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; | net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; | ||||
else | else | ||||
net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE; | net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE; | ||||
net_dev->send_buf_size = NETVSC_SEND_BUFFER_SIZE; | net_dev->send_buf_size = NETVSC_SEND_BUFFER_SIZE; | ||||
ret = hv_nv_init_rx_buffer_with_net_vsp(sc); | ret = hv_nv_init_rx_buffer_with_net_vsp(sc); | ||||
if (ret == 0) | if (ret == 0) | ||||
ret = hv_nv_init_send_buffer_with_net_vsp(sc); | ret = hv_nv_init_send_buffer_with_net_vsp(sc); | ||||
▲ Show 20 Lines • Show All 353 Lines • Show Last 20 Lines |