hyperv/hn: Rework RXCSUM related bits
MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7735
This commit is contained in:
parent
3c02834389
commit
a191051577
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user