Hi Thomas, > -----Original Message----- > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com] > Sent: Wednesday, November 4, 2015 7:18 PM > To: Liu, Jijiang > Cc: dev at dpdk.org; Michael S. Tsirkin > Subject: Re: [dpdk-dev] [PATCH v3 6/8] driver/virtio:enqueue vhost TX > offload > > 2015-11-04 18:54, Jijiang Liu: > > + /* if vhost TX checksum offload is required */ > > + if (m->ol_flags & PKT_TX_IP_CKSUM) { > > + hdr->csum_start = m->l2_len; > > + hdr->csum_offset = offsetof(struct ipv4_hdr, hdr_checksum); > > + } else if (m->ol_flags & PKT_TX_L4_MASK) { > > + hdr->csum_start = m->l2_len + m->l3_len; > > + switch (m->ol_flags & PKT_TX_L4_MASK) { > > + case PKT_TX_TCP_CKSUM: > > + hdr->csum_offset = offsetof(struct tcp_hdr, cksum); > > + break; > > + case PKT_TX_UDP_CKSUM: > > + hdr->csum_offset = offsetof(struct udp_hdr, > > + dgram_cksum); > > + break; > > + case PKT_TX_SCTP_CKSUM: > > + hdr->csum_offset = offsetof(struct sctp_hdr, cksum); > > + break; > > + default: > > + break; > > + } > > The header checksum to offload is deduced from csum_offset. > Your vhost implementation do some parsing to deduce it: > The ol_flag is set in application, we have to fill 'csum_start' and 'csum_offset' based on these offload flags. As long as the 'csum_start' and 'csum_offset' fileds are set correctly, and it can work well with a vanilla linux with vhost.
But in DPDK vhost lib, we need to parse the 'csum_start' and 'csum_offset' filed to get the which offload flags should be set, and the l2_len, l3_len and l3_len also should be filled. So I think it is necessary to do this in both side. We can continue discuss this if you have further comments. Thanks --Jijiang Liu