svn commit: r311258 - stable/10/sys/dev/hyperv/netvsc

Sepherosa Ziehau sephe at FreeBSD.org
Wed Jan 4 05:45:57 UTC 2017


Author: sephe
Date: Wed Jan  4 05:45:56 2017
New Revision: 311258
URL: https://svnweb.freebsd.org/changeset/base/311258

Log:
  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

Modified:
  stable/10/sys/dev/hyperv/netvsc/if_hn.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/if_hn.c	Wed Jan  4 05:41:47 2017	(r311257)
+++ stable/10/sys/dev/hyperv/netvsc/if_hn.c	Wed Jan  4 05:45:56 2017	(r311258)
@@ -326,7 +326,8 @@ static void			hn_link_status(struct hn_s
 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 *);
 static int			hn_rss_reconfig(struct hn_softc *);
 static void			hn_rss_ind_fixup(struct hn_softc *);
 static int			hn_rxpkt(struct hn_rx_ring *, const void *,
@@ -673,11 +674,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);
 
@@ -692,13 +707,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
@@ -2354,9 +2363,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 			break;
 		}
 
-		/* Disable polling. */
-		hn_polling(sc, 0);
-
 		/*
 		 * Suspend this interface before the synthetic parts
 		 * are ripped.
@@ -2402,13 +2408,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 		 */
 		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;
 
@@ -2428,7 +2427,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 				 * reply.
 				 */
 				HN_NO_SLEEPING(sc);
-				hn_set_rxfilter(sc);
+				hn_rxfilter_config(sc);
 				HN_SLEEPING_OK(sc);
 			} else {
 				hn_init_locked(sc);
@@ -2505,7 +2504,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 			 * the RNDIS reply.
 			 */
 			HN_NO_SLEEPING(sc);
-			hn_set_rxfilter(sc);
+			hn_rxfilter_config(sc);
 			HN_SLEEPING_OK(sc);
 		}
 
@@ -2563,7 +2562,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);
@@ -4781,8 +4780,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.
@@ -4854,6 +4852,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);
@@ -4886,7 +4887,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,
@@ -4946,6 +4947,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 


More information about the svn-src-all mailing list