Author: sephe
Date: Thu Sep 29 05:13:58 2016
New Revision: 306433
URL: https://svnweb.freebsd.org/changeset/base/306433

Log:
  hyperv/hn: Don't set HASHVAL pktinfo for NDIS < 6.30
  
  This unbreaks packet sending on WS2008R2.
  
  MFC after:    1 week
  Sponsored by: Microsoft
  Differential Revision:        https://reviews.freebsd.org/D8057

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

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h     Thu Sep 29 05:01:20 2016        
(r306432)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h     Thu Sep 29 05:13:58 2016        
(r306433)
@@ -168,6 +168,7 @@ struct hn_tx_ring {
        struct buf_ring *hn_mbuf_br;
        int             hn_oactive;
        int             hn_tx_idx;
+       int             hn_tx_flags;
 
        struct mtx      hn_tx_lock;
        struct hn_softc *hn_sc;
@@ -194,10 +195,10 @@ struct hn_tx_ring {
        struct hn_txdesc *hn_txdesc;
        bus_dma_tag_t   hn_tx_rndis_dtag;
        struct sysctl_oid *hn_tx_sysctl_tree;
-       int             hn_tx_flags;
 } __aligned(CACHE_LINE_SIZE);
 
 #define HN_TX_FLAG_ATTACHED    0x1
+#define HN_TX_FLAG_HASHVAL     0x2     /* support HASHVAL pktinfo */
 
 /*
  * Device-specific softc structure

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Thu Sep 29 05:01:20 
2016        (r306432)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Thu Sep 29 05:13:58 
2016        (r306433)
@@ -1006,14 +1006,16 @@ hn_encap(struct hn_tx_ring *txr, struct 
        pkt->rm_pktinfooffset = sizeof(*pkt);
        pkt->rm_pktinfolen = 0;
 
-       /*
-        * Set the hash value for this packet, so that the host could
-        * dispatch the TX done event for this packet back to this TX
-        * ring's channel.
-        */
-       pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN,
-           HN_NDIS_HASH_VALUE_SIZE, HN_NDIS_PKTINFO_TYPE_HASHVAL);
-       *pi_data = txr->hn_tx_idx;
+       if (txr->hn_tx_flags & HN_TX_FLAG_HASHVAL) {
+               /*
+                * Set the hash value for this packet, so that the host could
+                * dispatch the TX done event for this packet back to this TX
+                * ring's channel.
+                */
+               pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN,
+                   HN_NDIS_HASH_VALUE_SIZE, HN_NDIS_PKTINFO_TYPE_HASHVAL);
+               *pi_data = txr->hn_tx_idx;
+       }
 
        if (m_head->m_flags & M_VLANTAG) {
                pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN,
@@ -2920,6 +2922,12 @@ hn_fixup_tx_data(struct hn_softc *sc)
 
        for (i = 0; i < sc->hn_tx_ring_cnt; ++i)
                sc->hn_tx_ring[i].hn_csum_assist = csum_assist;
+
+       if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) {
+               /* Support HASHVAL pktinfo on TX path. */
+               for (i = 0; i < sc->hn_tx_ring_cnt; ++i)
+                       sc->hn_tx_ring[i].hn_tx_flags |= HN_TX_FLAG_HASHVAL;
+       }
 }
 
 static void
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to