hyperv/hn: Reorganize the synthetic parts detach.
MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8047
This commit is contained in:
parent
65fe5a4627
commit
c04dad64e2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306391
@ -618,27 +618,15 @@ hn_nvs_attach(struct hn_softc *sc, int mtu)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Net VSC disconnect from VSP
|
||||
*/
|
||||
static void
|
||||
hv_nv_disconnect_from_vsp(struct hn_softc *sc)
|
||||
void
|
||||
hn_nvs_detach(struct hn_softc *sc)
|
||||
{
|
||||
|
||||
/* NOTE: there are no requests to stop the NVS. */
|
||||
hn_nvs_disconn_rxbuf(sc);
|
||||
hn_nvs_disconn_chim(sc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Net VSC on device remove
|
||||
*/
|
||||
int
|
||||
hv_nv_on_device_remove(struct hn_softc *sc)
|
||||
{
|
||||
|
||||
hv_nv_disconnect_from_vsp(sc);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
hn_nvs_sent_xact(struct hn_send_ctx *sndc,
|
||||
struct hn_softc *sc __unused, struct vmbus_channel *chan __unused,
|
||||
|
@ -269,8 +269,6 @@ extern int hv_promisc_mode;
|
||||
struct hn_send_ctx;
|
||||
|
||||
void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status);
|
||||
int hn_nvs_attach(struct hn_softc *sc, int mtu);
|
||||
int hv_nv_on_device_remove(struct hn_softc *sc);
|
||||
int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype,
|
||||
struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt);
|
||||
|
||||
|
@ -348,6 +348,7 @@ static void hn_detach_allchans(struct hn_softc *);
|
||||
static void hn_chan_callback(struct vmbus_channel *chan, void *xrxr);
|
||||
static void hn_set_ring_inuse(struct hn_softc *, int);
|
||||
static int hn_synth_attach(struct hn_softc *, int);
|
||||
static void hn_synth_detach(struct hn_softc *);
|
||||
static bool hn_tx_ring_pending(struct hn_tx_ring *);
|
||||
static void hn_suspend(struct hn_softc *);
|
||||
static void hn_resume(struct hn_softc *);
|
||||
@ -744,29 +745,19 @@ netvsc_attach(device_t dev)
|
||||
}
|
||||
|
||||
/*
|
||||
* Standard detach entry point
|
||||
* TODO: Use this for error handling on attach path.
|
||||
*/
|
||||
static int
|
||||
netvsc_detach(device_t dev)
|
||||
{
|
||||
struct hn_softc *sc = device_get_softc(dev);
|
||||
|
||||
if (bootverbose)
|
||||
printf("netvsc_detach\n");
|
||||
/* TODO: ether_ifdetach */
|
||||
|
||||
/*
|
||||
* XXXKYS: Need to clean up all our
|
||||
* driver state; this is the driver
|
||||
* unloading.
|
||||
*/
|
||||
|
||||
/*
|
||||
* XXXKYS: Need to stop outgoing traffic and unregister
|
||||
* the netdevice.
|
||||
*/
|
||||
|
||||
hv_rf_on_device_remove(sc);
|
||||
hn_detach_allchans(sc);
|
||||
HN_LOCK(sc);
|
||||
/* TODO: hn_stop */
|
||||
hn_synth_detach(sc);
|
||||
HN_UNLOCK(sc);
|
||||
|
||||
hn_stop_tx_tasks(sc);
|
||||
|
||||
@ -779,6 +770,8 @@ netvsc_detach(device_t dev)
|
||||
|
||||
vmbus_xact_ctx_destroy(sc->hn_xact);
|
||||
HN_LOCK_DESTROY(sc);
|
||||
|
||||
/* TODO: if_free */
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1654,23 +1647,14 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
|
||||
hn_suspend(sc);
|
||||
|
||||
/* We must remove and add back the device to cause the new
|
||||
* MTU to take effect. This includes tearing down, but not
|
||||
* deleting the channel, then bringing it back up.
|
||||
/*
|
||||
* Detach the synthetics parts, i.e. NVS and RNDIS.
|
||||
*/
|
||||
error = hv_rf_on_device_remove(sc);
|
||||
if (error) {
|
||||
HN_UNLOCK(sc);
|
||||
break;
|
||||
}
|
||||
hn_synth_detach(sc);
|
||||
|
||||
/*
|
||||
* Detach all of the channels.
|
||||
*/
|
||||
hn_detach_allchans(sc);
|
||||
|
||||
/*
|
||||
* Attach the synthetic parts, i.e. NVS and RNDIS.
|
||||
* Reattach the synthetic parts, i.e. NVS and RNDIS,
|
||||
* with the new MTU setting.
|
||||
* XXX check error.
|
||||
*/
|
||||
hn_synth_attach(sc, ifr->ifr_mtu);
|
||||
@ -3520,6 +3504,26 @@ hn_synth_attach(struct hn_softc *sc, int mtu)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE:
|
||||
* The interface must have been suspended though hn_suspend(), before
|
||||
* this function get called.
|
||||
*/
|
||||
static void
|
||||
hn_synth_detach(struct hn_softc *sc)
|
||||
{
|
||||
HN_LOCK_ASSERT(sc);
|
||||
|
||||
/* Detach the RNDIS first. */
|
||||
hn_rndis_detach(sc);
|
||||
|
||||
/* Detach NVS. */
|
||||
hn_nvs_detach(sc);
|
||||
|
||||
/* Detach all of the channels. */
|
||||
hn_detach_allchans(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
hn_set_ring_inuse(struct hn_softc *sc, int ring_cnt)
|
||||
{
|
||||
|
@ -957,11 +957,8 @@ hn_rndis_init(struct hn_softc *sc)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* RNDIS filter halt device
|
||||
*/
|
||||
static int
|
||||
hv_rf_halt_device(struct hn_softc *sc)
|
||||
hn_rndis_halt(struct hn_softc *sc)
|
||||
{
|
||||
struct vmbus_xact *xact;
|
||||
struct rndis_halt_req *halt;
|
||||
@ -1008,21 +1005,12 @@ hn_rndis_attach(struct hn_softc *sc)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RNDIS filter on device remove
|
||||
*/
|
||||
int
|
||||
hv_rf_on_device_remove(struct hn_softc *sc)
|
||||
void
|
||||
hn_rndis_detach(struct hn_softc *sc)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Halt and release the rndis device */
|
||||
ret = hv_rf_halt_device(sc);
|
||||
|
||||
/* Pass control to inner driver to remove the device */
|
||||
ret |= hv_nv_on_device_remove(sc);
|
||||
|
||||
return (ret);
|
||||
/* Halt the RNDIS. */
|
||||
hn_rndis_halt(sc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -43,7 +43,6 @@ struct hn_rx_ring;
|
||||
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_remove(struct hn_softc *sc);
|
||||
int hv_rf_on_open(struct hn_softc *sc);
|
||||
int hv_rf_on_close(struct hn_softc *sc);
|
||||
|
||||
|
@ -118,6 +118,7 @@ uint32_t hn_chim_alloc(struct hn_softc *sc);
|
||||
void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx);
|
||||
|
||||
int hn_rndis_attach(struct hn_softc *sc);
|
||||
void hn_rndis_detach(struct hn_softc *sc);
|
||||
int hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags);
|
||||
void *hn_rndis_pktinfo_append(struct rndis_packet_msg *,
|
||||
size_t pktsize, size_t pi_dlen, uint32_t pi_type);
|
||||
@ -127,6 +128,7 @@ int hn_rndis_get_linkstatus(struct hn_softc *sc,
|
||||
uint32_t *link_status);
|
||||
|
||||
int hn_nvs_attach(struct hn_softc *sc, int mtu);
|
||||
void hn_nvs_detach(struct hn_softc *sc);
|
||||
int hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch);
|
||||
void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc,
|
||||
struct vmbus_channel *chan, const void *data, int dlen);
|
||||
|
Loading…
Reference in New Issue
Block a user