MCPcopy Create free account
hub / github.com/F-Stack/f-stack / process_inner_cksums

Function process_inner_cksums

dpdk/app/test-pmd/csumonly.c:458–573  ·  view source on GitHub ↗

if possible, calculate the checksum of a packet in hw or sw, * depending on the testpmd command line configuration */

Source from the content-addressed store, hash-verified

456/* if possible, calculate the checksum of a packet in hw or sw,
457 * depending on the testpmd command line configuration */
458static uint64_t
459process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info,
460 uint64_t tx_offloads, struct rte_mbuf *m)
461{
462 struct rte_ipv4_hdr *ipv4_hdr = l3_hdr;
463 struct rte_udp_hdr *udp_hdr;
464 struct rte_tcp_hdr *tcp_hdr;
465 struct rte_sctp_hdr *sctp_hdr;
466 uint64_t ol_flags = 0;
467 uint32_t max_pkt_len, tso_segsz = 0;
468 uint16_t l4_off;
469 uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
470 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
471 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
472 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
473 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
474 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
475
476 /* ensure packet is large enough to require tso */
477 if (!info->is_tunnel) {
478 max_pkt_len = info->l2_len + info->l3_len + info->l4_len +
479 info->tso_segsz;
480 if (info->tso_segsz != 0 && info->pkt_len > max_pkt_len)
481 tso_segsz = info->tso_segsz;
482 } else {
483 max_pkt_len = info->outer_l2_len + info->outer_l3_len +
484 info->l2_len + info->l3_len + info->l4_len +
485 info->tunnel_tso_segsz;
486 if (info->tunnel_tso_segsz != 0 && info->pkt_len > max_pkt_len)
487 tso_segsz = info->tunnel_tso_segsz;
488 }
489
490 if (info->ethertype == _htons(RTE_ETHER_TYPE_IPV4)) {
491 ipv4_hdr = l3_hdr;
492
493 ol_flags |= RTE_MBUF_F_TX_IPV4;
494 if (info->l4_proto == IPPROTO_TCP && tso_segsz) {
495 ol_flags |= RTE_MBUF_F_TX_IP_CKSUM;
496 } else {
497 if (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) {
498 ol_flags |= RTE_MBUF_F_TX_IP_CKSUM;
499 } else {
500 ipv4_hdr->hdr_checksum = 0;
501 ipv4_hdr->hdr_checksum =
502 rte_ipv4_cksum(ipv4_hdr);
503 }
504 }
505 } else if (info->ethertype == _htons(RTE_ETHER_TYPE_IPV6))
506 ol_flags |= RTE_MBUF_F_TX_IPV6;
507 else
508 return 0; /* packet type not supported, nothing to do */
509
510 if (info->l4_proto == IPPROTO_UDP) {
511 udp_hdr = (struct rte_udp_hdr *)((char *)l3_hdr + info->l3_len);
512 /* do not recalculate udp cksum if it was 0 */
513 if (udp_hdr->dgram_cksum != 0) {
514 if (tso_segsz && (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_TSO))
515 ol_flags |= RTE_MBUF_F_TX_UDP_SEG;

Callers 1

Calls 2

rte_ipv4_cksumFunction · 0.85
get_udptcp_checksumFunction · 0.85

Tested by

no test coverage detected