Author: sephe
Date: Wed Sep 28 05:12:09 2016
New Revision: 306393
URL: https://svnweb.freebsd.org/changeset/base/306393

Log:
  hyperv/hn: Flatten RX filter configuration.
  
  This paves way for more fixes.
  
  MFC after:    1 week
  Sponsored by: Microsoft
  Differential Revision:        https://reviews.freebsd.org/D8049

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
  head/sys/dev/hyperv/netvsc/hv_rndis_filter.h
  head/sys/dev/hyperv/netvsc/if_hnvar.h

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h     Wed Sep 28 05:01:53 2016        
(r306392)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h     Wed Sep 28 05:12:09 2016        
(r306393)
@@ -265,7 +265,6 @@ struct hn_softc {
 /*
  * Externs
  */
-extern int hv_promisc_mode;
 struct hn_send_ctx;
 
 void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status);

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 28 05:01:53 
2016        (r306392)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 28 05:12:09 
2016        (r306393)
@@ -205,8 +205,6 @@ struct hn_txdesc {
  * Globals
  */
 
-int hv_promisc_mode = 0;    /* normal mode by default */
-
 SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
     "Hyper-V network interface");
 
@@ -1779,7 +1777,7 @@ static void
 hn_stop(struct hn_softc *sc)
 {
        struct ifnet *ifp;
-       int ret, i;
+       int i;
 
        HN_LOCK_ASSERT(sc);
 
@@ -1795,7 +1793,8 @@ hn_stop(struct hn_softc *sc)
 
        if_link_state_change(ifp, LINK_STATE_DOWN);
 
-       ret = hv_rf_on_close(sc);
+       /* Disable RX by clearing RX filter. */
+       hn_rndis_set_rxfilter(sc, 0);
 }
 
 /*
@@ -1870,9 +1869,8 @@ hn_init_locked(struct hn_softc *sc)
                return;
        }
 
-       hv_promisc_mode = 1;
-
-       ret = hv_rf_on_open(sc);
+       /* TODO: add hn_rx_filter */
+       ret = hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS);
        if (ret != 0)
                return;
 
@@ -3576,9 +3574,9 @@ hn_suspend(struct hn_softc *sc)
        }
 
        /*
-        * Disable RX.
+        * Disable RX by clearing RX filter.
         */
-       hv_rf_on_close(sc);
+       hn_rndis_set_rxfilter(sc, 0);
 
        /*
         * Give RNDIS enough time to flush all pending data packets.
@@ -3612,8 +3610,9 @@ hn_resume(struct hn_softc *sc)
 
        /*
         * Re-enable RX.
+        * TODO: add hn_rx_filter.
         */
-       hv_rf_on_open(sc);
+       hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS);
 
        /*
         * Make sure to clear suspend status on "all" TX rings,

Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c        Wed Sep 28 05:01:53 
2016        (r306392)
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c        Wed Sep 28 05:12:09 
2016        (r306393)
@@ -887,7 +887,7 @@ hn_rndis_conf_rss(struct hn_softc *sc, u
        return (error);
 }
 
-static int
+int
 hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter)
 {
        int error;
@@ -1013,35 +1013,6 @@ hn_rndis_detach(struct hn_softc *sc)
        hn_rndis_halt(sc);
 }
 
-/*
- * RNDIS filter on open
- */
-int
-hv_rf_on_open(struct hn_softc *sc)
-{
-       uint32_t filter;
-
-       /* XXX */
-       if (hv_promisc_mode != 1) {
-               filter = NDIS_PACKET_TYPE_BROADCAST |
-                   NDIS_PACKET_TYPE_ALL_MULTICAST |
-                   NDIS_PACKET_TYPE_DIRECTED;
-       } else {
-               filter = NDIS_PACKET_TYPE_PROMISCUOUS;
-       }
-       return (hn_rndis_set_rxfilter(sc, filter));
-}
-
-/*
- * RNDIS filter on close
- */
-int 
-hv_rf_on_close(struct hn_softc *sc)
-{
-
-       return (hn_rndis_set_rxfilter(sc, 0));
-}
-
 void
 hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr)
 {

Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.h        Wed Sep 28 05:01:53 
2016        (r306392)
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.h        Wed Sep 28 05:12:09 
2016        (r306393)
@@ -43,8 +43,6 @@ struct hn_rx_ring;
 void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr,
     const void *data, int dlen);
 void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr);
-int hv_rf_on_open(struct hn_softc *sc);
-int hv_rf_on_close(struct hn_softc *sc);
 
 #endif  /* __HV_RNDIS_FILTER_H__ */
 

Modified: head/sys/dev/hyperv/netvsc/if_hnvar.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/if_hnvar.h       Wed Sep 28 05:01:53 2016        
(r306392)
+++ head/sys/dev/hyperv/netvsc/if_hnvar.h       Wed Sep 28 05:12:09 2016        
(r306393)
@@ -126,6 +126,8 @@ int         hn_rndis_get_rsscaps(struct hn_soft
 int            hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr);
 int            hn_rndis_get_linkstatus(struct hn_softc *sc,
                    uint32_t *link_status);
+/* filter: NDIS_PACKET_TYPE_ or 0. */
+int            hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter);
 
 int            hn_nvs_attach(struct hn_softc *sc, int mtu);
 void           hn_nvs_detach(struct hn_softc *sc);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to