dpdk/drivers/net/octeontx/octeontx_rxtx.c
<<
>>
Prefs
   1/* SPDX-License-Identifier: BSD-3-Clause
   2 * Copyright(c) 2017 Cavium, Inc
   3 */
   4
   5#include <stdint.h>
   6#include <stdio.h>
   7#include <stdlib.h>
   8#include <unistd.h>
   9
  10#include <rte_atomic.h>
  11#include <rte_common.h>
  12#include <ethdev_driver.h>
  13#include <rte_ether.h>
  14#include <rte_log.h>
  15#include <rte_mbuf.h>
  16#include <rte_prefetch.h>
  17
  18#include "octeontx_ethdev.h"
  19#include "octeontx_rxtx.h"
  20#include "octeontx_logs.h"
  21
  22uint16_t __rte_hot
  23octeontx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
  24{
  25        struct octeontx_rxq *rxq;
  26        struct rte_event ev;
  27        size_t count;
  28        uint16_t valid_event;
  29
  30        rxq = rx_queue;
  31        count = 0;
  32        while (count < nb_pkts) {
  33                valid_event = rte_event_dequeue_burst(rxq->evdev,
  34                                                        rxq->ev_ports, &ev,
  35                                                        1, 0);
  36                if (!valid_event)
  37                        break;
  38                rx_pkts[count++] = ev.mbuf;
  39        }
  40
  41        return count; /* return number of pkts received */
  42}
  43
  44#define T(name, f3, f2, f1, f0, sz, flags)                              \
  45static uint16_t __rte_noinline  __rte_hot                               \
  46octeontx_xmit_pkts_ ##name(void *tx_queue,                              \
  47                        struct rte_mbuf **tx_pkts, uint16_t pkts)       \
  48{                                                                       \
  49        uint64_t cmd[(sz)];                                             \
  50                                                                        \
  51        return __octeontx_xmit_pkts(tx_queue, tx_pkts, pkts, cmd,       \
  52                                    flags);                             \
  53}
  54
  55OCCTX_TX_FASTPATH_MODES
  56#undef T
  57
  58void __rte_hot
  59octeontx_set_tx_function(struct rte_eth_dev *dev)
  60{
  61        struct octeontx_nic *nic = octeontx_pmd_priv(dev);
  62
  63        const eth_tx_burst_t tx_burst_func[2][2][2][2] = {
  64#define T(name, f3, f2, f1, f0, sz, flags)                      \
  65        [f3][f2][f1][f0] =  octeontx_xmit_pkts_ ##name,
  66
  67OCCTX_TX_FASTPATH_MODES
  68#undef T
  69        };
  70
  71        dev->tx_pkt_burst = tx_burst_func
  72                [!!(nic->tx_offload_flags & OCCTX_TX_OFFLOAD_MBUF_NOFF_F)]
  73                [!!(nic->tx_offload_flags & OCCTX_TX_OFFLOAD_OL3_OL4_CSUM_F)]
  74                [!!(nic->tx_offload_flags & OCCTX_TX_OFFLOAD_L3_L4_CSUM_F)]
  75                [!!(nic->tx_offload_flags & OCCTX_TX_MULTI_SEG_F)];
  76}
  77