Index: sys/dev/hyperv/netvsc/hv_net_vsc.h =================================================================== --- sys/dev/hyperv/netvsc/hv_net_vsc.h +++ sys/dev/hyperv/netvsc/hv_net_vsc.h @@ -99,11 +99,6 @@ #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) #define NETVSC_PACKET_MAXPAGE 32 -typedef struct { - uint8_t mac_addr[ETHER_ADDR_LEN]; - uint32_t link_state; -} netvsc_device_info; - #define HN_XACT_REQ_PGCNT 2 #define HN_XACT_RESP_PGCNT 2 #define HN_XACT_REQ_SIZE (HN_XACT_REQ_PGCNT * PAGE_SIZE) Index: sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c =================================================================== --- sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c +++ sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c @@ -440,7 +440,8 @@ { struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; - netvsc_device_info device_info; + uint8_t eaddr[ETHER_ADDR_LEN]; + uint32_t link_status; hn_softc_t *sc; int unit = device_get_unit(dev); struct ifnet *ifp = NULL; @@ -564,7 +565,7 @@ if (sc->hn_xact == NULL) goto failed; - error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, ETHERMTU); + error = hv_rf_on_device_add(sc, &ring_cnt, ETHERMTU); if (error) goto failed; KASSERT(ring_cnt > 0 && ring_cnt <= sc->hn_rx_ring_inuse, @@ -597,9 +598,11 @@ } #endif - if (device_info.link_state == NDIS_MEDIA_STATE_CONNECTED) { + error = hn_rndis_get_linkstatus(sc, &link_status); + if (error) + goto failed; + if (link_status == NDIS_MEDIA_STATE_CONNECTED) sc->hn_carrier = 1; - } #if __FreeBSD_version >= 1100045 tso_maxlen = hn_tso_maxlen; @@ -612,7 +615,10 @@ (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); #endif - ether_ifattach(ifp, device_info.mac_addr); + error = hn_rndis_get_eaddr(sc, eaddr); + if (error) + goto failed; + ether_ifattach(ifp, eaddr); #if __FreeBSD_version >= 1100045 if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, @@ -1503,7 +1509,6 @@ #ifdef INET struct ifaddr *ifa = (struct ifaddr *)data; #endif - netvsc_device_info device_info; int mask, error = 0, ring_cnt; int retry_cnt = 500; @@ -1583,8 +1588,7 @@ hn_chan_attach(sc, sc->hn_prichan); /* XXX check error */ ring_cnt = sc->hn_rx_ring_inuse; - error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, - ifr->ifr_mtu); + error = hv_rf_on_device_add(sc, &ring_cnt, ifr->ifr_mtu); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; Index: sys/dev/hyperv/netvsc/hv_rndis_filter.h =================================================================== --- sys/dev/hyperv/netvsc/hv_rndis_filter.h +++ sys/dev/hyperv/netvsc/hv_rndis_filter.h @@ -43,8 +43,7 @@ void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); -int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int *nchan, - int mtu); +int hv_rf_on_device_add(struct hn_softc *sc, int *nchan, int mtu); int hv_rf_on_device_remove(struct hn_softc *sc); int hv_rf_on_open(struct hn_softc *sc); int hv_rf_on_close(struct hn_softc *sc); Index: sys/dev/hyperv/netvsc/hv_rndis_filter.c =================================================================== --- sys/dev/hyperv/netvsc/hv_rndis_filter.c +++ sys/dev/hyperv/netvsc/hv_rndis_filter.c @@ -75,9 +75,6 @@ const void *data, int dlen); static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen); -static int hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr); -static int hv_rf_query_device_link_status(struct hn_softc *sc, - uint32_t *link_status); static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); @@ -479,11 +476,8 @@ } } -/* - * RNDIS filter query device MAC address - */ -static int -hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr) +int +hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr) { size_t eaddr_len; int error; @@ -500,11 +494,8 @@ return (0); } -/* - * RNDIS filter query device link status - */ -static int -hv_rf_query_device_link_status(struct hn_softc *sc, uint32_t *link_status) +int +hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t *link_status) { size_t size; int error; @@ -1024,11 +1015,9 @@ } int -hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, - int *nchan0, int mtu) +hv_rf_on_device_add(struct hn_softc *sc, int *nchan0, int mtu) { int ret; - netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; device_t dev = sc->hn_dev; int nchan = *nchan0, rxr_cnt, nsubch; @@ -1040,13 +1029,6 @@ if (ret != 0) return (ret); - /* Get the mac address */ - ret = hv_rf_query_device_mac(sc, dev_info->mac_addr); - if (ret != 0) { - /* TODO: shut down rndis device and the channel */ - } - hv_rf_query_device_link_status(sc, &dev_info->link_state); - if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30 || nchan == 1) { /* * Either RSS is not supported, or multiple RX/TX rings Index: sys/dev/hyperv/netvsc/if_hnvar.h =================================================================== --- sys/dev/hyperv/netvsc/if_hnvar.h +++ sys/dev/hyperv/netvsc/if_hnvar.h @@ -122,6 +122,9 @@ void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, size_t pktsize, size_t pi_dlen, uint32_t pi_type); +int hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr); +int hn_rndis_get_linkstatus(struct hn_softc *sc, + uint32_t *link_status); int hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch); int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_recvinfo *info);