hyperv/hn: Regroup synthetic parts attach code.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7859
This commit is contained in:
Sepherosa Ziehau 2016-09-13 05:41:13 +00:00
parent 1f7866a48e
commit ec10046102

View File

@ -522,6 +522,14 @@ netvsc_attach(device_t dev)
if (error)
goto failed;
/*
* Create transaction context for NVS and RNDIS transactions.
*/
sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev),
HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE, 0);
if (sc->hn_xact == NULL)
goto failed;
/*
* Attach the primary channel before attaching NVS and RNDIS.
*/
@ -529,6 +537,26 @@ netvsc_attach(device_t dev)
if (error)
goto failed;
/*
* Attach NVS and RNDIS (synthetic parts).
*/
error = hv_rf_on_device_add(sc, &ring_cnt, ETHERMTU);
if (error)
goto failed;
/*
* Set the # of TX/RX rings that could be used according to
* the # of channels that host offered.
*/
hn_set_ring_inuse(sc, ring_cnt);
/*
* Attach the sub-channels, if any.
*/
error = hn_attach_subchans(sc);
if (error)
goto failed;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = hn_ioctl;
ifp->if_init = hn_ifinit;
@ -563,31 +591,6 @@ netvsc_attach(device_t dev)
IFCAP_LRO;
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, 0);
if (sc->hn_xact == NULL)
goto failed;
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,
("invalid channel count %d, should be less than %d",
ring_cnt, sc->hn_rx_ring_inuse));
/*
* Set the # of TX/RX rings that could be used according to
* the # of channels that host offered.
*/
hn_set_ring_inuse(sc, ring_cnt);
/*
* Attach the sub-channels, if any.
*/
error = hn_attach_subchans(sc);
if (error)
goto failed;
#if __FreeBSD_version >= 1100099
if (sc->hn_rx_ring_inuse > 1) {
/*