diff options
author | sephe <sephe@FreeBSD.org> | 2017-01-05 08:57:49 +0000 |
---|---|---|
committer | sephe <sephe@FreeBSD.org> | 2017-01-05 08:57:49 +0000 |
commit | 2cff2ac5d9eaab792051c67257629aaed678b92c (patch) | |
tree | f9ea9081fe4022ca1f955c2487b31ae6d21516c9 /sys/dev/hyperv | |
parent | 5328a52ae01dee52a64be985d1c63402e86899a6 (diff) | |
download | FreeBSD-src-2cff2ac5d9eaab792051c67257629aaed678b92c.zip FreeBSD-src-2cff2ac5d9eaab792051c67257629aaed678b92c.tar.gz |
MFC 310652,310657,310658
310652
hyperv/hn: Consolidate hn_{suspend,resume}
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8907
310657
hyperv/hn: Function renaming; no functional changes.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8908
310658
hyperv/hn: Factor out function to set rxfilter.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8928
Diffstat (limited to 'sys/dev/hyperv')
-rw-r--r-- | sys/dev/hyperv/netvsc/if_hn.c | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index 90b5a85..ae4d37d 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -333,7 +333,8 @@ static void hn_link_status(struct hn_softc *); static int hn_create_rx_data(struct hn_softc *, int); static void hn_destroy_rx_data(struct hn_softc *); static int hn_check_iplen(const struct mbuf *, int); -static int hn_set_rxfilter(struct hn_softc *); +static int hn_set_rxfilter(struct hn_softc *, uint32_t); +static int hn_rxfilter_config(struct hn_softc *); #ifndef RSS static int hn_rss_reconfig(struct hn_softc *); #endif @@ -684,11 +685,25 @@ do { \ #endif /* INET6 || INET */ static int -hn_set_rxfilter(struct hn_softc *sc) +hn_set_rxfilter(struct hn_softc *sc, uint32_t filter) +{ + int error = 0; + + HN_LOCK_ASSERT(sc); + + if (sc->hn_rx_filter != filter) { + error = hn_rndis_set_rxfilter(sc, filter); + if (!error) + sc->hn_rx_filter = filter; + } + return (error); +} + +static int +hn_rxfilter_config(struct hn_softc *sc) { struct ifnet *ifp = sc->hn_ifp; uint32_t filter; - int error = 0; HN_LOCK_ASSERT(sc); @@ -703,13 +718,7 @@ hn_set_rxfilter(struct hn_softc *sc) !TAILQ_EMPTY(&ifp->if_multiaddrs)) filter |= NDIS_PACKET_TYPE_ALL_MULTICAST; } - - if (sc->hn_rx_filter != filter) { - error = hn_rndis_set_rxfilter(sc, filter); - if (!error) - sc->hn_rx_filter = filter; - } - return (error); + return (hn_set_rxfilter(sc, filter)); } static void @@ -2367,9 +2376,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } - /* Disable polling. */ - hn_polling(sc, 0); - /* * Suspend this interface before the synthetic parts * are ripped. @@ -2415,13 +2421,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) */ hn_resume(sc); - /* - * Re-enable polling if this interface is running and - * the polling is requested. - */ - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) && sc->hn_pollhz > 0) - hn_polling(sc, sc->hn_pollhz); - HN_UNLOCK(sc); break; @@ -2441,7 +2440,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) * reply. */ HN_NO_SLEEPING(sc); - hn_set_rxfilter(sc); + hn_rxfilter_config(sc); HN_SLEEPING_OK(sc); } else { hn_init_locked(sc); @@ -2518,7 +2517,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) * the RNDIS reply. */ HN_NO_SLEEPING(sc); - hn_set_rxfilter(sc); + hn_rxfilter_config(sc); HN_SLEEPING_OK(sc); } @@ -2576,7 +2575,7 @@ hn_init_locked(struct hn_softc *sc) return; /* Configure RX filter */ - hn_set_rxfilter(sc); + hn_rxfilter_config(sc); /* Clear OACTIVE bit. */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); @@ -4827,8 +4826,7 @@ hn_suspend_data(struct hn_softc *sc) /* * Disable RX by clearing RX filter. */ - sc->hn_rx_filter = NDIS_PACKET_TYPE_NONE; - hn_rndis_set_rxfilter(sc, sc->hn_rx_filter); + hn_set_rxfilter(sc, NDIS_PACKET_TYPE_NONE); /* * Give RNDIS enough time to flush all pending data packets. @@ -4900,6 +4898,9 @@ static void hn_suspend(struct hn_softc *sc) { + /* Disable polling. */ + hn_polling(sc, 0); + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) hn_suspend_data(sc); hn_suspend_mgmt(sc); @@ -4932,7 +4933,7 @@ hn_resume_data(struct hn_softc *sc) /* * Re-enable RX. */ - hn_set_rxfilter(sc); + hn_rxfilter_config(sc); /* * Make sure to clear suspend status on "all" TX rings, @@ -4992,6 +4993,13 @@ hn_resume(struct hn_softc *sc) if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) hn_resume_data(sc); hn_resume_mgmt(sc); + + /* + * Re-enable polling if this interface is running and + * the polling is requested. + */ + if ((sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) && sc->hn_pollhz > 0) + hn_polling(sc, sc->hn_pollhz); } static void |