Page MenuHomeFreeBSD

D8047.diff
No OneTemporary

D8047.diff

Index: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
===================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h
@@ -269,8 +269,6 @@
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);
Index: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
===================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c
@@ -618,27 +618,15 @@
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,
Index: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
===================================================================
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -348,6 +348,7 @@
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 @@
}
/*
- * 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");
-
- /*
- * XXXKYS: Need to clean up all our
- * driver state; this is the driver
- * unloading.
- */
+ /* TODO: ether_ifdetach */
- /*
- * 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 @@
vmbus_xact_ctx_destroy(sc->hn_xact);
HN_LOCK_DESTROY(sc);
+
+ /* TODO: if_free */
return (0);
}
@@ -1654,23 +1647,14 @@
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.
- */
- error = hv_rf_on_device_remove(sc);
- if (error) {
- HN_UNLOCK(sc);
- break;
- }
-
/*
- * Detach all of the channels.
+ * Detach the synthetics parts, i.e. NVS and RNDIS.
*/
- hn_detach_allchans(sc);
+ hn_synth_detach(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 @@
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)
{
Index: head/sys/dev/hyperv/netvsc/hv_rndis_filter.h
===================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.h
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.h
@@ -43,7 +43,6 @@
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);
Index: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
===================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
@@ -957,11 +957,8 @@
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 @@
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);
}
/*
Index: head/sys/dev/hyperv/netvsc/if_hnvar.h
===================================================================
--- head/sys/dev/hyperv/netvsc/if_hnvar.h
+++ head/sys/dev/hyperv/netvsc/if_hnvar.h
@@ -118,6 +118,7 @@
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 @@
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);

File Metadata

Mime Type
text/plain
Expires
Sun, Feb 8, 8:26 PM (14 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28494413
Default Alt Text
D8047.diff (6 KB)

Event Timeline