hyperv/hn: Enable UDP RXCSUM

Reviewed by:	adrian
Approved by:	adrian (mentor)
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5102
This commit is contained in:
sephe 2016-02-05 05:06:14 +00:00
parent f8cf3cfcd0
commit 25d1f76bed
2 changed files with 11 additions and 4 deletions

View File

@ -1036,6 +1036,7 @@ typedef struct hn_softc {
u_long hn_csum_ip; u_long hn_csum_ip;
u_long hn_csum_tcp; u_long hn_csum_tcp;
u_long hn_csum_udp;
u_long hn_csum_trusted; u_long hn_csum_trusted;
u_long hn_lro_tried; u_long hn_lro_tried;
u_long hn_small_pkts; u_long hn_small_pkts;

View File

@ -456,6 +456,8 @@ netvsc_attach(device_t dev)
CTLFLAG_RW, &sc->hn_csum_ip, "RXCSUM IP"); CTLFLAG_RW, &sc->hn_csum_ip, "RXCSUM IP");
SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_tcp", SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_tcp",
CTLFLAG_RW, &sc->hn_csum_tcp, "RXCSUM TCP"); CTLFLAG_RW, &sc->hn_csum_tcp, "RXCSUM TCP");
SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_udp",
CTLFLAG_RW, &sc->hn_csum_udp, "RXCSUM UDP");
SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_trusted", SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_trusted",
CTLFLAG_RW, &sc->hn_csum_trusted, CTLFLAG_RW, &sc->hn_csum_trusted,
"# of TCP segements that we trust host's csum verification"); "# of TCP segements that we trust host's csum verification");
@ -1156,7 +1158,7 @@ netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet,
m_new->m_pkthdr.rcvif = ifp; m_new->m_pkthdr.rcvif = ifp;
/* receive side checksum offload */ /* receive side checksum offload */
if (NULL != csum_info) { if (csum_info != NULL) {
/* IP csum offload */ /* IP csum offload */
if (csum_info->receive.ip_csum_succeeded) { if (csum_info->receive.ip_csum_succeeded) {
m_new->m_pkthdr.csum_flags |= m_new->m_pkthdr.csum_flags |=
@ -1164,12 +1166,16 @@ netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet,
sc->hn_csum_ip++; sc->hn_csum_ip++;
} }
/* TCP csum offload */ /* TCP/UDP csum offload */
if (csum_info->receive.tcp_csum_succeeded) { if (csum_info->receive.tcp_csum_succeeded ||
csum_info->receive.udp_csum_succeeded) {
m_new->m_pkthdr.csum_flags |= m_new->m_pkthdr.csum_flags |=
(CSUM_DATA_VALID | CSUM_PSEUDO_HDR); (CSUM_DATA_VALID | CSUM_PSEUDO_HDR);
m_new->m_pkthdr.csum_data = 0xffff; m_new->m_pkthdr.csum_data = 0xffff;
sc->hn_csum_tcp++; if (csum_info->receive.tcp_csum_succeeded)
sc->hn_csum_tcp++;
else
sc->hn_csum_udp++;
} }
if (csum_info->receive.ip_csum_succeeded && if (csum_info->receive.ip_csum_succeeded &&