Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Sep 2016 03:10:30 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r305268 - head/sys/dev/hyperv/netvsc
Message-ID:  <201609020310.u823AU6t095294@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Fri Sep  2 03:10:30 2016
New Revision: 305268
URL: https://svnweb.freebsd.org/changeset/base/305268

Log:
  hyperv/hn: Rework RXCSUM related bits
  
  MFC after:	1 week
  Sponsored by:	Microsoft
  Differential Revision:	https://reviews.freebsd.org/D7735

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

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Fri Sep  2 01:41:57 2016	(r305267)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Fri Sep  2 03:10:30 2016	(r305268)
@@ -1335,28 +1335,29 @@ netvsc_recv(struct hn_rx_ring *rxr, cons
 		do_csum = 0;
 
 	/* receive side checksum offload */
-	if (info->csum_info != NULL) {
+	if (info->csum_info != HN_NDIS_RXCSUM_INFO_INVALID) {
 		/* IP csum offload */
-		if (info->csum_info->receive.ip_csum_succeeded && do_csum) {
+		if ((info->csum_info & NDIS_RXCSUM_INFO_IPCS_OK) && do_csum) {
 			m_new->m_pkthdr.csum_flags |=
 			    (CSUM_IP_CHECKED | CSUM_IP_VALID);
 			rxr->hn_csum_ip++;
 		}
 
 		/* TCP/UDP csum offload */
-		if ((info->csum_info->receive.tcp_csum_succeeded ||
-		     info->csum_info->receive.udp_csum_succeeded) && do_csum) {
+		if ((info->csum_info & (NDIS_RXCSUM_INFO_UDPCS_OK |
+		     NDIS_RXCSUM_INFO_TCPCS_OK)) && do_csum) {
 			m_new->m_pkthdr.csum_flags |=
 			    (CSUM_DATA_VALID | CSUM_PSEUDO_HDR);
 			m_new->m_pkthdr.csum_data = 0xffff;
-			if (info->csum_info->receive.tcp_csum_succeeded)
+			if (info->csum_info & NDIS_RXCSUM_INFO_TCPCS_OK)
 				rxr->hn_csum_tcp++;
 			else
 				rxr->hn_csum_udp++;
 		}
 
-		if (info->csum_info->receive.ip_csum_succeeded &&
-		    info->csum_info->receive.tcp_csum_succeeded)
+		if ((info->csum_info &
+		     (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK)) ==
+		    (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK))
 			do_lro = 1;
 	} else {
 		const struct ether_header *eh;

Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c	Fri Sep  2 01:41:57 2016	(r305267)
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c	Fri Sep  2 03:10:30 2016	(r305268)
@@ -157,7 +157,7 @@ hv_rf_find_recvinfo(const rndis_packet *
 	uint32_t mask = 0, len;
 
 	info->vlan_info = HN_NDIS_VLAN_INFO_INVALID;
-	info->csum_info = NULL;
+	info->csum_info = HN_NDIS_RXCSUM_INFO_INVALID;
 	info->hash_info = NULL;
 	info->hash_value = NULL;
 
@@ -200,10 +200,9 @@ hv_rf_find_recvinfo(const rndis_packet *
 			break;
 
 		case tcpip_chksum_info:
-			if (__predict_false(dlen <
-			    sizeof(rndis_tcp_ip_csum_info)))
+			if (__predict_false(dlen < NDIS_RXCSUM_INFO_SIZE))
 				return (EINVAL);
-			info->csum_info = data;
+			info->csum_info = *((const uint32_t *)data);
 			mask |= HV_RF_RECVINFO_CSUM;
 			break;
 

Modified: head/sys/dev/hyperv/netvsc/if_hnvar.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/if_hnvar.h	Fri Sep  2 01:41:57 2016	(r305267)
+++ head/sys/dev/hyperv/netvsc/if_hnvar.h	Fri Sep  2 03:10:30 2016	(r305268)
@@ -56,10 +56,11 @@ struct ndis_8021q_info_;
 struct rndis_tcp_ip_csum_info_;
 
 #define HN_NDIS_VLAN_INFO_INVALID	0xffffffff
+#define HN_NDIS_RXCSUM_INFO_INVALID	0
 
 struct hn_recvinfo {
 	uint32_t			vlan_info;
-	const struct rndis_tcp_ip_csum_info_ *csum_info;
+	uint32_t			csum_info;
 	const struct rndis_hash_info	*hash_info;
 	const struct rndis_hash_value	*hash_value;
 };

Modified: head/sys/dev/hyperv/netvsc/ndis.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/ndis.h	Fri Sep  2 01:41:57 2016	(r305267)
+++ head/sys/dev/hyperv/netvsc/ndis.h	Fri Sep  2 03:10:30 2016	(r305268)
@@ -219,4 +219,16 @@ struct ndis_rssprm_toeplitz {
 #define	NDIS_VLAN_INFO_CFI(inf)		(((inf) & NDIS_VLAN_INFO_CFI_MASK) >> 3)
 #define	NDIS_VLAN_INFO_PRI(inf)		((inf) & NDIS_VLAN_INFO_PRI_MASK)
 
+/* Reception checksum */
+#define	NDIS_RXCSUM_INFO_SIZE		sizeof(uint32_t)
+#define	NDIS_RXCSUM_INFO_TCPCS_FAILED	0x0001
+#define	NDIS_RXCSUM_INFO_UDPCS_FAILED	0x0002
+#define	NDIS_RXCSUM_INFO_IPCS_FAILED	0x0004
+#define	NDIS_RXCSUM_INFO_TCPCS_OK	0x0008
+#define	NDIS_RXCSUM_INFO_UDPCS_OK	0x0010
+#define	NDIS_RXCSUM_INFO_IPCS_OK	0x0020
+#define	NDIS_RXCSUM_INFO_LOOPBACK	0x0040
+#define	NDIS_RXCSUM_INFO_TCPCS_INVAL	0x0080
+#define	NDIS_RXCSUM_INFO_IPCS_INVAL	0x0100
+
 #endif	/* !_NET_NDIS_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609020310.u823AU6t095294>