git: 1aadba9cc8af - stable/12 - Hyper-V: hn: Store host hash value in flowid

Wei Hu whu at FreeBSD.org
Mon Mar 29 08:54:30 UTC 2021


The branch stable/12 has been updated by whu:

URL: https://cgit.FreeBSD.org/src/commit/?id=1aadba9cc8af4c1925eb27215eaf6d68e6fbf4d8

commit 1aadba9cc8af4c1925eb27215eaf6d68e6fbf4d8
Author:     Wei Hu <whu at FreeBSD.org>
AuthorDate: 2021-02-24 05:07:46 +0000
Commit:     Wei Hu <whu at FreeBSD.org>
CommitDate: 2021-03-29 08:32:39 +0000

    Hyper-V: hn: Store host hash value in flowid
    
    When rx packet contains hash value sent from host, store it in
    the mbuf's flowid field so when the same mbuf is on the tx path,
    the hash value can be used by the host to determine the outgoing
    network queue.
    
    MFC after:      2 weeks
    Sponsored by:   Microsoft
    
    (cherry picked from commit 80f39bd95f22322152709ea5fae3a3c546044c9c)
---
 sys/dev/hyperv/netvsc/if_hn.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c
index 1945732590cc..b77f3118b777 100644
--- a/sys/dev/hyperv/netvsc/if_hn.c
+++ b/sys/dev/hyperv/netvsc/if_hn.c
@@ -3073,13 +3073,24 @@ hn_encap(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd,
 
 	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.
+		 * Set the hash value for this packet.
 		 */
 		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_HASHTYPE_ISHASH(m_head))
+			/*
+			 * The flowid field contains the hash value host
+			 * set in the rx queue if it is a ip forwarding pkt.
+			 * Set the same hash value so host can send on the
+			 * cpu it was received.
+			 */
+			*pi_data = m_head->m_pkthdr.flowid;
+		else
+			/*
+			 * Otherwise just put the tx queue index.
+			 */
+			*pi_data = txr->hn_tx_idx;
 	}
 
 	if (m_head->m_flags & M_VLANTAG) {


More information about the dev-commits-src-all mailing list