svn commit: r314092 - stable/11/sys/dev/hyperv/netvsc

Dexuan Cui dexuan at FreeBSD.org
Wed Feb 22 08:37:53 UTC 2017


Author: dexuan
Date: Wed Feb 22 08:37:51 2017
New Revision: 314092
URL: https://svnweb.freebsd.org/changeset/base/314092

Log:
  MFC 312689, 312690
  
  Approved by:	sephe (mentor)
  
  r312689
      hyperv/hn: add a sysctl name for the VF interface
  
      This makes it easier for the userland script to find the releated
      VF interface.
  
      Reviewed by:	sephe
      Approved by:	sephe (mentor)
      Sponsored by:	Microsoft
      Differential Revision:	https://reviews.freebsd.org/D9101
  
  r312690
      hyperv/hn: add devctl_notify for VF_UP/DOWN events
  
      Reviewed by:	sephe
      Approved by:	sephe (mentor)
      Sponsored by:	Microsoft
      Differential Revision:	https://reviews.freebsd.org/D9102

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

Modified: stable/11/sys/dev/hyperv/netvsc/if_hn.c
==============================================================================
--- stable/11/sys/dev/hyperv/netvsc/if_hn.c	Wed Feb 22 08:26:51 2017	(r314091)
+++ stable/11/sys/dev/hyperv/netvsc/if_hn.c	Wed Feb 22 08:37:51 2017	(r314092)
@@ -301,6 +301,7 @@ static int			hn_txagg_pkts_sysctl(SYSCTL
 static int			hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS);
 static int			hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS);
 static int			hn_polling_sysctl(SYSCTL_HANDLER_ARGS);
+static int			hn_vf_sysctl(SYSCTL_HANDLER_ARGS);
 
 static void			hn_stop(struct hn_softc *, bool);
 static void			hn_init_locked(struct hn_softc *);
@@ -995,6 +996,9 @@ hn_set_vf(struct hn_softc *sc, struct if
 		hn_resume_mgmt(sc);
 	}
 
+	devctl_notify("HYPERV_NIC_VF", if_name(hn_ifp),
+	    vf ? "VF_UP" : "VF_DOWN", NULL);
+
 	if (bootverbose)
 		if_printf(hn_ifp, "Data path is switched %s %s\n",
 		    vf ? "to" : "from", if_name(ifp));
@@ -1254,6 +1258,9 @@ hn_attach(device_t dev)
 	    CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0,
 	    hn_polling_sysctl, "I",
 	    "Polling frequency: [100,1000000], 0 disable polling");
+	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "vf",
+	    CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0,
+	    hn_vf_sysctl, "A", "Virtual Function's name");
 
 	/*
 	 * Setup the ifmedia, which has been initialized earlier.
@@ -3222,6 +3229,22 @@ hn_rss_hash_sysctl(SYSCTL_HANDLER_ARGS)
 }
 
 static int
+hn_vf_sysctl(SYSCTL_HANDLER_ARGS)
+{
+	struct hn_softc *sc = arg1;
+	char vf_name[128];
+	struct ifnet *vf;
+
+	HN_LOCK(sc);
+	vf_name[0] = '\0';
+	vf = sc->hn_rx_ring[0].hn_vf;
+	if (vf != NULL)
+		snprintf(vf_name, sizeof(vf_name), "%s", if_name(vf));
+	HN_UNLOCK(sc);
+	return sysctl_handle_string(oidp, vf_name, sizeof(vf_name), req);
+}
+
+static int
 hn_check_iplen(const struct mbuf *m, int hoff)
 {
 	const struct ip *ip;


More information about the svn-src-all mailing list