summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSepherosa Ziehau <sephe@FreeBSD.org>2016-10-13 08:06:49 +0000
committerSepherosa Ziehau <sephe@FreeBSD.org>2016-10-13 08:06:49 +0000
commit276b347c54ddaa55501e8463e1dc365da7e9d72d (patch)
treef408b952f9df959a013c96017a91abbf036188ca
parentad4c48d3b305a8b1f72a0f2f15c5e58fb5150398 (diff)
Notes
-rw-r--r--sys/dev/hyperv/netvsc/hv_net_vsc.c64
1 files changed, 35 insertions, 29 deletions
diff --git a/sys/dev/hyperv/netvsc/hv_net_vsc.c b/sys/dev/hyperv/netvsc/hv_net_vsc.c
index 497f94e3204f0..67f66fbac4d4b 100644
--- a/sys/dev/hyperv/netvsc/hv_net_vsc.c
+++ b/sys/dev/hyperv/netvsc/hv_net_vsc.c
@@ -469,12 +469,10 @@ hn_nvs_doinit(struct hn_softc *sc, uint32_t nvs_ver)
}
/*
- * Send NDIS version 2 config packet containing MTU.
- *
- * Not valid for NDIS version 1.
+ * Configure MTU and enable VLAN.
*/
static int
-hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu)
+hn_nvs_conf_ndis(struct hn_softc *sc, int mtu)
{
struct hn_nvs_ndis_conf conf;
int error;
@@ -492,6 +490,24 @@ hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu)
}
static int
+hn_nvs_init_ndis(struct hn_softc *sc)
+{
+ struct hn_nvs_ndis_init ndis;
+ int error;
+
+ memset(&ndis, 0, sizeof(ndis));
+ ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT;
+ ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver);
+ ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver);
+
+ /* NOTE: No response. */
+ error = hn_nvs_req_send(sc, &ndis, sizeof(ndis));
+ if (error)
+ if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", error);
+ return (error);
+}
+
+static int
hn_nvs_init(struct hn_softc *sc)
{
int i;
@@ -521,47 +537,37 @@ hn_nvs_init(struct hn_softc *sc)
return (ENXIO);
}
-/*
- * Net VSC connect to VSP
- */
static int
hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu)
{
- int ret = 0;
- struct hn_nvs_ndis_init ndis;
+ int ret;
+ /*
+ * Initialize NVS.
+ */
ret = hn_nvs_init(sc);
if (ret != 0)
return (ret);
- /*
- * Set the MTU if supported by this NVSP protocol version
- * This needs to be right after the NVSP init message per Haiyang
- */
- if (sc->hn_nvs_ver >= HN_NVS_VERSION_2)
- ret = hv_nv_send_ndis_config(sc, mtu);
+ if (sc->hn_nvs_ver >= HN_NVS_VERSION_2) {
+ /*
+ * Configure NDIS before initializing it.
+ */
+ ret = hn_nvs_conf_ndis(sc, mtu);
+ if (ret != 0)
+ return (ret);
+ }
/*
* Initialize NDIS.
*/
-
- memset(&ndis, 0, sizeof(ndis));
- ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT;
- ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver);
- ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver);
-
- /* NOTE: No response. */
- ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis));
- if (ret != 0) {
- if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret);
- goto cleanup;
- }
+ ret = hn_nvs_init_ndis(sc);
+ if (ret != 0)
+ return (ret);
ret = hv_nv_init_rx_buffer_with_net_vsp(sc);
if (ret == 0)
ret = hv_nv_init_send_buffer_with_net_vsp(sc);
-
-cleanup:
return (ret);
}