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

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

Generated by: LCOV version 1.14