[dpdk-dev] [PATCH v2 10/12] virtio: add Tx checksum offload support

Yuanhan Liu yuanhan.liu at linux.intel.com
Thu Oct 13 10:38:21 CEST 2016


On Mon, Oct 03, 2016 at 11:00:21AM +0200, Olivier Matz wrote:
> +	/* Checksum Offload */
> +	switch (cookie->ol_flags & PKT_TX_L4_MASK) {
> +	case PKT_TX_UDP_CKSUM:
> +		hdr->csum_start = cookie->l2_len + cookie->l3_len;
> +		hdr->csum_offset = 6;
> +		hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
> +		break;
> +
> +	case PKT_TX_TCP_CKSUM:
> +		hdr->csum_start = cookie->l2_len + cookie->l3_len;
> +		hdr->csum_offset = 16;

I would suggest to use "offsetof(...)" here, instead of some magic
number like 16.

	--yliu


More information about the dev mailing list