Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
3 : : */
4 : :
5 : : #include <ethdev_driver.h>
6 : : #include <rte_net.h>
7 : : #include <rte_vect.h>
8 : : #include <rte_malloc.h>
9 : : #include <rte_memzone.h>
10 : :
11 : : #include "sxe2_ethdev.h"
12 : : #include "sxe2_queue.h"
13 : : #include "sxe2_rx.h"
14 : : #include "sxe2_cmd_chnl.h"
15 : :
16 : : #include "sxe2_osal.h"
17 : : #include "sxe2_common_log.h"
18 : :
19 : 0 : static void *sxe2_rx_doorbell_tail_addr_get(struct sxe2_adapter *adapter, uint16_t queue_id)
20 : : {
21 : 0 : return sxe2_pci_map_addr_get(adapter, SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL,
22 : : queue_id);
23 : : }
24 : :
25 : 0 : static void sxe2_rx_head_tail_init(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq)
26 : : {
27 : 0 : rxq->rdt_reg_addr = sxe2_rx_doorbell_tail_addr_get(adapter, rxq->queue_id);
28 : 0 : SXE2_PCI_REG_WRITE_WC(rxq->rdt_reg_addr, 0);
29 : 0 : }
30 : :
31 : 0 : static void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq)
32 : : {
33 : 0 : uint16_t i = 0;
34 : 0 : uint16_t len = 0;
35 : 0 : static const union sxe2_rx_desc zeroed_desc = {{0}};
36 : :
37 : 0 : len = rxq->ring_depth + SXE2_RX_PKTS_BURST_BATCH_NUM;
38 [ # # ]: 0 : for (i = 0; i < len; ++i)
39 : 0 : rxq->desc_ring[i] = zeroed_desc;
40 : :
41 : 0 : memset(&rxq->fake_mbuf, 0, sizeof(rxq->fake_mbuf));
42 [ # # ]: 0 : for (i = rxq->ring_depth; i < len; i++)
43 : 0 : rxq->buffer_ring[i] = &rxq->fake_mbuf;
44 : :
45 : 0 : rxq->hold_num = 0;
46 : 0 : rxq->next_ret_pkt = 0;
47 : 0 : rxq->processing_idx = 0;
48 : 0 : rxq->completed_pkts_num = 0;
49 : 0 : rxq->batch_alloc_trigger = rxq->rx_free_thresh - 1;
50 : :
51 : 0 : rxq->pkt_first_seg = NULL;
52 : 0 : rxq->pkt_last_seg = NULL;
53 : :
54 : 0 : rxq->realloc_num = 0;
55 : 0 : rxq->realloc_start = 0;
56 : 0 : }
57 : :
58 : 0 : void __rte_cold sxe2_rx_queue_mbufs_release(struct sxe2_rx_queue *rxq)
59 : : {
60 : 0 : uint16_t i;
61 : :
62 [ # # ]: 0 : if (rxq->buffer_ring != NULL) {
63 [ # # ]: 0 : for (i = 0; i < rxq->ring_depth; i++) {
64 [ # # ]: 0 : if (rxq->buffer_ring[i] != NULL) {
65 : 0 : rte_pktmbuf_free(rxq->buffer_ring[i]);
66 : 0 : rxq->buffer_ring[i] = NULL;
67 : : }
68 : : }
69 : : }
70 : :
71 [ # # ]: 0 : if (rxq->completed_pkts_num) {
72 [ # # ]: 0 : for (i = 0; i < rxq->completed_pkts_num; ++i) {
73 [ # # ]: 0 : if (rxq->completed_buf[rxq->next_ret_pkt + i] != NULL) {
74 : 0 : rte_pktmbuf_free(rxq->completed_buf[rxq->next_ret_pkt + i]);
75 : 0 : rxq->completed_buf[rxq->next_ret_pkt + i] = NULL;
76 : : }
77 : : }
78 : 0 : rxq->completed_pkts_num = 0;
79 : : }
80 : 0 : }
81 : :
82 : : const struct sxe2_rxq_ops sxe2_default_rxq_ops = {
83 : : .queue_reset = sxe2_rx_queue_reset,
84 : : .mbufs_release = sxe2_rx_queue_mbufs_release,
85 : : };
86 : :
87 : 0 : static struct sxe2_rxq_ops sxe2_rx_default_ops_get(void)
88 : : {
89 : 0 : return sxe2_default_rxq_ops;
90 : : }
91 : :
92 : 0 : void __rte_cold sxe2_rx_queue_info_get(struct rte_eth_dev *dev,
93 : : uint16_t queue_id, struct rte_eth_rxq_info *qinfo)
94 : : {
95 : 0 : struct sxe2_rx_queue *rxq = NULL;
96 : :
97 [ # # ]: 0 : if (queue_id >= dev->data->nb_rx_queues) {
98 : 0 : PMD_LOG_ERR(RX, "rx queue:%u is out of range:%u",
99 : : queue_id, dev->data->nb_rx_queues);
100 : 0 : goto end;
101 : : }
102 : :
103 : 0 : rxq = dev->data->rx_queues[queue_id];
104 [ # # ]: 0 : if (rxq == NULL) {
105 : 0 : PMD_LOG_ERR(RX, "rx queue:%u is NULL", queue_id);
106 : 0 : goto end;
107 : : }
108 : :
109 : 0 : qinfo->mp = rxq->mb_pool;
110 : 0 : qinfo->nb_desc = rxq->ring_depth;
111 : 0 : qinfo->scattered_rx = dev->data->scattered_rx;
112 : 0 : qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
113 : 0 : qinfo->conf.rx_drop_en = rxq->drop_en;
114 : 0 : qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
115 : :
116 : 0 : end:
117 : 0 : return;
118 : : }
119 : :
120 : 0 : int32_t __rte_cold sxe2_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
121 : : {
122 : 0 : struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
123 : 0 : struct sxe2_rx_queue *rxq;
124 : 0 : int32_t ret;
125 : 0 : PMD_INIT_FUNC_TRACE();
126 : :
127 [ # # ]: 0 : if (dev->data->rx_queue_state[rx_queue_id] ==
128 : : RTE_ETH_QUEUE_STATE_STOPPED) {
129 : 0 : ret = 0;
130 : 0 : goto l_end;
131 : : }
132 : :
133 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
134 [ # # ]: 0 : if (rxq == NULL) {
135 : 0 : ret = 0;
136 : 0 : goto l_end;
137 : : }
138 : 0 : ret = sxe2_drv_rxq_switch(adapter, rxq, false);
139 [ # # ]: 0 : if (ret) {
140 : 0 : PMD_LOG_ERR(RX, "Failed to switch rx queue %u off, ret = %d",
141 : : rx_queue_id, ret);
142 [ # # ]: 0 : if (ret == -EPERM)
143 : 0 : goto l_free;
144 : 0 : goto l_end;
145 : : }
146 : :
147 : 0 : l_free:
148 : 0 : rxq->ops.mbufs_release(rxq);
149 : 0 : rxq->ops.queue_reset(rxq);
150 : 0 : dev->data->rx_queue_state[rx_queue_id] =
151 : : RTE_ETH_QUEUE_STATE_STOPPED;
152 : 0 : l_end:
153 : 0 : return ret;
154 : : }
155 : :
156 : 0 : static void __rte_cold sxe2_rx_queue_free(struct sxe2_rx_queue *rxq)
157 : : {
158 [ # # ]: 0 : if (rxq != NULL) {
159 : 0 : rxq->ops.mbufs_release(rxq);
160 [ # # ]: 0 : if (rxq->buffer_ring != NULL) {
161 : 0 : rte_free(rxq->buffer_ring);
162 : 0 : rxq->buffer_ring = NULL;
163 : : }
164 : 0 : rte_memzone_free(rxq->mz);
165 : 0 : rte_free(rxq);
166 : : }
167 : 0 : }
168 : :
169 : 0 : void __rte_cold sxe2_rx_queue_release(struct rte_eth_dev *dev,
170 : : uint16_t queue_idx)
171 : : {
172 : 0 : (void)sxe2_rx_queue_stop(dev, queue_idx);
173 : 0 : sxe2_rx_queue_free(dev->data->rx_queues[queue_idx]);
174 : 0 : dev->data->rx_queues[queue_idx] = NULL;
175 : 0 : }
176 : :
177 : 0 : void __rte_cold sxe2_all_rxqs_release(struct rte_eth_dev *dev)
178 : : {
179 : 0 : struct rte_eth_dev_data *data = dev->data;
180 : 0 : uint16_t nb_rxq;
181 : :
182 [ # # ]: 0 : for (nb_rxq = 0; nb_rxq < data->nb_rx_queues; nb_rxq++) {
183 [ # # ]: 0 : if (data->rx_queues[nb_rxq] == NULL)
184 : 0 : continue;
185 : 0 : sxe2_rx_queue_release(dev, nb_rxq);
186 : 0 : data->rx_queues[nb_rxq] = NULL;
187 : : }
188 : 0 : data->nb_rx_queues = 0;
189 : 0 : }
190 : :
191 : 0 : static struct sxe2_rx_queue *sxe2_rx_queue_alloc(struct rte_eth_dev *dev, uint16_t queue_idx,
192 : : uint16_t ring_depth, uint32_t socket_id)
193 : : {
194 : 0 : struct sxe2_rx_queue *rxq;
195 : 0 : const struct rte_memzone *tz;
196 : 0 : uint16_t len;
197 : :
198 [ # # ]: 0 : if (dev->data->rx_queues[queue_idx] != NULL) {
199 : 0 : sxe2_rx_queue_release(dev, queue_idx);
200 : 0 : dev->data->rx_queues[queue_idx] = NULL;
201 : : }
202 : :
203 : 0 : rxq = rte_zmalloc_socket("rx_queue", sizeof(*rxq),
204 : : RTE_CACHE_LINE_SIZE, socket_id);
205 : :
206 [ # # ]: 0 : if (rxq == NULL) {
207 : 0 : PMD_LOG_ERR(RX, "rx queue[%d] alloc failed", queue_idx);
208 : 0 : goto l_end;
209 : : }
210 : :
211 : 0 : rxq->ring_depth = ring_depth;
212 : 0 : len = rxq->ring_depth + SXE2_RX_PKTS_BURST_BATCH_NUM;
213 : :
214 : 0 : rxq->buffer_ring = rte_zmalloc_socket("rx_buffer_ring",
215 : : sizeof(struct rte_mbuf *) * len,
216 : : RTE_CACHE_LINE_SIZE, socket_id);
217 : :
218 [ # # ]: 0 : if (!rxq->buffer_ring) {
219 : 0 : PMD_LOG_ERR(RX, "Rxq malloc mbuf mem failed");
220 : 0 : rte_free(rxq);
221 : 0 : rxq = NULL;
222 : 0 : goto l_end;
223 : : }
224 : :
225 : 0 : tz = rte_eth_dma_zone_reserve(dev, "rx_dma", queue_idx,
226 : : SXE2_RX_RING_SIZE, SXE2_DESC_ADDR_ALIGN, socket_id);
227 [ # # ]: 0 : if (tz == NULL) {
228 : 0 : PMD_LOG_ERR(RX, "Rxq malloc desc mem failed");
229 : 0 : rte_free(rxq->buffer_ring);
230 : 0 : rxq->buffer_ring = NULL;
231 : 0 : rte_free(rxq);
232 : 0 : rxq = NULL;
233 : 0 : goto l_end;
234 : : }
235 : :
236 : 0 : rxq->mz = tz;
237 : 0 : memset(tz->addr, 0, SXE2_RX_RING_SIZE);
238 : 0 : rxq->base_addr = tz->iova;
239 : 0 : rxq->desc_ring = (union sxe2_rx_desc *)tz->addr;
240 : :
241 : 0 : l_end:
242 : 0 : return rxq;
243 : : }
244 : :
245 : 0 : int32_t __rte_cold sxe2_rx_queue_setup(struct rte_eth_dev *dev,
246 : : uint16_t queue_idx, uint16_t nb_desc, uint32_t socket_id,
247 : : const struct rte_eth_rxconf *rx_conf,
248 : : struct rte_mempool *mp)
249 : : {
250 : 0 : struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
251 : 0 : struct sxe2_vsi *vsi = adapter->vsi_ctxt.main_vsi;
252 : 0 : struct sxe2_rx_queue *rxq;
253 : 0 : uint64_t offloads;
254 : 0 : int32_t ret;
255 : 0 : uint16_t rx_nseg;
256 : 0 : uint16_t i;
257 : :
258 : 0 : PMD_INIT_FUNC_TRACE();
259 : :
260 : 0 : if (nb_desc % SXE2_RX_DESC_RING_ALIGN != 0 ||
261 [ # # ]: 0 : nb_desc > SXE2_MAX_RING_DESC ||
262 : : nb_desc < SXE2_MIN_RING_DESC) {
263 : 0 : PMD_LOG_ERR(RX, "param desc num:%u is invalid", nb_desc);
264 : 0 : ret = -EINVAL;
265 : 0 : goto l_end;
266 : : }
267 : :
268 [ # # ]: 0 : if (mp != NULL)
269 : : rx_nseg = 1;
270 : : else
271 : 0 : rx_nseg = rx_conf->rx_nseg;
272 : :
273 : 0 : offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
274 : :
275 [ # # # # ]: 0 : if (rx_nseg > 1 && !(offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
276 : 0 : PMD_LOG_ERR(RX, "Port %u queue %u Buffer split offload not configured, but rx_nseg is %u",
277 : : dev->data->port_id, queue_idx, rx_nseg);
278 : 0 : ret = -EINVAL;
279 : 0 : goto l_end;
280 : : }
281 : :
282 [ # # # # ]: 0 : if ((offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) && !(rx_nseg > 1)) {
283 : 0 : PMD_LOG_ERR(RX, "Port %u queue %u Buffer split offload configured, but rx_nseg is %u",
284 : : dev->data->port_id, queue_idx, rx_nseg);
285 : 0 : ret = -EINVAL;
286 : 0 : goto l_end;
287 : : }
288 : :
289 [ # # ]: 0 : if ((offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO) &&
290 : : (offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)) {
291 : 0 : PMD_LOG_ERR(RX, "port_id %u queue %u, LRO can't be configure with Keep crc.",
292 : : dev->data->port_id, queue_idx);
293 : 0 : ret = -EINVAL;
294 : 0 : goto l_end;
295 : : }
296 : :
297 : 0 : rxq = sxe2_rx_queue_alloc(dev, queue_idx, nb_desc, socket_id);
298 [ # # ]: 0 : if (rxq == NULL) {
299 : 0 : PMD_LOG_ERR(RX, "rx queue[%d] resource alloc failed", queue_idx);
300 : 0 : ret = -ENOMEM;
301 : 0 : goto l_end;
302 : : }
303 : :
304 [ # # ]: 0 : if (offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO)
305 : 0 : dev->data->lro = 1;
306 : :
307 [ # # ]: 0 : if (rx_nseg > 1) {
308 [ # # ]: 0 : for (i = 0; i < rx_nseg; i++) {
309 [ # # ]: 0 : rte_memcpy(&rxq->rx_seg[i], &rx_conf->rx_seg[i].split,
310 : : sizeof(struct rte_eth_rxseg_split));
311 : : }
312 : 0 : rxq->mb_pool = rxq->rx_seg[0].mp;
313 : : } else {
314 : 0 : rxq->mb_pool = mp;
315 : : }
316 : :
317 : 0 : rxq->rx_free_thresh = rx_conf->rx_free_thresh;
318 : 0 : rxq->port_id = dev->data->port_id;
319 : 0 : rxq->offloads = offloads;
320 [ # # ]: 0 : if (offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
321 : 0 : rxq->crc_len = RTE_ETHER_CRC_LEN;
322 : : else
323 : 0 : rxq->crc_len = 0;
324 : :
325 : 0 : rxq->queue_id = queue_idx;
326 : 0 : rxq->idx_in_func = vsi->rxqs.base_idx_in_func + queue_idx;
327 : 0 : rxq->drop_en = rx_conf->rx_drop_en;
328 : 0 : rxq->rx_deferred_start = rx_conf->rx_deferred_start;
329 : 0 : rxq->vsi = vsi;
330 : 0 : rxq->ops = sxe2_rx_default_ops_get();
331 : 0 : rxq->ops.queue_reset(rxq);
332 : 0 : dev->data->rx_queues[queue_idx] = rxq;
333 : :
334 : 0 : ret = 0;
335 : 0 : l_end:
336 : 0 : return ret;
337 : : }
338 : :
339 : 0 : static int32_t __rte_cold sxe2_rx_queue_mbufs_alloc(struct sxe2_rx_queue *rxq)
340 : : {
341 : 0 : struct rte_mbuf **buf_ring = rxq->buffer_ring;
342 : 0 : struct rte_mbuf *mbuf = NULL;
343 : 0 : struct rte_mbuf *mbuf_pay;
344 : 0 : volatile union sxe2_rx_desc *desc;
345 : 0 : uint64_t dma_addr;
346 : 0 : int32_t ret;
347 : 0 : uint16_t i, j;
348 : :
349 [ # # ]: 0 : for (i = 0; i < rxq->ring_depth; i++) {
350 : 0 : mbuf = rte_mbuf_raw_alloc(rxq->mb_pool);
351 [ # # ]: 0 : if (mbuf == NULL) {
352 : 0 : PMD_LOG_ERR(RX, "Rx queue is not available or setup");
353 : 0 : ret = -ENOMEM;
354 : 0 : goto l_err_free_mbuf;
355 : : }
356 : :
357 : 0 : buf_ring[i] = mbuf;
358 : 0 : mbuf->data_off = RTE_PKTMBUF_HEADROOM;
359 : 0 : mbuf->nb_segs = 1;
360 : 0 : mbuf->port = rxq->port_id;
361 : :
362 [ # # ]: 0 : dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
363 : 0 : desc = &rxq->desc_ring[i];
364 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
365 : 0 : mbuf->next = NULL;
366 : 0 : desc->read.hdr_addr = 0;
367 : 0 : desc->read.pkt_addr = dma_addr;
368 : : } else {
369 : 0 : mbuf_pay = rte_mbuf_raw_alloc(rxq->rx_seg[1].mp);
370 [ # # ]: 0 : if (unlikely(!mbuf_pay)) {
371 : 0 : PMD_LOG_ERR(RX, "Failed to allocate payload mbuf for RX");
372 : 0 : ret = -ENOMEM;
373 : 0 : goto l_err_free_mbuf;
374 : : }
375 : :
376 : 0 : mbuf_pay->next = NULL;
377 : 0 : mbuf_pay->data_off = RTE_PKTMBUF_HEADROOM;
378 : 0 : mbuf_pay->nb_segs = 1;
379 : 0 : mbuf_pay->port = rxq->port_id;
380 : 0 : mbuf->next = mbuf_pay;
381 : :
382 : 0 : desc->read.hdr_addr = dma_addr;
383 : 0 : desc->read.pkt_addr =
384 : 0 : rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf_pay));
385 : : }
386 : :
387 : : #ifndef RTE_LIBRTE_SXE2_16BYTE_RX_DESC
388 : 0 : desc->read.rsvd1 = 0;
389 : 0 : desc->read.rsvd2 = 0;
390 : : #endif
391 : : }
392 : :
393 : 0 : ret = 0;
394 : 0 : goto l_end;
395 : :
396 : 0 : l_err_free_mbuf:
397 [ # # ]: 0 : for (j = 0; j <= i; j++) {
398 [ # # # # ]: 0 : if (buf_ring[j] != NULL && buf_ring[j]->next != NULL) {
399 : 0 : rte_pktmbuf_free(buf_ring[j]->next);
400 : 0 : buf_ring[j]->next = NULL;
401 : : }
402 : :
403 [ # # ]: 0 : if (buf_ring[j] != NULL) {
404 : 0 : rte_pktmbuf_free(buf_ring[j]);
405 : 0 : buf_ring[j] = NULL;
406 : : }
407 : : }
408 : :
409 : 0 : l_end:
410 : 0 : return ret;
411 : : }
412 : :
413 : 0 : int32_t __rte_cold sxe2_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
414 : : {
415 : 0 : struct sxe2_rx_queue *rxq;
416 : 0 : struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
417 : 0 : int32_t ret;
418 : 0 : PMD_INIT_FUNC_TRACE();
419 : :
420 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
421 [ # # ]: 0 : if (rxq == NULL) {
422 : 0 : PMD_LOG_ERR(RX, "Rx queue %u is not available or setup",
423 : : rx_queue_id);
424 : 0 : ret = -EINVAL;
425 : 0 : goto l_end;
426 : : }
427 : :
428 [ # # ]: 0 : if (dev->data->rx_queue_state[rx_queue_id] ==
429 : : RTE_ETH_QUEUE_STATE_STARTED) {
430 : 0 : ret = 0;
431 : 0 : goto l_end;
432 : : }
433 : :
434 : 0 : ret = sxe2_rx_queue_mbufs_alloc(rxq);
435 [ # # ]: 0 : if (ret) {
436 : 0 : PMD_LOG_ERR(RX, "Rx queue %u apply desc ring fail",
437 : : rx_queue_id);
438 : 0 : ret = -ENOMEM;
439 : 0 : goto l_end;
440 : : }
441 : :
442 : 0 : sxe2_rx_head_tail_init(adapter, rxq);
443 : :
444 : 0 : ret = sxe2_drv_rxq_ctxt_cfg(adapter, rxq, 1);
445 [ # # ]: 0 : if (ret) {
446 : 0 : PMD_LOG_ERR(RX, "Rx queue %u config ctxt fail, ret=%d",
447 : : rx_queue_id, ret);
448 : :
449 : 0 : (void)sxe2_drv_rxq_switch(adapter, rxq, false);
450 : 0 : rxq->ops.mbufs_release(rxq);
451 : 0 : rxq->ops.queue_reset(rxq);
452 : 0 : goto l_end;
453 : : }
454 : :
455 : 0 : SXE2_PCI_REG_WRITE_WC(rxq->rdt_reg_addr, rxq->ring_depth - 1);
456 : 0 : dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
457 : :
458 : 0 : l_end:
459 : 0 : return ret;
460 : : }
461 : :
462 : 0 : int32_t __rte_cold sxe2_rxqs_all_start(struct rte_eth_dev *dev)
463 : : {
464 : 0 : struct rte_eth_dev_data *data = dev->data;
465 : 0 : struct sxe2_rx_queue *rxq;
466 : 0 : uint16_t nb_rxq;
467 : 0 : uint16_t nb_started_rxq;
468 : 0 : int32_t ret;
469 : 0 : PMD_INIT_FUNC_TRACE();
470 : :
471 [ # # ]: 0 : for (nb_rxq = 0; nb_rxq < data->nb_rx_queues; nb_rxq++) {
472 : 0 : rxq = dev->data->rx_queues[nb_rxq];
473 [ # # # # ]: 0 : if (!rxq || rxq->rx_deferred_start)
474 : 0 : continue;
475 : :
476 : 0 : ret = sxe2_rx_queue_start(dev, nb_rxq);
477 [ # # ]: 0 : if (ret) {
478 : 0 : PMD_LOG_ERR(RX, "Fail to start rx queue %u", nb_rxq);
479 : 0 : goto l_free_started_queue;
480 : : }
481 : :
482 : 0 : rte_atomic_store_explicit(&rxq->sw_stats.pkts, 0,
483 : : rte_memory_order_relaxed);
484 : 0 : rte_atomic_store_explicit(&rxq->sw_stats.bytes, 0,
485 : : rte_memory_order_relaxed);
486 : 0 : rte_atomic_store_explicit(&rxq->sw_stats.drop_pkts, 0,
487 : : rte_memory_order_relaxed);
488 : 0 : rte_atomic_store_explicit(&rxq->sw_stats.drop_bytes, 0,
489 : : rte_memory_order_relaxed);
490 : 0 : rte_atomic_store_explicit(&rxq->sw_stats.unicast_pkts, 0,
491 : : rte_memory_order_relaxed);
492 : 0 : rte_atomic_store_explicit(&rxq->sw_stats.broadcast_pkts, 0,
493 : : rte_memory_order_relaxed);
494 : 0 : rte_atomic_store_explicit(&rxq->sw_stats.multicast_pkts, 0,
495 : : rte_memory_order_relaxed);
496 : : }
497 : 0 : ret = 0;
498 : 0 : goto l_end;
499 : :
500 : 0 : l_free_started_queue:
501 [ # # ]: 0 : for (nb_started_rxq = 0; nb_started_rxq <= nb_rxq; nb_started_rxq++)
502 : 0 : (void)sxe2_rx_queue_stop(dev, nb_started_rxq);
503 : 0 : l_end:
504 : 0 : return ret;
505 : : }
506 : :
507 : 0 : void __rte_cold sxe2_rxqs_all_stop(struct rte_eth_dev *dev)
508 : : {
509 : 0 : struct rte_eth_dev_data *data = dev->data;
510 : 0 : struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
511 : 0 : struct sxe2_vsi *vsi = adapter->vsi_ctxt.main_vsi;
512 : 0 : struct sxe2_stats *sw_stats_prev = &vsi->vsi_stats.vsi_sw_stats_prev;
513 : 0 : struct sxe2_rx_queue *rxq = NULL;
514 : 0 : int32_t ret;
515 : 0 : uint16_t nb_rxq;
516 : 0 : PMD_INIT_FUNC_TRACE();
517 : :
518 [ # # ]: 0 : for (nb_rxq = 0; nb_rxq < data->nb_rx_queues; nb_rxq++) {
519 : 0 : ret = sxe2_rx_queue_stop(dev, nb_rxq);
520 [ # # ]: 0 : if (ret) {
521 : 0 : PMD_LOG_ERR(RX, "Fail to stop rx queue %u", nb_rxq);
522 : 0 : continue;
523 : : }
524 : :
525 : 0 : rxq = dev->data->rx_queues[nb_rxq];
526 [ # # ]: 0 : if (rxq) {
527 : 0 : sw_stats_prev->ipackets +=
528 : 0 : rte_atomic_load_explicit(&rxq->sw_stats.pkts,
529 : : rte_memory_order_relaxed);
530 : 0 : sw_stats_prev->ierrors +=
531 : 0 : rte_atomic_load_explicit(&rxq->sw_stats.drop_pkts,
532 : : rte_memory_order_relaxed);
533 : 0 : sw_stats_prev->ibytes +=
534 : 0 : rte_atomic_load_explicit(&rxq->sw_stats.bytes,
535 : : rte_memory_order_relaxed);
536 : :
537 : 0 : sw_stats_prev->rx_sw_unicast_packets +=
538 : 0 : rte_atomic_load_explicit(&rxq->sw_stats.unicast_pkts,
539 : : rte_memory_order_relaxed);
540 : 0 : sw_stats_prev->rx_sw_broadcast_packets +=
541 : 0 : rte_atomic_load_explicit(&rxq->sw_stats.broadcast_pkts,
542 : : rte_memory_order_relaxed);
543 : 0 : sw_stats_prev->rx_sw_multicast_packets +=
544 : 0 : rte_atomic_load_explicit(&rxq->sw_stats.multicast_pkts,
545 : : rte_memory_order_relaxed);
546 : 0 : sw_stats_prev->rx_sw_drop_packets +=
547 : 0 : rte_atomic_load_explicit(&rxq->sw_stats.drop_pkts,
548 : : rte_memory_order_relaxed);
549 : 0 : sw_stats_prev->rx_sw_drop_bytes +=
550 : 0 : rte_atomic_load_explicit(&rxq->sw_stats.drop_bytes,
551 : : rte_memory_order_relaxed);
552 : : }
553 : : }
554 : 0 : }
|