LCOV - code coverage report
Current view: top level - drivers/net/cnxk - cn9k_ethdev.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 27 0.0 %
Date: 2025-01-02 22:41:34 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : #ifndef __CN9K_ETHDEV_H__
       5                 :            : #define __CN9K_ETHDEV_H__
       6                 :            : 
       7                 :            : #include <cnxk_ethdev.h>
       8                 :            : #include <cnxk_security.h>
       9                 :            : #include <cnxk_security_ar.h>
      10                 :            : 
      11                 :            : struct cn9k_eth_txq {
      12                 :            :         uint64_t send_hdr_w0;
      13                 :            :         int64_t fc_cache_pkts;
      14                 :            :         uint64_t *fc_mem;
      15                 :            :         void *lmt_addr;
      16                 :            :         rte_iova_t io_addr;
      17                 :            :         uint64_t lso_tun_fmt;
      18                 :            :         uint64_t ts_mem;
      19                 :            :         uint16_t sqes_per_sqb_log2;
      20                 :            :         int16_t nb_sqb_bufs_adj;
      21                 :            :         rte_iova_t cpt_io_addr;
      22                 :            :         uint64_t sa_base;
      23                 :            :         uint64_t *cpt_fc;
      24                 :            :         uint16_t cpt_desc;
      25                 :            :         uint64_t mark_flag : 8;
      26                 :            :         uint64_t mark_fmt : 48;
      27                 :            :         struct cnxk_eth_txq_comp tx_compl;
      28                 :            :         uint16_t tx_offload_flags;
      29                 :            : } __plt_cache_aligned;
      30                 :            : 
      31                 :            : struct cn9k_eth_rxq {
      32                 :            :         uint64_t mbuf_initializer;
      33                 :            :         uint64_t data_off;
      34                 :            :         uintptr_t desc;
      35                 :            :         void *lookup_mem;
      36                 :            :         uintptr_t cq_door;
      37                 :            :         uint64_t wdata;
      38                 :            :         int64_t *cq_status;
      39                 :            :         uint32_t head;
      40                 :            :         uint32_t qmask;
      41                 :            :         uint32_t available;
      42                 :            :         uint16_t rq;
      43                 :            :         struct cnxk_timesync_info *tstamp;
      44                 :            : } __plt_cache_aligned;
      45                 :            : 
      46                 :            : /* Private data in sw rsvd area of struct roc_onf_ipsec_inb_sa */
      47                 :            : struct cn9k_inb_priv_data {
      48                 :            :         void *userdata;
      49                 :            :         uint32_t replay_win_sz;
      50                 :            :         struct cnxk_on_ipsec_ar ar;
      51                 :            :         struct cnxk_eth_sec_sess *eth_sec;
      52                 :            : };
      53                 :            : 
      54                 :            : /* Private data in sw rsvd area of struct roc_onf_ipsec_outb_sa */
      55                 :            : struct cn9k_outb_priv_data {
      56                 :            :         union {
      57                 :            :                 uint64_t esn;
      58                 :            :                 struct {
      59                 :            :                         uint32_t seq;
      60                 :            :                         uint32_t esn_hi;
      61                 :            :                 };
      62                 :            :         };
      63                 :            : 
      64                 :            :         /* Rlen computation data */
      65                 :            :         struct cnxk_ipsec_outb_rlens rlens;
      66                 :            : 
      67                 :            :         /* IP identifier */
      68                 :            :         uint16_t ip_id;
      69                 :            : 
      70                 :            :         /* SA index */
      71                 :            :         uint32_t sa_idx;
      72                 :            : 
      73                 :            :         /* Flags */
      74                 :            :         uint16_t copy_salt : 1;
      75                 :            : 
      76                 :            :         /* Salt */
      77                 :            :         uint32_t nonce;
      78                 :            : 
      79                 :            :         /* User data pointer */
      80                 :            :         void *userdata;
      81                 :            : 
      82                 :            :         /* Back pointer to eth sec session */
      83                 :            :         struct cnxk_eth_sec_sess *eth_sec;
      84                 :            : 
      85                 :            :         /* IV in DBG mode */
      86                 :            :         uint8_t iv_dbg[ROC_IE_ON_MAX_IV_LEN];
      87                 :            : };
      88                 :            : 
      89                 :            : struct cn9k_sec_sess_priv {
      90                 :            :         union {
      91                 :            :                 struct {
      92                 :            :                         uint32_t sa_idx;
      93                 :            :                         uint8_t inb_sa : 1;
      94                 :            :                         uint8_t rsvd1 : 2;
      95                 :            :                         uint8_t roundup_byte : 5;
      96                 :            :                         uint8_t roundup_len;
      97                 :            :                         uint16_t partial_len;
      98                 :            :                 };
      99                 :            : 
     100                 :            :                 uint64_t u64;
     101                 :            :         };
     102                 :            : } __rte_packed;
     103                 :            : 
     104                 :            : /* Rx and Tx routines */
     105                 :            : void cn9k_eth_set_rx_function(struct rte_eth_dev *eth_dev);
     106                 :            : void cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev);
     107                 :            : 
     108                 :            : /* Security context setup */
     109                 :            : void cn9k_eth_sec_ops_override(void);
     110                 :            : 
     111                 :            : static inline uint16_t
     112                 :            : nix_tx_compl_nb_pkts(struct cn9k_eth_txq *txq, const uint64_t wdata,
     113                 :            :                 const uint32_t qmask)
     114                 :            : {
     115                 :          0 :         uint16_t available = txq->tx_compl.available;
     116                 :            : 
     117                 :            :         /* Update the available count if cached value is not enough */
     118         [ #  # ]:          0 :         if (!unlikely(available)) {
     119                 :            :                 uint64_t reg, head, tail;
     120                 :            : 
     121                 :            :                 /* Use LDADDA version to avoid reorder */
     122                 :            :                 reg = roc_atomic64_add_sync(wdata, txq->tx_compl.cq_status);
     123                 :            :                 /* CQ_OP_STATUS operation error */
     124                 :            :                 if (reg & BIT_ULL(NIX_CQ_OP_STAT_OP_ERR) ||
     125                 :            :                                 reg & BIT_ULL(NIX_CQ_OP_STAT_CQ_ERR))
     126                 :            :                         return 0;
     127                 :            : 
     128                 :            :                 tail = reg & 0xFFFFF;
     129                 :            :                 head = (reg >> 20) & 0xFFFFF;
     130                 :            :                 if (tail < head)
     131                 :            :                         available = tail - head + qmask + 1;
     132                 :            :                 else
     133                 :            :                         available = tail - head;
     134                 :            : 
     135                 :          0 :                 txq->tx_compl.available = available;
     136                 :            :         }
     137                 :            :         return available;
     138                 :            : }
     139                 :            : 
     140                 :            : static inline void
     141                 :          0 : handle_tx_completion_pkts(struct cn9k_eth_txq *txq, uint8_t mt_safe)
     142                 :            : {
     143                 :            : #define CNXK_NIX_CQ_ENTRY_SZ 128
     144                 :            : #define CQE_SZ(x)            ((x) * CNXK_NIX_CQ_ENTRY_SZ)
     145                 :            : 
     146                 :            :         uint16_t tx_pkts = 0, nb_pkts;
     147                 :          0 :         const uintptr_t desc = txq->tx_compl.desc_base;
     148                 :          0 :         const uint64_t wdata = txq->tx_compl.wdata;
     149                 :          0 :         const uint32_t qmask = txq->tx_compl.qmask;
     150                 :          0 :         uint32_t head = txq->tx_compl.head;
     151                 :            :         struct nix_cqe_hdr_s *tx_compl_cq;
     152                 :            :         struct nix_send_comp_s *tx_compl_s0;
     153                 :            :         struct rte_mbuf *m_next, *m;
     154                 :            : 
     155         [ #  # ]:          0 :         if (mt_safe)
     156                 :          0 :                 rte_spinlock_lock(&txq->tx_compl.ext_buf_lock);
     157                 :            : 
     158                 :            :         nb_pkts = nix_tx_compl_nb_pkts(txq, wdata, qmask);
     159         [ #  # ]:          0 :         while (tx_pkts < nb_pkts) {
     160                 :          0 :                 rte_prefetch_non_temporal((void *)(desc +
     161                 :          0 :                                         (CQE_SZ((head + 2) & qmask))));
     162                 :          0 :                 tx_compl_cq = (struct nix_cqe_hdr_s *)
     163                 :          0 :                         (desc + CQE_SZ(head));
     164                 :            :                 tx_compl_s0 = (struct nix_send_comp_s *)
     165                 :            :                         ((uint64_t *)tx_compl_cq + 1);
     166                 :          0 :                 m = txq->tx_compl.ptr[tx_compl_s0->sqe_id];
     167         [ #  # ]:          0 :                 while (m->next != NULL) {
     168                 :            :                         m_next = m->next;
     169                 :            :                         rte_pktmbuf_free_seg(m);
     170                 :            :                         m = m_next;
     171                 :            :                 }
     172                 :            :                 rte_pktmbuf_free_seg(m);
     173                 :          0 :                 txq->tx_compl.ptr[tx_compl_s0->sqe_id] = NULL;
     174                 :            : 
     175                 :          0 :                 head++;
     176                 :          0 :                 head &= qmask;
     177                 :          0 :                 tx_pkts++;
     178                 :            :         }
     179                 :          0 :         txq->tx_compl.head = head;
     180                 :          0 :         txq->tx_compl.available -= nb_pkts;
     181                 :            : 
     182         [ #  # ]:          0 :         plt_write64((wdata | nb_pkts), txq->tx_compl.cq_door);
     183                 :            : 
     184         [ #  # ]:          0 :         if (mt_safe)
     185                 :          0 :                 rte_spinlock_unlock(&txq->tx_compl.ext_buf_lock);
     186                 :          0 : }
     187                 :            : 
     188                 :            : 
     189                 :            : #endif /* __CN9K_ETHDEV_H__ */

Generated by: LCOV version 1.14