Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Oct 2016 08:56:53 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r307208 - stable/10/sys/dev/hyperv/netvsc
Message-ID:  <201610130856.u9D8urVR050361@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Thu Oct 13 08:56:52 2016
New Revision: 307208
URL: https://svnweb.freebsd.org/changeset/base/307208

Log:
  MFC 305790-305793
  
  305790
      hyperv/hn: Remove unused softc field
  
      Sponsored by:   Microsoft
      Differential Revision:  https://reviews.freebsd.org/D7866
  
  305791
      hyperv/hn: Deprecate hn_softc_t
  
      Sponsored by:   Microsoft
      Differential Revision:  https://reviews.freebsd.org/D7867
  
  305792
      hyperv/hn: Function renaming: hn_ifinit -> hn_init
  
      No functional changes.
  
      Sponsored by:   Microsoft
      Differential Revision:  https://reviews.freebsd.org/D7868
  
  305793
      hyperv/hn: Cleanup hn_ioctl.
  
      Sponsored by:   Microsoft
      Differential Revision:  https://reviews.freebsd.org/D7869

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

Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h	Thu Oct 13 08:50:18 2016	(r307207)
+++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h	Thu Oct 13 08:56:52 2016	(r307208)
@@ -198,12 +198,11 @@ struct hn_tx_ring {
 /*
  * Device-specific softc structure
  */
-typedef struct hn_softc {
+struct hn_softc {
 	struct ifnet    *hn_ifp;
 	struct arpcom   arpcom;
 	struct ifmedia	hn_media;
 	device_t        hn_dev;
-	uint8_t         hn_unit;
 	int             hn_carrier;
 	int             hn_if_flags;
 	struct mtx      hn_lock;
@@ -245,7 +244,7 @@ typedef struct hn_softc {
 	uint32_t		hn_ndis_ver;
 
 	struct ndis_rssprm_toeplitz hn_rss;
-} hn_softc_t;
+};
 
 #define HN_FLAG_RXBUF_CONNECTED		0x0001
 #define HN_FLAG_CHIM_CONNECTED		0x0002

Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Thu Oct 13 08:50:18 2016	(r307207)
+++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Thu Oct 13 08:56:52 2016	(r307208)
@@ -312,9 +312,9 @@ static u_int hn_cpu_index;
 /*
  * Forward declarations
  */
-static void hn_stop(hn_softc_t *sc);
-static void hn_ifinit_locked(hn_softc_t *sc);
-static void hn_ifinit(void *xsc);
+static void hn_stop(struct hn_softc *sc);
+static void hn_init_locked(struct hn_softc *sc);
+static void hn_init(void *xsc);
 static int  hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
 static int hn_start_locked(struct hn_tx_ring *txr, int len);
 static void hn_start(struct ifnet *ifp);
@@ -467,19 +467,15 @@ hn_cpuset_setthread_task(void *xmask, in
 static int
 netvsc_attach(device_t dev)
 {
+	struct hn_softc *sc = device_get_softc(dev);
 	struct sysctl_oid_list *child;
 	struct sysctl_ctx_list *ctx;
 	uint8_t eaddr[ETHER_ADDR_LEN];
 	uint32_t link_status;
-	hn_softc_t *sc;
-	int unit = device_get_unit(dev);
 	struct ifnet *ifp = NULL;
 	int error, ring_cnt, tx_ring_cnt;
 	int tso_maxlen;
 
-	sc = device_get_softc(dev);
-
-	sc->hn_unit = unit;
 	sc->hn_dev = dev;
 	sc->hn_prichan = vmbus_get_channel(dev);
 
@@ -564,7 +560,7 @@ netvsc_attach(device_t dev)
 
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = hn_ioctl;
-	ifp->if_init = hn_ifinit;
+	ifp->if_init = hn_init;
 	ifp->if_mtu = ETHERMTU;
 	if (hn_use_if_start) {
 		int qdepth = hn_get_txswq_depth(&sc->hn_tx_ring[0]);
@@ -1513,29 +1509,13 @@ skip:
 static int
 hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
-	hn_softc_t *sc = ifp->if_softc;
+	struct hn_softc *sc = ifp->if_softc;
 	struct ifreq *ifr = (struct ifreq *)data;
-#ifdef INET
-	struct ifaddr *ifa = (struct ifaddr *)data;
-#endif
 	int mask, error = 0;
 	int retry_cnt = 500;
 	
-	switch(cmd) {
-
-	case SIOCSIFADDR:
-#ifdef INET
-		if (ifa->ifa_addr->sa_family == AF_INET) {
-			ifp->if_flags |= IFF_UP;
-			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
-				hn_ifinit(sc);
-			arp_ifinit(ifp, ifa);
-		} else
-#endif
-		error = ether_ioctl(ifp, cmd, data);
-		break;
+	switch (cmd) {
 	case SIOCSIFMTU:
-		/* Check MTU value change */
 		if (ifp->if_mtu == ifr->ifr_mtu)
 			break;
 
@@ -1603,12 +1583,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 		if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax)
 			hn_set_chim_size(sc, sc->hn_chim_szmax);
 
-		hn_ifinit_locked(sc);
+		hn_init_locked(sc);
 
 		NV_LOCK(sc);
 		sc->temp_unusable = FALSE;
 		NV_UNLOCK(sc);
 		break;
+
 	case SIOCSIFFLAGS:
 		do {
                        NV_LOCK(sc);
@@ -1649,7 +1630,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 				/* do something here for Hyper-V */
 			} else
 #endif
-				hn_ifinit_locked(sc);
+				hn_init_locked(sc);
 		} else {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 				hn_stop(sc);
@@ -1659,8 +1640,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 		sc->temp_unusable = FALSE;
 		NV_UNLOCK(sc);
 		sc->hn_if_flags = ifp->if_flags;
-		error = 0;
 		break;
+
 	case SIOCSIFCAP:
 		NV_LOCK(sc);
 
@@ -1699,38 +1680,32 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 		}
 
 		NV_UNLOCK(sc);
-		error = 0;
 		break;
+
 	case SIOCADDMULTI:
 	case SIOCDELMULTI:
-#ifdef notyet
-		/* Fixme:  Multicast mode? */
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-			NV_LOCK(sc);
-			netvsc_setmulti(sc);
-			NV_UNLOCK(sc);
-			error = 0;
-		}
-#endif
-		error = EINVAL;
+		/* Always all-multi */
+		/*
+		 * TODO:
+		 * Enable/disable all-multi according to the emptiness of
+		 * the mcast address list.
+		 */
 		break;
+
 	case SIOCSIFMEDIA:
 	case SIOCGIFMEDIA:
 		error = ifmedia_ioctl(ifp, ifr, &sc->hn_media, cmd);
 		break;
+
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	}
-
 	return (error);
 }
 
-/*
- *
- */
 static void
-hn_stop(hn_softc_t *sc)
+hn_stop(struct hn_softc *sc)
 {
 	struct ifnet *ifp;
 	int ret, i;
@@ -1809,11 +1784,8 @@ do_sched:
 	}
 }
 
-/*
- *
- */
 static void
-hn_ifinit_locked(hn_softc_t *sc)
+hn_init_locked(struct hn_softc *sc)
 {
 	struct ifnet *ifp;
 	int ret, i;
@@ -1845,9 +1817,9 @@ hn_ifinit_locked(hn_softc_t *sc)
  *
  */
 static void
-hn_ifinit(void *xsc)
+hn_init(void *xsc)
 {
-	hn_softc_t *sc = xsc;
+	struct hn_softc *sc = xsc;
 
 	NV_LOCK(sc);
 	if (sc->temp_unusable) {
@@ -1857,7 +1829,7 @@ hn_ifinit(void *xsc)
 	sc->temp_unusable = TRUE;
 	NV_UNLOCK(sc);
 
-	hn_ifinit_locked(sc);
+	hn_init_locked(sc);
 
 	NV_LOCK(sc);
 	sc->temp_unusable = FALSE;
@@ -1871,11 +1843,9 @@ hn_ifinit(void *xsc)
 static void
 hn_watchdog(struct ifnet *ifp)
 {
-	hn_softc_t *sc;
-	sc = ifp->if_softc;
 
-	printf("hn%d: watchdog timeout -- resetting\n", sc->hn_unit);
-	hn_ifinit(sc);    /*???*/
+	if_printf(ifp, "watchdog timeout -- resetting\n");
+	hn_init(ifp->if_softc);    /* XXX */
 	ifp->if_oerrors++;
 }
 #endif
@@ -3545,7 +3515,7 @@ static device_method_t netvsc_methods[] 
 static driver_t netvsc_driver = {
         NETVSC_DEVNAME,
         netvsc_methods,
-        sizeof(hn_softc_t)
+        sizeof(struct hn_softc)
 };
 
 static devclass_t netvsc_devclass;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610130856.u9D8urVR050361>