Skip to content

Commit 9a8d949

Browse files
AndrewAtDaynixjasowang
authored andcommitted
hw/net: Added CSO for IPv6
Added fix for checksum offload for IPv6 if a backend doesn't have a virtual header. This patch is a part of IPv6 fragmentation. Signed-off-by: Andrew Melnychenko <[email protected]> Signed-off-by: Jason Wang <[email protected]>
1 parent 6501810 commit 9a8d949

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

hw/net/net_tx_pkt.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,18 +468,27 @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt)
468468
/* num of iovec without vhdr */
469469
uint32_t iov_len = pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1;
470470
uint16_t csl;
471-
struct ip_header *iphdr;
472471
size_t csum_offset = pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_offset;
472+
uint16_t l3_proto = eth_get_l3_proto(iov, 1, iov->iov_len);
473473

474474
/* Put zero to checksum field */
475475
iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);
476476

477477
/* Calculate L4 TCP/UDP checksum */
478478
csl = pkt->payload_len;
479479

480+
csum_cntr = 0;
481+
cso = 0;
480482
/* add pseudo header to csum */
481-
iphdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
482-
csum_cntr = eth_calc_ip4_pseudo_hdr_csum(iphdr, csl, &cso);
483+
if (l3_proto == ETH_P_IP) {
484+
csum_cntr = eth_calc_ip4_pseudo_hdr_csum(
485+
pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base,
486+
csl, &cso);
487+
} else if (l3_proto == ETH_P_IPV6) {
488+
csum_cntr = eth_calc_ip6_pseudo_hdr_csum(
489+
pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base,
490+
csl, pkt->l4proto, &cso);
491+
}
483492

484493
/* data checksum */
485494
csum_cntr +=

0 commit comments

Comments
 (0)