[dpdk-dev] [PATCH v2 16/17] net/ionic: add TX checksum support

Ferruh Yigit ferruh.yigit at intel.com
Mon Dec 2 17:15:07 CET 2019


On 10/15/2019 9:22 AM, Alfredo Cardigliano wrote:
> Add support for TX checksumming.
> 
> Signed-off-by: Alfredo Cardigliano <cardigliano at ntop.org>
> Reviewed-by: Shannon Nelson <snelson at pensando.io>

<...>

> +static void
> +ionic_tx_tcp_pseudo_csum(struct rte_mbuf *txm)
> +{
> +	struct ether_hdr *eth_hdr = rte_pktmbuf_mtod(txm, struct ether_hdr *);
> +	char *l3_hdr = ((char *)eth_hdr) + txm->l2_len;
> +	struct rte_tcp_hdr *tcp_hdr = (struct rte_tcp_hdr *)
> +			(l3_hdr + txm->l3_len);
> +
> +	if (txm->ol_flags & PKT_TX_IP_CKSUM) {
> +		struct rte_ipv4_hdr *ipv4_hdr = (struct rte_ipv4_hdr *)l3_hdr;
> +		ipv4_hdr->hdr_checksum = 0;
> +		tcp_hdr->cksum = 0;
> +		tcp_hdr->cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, tcp_hdr);
> +	} else {
> +		struct rte_ipv6_hdr *ipv6_hdr = (struct rte_ipv6_hdr *)l3_hdr;
> +		tcp_hdr->cksum = 0;
> +		tcp_hdr->cksum = rte_ipv6_udptcp_cksum(ipv6_hdr, tcp_hdr);
> +	}
> +}
> +
> +static void
> +ionic_tx_tcp_inner_pseudo_csum(struct rte_mbuf *txm)
> +{
> +	struct ether_hdr *eth_hdr = rte_pktmbuf_mtod(txm, struct ether_hdr *);
> +	char *l3_hdr = ((char *)eth_hdr) + txm->outer_l2_len +
> +			txm->outer_l3_len + txm->l2_len;
> +	struct rte_tcp_hdr *tcp_hdr = (struct rte_tcp_hdr *)
> +			(l3_hdr + txm->l3_len);
> +
> +	if (txm->ol_flags & PKT_TX_IPV4) {
> +		struct rte_ipv4_hdr *ipv4_hdr = (struct rte_ipv4_hdr *)l3_hdr;
> +		ipv4_hdr->hdr_checksum = 0;
> +		tcp_hdr->cksum = 0;
> +		tcp_hdr->cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, tcp_hdr);
> +	} else {
> +		struct rte_ipv6_hdr *ipv6_hdr = (struct rte_ipv6_hdr *)l3_hdr;
> +		tcp_hdr->cksum = 0;
> +		tcp_hdr->cksum = rte_ipv6_udptcp_cksum(ipv6_hdr, tcp_hdr);
> +	}
> +}

I think the intestion of 'tx_pkt_prepare' dev_ops is for above operations, if
you want to seperate these from regular Tx path, you can call them from
'tx_pkt_prepare', but if you need them always can keep as it is I think.




More information about the dev mailing list