Author: dexuan
Date: Thu Feb 23 07:07:21 2017
New Revision: 314124
URL: https://svnweb.freebsd.org/changeset/base/314124

Log:
  MFC r312689, r312690
  
  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/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     Thu Feb 23 07:04:17 2017        
(r314123)
+++ stable/10/sys/dev/hyperv/netvsc/if_hn.c     Thu Feb 23 07:07:21 2017        
(r314124)
@@ -294,6 +294,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 *);
@@ -982,6 +983,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));
@@ -1232,6 +1236,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.
@@ -3205,6 +3212,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;
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to