1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Cesnet
3 * Copyright(c) 2019 Netcope Technologies, a.s. <info@netcope.com>
7 #include <rte_kvargs.h>
12 uint64_t nfb_timestamp_rx_dynflag;
13 int nfb_timestamp_dynfield_offset = -1;
16 timestamp_check_handler(__rte_unused const char *key,
17 const char *value, __rte_unused void *opaque)
19 if (strcmp(value, "1"))
27 nfb_check_timestamp(struct rte_devargs *devargs)
29 struct rte_kvargs *kvlist;
35 kvlist = rte_kvargs_parse(devargs->args, NULL);
39 if (!rte_kvargs_count(kvlist, TIMESTAMP_ARG)) {
40 rte_kvargs_free(kvlist);
43 /* Timestamps are enabled when there is
44 * key-value pair: enable_timestamp=1
45 * TODO: timestamp should be enabled with DEV_RX_OFFLOAD_TIMESTAMP
47 if (rte_kvargs_process(kvlist, TIMESTAMP_ARG,
48 timestamp_check_handler, NULL) < 0) {
49 rte_kvargs_free(kvlist);
52 rte_kvargs_free(kvlist);
54 ret = rte_mbuf_dyn_rx_timestamp_register(
55 &nfb_timestamp_dynfield_offset,
56 &nfb_timestamp_rx_dynflag);
58 RTE_LOG(ERR, PMD, "Cannot register Rx timestamp field/flag\n");
66 nfb_eth_rx_queue_start(struct rte_eth_dev *dev, uint16_t rxq_id)
68 struct ndp_rx_queue *rxq = dev->data->rx_queues[rxq_id];
71 if (rxq->queue == NULL) {
72 RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
76 ret = ndp_queue_start(rxq->queue);
79 dev->data->rx_queue_state[rxq_id] = RTE_ETH_QUEUE_STATE_STARTED;
87 nfb_eth_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rxq_id)
89 struct ndp_rx_queue *rxq = dev->data->rx_queues[rxq_id];
92 if (rxq->queue == NULL) {
93 RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
97 ret = ndp_queue_stop(rxq->queue);
101 dev->data->rx_queue_state[rxq_id] = RTE_ETH_QUEUE_STATE_STOPPED;
106 nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,
107 uint16_t rx_queue_id,
108 uint16_t nb_rx_desc __rte_unused,
109 unsigned int socket_id,
110 const struct rte_eth_rxconf *rx_conf __rte_unused,
111 struct rte_mempool *mb_pool)
113 struct pmd_internals *internals = dev->data->dev_private;
115 struct ndp_rx_queue *rxq;
118 rxq = rte_zmalloc_socket("ndp rx queue",
119 sizeof(struct ndp_rx_queue),
120 RTE_CACHE_LINE_SIZE, socket_id);
123 RTE_LOG(ERR, PMD, "rte_zmalloc_socket() failed for rx queue id "
124 "%" PRIu16 "!\n", rx_queue_id);
130 ret = nfb_eth_rx_queue_init(internals->nfb,
137 dev->data->rx_queues[rx_queue_id] = rxq;
141 if (nfb_check_timestamp(dev->device->devargs) > 0)
142 rxq->flags |= NFB_TIMESTAMP_FLAG;
148 nfb_eth_rx_queue_init(struct nfb_device *nfb,
149 uint16_t rx_queue_id,
151 struct rte_mempool *mb_pool,
152 struct ndp_rx_queue *rxq)
154 const struct rte_pktmbuf_pool_private *mbp_priv =
155 rte_mempool_get_priv(mb_pool);
160 rxq->queue = ndp_open_rx_queue(nfb, rx_queue_id);
161 if (rxq->queue == NULL)
165 rxq->rx_queue_id = rx_queue_id;
166 rxq->in_port = port_id;
167 rxq->mb_pool = mb_pool;
168 rxq->buf_size = (uint16_t)(mbp_priv->mbuf_data_room_size -
169 RTE_PKTMBUF_HEADROOM);
179 nfb_eth_rx_queue_release(void *q)
181 struct ndp_rx_queue *rxq = (struct ndp_rx_queue *)q;
182 if (rxq->queue != NULL) {
183 ndp_close_rx_queue(rxq->queue);