diff --git a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c index 5bfa85f5db70..56202eba78c8 100644 --- a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c +++ b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c @@ -1335,28 +1335,29 @@ netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen, 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; diff --git a/sys/dev/hyperv/netvsc/hv_rndis_filter.c b/sys/dev/hyperv/netvsc/hv_rndis_filter.c index ab85e41cc073..22e2a818c3a8 100644 --- a/sys/dev/hyperv/netvsc/hv_rndis_filter.c +++ b/sys/dev/hyperv/netvsc/hv_rndis_filter.c @@ -157,7 +157,7 @@ hv_rf_find_recvinfo(const rndis_packet *rpkt, struct hn_recvinfo *info) 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 *rpkt, struct hn_recvinfo *info) 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; diff --git a/sys/dev/hyperv/netvsc/if_hnvar.h b/sys/dev/hyperv/netvsc/if_hnvar.h index 99313628a9f3..cae9bd1e6524 100644 --- a/sys/dev/hyperv/netvsc/if_hnvar.h +++ b/sys/dev/hyperv/netvsc/if_hnvar.h @@ -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; }; diff --git a/sys/dev/hyperv/netvsc/ndis.h b/sys/dev/hyperv/netvsc/ndis.h index 923f3d9a6c78..9e65b4f5a6a8 100644 --- a/sys/dev/hyperv/netvsc/ndis.h +++ b/sys/dev/hyperv/netvsc/ndis.h @@ -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_ */