1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2019 Cesnet
* Copyright(c) 2019 Netcope Technologies, a.s. <info@netcope.com>
* All rights reserved.
*/
#include "nfb_rx.h"
#include "nfb.h"
int
nfb_eth_rx_queue_start(struct rte_eth_dev *dev, uint16_t rxq_id)
{
struct ndp_rx_queue *rxq = dev->data->rx_queues[rxq_id];
int ret;
if (rxq->queue == NULL) {
RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
return -EINVAL;
}
ret = ndp_queue_start(rxq->queue);
if (ret != 0)
goto err;
dev->data->rx_queue_state[rxq_id] = RTE_ETH_QUEUE_STATE_STARTED;
return 0;
err:
return -EINVAL;
}
int
nfb_eth_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rxq_id)
{
struct ndp_rx_queue *rxq = dev->data->rx_queues[rxq_id];
int ret;
if (rxq->queue == NULL) {
RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
return -EINVAL;
}
ret = ndp_queue_stop(rxq->queue);
if (ret != 0)
return -EINVAL;
dev->data->rx_queue_state[rxq_id] = RTE_ETH_QUEUE_STATE_STOPPED;
return 0;
}
int
nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,
uint16_t rx_queue_id,
uint16_t nb_rx_desc __rte_unused,
unsigned int socket_id,
const struct rte_eth_rxconf *rx_conf __rte_unused,
struct rte_mempool *mb_pool)
{
struct pmd_internals *internals = dev->data->dev_private;
struct ndp_rx_queue *rxq;
int ret;
rxq = rte_zmalloc_socket("ndp rx queue",
sizeof(struct ndp_rx_queue),
RTE_CACHE_LINE_SIZE, socket_id);
if (rxq == NULL) {
RTE_LOG(ERR, PMD, "rte_zmalloc_socket() failed for rx queue id "
"%" PRIu16 "!\n", rx_queue_id);
return -ENOMEM;
}
ret = nfb_eth_rx_queue_init(internals->nfb,
rx_queue_id,
dev->data->port_id,
mb_pool,
rxq);
if (ret == 0)
dev->data->rx_queues[rx_queue_id] = rxq;
else
rte_free(rxq);
return ret;
}
int
nfb_eth_rx_queue_init(struct nfb_device *nfb,
uint16_t rx_queue_id,
uint16_t port_id,
struct rte_mempool *mb_pool,
struct ndp_rx_queue *rxq)
{
const struct rte_pktmbuf_pool_private *mbp_priv =
rte_mempool_get_priv(mb_pool);
if (nfb == NULL)
return -EINVAL;
rxq->queue = ndp_open_rx_queue(nfb, rx_queue_id);
if (rxq->queue == NULL)
return -EINVAL;
rxq->nfb = nfb;
rxq->rx_queue_id = rx_queue_id;
rxq->in_port = port_id;
rxq->mb_pool = mb_pool;
rxq->buf_size = (uint16_t)(mbp_priv->mbuf_data_room_size -
RTE_PKTMBUF_HEADROOM);
rxq->rx_pkts = 0;
rxq->rx_bytes = 0;
rxq->err_pkts = 0;
return 0;
}
void
nfb_eth_rx_queue_release(void *q)
{
struct ndp_rx_queue *rxq = (struct ndp_rx_queue *)q;
if (rxq->queue != NULL) {
ndp_close_rx_queue(rxq->queue);
rte_free(rxq);
rxq->queue = NULL;
}
}
|