LCOV - code coverage report
Current view: top level - drivers/net/failsafe - failsafe_rxtx.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 31 0.0 %
Date: 2026-12-01 19:01:22 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 38 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright 2017 6WIND S.A.
       3                 :            :  * Copyright 2017 Mellanox Technologies, Ltd
       4                 :            :  */
       5                 :            : 
       6                 :            : #include <rte_stdatomic.h>
       7                 :            : #include <rte_debug.h>
       8                 :            : #include <rte_mbuf.h>
       9                 :            : #include <ethdev_driver.h>
      10                 :            : 
      11                 :            : #include "failsafe_private.h"
      12                 :            : 
      13                 :            : static inline int
      14                 :            : fs_rx_unsafe(struct sub_device *sdev)
      15                 :            : {
      16                 :          0 :         return (ETH(sdev) == NULL) ||
      17         [ #  # ]:          0 :                 (ETH(sdev)->rx_pkt_burst == NULL) ||
      18   [ #  #  #  # ]:          0 :                 (sdev->state != DEV_STARTED) ||
      19         [ #  # ]:          0 :                 (sdev->remove != 0);
      20                 :            : }
      21                 :            : 
      22                 :            : static inline int
      23                 :            : fs_tx_unsafe(struct sub_device *sdev)
      24                 :            : {
      25                 :          0 :         return (sdev == NULL) ||
      26         [ #  # ]:          0 :                 (ETH(sdev) == NULL) ||
      27   [ #  #  #  # ]:          0 :                 (ETH(sdev)->tx_pkt_burst == NULL) ||
      28                 :            :                 (sdev->state != DEV_STARTED);
      29                 :            : }
      30                 :            : 
      31                 :            : /*
      32                 :            :  * Override source port in Rx packets.
      33                 :            :  *
      34                 :            :  * Make Rx packets originate from this PMD instance instead of one of its
      35                 :            :  * sub-devices. This is mandatory to avoid breaking applications.
      36                 :            :  */
      37                 :            : static void
      38                 :            : failsafe_rx_set_port(struct rte_mbuf **rx_pkts, uint16_t nb_pkts, uint16_t port)
      39                 :            : {
      40                 :            :         unsigned int i;
      41                 :            : 
      42         [ #  # ]:          0 :         for (i = 0; i != nb_pkts; ++i)
      43                 :          0 :                 rx_pkts[i]->port = port;
      44                 :            : }
      45                 :            : 
      46                 :            : uint16_t
      47                 :          0 : failsafe_rx_burst(void *queue,
      48                 :            :                   struct rte_mbuf **rx_pkts,
      49                 :            :                   uint16_t nb_pkts)
      50                 :            : {
      51                 :            :         struct sub_device *sdev;
      52                 :            :         struct rxq *rxq;
      53                 :            :         void *sub_rxq;
      54                 :            :         uint16_t nb_rx;
      55                 :            : 
      56                 :            :         rxq = queue;
      57                 :          0 :         sdev = rxq->sdev;
      58                 :            :         do {
      59         [ #  # ]:          0 :                 if (unlikely(fs_rx_unsafe(sdev))) {
      60                 :            :                         nb_rx = 0;
      61                 :          0 :                         sdev = sdev->next;
      62                 :            :                         continue;
      63                 :            :                 }
      64         [ #  # ]:          0 :                 sub_rxq = ETH(sdev)->data->rx_queues[rxq->qid];
      65                 :          0 :                 FS_ATOMIC_P(rxq->refcnt[sdev->sid]);
      66         [ #  # ]:          0 :                 nb_rx = ETH(sdev)->
      67                 :            :                         rx_pkt_burst(sub_rxq, rx_pkts, nb_pkts);
      68                 :          0 :                 FS_ATOMIC_V(rxq->refcnt[sdev->sid]);
      69                 :          0 :                 sdev = sdev->next;
      70   [ #  #  #  # ]:          0 :         } while (nb_rx == 0 && sdev != rxq->sdev);
      71                 :          0 :         rxq->sdev = sdev;
      72         [ #  # ]:          0 :         if (nb_rx)
      73                 :            :                 failsafe_rx_set_port(rx_pkts, nb_rx,
      74                 :          0 :                                      rxq->priv->data->port_id);
      75                 :          0 :         return nb_rx;
      76                 :            : }
      77                 :            : 
      78                 :            : uint16_t
      79                 :          0 : failsafe_tx_burst(void *queue,
      80                 :            :                   struct rte_mbuf **tx_pkts,
      81                 :            :                   uint16_t nb_pkts)
      82                 :            : {
      83                 :            :         struct sub_device *sdev;
      84                 :            :         struct txq *txq;
      85                 :            :         void *sub_txq;
      86                 :            :         uint16_t nb_tx;
      87                 :            : 
      88                 :            :         txq = queue;
      89   [ #  #  #  # ]:          0 :         sdev = TX_SUBDEV(&rte_eth_devices[txq->priv->data->port_id]);
      90         [ #  # ]:          0 :         if (unlikely(fs_tx_unsafe(sdev)))
      91                 :            :                 return 0;
      92         [ #  # ]:          0 :         sub_txq = ETH(sdev)->data->tx_queues[txq->qid];
      93                 :          0 :         FS_ATOMIC_P(txq->refcnt[sdev->sid]);
      94         [ #  # ]:          0 :         nb_tx = ETH(sdev)->tx_pkt_burst(sub_txq, tx_pkts, nb_pkts);
      95                 :          0 :         FS_ATOMIC_V(txq->refcnt[sdev->sid]);
      96                 :          0 :         return nb_tx;
      97                 :            : }

Generated by: LCOV version 1.14