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>
13 timestamp_check_handler(__rte_unused const char *key,
14 const char *value, __rte_unused void *opaque)
16 if (strcmp(value, "1"))
24 nfb_check_timestamp(struct rte_devargs *devargs)
26 struct rte_kvargs *kvlist;
31 kvlist = rte_kvargs_parse(devargs->args, NULL);
35 if (!rte_kvargs_count(kvlist, TIMESTAMP_ARG)) {
36 rte_kvargs_free(kvlist);
39 /* Timestamps are enabled when there is
40 * key-value pair: enable_timestamp=1
42 if (rte_kvargs_process(kvlist, TIMESTAMP_ARG,
43 timestamp_check_handler, NULL) < 0) {
44 rte_kvargs_free(kvlist);
47 rte_kvargs_free(kvlist);
53 nfb_eth_rx_queue_start(struct rte_eth_dev *dev, uint16_t rxq_id)
55 struct ndp_rx_queue *rxq = dev->data->rx_queues[rxq_id];
58 if (rxq->queue == NULL) {
59 RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
63 ret = ndp_queue_start(rxq->queue);
66 dev->data->rx_queue_state[rxq_id] = RTE_ETH_QUEUE_STATE_STARTED;
74 nfb_eth_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rxq_id)
76 struct ndp_rx_queue *rxq = dev->data->rx_queues[rxq_id];
79 if (rxq->queue == NULL) {
80 RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
84 ret = ndp_queue_stop(rxq->queue);
88 dev->data->rx_queue_state[rxq_id] = RTE_ETH_QUEUE_STATE_STOPPED;
93 nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,
95 uint16_t nb_rx_desc __rte_unused,
96 unsigned int socket_id,
97 const struct rte_eth_rxconf *rx_conf __rte_unused,
98 struct rte_mempool *mb_pool)
100 struct pmd_internals *internals = dev->data->dev_private;
102 struct ndp_rx_queue *rxq;
105 rxq = rte_zmalloc_socket("ndp rx queue",
106 sizeof(struct ndp_rx_queue),
107 RTE_CACHE_LINE_SIZE, socket_id);
110 RTE_LOG(ERR, PMD, "rte_zmalloc_socket() failed for rx queue id "
111 "%" PRIu16 "!\n", rx_queue_id);
117 ret = nfb_eth_rx_queue_init(internals->nfb,
124 dev->data->rx_queues[rx_queue_id] = rxq;
128 if (nfb_check_timestamp(dev->device->devargs))
129 rxq->flags |= NFB_TIMESTAMP_FLAG;
135 nfb_eth_rx_queue_init(struct nfb_device *nfb,
136 uint16_t rx_queue_id,
138 struct rte_mempool *mb_pool,
139 struct ndp_rx_queue *rxq)
141 const struct rte_pktmbuf_pool_private *mbp_priv =
142 rte_mempool_get_priv(mb_pool);
147 rxq->queue = ndp_open_rx_queue(nfb, rx_queue_id);
148 if (rxq->queue == NULL)
152 rxq->rx_queue_id = rx_queue_id;
153 rxq->in_port = port_id;
154 rxq->mb_pool = mb_pool;
155 rxq->buf_size = (uint16_t)(mbp_priv->mbuf_data_room_size -
156 RTE_PKTMBUF_HEADROOM);
166 nfb_eth_rx_queue_release(void *q)
168 struct ndp_rx_queue *rxq = (struct ndp_rx_queue *)q;
169 if (rxq->queue != NULL) {
170 ndp_close_rx_queue(rxq->queue);