LCOV - code coverage report
Current view: top level - lib/gso - gso_udp4.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 22 0.0 %
Date: 2025-01-02 22:41:34 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 16 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "gso_common.h"
       6                 :            : #include "gso_udp4.h"
       7                 :            : 
       8                 :            : #define IPV4_HDR_MF_BIT (1U << 13)
       9                 :            : 
      10                 :            : static inline void
      11                 :          0 : update_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
      12                 :            :                 uint16_t nb_segs)
      13                 :            : {
      14                 :            :         struct rte_ipv4_hdr *ipv4_hdr;
      15                 :            :         uint16_t frag_offset = 0, is_mf;
      16                 :          0 :         uint16_t l2_hdrlen = pkt->l2_len, l3_hdrlen = pkt->l3_len;
      17                 :          0 :         uint16_t tail_idx = nb_segs - 1, length, i;
      18                 :            : 
      19                 :            :         /*
      20                 :            :          * Update IP header fields for output segments. Specifically,
      21                 :            :          * keep the same IP id, update fragment offset and total
      22                 :            :          * length.
      23                 :            :          */
      24         [ #  # ]:          0 :         for (i = 0; i < nb_segs; i++) {
      25                 :          0 :                 ipv4_hdr = rte_pktmbuf_mtod_offset(segs[i],
      26                 :            :                         struct rte_ipv4_hdr *, l2_hdrlen);
      27                 :          0 :                 length = segs[i]->pkt_len - l2_hdrlen;
      28         [ #  # ]:          0 :                 ipv4_hdr->total_length = rte_cpu_to_be_16(length);
      29                 :            : 
      30         [ #  # ]:          0 :                 is_mf = i < tail_idx ? IPV4_HDR_MF_BIT : 0;
      31                 :          0 :                 ipv4_hdr->fragment_offset =
      32         [ #  # ]:          0 :                         rte_cpu_to_be_16(frag_offset | is_mf);
      33                 :          0 :                 frag_offset += ((length - l3_hdrlen) >> 3);
      34                 :            :         }
      35                 :          0 : }
      36                 :            : 
      37                 :            : int
      38                 :          0 : gso_udp4_segment(struct rte_mbuf *pkt,
      39                 :            :                 uint16_t gso_size,
      40                 :            :                 struct rte_mempool *direct_pool,
      41                 :            :                 struct rte_mempool *indirect_pool,
      42                 :            :                 struct rte_mbuf **pkts_out,
      43                 :            :                 uint16_t nb_pkts_out)
      44                 :            : {
      45                 :            :         struct rte_ipv4_hdr *ipv4_hdr;
      46                 :            :         uint16_t pyld_unit_size, hdr_offset;
      47                 :            :         uint16_t frag_off;
      48                 :            :         int ret;
      49                 :            : 
      50                 :            :         /* Don't process the fragmented packet */
      51                 :          0 :         ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
      52                 :            :                         pkt->l2_len);
      53         [ #  # ]:          0 :         frag_off = rte_be_to_cpu_16(ipv4_hdr->fragment_offset);
      54         [ #  # ]:          0 :         if (unlikely(IS_FRAGMENTED(frag_off))) {
      55                 :            :                 return 0;
      56                 :            :         }
      57                 :            : 
      58                 :            :         /*
      59                 :            :          * UDP fragmentation is the same as IP fragmentation.
      60                 :            :          * Except the first one, other output packets just have l2
      61                 :            :          * and l3 headers.
      62                 :            :          */
      63                 :          0 :         hdr_offset = pkt->l2_len + pkt->l3_len;
      64                 :            : 
      65                 :            :         /* Don't process the packet without data. */
      66         [ #  # ]:          0 :         if (unlikely(hdr_offset + pkt->l4_len >= pkt->pkt_len)) {
      67                 :            :                 return 0;
      68                 :            :         }
      69                 :            : 
      70                 :            :         /* pyld_unit_size must be a multiple of 8 because frag_off
      71                 :            :          * uses 8 bytes as unit.
      72                 :            :          */
      73                 :          0 :         pyld_unit_size = (gso_size - hdr_offset) & ~7U;
      74                 :            : 
      75                 :            :         /* Segment the payload */
      76                 :          0 :         ret = gso_do_segment(pkt, hdr_offset, pyld_unit_size, direct_pool,
      77                 :            :                         indirect_pool, pkts_out, nb_pkts_out);
      78         [ #  # ]:          0 :         if (ret > 1)
      79                 :          0 :                 update_ipv4_udp_headers(pkt, pkts_out, ret);
      80                 :            : 
      81                 :            :         return ret;
      82                 :            : }

Generated by: LCOV version 1.14