Calculate the checksum of outer header */
| 574 | |
| 575 | /* Calculate the checksum of outer header */ |
| 576 | static uint64_t |
| 577 | process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, |
| 578 | uint64_t tx_offloads, int tso_enabled, struct rte_mbuf *m) |
| 579 | { |
| 580 | struct rte_udp_hdr *udp_hdr; |
| 581 | uint64_t ol_flags = 0; |
| 582 | |
| 583 | if (info->outer_ethertype == _htons(RTE_ETHER_TYPE_IPV4)) { |
| 584 | ol_flags |= RTE_MBUF_F_TX_OUTER_IPV4; |
| 585 | |
| 586 | if (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) { |
| 587 | ol_flags |= RTE_MBUF_F_TX_OUTER_IP_CKSUM; |
| 588 | } else { |
| 589 | struct rte_ipv4_hdr *ipv4_hdr = outer_l3_hdr; |
| 590 | |
| 591 | ipv4_hdr->hdr_checksum = 0; |
| 592 | ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); |
| 593 | } |
| 594 | } else { |
| 595 | ol_flags |= RTE_MBUF_F_TX_OUTER_IPV6; |
| 596 | } |
| 597 | |
| 598 | if (info->outer_l4_proto != IPPROTO_UDP) |
| 599 | return ol_flags; |
| 600 | |
| 601 | udp_hdr = (struct rte_udp_hdr *) |
| 602 | ((char *)outer_l3_hdr + info->outer_l3_len); |
| 603 | |
| 604 | if (tso_enabled && info->l4_proto == IPPROTO_TCP) |
| 605 | ol_flags |= RTE_MBUF_F_TX_TCP_SEG; |
| 606 | else if (tso_enabled && info->l4_proto == IPPROTO_UDP) |
| 607 | ol_flags |= RTE_MBUF_F_TX_UDP_SEG; |
| 608 | |
| 609 | /* Skip SW outer UDP checksum generation if HW supports it */ |
| 610 | if (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) { |
| 611 | ol_flags |= RTE_MBUF_F_TX_OUTER_UDP_CKSUM; |
| 612 | return ol_flags; |
| 613 | } |
| 614 | |
| 615 | /* outer UDP checksum is done in software. In the other side, for |
| 616 | * UDP tunneling, like VXLAN or Geneve, outer UDP checksum can be |
| 617 | * set to zero. |
| 618 | * |
| 619 | * If a packet will be TSOed into small packets by NIC, we cannot |
| 620 | * set/calculate a non-zero checksum, because it will be a wrong |
| 621 | * value after the packet be split into several small packets. |
| 622 | */ |
| 623 | if (tso_enabled) |
| 624 | udp_hdr->dgram_cksum = 0; |
| 625 | |
| 626 | /* do not recalculate udp cksum if it was 0 */ |
| 627 | if (udp_hdr->dgram_cksum != 0) { |
| 628 | udp_hdr->dgram_cksum = 0; |
| 629 | udp_hdr->dgram_cksum = get_udptcp_checksum(m, outer_l3_hdr, |
| 630 | info->outer_l2_len + info->outer_l3_len, |
| 631 | info->outer_ethertype); |
| 632 | } |
| 633 |
no test coverage detected