hns3_outer_header_cksum_prepare(struct rte_mbuf *m)
{
uint64_t ol_flags = m->ol_flags;
- struct rte_ipv4_hdr *ipv4_hdr;
- struct rte_udp_hdr *udp_hdr;
- uint32_t paylen, hdr_len;
+ uint32_t paylen, hdr_len, l4_proto;
if (!(ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6)))
return;
- if (ol_flags & PKT_TX_IPV4) {
+ if (ol_flags & PKT_TX_OUTER_IPV4) {
+ struct rte_ipv4_hdr *ipv4_hdr;
ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
m->outer_l2_len);
-
- if (ol_flags & PKT_TX_IP_CKSUM)
+ l4_proto = ipv4_hdr->next_proto_id;
+ if (ol_flags & PKT_TX_OUTER_IP_CKSUM)
ipv4_hdr->hdr_checksum = 0;
+ } else {
+ struct rte_ipv6_hdr *ipv6_hdr;
+ ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *,
+ m->outer_l2_len);
+ l4_proto = ipv6_hdr->proto;
}
-
- if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM &&
- ol_flags & PKT_TX_TCP_SEG) {
+ /* driver should ensure the outer udp cksum is 0 for TUNNEL TSO */
+ if (l4_proto == IPPROTO_UDP && (ol_flags & PKT_TX_TCP_SEG)) {
+ struct rte_udp_hdr *udp_hdr;
hdr_len = m->l2_len + m->l3_len + m->l4_len;
- hdr_len += (ol_flags & PKT_TX_TUNNEL_MASK) ?
- m->outer_l2_len + m->outer_l3_len : 0;
+ hdr_len += m->outer_l2_len + m->outer_l3_len;
paylen = m->pkt_len - hdr_len;
if (paylen <= m->tso_segsz)
return;