LCOV - code coverage report
Current view: top level - lib/port - rte_port_sym_crypto.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 177 0.0 %
Date: 2024-01-22 15:35:40 Functions: 0 18 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 88 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Intel Corporation
       3                 :            :  */
       4                 :            : #include <string.h>
       5                 :            : 
       6                 :            : #include <rte_common.h>
       7                 :            : #include <rte_malloc.h>
       8                 :            : 
       9                 :            : #include "rte_port_sym_crypto.h"
      10                 :            : 
      11                 :            : #include "port_log.h"
      12                 :            : 
      13                 :            : /*
      14                 :            :  * Port Crypto Reader
      15                 :            :  */
      16                 :            : #ifdef RTE_PORT_STATS_COLLECT
      17                 :            : 
      18                 :            : #define RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_IN_ADD(port, val) \
      19                 :            :         (port)->stats.n_pkts_in += (val)
      20                 :            : #define RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_DROP_ADD(port, val) \
      21                 :            :         (port)->stats.n_pkts_drop += (val)
      22                 :            : 
      23                 :            : #else
      24                 :            : 
      25                 :            : #define RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_IN_ADD(port, val)
      26                 :            : #define RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_DROP_ADD(port, val)
      27                 :            : 
      28                 :            : #endif
      29                 :            : 
      30                 :            : struct rte_port_sym_crypto_reader {
      31                 :            :         struct rte_port_in_stats stats;
      32                 :            : 
      33                 :            :         uint8_t cryptodev_id;
      34                 :            :         uint16_t queue_id;
      35                 :            :         struct rte_crypto_op *ops[RTE_PORT_IN_BURST_SIZE_MAX];
      36                 :            :         rte_port_sym_crypto_reader_callback_fn f_callback;
      37                 :            :         void *arg_callback;
      38                 :            : };
      39                 :            : 
      40                 :            : static void *
      41                 :          0 : rte_port_sym_crypto_reader_create(void *params, int socket_id)
      42                 :            : {
      43                 :            :         struct rte_port_sym_crypto_reader_params *conf =
      44                 :            :                         params;
      45                 :            :         struct rte_port_sym_crypto_reader *port;
      46                 :            : 
      47                 :            :         /* Check input parameters */
      48         [ #  # ]:          0 :         if (conf == NULL) {
      49                 :          0 :                 PORT_LOG(ERR, "%s: params is NULL", __func__);
      50                 :          0 :                 return NULL;
      51                 :            :         }
      52                 :            : 
      53                 :            :         /* Memory allocation */
      54                 :          0 :         port = rte_zmalloc_socket("PORT", sizeof(*port),
      55                 :            :                 RTE_CACHE_LINE_SIZE, socket_id);
      56         [ #  # ]:          0 :         if (port == NULL) {
      57                 :          0 :                 PORT_LOG(ERR, "%s: Failed to allocate port", __func__);
      58                 :          0 :                 return NULL;
      59                 :            :         }
      60                 :            : 
      61                 :            :         /* Initialization */
      62                 :          0 :         port->cryptodev_id = conf->cryptodev_id;
      63                 :          0 :         port->queue_id = conf->queue_id;
      64                 :          0 :         port->f_callback = conf->f_callback;
      65                 :          0 :         port->arg_callback = conf->arg_callback;
      66                 :            : 
      67                 :          0 :         return port;
      68                 :            : }
      69                 :            : 
      70                 :            : static int
      71                 :          0 : rte_port_sym_crypto_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
      72                 :            : {
      73                 :            :         struct rte_port_sym_crypto_reader *p =
      74                 :            :                         port;
      75                 :            :         uint16_t rx_ops_cnt, i, n = 0;
      76                 :            : 
      77                 :          0 :         rx_ops_cnt = rte_cryptodev_dequeue_burst(p->cryptodev_id, p->queue_id,
      78                 :          0 :                         p->ops, n_pkts);
      79                 :            : 
      80         [ #  # ]:          0 :         for (i = 0; i < rx_ops_cnt; i++) {
      81                 :          0 :                 struct rte_crypto_op *op = p->ops[i];
      82                 :            : 
      83                 :            :                 /** Drop failed pkts */
      84         [ #  # ]:          0 :                 if (unlikely(op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)) {
      85                 :          0 :                         rte_pktmbuf_free(op->sym->m_src);
      86                 :          0 :                         continue;
      87                 :            :                 }
      88                 :            : 
      89                 :          0 :                 pkts[n++] = op->sym->m_src;
      90                 :            :         }
      91                 :            : 
      92         [ #  # ]:          0 :         if (p->f_callback)
      93                 :          0 :                 (*p->f_callback)(pkts, n, p->arg_callback);
      94                 :            : 
      95                 :            :         RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_IN_ADD(p, n);
      96                 :            :         RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_DROP_ADD(p, rx_ops_cnt - n);
      97                 :            : 
      98                 :          0 :         return n;
      99                 :            : }
     100                 :            : 
     101                 :            : static int
     102                 :          0 : rte_port_sym_crypto_reader_free(void *port)
     103                 :            : {
     104         [ #  # ]:          0 :         if (port == NULL) {
     105                 :          0 :                 PORT_LOG(ERR, "%s: port is NULL", __func__);
     106                 :          0 :                 return -EINVAL;
     107                 :            :         }
     108                 :            : 
     109                 :          0 :         rte_free(port);
     110                 :            : 
     111                 :          0 :         return 0;
     112                 :            : }
     113                 :            : 
     114                 :          0 : static int rte_port_sym_crypto_reader_stats_read(void *port,
     115                 :            :         struct rte_port_in_stats *stats, int clear)
     116                 :            : {
     117                 :            :         struct rte_port_sym_crypto_reader *p =
     118                 :            :                         port;
     119                 :            : 
     120         [ #  # ]:          0 :         if (stats != NULL)
     121                 :          0 :                 memcpy(stats, &p->stats, sizeof(p->stats));
     122                 :            : 
     123         [ #  # ]:          0 :         if (clear)
     124                 :          0 :                 memset(&p->stats, 0, sizeof(p->stats));
     125                 :            : 
     126                 :          0 :         return 0;
     127                 :            : }
     128                 :            : 
     129                 :            : /*
     130                 :            :  * Port crypto Writer
     131                 :            :  */
     132                 :            : #ifdef RTE_PORT_STATS_COLLECT
     133                 :            : 
     134                 :            : #define RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(port, val) \
     135                 :            :         (port)->stats.n_pkts_in += (val)
     136                 :            : #define RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_DROP_ADD(port, val) \
     137                 :            :         (port)->stats.n_pkts_drop += (val)
     138                 :            : 
     139                 :            : #else
     140                 :            : 
     141                 :            : #define RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(port, val)
     142                 :            : #define RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_DROP_ADD(port, val)
     143                 :            : 
     144                 :            : #endif
     145                 :            : 
     146                 :            : struct rte_port_sym_crypto_writer {
     147                 :            :         struct rte_port_out_stats stats;
     148                 :            : 
     149                 :            :         struct rte_crypto_op *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX];
     150                 :            : 
     151                 :            :         uint32_t tx_burst_sz;
     152                 :            :         uint32_t tx_buf_count;
     153                 :            :         uint64_t bsz_mask;
     154                 :            : 
     155                 :            :         uint8_t cryptodev_id;
     156                 :            :         uint16_t queue_id;
     157                 :            :         uint16_t crypto_op_offset;
     158                 :            : };
     159                 :            : 
     160                 :            : static void *
     161                 :          0 : rte_port_sym_crypto_writer_create(void *params, int socket_id)
     162                 :            : {
     163                 :            :         struct rte_port_sym_crypto_writer_params *conf =
     164                 :            :                         params;
     165                 :            :         struct rte_port_sym_crypto_writer *port;
     166                 :            : 
     167                 :            :         /* Check input parameters */
     168         [ #  # ]:          0 :         if ((conf == NULL) ||
     169   [ #  #  #  # ]:          0 :                 (conf->tx_burst_sz == 0) ||
     170                 :            :                 (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
     171                 :            :                 (!rte_is_power_of_2(conf->tx_burst_sz))) {
     172                 :          0 :                 PORT_LOG(ERR, "%s: Invalid input parameters", __func__);
     173                 :          0 :                 return NULL;
     174                 :            :         }
     175                 :            : 
     176                 :            :         /* Memory allocation */
     177                 :          0 :         port = rte_zmalloc_socket("PORT", sizeof(*port),
     178                 :            :                 RTE_CACHE_LINE_SIZE, socket_id);
     179         [ #  # ]:          0 :         if (port == NULL) {
     180                 :          0 :                 PORT_LOG(ERR, "%s: Failed to allocate port", __func__);
     181                 :          0 :                 return NULL;
     182                 :            :         }
     183                 :            : 
     184                 :            :         /* Initialization */
     185                 :          0 :         port->tx_burst_sz = conf->tx_burst_sz;
     186                 :          0 :         port->tx_buf_count = 0;
     187                 :          0 :         port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1);
     188                 :            : 
     189                 :          0 :         port->cryptodev_id = conf->cryptodev_id;
     190                 :          0 :         port->queue_id = conf->queue_id;
     191                 :          0 :         port->crypto_op_offset = conf->crypto_op_offset;
     192                 :            : 
     193                 :          0 :         return port;
     194                 :            : }
     195                 :            : 
     196                 :            : static inline void
     197                 :          0 : send_burst(struct rte_port_sym_crypto_writer *p)
     198                 :            : {
     199                 :            :         uint32_t nb_tx;
     200                 :            : 
     201                 :          0 :         nb_tx = rte_cryptodev_enqueue_burst(p->cryptodev_id, p->queue_id,
     202                 :          0 :                         p->tx_buf, p->tx_buf_count);
     203                 :            : 
     204                 :            :         RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count -
     205                 :            :                         nb_tx);
     206         [ #  # ]:          0 :         for (; nb_tx < p->tx_buf_count; nb_tx++)
     207                 :          0 :                 rte_pktmbuf_free(p->tx_buf[nb_tx]->sym->m_src);
     208                 :            : 
     209                 :          0 :         p->tx_buf_count = 0;
     210                 :          0 : }
     211                 :            : 
     212                 :            : static int
     213                 :          0 : rte_port_sym_crypto_writer_tx(void *port, struct rte_mbuf *pkt)
     214                 :            : {
     215                 :            :         struct rte_port_sym_crypto_writer *p =
     216                 :            :                         port;
     217                 :            : 
     218                 :          0 :         p->tx_buf[p->tx_buf_count++] = (struct rte_crypto_op *)
     219                 :          0 :                         RTE_MBUF_METADATA_UINT8_PTR(pkt, p->crypto_op_offset);
     220                 :            :         RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(p, 1);
     221         [ #  # ]:          0 :         if (p->tx_buf_count >= p->tx_burst_sz)
     222                 :          0 :                 send_burst(p);
     223                 :            : 
     224                 :          0 :         return 0;
     225                 :            : }
     226                 :            : 
     227                 :            : static int
     228                 :          0 : rte_port_sym_crypto_writer_tx_bulk(void *port,
     229                 :            :         struct rte_mbuf **pkts,
     230                 :            :         uint64_t pkts_mask)
     231                 :            : {
     232                 :            :         struct rte_port_sym_crypto_writer *p =
     233                 :            :                         port;
     234                 :          0 :         uint64_t bsz_mask = p->bsz_mask;
     235                 :          0 :         uint32_t tx_buf_count = p->tx_buf_count;
     236                 :          0 :         uint64_t expr = (pkts_mask & (pkts_mask + 1)) |
     237                 :            :                                         ((pkts_mask & bsz_mask) ^ bsz_mask);
     238                 :            : 
     239         [ #  # ]:          0 :         if (expr == 0) {
     240                 :            :                 uint64_t n_pkts = rte_popcount64(pkts_mask);
     241                 :            :                 uint32_t i;
     242                 :            : 
     243                 :            :                 RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(p, n_pkts);
     244                 :            : 
     245         [ #  # ]:          0 :                 for (i = 0; i < n_pkts; i++)
     246                 :          0 :                         p->tx_buf[p->tx_buf_count++] = (struct rte_crypto_op *)
     247                 :          0 :                                         RTE_MBUF_METADATA_UINT8_PTR(pkts[i],
     248                 :            :                                                         p->crypto_op_offset);
     249                 :            : 
     250         [ #  # ]:          0 :                 if (p->tx_buf_count >= p->tx_burst_sz)
     251                 :          0 :                         send_burst(p);
     252                 :            :         } else {
     253         [ #  # ]:          0 :                 for (; pkts_mask;) {
     254                 :            :                         uint32_t pkt_index = rte_ctz64(pkts_mask);
     255                 :          0 :                         uint64_t pkt_mask = 1LLU << pkt_index;
     256                 :          0 :                         struct rte_mbuf *pkt = pkts[pkt_index];
     257                 :            : 
     258                 :          0 :                         p->tx_buf[tx_buf_count++] = (struct rte_crypto_op *)
     259                 :          0 :                                         RTE_MBUF_METADATA_UINT8_PTR(pkt,
     260                 :            :                                                         p->crypto_op_offset);
     261                 :            : 
     262                 :            :                         RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(p, 1);
     263                 :          0 :                         pkts_mask &= ~pkt_mask;
     264                 :            :                 }
     265                 :            : 
     266                 :          0 :                 p->tx_buf_count = tx_buf_count;
     267         [ #  # ]:          0 :                 if (tx_buf_count >= p->tx_burst_sz)
     268                 :          0 :                         send_burst(p);
     269                 :            :         }
     270                 :            : 
     271                 :          0 :         return 0;
     272                 :            : }
     273                 :            : 
     274                 :            : static int
     275                 :          0 : rte_port_sym_crypto_writer_flush(void *port)
     276                 :            : {
     277                 :            :         struct rte_port_sym_crypto_writer *p =
     278                 :            :                         port;
     279                 :            : 
     280   [ #  #  #  # ]:          0 :         if (p->tx_buf_count > 0)
     281                 :          0 :                 send_burst(p);
     282                 :            : 
     283                 :          0 :         return 0;
     284                 :            : }
     285                 :            : 
     286                 :            : static int
     287                 :          0 : rte_port_sym_crypto_writer_free(void *port)
     288                 :            : {
     289         [ #  # ]:          0 :         if (port == NULL) {
     290                 :          0 :                 PORT_LOG(ERR, "%s: Port is NULL", __func__);
     291                 :          0 :                 return -EINVAL;
     292                 :            :         }
     293                 :            : 
     294                 :            :         rte_port_sym_crypto_writer_flush(port);
     295                 :          0 :         rte_free(port);
     296                 :            : 
     297                 :          0 :         return 0;
     298                 :            : }
     299                 :            : 
     300                 :          0 : static int rte_port_sym_crypto_writer_stats_read(void *port,
     301                 :            :         struct rte_port_out_stats *stats, int clear)
     302                 :            : {
     303                 :            :         struct rte_port_sym_crypto_writer *p =
     304                 :            :                         port;
     305                 :            : 
     306         [ #  # ]:          0 :         if (stats != NULL)
     307                 :          0 :                 memcpy(stats, &p->stats, sizeof(p->stats));
     308                 :            : 
     309         [ #  # ]:          0 :         if (clear)
     310                 :          0 :                 memset(&p->stats, 0, sizeof(p->stats));
     311                 :            : 
     312                 :          0 :         return 0;
     313                 :            : }
     314                 :            : 
     315                 :            : /*
     316                 :            :  * Port crypto Writer Nodrop
     317                 :            :  */
     318                 :            : #ifdef RTE_PORT_STATS_COLLECT
     319                 :            : 
     320                 :            : #define RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \
     321                 :            :         (port)->stats.n_pkts_in += (val)
     322                 :            : #define RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \
     323                 :            :         (port)->stats.n_pkts_drop += (val)
     324                 :            : 
     325                 :            : #else
     326                 :            : 
     327                 :            : #define RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val)
     328                 :            : #define RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val)
     329                 :            : 
     330                 :            : #endif
     331                 :            : 
     332                 :            : struct rte_port_sym_crypto_writer_nodrop {
     333                 :            :         struct rte_port_out_stats stats;
     334                 :            : 
     335                 :            :         struct rte_crypto_op *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX];
     336                 :            :         uint32_t tx_burst_sz;
     337                 :            :         uint32_t tx_buf_count;
     338                 :            :         uint64_t bsz_mask;
     339                 :            :         uint64_t n_retries;
     340                 :            : 
     341                 :            :         uint8_t cryptodev_id;
     342                 :            :         uint16_t queue_id;
     343                 :            :         uint16_t crypto_op_offset;
     344                 :            : };
     345                 :            : 
     346                 :            : static void *
     347                 :          0 : rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id)
     348                 :            : {
     349                 :            :         struct rte_port_sym_crypto_writer_nodrop_params *conf =
     350                 :            :                 params;
     351                 :            :         struct rte_port_sym_crypto_writer_nodrop *port;
     352                 :            : 
     353                 :            :         /* Check input parameters */
     354         [ #  # ]:          0 :         if ((conf == NULL) ||
     355   [ #  #  #  # ]:          0 :                 (conf->tx_burst_sz == 0) ||
     356                 :            :                 (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
     357                 :            :                 (!rte_is_power_of_2(conf->tx_burst_sz))) {
     358                 :          0 :                 PORT_LOG(ERR, "%s: Invalid input parameters", __func__);
     359                 :          0 :                 return NULL;
     360                 :            :         }
     361                 :            : 
     362                 :            :         /* Memory allocation */
     363                 :          0 :         port = rte_zmalloc_socket("PORT", sizeof(*port),
     364                 :            :                 RTE_CACHE_LINE_SIZE, socket_id);
     365         [ #  # ]:          0 :         if (port == NULL) {
     366                 :          0 :                 PORT_LOG(ERR, "%s: Failed to allocate port", __func__);
     367                 :          0 :                 return NULL;
     368                 :            :         }
     369                 :            : 
     370                 :            :         /* Initialization */
     371                 :          0 :         port->cryptodev_id = conf->cryptodev_id;
     372                 :          0 :         port->queue_id = conf->queue_id;
     373                 :          0 :         port->crypto_op_offset = conf->crypto_op_offset;
     374                 :          0 :         port->tx_burst_sz = conf->tx_burst_sz;
     375                 :          0 :         port->tx_buf_count = 0;
     376                 :          0 :         port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1);
     377                 :            : 
     378                 :            :         /*
     379                 :            :          * When n_retries is 0 it means that we should wait for every packet to
     380                 :            :          * send no matter how many retries should it take. To limit number of
     381                 :            :          * branches in fast path, we use UINT64_MAX instead of branching.
     382                 :            :          */
     383         [ #  # ]:          0 :         port->n_retries = (conf->n_retries == 0) ? UINT64_MAX : conf->n_retries;
     384                 :            : 
     385                 :          0 :         return port;
     386                 :            : }
     387                 :            : 
     388                 :            : static inline void
     389                 :          0 : send_burst_nodrop(struct rte_port_sym_crypto_writer_nodrop *p)
     390                 :            : {
     391                 :            :         uint32_t nb_tx = 0, i;
     392                 :            : 
     393                 :          0 :         nb_tx = rte_cryptodev_enqueue_burst(p->cryptodev_id, p->queue_id,
     394                 :          0 :                         p->tx_buf, p->tx_buf_count);
     395                 :            : 
     396                 :            :         /* We sent all the packets in a first try */
     397         [ #  # ]:          0 :         if (nb_tx >= p->tx_buf_count) {
     398                 :          0 :                 p->tx_buf_count = 0;
     399                 :          0 :                 return;
     400                 :            :         }
     401                 :            : 
     402         [ #  # ]:          0 :         for (i = 0; i < p->n_retries; i++) {
     403                 :          0 :                 nb_tx += rte_cryptodev_enqueue_burst(p->cryptodev_id,
     404                 :          0 :                                 p->queue_id, p->tx_buf + nb_tx,
     405                 :          0 :                                 p->tx_buf_count - nb_tx);
     406                 :            : 
     407                 :            :                 /* We sent all the packets in more than one try */
     408         [ #  # ]:          0 :                 if (nb_tx >= p->tx_buf_count) {
     409                 :          0 :                         p->tx_buf_count = 0;
     410                 :          0 :                         return;
     411                 :            :                 }
     412                 :            :         }
     413                 :            : 
     414                 :            :         /* We didn't send the packets in maximum allowed attempts */
     415                 :            :         RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_DROP_ADD(p,
     416                 :            :                         p->tx_buf_count - nb_tx);
     417         [ #  # ]:          0 :         for ( ; nb_tx < p->tx_buf_count; nb_tx++)
     418                 :          0 :                 rte_pktmbuf_free(p->tx_buf[nb_tx]->sym->m_src);
     419                 :            : 
     420                 :          0 :         p->tx_buf_count = 0;
     421                 :            : }
     422                 :            : 
     423                 :            : static int
     424                 :          0 : rte_port_sym_crypto_writer_nodrop_tx(void *port, struct rte_mbuf *pkt)
     425                 :            : {
     426                 :            :         struct rte_port_sym_crypto_writer_nodrop *p =
     427                 :            :                         port;
     428                 :            : 
     429                 :          0 :         p->tx_buf[p->tx_buf_count++] = (struct rte_crypto_op *)
     430                 :          0 :                         RTE_MBUF_METADATA_UINT8_PTR(pkt, p->crypto_op_offset);
     431                 :            :         RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(p, 1);
     432         [ #  # ]:          0 :         if (p->tx_buf_count >= p->tx_burst_sz)
     433                 :          0 :                 send_burst_nodrop(p);
     434                 :            : 
     435                 :          0 :         return 0;
     436                 :            : }
     437                 :            : 
     438                 :            : static int
     439                 :          0 : rte_port_sym_crypto_writer_nodrop_tx_bulk(void *port,
     440                 :            :         struct rte_mbuf **pkts,
     441                 :            :         uint64_t pkts_mask)
     442                 :            : {
     443                 :            :         struct rte_port_sym_crypto_writer_nodrop *p =
     444                 :            :                         port;
     445                 :            : 
     446                 :          0 :         uint64_t bsz_mask = p->bsz_mask;
     447                 :          0 :         uint32_t tx_buf_count = p->tx_buf_count;
     448                 :          0 :         uint64_t expr = (pkts_mask & (pkts_mask + 1)) |
     449                 :            :                                         ((pkts_mask & bsz_mask) ^ bsz_mask);
     450                 :            : 
     451         [ #  # ]:          0 :         if (expr == 0) {
     452                 :            :                 uint64_t n_pkts = rte_popcount64(pkts_mask);
     453                 :            :                 uint32_t i;
     454                 :            : 
     455                 :            :                 RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts);
     456                 :            : 
     457         [ #  # ]:          0 :                 for (i = 0; i < n_pkts; i++)
     458                 :          0 :                         p->tx_buf[p->tx_buf_count++] = (struct rte_crypto_op *)
     459                 :          0 :                                         RTE_MBUF_METADATA_UINT8_PTR(pkts[i],
     460                 :            :                                                         p->crypto_op_offset);
     461                 :            : 
     462         [ #  # ]:          0 :                 if (p->tx_buf_count >= p->tx_burst_sz)
     463                 :          0 :                         send_burst_nodrop(p);
     464                 :            :         } else {
     465         [ #  # ]:          0 :                 for ( ; pkts_mask; ) {
     466                 :            :                         uint32_t pkt_index = rte_ctz64(pkts_mask);
     467                 :          0 :                         uint64_t pkt_mask = 1LLU << pkt_index;
     468                 :          0 :                         struct rte_mbuf *pkt = pkts[pkt_index];
     469                 :            : 
     470                 :          0 :                         p->tx_buf[tx_buf_count++] = (struct rte_crypto_op *)
     471                 :          0 :                                         RTE_MBUF_METADATA_UINT8_PTR(pkt,
     472                 :            :                                                         p->crypto_op_offset);
     473                 :            :                         RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_IN_ADD(p,
     474                 :            :                                         1);
     475                 :          0 :                         pkts_mask &= ~pkt_mask;
     476                 :            :                 }
     477                 :            : 
     478                 :          0 :                 p->tx_buf_count = tx_buf_count;
     479         [ #  # ]:          0 :                 if (tx_buf_count >= p->tx_burst_sz)
     480                 :          0 :                         send_burst_nodrop(p);
     481                 :            :         }
     482                 :            : 
     483                 :          0 :         return 0;
     484                 :            : }
     485                 :            : 
     486                 :            : static int
     487                 :          0 : rte_port_sym_crypto_writer_nodrop_flush(void *port)
     488                 :            : {
     489                 :            :         struct rte_port_sym_crypto_writer_nodrop *p =
     490                 :            :                 port;
     491                 :            : 
     492   [ #  #  #  # ]:          0 :         if (p->tx_buf_count > 0)
     493                 :          0 :                 send_burst_nodrop(p);
     494                 :            : 
     495                 :          0 :         return 0;
     496                 :            : }
     497                 :            : 
     498                 :            : static int
     499                 :          0 : rte_port_sym_crypto_writer_nodrop_free(void *port)
     500                 :            : {
     501         [ #  # ]:          0 :         if (port == NULL) {
     502                 :          0 :                 PORT_LOG(ERR, "%s: Port is NULL", __func__);
     503                 :          0 :                 return -EINVAL;
     504                 :            :         }
     505                 :            : 
     506                 :            :         rte_port_sym_crypto_writer_nodrop_flush(port);
     507                 :          0 :         rte_free(port);
     508                 :            : 
     509                 :          0 :         return 0;
     510                 :            : }
     511                 :            : 
     512                 :          0 : static int rte_port_sym_crypto_writer_nodrop_stats_read(void *port,
     513                 :            :         struct rte_port_out_stats *stats, int clear)
     514                 :            : {
     515                 :            :         struct rte_port_sym_crypto_writer_nodrop *p =
     516                 :            :                         port;
     517                 :            : 
     518         [ #  # ]:          0 :         if (stats != NULL)
     519                 :          0 :                 memcpy(stats, &p->stats, sizeof(p->stats));
     520                 :            : 
     521         [ #  # ]:          0 :         if (clear)
     522                 :          0 :                 memset(&p->stats, 0, sizeof(p->stats));
     523                 :            : 
     524                 :          0 :         return 0;
     525                 :            : }
     526                 :            : 
     527                 :            : 
     528                 :            : /*
     529                 :            :  * Summary of port operations
     530                 :            :  */
     531                 :            : struct rte_port_in_ops rte_port_sym_crypto_reader_ops = {
     532                 :            :         .f_create = rte_port_sym_crypto_reader_create,
     533                 :            :         .f_free = rte_port_sym_crypto_reader_free,
     534                 :            :         .f_rx = rte_port_sym_crypto_reader_rx,
     535                 :            :         .f_stats = rte_port_sym_crypto_reader_stats_read,
     536                 :            : };
     537                 :            : 
     538                 :            : struct rte_port_out_ops rte_port_sym_crypto_writer_ops = {
     539                 :            :         .f_create = rte_port_sym_crypto_writer_create,
     540                 :            :         .f_free = rte_port_sym_crypto_writer_free,
     541                 :            :         .f_tx = rte_port_sym_crypto_writer_tx,
     542                 :            :         .f_tx_bulk = rte_port_sym_crypto_writer_tx_bulk,
     543                 :            :         .f_flush = rte_port_sym_crypto_writer_flush,
     544                 :            :         .f_stats = rte_port_sym_crypto_writer_stats_read,
     545                 :            : };
     546                 :            : 
     547                 :            : struct rte_port_out_ops rte_port_sym_crypto_writer_nodrop_ops = {
     548                 :            :         .f_create = rte_port_sym_crypto_writer_nodrop_create,
     549                 :            :         .f_free = rte_port_sym_crypto_writer_nodrop_free,
     550                 :            :         .f_tx = rte_port_sym_crypto_writer_nodrop_tx,
     551                 :            :         .f_tx_bulk = rte_port_sym_crypto_writer_nodrop_tx_bulk,
     552                 :            :         .f_flush = rte_port_sym_crypto_writer_nodrop_flush,
     553                 :            :         .f_stats = rte_port_sym_crypto_writer_nodrop_stats_read,
     554                 :            : };

Generated by: LCOV version 1.14