Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : *
3 : : * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
4 : : * Copyright 2016-2024 NXP
5 : : *
6 : : */
7 : :
8 : : #include <time.h>
9 : : #include <net/if.h>
10 : :
11 : : #include <eal_export.h>
12 : : #include <rte_mbuf.h>
13 : : #include <ethdev_driver.h>
14 : : #include <rte_malloc.h>
15 : : #include <rte_memcpy.h>
16 : : #include <rte_string_fns.h>
17 : : #include <dev_driver.h>
18 : : #include <rte_hexdump.h>
19 : :
20 : : #include <bus_fslmc_driver.h>
21 : : #include <fslmc_vfio.h>
22 : : #include <dpaa2_hw_pvt.h>
23 : : #include <dpaa2_hw_dpio.h>
24 : : #include <dpaa2_hw_mempool.h>
25 : :
26 : : #include "dpaa2_pmd_logs.h"
27 : : #include "dpaa2_ethdev.h"
28 : : #include "base/dpaa2_hw_dpni_annot.h"
29 : : #include "dpaa2_parse_dump.h"
30 : :
31 : : static inline uint32_t __rte_hot
32 : : dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf,
33 : : struct dpaa2_annot_hdr *annotation);
34 : :
35 : : static void enable_tx_tstamp(struct qbman_fd *fd) __rte_unused;
36 : :
37 : : static inline rte_mbuf_timestamp_t *
38 : : dpaa2_timestamp_dynfield(struct rte_mbuf *mbuf)
39 : : {
40 : 0 : return RTE_MBUF_DYNFIELD(mbuf,
41 : : dpaa2_timestamp_dynfield_offset, rte_mbuf_timestamp_t *);
42 : : }
43 : :
44 : : #define DPAA2_MBUF_TO_CONTIG_FD(_mbuf, _fd, _bpid) do { \
45 : : DPAA2_SET_FD_ADDR(_fd, DPAA2_MBUF_VADDR_TO_IOVA(_mbuf)); \
46 : : DPAA2_SET_FD_LEN(_fd, _mbuf->data_len); \
47 : : DPAA2_SET_ONLY_FD_BPID(_fd, _bpid); \
48 : : DPAA2_SET_FD_OFFSET(_fd, _mbuf->data_off); \
49 : : DPAA2_SET_FD_FRC(_fd, 0); \
50 : : DPAA2_RESET_FD_CTRL(_fd); \
51 : : DPAA2_RESET_FD_FLC(_fd); \
52 : : } while (0)
53 : :
54 : : static inline void __rte_hot
55 : 0 : dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd,
56 : : void *hw_annot_addr)
57 : : {
58 : 0 : uint16_t frc = DPAA2_GET_FD_FRC_PARSE_SUM(fd);
59 : : struct dpaa2_annot_hdr *annotation =
60 : : (struct dpaa2_annot_hdr *)hw_annot_addr;
61 : : uint32_t flc_lo, tc, flow;
62 : :
63 [ # # ]: 0 : if (unlikely(dpaa2_print_parser_result))
64 : 0 : dpaa2_print_parse_result(annotation);
65 : :
66 : 0 : m->packet_type = RTE_PTYPE_UNKNOWN;
67 [ # # # # : 0 : switch (frc) {
# # # # #
# # # # #
# # # # #
# ]
68 : 0 : case DPAA2_PKT_TYPE_ETHER:
69 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER;
70 : 0 : break;
71 : 0 : case DPAA2_PKT_TYPE_IPV4:
72 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
73 : : RTE_PTYPE_L3_IPV4;
74 : 0 : break;
75 : 0 : case DPAA2_PKT_TYPE_IPV6:
76 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
77 : : RTE_PTYPE_L3_IPV6;
78 : 0 : break;
79 : 0 : case DPAA2_PKT_TYPE_IPV4_TCP:
80 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
81 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP;
82 : 0 : break;
83 : 0 : case DPAA2_PKT_TYPE_IPV6_TCP:
84 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
85 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP;
86 : 0 : break;
87 : 0 : case DPAA2_PKT_TYPE_IPV4_UDP:
88 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
89 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP;
90 : 0 : break;
91 : 0 : case DPAA2_PKT_TYPE_IPV6_UDP:
92 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
93 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP;
94 : 0 : break;
95 : 0 : case DPAA2_PKT_TYPE_IPV4_SCTP:
96 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
97 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_SCTP;
98 : 0 : break;
99 : 0 : case DPAA2_PKT_TYPE_IPV6_SCTP:
100 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
101 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_SCTP;
102 : 0 : break;
103 : 0 : case DPAA2_PKT_TYPE_IPV4_ICMP:
104 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
105 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_ICMP;
106 : 0 : break;
107 : 0 : case DPAA2_PKT_TYPE_IPV6_ICMP:
108 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
109 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_ICMP;
110 : 0 : break;
111 : 0 : case DPAA2_PKT_TYPE_IPV4_FRAG:
112 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
113 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_FRAG;
114 : 0 : break;
115 : 0 : case DPAA2_PKT_TYPE_IPV6_FRAG:
116 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
117 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_FRAG;
118 : 0 : break;
119 : 0 : case DPAA2_PKT_TYPE_IPV4_ESP:
120 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
121 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_ESP;
122 : 0 : break;
123 : 0 : case DPAA2_PKT_TYPE_IPV6_ESP:
124 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
125 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_ESP;
126 : 0 : break;
127 : 0 : case DPAA2_PKT_TYPE_IPV4_GTPU:
128 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
129 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP |
130 : : RTE_PTYPE_TUNNEL_GTPU;
131 : 0 : break;
132 : 0 : case DPAA2_PKT_TYPE_IPV6_GTPU:
133 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
134 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP |
135 : : RTE_PTYPE_TUNNEL_GTPU;
136 : 0 : break;
137 : 0 : case DPAA2_PKT_TYPE_IPV4_GTPC:
138 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
139 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP |
140 : : RTE_PTYPE_TUNNEL_GTPC;
141 : 0 : break;
142 : 0 : case DPAA2_PKT_TYPE_IPV6_GTPC:
143 : 0 : m->packet_type = RTE_PTYPE_L2_ETHER |
144 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP |
145 : : RTE_PTYPE_TUNNEL_GTPC;
146 : 0 : break;
147 : 0 : default:
148 : 0 : m->packet_type = dpaa2_dev_rx_parse_slow(m, annotation);
149 : : }
150 : 0 : flc_lo = fd->simple.flc_lo;
151 [ # # ]: 0 : if (flc_lo & (1 << DPAA2_FS_FLC_FS_MARK_OFFSET)) {
152 : 0 : tc = (flc_lo >> DPAA2_FS_FLC_TC_OFFSET) &
153 : : DPAA2_FS_FLC_TC_MASK;
154 : 0 : flow = flc_lo >> DPAA2_FS_FLC_FLOW_OFFSET;
155 : 0 : m->ol_flags |= RTE_MBUF_F_RX_FDIR;
156 : 0 : m->hash.fdir.hi = (tc << 16) | flow;
157 : : DPAA2_PMD_DP_DEBUG("FS frame received from TC[%d]->flow%d",
158 : : tc, flow);
159 : : } else {
160 : 0 : m->hash.rss = fd->simple.flc_hi;
161 : 0 : m->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
162 : : DPAA2_PMD_DP_DEBUG("Hash frame received with RSS(%08x)",
163 : : m->hash.rss);
164 : : }
165 : :
166 [ # # ]: 0 : if (dpaa2_enable_ts[m->port]) {
167 : 0 : *dpaa2_timestamp_dynfield(m) = annotation->word2;
168 : 0 : m->ol_flags |= dpaa2_timestamp_rx_dynflag;
169 : : DPAA2_PMD_DP_DEBUG("pkt timestamp:0x%" PRIx64 "",
170 : : *dpaa2_timestamp_dynfield(m));
171 : : }
172 : :
173 : : DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
174 : : "ol_flags =0x%" PRIx64 "",
175 : : frc, m->packet_type, m->ol_flags);
176 : 0 : }
177 : :
178 : : static inline uint32_t __rte_hot
179 : 0 : dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf,
180 : : struct dpaa2_annot_hdr *annotation)
181 : : {
182 : : uint32_t pkt_type = RTE_PTYPE_UNKNOWN;
183 : : uint16_t *vlan_tci;
184 : :
185 : : DPAA2_PMD_DP_DEBUG("(slow parse)annotation(3)=0x%" PRIx64 "\t"
186 : : "(4)=0x%" PRIx64 "\t",
187 : : annotation->word3, annotation->word4);
188 : :
189 : : #if defined(RTE_LIBRTE_IEEE1588)
190 : : if (BIT_ISSET_AT_POS(annotation->word1, DPAA2_ETH_FAS_PTP)) {
191 : : mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
192 : : mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_TMST;
193 : : }
194 : : #endif
195 : :
196 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word3, L2_VLAN_1_PRESENT)) {
197 : 0 : vlan_tci = rte_pktmbuf_mtod_offset(mbuf, uint16_t *,
198 : : (VLAN_TCI_OFFSET_1(annotation->word5) >> 16));
199 [ # # ]: 0 : mbuf->vlan_tci = rte_be_to_cpu_16(*vlan_tci);
200 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_VLAN;
201 : : pkt_type |= RTE_PTYPE_L2_ETHER_VLAN;
202 [ # # ]: 0 : } else if (BIT_ISSET_AT_POS(annotation->word3, L2_VLAN_N_PRESENT)) {
203 : 0 : vlan_tci = rte_pktmbuf_mtod_offset(mbuf, uint16_t *,
204 : : (VLAN_TCI_OFFSET_1(annotation->word5) >> 16));
205 [ # # ]: 0 : mbuf->vlan_tci = rte_be_to_cpu_16(*vlan_tci);
206 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_QINQ;
207 : : pkt_type |= RTE_PTYPE_L2_ETHER_QINQ;
208 : : }
209 : :
210 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word3, L2_ARP_PRESENT)) {
211 : 0 : pkt_type |= RTE_PTYPE_L2_ETHER_ARP;
212 : 0 : goto parse_done;
213 [ # # ]: 0 : } else if (BIT_ISSET_AT_POS(annotation->word3, L2_ETH_MAC_PRESENT)) {
214 : 0 : pkt_type |= RTE_PTYPE_L2_ETHER;
215 : : } else {
216 : 0 : goto parse_done;
217 : : }
218 : :
219 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word3, L2_MPLS_1_PRESENT |
220 : : L2_MPLS_N_PRESENT))
221 : 0 : pkt_type |= RTE_PTYPE_L2_ETHER_MPLS;
222 : :
223 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word4, L3_IPV4_1_PRESENT |
224 : : L3_IPV4_N_PRESENT)) {
225 : 0 : pkt_type |= RTE_PTYPE_L3_IPV4;
226 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word4, L3_IP_1_OPT_PRESENT |
227 : : L3_IP_N_OPT_PRESENT))
228 : 0 : pkt_type |= RTE_PTYPE_L3_IPV4_EXT;
229 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_IPSEC_ESP_PRESENT |
230 : : L3_PROTO_ESP_PRESENT))
231 : 0 : pkt_type |= RTE_PTYPE_TUNNEL_ESP;
232 : :
233 [ # # ]: 0 : } else if (BIT_ISSET_AT_POS(annotation->word4, L3_IPV6_1_PRESENT |
234 : : L3_IPV6_N_PRESENT)) {
235 : 0 : pkt_type |= RTE_PTYPE_L3_IPV6;
236 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word4, L3_IP_1_OPT_PRESENT |
237 : : L3_IP_N_OPT_PRESENT))
238 : 0 : pkt_type |= RTE_PTYPE_L3_IPV6_EXT;
239 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_IPSEC_ESP_PRESENT |
240 : : L3_PROTO_ESP_PRESENT))
241 : 0 : pkt_type |= RTE_PTYPE_TUNNEL_ESP;
242 : : } else {
243 : 0 : goto parse_done;
244 : : }
245 : :
246 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word1, DPAA2_ETH_FAS_L3CE))
247 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
248 [ # # ]: 0 : else if (BIT_ISSET_AT_POS(annotation->word1, DPAA2_ETH_FAS_L3CV))
249 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
250 : :
251 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word1, DPAA2_ETH_FAS_L4CE))
252 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
253 [ # # ]: 0 : else if (BIT_ISSET_AT_POS(annotation->word1, DPAA2_ETH_FAS_L4CV))
254 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
255 : :
256 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word4, L3_IP_1_FIRST_FRAGMENT |
257 : : L3_IP_1_MORE_FRAGMENT |
258 : : L3_IP_N_FIRST_FRAGMENT |
259 : : L3_IP_N_MORE_FRAGMENT)) {
260 : 0 : pkt_type |= RTE_PTYPE_L4_FRAG;
261 : 0 : goto parse_done;
262 : : }
263 : :
264 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_UDP_PRESENT))
265 : 0 : pkt_type |= RTE_PTYPE_L4_UDP;
266 [ # # ]: 0 : else if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_TCP_PRESENT))
267 : 0 : pkt_type |= RTE_PTYPE_L4_TCP;
268 [ # # ]: 0 : else if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_SCTP_PRESENT))
269 : 0 : pkt_type |= RTE_PTYPE_L4_SCTP;
270 [ # # ]: 0 : else if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_ICMP_PRESENT))
271 : 0 : pkt_type |= RTE_PTYPE_L4_ICMP;
272 : : else
273 : 0 : pkt_type |= RTE_PTYPE_L4_NONFRAG;
274 : :
275 : 0 : parse_done:
276 : 0 : return pkt_type;
277 : : }
278 : :
279 : : static inline uint32_t __rte_hot
280 : 0 : dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)
281 : : {
282 : : struct dpaa2_annot_hdr *annotation =
283 : : (struct dpaa2_annot_hdr *)hw_annot_addr;
284 : :
285 : : DPAA2_PMD_DP_DEBUG("(fast parse) Annotation = 0x%" PRIx64 "\t",
286 : : annotation->word4);
287 : :
288 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word1, DPAA2_ETH_FAS_L3CE))
289 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
290 [ # # ]: 0 : else if (BIT_ISSET_AT_POS(annotation->word1, DPAA2_ETH_FAS_L3CV))
291 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
292 : :
293 [ # # ]: 0 : if (BIT_ISSET_AT_POS(annotation->word1, DPAA2_ETH_FAS_L4CE))
294 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
295 [ # # ]: 0 : else if (BIT_ISSET_AT_POS(annotation->word1, DPAA2_ETH_FAS_L4CV))
296 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
297 : :
298 [ # # ]: 0 : if (unlikely(dpaa2_print_parser_result))
299 : 0 : dpaa2_print_parse_result(annotation);
300 : :
301 [ # # ]: 0 : if (dpaa2_enable_ts[mbuf->port]) {
302 : 0 : *dpaa2_timestamp_dynfield(mbuf) = annotation->word2;
303 : 0 : mbuf->ol_flags |= dpaa2_timestamp_rx_dynflag;
304 : : DPAA2_PMD_DP_DEBUG("pkt timestamp: 0x%" PRIx64 "",
305 : : *dpaa2_timestamp_dynfield(mbuf));
306 : : }
307 : :
308 : : /* Check detailed parsing requirement */
309 [ # # ]: 0 : if (annotation->word3 & 0x7FFFFC3FFFF)
310 : 0 : return dpaa2_dev_rx_parse_slow(mbuf, annotation);
311 : :
312 : : /* Return some common types from parse processing */
313 [ # # # # : 0 : switch (annotation->word4) {
# # # ]
314 : : case DPAA2_L3_IPv4:
315 : : return RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4;
316 : 0 : case DPAA2_L3_IPv6:
317 : 0 : return RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6;
318 : 0 : case DPAA2_L3_IPv4_TCP:
319 : 0 : return RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 |
320 : : RTE_PTYPE_L4_TCP;
321 : 0 : case DPAA2_L3_IPv4_UDP:
322 : 0 : return RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 |
323 : : RTE_PTYPE_L4_UDP;
324 : 0 : case DPAA2_L3_IPv6_TCP:
325 : 0 : return RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 |
326 : : RTE_PTYPE_L4_TCP;
327 : 0 : case DPAA2_L3_IPv6_UDP:
328 : 0 : return RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 |
329 : : RTE_PTYPE_L4_UDP;
330 : : default:
331 : : break;
332 : : }
333 : :
334 : 0 : return dpaa2_dev_rx_parse_slow(mbuf, annotation);
335 : : }
336 : :
337 : : static inline struct rte_mbuf *__rte_hot
338 : 0 : eth_sg_fd_to_mbuf(const struct qbman_fd *fd,
339 : : int port_id)
340 : : {
341 : : struct qbman_sge *sgt, *sge;
342 : : size_t sg_addr, fd_addr;
343 : : int i = 0;
344 : : void *hw_annot_addr;
345 : : struct rte_mbuf *first_seg, *next_seg, *cur_seg, *temp;
346 : :
347 : 0 : fd_addr = (size_t)DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd));
348 : : hw_annot_addr = (void *)(fd_addr + DPAA2_FD_PTA_SIZE);
349 : :
350 : : /* Get Scatter gather table address */
351 : 0 : sgt = (struct qbman_sge *)(fd_addr + DPAA2_GET_FD_OFFSET(fd));
352 : :
353 : : sge = &sgt[i++];
354 : 0 : sg_addr = (size_t)DPAA2_IOVA_TO_VADDR(DPAA2_GET_FLE_ADDR(sge));
355 : :
356 : : /* First Scatter gather entry */
357 : 0 : first_seg = DPAA2_INLINE_MBUF_FROM_BUF(sg_addr,
358 : : rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size);
359 : : /* Prepare all the metadata for first segment */
360 : 0 : first_seg->buf_addr = (uint8_t *)sg_addr;
361 : 0 : first_seg->ol_flags = 0;
362 : 0 : first_seg->data_off = DPAA2_GET_FLE_OFFSET(sge);
363 : 0 : first_seg->data_len = sge->length & 0x1FFFF;
364 : 0 : first_seg->pkt_len = DPAA2_GET_FD_LEN(fd);
365 : 0 : first_seg->nb_segs = 1;
366 : 0 : first_seg->next = NULL;
367 : 0 : first_seg->port = port_id;
368 [ # # ]: 0 : if (dpaa2_svr_family == SVR_LX2160A)
369 : 0 : dpaa2_dev_rx_parse_new(first_seg, fd, hw_annot_addr);
370 : : else
371 : 0 : first_seg->packet_type =
372 : 0 : dpaa2_dev_rx_parse(first_seg, hw_annot_addr);
373 : :
374 : : rte_mbuf_refcnt_set(first_seg, 1);
375 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
376 : : rte_mempool_check_cookies(rte_mempool_from_obj((void *)first_seg),
377 : : (void **)&first_seg, 1, 1);
378 : : #endif
379 : : cur_seg = first_seg;
380 [ # # # # ]: 0 : while (!DPAA2_SG_IS_FINAL(sge) && i < DPAA2_MAX_SGS) {
381 : 0 : sge = &sgt[i++];
382 : 0 : sg_addr = (size_t)DPAA2_IOVA_TO_VADDR(
383 : : DPAA2_GET_FLE_ADDR(sge));
384 : 0 : next_seg = DPAA2_INLINE_MBUF_FROM_BUF(sg_addr,
385 : : rte_dpaa2_bpid_info[DPAA2_GET_FLE_BPID(sge)].meta_data_size);
386 : 0 : next_seg->buf_addr = (uint8_t *)sg_addr;
387 : 0 : next_seg->data_off = DPAA2_GET_FLE_OFFSET(sge);
388 : 0 : next_seg->data_len = sge->length & 0x1FFFF;
389 : 0 : first_seg->nb_segs += 1;
390 : : rte_mbuf_refcnt_set(next_seg, 1);
391 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
392 : : rte_mempool_check_cookies(rte_mempool_from_obj((void *)next_seg),
393 : : (void **)&next_seg, 1, 1);
394 : : #endif
395 : 0 : cur_seg->next = next_seg;
396 : 0 : next_seg->next = NULL;
397 : : cur_seg = next_seg;
398 : : }
399 [ # # ]: 0 : temp = DPAA2_INLINE_MBUF_FROM_BUF(fd_addr,
400 : : rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size);
401 : : rte_mbuf_refcnt_set(temp, 1);
402 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
403 : : rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
404 : : (void **)&temp, 1, 1);
405 : : #endif
406 : : rte_pktmbuf_free_seg(temp);
407 : :
408 : 0 : return (void *)first_seg;
409 : : }
410 : :
411 : : static inline struct rte_mbuf *__rte_hot
412 : 0 : eth_fd_to_mbuf(const struct qbman_fd *fd,
413 : : int port_id)
414 : : {
415 : 0 : void *v_addr = DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd));
416 : : void *hw_annot_addr = (void *)((size_t)v_addr + DPAA2_FD_PTA_SIZE);
417 : 0 : struct rte_mbuf *mbuf = DPAA2_INLINE_MBUF_FROM_BUF(v_addr,
418 : : rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size);
419 : :
420 : : /* need to repopulated some of the fields,
421 : : * as they may have changed in last transmission
422 : : */
423 : 0 : mbuf->nb_segs = 1;
424 : 0 : mbuf->ol_flags = 0;
425 : 0 : mbuf->data_off = DPAA2_GET_FD_OFFSET(fd);
426 : 0 : mbuf->data_len = DPAA2_GET_FD_LEN(fd);
427 : 0 : mbuf->pkt_len = mbuf->data_len;
428 : 0 : mbuf->port = port_id;
429 : 0 : mbuf->next = NULL;
430 [ # # ]: 0 : mbuf->hash.sched.color = DPAA2_GET_FD_DROPP(fd);
431 : : rte_mbuf_refcnt_set(mbuf, 1);
432 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
433 : : rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
434 : : (void **)&mbuf, 1, 1);
435 : : #endif
436 : :
437 : : /* Parse the packet */
438 : : /* parse results for LX2 are there in FRC field of FD.
439 : : * For other DPAA2 platforms , parse results are after
440 : : * the private - sw annotation area
441 : : */
442 : :
443 [ # # ]: 0 : if (dpaa2_svr_family == SVR_LX2160A)
444 : 0 : dpaa2_dev_rx_parse_new(mbuf, fd, hw_annot_addr);
445 : : else
446 : 0 : mbuf->packet_type = dpaa2_dev_rx_parse(mbuf, hw_annot_addr);
447 : :
448 : : DPAA2_PMD_DP_DEBUG("to mbuf - mbuf =%p, mbuf->buf_addr =%p, off = %d,"
449 : : "fd_off=%d fd =%" PRIx64 ", meta = %d bpid =%d, len=%d",
450 : : mbuf, mbuf->buf_addr, mbuf->data_off,
451 : : DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_ADDR(fd),
452 : : rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size,
453 : : DPAA2_GET_FD_BPID(fd), DPAA2_GET_FD_LEN(fd));
454 : :
455 : 0 : return mbuf;
456 : : }
457 : :
458 : : static int __rte_noinline __rte_hot
459 : 0 : eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
460 : : struct qbman_fd *fd,
461 : : struct sw_buf_free *free_buf,
462 : : uint32_t *free_count,
463 : : uint32_t pkt_id,
464 : : uint16_t bpid)
465 : : {
466 : : struct rte_mbuf *cur_seg = mbuf, *mi, *temp;
467 : : struct qbman_sge *sgt, *sge = NULL;
468 : : int i, offset = 0;
469 : :
470 : : #ifdef RTE_LIBRTE_IEEE1588
471 : : /* annotation area for timestamp in first buffer */
472 : : offset = 0x64;
473 : : #endif
474 [ # # ]: 0 : if (RTE_MBUF_DIRECT(mbuf) &&
475 [ # # ]: 0 : (mbuf->data_off > (mbuf->nb_segs * sizeof(struct qbman_sge)
476 : : + offset))) {
477 : : temp = mbuf;
478 [ # # ]: 0 : if (rte_mbuf_refcnt_read(temp) > 1) {
479 : : /* If refcnt > 1, invalid bpid is set to ensure
480 : : * buffer is not freed by HW
481 : : */
482 : : fd->simple.bpid_offset = 0;
483 : 0 : DPAA2_SET_FD_IVP(fd);
484 : 0 : rte_mbuf_refcnt_update(temp, -1);
485 : : } else {
486 : 0 : DPAA2_SET_ONLY_FD_BPID(fd, bpid);
487 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
488 : : rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
489 : : (void **)&temp, 1, 0);
490 : : #endif
491 : : }
492 : 0 : DPAA2_SET_FD_OFFSET(fd, offset);
493 : : } else {
494 : 0 : temp = rte_pktmbuf_alloc(dpaa2_tx_sg_pool);
495 [ # # ]: 0 : if (temp == NULL) {
496 : : DPAA2_PMD_DP_DEBUG("No memory to allocate S/G table");
497 : : return -ENOMEM;
498 : : }
499 : 0 : DPAA2_SET_ONLY_FD_BPID(fd, mempool_to_bpid(dpaa2_tx_sg_pool));
500 : 0 : DPAA2_SET_FD_OFFSET(fd, temp->data_off);
501 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
502 : : rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
503 : : (void **)&temp, 1, 0);
504 : : #endif
505 : : }
506 : 0 : DPAA2_SET_FD_ADDR(fd, DPAA2_MBUF_VADDR_TO_IOVA(temp));
507 : 0 : DPAA2_SET_FD_LEN(fd, mbuf->pkt_len);
508 : 0 : DPAA2_FD_SET_FORMAT(fd, qbman_fd_sg);
509 : 0 : DPAA2_RESET_FD_FRC(fd);
510 : 0 : DPAA2_RESET_FD_CTRL(fd);
511 : 0 : DPAA2_RESET_FD_FLC(fd);
512 : : /*Set Scatter gather table and Scatter gather entries*/
513 : 0 : sgt = (struct qbman_sge *)(
514 : 0 : (size_t)DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd))
515 : 0 : + DPAA2_GET_FD_OFFSET(fd));
516 : :
517 [ # # ]: 0 : for (i = 0; i < mbuf->nb_segs; i++) {
518 : 0 : sge = &sgt[i];
519 : : /*Resetting the buffer pool id and offset field*/
520 [ # # ]: 0 : sge->fin_bpid_offset = 0;
521 : 0 : DPAA2_SET_FLE_ADDR(sge, rte_pktmbuf_iova(cur_seg));
522 : 0 : sge->length = cur_seg->data_len;
523 [ # # ]: 0 : if (RTE_MBUF_DIRECT(cur_seg)) {
524 : : /* if we are using inline SGT in same buffers
525 : : * set the FLE FMT as Frame Data Section
526 : : */
527 [ # # ]: 0 : if (temp == cur_seg) {
528 : : DPAA2_SG_SET_FORMAT(sge, qbman_fd_list);
529 : 0 : DPAA2_SET_FLE_IVP(sge);
530 : : } else {
531 [ # # ]: 0 : if (rte_mbuf_refcnt_read(cur_seg) > 1) {
532 : : /* If refcnt > 1, invalid bpid is set to ensure
533 : : * buffer is not freed by HW
534 : : */
535 : 0 : DPAA2_SET_FLE_IVP(sge);
536 : 0 : rte_mbuf_refcnt_update(cur_seg, -1);
537 : : } else {
538 : 0 : DPAA2_SET_FLE_BPID(sge,
539 : : mempool_to_bpid(cur_seg->pool));
540 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
541 : : rte_mempool_check_cookies(rte_mempool_from_obj((void *)cur_seg),
542 : : (void **)&cur_seg, 1, 0);
543 : : #endif
544 : : }
545 : : }
546 [ # # ]: 0 : } else if (RTE_MBUF_HAS_EXTBUF(cur_seg)) {
547 : 0 : free_buf[*free_count].seg = cur_seg;
548 : 0 : free_buf[*free_count].pkt_id = pkt_id;
549 : 0 : ++*free_count;
550 : 0 : DPAA2_SET_FLE_IVP(sge);
551 : : } else {
552 : : /* Get owner MBUF from indirect buffer */
553 : : mi = rte_mbuf_from_indirect(cur_seg);
554 [ # # ]: 0 : if (rte_mbuf_refcnt_read(mi) > 1) {
555 : : /* If refcnt > 1, invalid bpid is set to ensure
556 : : * owner buffer is not freed by HW
557 : : */
558 : 0 : DPAA2_SET_FLE_IVP(sge);
559 : : } else {
560 : 0 : DPAA2_SET_FLE_BPID(sge,
561 : : mempool_to_bpid(mi->pool));
562 : 0 : rte_mbuf_refcnt_update(mi, 1);
563 : : }
564 : 0 : free_buf[*free_count].seg = cur_seg;
565 : 0 : free_buf[*free_count].pkt_id = pkt_id;
566 : 0 : ++*free_count;
567 : : }
568 : 0 : cur_seg = cur_seg->next;
569 : : }
570 : 0 : DPAA2_SG_SET_FINAL(sge, true);
571 : 0 : return 0;
572 : : }
573 : :
574 : : static inline void
575 : 0 : dpaa2_dev_prefetch_next_psr(const struct qbman_result *dq)
576 : : {
577 : : const struct qbman_fd *fd;
578 : : const struct dpaa2_annot_hdr *annotation;
579 : : uint64_t annot_iova;
580 : :
581 : 0 : dq++;
582 : :
583 : 0 : fd = qbman_result_DQ_fd(dq);
584 : 0 : annot_iova = DPAA2_GET_FD_ADDR(fd) + DPAA2_FD_PTA_SIZE;
585 : : annotation = DPAA2_IOVA_TO_VADDR(annot_iova);
586 : :
587 : : /** Prefetch from word3 to parse next header.*/
588 : 0 : rte_prefetch0(&annotation->word3);
589 : 0 : }
590 : :
591 : : static void
592 : : eth_mbuf_to_fd(struct rte_mbuf *mbuf,
593 : : struct qbman_fd *fd,
594 : : struct sw_buf_free *buf_to_free,
595 : : uint32_t *free_count,
596 : : uint32_t pkt_id,
597 : : uint16_t bpid) __rte_unused;
598 : :
599 : : static void __rte_noinline __rte_hot
600 : 0 : eth_mbuf_to_fd(struct rte_mbuf *mbuf,
601 : : struct qbman_fd *fd,
602 : : struct sw_buf_free *buf_to_free,
603 : : uint32_t *free_count,
604 : : uint32_t pkt_id,
605 : : uint16_t bpid)
606 : : {
607 : 0 : DPAA2_MBUF_TO_CONTIG_FD(mbuf, fd, bpid);
608 : :
609 : : DPAA2_PMD_DP_DEBUG("mbuf =%p, mbuf->buf_addr =%p, off = %d,"
610 : : "fd_off=%d fd =%" PRIx64 ", meta = %d bpid =%d, len=%d",
611 : : mbuf, mbuf->buf_addr, mbuf->data_off,
612 : : DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_ADDR(fd),
613 : : rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size,
614 : : DPAA2_GET_FD_BPID(fd), DPAA2_GET_FD_LEN(fd));
615 [ # # ]: 0 : if (RTE_MBUF_DIRECT(mbuf)) {
616 [ # # ]: 0 : if (rte_mbuf_refcnt_read(mbuf) > 1) {
617 : 0 : DPAA2_SET_FD_IVP(fd);
618 : 0 : rte_mbuf_refcnt_update(mbuf, -1);
619 : : }
620 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
621 : : else
622 : : rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
623 : : (void **)&mbuf, 1, 0);
624 : : #endif
625 [ # # ]: 0 : } else if (RTE_MBUF_HAS_EXTBUF(mbuf)) {
626 : 0 : buf_to_free[*free_count].seg = mbuf;
627 : 0 : buf_to_free[*free_count].pkt_id = pkt_id;
628 : 0 : ++*free_count;
629 : 0 : DPAA2_SET_FD_IVP(fd);
630 : : } else {
631 : : struct rte_mbuf *mi;
632 : :
633 : : mi = rte_mbuf_from_indirect(mbuf);
634 [ # # ]: 0 : if (rte_mbuf_refcnt_read(mi) > 1)
635 : 0 : DPAA2_SET_FD_IVP(fd);
636 : : else
637 : 0 : rte_mbuf_refcnt_update(mi, 1);
638 : :
639 : 0 : buf_to_free[*free_count].seg = mbuf;
640 : 0 : buf_to_free[*free_count].pkt_id = pkt_id;
641 : 0 : ++*free_count;
642 : : }
643 : 0 : }
644 : :
645 : : static inline int __rte_hot
646 : 0 : eth_copy_mbuf_to_fd(struct rte_mbuf *mbuf,
647 : : struct qbman_fd *fd, uint16_t bpid)
648 : : {
649 : : struct rte_mbuf *m;
650 : 0 : void *mb = NULL;
651 : :
652 [ # # ]: 0 : if (rte_dpaa2_mbuf_alloc_bulk(
653 : 0 : rte_dpaa2_bpid_info[bpid].bp_list->mp, &mb, 1)) {
654 : : DPAA2_PMD_DP_DEBUG("Unable to allocated DPAA2 buffer");
655 : : return -1;
656 : : }
657 : 0 : m = (struct rte_mbuf *)mb;
658 : 0 : memcpy((char *)m->buf_addr + mbuf->data_off,
659 : 0 : (void *)((char *)mbuf->buf_addr + mbuf->data_off),
660 : 0 : mbuf->pkt_len);
661 : :
662 : : /* Copy required fields */
663 : 0 : m->data_off = mbuf->data_off;
664 : 0 : m->ol_flags = mbuf->ol_flags;
665 : 0 : m->packet_type = mbuf->packet_type;
666 : 0 : m->tx_offload = mbuf->tx_offload;
667 : :
668 : 0 : DPAA2_MBUF_TO_CONTIG_FD(m, fd, bpid);
669 : :
670 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
671 : : rte_mempool_check_cookies(rte_mempool_from_obj((void *)m),
672 : : (void **)&m, 1, 0);
673 : : #endif
674 : : DPAA2_PMD_DP_DEBUG(
675 : : "mbuf: %p, BMAN buf addr: %p, fdaddr: %" PRIx64 ", bpid: %d,"
676 : : " meta: %d, off: %d, len: %d",
677 : : (void *)mbuf,
678 : : mbuf->buf_addr,
679 : : DPAA2_GET_FD_ADDR(fd),
680 : : DPAA2_GET_FD_BPID(fd),
681 : : rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size,
682 : : DPAA2_GET_FD_OFFSET(fd),
683 : : DPAA2_GET_FD_LEN(fd));
684 : :
685 : 0 : return 0;
686 : : }
687 : :
688 : : static void
689 : 0 : dump_err_pkts(struct dpaa2_queue *dpaa2_q)
690 : : {
691 : : /* Function receive frames for a given device and VQ */
692 : : struct qbman_result *dq_storage;
693 : 0 : uint32_t fqid = dpaa2_q->fqid;
694 : : int ret, num_rx = 0;
695 : : uint8_t pending, status;
696 : : struct qbman_swp *swp;
697 : : const struct qbman_fd *fd;
698 : : struct qbman_pull_desc pulldesc;
699 [ # # ]: 0 : struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
700 : : uint32_t lcore_id = rte_lcore_id();
701 : : void *v_addr, *hw_annot_addr;
702 : : struct dpaa2_fas *fas;
703 : : struct rte_mbuf *mbuf;
704 : : char title[32];
705 : :
706 [ # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
707 : 0 : ret = dpaa2_affine_qbman_swp();
708 [ # # ]: 0 : if (ret) {
709 : 0 : DPAA2_PMD_ERR("Failed to allocate IO portal, tid: %d",
710 : : rte_gettid());
711 : 0 : return;
712 : : }
713 : : }
714 : 0 : swp = DPAA2_PER_LCORE_PORTAL;
715 : :
716 : 0 : dq_storage = dpaa2_q->q_storage[lcore_id]->dq_storage[0];
717 : 0 : qbman_pull_desc_clear(&pulldesc);
718 : 0 : qbman_pull_desc_set_fq(&pulldesc, fqid);
719 : 0 : qbman_pull_desc_set_storage(&pulldesc, dq_storage,
720 : : (size_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1);
721 : 0 : qbman_pull_desc_set_numframes(&pulldesc, dpaa2_dqrr_size);
722 : :
723 : : while (1) {
724 [ # # ]: 0 : if (qbman_swp_pull(swp, &pulldesc)) {
725 : : DPAA2_PMD_DP_DEBUG("VDQ command is not issued.QBMAN is busy");
726 : : /* Portal was busy, try again */
727 : : continue;
728 : : }
729 : : break;
730 : : }
731 : :
732 : : /* Check if the previous issued command is completed. */
733 [ # # ]: 0 : while (!qbman_check_command_complete(dq_storage))
734 : : ;
735 : :
736 : : pending = 1;
737 : : do {
738 : : /* Loop until the dq_storage is updated with
739 : : * new token by QBMAN
740 : : */
741 [ # # ]: 0 : while (!qbman_check_new_result(dq_storage))
742 : : ;
743 : :
744 : : /* Check whether Last Pull command is Expired and
745 : : * setting Condition for Loop termination
746 : : */
747 [ # # ]: 0 : if (qbman_result_DQ_is_pull_complete(dq_storage)) {
748 : : pending = 0;
749 : : /* Check for valid frame. */
750 : 0 : status = qbman_result_DQ_flags(dq_storage);
751 [ # # ]: 0 : if (unlikely((status &
752 : : QBMAN_DQ_STAT_VALIDFRAME) == 0))
753 : 0 : continue;
754 : : }
755 : 0 : fd = qbman_result_DQ_fd(dq_storage);
756 : 0 : v_addr = DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd));
757 : : hw_annot_addr = (void *)((size_t)v_addr + DPAA2_FD_PTA_SIZE);
758 : : fas = hw_annot_addr;
759 : :
760 [ # # ]: 0 : if (DPAA2_FD_GET_FORMAT(fd) == qbman_fd_sg)
761 : 0 : mbuf = eth_sg_fd_to_mbuf(fd, eth_data->port_id);
762 : : else
763 : 0 : mbuf = eth_fd_to_mbuf(fd, eth_data->port_id);
764 : :
765 [ # # ]: 0 : if (!dpaa2_print_parser_result) {
766 : : /** Don't print parse result twice.*/
767 : 0 : dpaa2_print_parse_result(hw_annot_addr);
768 : : }
769 : :
770 : 0 : DPAA2_PMD_ERR("Err pkt on port[%d]:", eth_data->port_id);
771 : 0 : DPAA2_PMD_ERR("FD offset: %d, FD err: %x, FAS status: %x",
772 : : DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_ERR(fd),
773 : : fas->status);
774 : :
775 [ # # ]: 0 : if (mbuf) {
776 : : __rte_mbuf_sanity_check(mbuf, 1);
777 [ # # ]: 0 : if (mbuf->nb_segs > 1) {
778 : : struct rte_mbuf *seg = mbuf;
779 : : int i = 0;
780 : :
781 [ # # ]: 0 : while (seg) {
782 : : sprintf(title, "Payload seg[%d]", i);
783 : 0 : rte_hexdump(stderr, title,
784 : 0 : (char *)seg->buf_addr + seg->data_off,
785 : 0 : seg->data_len);
786 : 0 : seg = seg->next;
787 : 0 : i++;
788 : : }
789 : : } else {
790 : 0 : rte_hexdump(stderr, "Payload",
791 : 0 : (char *)mbuf->buf_addr + mbuf->data_off,
792 : 0 : mbuf->data_len);
793 : : }
794 : 0 : rte_pktmbuf_free(mbuf);
795 : : }
796 : 0 : dq_storage++;
797 : 0 : num_rx++;
798 [ # # ]: 0 : } while (pending);
799 : :
800 : 0 : dpaa2_q->err_pkts += num_rx;
801 : : }
802 : :
803 : : /* This function assumes that caller will be keep the same value for nb_pkts
804 : : * across calls per queue, if that is not the case, better use non-prefetch
805 : : * version of rx call.
806 : : * It will return the packets as requested in previous call without honoring
807 : : * the current nb_pkts or bufs space.
808 : : */
809 : : static __rte_always_inline uint16_t
810 : : dpaa2_dev_prefetch_rx_common(void *queue, struct rte_mbuf **bufs,
811 : : uint16_t nb_pkts, bool by_channel)
812 : : {
813 : : /* Function receive frames for a given device and VQ*/
814 : : struct dpaa2_queue *dpaa2_q = queue;
815 : : struct qbman_result *dq_storage, *dq_storage1 = NULL;
816 : : int ret, num_rx = 0, pull_size;
817 : : uint8_t pending, status;
818 : : struct qbman_swp *swp;
819 : : const struct qbman_fd *fd;
820 : : struct qbman_pull_desc pulldesc;
821 : : struct queue_storage_info_t *q_storage;
822 : 0 : struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
823 : :
824 : 0 : q_storage = dpaa2_q->q_storage[rte_lcore_id()];
825 : :
826 : : /* the error-queue drain runs on the regular portal (DPAA2_PER_LCORE_PORTAL);
827 : : * the channel/interrupt path owns the ethrx portal, so skip it there
828 : : */
829 : : if (!by_channel) {
830 : 0 : struct dpaa2_dev_priv *priv = eth_data->dev_private;
831 : :
832 [ # # ]: 0 : if (unlikely(priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG))
833 : 0 : dump_err_pkts(priv->rx_err_vq);
834 : : }
835 : :
836 [ # # # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_ETHRX_DPIO)) {
837 : 0 : ret = dpaa2_affine_qbman_ethrx_swp();
838 [ # # # # ]: 0 : if (ret) {
839 : 0 : DPAA2_PMD_ERR("Failure in affining portal");
840 : 0 : return 0;
841 : : }
842 : : }
843 : :
844 [ # # # # ]: 0 : if (!by_channel && unlikely(!rte_dpaa2_bpid_info &&
845 : : rte_eal_process_type() == RTE_PROC_SECONDARY))
846 : 0 : rte_dpaa2_bpid_info = dpaa2_q->bp_array;
847 : :
848 : 0 : swp = DPAA2_PER_LCORE_ETHRX_PORTAL;
849 [ # # # # ]: 0 : pull_size = (nb_pkts > dpaa2_dqrr_size) ? dpaa2_dqrr_size : nb_pkts;
850 [ # # # # ]: 0 : if (unlikely(!q_storage->active_dqs)) {
851 : 0 : q_storage->toggle = 0;
852 : 0 : dq_storage = q_storage->dq_storage[q_storage->toggle];
853 : 0 : q_storage->last_num_pkts = pull_size;
854 : 0 : qbman_pull_desc_clear(&pulldesc);
855 : 0 : qbman_pull_desc_set_numframes(&pulldesc,
856 : 0 : q_storage->last_num_pkts);
857 : : if (by_channel)
858 : 0 : qbman_pull_desc_set_channel(&pulldesc,
859 : 0 : dpaa2_q->napi_dpcon->qbman_ch_id,
860 : : qbman_pull_type_active);
861 : : else
862 : 0 : qbman_pull_desc_set_fq(&pulldesc, dpaa2_q->fqid);
863 : 0 : qbman_pull_desc_set_storage(&pulldesc, dq_storage,
864 : : (uint64_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1);
865 [ # # # # ]: 0 : if (check_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index)) {
866 [ # # # # ]: 0 : while (!qbman_check_command_complete(
867 : : get_swp_active_dqs(
868 : 0 : DPAA2_PER_LCORE_ETHRX_DPIO->index)))
869 : : ;
870 : 0 : clear_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index);
871 : : }
872 : : while (1) {
873 [ # # # # ]: 0 : if (qbman_swp_pull(swp, &pulldesc)) {
874 : : DPAA2_PMD_DP_DEBUG("VDQ command is not issued."
875 : : " QBMAN is busy (1)");
876 : : /* Portal was busy, try again */
877 : : continue;
878 : : }
879 : : break;
880 : : }
881 : 0 : q_storage->active_dqs = dq_storage;
882 : 0 : q_storage->active_dpio_id = DPAA2_PER_LCORE_ETHRX_DPIO->index;
883 : 0 : set_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index,
884 : : dq_storage);
885 : : }
886 : :
887 : 0 : dq_storage = q_storage->active_dqs;
888 : : rte_prefetch0((void *)(size_t)(dq_storage));
889 : 0 : rte_prefetch0((void *)(size_t)(dq_storage + 1));
890 : :
891 : : /* Prepare next pull descriptor. This will give space for the
892 : : * prefetching done on DQRR entries
893 : : */
894 : 0 : q_storage->toggle ^= 1;
895 : 0 : dq_storage1 = q_storage->dq_storage[q_storage->toggle];
896 : 0 : qbman_pull_desc_clear(&pulldesc);
897 : 0 : qbman_pull_desc_set_numframes(&pulldesc, pull_size);
898 : : if (by_channel)
899 : 0 : qbman_pull_desc_set_channel(&pulldesc,
900 : 0 : dpaa2_q->napi_dpcon->qbman_ch_id,
901 : : qbman_pull_type_active);
902 : : else
903 : 0 : qbman_pull_desc_set_fq(&pulldesc, dpaa2_q->fqid);
904 : 0 : qbman_pull_desc_set_storage(&pulldesc, dq_storage1,
905 : : (uint64_t)(DPAA2_VADDR_TO_IOVA(dq_storage1)), 1);
906 : :
907 : : /* Check if the previous issued command is completed.
908 : : * Also seems like the SWP is shared between the Ethernet Driver
909 : : * and the SEC driver.
910 : : */
911 [ # # # # ]: 0 : while (!qbman_check_command_complete(dq_storage))
912 : : ;
913 [ # # # # ]: 0 : if (dq_storage == get_swp_active_dqs(q_storage->active_dpio_id))
914 : : clear_swp_active_dqs(q_storage->active_dpio_id);
915 : :
916 : : pending = 1;
917 : :
918 : : do {
919 : : /* Loop until the dq_storage is updated with
920 : : * new token by QBMAN
921 : : */
922 [ # # # # ]: 0 : while (!qbman_check_new_result(dq_storage))
923 : : ;
924 : 0 : rte_prefetch0((void *)((size_t)(dq_storage + 2)));
925 : : /* Check whether Last Pull command is Expired and
926 : : * setting Condition for Loop termination
927 : : */
928 [ # # # # ]: 0 : if (qbman_result_DQ_is_pull_complete(dq_storage)) {
929 : : pending = 0;
930 : : /* Check for valid frame. */
931 : 0 : status = qbman_result_DQ_flags(dq_storage);
932 [ # # # # ]: 0 : if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0))
933 : 0 : continue;
934 : : }
935 [ # # # # ]: 0 : if (dpaa2_svr_family != SVR_LX2160A)
936 : : /** Packet type is parsed from FRC for LX2160A.*/
937 : 0 : dpaa2_dev_prefetch_next_psr(dq_storage);
938 : :
939 : 0 : fd = qbman_result_DQ_fd(dq_storage);
940 [ # # # # ]: 0 : if (unlikely(DPAA2_FD_GET_FORMAT(fd) == qbman_fd_sg))
941 : 0 : bufs[num_rx] = eth_sg_fd_to_mbuf(fd, eth_data->port_id);
942 : : else
943 : 0 : bufs[num_rx] = eth_fd_to_mbuf(fd, eth_data->port_id);
944 : : #if defined(RTE_LIBRTE_IEEE1588)
945 : : if (bufs[num_rx]->ol_flags & RTE_MBUF_F_RX_IEEE1588_TMST) {
946 : : struct dpaa2_dev_priv *priv = eth_data->dev_private;
947 : :
948 : : priv->rx_timestamp =
949 : : *dpaa2_timestamp_dynfield(bufs[num_rx]);
950 : : }
951 : : #endif
952 : :
953 : 0 : dq_storage++;
954 : 0 : num_rx++;
955 [ # # # # ]: 0 : } while (pending);
956 : :
957 [ # # # # ]: 0 : if (check_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index)) {
958 [ # # # # ]: 0 : while (!qbman_check_command_complete(
959 : 0 : get_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index)))
960 : : ;
961 : 0 : clear_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index);
962 : : }
963 : : /* issue a volatile dequeue command for next pull */
964 : : while (1) {
965 [ # # # # ]: 0 : if (qbman_swp_pull(swp, &pulldesc)) {
966 : : DPAA2_PMD_DP_DEBUG("VDQ command is not issued."
967 : : "QBMAN is busy (2)");
968 : : continue;
969 : : }
970 : : break;
971 : : }
972 : 0 : q_storage->active_dqs = dq_storage1;
973 : 0 : q_storage->active_dpio_id = DPAA2_PER_LCORE_ETHRX_DPIO->index;
974 : 0 : set_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index, dq_storage1);
975 : :
976 : 0 : dpaa2_q->rx_pkts += num_rx;
977 : :
978 : 0 : return num_rx;
979 : : }
980 : :
981 : : uint16_t __rte_hot
982 : 0 : dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
983 : : {
984 [ # # ]: 0 : return dpaa2_dev_prefetch_rx_common(queue, bufs, nb_pkts, false);
985 : : }
986 : :
987 : : /* rx interrupt/CDAN path: each Rx FQ is scheduled to its own DPCON channel,
988 : : * which a CDAN notifies on empty->non-empty. A VDQ on a scheduled FQ never
989 : : * completes, so the channel is drained by a volatile pull on the CHANNEL (not
990 : : * the FQID); one FQ per channel, so no demux is needed. Same prefetch pipeline
991 : : * as dpaa2_dev_prefetch_rx (one VDQ kept in flight to mask the ~700 cycle
992 : : * latency); the portal's single in-flight VDQ (global_active_dqs) must be
993 : : * quiesced before an interrupt sleep.
994 : : */
995 : : uint16_t __rte_hot
996 : 0 : dpaa2_dev_prefetch_rx_channel(void *queue, struct rte_mbuf **bufs,
997 : : uint16_t nb_pkts)
998 : : {
999 [ # # ]: 0 : return dpaa2_dev_prefetch_rx_common(queue, bufs, nb_pkts, true);
1000 : : }
1001 : :
1002 : : void __rte_hot
1003 : 0 : dpaa2_dev_process_parallel_event(struct qbman_swp *swp,
1004 : : const struct qbman_fd *fd,
1005 : : const struct qbman_result *dq,
1006 : : struct dpaa2_queue *rxq,
1007 : : struct rte_event *ev)
1008 : : {
1009 : 0 : rte_prefetch0((void *)(size_t)(DPAA2_GET_FD_ADDR(fd) +
1010 : : DPAA2_FD_PTA_SIZE + 16));
1011 : :
1012 : 0 : ev->flow_id = rxq->ev.flow_id;
1013 : 0 : ev->sub_event_type = rxq->ev.sub_event_type;
1014 : 0 : ev->event_type = RTE_EVENT_TYPE_ETHDEV;
1015 : 0 : ev->op = RTE_EVENT_OP_NEW;
1016 : 0 : ev->sched_type = rxq->ev.sched_type;
1017 : 0 : ev->queue_id = rxq->ev.queue_id;
1018 : 0 : ev->priority = rxq->ev.priority;
1019 : :
1020 : 0 : ev->mbuf = eth_fd_to_mbuf(fd, rxq->eth_data->port_id);
1021 : :
1022 : 0 : qbman_swp_dqrr_consume(swp, dq);
1023 : 0 : }
1024 : :
1025 : : void __rte_hot
1026 : 0 : dpaa2_dev_process_atomic_event(struct qbman_swp *swp __rte_unused,
1027 : : const struct qbman_fd *fd,
1028 : : const struct qbman_result *dq,
1029 : : struct dpaa2_queue *rxq,
1030 : : struct rte_event *ev)
1031 : : {
1032 : : uint8_t dqrr_index;
1033 : :
1034 : 0 : rte_prefetch0((void *)(size_t)(DPAA2_GET_FD_ADDR(fd) +
1035 : : DPAA2_FD_PTA_SIZE + 16));
1036 : :
1037 : 0 : ev->flow_id = rxq->ev.flow_id;
1038 : 0 : ev->sub_event_type = rxq->ev.sub_event_type;
1039 : 0 : ev->event_type = RTE_EVENT_TYPE_ETHDEV;
1040 : 0 : ev->op = RTE_EVENT_OP_NEW;
1041 : 0 : ev->sched_type = rxq->ev.sched_type;
1042 : 0 : ev->queue_id = rxq->ev.queue_id;
1043 : 0 : ev->priority = rxq->ev.priority;
1044 : :
1045 : 0 : ev->mbuf = eth_fd_to_mbuf(fd, rxq->eth_data->port_id);
1046 : :
1047 : 0 : dqrr_index = qbman_get_dqrr_idx(dq);
1048 : 0 : *dpaa2_seqn(ev->mbuf) = dqrr_index + 1;
1049 : 0 : DPAA2_PER_LCORE_DQRR_SIZE++;
1050 : 0 : DPAA2_PER_LCORE_DQRR_HELD |= UINT64_C(1) << dqrr_index;
1051 : 0 : DPAA2_PER_LCORE_DQRR_MBUF(dqrr_index) = ev->mbuf;
1052 : 0 : }
1053 : :
1054 : : void __rte_hot
1055 : 0 : dpaa2_dev_process_ordered_event(struct qbman_swp *swp,
1056 : : const struct qbman_fd *fd,
1057 : : const struct qbman_result *dq,
1058 : : struct dpaa2_queue *rxq,
1059 : : struct rte_event *ev)
1060 : : {
1061 : 0 : rte_prefetch0((void *)(size_t)(DPAA2_GET_FD_ADDR(fd) +
1062 : : DPAA2_FD_PTA_SIZE + 16));
1063 : :
1064 : 0 : ev->flow_id = rxq->ev.flow_id;
1065 : 0 : ev->sub_event_type = rxq->ev.sub_event_type;
1066 : 0 : ev->event_type = RTE_EVENT_TYPE_ETHDEV;
1067 : 0 : ev->op = RTE_EVENT_OP_NEW;
1068 : 0 : ev->sched_type = rxq->ev.sched_type;
1069 : 0 : ev->queue_id = rxq->ev.queue_id;
1070 : 0 : ev->priority = rxq->ev.priority;
1071 : :
1072 : 0 : ev->mbuf = eth_fd_to_mbuf(fd, rxq->eth_data->port_id);
1073 : :
1074 : 0 : *dpaa2_seqn(ev->mbuf) = DPAA2_ENQUEUE_FLAG_ORP;
1075 : 0 : *dpaa2_seqn(ev->mbuf) |= qbman_result_DQ_odpid(dq) << DPAA2_EQCR_OPRID_SHIFT;
1076 : 0 : *dpaa2_seqn(ev->mbuf) |= qbman_result_DQ_seqnum(dq) << DPAA2_EQCR_SEQNUM_SHIFT;
1077 : :
1078 : 0 : qbman_swp_dqrr_consume(swp, dq);
1079 : 0 : }
1080 : :
1081 : : static __rte_always_inline uint16_t
1082 : : dpaa2_dev_rx_common(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts,
1083 : : bool by_channel)
1084 : : {
1085 : : /* Function receive frames for a given device and VQ */
1086 : : struct dpaa2_queue *dpaa2_q = queue;
1087 : : struct qbman_result *dq_storage;
1088 : 0 : uint32_t fqid = dpaa2_q->fqid;
1089 : : int ret, num_rx = 0, next_pull = nb_pkts, num_pulled;
1090 : : uint8_t pending, status;
1091 : : struct qbman_swp *swp;
1092 : : const struct qbman_fd *fd;
1093 : : struct qbman_pull_desc pulldesc;
1094 : 0 : struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
1095 : 0 : struct dpaa2_dev_priv *priv = eth_data->dev_private;
1096 : :
1097 : 0 : if (!by_channel && unlikely(priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG))
1098 : 0 : dump_err_pkts(priv->rx_err_vq);
1099 : :
1100 : : if (by_channel) {
1101 : 0 : if (unlikely(!DPAA2_PER_LCORE_ETHRX_DPIO)) {
1102 : 0 : ret = dpaa2_affine_qbman_ethrx_swp();
1103 [ # # ]: 0 : if (ret) {
1104 : 0 : DPAA2_PMD_ERR("Failure in affining portal");
1105 : 0 : return 0;
1106 : : }
1107 : : }
1108 : 0 : swp = DPAA2_PER_LCORE_ETHRX_PORTAL;
1109 : : } else {
1110 [ # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
1111 : 0 : ret = dpaa2_affine_qbman_swp();
1112 [ # # ]: 0 : if (ret) {
1113 : 0 : DPAA2_PMD_ERR("Failed to allocate IO portal, tid: %d",
1114 : : rte_gettid());
1115 : 0 : return 0;
1116 : : }
1117 : : }
1118 : 0 : swp = DPAA2_PER_LCORE_PORTAL;
1119 : : }
1120 : :
1121 : : do {
1122 : 0 : dq_storage = dpaa2_q->q_storage[0]->dq_storage[0];
1123 : 0 : qbman_pull_desc_clear(&pulldesc);
1124 : : if (by_channel)
1125 : 0 : qbman_pull_desc_set_channel(&pulldesc,
1126 : 0 : dpaa2_q->napi_dpcon->qbman_ch_id,
1127 : : qbman_pull_type_active);
1128 : : else
1129 : 0 : qbman_pull_desc_set_fq(&pulldesc, fqid);
1130 : 0 : qbman_pull_desc_set_storage(&pulldesc, dq_storage,
1131 : : (size_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1);
1132 : :
1133 [ # # # # ]: 0 : if (next_pull > dpaa2_dqrr_size) {
1134 : 0 : qbman_pull_desc_set_numframes(&pulldesc,
1135 : : dpaa2_dqrr_size);
1136 : 0 : next_pull -= dpaa2_dqrr_size;
1137 : : } else {
1138 : 0 : qbman_pull_desc_set_numframes(&pulldesc, next_pull);
1139 : : next_pull = 0;
1140 : : }
1141 : :
1142 : : while (1) {
1143 [ # # # # ]: 0 : if (qbman_swp_pull(swp, &pulldesc)) {
1144 : : DPAA2_PMD_DP_DEBUG(
1145 : : "VDQ command is not issued.QBMAN is busy");
1146 : : /* Portal was busy, try again */
1147 : : continue;
1148 : : }
1149 : : break;
1150 : : }
1151 : :
1152 : 0 : rte_prefetch0((void *)((size_t)(dq_storage + 1)));
1153 : : /* Check if the previous issued command is completed. */
1154 [ # # # # ]: 0 : while (!qbman_check_command_complete(dq_storage))
1155 : : ;
1156 : :
1157 : : num_pulled = 0;
1158 : : pending = 1;
1159 : : do {
1160 : : /* Loop until the dq_storage is updated with
1161 : : * new token by QBMAN
1162 : : */
1163 [ # # # # ]: 0 : while (!qbman_check_new_result(dq_storage))
1164 : : ;
1165 : 0 : rte_prefetch0((void *)((size_t)(dq_storage + 2)));
1166 : : /* Check whether Last Pull command is Expired and
1167 : : * setting Condition for Loop termination
1168 : : */
1169 [ # # # # ]: 0 : if (qbman_result_DQ_is_pull_complete(dq_storage)) {
1170 : : pending = 0;
1171 : : /* Check for valid frame. */
1172 : 0 : status = qbman_result_DQ_flags(dq_storage);
1173 [ # # # # ]: 0 : if (unlikely((status &
1174 : : QBMAN_DQ_STAT_VALIDFRAME) == 0))
1175 : 0 : continue;
1176 : : }
1177 [ # # # # ]: 0 : if (dpaa2_svr_family != SVR_LX2160A)
1178 : : /** Packet type is parsed from FRC for LX2160A.*/
1179 : 0 : dpaa2_dev_prefetch_next_psr(dq_storage);
1180 : :
1181 : 0 : fd = qbman_result_DQ_fd(dq_storage);
1182 [ # # # # ]: 0 : if (unlikely(DPAA2_FD_GET_FORMAT(fd) == qbman_fd_sg))
1183 : 0 : bufs[num_rx] = eth_sg_fd_to_mbuf(fd,
1184 : 0 : eth_data->port_id);
1185 : : else
1186 : 0 : bufs[num_rx] = eth_fd_to_mbuf(fd,
1187 : 0 : eth_data->port_id);
1188 : :
1189 : : #if defined(RTE_LIBRTE_IEEE1588)
1190 : : if (bufs[num_rx]->ol_flags & RTE_MBUF_F_RX_IEEE1588_TMST) {
1191 : : priv->rx_timestamp =
1192 : : *dpaa2_timestamp_dynfield(bufs[num_rx]);
1193 : : }
1194 : : #endif
1195 : :
1196 : 0 : dq_storage++;
1197 : 0 : num_rx++;
1198 : 0 : num_pulled++;
1199 [ # # # # ]: 0 : } while (pending);
1200 : : /* Last VDQ provided all packets and more packets are requested */
1201 [ # # # # : 0 : } while (next_pull && num_pulled == dpaa2_dqrr_size);
# # # # ]
1202 : :
1203 : 0 : dpaa2_q->rx_pkts += num_rx;
1204 : :
1205 : 0 : return num_rx;
1206 : : }
1207 : :
1208 : : uint16_t
1209 : 0 : dpaa2_dev_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
1210 : : {
1211 [ # # ]: 0 : return dpaa2_dev_rx_common(queue, bufs, nb_pkts, false);
1212 : : }
1213 : :
1214 : : /* rx-interrupt path: synchronous volatile dequeue on the queue's DPCON channel
1215 : : * (no prefetch pipeline, so nothing is left in flight across an interrupt
1216 : : * sleep, and a channel VDQ -- unlike an FQ VDQ -- completes on a scheduled FQ).
1217 : : */
1218 : : uint16_t __rte_hot
1219 : 0 : dpaa2_dev_rx_channel(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
1220 : : {
1221 [ # # ]: 0 : return dpaa2_dev_rx_common(queue, bufs, nb_pkts, true);
1222 : : }
1223 : :
1224 : 0 : uint16_t dpaa2_dev_tx_conf(void *queue)
1225 : : {
1226 : : /* Function receive frames for a given device and VQ */
1227 : : struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;
1228 : : struct qbman_result *dq_storage;
1229 : 0 : uint32_t fqid = dpaa2_q->fqid;
1230 : : int ret, num_tx_conf = 0, num_pulled;
1231 : : uint8_t pending, status;
1232 : : struct qbman_swp *swp;
1233 : : const struct qbman_fd *fd;
1234 : : struct qbman_pull_desc pulldesc;
1235 : : struct qbman_release_desc releasedesc;
1236 : : uint32_t bpid;
1237 : : uint64_t buf;
1238 : : #if defined(RTE_LIBRTE_IEEE1588)
1239 : : struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
1240 : : struct dpaa2_dev_priv *priv = eth_data->dev_private;
1241 : : struct dpaa2_annot_hdr *annotation;
1242 : : void *v_addr;
1243 : : struct rte_mbuf *mbuf;
1244 : : #endif
1245 : :
1246 [ # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
1247 : 0 : ret = dpaa2_affine_qbman_swp();
1248 [ # # ]: 0 : if (ret) {
1249 : 0 : DPAA2_PMD_ERR(
1250 : : "Failed to allocate IO portal, tid: %d",
1251 : : rte_gettid());
1252 : 0 : return 0;
1253 : : }
1254 : : }
1255 : 0 : swp = DPAA2_PER_LCORE_PORTAL;
1256 : :
1257 : : do {
1258 : 0 : dq_storage = dpaa2_q->q_storage[0]->dq_storage[0];
1259 : 0 : qbman_pull_desc_clear(&pulldesc);
1260 : 0 : qbman_pull_desc_set_fq(&pulldesc, fqid);
1261 : 0 : qbman_pull_desc_set_storage(&pulldesc, dq_storage,
1262 : : (size_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1);
1263 : :
1264 : 0 : qbman_pull_desc_set_numframes(&pulldesc, dpaa2_dqrr_size);
1265 : :
1266 : : while (1) {
1267 [ # # ]: 0 : if (qbman_swp_pull(swp, &pulldesc)) {
1268 : : DPAA2_PMD_DP_DEBUG("VDQ command is not issued."
1269 : : "QBMAN is busy");
1270 : : /* Portal was busy, try again */
1271 : : continue;
1272 : : }
1273 : : break;
1274 : : }
1275 : :
1276 : 0 : rte_prefetch0((void *)((size_t)(dq_storage + 1)));
1277 : : /* Check if the previous issued command is completed. */
1278 [ # # ]: 0 : while (!qbman_check_command_complete(dq_storage))
1279 : : ;
1280 : :
1281 : : num_pulled = 0;
1282 : : pending = 1;
1283 : : do {
1284 : : /* Loop until the dq_storage is updated with
1285 : : * new token by QBMAN
1286 : : */
1287 [ # # ]: 0 : while (!qbman_check_new_result(dq_storage))
1288 : : ;
1289 : 0 : rte_prefetch0((void *)((size_t)(dq_storage + 2)));
1290 : : /* Check whether Last Pull command is Expired and
1291 : : * setting Condition for Loop termination
1292 : : */
1293 [ # # ]: 0 : if (qbman_result_DQ_is_pull_complete(dq_storage)) {
1294 : : pending = 0;
1295 : : /* Check for valid frame. */
1296 : 0 : status = qbman_result_DQ_flags(dq_storage);
1297 [ # # ]: 0 : if (unlikely((status &
1298 : : QBMAN_DQ_STAT_VALIDFRAME) == 0))
1299 : 0 : continue;
1300 : : }
1301 [ # # ]: 0 : if (dpaa2_svr_family != SVR_LX2160A)
1302 : : /** Packet type is parsed from FRC for LX2160A.*/
1303 : 0 : dpaa2_dev_prefetch_next_psr(dq_storage);
1304 : :
1305 : 0 : fd = qbman_result_DQ_fd(dq_storage);
1306 : 0 : bpid = DPAA2_GET_FD_BPID(fd);
1307 : :
1308 : : /* Create a release descriptor required for releasing
1309 : : * buffers into QBMAN
1310 : : */
1311 : 0 : qbman_release_desc_clear(&releasedesc);
1312 : 0 : qbman_release_desc_set_bpid(&releasedesc, bpid);
1313 : :
1314 : 0 : buf = DPAA2_GET_FD_ADDR(fd);
1315 : : /* feed them to bman */
1316 : : do {
1317 : 0 : ret = qbman_swp_release(swp, &releasedesc,
1318 : : &buf, 1);
1319 [ # # ]: 0 : } while (ret == -EBUSY);
1320 : :
1321 : 0 : dq_storage++;
1322 : 0 : num_tx_conf++;
1323 : 0 : num_pulled++;
1324 : : #if defined(RTE_LIBRTE_IEEE1588)
1325 : : v_addr = DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd));
1326 : : mbuf = DPAA2_INLINE_MBUF_FROM_BUF(v_addr,
1327 : : rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size);
1328 : :
1329 : : if (mbuf->ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST) {
1330 : : annotation = (struct dpaa2_annot_hdr *)((size_t)
1331 : : DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd)) +
1332 : : DPAA2_FD_PTA_SIZE);
1333 : : priv->tx_timestamp = annotation->word2;
1334 : : }
1335 : : #endif
1336 [ # # ]: 0 : } while (pending);
1337 : :
1338 : : /* Last VDQ provided all packets and more packets are requested */
1339 [ # # ]: 0 : } while (num_pulled == dpaa2_dqrr_size);
1340 : :
1341 : 0 : dpaa2_q->rx_pkts += num_tx_conf;
1342 : :
1343 : 0 : return num_tx_conf;
1344 : : }
1345 : :
1346 : : /* Configure the egress frame annotation for timestamp update */
1347 : : static void enable_tx_tstamp(struct qbman_fd *fd)
1348 : : {
1349 : : struct dpaa2_faead *fd_faead;
1350 : :
1351 : : /* Set frame annotation status field as valid */
1352 : : (fd)->simple.frc |= DPAA2_FD_FRC_FASV;
1353 : :
1354 : : /* Set frame annotation egress action descriptor as valid */
1355 : : (fd)->simple.frc |= DPAA2_FD_FRC_FAEADV;
1356 : :
1357 : : /* Set Annotation Length as 128B */
1358 : : (fd)->simple.ctrl |= DPAA2_FD_CTRL_ASAL;
1359 : :
1360 : : /* enable update of confirmation frame annotation */
1361 : : fd_faead = (struct dpaa2_faead *)((size_t)
1362 : : DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd)) +
1363 : : DPAA2_FD_PTA_SIZE + DPAA2_FD_HW_ANNOT_FAEAD_OFFSET);
1364 : : fd_faead->ctrl = DPAA2_ANNOT_FAEAD_A2V | DPAA2_ANNOT_FAEAD_UPDV |
1365 : : DPAA2_ANNOT_FAEAD_UPD;
1366 : : }
1367 : :
1368 : : /*
1369 : : * Callback to handle sending packets through WRIOP based interface
1370 : : */
1371 : : uint16_t
1372 : 0 : dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
1373 : 0 : {
1374 : : /* Function to transmit the frames to given device and VQ*/
1375 : : uint32_t loop, retry_count;
1376 : : int32_t ret;
1377 : : struct qbman_fd fd_arr[MAX_TX_RING_SLOTS];
1378 : : struct rte_mbuf *mi;
1379 : : uint32_t frames_to_send;
1380 : : struct rte_mempool *mp;
1381 : : struct qbman_eq_desc eqdesc;
1382 : : struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;
1383 : : struct qbman_swp *swp;
1384 : : uint16_t num_tx = 0;
1385 : : uint16_t bpid;
1386 : 0 : struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
1387 : 0 : struct dpaa2_dev_priv *priv = eth_data->dev_private;
1388 : 0 : uint32_t flags[MAX_TX_RING_SLOTS] = {0};
1389 : 0 : struct sw_buf_free buf_to_free[DPAA2_MAX_SGS * dpaa2_dqrr_size];
1390 : 0 : uint32_t free_count = 0;
1391 : :
1392 [ # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
1393 : 0 : ret = dpaa2_affine_qbman_swp();
1394 [ # # ]: 0 : if (ret) {
1395 : 0 : DPAA2_PMD_ERR(
1396 : : "Failed to allocate IO portal, tid: %d",
1397 : : rte_gettid());
1398 : 0 : return 0;
1399 : : }
1400 : : }
1401 : 0 : swp = DPAA2_PER_LCORE_PORTAL;
1402 : :
1403 : : DPAA2_PMD_DP_DEBUG("===> eth_data =%p, fqid =%d",
1404 : : eth_data, dpaa2_q->fqid);
1405 : :
1406 : : #ifdef RTE_LIBRTE_IEEE1588
1407 : : /* IEEE1588 driver need pointer to tx confirmation queue
1408 : : * corresponding to last packet transmitted for reading
1409 : : * the timestamp
1410 : : */
1411 : : if ((*bufs)->ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST) {
1412 : : priv->next_tx_conf_queue = dpaa2_q->tx_conf_queue;
1413 : : dpaa2_dev_tx_conf(dpaa2_q->tx_conf_queue);
1414 : : priv->tx_timestamp = 0;
1415 : : }
1416 : : #endif
1417 : :
1418 : : /*Prepare enqueue descriptor*/
1419 : 0 : qbman_eq_desc_clear(&eqdesc);
1420 : 0 : qbman_eq_desc_set_no_orp(&eqdesc, DPAA2_EQ_RESP_ERR_FQ);
1421 : 0 : qbman_eq_desc_set_fq(&eqdesc, dpaa2_q->fqid);
1422 : :
1423 : : /*Clear the unused FD fields before sending*/
1424 [ # # ]: 0 : while (nb_pkts) {
1425 : : /*Check if the queue is congested*/
1426 : : retry_count = 0;
1427 [ # # ]: 0 : while (qbman_result_SCN_state(dpaa2_q->cscn)) {
1428 : 0 : retry_count++;
1429 : : /* Retry for some time before giving up */
1430 [ # # ]: 0 : if (retry_count > CONG_RETRY_COUNT) {
1431 [ # # ]: 0 : if (dpaa2_q->tm_sw_td)
1432 : 0 : goto sw_td;
1433 : 0 : goto skip_tx;
1434 : : }
1435 : : }
1436 : :
1437 : 0 : frames_to_send = (nb_pkts > dpaa2_eqcr_size) ?
1438 [ # # ]: 0 : dpaa2_eqcr_size : nb_pkts;
1439 : :
1440 [ # # ]: 0 : for (loop = 0; loop < frames_to_send; loop++) {
1441 [ # # ]: 0 : if (*dpaa2_seqn(*bufs)) {
1442 : 0 : uint8_t dqrr_index = *dpaa2_seqn(*bufs) - 1;
1443 : :
1444 : 0 : flags[loop] = QBMAN_ENQUEUE_FLAG_DCA |
1445 : : dqrr_index;
1446 : 0 : DPAA2_PER_LCORE_DQRR_SIZE--;
1447 : 0 : DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C(1) << dqrr_index);
1448 : 0 : *dpaa2_seqn(*bufs) = DPAA2_INVALID_MBUF_SEQN;
1449 : : }
1450 : :
1451 [ # # ]: 0 : if (likely(RTE_MBUF_DIRECT(*bufs))) {
1452 : 0 : mp = (*bufs)->pool;
1453 : : /* Check the basic scenario and set
1454 : : * the FD appropriately here itself.
1455 : : */
1456 [ # # # # : 0 : if (likely(mp && mp->ops_index ==
# # # # ]
1457 : : priv->bp_list->dpaa2_ops_index &&
1458 : : (*bufs)->nb_segs == 1 &&
1459 : : rte_mbuf_refcnt_read((*bufs)) == 1)) {
1460 [ # # ]: 0 : if (unlikely((*bufs)->ol_flags
1461 : : & RTE_MBUF_F_TX_VLAN)) {
1462 : : ret = rte_vlan_insert(bufs);
1463 [ # # ]: 0 : if (ret)
1464 : 0 : goto send_n_return;
1465 : : }
1466 : 0 : DPAA2_MBUF_TO_CONTIG_FD((*bufs),
1467 : : &fd_arr[loop], mempool_to_bpid(mp));
1468 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
1469 : : rte_mempool_check_cookies
1470 : : (rte_mempool_from_obj((void *)*bufs),
1471 : : (void **)bufs, 1, 0);
1472 : : #endif
1473 : 0 : bufs++;
1474 : : #ifdef RTE_LIBRTE_IEEE1588
1475 : : enable_tx_tstamp(&fd_arr[loop]);
1476 : : #endif
1477 : 0 : continue;
1478 : : }
1479 : : } else {
1480 : : mi = rte_mbuf_from_indirect(*bufs);
1481 : 0 : mp = mi->pool;
1482 : : }
1483 : :
1484 [ # # ]: 0 : if (unlikely(RTE_MBUF_HAS_EXTBUF(*bufs))) {
1485 [ # # ]: 0 : if (unlikely((*bufs)->nb_segs > 1)) {
1486 : 0 : mp = (*bufs)->pool;
1487 [ # # ]: 0 : if (eth_mbuf_to_sg_fd(*bufs,
1488 : : &fd_arr[loop],
1489 : : buf_to_free,
1490 : : &free_count,
1491 : : loop,
1492 : 0 : mempool_to_bpid(mp)))
1493 : 0 : goto send_n_return;
1494 : : } else {
1495 : 0 : eth_mbuf_to_fd(*bufs,
1496 : : &fd_arr[loop],
1497 : : buf_to_free,
1498 : : &free_count,
1499 : : loop, 0);
1500 : : }
1501 : 0 : bufs++;
1502 : : #ifdef RTE_LIBRTE_IEEE1588
1503 : : enable_tx_tstamp(&fd_arr[loop]);
1504 : : #endif
1505 : 0 : continue;
1506 : : }
1507 : :
1508 : : /* Not a hw_pkt pool allocated frame */
1509 [ # # # # ]: 0 : if (unlikely(!mp || !priv->bp_list)) {
1510 : 0 : DPAA2_PMD_ERR("Err: No buffer pool attached");
1511 : 0 : goto send_n_return;
1512 : : }
1513 : :
1514 [ # # ]: 0 : if (unlikely((*bufs)->ol_flags & RTE_MBUF_F_TX_VLAN)) {
1515 : : int ret = rte_vlan_insert(bufs);
1516 [ # # ]: 0 : if (ret)
1517 : 0 : goto send_n_return;
1518 : : }
1519 [ # # ]: 0 : if (mp->ops_index != priv->bp_list->dpaa2_ops_index) {
1520 : 0 : DPAA2_PMD_WARN("Non DPAA2 buffer pool");
1521 : : /* alloc should be from the default buffer pool
1522 : : * attached to this interface
1523 : : */
1524 : 0 : bpid = priv->bp_list->buf_pool.bpid;
1525 : :
1526 [ # # ]: 0 : if (unlikely((*bufs)->nb_segs > 1)) {
1527 : 0 : DPAA2_PMD_ERR("S/G support not added"
1528 : : " for non hw offload buffer");
1529 : 0 : goto send_n_return;
1530 : : }
1531 [ # # ]: 0 : if (eth_copy_mbuf_to_fd(*bufs,
1532 : : &fd_arr[loop], bpid)) {
1533 : 0 : goto send_n_return;
1534 : : }
1535 : : /* free the original packet */
1536 : 0 : rte_pktmbuf_free(*bufs);
1537 : : } else {
1538 : 0 : bpid = mempool_to_bpid(mp);
1539 [ # # ]: 0 : if (unlikely((*bufs)->nb_segs > 1)) {
1540 [ # # ]: 0 : if (eth_mbuf_to_sg_fd(*bufs,
1541 : : &fd_arr[loop],
1542 : : buf_to_free,
1543 : : &free_count,
1544 : : loop,
1545 : : bpid))
1546 : 0 : goto send_n_return;
1547 : : } else {
1548 : 0 : eth_mbuf_to_fd(*bufs,
1549 : : &fd_arr[loop],
1550 : : buf_to_free,
1551 : : &free_count,
1552 : : loop, bpid);
1553 : : }
1554 : : }
1555 : : #ifdef RTE_LIBRTE_IEEE1588
1556 : : enable_tx_tstamp(&fd_arr[loop]);
1557 : : #endif
1558 : 0 : bufs++;
1559 : : }
1560 : :
1561 : : loop = 0;
1562 : : retry_count = 0;
1563 [ # # ]: 0 : while (loop < frames_to_send) {
1564 : 0 : ret = qbman_swp_enqueue_multiple(swp, &eqdesc,
1565 : 0 : &fd_arr[loop], &flags[loop],
1566 : 0 : frames_to_send - loop);
1567 [ # # ]: 0 : if (unlikely(ret < 0)) {
1568 : 0 : retry_count++;
1569 [ # # ]: 0 : if (retry_count > DPAA2_MAX_TX_RETRY_COUNT) {
1570 : 0 : num_tx += loop;
1571 : : nb_pkts -= loop;
1572 : 0 : goto send_n_return;
1573 : : }
1574 : : } else {
1575 : 0 : loop += ret;
1576 : : retry_count = 0;
1577 : : }
1578 : : }
1579 : :
1580 : 0 : num_tx += loop;
1581 : 0 : nb_pkts -= loop;
1582 : : }
1583 : 0 : dpaa2_q->tx_pkts += num_tx;
1584 : :
1585 [ # # ]: 0 : for (loop = 0; loop < free_count; loop++) {
1586 [ # # ]: 0 : if (buf_to_free[loop].pkt_id < num_tx)
1587 [ # # ]: 0 : rte_pktmbuf_free_seg(buf_to_free[loop].seg);
1588 : : }
1589 : :
1590 : : return num_tx;
1591 : :
1592 : 0 : send_n_return:
1593 : : /* send any already prepared fd */
1594 [ # # ]: 0 : if (loop) {
1595 : : unsigned int i = 0;
1596 : :
1597 : : retry_count = 0;
1598 [ # # ]: 0 : while (i < loop) {
1599 : 0 : ret = qbman_swp_enqueue_multiple(swp, &eqdesc,
1600 : 0 : &fd_arr[i],
1601 : : &flags[i],
1602 : 0 : loop - i);
1603 [ # # ]: 0 : if (unlikely(ret < 0)) {
1604 : 0 : retry_count++;
1605 [ # # ]: 0 : if (retry_count > DPAA2_MAX_TX_RETRY_COUNT)
1606 : : break;
1607 : : } else {
1608 : 0 : i += ret;
1609 : : retry_count = 0;
1610 : : }
1611 : : }
1612 : 0 : num_tx += i;
1613 : : }
1614 : 0 : skip_tx:
1615 : 0 : dpaa2_q->tx_pkts += num_tx;
1616 [ # # ]: 0 : for (loop = 0; loop < free_count; loop++) {
1617 [ # # ]: 0 : if (buf_to_free[loop].pkt_id < num_tx)
1618 [ # # ]: 0 : rte_pktmbuf_free_seg(buf_to_free[loop].seg);
1619 : : }
1620 : :
1621 : : return num_tx;
1622 : : sw_td:
1623 [ # # ]: 0 : for (loop = 0; loop < free_count; loop++) {
1624 [ # # ]: 0 : if (buf_to_free[loop].pkt_id < num_tx)
1625 [ # # ]: 0 : rte_pktmbuf_free_seg(buf_to_free[loop].seg);
1626 : : }
1627 : :
1628 : : /* free the pending buffers */
1629 : 0 : rte_pktmbuf_free_bulk(bufs, nb_pkts);
1630 : :
1631 : 0 : num_tx += nb_pkts;
1632 : 0 : dpaa2_q->tx_pkts += num_tx;
1633 : :
1634 : 0 : return num_tx;
1635 : : }
1636 : :
1637 : : void
1638 : 0 : dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci,
1639 : : __rte_unused struct dpaa2_queue *dpaa2_q)
1640 : : {
1641 : 0 : struct dpaa2_dpio_dev *dpio_dev = DPAA2_PER_LCORE_DPIO;
1642 : : struct qbman_fd *fd;
1643 : : struct rte_mbuf *m;
1644 : :
1645 : 0 : fd = qbman_result_eqresp_fd(&dpio_dev->eqresp[eqresp_ci]);
1646 : :
1647 : : /* Setting port id does not matter as we are to free the mbuf */
1648 : 0 : m = eth_fd_to_mbuf(fd, 0);
1649 : 0 : rte_pktmbuf_free(m);
1650 : 0 : }
1651 : :
1652 : : static void
1653 : 0 : dpaa2_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q,
1654 : : struct rte_mbuf *m,
1655 : : struct qbman_eq_desc *eqdesc)
1656 : : {
1657 : 0 : struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
1658 : 0 : struct dpaa2_dev_priv *priv = eth_data->dev_private;
1659 : 0 : struct dpaa2_dpio_dev *dpio_dev = DPAA2_PER_LCORE_DPIO;
1660 : : struct eqresp_metadata *eqresp_meta;
1661 : : uint16_t orpid, seqnum;
1662 : : uint8_t dq_idx;
1663 : :
1664 : 0 : qbman_eq_desc_set_fq(eqdesc, dpaa2_q->fqid);
1665 : :
1666 [ # # ]: 0 : if (*dpaa2_seqn(m) & DPAA2_ENQUEUE_FLAG_ORP) {
1667 : 0 : orpid = (*dpaa2_seqn(m) & DPAA2_EQCR_OPRID_MASK) >>
1668 : : DPAA2_EQCR_OPRID_SHIFT;
1669 : : seqnum = (*dpaa2_seqn(m) & DPAA2_EQCR_SEQNUM_MASK) >>
1670 : : DPAA2_EQCR_SEQNUM_SHIFT;
1671 : :
1672 [ # # ]: 0 : if (!priv->en_loose_ordered) {
1673 : 0 : qbman_eq_desc_set_orp(eqdesc, 1, orpid, seqnum, 0);
1674 : 0 : qbman_eq_desc_set_response(eqdesc, (uint64_t)
1675 : 0 : DPAA2_VADDR_TO_IOVA(&dpio_dev->eqresp[
1676 : : dpio_dev->eqresp_pi]), 1);
1677 : 0 : qbman_eq_desc_set_token(eqdesc, 1);
1678 : :
1679 : 0 : eqresp_meta = &dpio_dev->eqresp_meta[
1680 : 0 : dpio_dev->eqresp_pi];
1681 : 0 : eqresp_meta->dpaa2_q = dpaa2_q;
1682 : 0 : eqresp_meta->mp = m->pool;
1683 : :
1684 : : dpio_dev->eqresp_pi + 1 < MAX_EQ_RESP_ENTRIES ?
1685 [ # # ]: 0 : dpio_dev->eqresp_pi++ :
1686 : 0 : (dpio_dev->eqresp_pi = 0);
1687 : : } else {
1688 : 0 : qbman_eq_desc_set_orp(eqdesc, 0, orpid, seqnum, 0);
1689 : : }
1690 : : } else {
1691 : 0 : dq_idx = *dpaa2_seqn(m) - 1;
1692 : 0 : qbman_eq_desc_set_dca(eqdesc, 1, dq_idx, 0);
1693 : 0 : DPAA2_PER_LCORE_DQRR_SIZE--;
1694 : 0 : DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C(1) << dq_idx);
1695 : : }
1696 : 0 : *dpaa2_seqn(m) = DPAA2_INVALID_MBUF_SEQN;
1697 : 0 : }
1698 : :
1699 : : RTE_EXPORT_INTERNAL_SYMBOL(dpaa2_dev_tx_multi_txq_ordered)
1700 : : uint16_t
1701 : 0 : dpaa2_dev_tx_multi_txq_ordered(void **queue,
1702 : : struct rte_mbuf **bufs, uint16_t nb_pkts)
1703 : 0 : {
1704 : : /* Function to transmit the frames to multiple queues respectively.*/
1705 : : uint32_t loop, i, retry_count;
1706 : : int32_t ret;
1707 : : struct qbman_fd fd_arr[MAX_TX_RING_SLOTS];
1708 : : uint32_t frames_to_send, num_free_eq_desc = 0;
1709 : : struct rte_mempool *mp;
1710 : : struct qbman_eq_desc eqdesc[MAX_TX_RING_SLOTS];
1711 : : struct dpaa2_queue *dpaa2_q[MAX_TX_RING_SLOTS];
1712 : : struct qbman_swp *swp;
1713 : : uint16_t bpid;
1714 : : struct rte_mbuf *mi;
1715 : : struct rte_eth_dev_data *eth_data;
1716 : : struct dpaa2_dev_priv *priv;
1717 : : struct dpaa2_queue *order_sendq;
1718 : 0 : struct sw_buf_free buf_to_free[DPAA2_MAX_SGS * dpaa2_dqrr_size];
1719 : 0 : uint32_t free_count = 0;
1720 : :
1721 [ # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
1722 : 0 : ret = dpaa2_affine_qbman_swp();
1723 [ # # ]: 0 : if (ret) {
1724 : 0 : DPAA2_PMD_ERR(
1725 : : "Failed to allocate IO portal, tid: %d",
1726 : : rte_gettid());
1727 : 0 : return 0;
1728 : : }
1729 : : }
1730 : 0 : swp = DPAA2_PER_LCORE_PORTAL;
1731 : :
1732 : 0 : frames_to_send = (nb_pkts > dpaa2_eqcr_size) ?
1733 [ # # ]: 0 : dpaa2_eqcr_size : nb_pkts;
1734 : :
1735 [ # # ]: 0 : for (loop = 0; loop < frames_to_send; loop++) {
1736 : 0 : dpaa2_q[loop] = (struct dpaa2_queue *)queue[loop];
1737 : 0 : eth_data = dpaa2_q[loop]->eth_data;
1738 : 0 : priv = eth_data->dev_private;
1739 [ # # ]: 0 : if (!priv->en_loose_ordered) {
1740 [ # # ]: 0 : if (*dpaa2_seqn(*bufs) & DPAA2_ENQUEUE_FLAG_ORP) {
1741 [ # # ]: 0 : if (!num_free_eq_desc) {
1742 : 0 : num_free_eq_desc = dpaa2_free_eq_descriptors();
1743 [ # # ]: 0 : if (!num_free_eq_desc)
1744 : 0 : goto send_frames;
1745 : : }
1746 : 0 : num_free_eq_desc--;
1747 : : }
1748 : : }
1749 : :
1750 : : DPAA2_PMD_DP_DEBUG("===> eth_data =%p, fqid =%d",
1751 : : eth_data, dpaa2_q[loop]->fqid);
1752 : :
1753 : : /* Check if the queue is congested */
1754 : : retry_count = 0;
1755 [ # # ]: 0 : while (qbman_result_SCN_state(dpaa2_q[loop]->cscn)) {
1756 : 0 : retry_count++;
1757 : : /* Retry for some time before giving up */
1758 [ # # ]: 0 : if (retry_count > CONG_RETRY_COUNT)
1759 : 0 : goto send_frames;
1760 : : }
1761 : :
1762 : : /* Prepare enqueue descriptor */
1763 : 0 : qbman_eq_desc_clear(&eqdesc[loop]);
1764 : :
1765 [ # # # # ]: 0 : if (*dpaa2_seqn(*bufs) && priv->en_ordered) {
1766 : 0 : order_sendq = (struct dpaa2_queue *)priv->tx_vq[0];
1767 : 0 : dpaa2_set_enqueue_descriptor(order_sendq,
1768 : : (*bufs),
1769 : : &eqdesc[loop]);
1770 : : } else {
1771 : 0 : qbman_eq_desc_set_no_orp(&eqdesc[loop],
1772 : : DPAA2_EQ_RESP_ERR_FQ);
1773 : 0 : qbman_eq_desc_set_fq(&eqdesc[loop],
1774 : : dpaa2_q[loop]->fqid);
1775 : : }
1776 : :
1777 [ # # ]: 0 : if (likely(RTE_MBUF_DIRECT(*bufs))) {
1778 : 0 : mp = (*bufs)->pool;
1779 : : /* Check the basic scenario and set
1780 : : * the FD appropriately here itself.
1781 : : */
1782 [ # # # # : 0 : if (likely(mp && mp->ops_index ==
# # # # ]
1783 : : priv->bp_list->dpaa2_ops_index &&
1784 : : (*bufs)->nb_segs == 1 &&
1785 : : rte_mbuf_refcnt_read((*bufs)) == 1)) {
1786 [ # # ]: 0 : if (unlikely((*bufs)->ol_flags
1787 : : & RTE_MBUF_F_TX_VLAN)) {
1788 : : ret = rte_vlan_insert(bufs);
1789 [ # # ]: 0 : if (ret)
1790 : 0 : goto send_frames;
1791 : : }
1792 : 0 : DPAA2_MBUF_TO_CONTIG_FD((*bufs),
1793 : : &fd_arr[loop],
1794 : : mempool_to_bpid(mp));
1795 : 0 : bufs++;
1796 : 0 : continue;
1797 : : }
1798 : : } else {
1799 : : mi = rte_mbuf_from_indirect(*bufs);
1800 : 0 : mp = mi->pool;
1801 : : }
1802 : : /* Not a hw_pkt pool allocated frame */
1803 [ # # # # ]: 0 : if (unlikely(!mp || !priv->bp_list)) {
1804 : 0 : DPAA2_PMD_ERR("Err: No buffer pool attached");
1805 : 0 : goto send_frames;
1806 : : }
1807 : :
1808 [ # # ]: 0 : if (mp->ops_index != priv->bp_list->dpaa2_ops_index) {
1809 : 0 : DPAA2_PMD_WARN("Non DPAA2 buffer pool");
1810 : : /* alloc should be from the default buffer pool
1811 : : * attached to this interface
1812 : : */
1813 : 0 : bpid = priv->bp_list->buf_pool.bpid;
1814 : :
1815 [ # # ]: 0 : if (unlikely((*bufs)->nb_segs > 1)) {
1816 : 0 : DPAA2_PMD_ERR(
1817 : : "S/G not supp for non hw offload buffer");
1818 : 0 : goto send_frames;
1819 : : }
1820 [ # # ]: 0 : if (eth_copy_mbuf_to_fd(*bufs,
1821 : : &fd_arr[loop], bpid)) {
1822 : 0 : goto send_frames;
1823 : : }
1824 : : /* free the original packet */
1825 : 0 : rte_pktmbuf_free(*bufs);
1826 : : } else {
1827 : 0 : bpid = mempool_to_bpid(mp);
1828 [ # # ]: 0 : if (unlikely((*bufs)->nb_segs > 1)) {
1829 [ # # ]: 0 : if (eth_mbuf_to_sg_fd(*bufs,
1830 : : &fd_arr[loop],
1831 : : buf_to_free,
1832 : : &free_count,
1833 : : loop,
1834 : : bpid))
1835 : 0 : goto send_frames;
1836 : : } else {
1837 : 0 : eth_mbuf_to_fd(*bufs,
1838 : : &fd_arr[loop],
1839 : : buf_to_free,
1840 : : &free_count,
1841 : : loop, bpid);
1842 : : }
1843 : : }
1844 : :
1845 : 0 : bufs++;
1846 : : }
1847 : :
1848 : 0 : send_frames:
1849 : : frames_to_send = loop;
1850 : : loop = 0;
1851 : : retry_count = 0;
1852 [ # # ]: 0 : while (loop < frames_to_send) {
1853 : 0 : ret = qbman_swp_enqueue_multiple_desc(swp, &eqdesc[loop],
1854 : 0 : &fd_arr[loop],
1855 : 0 : frames_to_send - loop);
1856 [ # # ]: 0 : if (likely(ret > 0)) {
1857 : 0 : loop += ret;
1858 : : retry_count = 0;
1859 : : } else {
1860 : 0 : retry_count++;
1861 [ # # ]: 0 : if (retry_count > DPAA2_MAX_TX_RETRY_COUNT)
1862 : : break;
1863 : : }
1864 : : }
1865 : :
1866 [ # # ]: 0 : for (i = 0; i < free_count; i++) {
1867 [ # # ]: 0 : if (buf_to_free[i].pkt_id < loop)
1868 [ # # ]: 0 : rte_pktmbuf_free_seg(buf_to_free[i].seg);
1869 : : }
1870 : 0 : return loop;
1871 : : }
1872 : :
1873 : : /* Callback to handle sending ordered packets through WRIOP based interface */
1874 : : uint16_t
1875 : 0 : dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
1876 : 0 : {
1877 : : /* Function to transmit the frames to given device and VQ*/
1878 : : struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;
1879 : 0 : struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
1880 : 0 : struct dpaa2_dev_priv *priv = eth_data->dev_private;
1881 : 0 : struct dpaa2_queue *order_sendq = (struct dpaa2_queue *)priv->tx_vq[0];
1882 : : struct qbman_fd fd_arr[MAX_TX_RING_SLOTS];
1883 : : struct rte_mbuf *mi;
1884 : : struct rte_mempool *mp;
1885 : : struct qbman_eq_desc eqdesc[MAX_TX_RING_SLOTS];
1886 : : struct qbman_swp *swp;
1887 : : uint32_t frames_to_send, num_free_eq_desc;
1888 : : uint32_t loop, retry_count;
1889 : : int32_t ret;
1890 : : uint16_t num_tx = 0;
1891 : : uint16_t bpid;
1892 : 0 : struct sw_buf_free buf_to_free[DPAA2_MAX_SGS * dpaa2_dqrr_size];
1893 : 0 : uint32_t free_count = 0;
1894 : :
1895 [ # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
1896 : 0 : ret = dpaa2_affine_qbman_swp();
1897 [ # # ]: 0 : if (ret) {
1898 : 0 : DPAA2_PMD_ERR(
1899 : : "Failed to allocate IO portal, tid: %d",
1900 : : rte_gettid());
1901 : 0 : return 0;
1902 : : }
1903 : : }
1904 : 0 : swp = DPAA2_PER_LCORE_PORTAL;
1905 : :
1906 : : DPAA2_PMD_DP_DEBUG("===> eth_data =%p, fqid =%d",
1907 : : eth_data, dpaa2_q->fqid);
1908 : :
1909 : : /* This would also handle normal and atomic queues as any type
1910 : : * of packet can be enqueued when ordered queues are being used.
1911 : : */
1912 [ # # ]: 0 : while (nb_pkts) {
1913 : : /*Check if the queue is congested*/
1914 : : retry_count = 0;
1915 [ # # ]: 0 : while (qbman_result_SCN_state(dpaa2_q->cscn)) {
1916 : 0 : retry_count++;
1917 : : /* Retry for some time before giving up */
1918 [ # # ]: 0 : if (retry_count > CONG_RETRY_COUNT) {
1919 [ # # ]: 0 : if (dpaa2_q->tm_sw_td)
1920 : 0 : goto sw_td;
1921 : 0 : goto skip_tx;
1922 : : }
1923 : : }
1924 : :
1925 : 0 : frames_to_send = (nb_pkts > dpaa2_eqcr_size) ?
1926 [ # # ]: 0 : dpaa2_eqcr_size : nb_pkts;
1927 : :
1928 [ # # ]: 0 : if (!priv->en_loose_ordered) {
1929 [ # # ]: 0 : if (*dpaa2_seqn(*bufs) & DPAA2_ENQUEUE_FLAG_ORP) {
1930 : 0 : num_free_eq_desc = dpaa2_free_eq_descriptors();
1931 : : if (num_free_eq_desc < frames_to_send)
1932 : : frames_to_send = num_free_eq_desc;
1933 : : }
1934 : : }
1935 : :
1936 [ # # ]: 0 : for (loop = 0; loop < frames_to_send; loop++) {
1937 : : /*Prepare enqueue descriptor*/
1938 : 0 : qbman_eq_desc_clear(&eqdesc[loop]);
1939 : :
1940 [ # # ]: 0 : if (*dpaa2_seqn(*bufs)) {
1941 : : /* Use only queue 0 for Tx in case of atomic/
1942 : : * ordered packets as packets can get unordered
1943 : : * when being transmitted out from the interface
1944 : : */
1945 : 0 : dpaa2_set_enqueue_descriptor(order_sendq,
1946 : : (*bufs),
1947 : : &eqdesc[loop]);
1948 : : } else {
1949 : 0 : qbman_eq_desc_set_no_orp(&eqdesc[loop],
1950 : : DPAA2_EQ_RESP_ERR_FQ);
1951 : 0 : qbman_eq_desc_set_fq(&eqdesc[loop],
1952 : : dpaa2_q->fqid);
1953 : : }
1954 : :
1955 [ # # ]: 0 : if (likely(RTE_MBUF_DIRECT(*bufs))) {
1956 : 0 : mp = (*bufs)->pool;
1957 : : /* Check the basic scenario and set
1958 : : * the FD appropriately here itself.
1959 : : */
1960 [ # # # # : 0 : if (likely(mp && mp->ops_index ==
# # # # ]
1961 : : priv->bp_list->dpaa2_ops_index &&
1962 : : (*bufs)->nb_segs == 1 &&
1963 : : rte_mbuf_refcnt_read((*bufs)) == 1)) {
1964 [ # # ]: 0 : if (unlikely((*bufs)->ol_flags
1965 : : & RTE_MBUF_F_TX_VLAN)) {
1966 : : ret = rte_vlan_insert(bufs);
1967 [ # # ]: 0 : if (ret)
1968 : 0 : goto send_n_return;
1969 : : }
1970 : 0 : DPAA2_MBUF_TO_CONTIG_FD((*bufs),
1971 : : &fd_arr[loop],
1972 : : mempool_to_bpid(mp));
1973 : 0 : bufs++;
1974 : 0 : continue;
1975 : : }
1976 : : } else {
1977 : : mi = rte_mbuf_from_indirect(*bufs);
1978 : 0 : mp = mi->pool;
1979 : : }
1980 : : /* Not a hw_pkt pool allocated frame */
1981 [ # # # # ]: 0 : if (unlikely(!mp || !priv->bp_list)) {
1982 : 0 : DPAA2_PMD_ERR("Err: No buffer pool attached");
1983 : 0 : goto send_n_return;
1984 : : }
1985 : :
1986 [ # # ]: 0 : if (mp->ops_index != priv->bp_list->dpaa2_ops_index) {
1987 : 0 : DPAA2_PMD_WARN("Non DPAA2 buffer pool");
1988 : : /* alloc should be from the default buffer pool
1989 : : * attached to this interface
1990 : : */
1991 : 0 : bpid = priv->bp_list->buf_pool.bpid;
1992 : :
1993 [ # # ]: 0 : if (unlikely((*bufs)->nb_segs > 1)) {
1994 : 0 : DPAA2_PMD_ERR(
1995 : : "S/G not supp for non hw offload buffer");
1996 : 0 : goto send_n_return;
1997 : : }
1998 [ # # ]: 0 : if (eth_copy_mbuf_to_fd(*bufs,
1999 : : &fd_arr[loop], bpid)) {
2000 : 0 : goto send_n_return;
2001 : : }
2002 : : /* free the original packet */
2003 : 0 : rte_pktmbuf_free(*bufs);
2004 : : } else {
2005 : 0 : bpid = mempool_to_bpid(mp);
2006 [ # # ]: 0 : if (unlikely((*bufs)->nb_segs > 1)) {
2007 [ # # ]: 0 : if (eth_mbuf_to_sg_fd(*bufs,
2008 : : &fd_arr[loop],
2009 : : buf_to_free,
2010 : : &free_count,
2011 : : loop,
2012 : : bpid))
2013 : 0 : goto send_n_return;
2014 : : } else {
2015 : 0 : eth_mbuf_to_fd(*bufs,
2016 : : &fd_arr[loop],
2017 : : buf_to_free,
2018 : : &free_count,
2019 : : loop, bpid);
2020 : : }
2021 : : }
2022 : 0 : bufs++;
2023 : : }
2024 : :
2025 : : loop = 0;
2026 : : retry_count = 0;
2027 [ # # ]: 0 : while (loop < frames_to_send) {
2028 : 0 : ret = qbman_swp_enqueue_multiple_desc(swp,
2029 : 0 : &eqdesc[loop], &fd_arr[loop],
2030 : 0 : frames_to_send - loop);
2031 [ # # ]: 0 : if (unlikely(ret < 0)) {
2032 : 0 : retry_count++;
2033 [ # # ]: 0 : if (retry_count > DPAA2_MAX_TX_RETRY_COUNT) {
2034 : 0 : num_tx += loop;
2035 : : nb_pkts -= loop;
2036 : 0 : goto send_n_return;
2037 : : }
2038 : : } else {
2039 : 0 : loop += ret;
2040 : : retry_count = 0;
2041 : : }
2042 : : }
2043 : :
2044 : 0 : num_tx += loop;
2045 : 0 : nb_pkts -= loop;
2046 : : }
2047 : 0 : dpaa2_q->tx_pkts += num_tx;
2048 [ # # ]: 0 : for (loop = 0; loop < free_count; loop++) {
2049 [ # # ]: 0 : if (buf_to_free[loop].pkt_id < num_tx)
2050 [ # # ]: 0 : rte_pktmbuf_free_seg(buf_to_free[loop].seg);
2051 : : }
2052 : :
2053 : : return num_tx;
2054 : :
2055 : 0 : send_n_return:
2056 : : /* send any already prepared fd */
2057 [ # # ]: 0 : if (loop) {
2058 : : unsigned int i = 0;
2059 : :
2060 : : retry_count = 0;
2061 [ # # ]: 0 : while (i < loop) {
2062 : 0 : ret = qbman_swp_enqueue_multiple_desc(swp,
2063 : 0 : &eqdesc[i], &fd_arr[i], loop - i);
2064 [ # # ]: 0 : if (unlikely(ret < 0)) {
2065 : 0 : retry_count++;
2066 [ # # ]: 0 : if (retry_count > DPAA2_MAX_TX_RETRY_COUNT)
2067 : : break;
2068 : : } else {
2069 : 0 : i += ret;
2070 : : retry_count = 0;
2071 : : }
2072 : : }
2073 : 0 : num_tx += i;
2074 : : }
2075 : 0 : skip_tx:
2076 : 0 : dpaa2_q->tx_pkts += num_tx;
2077 [ # # ]: 0 : for (loop = 0; loop < free_count; loop++) {
2078 [ # # ]: 0 : if (buf_to_free[loop].pkt_id < num_tx)
2079 [ # # ]: 0 : rte_pktmbuf_free_seg(buf_to_free[loop].seg);
2080 : : }
2081 : :
2082 : : return num_tx;
2083 : : sw_td:
2084 [ # # ]: 0 : for (loop = 0; loop < free_count; loop++) {
2085 [ # # ]: 0 : if (buf_to_free[loop].pkt_id < num_tx)
2086 [ # # ]: 0 : rte_pktmbuf_free_seg(buf_to_free[loop].seg);
2087 : : }
2088 : :
2089 : : /* free the pending buffers */
2090 : 0 : rte_pktmbuf_free_bulk(bufs, nb_pkts);
2091 : :
2092 : 0 : num_tx += nb_pkts;
2093 : 0 : dpaa2_q->tx_pkts += num_tx;
2094 : :
2095 : 0 : return num_tx;
2096 : : }
2097 : :
2098 : : /* This function loopbacks all the received packets.*/
2099 : : uint16_t
2100 : 0 : dpaa2_dev_loopback_rx(void *queue,
2101 : : struct rte_mbuf **bufs __rte_unused,
2102 : : uint16_t nb_pkts)
2103 : : {
2104 : : /* Function receive frames for a given device and VQ*/
2105 : : struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;
2106 : : struct qbman_result *dq_storage, *dq_storage1 = NULL;
2107 : 0 : uint32_t fqid = dpaa2_q->fqid;
2108 : : int ret, num_rx = 0, num_tx = 0, pull_size;
2109 : : uint8_t pending, status;
2110 : : struct qbman_swp *swp;
2111 : : struct qbman_fd *fd[DPAA2_LX2_DQRR_RING_SIZE];
2112 : : struct qbman_pull_desc pulldesc;
2113 : : struct qbman_eq_desc eqdesc;
2114 : : struct queue_storage_info_t *q_storage;
2115 : 0 : struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
2116 : 0 : struct dpaa2_dev_priv *priv = eth_data->dev_private;
2117 [ # # ]: 0 : struct dpaa2_queue *tx_q = priv->tx_vq[0];
2118 : : /* todo - currently we are using 1st TX queue only for loopback*/
2119 : :
2120 : 0 : q_storage = dpaa2_q->q_storage[rte_lcore_id()];
2121 [ # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_ETHRX_DPIO)) {
2122 : 0 : ret = dpaa2_affine_qbman_ethrx_swp();
2123 [ # # ]: 0 : if (ret) {
2124 : 0 : DPAA2_PMD_ERR("Failure in affining portal");
2125 : 0 : return 0;
2126 : : }
2127 : : }
2128 : 0 : swp = DPAA2_PER_LCORE_ETHRX_PORTAL;
2129 [ # # ]: 0 : pull_size = (nb_pkts > dpaa2_dqrr_size) ? dpaa2_dqrr_size : nb_pkts;
2130 [ # # ]: 0 : if (unlikely(!q_storage->active_dqs)) {
2131 : 0 : q_storage->toggle = 0;
2132 : 0 : dq_storage = q_storage->dq_storage[q_storage->toggle];
2133 : 0 : q_storage->last_num_pkts = pull_size;
2134 : 0 : qbman_pull_desc_clear(&pulldesc);
2135 : 0 : qbman_pull_desc_set_numframes(&pulldesc,
2136 : 0 : q_storage->last_num_pkts);
2137 : 0 : qbman_pull_desc_set_fq(&pulldesc, fqid);
2138 : 0 : qbman_pull_desc_set_storage(&pulldesc, dq_storage,
2139 : : (size_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1);
2140 [ # # ]: 0 : if (check_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index)) {
2141 [ # # ]: 0 : while (!qbman_check_command_complete(
2142 : : get_swp_active_dqs(
2143 : 0 : DPAA2_PER_LCORE_ETHRX_DPIO->index)))
2144 : : ;
2145 : 0 : clear_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index);
2146 : : }
2147 : : while (1) {
2148 [ # # ]: 0 : if (qbman_swp_pull(swp, &pulldesc)) {
2149 : : DPAA2_PMD_DP_DEBUG(
2150 : : "VDQ command not issued.QBMAN busy");
2151 : : /* Portal was busy, try again */
2152 : : continue;
2153 : : }
2154 : : break;
2155 : : }
2156 : 0 : q_storage->active_dqs = dq_storage;
2157 : 0 : q_storage->active_dpio_id = DPAA2_PER_LCORE_ETHRX_DPIO->index;
2158 : 0 : set_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index,
2159 : : dq_storage);
2160 : : }
2161 : :
2162 : 0 : dq_storage = q_storage->active_dqs;
2163 : : rte_prefetch0((void *)(size_t)(dq_storage));
2164 : 0 : rte_prefetch0((void *)(size_t)(dq_storage + 1));
2165 : :
2166 : : /* Prepare next pull descriptor. This will give space for the
2167 : : * prefetching done on DQRR entries
2168 : : */
2169 : 0 : q_storage->toggle ^= 1;
2170 : 0 : dq_storage1 = q_storage->dq_storage[q_storage->toggle];
2171 : 0 : qbman_pull_desc_clear(&pulldesc);
2172 : 0 : qbman_pull_desc_set_numframes(&pulldesc, pull_size);
2173 : 0 : qbman_pull_desc_set_fq(&pulldesc, fqid);
2174 : 0 : qbman_pull_desc_set_storage(&pulldesc, dq_storage1,
2175 : : (size_t)(DPAA2_VADDR_TO_IOVA(dq_storage1)), 1);
2176 : :
2177 : : /*Prepare enqueue descriptor*/
2178 : 0 : qbman_eq_desc_clear(&eqdesc);
2179 : 0 : qbman_eq_desc_set_no_orp(&eqdesc, DPAA2_EQ_RESP_ERR_FQ);
2180 : 0 : qbman_eq_desc_set_response(&eqdesc, 0, 0);
2181 : 0 : qbman_eq_desc_set_fq(&eqdesc, tx_q->fqid);
2182 : :
2183 : : /* Check if the previous issued command is completed.
2184 : : * Also seems like the SWP is shared between the Ethernet Driver
2185 : : * and the SEC driver.
2186 : : */
2187 [ # # ]: 0 : while (!qbman_check_command_complete(dq_storage))
2188 : : ;
2189 [ # # ]: 0 : if (dq_storage == get_swp_active_dqs(q_storage->active_dpio_id))
2190 : : clear_swp_active_dqs(q_storage->active_dpio_id);
2191 : :
2192 : : pending = 1;
2193 : :
2194 : : do {
2195 : : /* Loop until the dq_storage is updated with
2196 : : * new token by QBMAN
2197 : : */
2198 [ # # ]: 0 : while (!qbman_check_new_result(dq_storage))
2199 : : ;
2200 : 0 : rte_prefetch0((void *)((size_t)(dq_storage + 2)));
2201 : : /* Check whether Last Pull command is Expired and
2202 : : * setting Condition for Loop termination
2203 : : */
2204 [ # # ]: 0 : if (qbman_result_DQ_is_pull_complete(dq_storage)) {
2205 : : pending = 0;
2206 : : /* Check for valid frame. */
2207 : 0 : status = qbman_result_DQ_flags(dq_storage);
2208 [ # # ]: 0 : if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0))
2209 : 0 : continue;
2210 : : }
2211 : 0 : fd[num_rx] = RTE_PTR_UNQUAL(qbman_result_DQ_fd(dq_storage));
2212 : :
2213 : 0 : dq_storage++;
2214 : 0 : num_rx++;
2215 [ # # ]: 0 : } while (pending);
2216 : :
2217 [ # # ]: 0 : while (num_tx < num_rx) {
2218 : 0 : num_tx += qbman_swp_enqueue_multiple_fd(swp, &eqdesc,
2219 : : &fd[num_tx], 0, num_rx - num_tx);
2220 : : }
2221 : :
2222 [ # # ]: 0 : if (check_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index)) {
2223 [ # # ]: 0 : while (!qbman_check_command_complete(
2224 : 0 : get_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index)))
2225 : : ;
2226 : 0 : clear_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index);
2227 : : }
2228 : : /* issue a volatile dequeue command for next pull */
2229 : : while (1) {
2230 [ # # ]: 0 : if (qbman_swp_pull(swp, &pulldesc)) {
2231 : : DPAA2_PMD_DP_DEBUG("VDQ command is not issued."
2232 : : "QBMAN is busy (2)");
2233 : : continue;
2234 : : }
2235 : : break;
2236 : : }
2237 : 0 : q_storage->active_dqs = dq_storage1;
2238 : 0 : q_storage->active_dpio_id = DPAA2_PER_LCORE_ETHRX_DPIO->index;
2239 : 0 : set_swp_active_dqs(DPAA2_PER_LCORE_ETHRX_DPIO->index, dq_storage1);
2240 : :
2241 : 0 : dpaa2_q->rx_pkts += num_rx;
2242 : 0 : dpaa2_q->tx_pkts += num_tx;
2243 : :
2244 : 0 : return 0;
2245 : : }
|