From c890792330e2bbc9b15dbbe1ea94e88342cc4a36 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Tue, 29 Mar 2016 13:31:09 +0000 Subject: [PATCH] Improve HW checksums support in VNIC - Do not mark CSUM_IP_CHECKED and CSUM_IP_VALID on IPv6 packets. IPv6 does not have checksums by definition. - Set SCTP packets csum_flags CSUM_SCTP_VALID instead of CSUM_DATA_VALID and skip csum_data - Set csum_data simply as 0xffff without byteswap Pointed out by: yongari Reviewed by: yongari, wma Obtained from: Semihalf Sponsored by: Cavium Differential Revision: https://reviews.freebsd.org/D5537 --- sys/dev/vnic/nicvf_queues.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sys/dev/vnic/nicvf_queues.c b/sys/dev/vnic/nicvf_queues.c index 337921de490..0090796dbcf 100644 --- a/sys/dev/vnic/nicvf_queues.c +++ b/sys/dev/vnic/nicvf_queues.c @@ -1771,7 +1771,6 @@ nicvf_sq_add_hdr_subdesc(struct snd_queue *sq, int qentry, } ip = (struct ip *)(mbuf->m_data + ehdrlen); - ip->ip_sum = 0; iphlen = ip->ip_hl << 2; poff = ehdrlen + iphlen; @@ -1984,19 +1983,23 @@ nicvf_get_rcv_mbuf(struct nicvf *nic, struct cqe_rx_t *cqe_rx) /* * HW by default verifies IP & TCP/UDP/SCTP checksums */ - - /* XXX: Do we need to include IP with options too? */ - if (__predict_true(cqe_rx->l3_type == L3TYPE_IPV4 || - cqe_rx->l3_type == L3TYPE_IPV6)) { + if (__predict_true(cqe_rx->l3_type == L3TYPE_IPV4)) { mbuf->m_pkthdr.csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID); } - if (cqe_rx->l4_type == L4TYPE_TCP || - cqe_rx->l4_type == L4TYPE_UDP || - cqe_rx->l4_type == L4TYPE_SCTP) { + + switch (cqe_rx->l4_type) { + case L4TYPE_UDP: + case L4TYPE_TCP: /* fall through */ mbuf->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); - mbuf->m_pkthdr.csum_data = htons(0xffff); + mbuf->m_pkthdr.csum_data = 0xffff; + break; + case L4TYPE_SCTP: + mbuf->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; + break; + default: + break; } } }