LCOV - code coverage report
Current view: top level - lib/gso - rte_gso.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 29 0.0 %
Date: 2025-05-01 17:49:45 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 36 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2017 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <errno.h>
       6                 :            : 
       7                 :            : #include <eal_export.h>
       8                 :            : #include <rte_log.h>
       9                 :            : #include <rte_ethdev.h>
      10                 :            : 
      11                 :            : #include "rte_gso.h"
      12                 :            : #include "gso_common.h"
      13                 :            : #include "gso_tcp4.h"
      14                 :            : #include "gso_tunnel_tcp4.h"
      15                 :            : #include "gso_tunnel_udp4.h"
      16                 :            : #include "gso_udp4.h"
      17                 :            : 
      18                 :            : #define ILLEGAL_UDP_GSO_CTX(ctx) \
      19                 :            :         ((((ctx)->gso_types & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0) || \
      20                 :            :          (ctx)->gso_size < RTE_GSO_UDP_SEG_SIZE_MIN)
      21                 :            : 
      22                 :            : #define ILLEGAL_TCP_GSO_CTX(ctx) \
      23                 :            :         ((((ctx)->gso_types & (RTE_ETH_TX_OFFLOAD_TCP_TSO | \
      24                 :            :                 RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | \
      25                 :            :                 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO)) == 0) || \
      26                 :            :                 (ctx)->gso_size < RTE_GSO_SEG_SIZE_MIN)
      27                 :            : 
      28                 :            : RTE_EXPORT_SYMBOL(rte_gso_segment)
      29                 :            : int
      30                 :          0 : rte_gso_segment(struct rte_mbuf *pkt,
      31                 :            :                 const struct rte_gso_ctx *gso_ctx,
      32                 :            :                 struct rte_mbuf **pkts_out,
      33                 :            :                 uint16_t nb_pkts_out)
      34                 :            : {
      35                 :            :         struct rte_mempool *direct_pool, *indirect_pool;
      36                 :            :         uint64_t ol_flags;
      37                 :            :         uint16_t gso_size;
      38                 :            :         uint8_t ipid_delta;
      39                 :            :         int ret = 1;
      40                 :            : 
      41         [ #  # ]:          0 :         if (pkt == NULL || pkts_out == NULL || gso_ctx == NULL ||
      42         [ #  # ]:          0 :                         nb_pkts_out < 1 ||
      43   [ #  #  #  #  :          0 :                         (ILLEGAL_UDP_GSO_CTX(gso_ctx) &&
                   #  # ]
      44         [ #  # ]:          0 :                          ILLEGAL_TCP_GSO_CTX(gso_ctx)))
      45                 :            :                 return -EINVAL;
      46                 :            : 
      47         [ #  # ]:          0 :         if (gso_ctx->gso_size >= pkt->pkt_len) {
      48                 :          0 :                 pkt->ol_flags &= (~(RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG));
      49                 :          0 :                 return 0;
      50                 :            :         }
      51                 :            : 
      52                 :          0 :         direct_pool = gso_ctx->direct_pool;
      53                 :          0 :         indirect_pool = gso_ctx->indirect_pool;
      54                 :            :         gso_size = gso_ctx->gso_size;
      55                 :          0 :         ipid_delta = (gso_ctx->flag != RTE_GSO_FLAG_IPID_FIXED);
      56                 :          0 :         ol_flags = pkt->ol_flags;
      57                 :            : 
      58   [ #  #  #  # ]:          0 :         if ((IS_IPV4_VXLAN_TCP4(pkt->ol_flags) &&
      59         [ #  # ]:          0 :                         (gso_ctx->gso_types & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO)) ||
      60         [ #  # ]:          0 :                         ((IS_IPV4_GRE_TCP4(pkt->ol_flags) &&
      61                 :            :                          (gso_ctx->gso_types & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO)))) {
      62                 :          0 :                 pkt->ol_flags &= (~RTE_MBUF_F_TX_TCP_SEG);
      63                 :          0 :                 ret = gso_tunnel_tcp4_segment(pkt, gso_size, ipid_delta,
      64                 :            :                                 direct_pool, indirect_pool,
      65                 :            :                                 pkts_out, nb_pkts_out);
      66         [ #  # ]:          0 :         } else if (IS_IPV4_VXLAN_UDP4(pkt->ol_flags) &&
      67         [ #  # ]:          0 :                         (gso_ctx->gso_types & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) &&
      68                 :            :                         (gso_ctx->gso_types & RTE_ETH_TX_OFFLOAD_UDP_TSO)) {
      69                 :          0 :                 pkt->ol_flags &= (~RTE_MBUF_F_TX_UDP_SEG);
      70                 :          0 :                 ret = gso_tunnel_udp4_segment(pkt, gso_size,
      71                 :            :                                 direct_pool, indirect_pool,
      72                 :            :                                 pkts_out, nb_pkts_out);
      73   [ #  #  #  # ]:          0 :         } else if (IS_IPV4_TCP(pkt->ol_flags) &&
      74                 :            :                         (gso_ctx->gso_types & RTE_ETH_TX_OFFLOAD_TCP_TSO)) {
      75                 :          0 :                 pkt->ol_flags &= (~RTE_MBUF_F_TX_TCP_SEG);
      76                 :          0 :                 ret = gso_tcp4_segment(pkt, gso_size, ipid_delta,
      77                 :            :                                 direct_pool, indirect_pool,
      78                 :            :                                 pkts_out, nb_pkts_out);
      79   [ #  #  #  # ]:          0 :         } else if (IS_IPV4_UDP(pkt->ol_flags) &&
      80                 :            :                         (gso_ctx->gso_types & RTE_ETH_TX_OFFLOAD_UDP_TSO)) {
      81                 :          0 :                 pkt->ol_flags &= (~RTE_MBUF_F_TX_UDP_SEG);
      82                 :          0 :                 ret = gso_udp4_segment(pkt, gso_size, direct_pool,
      83                 :            :                                 indirect_pool, pkts_out, nb_pkts_out);
      84                 :            :         } else {
      85                 :            :                 ret = -ENOTSUP; /* only UDP or TCP allowed */
      86                 :            :         }
      87                 :            : 
      88         [ #  # ]:          0 :         if (ret < 0) {
      89                 :            :                 /* Revert the ol_flags in the event of failure. */
      90                 :          0 :                 pkt->ol_flags = ol_flags;
      91                 :            :         }
      92                 :            : 
      93                 :            :         return ret;
      94                 :            : }

Generated by: LCOV version 1.14