Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : *
3 : : * Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
4 : : * Copyright 2017-2020,2022-2024 NXP
5 : : *
6 : : */
7 : : /* System headers */
8 : : #include <stdio.h>
9 : : #include <inttypes.h>
10 : : #include <unistd.h>
11 : : #include <limits.h>
12 : : #include <sched.h>
13 : : #include <signal.h>
14 : : #include <pthread.h>
15 : : #include <sys/types.h>
16 : : #include <sys/syscall.h>
17 : : #include <sys/ioctl.h>
18 : :
19 : : #include <rte_string_fns.h>
20 : : #include <rte_byteorder.h>
21 : : #include <rte_common.h>
22 : : #include <rte_interrupts.h>
23 : : #include <rte_log.h>
24 : : #include <rte_debug.h>
25 : : #include <rte_pci.h>
26 : : #include <rte_atomic.h>
27 : : #include <rte_branch_prediction.h>
28 : : #include <rte_memory.h>
29 : : #include <rte_tailq.h>
30 : : #include <rte_eal.h>
31 : : #include <rte_alarm.h>
32 : : #include <rte_ether.h>
33 : : #include <rte_kvargs.h>
34 : : #include <ethdev_driver.h>
35 : : #include <rte_malloc.h>
36 : : #include <rte_ring.h>
37 : :
38 : : #include <bus_dpaa_driver.h>
39 : : #include <rte_dpaa_logs.h>
40 : : #include <dpaa_mempool.h>
41 : :
42 : : #include <dpaa_ethdev.h>
43 : : #include <dpaa_rxtx.h>
44 : : #include <dpaa_flow.h>
45 : : #include <rte_pmd_dpaa.h>
46 : :
47 : : #include <fsl_usd.h>
48 : : #include <fsl_qman.h>
49 : : #include <fsl_bman.h>
50 : : #include <fsl_fman.h>
51 : : #include <process.h>
52 : : #include <fmlib/fm_ext.h>
53 : :
54 : : #define DRIVER_IEEE1588 "drv_ieee1588"
55 : : #define CHECK_INTERVAL 100 /* 100ms */
56 : : #define MAX_REPEAT_TIME 90 /* 9s (90 * 100ms) in total */
57 : :
58 : : /* Supported Rx offloads */
59 : : static uint64_t dev_rx_offloads_sup =
60 : : RTE_ETH_RX_OFFLOAD_SCATTER;
61 : :
62 : : /* Rx offloads which cannot be disabled */
63 : : static uint64_t dev_rx_offloads_nodis =
64 : : RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
65 : : RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
66 : : RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
67 : : RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
68 : : RTE_ETH_RX_OFFLOAD_RSS_HASH;
69 : :
70 : : /* Supported Tx offloads */
71 : : static uint64_t dev_tx_offloads_sup =
72 : : RTE_ETH_TX_OFFLOAD_MT_LOCKFREE |
73 : : RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
74 : :
75 : : /* Tx offloads which cannot be disabled */
76 : : static uint64_t dev_tx_offloads_nodis =
77 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
78 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
79 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
80 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |
81 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
82 : : RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
83 : :
84 : : /* Keep track of whether QMAN and BMAN have been globally initialized */
85 : : static int is_global_init;
86 : : static int fmc_q = 1; /* Indicates the use of static fmc for distribution */
87 : : static int default_q; /* use default queue - FMC is not executed*/
88 : : int dpaa_ieee_1588; /* use to indicate if IEEE 1588 is enabled for the driver */
89 : : /* At present we only allow up to 4 push mode queues as default - as each of
90 : : * this queue need dedicated portal and we are short of portals.
91 : : */
92 : : #define DPAA_MAX_PUSH_MODE_QUEUE 8
93 : : #define DPAA_DEFAULT_PUSH_MODE_QUEUE 4
94 : :
95 : : static int dpaa_push_mode_max_queue = DPAA_DEFAULT_PUSH_MODE_QUEUE;
96 : : static int dpaa_push_queue_idx; /* Queue index which are in push mode*/
97 : :
98 : :
99 : : /* Per RX FQ Taildrop in frame count */
100 : : static unsigned int td_threshold = CGR_RX_PERFQ_THRESH;
101 : :
102 : : /* Per TX FQ Taildrop in frame count, disabled by default */
103 : : static unsigned int td_tx_threshold;
104 : :
105 : : struct rte_dpaa_xstats_name_off {
106 : : char name[RTE_ETH_XSTATS_NAME_SIZE];
107 : : uint32_t offset;
108 : : };
109 : :
110 : : static const struct rte_dpaa_xstats_name_off dpaa_xstats_strings[] = {
111 : : {"rx_align_err",
112 : : offsetof(struct dpaa_if_stats, raln)},
113 : : {"rx_valid_pause",
114 : : offsetof(struct dpaa_if_stats, rxpf)},
115 : : {"rx_fcs_err",
116 : : offsetof(struct dpaa_if_stats, rfcs)},
117 : : {"rx_vlan_frame",
118 : : offsetof(struct dpaa_if_stats, rvlan)},
119 : : {"rx_frame_err",
120 : : offsetof(struct dpaa_if_stats, rerr)},
121 : : {"rx_drop_err",
122 : : offsetof(struct dpaa_if_stats, rdrp)},
123 : : {"rx_undersized",
124 : : offsetof(struct dpaa_if_stats, rund)},
125 : : {"rx_oversize_err",
126 : : offsetof(struct dpaa_if_stats, rovr)},
127 : : {"rx_fragment_pkt",
128 : : offsetof(struct dpaa_if_stats, rfrg)},
129 : : {"tx_valid_pause",
130 : : offsetof(struct dpaa_if_stats, txpf)},
131 : : {"tx_fcs_err",
132 : : offsetof(struct dpaa_if_stats, terr)},
133 : : {"tx_vlan_frame",
134 : : offsetof(struct dpaa_if_stats, tvlan)},
135 : : {"rx_undersized",
136 : : offsetof(struct dpaa_if_stats, tund)},
137 : : {"rx_frame_counter",
138 : : offsetof(struct dpaa_if_rx_bmi_stats, fmbm_rfrc)},
139 : : {"rx_bad_frames_count",
140 : : offsetof(struct dpaa_if_rx_bmi_stats, fmbm_rfbc)},
141 : : {"rx_large_frames_count",
142 : : offsetof(struct dpaa_if_rx_bmi_stats, fmbm_rlfc)},
143 : : {"rx_filter_frames_count",
144 : : offsetof(struct dpaa_if_rx_bmi_stats, fmbm_rffc)},
145 : : {"rx_frame_discrad_count",
146 : : offsetof(struct dpaa_if_rx_bmi_stats, fmbm_rfdc)},
147 : : {"rx_frame_list_dma_err_count",
148 : : offsetof(struct dpaa_if_rx_bmi_stats, fmbm_rfldec)},
149 : : {"rx_out_of_buffer_discard ",
150 : : offsetof(struct dpaa_if_rx_bmi_stats, fmbm_rodc)},
151 : : {"rx_buf_diallocate",
152 : : offsetof(struct dpaa_if_rx_bmi_stats, fmbm_rbdc)},
153 : : };
154 : :
155 : : static struct rte_dpaa_driver rte_dpaa_pmd;
156 : : int dpaa_valid_dev;
157 : : struct rte_mempool *dpaa_tx_sg_pool;
158 : :
159 : : static int
160 : : dpaa_eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info);
161 : :
162 : : static int dpaa_eth_link_update(struct rte_eth_dev *dev,
163 : : int wait_to_complete __rte_unused);
164 : :
165 : : static void dpaa_interrupt_handler(void *param);
166 : :
167 : : static inline void
168 [ # # ]: 0 : dpaa_poll_queue_default_config(struct qm_mcc_initfq *opts)
169 : : {
170 : : memset(opts, 0, sizeof(struct qm_mcc_initfq));
171 : 0 : opts->we_mask = QM_INITFQ_WE_FQCTRL | QM_INITFQ_WE_CONTEXTA;
172 : 0 : opts->fqd.fq_ctrl = QM_FQCTRL_AVOIDBLOCK | QM_FQCTRL_CTXASTASHING |
173 : : QM_FQCTRL_PREFERINCACHE;
174 : : opts->fqd.context_a.stashing.exclusive = 0;
175 [ # # ]: 0 : if (dpaa_svr_family != SVR_LS1046A_FAMILY)
176 : 0 : opts->fqd.context_a.stashing.annotation_cl =
177 : : DPAA_IF_RX_ANNOTATION_STASH;
178 : 0 : opts->fqd.context_a.stashing.data_cl = DPAA_IF_RX_DATA_STASH;
179 : : opts->fqd.context_a.stashing.context_cl = DPAA_IF_RX_CONTEXT_STASH;
180 : 0 : }
181 : :
182 : : static int
183 : 0 : dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
184 : : {
185 : 0 : uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN
186 : 0 : + VLAN_TAG_SIZE;
187 : 0 : uint32_t buffsz = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM;
188 : 0 : struct fman_if *fif = dev->process_private;
189 : :
190 : 0 : PMD_INIT_FUNC_TRACE();
191 : :
192 [ # # ]: 0 : if (fif->is_shared_mac) {
193 : 0 : DPAA_PMD_ERR("Cannot configure mtu from DPDK in VSP mode.");
194 : 0 : return -ENOTSUP;
195 : : }
196 : :
197 : : /*
198 : : * Refuse mtu that requires the support of scattered packets
199 : : * when this feature has not been enabled before.
200 : : */
201 [ # # ]: 0 : if (dev->data->min_rx_buf_size &&
202 [ # # # # ]: 0 : !dev->data->scattered_rx && frame_size > buffsz) {
203 : 0 : DPAA_PMD_ERR("SG not enabled, will not fit in one buffer");
204 : 0 : return -EINVAL;
205 : : }
206 : :
207 : : /* check <seg size> * <max_seg> >= max_frame */
208 [ # # # # ]: 0 : if (dev->data->min_rx_buf_size && dev->data->scattered_rx &&
209 [ # # ]: 0 : (frame_size > buffsz * DPAA_SGT_MAX_ENTRIES)) {
210 : 0 : DPAA_PMD_ERR("Too big to fit for Max SG list %d",
211 : : buffsz * DPAA_SGT_MAX_ENTRIES);
212 : 0 : return -EINVAL;
213 : : }
214 : :
215 : 0 : fman_if_set_maxfrm(dev->process_private, frame_size);
216 : :
217 : 0 : return 0;
218 : : }
219 : :
220 : : static int
221 : 0 : dpaa_eth_dev_configure(struct rte_eth_dev *dev)
222 : : {
223 : 0 : struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
224 : 0 : uint64_t rx_offloads = eth_conf->rxmode.offloads;
225 : 0 : uint64_t tx_offloads = eth_conf->txmode.offloads;
226 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
227 : 0 : struct rte_device *rdev = dev->device;
228 : : struct rte_eth_link *link = &dev->data->dev_link;
229 : : struct rte_dpaa_device *dpaa_dev;
230 : 0 : struct fman_if *fif = dev->process_private;
231 : : struct __fman_if *__fif;
232 : : struct rte_intr_handle *intr_handle;
233 : : uint32_t max_rx_pktlen;
234 : : int speed, duplex;
235 : : int ret, rx_status, socket_fd;
236 : : struct ifreq ifr;
237 : :
238 : 0 : PMD_INIT_FUNC_TRACE();
239 : :
240 : 0 : dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
241 : 0 : intr_handle = dpaa_dev->intr_handle;
242 : : __fif = container_of(fif, struct __fman_if, __if);
243 : :
244 : : /* Check if interface is enabled in case of shared MAC */
245 [ # # ]: 0 : if (fif->is_shared_mac) {
246 : 0 : rx_status = fman_if_get_rx_status(fif);
247 [ # # ]: 0 : if (!rx_status) {
248 : 0 : DPAA_PMD_ERR("%s Interface not enabled in kernel!",
249 : : dpaa_intf->name);
250 : 0 : return -EHOSTDOWN;
251 : : }
252 : :
253 : 0 : socket_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
254 [ # # ]: 0 : if (socket_fd == -1) {
255 : 0 : DPAA_PMD_ERR("Cannot open IF socket");
256 : 0 : return -errno;
257 : : }
258 : 0 : strncpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ - 1);
259 : :
260 [ # # ]: 0 : if (ioctl(socket_fd, SIOCGIFMTU, &ifr) < 0) {
261 : 0 : DPAA_PMD_ERR("Cannot get interface mtu");
262 : 0 : close(socket_fd);
263 : 0 : return -errno;
264 : : }
265 : :
266 : 0 : close(socket_fd);
267 : 0 : DPAA_PMD_INFO("Using kernel configured mtu size(%u)",
268 : : ifr.ifr_mtu);
269 : :
270 : 0 : eth_conf->rxmode.mtu = ifr.ifr_mtu;
271 : : }
272 : :
273 : : /* Rx offloads which are enabled by default */
274 [ # # ]: 0 : if (dev_rx_offloads_nodis & ~rx_offloads) {
275 : 0 : DPAA_PMD_INFO(
276 : : "Some of rx offloads enabled by default - requested 0x%" PRIx64
277 : : " fixed are 0x%" PRIx64,
278 : : rx_offloads, dev_rx_offloads_nodis);
279 : : }
280 : :
281 : : /* Tx offloads which are enabled by default */
282 [ # # ]: 0 : if (dev_tx_offloads_nodis & ~tx_offloads) {
283 : 0 : DPAA_PMD_INFO(
284 : : "Some of tx offloads enabled by default - requested 0x%" PRIx64
285 : : " fixed are 0x%" PRIx64,
286 : : tx_offloads, dev_tx_offloads_nodis);
287 : : }
288 : :
289 : 0 : max_rx_pktlen = eth_conf->rxmode.mtu + RTE_ETHER_HDR_LEN +
290 : : RTE_ETHER_CRC_LEN + VLAN_TAG_SIZE;
291 [ # # ]: 0 : if (max_rx_pktlen > DPAA_MAX_RX_PKT_LEN) {
292 : 0 : DPAA_PMD_INFO("enabling jumbo override conf max len=%d "
293 : : "supported is %d",
294 : : max_rx_pktlen, DPAA_MAX_RX_PKT_LEN);
295 : : max_rx_pktlen = DPAA_MAX_RX_PKT_LEN;
296 : : }
297 : :
298 [ # # # # : 0 : if (!fif->is_shared_mac && fif->mac_type != fman_offline_internal &&
# # ]
299 : : fif->mac_type != fman_onic)
300 : 0 : fman_if_set_maxfrm(dev->process_private, max_rx_pktlen);
301 : :
302 [ # # ]: 0 : if (rx_offloads & RTE_ETH_RX_OFFLOAD_SCATTER) {
303 : 0 : DPAA_PMD_DEBUG("enabling scatter mode");
304 : 0 : fman_if_set_sg(dev->process_private, 1);
305 : 0 : dev->data->scattered_rx = 1;
306 : : }
307 : :
308 [ # # # # ]: 0 : if (!(default_q || fmc_q)) {
309 [ # # ]: 0 : if (dpaa_fm_config(dev,
310 : : eth_conf->rx_adv_conf.rss_conf.rss_hf)) {
311 : 0 : dpaa_write_fm_config_to_file();
312 : 0 : DPAA_PMD_ERR("FM port configuration: Failed");
313 : 0 : return -1;
314 : : }
315 : 0 : dpaa_write_fm_config_to_file();
316 : : }
317 : :
318 : : /* Disable interrupt support on offline port*/
319 [ # # ]: 0 : if (fif->mac_type == fman_offline_internal ||
320 : : fif->mac_type == fman_onic)
321 : : return 0;
322 : :
323 : : /* if the interrupts were configured on this devices*/
324 [ # # # # ]: 0 : if (intr_handle && rte_intr_fd_get(intr_handle)) {
325 [ # # ]: 0 : if (dev->data->dev_conf.intr_conf.lsc != 0)
326 : 0 : rte_intr_callback_register(intr_handle,
327 : : dpaa_interrupt_handler,
328 : : (void *)dev);
329 : :
330 : 0 : ret = dpaa_intr_enable(__fif->node_name,
331 : : rte_intr_fd_get(intr_handle));
332 [ # # ]: 0 : if (ret) {
333 [ # # ]: 0 : if (dev->data->dev_conf.intr_conf.lsc != 0) {
334 : 0 : rte_intr_callback_unregister(intr_handle,
335 : : dpaa_interrupt_handler,
336 : : (void *)dev);
337 [ # # ]: 0 : if (ret == EINVAL)
338 : 0 : DPAA_PMD_ERR("Failed to enable interrupt: Not Supported");
339 : : else
340 : 0 : DPAA_PMD_ERR("Failed to enable interrupt");
341 : : }
342 : 0 : dev->data->dev_conf.intr_conf.lsc = 0;
343 : 0 : dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
344 : : }
345 : : }
346 : :
347 : : /* Wait for link status to get updated */
348 [ # # ]: 0 : if (!link->link_status)
349 : 0 : sleep(1);
350 : :
351 : : /* Configure link only if link is UP*/
352 [ # # ]: 0 : if (link->link_status) {
353 [ # # ]: 0 : if (eth_conf->link_speeds == RTE_ETH_LINK_SPEED_AUTONEG) {
354 : : /* Start autoneg only if link is not in autoneg mode */
355 [ # # ]: 0 : if (!link->link_autoneg)
356 : 0 : dpaa_restart_link_autoneg(__fif->node_name);
357 [ # # ]: 0 : } else if (eth_conf->link_speeds & RTE_ETH_LINK_SPEED_FIXED) {
358 : : switch (eth_conf->link_speeds & RTE_ETH_LINK_SPEED_FIXED) {
359 : : case RTE_ETH_LINK_SPEED_10M_HD:
360 : : speed = RTE_ETH_SPEED_NUM_10M;
361 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
362 : : break;
363 : : case RTE_ETH_LINK_SPEED_10M:
364 : : speed = RTE_ETH_SPEED_NUM_10M;
365 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
366 : : break;
367 : : case RTE_ETH_LINK_SPEED_100M_HD:
368 : : speed = RTE_ETH_SPEED_NUM_100M;
369 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
370 : : break;
371 : : case RTE_ETH_LINK_SPEED_100M:
372 : : speed = RTE_ETH_SPEED_NUM_100M;
373 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
374 : : break;
375 : : case RTE_ETH_LINK_SPEED_1G:
376 : : speed = RTE_ETH_SPEED_NUM_1G;
377 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
378 : : break;
379 : : case RTE_ETH_LINK_SPEED_2_5G:
380 : : speed = RTE_ETH_SPEED_NUM_2_5G;
381 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
382 : : break;
383 : : case RTE_ETH_LINK_SPEED_10G:
384 : : speed = RTE_ETH_SPEED_NUM_10G;
385 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
386 : : break;
387 : : default:
388 : : speed = RTE_ETH_SPEED_NUM_NONE;
389 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
390 : : break;
391 : : }
392 : : /* Set link speed */
393 : 0 : dpaa_update_link_speed(__fif->node_name, speed, duplex);
394 : : } else {
395 : : /* Manual autoneg - custom advertisement speed. */
396 : 0 : DPAA_PMD_ERR("Custom Advertisement speeds not supported");
397 : : }
398 : : }
399 : :
400 : : return 0;
401 : : }
402 : :
403 : : static const uint32_t *
404 : 0 : dpaa_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)
405 : : {
406 : : static const uint32_t ptypes[] = {
407 : : RTE_PTYPE_L2_ETHER,
408 : : RTE_PTYPE_L2_ETHER_VLAN,
409 : : RTE_PTYPE_L2_ETHER_ARP,
410 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
411 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
412 : : RTE_PTYPE_L4_ICMP,
413 : : RTE_PTYPE_L4_TCP,
414 : : RTE_PTYPE_L4_UDP,
415 : : RTE_PTYPE_L4_FRAG,
416 : : RTE_PTYPE_L4_TCP,
417 : : RTE_PTYPE_L4_UDP,
418 : : RTE_PTYPE_L4_SCTP,
419 : : RTE_PTYPE_TUNNEL_ESP,
420 : : RTE_PTYPE_TUNNEL_GRE,
421 : : };
422 : :
423 : 0 : PMD_INIT_FUNC_TRACE();
424 : :
425 [ # # ]: 0 : if (dev->rx_pkt_burst == dpaa_eth_queue_rx) {
426 : 0 : *no_of_elements = RTE_DIM(ptypes);
427 : 0 : return ptypes;
428 : : }
429 : : return NULL;
430 : : }
431 : :
432 : 0 : static void dpaa_interrupt_handler(void *param)
433 : : {
434 : : struct rte_eth_dev *dev = param;
435 : 0 : struct rte_device *rdev = dev->device;
436 : : struct rte_dpaa_device *dpaa_dev;
437 : : struct rte_intr_handle *intr_handle;
438 : : uint64_t buf;
439 : : int bytes_read;
440 : :
441 : 0 : dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
442 : 0 : intr_handle = dpaa_dev->intr_handle;
443 : :
444 [ # # ]: 0 : if (rte_intr_fd_get(intr_handle) < 0)
445 : 0 : return;
446 : :
447 : 0 : bytes_read = read(rte_intr_fd_get(intr_handle), &buf,
448 : : sizeof(uint64_t));
449 [ # # ]: 0 : if (bytes_read < 0)
450 : 0 : DPAA_PMD_ERR("Error reading eventfd");
451 : 0 : dpaa_eth_link_update(dev, 0);
452 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
453 : : }
454 : :
455 : 0 : static int dpaa_eth_dev_start(struct rte_eth_dev *dev)
456 : : {
457 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
458 : 0 : struct fman_if *fif = dev->process_private;
459 : : uint16_t i;
460 : :
461 : 0 : PMD_INIT_FUNC_TRACE();
462 : :
463 [ # # # # ]: 0 : if (!(default_q || fmc_q))
464 : 0 : dpaa_write_fm_config_to_file();
465 : :
466 : : /* Change tx callback to the real one */
467 [ # # ]: 0 : if (dpaa_intf->cgr_tx)
468 : 0 : dev->tx_pkt_burst = dpaa_eth_queue_tx_slow;
469 : : else
470 : 0 : dev->tx_pkt_burst = dpaa_eth_queue_tx;
471 : :
472 [ # # ]: 0 : if (fif->mac_type != fman_onic) {
473 : 0 : fman_if_bmi_stats_enable(fif);
474 : 0 : fman_if_bmi_stats_reset(fif);
475 : 0 : fman_if_enable_rx(fif);
476 : : }
477 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++)
478 : 0 : dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
479 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++)
480 : 0 : dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
481 : :
482 : 0 : return 0;
483 : : }
484 : :
485 : 0 : static int dpaa_eth_dev_stop(struct rte_eth_dev *dev)
486 : : {
487 : 0 : struct fman_if *fif = dev->process_private;
488 : : uint16_t i;
489 : :
490 : 0 : PMD_INIT_FUNC_TRACE();
491 : 0 : dev->data->dev_started = 0;
492 : :
493 [ # # ]: 0 : if (!fif->is_shared_mac) {
494 : 0 : fman_if_bmi_stats_disable(fif);
495 : 0 : fman_if_disable_rx(fif);
496 : : }
497 : 0 : dev->tx_pkt_burst = dpaa_eth_tx_drop_all;
498 : :
499 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++)
500 : 0 : dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
501 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++)
502 : 0 : dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
503 : :
504 : 0 : return 0;
505 : : }
506 : :
507 : 0 : static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
508 : : {
509 : 0 : struct fman_if *fif = dev->process_private;
510 : : struct __fman_if *__fif;
511 : 0 : struct rte_device *rdev = dev->device;
512 : : struct rte_dpaa_device *dpaa_dev;
513 : : struct rte_intr_handle *intr_handle;
514 : 0 : struct rte_eth_link *link = &dev->data->dev_link;
515 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
516 : : int loop;
517 : : int ret;
518 : :
519 : 0 : PMD_INIT_FUNC_TRACE();
520 : :
521 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
522 : : return 0;
523 : :
524 [ # # ]: 0 : if (!dpaa_intf) {
525 : 0 : DPAA_PMD_WARN("Already closed or not started");
526 : 0 : return -1;
527 : : }
528 : :
529 : : /* DPAA FM deconfig */
530 [ # # # # ]: 0 : if (!(default_q || fmc_q)) {
531 [ # # ]: 0 : if (dpaa_fm_deconfig(dpaa_intf, dev->process_private))
532 : 0 : DPAA_PMD_WARN("DPAA FM deconfig failed");
533 : : }
534 : :
535 : 0 : dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
536 : 0 : intr_handle = dpaa_dev->intr_handle;
537 : : __fif = container_of(fif, struct __fman_if, __if);
538 : :
539 : 0 : ret = dpaa_eth_dev_stop(dev);
540 : :
541 [ # # ]: 0 : if (fif->mac_type == fman_offline_internal ||
542 : : fif->mac_type == fman_onic)
543 : : return 0;
544 : :
545 : : /* Reset link to autoneg */
546 [ # # ]: 0 : if (link->link_status && !link->link_autoneg)
547 : 0 : dpaa_restart_link_autoneg(__fif->node_name);
548 : :
549 [ # # # # ]: 0 : if (intr_handle && rte_intr_fd_get(intr_handle) &&
550 [ # # ]: 0 : dev->data->dev_conf.intr_conf.lsc != 0) {
551 : 0 : dpaa_intr_disable(__fif->node_name);
552 : 0 : rte_intr_callback_unregister(intr_handle,
553 : : dpaa_interrupt_handler,
554 : : (void *)dev);
555 : : }
556 : :
557 : : /* release configuration memory */
558 : 0 : rte_free(dpaa_intf->fc_conf);
559 : :
560 : : /* Release RX congestion Groups */
561 [ # # ]: 0 : if (dpaa_intf->cgr_rx) {
562 [ # # ]: 0 : for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
563 : 0 : qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
564 : 0 : rte_free(dpaa_intf->cgr_rx);
565 : 0 : dpaa_intf->cgr_rx = NULL;
566 : : }
567 : :
568 : : /* Release TX congestion Groups */
569 [ # # ]: 0 : if (dpaa_intf->cgr_tx) {
570 [ # # ]: 0 : for (loop = 0; loop < MAX_DPAA_CORES; loop++)
571 : 0 : qman_delete_cgr(&dpaa_intf->cgr_tx[loop]);
572 : 0 : rte_free(dpaa_intf->cgr_tx);
573 : 0 : dpaa_intf->cgr_tx = NULL;
574 : : }
575 : :
576 : 0 : rte_free(dpaa_intf->rx_queues);
577 : 0 : dpaa_intf->rx_queues = NULL;
578 : :
579 : 0 : rte_free(dpaa_intf->tx_queues);
580 : 0 : dpaa_intf->tx_queues = NULL;
581 [ # # ]: 0 : if (dpaa_intf->port_handle) {
582 [ # # ]: 0 : if (dpaa_fm_deconfig(dpaa_intf, fif))
583 : 0 : DPAA_PMD_WARN("DPAA FM "
584 : : "deconfig failed");
585 : : }
586 [ # # ]: 0 : if (fif->num_profiles) {
587 [ # # ]: 0 : if (dpaa_port_vsp_cleanup(dpaa_intf, fif))
588 : 0 : DPAA_PMD_WARN("DPAA FM vsp cleanup failed");
589 : : }
590 : :
591 : : return ret;
592 : : }
593 : :
594 : : static int
595 : 0 : dpaa_fw_version_get(struct rte_eth_dev *dev __rte_unused,
596 : : char *fw_version,
597 : : size_t fw_size)
598 : : {
599 : : int ret;
600 : : FILE *svr_file = NULL;
601 : 0 : unsigned int svr_ver = 0;
602 : :
603 : 0 : PMD_INIT_FUNC_TRACE();
604 : :
605 : 0 : svr_file = fopen(DPAA_SOC_ID_FILE, "r");
606 [ # # ]: 0 : if (!svr_file) {
607 : 0 : DPAA_PMD_ERR("Unable to open SoC device");
608 : 0 : return -ENOTSUP; /* Not supported on this infra */
609 : : }
610 [ # # ]: 0 : if (fscanf(svr_file, "svr:%x", &svr_ver) > 0)
611 : 0 : dpaa_svr_family = svr_ver & SVR_MASK;
612 : : else
613 : 0 : DPAA_PMD_ERR("Unable to read SoC device");
614 : :
615 : 0 : fclose(svr_file);
616 : :
617 [ # # ]: 0 : ret = snprintf(fw_version, fw_size, "SVR:%x-fman-v%x",
618 : : svr_ver, fman_ip_rev);
619 [ # # ]: 0 : if (ret < 0)
620 : : return -EINVAL;
621 : :
622 : 0 : ret += 1; /* add the size of '\0' */
623 [ # # ]: 0 : if (fw_size < (size_t)ret)
624 : : return ret;
625 : : else
626 : 0 : return 0;
627 : : }
628 : :
629 : 0 : static int dpaa_eth_dev_info(struct rte_eth_dev *dev,
630 : : struct rte_eth_dev_info *dev_info)
631 : : {
632 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
633 : 0 : struct fman_if *fif = dev->process_private;
634 : :
635 : 0 : DPAA_PMD_DEBUG(": %s", dpaa_intf->name);
636 : :
637 : 0 : dev_info->max_rx_queues = dpaa_intf->nb_rx_queues;
638 : 0 : dev_info->max_tx_queues = dpaa_intf->nb_tx_queues;
639 : 0 : dev_info->max_rx_pktlen = DPAA_MAX_RX_PKT_LEN;
640 : 0 : dev_info->max_mac_addrs = DPAA_MAX_MAC_FILTER;
641 : 0 : dev_info->max_hash_mac_addrs = 0;
642 : 0 : dev_info->max_vfs = 0;
643 : 0 : dev_info->max_vmdq_pools = RTE_ETH_16_POOLS;
644 : 0 : dev_info->flow_type_rss_offloads = DPAA_RSS_OFFLOAD_ALL;
645 : :
646 [ # # ]: 0 : if (fif->mac_type == fman_mac_1g) {
647 : 0 : dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M_HD
648 : : | RTE_ETH_LINK_SPEED_10M
649 : : | RTE_ETH_LINK_SPEED_100M_HD
650 : : | RTE_ETH_LINK_SPEED_100M
651 : : | RTE_ETH_LINK_SPEED_1G;
652 [ # # ]: 0 : } else if (fif->mac_type == fman_mac_2_5g) {
653 : 0 : dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M_HD
654 : : | RTE_ETH_LINK_SPEED_10M
655 : : | RTE_ETH_LINK_SPEED_100M_HD
656 : : | RTE_ETH_LINK_SPEED_100M
657 : : | RTE_ETH_LINK_SPEED_1G
658 : : | RTE_ETH_LINK_SPEED_2_5G;
659 [ # # ]: 0 : } else if (fif->mac_type == fman_mac_10g) {
660 : 0 : dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M_HD
661 : : | RTE_ETH_LINK_SPEED_10M
662 : : | RTE_ETH_LINK_SPEED_100M_HD
663 : : | RTE_ETH_LINK_SPEED_100M
664 : : | RTE_ETH_LINK_SPEED_1G
665 : : | RTE_ETH_LINK_SPEED_2_5G
666 : : | RTE_ETH_LINK_SPEED_10G;
667 [ # # ]: 0 : } else if (fif->mac_type == fman_offline_internal ||
668 : : fif->mac_type == fman_onic) {
669 : 0 : dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M_HD
670 : : | RTE_ETH_LINK_SPEED_10M
671 : : | RTE_ETH_LINK_SPEED_100M_HD
672 : : | RTE_ETH_LINK_SPEED_100M
673 : : | RTE_ETH_LINK_SPEED_1G
674 : : | RTE_ETH_LINK_SPEED_2_5G;
675 : : } else {
676 : 0 : DPAA_PMD_ERR("invalid link_speed: %s, %d",
677 : : dpaa_intf->name, fif->mac_type);
678 : 0 : return -EINVAL;
679 : : }
680 : :
681 : 0 : dev_info->rx_offload_capa = dev_rx_offloads_sup |
682 : : dev_rx_offloads_nodis;
683 : 0 : dev_info->tx_offload_capa = dev_tx_offloads_sup |
684 : : dev_tx_offloads_nodis;
685 : 0 : dev_info->default_rxportconf.burst_size = DPAA_DEF_RX_BURST_SIZE;
686 : 0 : dev_info->default_txportconf.burst_size = DPAA_DEF_TX_BURST_SIZE;
687 : 0 : dev_info->default_rxportconf.nb_queues = 1;
688 : 0 : dev_info->default_txportconf.nb_queues = 1;
689 : 0 : dev_info->default_txportconf.ring_size = CGR_TX_CGR_THRESH;
690 : 0 : dev_info->default_rxportconf.ring_size = CGR_RX_PERFQ_THRESH;
691 : :
692 : 0 : return 0;
693 : : }
694 : :
695 : : static int
696 : 0 : dpaa_dev_rx_burst_mode_get(struct rte_eth_dev *dev,
697 : : __rte_unused uint16_t queue_id,
698 : : struct rte_eth_burst_mode *mode)
699 : : {
700 : 0 : struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
701 : : int ret = -EINVAL;
702 : : unsigned int i;
703 : : const struct burst_info {
704 : : uint64_t flags;
705 : : const char *output;
706 : 0 : } rx_offload_map[] = {
707 : : {RTE_ETH_RX_OFFLOAD_SCATTER, " Scattered,"},
708 : : {RTE_ETH_RX_OFFLOAD_IPV4_CKSUM, " IPV4 csum,"},
709 : : {RTE_ETH_RX_OFFLOAD_UDP_CKSUM, " UDP csum,"},
710 : : {RTE_ETH_RX_OFFLOAD_TCP_CKSUM, " TCP csum,"},
711 : : {RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM, " Outer IPV4 csum,"},
712 : : {RTE_ETH_RX_OFFLOAD_RSS_HASH, " RSS,"}
713 : : };
714 : :
715 : : /* Update Rx offload info */
716 [ # # ]: 0 : for (i = 0; i < RTE_DIM(rx_offload_map); i++) {
717 [ # # ]: 0 : if (eth_conf->rxmode.offloads & rx_offload_map[i].flags) {
718 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
719 : 0 : rx_offload_map[i].output);
720 : : ret = 0;
721 : 0 : break;
722 : : }
723 : : }
724 : 0 : return ret;
725 : : }
726 : :
727 : : static int
728 : 0 : dpaa_dev_tx_burst_mode_get(struct rte_eth_dev *dev,
729 : : __rte_unused uint16_t queue_id,
730 : : struct rte_eth_burst_mode *mode)
731 : : {
732 : 0 : struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
733 : : int ret = -EINVAL;
734 : : unsigned int i;
735 : : const struct burst_info {
736 : : uint64_t flags;
737 : : const char *output;
738 : 0 : } tx_offload_map[] = {
739 : : {RTE_ETH_TX_OFFLOAD_MT_LOCKFREE, " MT lockfree,"},
740 : : {RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE, " MBUF free disable,"},
741 : : {RTE_ETH_TX_OFFLOAD_IPV4_CKSUM, " IPV4 csum,"},
742 : : {RTE_ETH_TX_OFFLOAD_UDP_CKSUM, " UDP csum,"},
743 : : {RTE_ETH_TX_OFFLOAD_TCP_CKSUM, " TCP csum,"},
744 : : {RTE_ETH_TX_OFFLOAD_SCTP_CKSUM, " SCTP csum,"},
745 : : {RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM, " Outer IPV4 csum,"},
746 : : {RTE_ETH_TX_OFFLOAD_MULTI_SEGS, " Scattered,"}
747 : : };
748 : :
749 : : /* Update Tx offload info */
750 [ # # ]: 0 : for (i = 0; i < RTE_DIM(tx_offload_map); i++) {
751 [ # # ]: 0 : if (eth_conf->txmode.offloads & tx_offload_map[i].flags) {
752 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
753 : 0 : tx_offload_map[i].output);
754 : : ret = 0;
755 : 0 : break;
756 : : }
757 : : }
758 : 0 : return ret;
759 : : }
760 : :
761 : 0 : static int dpaa_eth_link_update(struct rte_eth_dev *dev,
762 : : int wait_to_complete)
763 : : {
764 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
765 : 0 : struct rte_eth_link *link = &dev->data->dev_link;
766 : 0 : struct fman_if *fif = dev->process_private;
767 : : struct __fman_if *__fif = container_of(fif, struct __fman_if, __if);
768 : : int ret, ioctl_version;
769 : : uint8_t count;
770 : :
771 : 0 : PMD_INIT_FUNC_TRACE();
772 : :
773 : 0 : ioctl_version = dpaa_get_ioctl_version_number();
774 : :
775 [ # # ]: 0 : if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC &&
776 [ # # # # ]: 0 : fif->mac_type != fman_offline_internal &&
777 : : fif->mac_type != fman_onic) {
778 [ # # ]: 0 : for (count = 0; count <= MAX_REPEAT_TIME; count++) {
779 : 0 : ret = dpaa_get_link_status(__fif->node_name, link);
780 [ # # ]: 0 : if (ret)
781 : 0 : return ret;
782 [ # # # # ]: 0 : if (link->link_status == RTE_ETH_LINK_DOWN &&
783 : : wait_to_complete)
784 : : rte_delay_ms(CHECK_INTERVAL);
785 : : else
786 : : break;
787 : : }
788 : : } else {
789 : 0 : link->link_status = dpaa_intf->valid;
790 [ # # ]: 0 : if (fif->mac_type == fman_offline_internal ||
791 : : fif->mac_type == fman_onic) {
792 : : /*Max supported rate for O/H port is 3.75Mpps*/
793 : 0 : link->link_speed = RTE_ETH_SPEED_NUM_2_5G;
794 : 0 : link->link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
795 : : }
796 : : }
797 : :
798 [ # # ]: 0 : if (ioctl_version < 2) {
799 : 0 : link->link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
800 : 0 : link->link_autoneg = RTE_ETH_LINK_AUTONEG;
801 : :
802 [ # # ]: 0 : if (fif->mac_type == fman_mac_1g)
803 : 0 : link->link_speed = RTE_ETH_SPEED_NUM_1G;
804 [ # # ]: 0 : else if (fif->mac_type == fman_mac_2_5g)
805 : 0 : link->link_speed = RTE_ETH_SPEED_NUM_2_5G;
806 [ # # ]: 0 : else if (fif->mac_type == fman_mac_10g)
807 : 0 : link->link_speed = RTE_ETH_SPEED_NUM_10G;
808 : : else
809 : 0 : DPAA_PMD_ERR("invalid link_speed: %s, %d",
810 : : dpaa_intf->name, fif->mac_type);
811 : : }
812 : :
813 [ # # ]: 0 : DPAA_PMD_INFO("Port %d Link is %s", dev->data->port_id,
814 : : link->link_status ? "Up" : "Down");
815 : 0 : return 0;
816 : : }
817 : :
818 : 0 : static int dpaa_eth_stats_get(struct rte_eth_dev *dev,
819 : : struct rte_eth_stats *stats)
820 : : {
821 : 0 : PMD_INIT_FUNC_TRACE();
822 : :
823 : 0 : fman_if_stats_get(dev->process_private, stats);
824 : 0 : return 0;
825 : : }
826 : :
827 : 0 : static int dpaa_eth_stats_reset(struct rte_eth_dev *dev)
828 : : {
829 : 0 : PMD_INIT_FUNC_TRACE();
830 : :
831 : 0 : fman_if_stats_reset(dev->process_private);
832 : 0 : fman_if_bmi_stats_reset(dev->process_private);
833 : :
834 : 0 : return 0;
835 : : }
836 : :
837 : : static int
838 : 0 : dpaa_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
839 : : unsigned int n)
840 : : {
841 : : unsigned int i = 0, j, num = RTE_DIM(dpaa_xstats_strings);
842 : : uint64_t values[sizeof(struct dpaa_if_stats) / 8];
843 : : unsigned int bmi_count = sizeof(struct dpaa_if_rx_bmi_stats) / 4;
844 : :
845 [ # # ]: 0 : if (n < num)
846 : : return num;
847 : :
848 [ # # ]: 0 : if (xstats == NULL)
849 : : return 0;
850 : :
851 : 0 : fman_if_stats_get_all(dev->process_private, values,
852 : : sizeof(struct dpaa_if_stats) / 8);
853 : :
854 [ # # ]: 0 : for (i = 0; i < num - (bmi_count - 1); i++) {
855 : 0 : xstats[i].id = i;
856 : 0 : xstats[i].value = values[dpaa_xstats_strings[i].offset / 8];
857 : : }
858 : 0 : fman_if_bmi_stats_get_all(dev->process_private, values);
859 [ # # ]: 0 : for (j = 0; i < num; i++, j++) {
860 : 0 : xstats[i].id = i;
861 : 0 : xstats[i].value = values[j];
862 : : }
863 : :
864 : : return i;
865 : : }
866 : :
867 : : static int
868 : 0 : dpaa_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
869 : : struct rte_eth_xstat_name *xstats_names,
870 : : unsigned int limit)
871 : : {
872 : : unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings);
873 : :
874 [ # # ]: 0 : if (limit < stat_cnt)
875 : : return stat_cnt;
876 : :
877 [ # # ]: 0 : if (xstats_names != NULL)
878 [ # # ]: 0 : for (i = 0; i < stat_cnt; i++)
879 : 0 : strlcpy(xstats_names[i].name,
880 : : dpaa_xstats_strings[i].name,
881 : : sizeof(xstats_names[i].name));
882 : :
883 : : return stat_cnt;
884 : : }
885 : :
886 : : static int
887 : 0 : dpaa_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
888 : : uint64_t *values, unsigned int n)
889 : : {
890 : : unsigned int i, j, stat_cnt = RTE_DIM(dpaa_xstats_strings);
891 : : uint64_t values_copy[sizeof(struct dpaa_if_stats) / 8];
892 : : unsigned int bmi_count = sizeof(struct dpaa_if_rx_bmi_stats) / 4;
893 : :
894 [ # # ]: 0 : if (!ids) {
895 [ # # ]: 0 : if (n < stat_cnt)
896 : : return stat_cnt;
897 : :
898 [ # # ]: 0 : if (!values)
899 : : return 0;
900 : :
901 : 0 : fman_if_stats_get_all(dev->process_private, values_copy,
902 : : sizeof(struct dpaa_if_stats) / 8);
903 : :
904 [ # # ]: 0 : for (i = 0; i < stat_cnt - (bmi_count - 1); i++)
905 : 0 : values[i] =
906 : 0 : values_copy[dpaa_xstats_strings[i].offset / 8];
907 : :
908 : 0 : fman_if_bmi_stats_get_all(dev->process_private, values);
909 [ # # ]: 0 : for (j = 0; i < stat_cnt; i++, j++)
910 : 0 : values[i] = values_copy[j];
911 : :
912 : : return stat_cnt;
913 : : }
914 : :
915 : 0 : dpaa_xstats_get_by_id(dev, NULL, values_copy, stat_cnt);
916 : :
917 [ # # ]: 0 : for (i = 0; i < n; i++) {
918 [ # # ]: 0 : if (ids[i] >= stat_cnt) {
919 : 0 : DPAA_PMD_ERR("id value isn't valid");
920 : 0 : return -1;
921 : : }
922 : 0 : values[i] = values_copy[ids[i]];
923 : : }
924 : 0 : return n;
925 : : }
926 : :
927 : : static int
928 : 0 : dpaa_xstats_get_names_by_id(
929 : : struct rte_eth_dev *dev,
930 : : const uint64_t *ids,
931 : : struct rte_eth_xstat_name *xstats_names,
932 : : unsigned int limit)
933 : 0 : {
934 : : unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings);
935 : 0 : struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
936 : :
937 [ # # ]: 0 : if (!ids)
938 : 0 : return dpaa_xstats_get_names(dev, xstats_names, limit);
939 : :
940 : 0 : dpaa_xstats_get_names(dev, xstats_names_copy, limit);
941 : :
942 [ # # ]: 0 : for (i = 0; i < limit; i++) {
943 [ # # ]: 0 : if (ids[i] >= stat_cnt) {
944 : 0 : DPAA_PMD_ERR("id value isn't valid");
945 : 0 : return -1;
946 : : }
947 : 0 : strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name);
948 : : }
949 : 0 : return limit;
950 : : }
951 : :
952 : 0 : static int dpaa_eth_promiscuous_enable(struct rte_eth_dev *dev)
953 : : {
954 : 0 : struct fman_if *fif = dev->process_private;
955 : :
956 : 0 : PMD_INIT_FUNC_TRACE();
957 : :
958 [ # # ]: 0 : if (fif->mac_type == fman_onic) {
959 : 0 : DPAA_PMD_INFO("Enable promiscuous mode not supported on ONIC "
960 : : "port");
961 : 0 : return 0;
962 : : }
963 : :
964 : 0 : fman_if_promiscuous_enable(dev->process_private);
965 : :
966 : 0 : return 0;
967 : : }
968 : :
969 : 0 : static int dpaa_eth_promiscuous_disable(struct rte_eth_dev *dev)
970 : : {
971 : 0 : struct fman_if *fif = dev->process_private;
972 : :
973 : 0 : PMD_INIT_FUNC_TRACE();
974 : :
975 [ # # ]: 0 : if (fif->mac_type == fman_onic) {
976 : 0 : DPAA_PMD_INFO("Disable promiscuous mode not supported on ONIC "
977 : : "port");
978 : 0 : return 0;
979 : : }
980 : :
981 : 0 : fman_if_promiscuous_disable(dev->process_private);
982 : :
983 : 0 : return 0;
984 : : }
985 : :
986 : 0 : static int dpaa_eth_multicast_enable(struct rte_eth_dev *dev)
987 : : {
988 : 0 : struct fman_if *fif = dev->process_private;
989 : :
990 : 0 : PMD_INIT_FUNC_TRACE();
991 : :
992 [ # # ]: 0 : if (fif->mac_type == fman_onic) {
993 : 0 : DPAA_PMD_INFO("Enable Multicast not supported on ONIC port");
994 : 0 : return 0;
995 : : }
996 : :
997 : 0 : fman_if_set_mcast_filter_table(dev->process_private);
998 : :
999 : 0 : return 0;
1000 : : }
1001 : :
1002 : 0 : static int dpaa_eth_multicast_disable(struct rte_eth_dev *dev)
1003 : : {
1004 : 0 : struct fman_if *fif = dev->process_private;
1005 : :
1006 : 0 : PMD_INIT_FUNC_TRACE();
1007 : :
1008 [ # # ]: 0 : if (fif->mac_type == fman_onic) {
1009 : 0 : DPAA_PMD_INFO("Disable Multicast not supported on ONIC port");
1010 : 0 : return 0;
1011 : : }
1012 : :
1013 : 0 : fman_if_reset_mcast_filter_table(dev->process_private);
1014 : :
1015 : 0 : return 0;
1016 : : }
1017 : :
1018 : 0 : static void dpaa_fman_if_pool_setup(struct rte_eth_dev *dev)
1019 : : {
1020 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1021 : : struct fman_if_ic_params icp;
1022 : : uint32_t fd_offset;
1023 : : uint32_t bp_size;
1024 : :
1025 : : memset(&icp, 0, sizeof(icp));
1026 : : /* set ICEOF for to the default value , which is 0*/
1027 : 0 : icp.iciof = DEFAULT_ICIOF;
1028 : 0 : icp.iceof = DEFAULT_RX_ICEOF;
1029 : 0 : icp.icsz = DEFAULT_ICSZ;
1030 : 0 : fman_if_set_ic_params(dev->process_private, &icp);
1031 : :
1032 : : fd_offset = RTE_PKTMBUF_HEADROOM + DPAA_HW_BUF_RESERVE;
1033 : 0 : fman_if_set_fdoff(dev->process_private, fd_offset);
1034 : :
1035 : : /* Buffer pool size should be equal to Dataroom Size*/
1036 [ # # ]: 0 : bp_size = rte_pktmbuf_data_room_size(dpaa_intf->bp_info->mp);
1037 : :
1038 : 0 : fman_if_set_bp(dev->process_private,
1039 : : dpaa_intf->bp_info->mp->size,
1040 : 0 : dpaa_intf->bp_info->bpid, bp_size);
1041 : 0 : }
1042 : :
1043 : 0 : static inline int dpaa_eth_rx_queue_bp_check(struct rte_eth_dev *dev,
1044 : : int8_t vsp_id, uint32_t bpid)
1045 : : {
1046 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1047 : 0 : struct fman_if *fif = dev->process_private;
1048 : :
1049 [ # # ]: 0 : if (fif->num_profiles) {
1050 [ # # ]: 0 : if (vsp_id < 0)
1051 : 0 : vsp_id = fif->base_profile_id;
1052 : : } else {
1053 : : if (vsp_id < 0)
1054 : : vsp_id = 0;
1055 : : }
1056 : :
1057 [ # # # # ]: 0 : if (dpaa_intf->vsp_bpid[vsp_id] &&
1058 : : bpid != dpaa_intf->vsp_bpid[vsp_id]) {
1059 : 0 : DPAA_PMD_ERR("Various MPs are assigned to RXQs with same VSP");
1060 : :
1061 : 0 : return -1;
1062 : : }
1063 : :
1064 : : return 0;
1065 : : }
1066 : :
1067 : : static
1068 : 0 : int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
1069 : : uint16_t nb_desc,
1070 : : unsigned int socket_id __rte_unused,
1071 : : const struct rte_eth_rxconf *rx_conf,
1072 : : struct rte_mempool *mp)
1073 : : {
1074 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1075 : 0 : struct fman_if *fif = dev->process_private;
1076 : 0 : struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_idx];
1077 [ # # ]: 0 : struct qm_mcc_initfq opts = {0};
1078 : : u32 ch_id, flags = 0;
1079 : : int ret;
1080 : 0 : u32 buffsz = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
1081 : : uint32_t max_rx_pktlen;
1082 : :
1083 : 0 : PMD_INIT_FUNC_TRACE();
1084 : :
1085 [ # # ]: 0 : if (queue_idx >= dev->data->nb_rx_queues) {
1086 : 0 : rte_errno = EOVERFLOW;
1087 : 0 : DPAA_PMD_ERR("%p: queue index out of range (%u >= %u)",
1088 : : (void *)dev, queue_idx, dev->data->nb_rx_queues);
1089 : 0 : return -rte_errno;
1090 : : }
1091 : :
1092 : 0 : rxq->nb_desc = UINT16_MAX;
1093 : 0 : rxq->offloads = rx_conf->offloads;
1094 : :
1095 : 0 : DPAA_PMD_INFO("Rx queue setup for queue index: %d fq_id (0x%x)",
1096 : : queue_idx, rxq->fqid);
1097 : :
1098 [ # # ]: 0 : if (!fif->num_profiles) {
1099 [ # # # # ]: 0 : if (dpaa_intf->bp_info && dpaa_intf->bp_info->bp &&
1100 [ # # ]: 0 : dpaa_intf->bp_info->mp != mp) {
1101 : 0 : DPAA_PMD_WARN("Multiple pools on same interface not"
1102 : : " supported");
1103 : 0 : return -EINVAL;
1104 : : }
1105 : : } else {
1106 [ # # ]: 0 : if (dpaa_eth_rx_queue_bp_check(dev, rxq->vsp_id,
1107 : 0 : DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid)) {
1108 : : return -EINVAL;
1109 : : }
1110 : : }
1111 : :
1112 [ # # # # ]: 0 : if (dpaa_intf->bp_info && dpaa_intf->bp_info->bp &&
1113 [ # # ]: 0 : dpaa_intf->bp_info->mp != mp) {
1114 : 0 : DPAA_PMD_WARN("Multiple pools on same interface not supported");
1115 : 0 : return -EINVAL;
1116 : : }
1117 : :
1118 : 0 : max_rx_pktlen = dev->data->mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN +
1119 : : VLAN_TAG_SIZE;
1120 : : /* Max packet can fit in single buffer */
1121 [ # # ]: 0 : if (max_rx_pktlen <= buffsz) {
1122 : : ;
1123 [ # # ]: 0 : } else if (dev->data->dev_conf.rxmode.offloads &
1124 : : RTE_ETH_RX_OFFLOAD_SCATTER) {
1125 [ # # ]: 0 : if (max_rx_pktlen > buffsz * DPAA_SGT_MAX_ENTRIES) {
1126 : 0 : DPAA_PMD_ERR("Maximum Rx packet size %d too big to fit "
1127 : : "MaxSGlist %d",
1128 : : max_rx_pktlen, buffsz * DPAA_SGT_MAX_ENTRIES);
1129 : 0 : rte_errno = EOVERFLOW;
1130 : 0 : return -rte_errno;
1131 : : }
1132 : : } else {
1133 : 0 : DPAA_PMD_WARN("The requested maximum Rx packet size (%u) is"
1134 : : " larger than a single mbuf (%u) and scattered"
1135 : : " mode has not been requested", max_rx_pktlen, buffsz);
1136 : : }
1137 : :
1138 : 0 : dpaa_intf->bp_info = DPAA_MEMPOOL_TO_POOL_INFO(mp);
1139 : :
1140 : : /* For shared interface, it's done in kernel, skip.*/
1141 [ # # # # : 0 : if (!fif->is_shared_mac && fif->mac_type != fman_offline_internal &&
# # ]
1142 : : fif->mac_type != fman_onic)
1143 : 0 : dpaa_fman_if_pool_setup(dev);
1144 : :
1145 [ # # ]: 0 : if (fif->num_profiles) {
1146 : 0 : int8_t vsp_id = rxq->vsp_id;
1147 : :
1148 [ # # ]: 0 : if (vsp_id >= 0) {
1149 : 0 : ret = dpaa_port_vsp_update(dpaa_intf, fmc_q, vsp_id,
1150 : 0 : DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid,
1151 : : fif, buffsz + RTE_PKTMBUF_HEADROOM);
1152 [ # # ]: 0 : if (ret) {
1153 : 0 : DPAA_PMD_ERR("dpaa_port_vsp_update failed");
1154 : 0 : return ret;
1155 : : }
1156 : : } else {
1157 : 0 : DPAA_PMD_INFO("Base profile is associated to"
1158 : : " RXQ fqid:%d", rxq->fqid);
1159 [ # # ]: 0 : if (fif->is_shared_mac) {
1160 : 0 : DPAA_PMD_ERR("Fatal: Base profile is associated"
1161 : : " to shared interface on DPDK.");
1162 : 0 : return -EINVAL;
1163 : : }
1164 : 0 : dpaa_intf->vsp_bpid[fif->base_profile_id] =
1165 : 0 : DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid;
1166 : : }
1167 : : } else {
1168 : 0 : dpaa_intf->vsp_bpid[0] =
1169 : 0 : DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid;
1170 : : }
1171 : :
1172 : 0 : dpaa_intf->valid = 1;
1173 [ # # ]: 0 : if (fif->mac_type != fman_onic)
1174 : 0 : DPAA_PMD_DEBUG("if:%s sg_on = %d, max_frm =%d", dpaa_intf->name,
1175 : : fman_if_get_sg_enable(fif), max_rx_pktlen);
1176 : : /* checking if push mode only, no error check for now */
1177 [ # # ]: 0 : if (!rxq->is_static &&
1178 [ # # ]: 0 : dpaa_push_mode_max_queue > dpaa_push_queue_idx) {
1179 : : struct qman_portal *qp;
1180 : : int q_fd;
1181 : :
1182 : 0 : dpaa_push_queue_idx++;
1183 : 0 : opts.we_mask = QM_INITFQ_WE_FQCTRL | QM_INITFQ_WE_CONTEXTA;
1184 : 0 : opts.fqd.fq_ctrl = QM_FQCTRL_AVOIDBLOCK |
1185 : : QM_FQCTRL_CTXASTASHING |
1186 : : QM_FQCTRL_PREFERINCACHE;
1187 : 0 : opts.fqd.context_a.stashing.exclusive = 0;
1188 : : /* In multicore scenario stashing becomes a bottleneck on LS1046.
1189 : : * So do not enable stashing in this case
1190 : : */
1191 [ # # ]: 0 : if (dpaa_svr_family != SVR_LS1046A_FAMILY)
1192 : 0 : opts.fqd.context_a.stashing.annotation_cl =
1193 : : DPAA_IF_RX_ANNOTATION_STASH;
1194 : 0 : opts.fqd.context_a.stashing.data_cl = DPAA_IF_RX_DATA_STASH;
1195 : 0 : opts.fqd.context_a.stashing.context_cl =
1196 : : DPAA_IF_RX_CONTEXT_STASH;
1197 : :
1198 : : /*Create a channel and associate given queue with the channel*/
1199 : 0 : qman_alloc_pool_range(&ch_id, 1, 1, 0);
1200 : 0 : rxq->ch_id = (u16)ch_id;
1201 : :
1202 : 0 : opts.we_mask = opts.we_mask | QM_INITFQ_WE_DESTWQ;
1203 : 0 : opts.fqd.dest.channel = rxq->ch_id;
1204 : 0 : opts.fqd.dest.wq = DPAA_IF_RX_PRIORITY;
1205 : : flags = QMAN_INITFQ_FLAG_SCHED;
1206 : :
1207 : : /* Configure tail drop */
1208 [ # # ]: 0 : if (dpaa_intf->cgr_rx) {
1209 : 0 : opts.we_mask |= QM_INITFQ_WE_CGID;
1210 : 0 : opts.fqd.cgid = dpaa_intf->cgr_rx[queue_idx].cgrid;
1211 : 0 : opts.fqd.fq_ctrl |= QM_FQCTRL_CGE;
1212 : : }
1213 : 0 : ret = qman_init_fq(rxq, flags, &opts);
1214 [ # # ]: 0 : if (ret) {
1215 : 0 : DPAA_PMD_ERR("Channel/Q association failed. fqid 0x%x "
1216 : : "ret:%d(%s)", rxq->fqid, ret, strerror(ret));
1217 : 0 : return ret;
1218 : : }
1219 [ # # ]: 0 : if (dpaa_svr_family == SVR_LS1043A_FAMILY) {
1220 : 0 : rxq->cb.dqrr_dpdk_pull_cb = dpaa_rx_cb_no_prefetch;
1221 : : } else {
1222 : 0 : rxq->cb.dqrr_dpdk_pull_cb = dpaa_rx_cb;
1223 : 0 : rxq->cb.dqrr_prepare = dpaa_rx_cb_prepare;
1224 : : }
1225 : :
1226 : 0 : rxq->is_static = true;
1227 : :
1228 : : /* Allocate qman specific portals */
1229 : 0 : qp = fsl_qman_fq_portal_create(&q_fd);
1230 [ # # ]: 0 : if (!qp) {
1231 : 0 : DPAA_PMD_ERR("Unable to alloc fq portal");
1232 : 0 : return -1;
1233 : : }
1234 : 0 : rxq->qp = qp;
1235 : :
1236 : : /* Set up the device interrupt handler */
1237 [ # # ]: 0 : if (dev->intr_handle == NULL) {
1238 : : struct rte_dpaa_device *dpaa_dev;
1239 : 0 : struct rte_device *rdev = dev->device;
1240 : :
1241 : 0 : dpaa_dev = container_of(rdev, struct rte_dpaa_device,
1242 : : device);
1243 : 0 : dev->intr_handle = dpaa_dev->intr_handle;
1244 [ # # ]: 0 : if (rte_intr_vec_list_alloc(dev->intr_handle,
1245 : : NULL, dpaa_push_mode_max_queue)) {
1246 : 0 : DPAA_PMD_ERR("intr_vec alloc failed");
1247 : 0 : return -ENOMEM;
1248 : : }
1249 [ # # ]: 0 : if (rte_intr_nb_efd_set(dev->intr_handle,
1250 : : dpaa_push_mode_max_queue))
1251 : 0 : return -rte_errno;
1252 : :
1253 [ # # ]: 0 : if (rte_intr_max_intr_set(dev->intr_handle,
1254 : : dpaa_push_mode_max_queue))
1255 : 0 : return -rte_errno;
1256 : : }
1257 : :
1258 [ # # ]: 0 : if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_EXT))
1259 : 0 : return -rte_errno;
1260 : :
1261 [ # # ]: 0 : if (rte_intr_vec_list_index_set(dev->intr_handle,
1262 : : queue_idx, queue_idx + 1))
1263 : 0 : return -rte_errno;
1264 : :
1265 [ # # ]: 0 : if (rte_intr_efds_index_set(dev->intr_handle, queue_idx,
1266 : : q_fd))
1267 : 0 : return -rte_errno;
1268 : :
1269 : 0 : rxq->q_fd = q_fd;
1270 : : }
1271 : 0 : rxq->bp_array = rte_dpaa_bpid_info;
1272 : 0 : dev->data->rx_queues[queue_idx] = rxq;
1273 : :
1274 : : /* configure the CGR size as per the desc size */
1275 [ # # ]: 0 : if (dpaa_intf->cgr_rx) {
1276 : 0 : struct qm_mcc_initcgr cgr_opts = {0};
1277 : :
1278 : 0 : rxq->nb_desc = nb_desc;
1279 : : /* Enable tail drop with cgr on this queue */
1280 : 0 : qm_cgr_cs_thres_set64(&cgr_opts.cgr.cs_thres, nb_desc, 0);
1281 : 0 : ret = qman_modify_cgr(dpaa_intf->cgr_rx, 0, &cgr_opts);
1282 [ # # ]: 0 : if (ret) {
1283 : 0 : DPAA_PMD_WARN(
1284 : : "rx taildrop modify fail on fqid %d (ret=%d)",
1285 : : rxq->fqid, ret);
1286 : : }
1287 : : }
1288 : :
1289 : : /* Enable main queue to receive error packets also by default */
1290 [ # # ]: 0 : if (fif->mac_type != fman_offline_internal &&
1291 : : fif->mac_type != fman_onic)
1292 : 0 : fman_if_set_err_fqid(fif, rxq->fqid);
1293 : :
1294 : : return 0;
1295 : : }
1296 : :
1297 : : int
1298 : 0 : dpaa_eth_eventq_attach(const struct rte_eth_dev *dev,
1299 : : int eth_rx_queue_id,
1300 : : u16 ch_id,
1301 : : const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
1302 : : {
1303 : : int ret;
1304 : : u32 flags = 0;
1305 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1306 : 0 : struct qman_fq *rxq = &dpaa_intf->rx_queues[eth_rx_queue_id];
1307 : 0 : struct qm_mcc_initfq opts = {0};
1308 : :
1309 [ # # ]: 0 : if (dpaa_push_mode_max_queue) {
1310 : 0 : DPAA_PMD_WARN("PUSH mode q and EVENTDEV are not compatible");
1311 : 0 : DPAA_PMD_WARN("PUSH mode already enabled for first %d queues.",
1312 : : dpaa_push_mode_max_queue);
1313 : 0 : DPAA_PMD_WARN("To disable set DPAA_PUSH_QUEUES_NUMBER to 0");
1314 : : }
1315 : :
1316 : 0 : dpaa_poll_queue_default_config(&opts);
1317 : :
1318 [ # # # ]: 0 : switch (queue_conf->ev.sched_type) {
1319 : 0 : case RTE_SCHED_TYPE_ATOMIC:
1320 : 0 : opts.fqd.fq_ctrl |= QM_FQCTRL_HOLDACTIVE;
1321 : : /* Reset FQCTRL_AVOIDBLOCK bit as it is unnecessary
1322 : : * configuration with HOLD_ACTIVE setting
1323 : : */
1324 : 0 : opts.fqd.fq_ctrl &= (~QM_FQCTRL_AVOIDBLOCK);
1325 : 0 : rxq->cb.dqrr_dpdk_cb = dpaa_rx_cb_atomic;
1326 : 0 : break;
1327 : 0 : case RTE_SCHED_TYPE_ORDERED:
1328 : 0 : DPAA_PMD_ERR("Ordered queue schedule type is not supported");
1329 : 0 : return -1;
1330 : 0 : default:
1331 : 0 : opts.fqd.fq_ctrl |= QM_FQCTRL_AVOIDBLOCK;
1332 : 0 : rxq->cb.dqrr_dpdk_cb = dpaa_rx_cb_parallel;
1333 : 0 : break;
1334 : : }
1335 : :
1336 : 0 : opts.we_mask = opts.we_mask | QM_INITFQ_WE_DESTWQ;
1337 : 0 : opts.fqd.dest.channel = ch_id;
1338 : 0 : opts.fqd.dest.wq = queue_conf->ev.priority;
1339 : :
1340 [ # # ]: 0 : if (dpaa_intf->cgr_rx) {
1341 : 0 : opts.we_mask |= QM_INITFQ_WE_CGID;
1342 : 0 : opts.fqd.cgid = dpaa_intf->cgr_rx[eth_rx_queue_id].cgrid;
1343 : 0 : opts.fqd.fq_ctrl |= QM_FQCTRL_CGE;
1344 : : }
1345 : :
1346 : : flags = QMAN_INITFQ_FLAG_SCHED;
1347 : :
1348 : 0 : ret = qman_init_fq(rxq, flags, &opts);
1349 [ # # ]: 0 : if (ret) {
1350 : 0 : DPAA_PMD_ERR("Ev-Channel/Q association failed. fqid 0x%x "
1351 : : "ret:%d(%s)", rxq->fqid, ret, strerror(ret));
1352 : 0 : return ret;
1353 : : }
1354 : :
1355 : : /* copy configuration which needs to be filled during dequeue */
1356 : 0 : memcpy(&rxq->ev, &queue_conf->ev, sizeof(struct rte_event));
1357 : 0 : dev->data->rx_queues[eth_rx_queue_id] = rxq;
1358 : :
1359 : 0 : return ret;
1360 : : }
1361 : :
1362 : : int
1363 : 0 : dpaa_eth_eventq_detach(const struct rte_eth_dev *dev,
1364 : : int eth_rx_queue_id)
1365 : : {
1366 : 0 : struct qm_mcc_initfq opts = {0};
1367 : : int ret;
1368 : : u32 flags = 0;
1369 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1370 : 0 : struct qman_fq *rxq = &dpaa_intf->rx_queues[eth_rx_queue_id];
1371 : :
1372 : 0 : qman_retire_fq(rxq, NULL);
1373 : 0 : qman_oos_fq(rxq);
1374 : 0 : ret = qman_init_fq(rxq, flags, &opts);
1375 [ # # ]: 0 : if (ret) {
1376 : 0 : DPAA_PMD_ERR("detach rx fqid %d failed with ret: %d",
1377 : : rxq->fqid, ret);
1378 : : }
1379 : :
1380 : 0 : rxq->cb.dqrr_dpdk_cb = NULL;
1381 : 0 : dev->data->rx_queues[eth_rx_queue_id] = NULL;
1382 : :
1383 : 0 : return 0;
1384 : : }
1385 : :
1386 : : static
1387 : 0 : int dpaa_eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
1388 : : uint16_t nb_desc __rte_unused,
1389 : : unsigned int socket_id __rte_unused,
1390 : : const struct rte_eth_txconf *tx_conf)
1391 : : {
1392 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1393 : 0 : struct qman_fq *txq = &dpaa_intf->tx_queues[queue_idx];
1394 : :
1395 : 0 : PMD_INIT_FUNC_TRACE();
1396 : :
1397 : 0 : txq->nb_desc = UINT16_MAX;
1398 : 0 : txq->offloads = tx_conf->offloads;
1399 : :
1400 [ # # ]: 0 : if (queue_idx >= dev->data->nb_tx_queues) {
1401 : 0 : rte_errno = EOVERFLOW;
1402 : 0 : DPAA_PMD_ERR("%p: queue index out of range (%u >= %u)",
1403 : : (void *)dev, queue_idx, dev->data->nb_tx_queues);
1404 : 0 : return -rte_errno;
1405 : : }
1406 : :
1407 : 0 : DPAA_PMD_INFO("Tx queue setup for queue index: %d fq_id (0x%x)",
1408 : : queue_idx, txq->fqid);
1409 : 0 : dev->data->tx_queues[queue_idx] = txq;
1410 : :
1411 : 0 : return 0;
1412 : : }
1413 : :
1414 : : static uint32_t
1415 : 0 : dpaa_dev_rx_queue_count(void *rx_queue)
1416 : : {
1417 : : struct qman_fq *rxq = rx_queue;
1418 : 0 : u32 frm_cnt = 0;
1419 : :
1420 : 0 : PMD_INIT_FUNC_TRACE();
1421 : :
1422 [ # # ]: 0 : if (qman_query_fq_frm_cnt(rxq, &frm_cnt) == 0) {
1423 : 0 : DPAA_PMD_DEBUG("RX frame count for q(%p) is %u",
1424 : : rx_queue, frm_cnt);
1425 : : }
1426 : 0 : return frm_cnt;
1427 : : }
1428 : :
1429 : 0 : static int dpaa_link_down(struct rte_eth_dev *dev)
1430 : : {
1431 : 0 : struct fman_if *fif = dev->process_private;
1432 : : struct __fman_if *__fif;
1433 : :
1434 : 0 : PMD_INIT_FUNC_TRACE();
1435 : :
1436 : : __fif = container_of(fif, struct __fman_if, __if);
1437 : :
1438 [ # # ]: 0 : if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC &&
1439 [ # # # # ]: 0 : fif->mac_type != fman_offline_internal &&
1440 : : fif->mac_type != fman_onic)
1441 : 0 : dpaa_update_link_status(__fif->node_name, RTE_ETH_LINK_DOWN);
1442 : : else
1443 : 0 : return dpaa_eth_dev_stop(dev);
1444 : 0 : return 0;
1445 : : }
1446 : :
1447 : 0 : static int dpaa_link_up(struct rte_eth_dev *dev)
1448 : : {
1449 : 0 : struct fman_if *fif = dev->process_private;
1450 : : struct __fman_if *__fif;
1451 : :
1452 : 0 : PMD_INIT_FUNC_TRACE();
1453 : :
1454 : : __fif = container_of(fif, struct __fman_if, __if);
1455 : :
1456 [ # # ]: 0 : if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC &&
1457 [ # # # # ]: 0 : fif->mac_type != fman_offline_internal &&
1458 : : fif->mac_type != fman_onic)
1459 : 0 : dpaa_update_link_status(__fif->node_name, RTE_ETH_LINK_UP);
1460 : : else
1461 : 0 : dpaa_eth_dev_start(dev);
1462 : 0 : return 0;
1463 : : }
1464 : :
1465 : : static int
1466 : 0 : dpaa_flow_ctrl_set(struct rte_eth_dev *dev,
1467 : : struct rte_eth_fc_conf *fc_conf)
1468 : : {
1469 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1470 : : struct rte_eth_fc_conf *net_fc;
1471 : :
1472 : 0 : PMD_INIT_FUNC_TRACE();
1473 : :
1474 [ # # ]: 0 : if (!(dpaa_intf->fc_conf)) {
1475 : 0 : dpaa_intf->fc_conf = rte_zmalloc(NULL,
1476 : : sizeof(struct rte_eth_fc_conf), MAX_CACHELINE);
1477 [ # # ]: 0 : if (!dpaa_intf->fc_conf) {
1478 : 0 : DPAA_PMD_ERR("unable to save flow control info");
1479 : 0 : return -ENOMEM;
1480 : : }
1481 : : }
1482 : 0 : net_fc = dpaa_intf->fc_conf;
1483 : :
1484 [ # # ]: 0 : if (fc_conf->high_water < fc_conf->low_water) {
1485 : 0 : DPAA_PMD_ERR("Incorrect Flow Control Configuration");
1486 : 0 : return -EINVAL;
1487 : : }
1488 : :
1489 [ # # ]: 0 : if (fc_conf->mode == RTE_ETH_FC_NONE) {
1490 : : return 0;
1491 [ # # ]: 0 : } else if (fc_conf->mode == RTE_ETH_FC_TX_PAUSE ||
1492 : : fc_conf->mode == RTE_ETH_FC_FULL) {
1493 : 0 : fman_if_set_fc_threshold(dev->process_private,
1494 : : fc_conf->high_water,
1495 : : fc_conf->low_water,
1496 : 0 : dpaa_intf->bp_info->bpid);
1497 [ # # ]: 0 : if (fc_conf->pause_time)
1498 : 0 : fman_if_set_fc_quanta(dev->process_private,
1499 : : fc_conf->pause_time);
1500 : : }
1501 : :
1502 : : /* Save the information in dpaa device */
1503 : 0 : net_fc->pause_time = fc_conf->pause_time;
1504 : 0 : net_fc->high_water = fc_conf->high_water;
1505 : 0 : net_fc->low_water = fc_conf->low_water;
1506 : 0 : net_fc->send_xon = fc_conf->send_xon;
1507 : 0 : net_fc->mac_ctrl_frame_fwd = fc_conf->mac_ctrl_frame_fwd;
1508 : 0 : net_fc->mode = fc_conf->mode;
1509 : 0 : net_fc->autoneg = fc_conf->autoneg;
1510 : :
1511 : 0 : return 0;
1512 : : }
1513 : :
1514 : : static int
1515 : 0 : dpaa_flow_ctrl_get(struct rte_eth_dev *dev,
1516 : : struct rte_eth_fc_conf *fc_conf)
1517 : : {
1518 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1519 : 0 : struct rte_eth_fc_conf *net_fc = dpaa_intf->fc_conf;
1520 : : int ret;
1521 : :
1522 : 0 : PMD_INIT_FUNC_TRACE();
1523 : :
1524 [ # # ]: 0 : if (net_fc) {
1525 : 0 : fc_conf->pause_time = net_fc->pause_time;
1526 : 0 : fc_conf->high_water = net_fc->high_water;
1527 : 0 : fc_conf->low_water = net_fc->low_water;
1528 : 0 : fc_conf->send_xon = net_fc->send_xon;
1529 : 0 : fc_conf->mac_ctrl_frame_fwd = net_fc->mac_ctrl_frame_fwd;
1530 : 0 : fc_conf->mode = net_fc->mode;
1531 : 0 : fc_conf->autoneg = net_fc->autoneg;
1532 : 0 : return 0;
1533 : : }
1534 : 0 : ret = fman_if_get_fc_threshold(dev->process_private);
1535 [ # # ]: 0 : if (ret) {
1536 : 0 : fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
1537 : 0 : fc_conf->pause_time =
1538 : 0 : fman_if_get_fc_quanta(dev->process_private);
1539 : : } else {
1540 : 0 : fc_conf->mode = RTE_ETH_FC_NONE;
1541 : : }
1542 : :
1543 : : return 0;
1544 : : }
1545 : :
1546 : : static int
1547 : 0 : dpaa_dev_add_mac_addr(struct rte_eth_dev *dev,
1548 : : struct rte_ether_addr *addr,
1549 : : uint32_t index,
1550 : : __rte_unused uint32_t pool)
1551 : : {
1552 : : int ret;
1553 : 0 : struct fman_if *fif = dev->process_private;
1554 : :
1555 : 0 : PMD_INIT_FUNC_TRACE();
1556 : :
1557 [ # # ]: 0 : if (fif->mac_type == fman_offline_internal) {
1558 : 0 : DPAA_PMD_DEBUG("Add MAC Address not supported on O/H port");
1559 : 0 : return 0;
1560 : : }
1561 : :
1562 [ # # ]: 0 : if (fif->mac_type == fman_onic) {
1563 : 0 : DPAA_PMD_INFO("Add MAC Address not supported on ONIC port");
1564 : 0 : return 0;
1565 : : }
1566 : :
1567 : 0 : ret = fman_if_add_mac_addr(dev->process_private,
1568 : 0 : addr->addr_bytes, index);
1569 : :
1570 [ # # ]: 0 : if (ret)
1571 : 0 : DPAA_PMD_ERR("Adding the MAC ADDR failed: err = %d", ret);
1572 : : return 0;
1573 : : }
1574 : :
1575 : : static void
1576 : 0 : dpaa_dev_remove_mac_addr(struct rte_eth_dev *dev,
1577 : : uint32_t index)
1578 : : {
1579 : 0 : struct fman_if *fif = dev->process_private;
1580 : :
1581 : 0 : PMD_INIT_FUNC_TRACE();
1582 : :
1583 [ # # ]: 0 : if (fif->mac_type == fman_offline_internal) {
1584 : 0 : DPAA_PMD_DEBUG("Remove MAC Address not supported on O/H port");
1585 : 0 : return;
1586 : : }
1587 : :
1588 [ # # ]: 0 : if (fif->mac_type == fman_onic) {
1589 : 0 : DPAA_PMD_INFO("Remove MAC Address not supported on ONIC port");
1590 : 0 : return;
1591 : : }
1592 : :
1593 : 0 : fman_if_clear_mac_addr(dev->process_private, index);
1594 : : }
1595 : :
1596 : : static int
1597 : 0 : dpaa_dev_set_mac_addr(struct rte_eth_dev *dev,
1598 : : struct rte_ether_addr *addr)
1599 : : {
1600 : : int ret;
1601 : 0 : struct fman_if *fif = dev->process_private;
1602 : :
1603 : 0 : PMD_INIT_FUNC_TRACE();
1604 : :
1605 [ # # ]: 0 : if (fif->mac_type == fman_offline_internal) {
1606 : 0 : DPAA_PMD_DEBUG("Set MAC Address not supported on O/H port");
1607 : 0 : return 0;
1608 : : }
1609 : :
1610 [ # # ]: 0 : if (fif->mac_type == fman_onic) {
1611 : 0 : DPAA_PMD_INFO("Set MAC Address not supported on ONIC port");
1612 : 0 : return 0;
1613 : : }
1614 : :
1615 : 0 : ret = fman_if_add_mac_addr(dev->process_private, addr->addr_bytes, 0);
1616 [ # # ]: 0 : if (ret)
1617 : 0 : DPAA_PMD_ERR("Setting the MAC ADDR failed %d", ret);
1618 : :
1619 : : return ret;
1620 : : }
1621 : :
1622 : : static int
1623 : 0 : dpaa_dev_rss_hash_update(struct rte_eth_dev *dev,
1624 : : struct rte_eth_rss_conf *rss_conf)
1625 : : {
1626 : 0 : struct rte_eth_dev_data *data = dev->data;
1627 : : struct rte_eth_conf *eth_conf = &data->dev_conf;
1628 : :
1629 : 0 : PMD_INIT_FUNC_TRACE();
1630 : :
1631 [ # # # # ]: 0 : if (!(default_q || fmc_q)) {
1632 [ # # ]: 0 : if (dpaa_fm_config(dev, rss_conf->rss_hf)) {
1633 : 0 : DPAA_PMD_ERR("FM port configuration: Failed");
1634 : 0 : return -1;
1635 : : }
1636 : 0 : eth_conf->rx_adv_conf.rss_conf.rss_hf = rss_conf->rss_hf;
1637 : : } else {
1638 : 0 : DPAA_PMD_ERR("Function not supported");
1639 : 0 : return -ENOTSUP;
1640 : : }
1641 : 0 : return 0;
1642 : : }
1643 : :
1644 : : static int
1645 : 0 : dpaa_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
1646 : : struct rte_eth_rss_conf *rss_conf)
1647 : : {
1648 : 0 : struct rte_eth_dev_data *data = dev->data;
1649 : : struct rte_eth_conf *eth_conf = &data->dev_conf;
1650 : :
1651 : : /* dpaa does not support rss_key, so length should be 0*/
1652 : 0 : rss_conf->rss_key_len = 0;
1653 : 0 : rss_conf->rss_hf = eth_conf->rx_adv_conf.rss_conf.rss_hf;
1654 : 0 : return 0;
1655 : : }
1656 : :
1657 : 0 : static int dpaa_dev_queue_intr_enable(struct rte_eth_dev *dev,
1658 : : uint16_t queue_id)
1659 : : {
1660 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1661 : 0 : struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_id];
1662 : :
1663 [ # # ]: 0 : if (!rxq->is_static)
1664 : : return -EINVAL;
1665 : :
1666 : 0 : return qman_fq_portal_irqsource_add(rxq->qp, QM_PIRQ_DQRI);
1667 : : }
1668 : :
1669 : 0 : static int dpaa_dev_queue_intr_disable(struct rte_eth_dev *dev,
1670 : : uint16_t queue_id)
1671 : : {
1672 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1673 : 0 : struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_id];
1674 : : uint32_t temp;
1675 : : ssize_t temp1;
1676 : :
1677 [ # # ]: 0 : if (!rxq->is_static)
1678 : : return -EINVAL;
1679 : :
1680 : 0 : qman_fq_portal_irqsource_remove(rxq->qp, ~0);
1681 : :
1682 : 0 : temp1 = read(rxq->q_fd, &temp, sizeof(temp));
1683 [ # # ]: 0 : if (temp1 != sizeof(temp))
1684 : 0 : DPAA_PMD_DEBUG("read did not return anything");
1685 : :
1686 : 0 : qman_fq_portal_thread_irq(rxq->qp);
1687 : :
1688 : 0 : return 0;
1689 : : }
1690 : :
1691 : : static void
1692 : 0 : dpaa_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1693 : : struct rte_eth_rxq_info *qinfo)
1694 : : {
1695 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
1696 : : struct qman_fq *rxq;
1697 : : int ret;
1698 : :
1699 : 0 : rxq = dev->data->rx_queues[queue_id];
1700 : :
1701 : 0 : qinfo->mp = dpaa_intf->bp_info->mp;
1702 : 0 : qinfo->scattered_rx = dev->data->scattered_rx;
1703 : 0 : qinfo->nb_desc = rxq->nb_desc;
1704 : :
1705 : : /* Report the HW Rx buffer length to user */
1706 : 0 : ret = fman_if_get_maxfrm(dev->process_private);
1707 [ # # ]: 0 : if (ret > 0)
1708 : 0 : qinfo->rx_buf_size = ret;
1709 : :
1710 : 0 : qinfo->conf.rx_free_thresh = 1;
1711 : 0 : qinfo->conf.rx_drop_en = 1;
1712 : 0 : qinfo->conf.rx_deferred_start = 0;
1713 : 0 : qinfo->conf.offloads = rxq->offloads;
1714 : 0 : }
1715 : :
1716 : : static void
1717 : 0 : dpaa_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1718 : : struct rte_eth_txq_info *qinfo)
1719 : : {
1720 : : struct qman_fq *txq;
1721 : :
1722 : 0 : txq = dev->data->tx_queues[queue_id];
1723 : :
1724 : 0 : qinfo->nb_desc = txq->nb_desc;
1725 : 0 : qinfo->conf.tx_thresh.pthresh = 0;
1726 : 0 : qinfo->conf.tx_thresh.hthresh = 0;
1727 : 0 : qinfo->conf.tx_thresh.wthresh = 0;
1728 : :
1729 : 0 : qinfo->conf.tx_free_thresh = 0;
1730 : 0 : qinfo->conf.tx_rs_thresh = 0;
1731 : 0 : qinfo->conf.offloads = txq->offloads;
1732 : 0 : qinfo->conf.tx_deferred_start = 0;
1733 : 0 : }
1734 : :
1735 : : static struct eth_dev_ops dpaa_devops = {
1736 : : .dev_configure = dpaa_eth_dev_configure,
1737 : : .dev_start = dpaa_eth_dev_start,
1738 : : .dev_stop = dpaa_eth_dev_stop,
1739 : : .dev_close = dpaa_eth_dev_close,
1740 : : .dev_infos_get = dpaa_eth_dev_info,
1741 : : .dev_supported_ptypes_get = dpaa_supported_ptypes_get,
1742 : :
1743 : : .rx_queue_setup = dpaa_eth_rx_queue_setup,
1744 : : .tx_queue_setup = dpaa_eth_tx_queue_setup,
1745 : : .rx_burst_mode_get = dpaa_dev_rx_burst_mode_get,
1746 : : .tx_burst_mode_get = dpaa_dev_tx_burst_mode_get,
1747 : : .rxq_info_get = dpaa_rxq_info_get,
1748 : : .txq_info_get = dpaa_txq_info_get,
1749 : :
1750 : : .flow_ctrl_get = dpaa_flow_ctrl_get,
1751 : : .flow_ctrl_set = dpaa_flow_ctrl_set,
1752 : :
1753 : : .link_update = dpaa_eth_link_update,
1754 : : .stats_get = dpaa_eth_stats_get,
1755 : : .xstats_get = dpaa_dev_xstats_get,
1756 : : .xstats_get_by_id = dpaa_xstats_get_by_id,
1757 : : .xstats_get_names_by_id = dpaa_xstats_get_names_by_id,
1758 : : .xstats_get_names = dpaa_xstats_get_names,
1759 : : .xstats_reset = dpaa_eth_stats_reset,
1760 : : .stats_reset = dpaa_eth_stats_reset,
1761 : : .promiscuous_enable = dpaa_eth_promiscuous_enable,
1762 : : .promiscuous_disable = dpaa_eth_promiscuous_disable,
1763 : : .allmulticast_enable = dpaa_eth_multicast_enable,
1764 : : .allmulticast_disable = dpaa_eth_multicast_disable,
1765 : : .mtu_set = dpaa_mtu_set,
1766 : : .dev_set_link_down = dpaa_link_down,
1767 : : .dev_set_link_up = dpaa_link_up,
1768 : : .mac_addr_add = dpaa_dev_add_mac_addr,
1769 : : .mac_addr_remove = dpaa_dev_remove_mac_addr,
1770 : : .mac_addr_set = dpaa_dev_set_mac_addr,
1771 : :
1772 : : .fw_version_get = dpaa_fw_version_get,
1773 : :
1774 : : .rx_queue_intr_enable = dpaa_dev_queue_intr_enable,
1775 : : .rx_queue_intr_disable = dpaa_dev_queue_intr_disable,
1776 : : .rss_hash_update = dpaa_dev_rss_hash_update,
1777 : : .rss_hash_conf_get = dpaa_dev_rss_hash_conf_get,
1778 : : .timesync_enable = dpaa_timesync_enable,
1779 : : .timesync_disable = dpaa_timesync_disable,
1780 : : .timesync_read_time = dpaa_timesync_read_time,
1781 : : .timesync_write_time = dpaa_timesync_write_time,
1782 : : .timesync_adjust_time = dpaa_timesync_adjust_time,
1783 : : .timesync_read_rx_timestamp = dpaa_timesync_read_rx_timestamp,
1784 : : .timesync_read_tx_timestamp = dpaa_timesync_read_tx_timestamp,
1785 : : };
1786 : :
1787 : : static bool
1788 : : is_device_supported(struct rte_eth_dev *dev, struct rte_dpaa_driver *drv)
1789 : : {
1790 [ # # ]: 0 : if (strcmp(dev->device->driver->name,
1791 : : drv->driver.name))
1792 : : return false;
1793 : :
1794 : : return true;
1795 : : }
1796 : :
1797 : : static bool
1798 : : is_dpaa_supported(struct rte_eth_dev *dev)
1799 : : {
1800 : : return is_device_supported(dev, &rte_dpaa_pmd);
1801 : : }
1802 : :
1803 : : int
1804 : 0 : rte_pmd_dpaa_set_tx_loopback(uint16_t port, uint8_t on)
1805 : : {
1806 : : struct rte_eth_dev *dev;
1807 : :
1808 [ # # ]: 0 : RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
1809 : :
1810 : : dev = &rte_eth_devices[port];
1811 : :
1812 : : if (!is_dpaa_supported(dev))
1813 : : return -ENOTSUP;
1814 : :
1815 [ # # ]: 0 : if (on)
1816 : 0 : fman_if_loopback_enable(dev->process_private);
1817 : : else
1818 : 0 : fman_if_loopback_disable(dev->process_private);
1819 : :
1820 : : return 0;
1821 : : }
1822 : :
1823 : 0 : static int dpaa_fc_set_default(struct dpaa_if *dpaa_intf,
1824 : : struct fman_if *fman_intf)
1825 : : {
1826 : : struct rte_eth_fc_conf *fc_conf;
1827 : : int ret;
1828 : :
1829 : 0 : PMD_INIT_FUNC_TRACE();
1830 : :
1831 [ # # ]: 0 : if (!(dpaa_intf->fc_conf)) {
1832 : 0 : dpaa_intf->fc_conf = rte_zmalloc(NULL,
1833 : : sizeof(struct rte_eth_fc_conf), MAX_CACHELINE);
1834 [ # # ]: 0 : if (!dpaa_intf->fc_conf) {
1835 : 0 : DPAA_PMD_ERR("unable to save flow control info");
1836 : 0 : return -ENOMEM;
1837 : : }
1838 : : }
1839 : 0 : fc_conf = dpaa_intf->fc_conf;
1840 : 0 : ret = fman_if_get_fc_threshold(fman_intf);
1841 [ # # ]: 0 : if (ret) {
1842 : 0 : fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
1843 : 0 : fc_conf->pause_time = fman_if_get_fc_quanta(fman_intf);
1844 : : } else {
1845 : 0 : fc_conf->mode = RTE_ETH_FC_NONE;
1846 : : }
1847 : :
1848 : : return 0;
1849 : : }
1850 : :
1851 : : /* Initialise an Rx FQ */
1852 : 0 : static int dpaa_rx_queue_init(struct qman_fq *fq, struct qman_cgr *cgr_rx,
1853 : : uint32_t fqid)
1854 : : {
1855 : 0 : struct qm_mcc_initfq opts = {0};
1856 : : int ret;
1857 : : u32 flags = QMAN_FQ_FLAG_NO_ENQUEUE;
1858 : 0 : struct qm_mcc_initcgr cgr_opts = {
1859 : : .we_mask = QM_CGR_WE_CS_THRES |
1860 : : QM_CGR_WE_CSTD_EN |
1861 : : QM_CGR_WE_MODE,
1862 : : .cgr = {
1863 : : .cstd_en = QM_CGR_EN,
1864 : : .mode = QMAN_CGR_MODE_FRAME
1865 : : }
1866 : : };
1867 : :
1868 [ # # # # ]: 0 : if (fmc_q || default_q) {
1869 : : ret = qman_reserve_fqid(fqid);
1870 [ # # ]: 0 : if (ret) {
1871 : 0 : DPAA_PMD_ERR("reserve rx fqid 0x%x failed, ret: %d",
1872 : : fqid, ret);
1873 : 0 : return -EINVAL;
1874 : : }
1875 : : }
1876 : :
1877 : 0 : DPAA_PMD_DEBUG("creating rx fq %p, fqid 0x%x", fq, fqid);
1878 : 0 : ret = qman_create_fq(fqid, flags, fq);
1879 [ # # ]: 0 : if (ret) {
1880 : 0 : DPAA_PMD_ERR("create rx fqid 0x%x failed with ret: %d",
1881 : : fqid, ret);
1882 : 0 : return ret;
1883 : : }
1884 : 0 : fq->is_static = false;
1885 : :
1886 : 0 : dpaa_poll_queue_default_config(&opts);
1887 : :
1888 [ # # ]: 0 : if (cgr_rx) {
1889 : : /* Enable tail drop with cgr on this queue */
1890 : 0 : qm_cgr_cs_thres_set64(&cgr_opts.cgr.cs_thres, td_threshold, 0);
1891 : 0 : cgr_rx->cb = NULL;
1892 : 0 : ret = qman_create_cgr(cgr_rx, QMAN_CGR_FLAG_USE_INIT,
1893 : : &cgr_opts);
1894 [ # # ]: 0 : if (ret) {
1895 : 0 : DPAA_PMD_WARN(
1896 : : "rx taildrop init fail on rx fqid 0x%x(ret=%d)",
1897 : : fq->fqid, ret);
1898 : 0 : goto without_cgr;
1899 : : }
1900 : 0 : opts.we_mask |= QM_INITFQ_WE_CGID;
1901 : 0 : opts.fqd.cgid = cgr_rx->cgrid;
1902 : 0 : opts.fqd.fq_ctrl |= QM_FQCTRL_CGE;
1903 : : }
1904 : 0 : without_cgr:
1905 : 0 : ret = qman_init_fq(fq, 0, &opts);
1906 [ # # ]: 0 : if (ret)
1907 : 0 : DPAA_PMD_ERR("init rx fqid 0x%x failed with ret:%d", fqid, ret);
1908 : : return ret;
1909 : : }
1910 : :
1911 : 0 : uint8_t fm_default_vsp_id(struct fman_if *fif)
1912 : : {
1913 : : /* Avoid being same as base profile which could be used
1914 : : * for kernel interface of shared mac.
1915 : : */
1916 [ # # ]: 0 : if (fif->base_profile_id)
1917 : : return 0;
1918 : : else
1919 : 0 : return DPAA_DEFAULT_RXQ_VSP_ID;
1920 : : }
1921 : :
1922 : : /* Initialise a Tx FQ */
1923 : 0 : static int dpaa_tx_queue_init(struct qman_fq *fq,
1924 : : struct fman_if *fman_intf,
1925 : : struct qman_cgr *cgr_tx)
1926 : : {
1927 : 0 : struct qm_mcc_initfq opts = {0};
1928 : 0 : struct qm_mcc_initcgr cgr_opts = {
1929 : : .we_mask = QM_CGR_WE_CS_THRES |
1930 : : QM_CGR_WE_CSTD_EN |
1931 : : QM_CGR_WE_MODE,
1932 : : .cgr = {
1933 : : .cstd_en = QM_CGR_EN,
1934 : : .mode = QMAN_CGR_MODE_FRAME
1935 : : }
1936 : : };
1937 : : int ret;
1938 : :
1939 : 0 : ret = qman_create_fq(0, QMAN_FQ_FLAG_DYNAMIC_FQID |
1940 : : QMAN_FQ_FLAG_TO_DCPORTAL, fq);
1941 [ # # ]: 0 : if (ret) {
1942 : 0 : DPAA_PMD_ERR("create tx fq failed with ret: %d", ret);
1943 : 0 : return ret;
1944 : : }
1945 : 0 : opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL |
1946 : : QM_INITFQ_WE_CONTEXTB | QM_INITFQ_WE_CONTEXTA;
1947 : 0 : opts.fqd.dest.channel = fman_intf->tx_channel_id;
1948 : 0 : opts.fqd.dest.wq = DPAA_IF_TX_PRIORITY;
1949 : 0 : opts.fqd.fq_ctrl = QM_FQCTRL_PREFERINCACHE;
1950 : 0 : opts.fqd.context_b = 0;
1951 [ # # ]: 0 : if (dpaa_ieee_1588) {
1952 : 0 : opts.fqd.context_a.lo = 0;
1953 : 0 : opts.fqd.context_a.hi = fman_dealloc_bufs_mask_hi;
1954 : : } else {
1955 : : /* no tx-confirmation */
1956 : 0 : opts.fqd.context_a.lo = fman_dealloc_bufs_mask_lo;
1957 : 0 : opts.fqd.context_a.hi = DPAA_FQD_CTX_A_OVERRIDE_FQ |
1958 : : fman_dealloc_bufs_mask_hi;
1959 : : }
1960 : :
1961 [ # # ]: 0 : if (fman_ip_rev >= FMAN_V3)
1962 : : /* Set B0V bit in contextA to set ASPID to 0 */
1963 : 0 : opts.fqd.context_a.hi |= DPAA_FQD_CTX_A_B0_FIELD_VALID;
1964 : :
1965 [ # # ]: 0 : if (fman_intf->mac_type == fman_offline_internal ||
1966 : : fman_intf->mac_type == fman_onic) {
1967 : 0 : opts.fqd.context_a.lo |= DPAA_FQD_CTX_A2_VSPE_BIT;
1968 : 0 : opts.fqd.context_b = fm_default_vsp_id(fman_intf) <<
1969 : : DPAA_FQD_CTX_B_SHIFT_BITS;
1970 : : }
1971 : :
1972 : 0 : DPAA_PMD_DEBUG("init tx fq %p, fqid 0x%x", fq, fq->fqid);
1973 : :
1974 [ # # ]: 0 : if (cgr_tx) {
1975 : : /* Enable tail drop with cgr on this queue */
1976 : 0 : qm_cgr_cs_thres_set64(&cgr_opts.cgr.cs_thres,
1977 : : td_tx_threshold, 0);
1978 : 0 : cgr_tx->cb = NULL;
1979 : 0 : ret = qman_create_cgr(cgr_tx, QMAN_CGR_FLAG_USE_INIT,
1980 : : &cgr_opts);
1981 [ # # ]: 0 : if (ret) {
1982 : 0 : DPAA_PMD_WARN(
1983 : : "rx taildrop init fail on rx fqid 0x%x(ret=%d)",
1984 : : fq->fqid, ret);
1985 : 0 : goto without_cgr;
1986 : : }
1987 : 0 : opts.we_mask |= QM_INITFQ_WE_CGID;
1988 : 0 : opts.fqd.cgid = cgr_tx->cgrid;
1989 : 0 : opts.fqd.fq_ctrl |= QM_FQCTRL_CGE;
1990 : 0 : DPAA_PMD_DEBUG("Tx FQ tail drop enabled, threshold = %d",
1991 : : td_tx_threshold);
1992 : : }
1993 : 0 : without_cgr:
1994 : 0 : ret = qman_init_fq(fq, QMAN_INITFQ_FLAG_SCHED, &opts);
1995 [ # # ]: 0 : if (ret)
1996 : 0 : DPAA_PMD_ERR("init tx fqid 0x%x failed %d", fq->fqid, ret);
1997 : : return ret;
1998 : : }
1999 : :
2000 : : static int
2001 : 0 : dpaa_tx_conf_queue_init(struct qman_fq *fq)
2002 : : {
2003 : 0 : struct qm_mcc_initfq opts = {0};
2004 : : int ret;
2005 : :
2006 : 0 : PMD_INIT_FUNC_TRACE();
2007 : :
2008 : 0 : ret = qman_create_fq(0, QMAN_FQ_FLAG_DYNAMIC_FQID, fq);
2009 [ # # ]: 0 : if (ret) {
2010 : 0 : DPAA_PMD_ERR("create Tx_conf failed with ret: %d", ret);
2011 : 0 : return ret;
2012 : : }
2013 : :
2014 : 0 : opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL;
2015 : 0 : opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
2016 : 0 : ret = qman_init_fq(fq, 0, &opts);
2017 [ # # ]: 0 : if (ret)
2018 : 0 : DPAA_PMD_ERR("init Tx_conf fqid %d failed with ret: %d",
2019 : : fq->fqid, ret);
2020 : : return ret;
2021 : : }
2022 : :
2023 : : #if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
2024 : : /* Initialise a DEBUG FQ ([rt]x_error, rx_default) */
2025 : : static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
2026 : : {
2027 : : struct qm_mcc_initfq opts = {0};
2028 : : int ret;
2029 : :
2030 : : PMD_INIT_FUNC_TRACE();
2031 : :
2032 : : ret = qman_reserve_fqid(fqid);
2033 : : if (ret) {
2034 : : DPAA_PMD_ERR("Reserve fqid %d failed with ret: %d",
2035 : : fqid, ret);
2036 : : return -EINVAL;
2037 : : }
2038 : : /* "map" this Rx FQ to one of the interfaces Tx FQID */
2039 : : DPAA_PMD_DEBUG("Creating fq %p, fqid %d", fq, fqid);
2040 : : ret = qman_create_fq(fqid, QMAN_FQ_FLAG_NO_ENQUEUE, fq);
2041 : : if (ret) {
2042 : : DPAA_PMD_ERR("create fqid %d failed with ret: %d",
2043 : : fqid, ret);
2044 : : return ret;
2045 : : }
2046 : : opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL;
2047 : : opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
2048 : : ret = qman_init_fq(fq, 0, &opts);
2049 : : if (ret)
2050 : : DPAA_PMD_ERR("init fqid %d failed with ret: %d",
2051 : : fqid, ret);
2052 : : return ret;
2053 : : }
2054 : : #endif
2055 : :
2056 : : /* Initialise a network interface */
2057 : : static int
2058 : 0 : dpaa_dev_init_secondary(struct rte_eth_dev *eth_dev)
2059 : : {
2060 : : struct rte_dpaa_device *dpaa_device;
2061 : : struct fm_eth_port_cfg *cfg;
2062 : : struct dpaa_if *dpaa_intf;
2063 : : struct fman_if *fman_intf;
2064 : : int dev_id;
2065 : :
2066 : 0 : PMD_INIT_FUNC_TRACE();
2067 : :
2068 : 0 : dpaa_device = DEV_TO_DPAA_DEVICE(eth_dev->device);
2069 : 0 : dev_id = dpaa_device->id.dev_id;
2070 : 0 : cfg = dpaa_get_eth_port_cfg(dev_id);
2071 : 0 : fman_intf = cfg->fman_if;
2072 : 0 : eth_dev->process_private = fman_intf;
2073 : :
2074 : : /* Plugging of UCODE burst API not supported in Secondary */
2075 : 0 : dpaa_intf = eth_dev->data->dev_private;
2076 : 0 : eth_dev->rx_pkt_burst = dpaa_eth_queue_rx;
2077 [ # # ]: 0 : if (dpaa_intf->cgr_tx)
2078 : 0 : eth_dev->tx_pkt_burst = dpaa_eth_queue_tx_slow;
2079 : : else
2080 : 0 : eth_dev->tx_pkt_burst = dpaa_eth_queue_tx;
2081 : : #ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
2082 : 0 : qman_set_fq_lookup_table(
2083 : 0 : dpaa_intf->rx_queues->qman_fq_lookup_table);
2084 : : #endif
2085 : :
2086 : 0 : return 0;
2087 : : }
2088 : :
2089 : : #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
2090 : : static int
2091 : : dpaa_error_queue_init(struct dpaa_if *dpaa_intf,
2092 : : struct fman_if *fman_intf)
2093 : : {
2094 : : int i, ret;
2095 : : struct qman_fq *err_queues = dpaa_intf->debug_queues;
2096 : : uint32_t err_fqid = 0;
2097 : :
2098 : : if (fman_intf->is_shared_mac) {
2099 : : DPAA_PMD_DEBUG("Shared MAC's err queues are handled in kernel");
2100 : : return 0;
2101 : : }
2102 : :
2103 : : for (i = 0; i < DPAA_DEBUG_FQ_MAX_NUM; i++) {
2104 : : if (i == DPAA_DEBUG_FQ_RX_ERROR)
2105 : : err_fqid = fman_intf->fqid_rx_err;
2106 : : else if (i == DPAA_DEBUG_FQ_TX_ERROR)
2107 : : err_fqid = fman_intf->fqid_tx_err;
2108 : : else
2109 : : continue;
2110 : : ret = dpaa_def_queue_init(&err_queues[i], err_fqid);
2111 : : if (ret) {
2112 : : DPAA_PMD_ERR("DPAA %s ERROR queue init failed!",
2113 : : i == DPAA_DEBUG_FQ_RX_ERROR ?
2114 : : "RX" : "TX");
2115 : : return ret;
2116 : : }
2117 : : err_queues[i].dpaa_intf = dpaa_intf;
2118 : : }
2119 : :
2120 : : return 0;
2121 : : }
2122 : : #endif
2123 : :
2124 : : static int
2125 : 0 : check_devargs_handler(__rte_unused const char *key, const char *value,
2126 : : __rte_unused void *opaque)
2127 : : {
2128 [ # # ]: 0 : if (strcmp(value, "1"))
2129 : 0 : return -1;
2130 : :
2131 : : return 0;
2132 : : }
2133 : :
2134 : : static int
2135 : 0 : dpaa_get_devargs(struct rte_devargs *devargs, const char *key)
2136 : : {
2137 : : struct rte_kvargs *kvlist;
2138 : :
2139 [ # # ]: 0 : if (!devargs)
2140 : : return 0;
2141 : :
2142 : 0 : kvlist = rte_kvargs_parse(devargs->args, NULL);
2143 [ # # ]: 0 : if (!kvlist)
2144 : : return 0;
2145 : :
2146 [ # # ]: 0 : if (!rte_kvargs_count(kvlist, key)) {
2147 : 0 : rte_kvargs_free(kvlist);
2148 : 0 : return 0;
2149 : : }
2150 : :
2151 [ # # ]: 0 : if (rte_kvargs_process(kvlist, key,
2152 : : check_devargs_handler, NULL) < 0) {
2153 : 0 : rte_kvargs_free(kvlist);
2154 : 0 : return 0;
2155 : : }
2156 : 0 : rte_kvargs_free(kvlist);
2157 : :
2158 : 0 : return 1;
2159 : : }
2160 : :
2161 : : /* Initialise a network interface */
2162 : : static int
2163 : 0 : dpaa_dev_init(struct rte_eth_dev *eth_dev)
2164 : : {
2165 : : int num_rx_fqs, fqid;
2166 : : int loop, ret = 0;
2167 : : int dev_id;
2168 : : struct rte_dpaa_device *dpaa_device;
2169 : : struct dpaa_if *dpaa_intf;
2170 : : struct fm_eth_port_cfg *cfg;
2171 : : struct fman_if *fman_intf;
2172 : : struct fman_if_bpool *bp, *tmp_bp;
2173 : : uint32_t cgrid[DPAA_MAX_NUM_PCD_QUEUES];
2174 : : uint32_t cgrid_tx[MAX_DPAA_CORES];
2175 : : uint32_t dev_rx_fqids[DPAA_MAX_NUM_PCD_QUEUES];
2176 : : int8_t dev_vspids[DPAA_MAX_NUM_PCD_QUEUES];
2177 : : int8_t vsp_id = -1;
2178 : 0 : struct rte_device *dev = eth_dev->device;
2179 : : #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
2180 : : char *penv;
2181 : : #endif
2182 : :
2183 : 0 : PMD_INIT_FUNC_TRACE();
2184 : :
2185 : 0 : dpaa_device = DEV_TO_DPAA_DEVICE(eth_dev->device);
2186 : 0 : dev_id = dpaa_device->id.dev_id;
2187 : 0 : dpaa_intf = eth_dev->data->dev_private;
2188 : 0 : cfg = dpaa_get_eth_port_cfg(dev_id);
2189 : 0 : fman_intf = cfg->fman_if;
2190 : :
2191 : 0 : dpaa_intf->name = dpaa_device->name;
2192 : :
2193 : : /* save fman_if & cfg in the interface structure */
2194 : 0 : eth_dev->process_private = fman_intf;
2195 : 0 : dpaa_intf->ifid = dev_id;
2196 : 0 : dpaa_intf->cfg = cfg;
2197 : :
2198 [ # # ]: 0 : if (dpaa_get_devargs(dev->devargs, DRIVER_IEEE1588))
2199 : 0 : dpaa_ieee_1588 = 1;
2200 : :
2201 : : memset((char *)dev_rx_fqids, 0,
2202 : : sizeof(uint32_t) * DPAA_MAX_NUM_PCD_QUEUES);
2203 : :
2204 : : memset(dev_vspids, -1, DPAA_MAX_NUM_PCD_QUEUES);
2205 : :
2206 : : /* Initialize Rx FQ's */
2207 [ # # ]: 0 : if (default_q) {
2208 : : num_rx_fqs = DPAA_DEFAULT_NUM_PCD_QUEUES;
2209 [ # # ]: 0 : } else if (fmc_q) {
2210 : 0 : num_rx_fqs = dpaa_port_fmc_init(fman_intf, dev_rx_fqids,
2211 : : dev_vspids,
2212 : : DPAA_MAX_NUM_PCD_QUEUES);
2213 [ # # ]: 0 : if (num_rx_fqs < 0) {
2214 : 0 : DPAA_PMD_ERR("%s FMC initializes failed!",
2215 : : dpaa_intf->name);
2216 : 0 : goto free_rx;
2217 : : }
2218 [ # # ]: 0 : if (!num_rx_fqs) {
2219 [ # # ]: 0 : if (fman_intf->mac_type == fman_offline_internal ||
2220 : : fman_intf->mac_type == fman_onic) {
2221 : : ret = -ENODEV;
2222 : 0 : goto free_rx;
2223 : : }
2224 : 0 : DPAA_PMD_WARN("%s is not configured by FMC.",
2225 : : dpaa_intf->name);
2226 : : }
2227 : : } else {
2228 : : /* FMCLESS mode, load balance to multiple cores.*/
2229 : 0 : num_rx_fqs = rte_lcore_count();
2230 : : }
2231 : :
2232 : : /* Each device can not have more than DPAA_MAX_NUM_PCD_QUEUES RX
2233 : : * queues.
2234 : : */
2235 [ # # ]: 0 : if (num_rx_fqs < 0 || num_rx_fqs > DPAA_MAX_NUM_PCD_QUEUES) {
2236 : 0 : DPAA_PMD_ERR("Invalid number of RX queues");
2237 : 0 : return -EINVAL;
2238 : : }
2239 : :
2240 [ # # ]: 0 : if (num_rx_fqs > 0) {
2241 : 0 : dpaa_intf->rx_queues = rte_zmalloc(NULL,
2242 : : sizeof(struct qman_fq) * num_rx_fqs, MAX_CACHELINE);
2243 [ # # ]: 0 : if (!dpaa_intf->rx_queues) {
2244 : 0 : DPAA_PMD_ERR("Failed to alloc mem for RX queues");
2245 : 0 : return -ENOMEM;
2246 : : }
2247 : : } else {
2248 : 0 : dpaa_intf->rx_queues = NULL;
2249 : : }
2250 : :
2251 : : memset(cgrid, 0, sizeof(cgrid));
2252 : : memset(cgrid_tx, 0, sizeof(cgrid_tx));
2253 : :
2254 : : /* if DPAA_TX_TAILDROP_THRESHOLD is set, use that value; if 0, it means
2255 : : * Tx tail drop is disabled.
2256 : : */
2257 [ # # ]: 0 : if (getenv("DPAA_TX_TAILDROP_THRESHOLD")) {
2258 : 0 : td_tx_threshold = atoi(getenv("DPAA_TX_TAILDROP_THRESHOLD"));
2259 : 0 : DPAA_PMD_DEBUG("Tail drop threshold env configured: %u",
2260 : : td_tx_threshold);
2261 : : /* if a very large value is being configured */
2262 [ # # ]: 0 : if (td_tx_threshold > UINT16_MAX)
2263 : 0 : td_tx_threshold = CGR_RX_PERFQ_THRESH;
2264 : : }
2265 : :
2266 : : #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
2267 : : penv = getenv("DPAA_DISPLAY_FRAME_AND_PARSER_RESULT");
2268 : : if (penv)
2269 : : dpaa_force_display_frame_set(atoi(penv));
2270 : : #endif
2271 : :
2272 : : /* If congestion control is enabled globally*/
2273 [ # # # # ]: 0 : if (num_rx_fqs > 0 && td_threshold) {
2274 : 0 : dpaa_intf->cgr_rx = rte_zmalloc(NULL,
2275 : : sizeof(struct qman_cgr) * num_rx_fqs, MAX_CACHELINE);
2276 [ # # ]: 0 : if (!dpaa_intf->cgr_rx) {
2277 : 0 : DPAA_PMD_ERR("Failed to alloc mem for cgr_rx");
2278 : : ret = -ENOMEM;
2279 : 0 : goto free_rx;
2280 : : }
2281 : :
2282 : 0 : ret = qman_alloc_cgrid_range(&cgrid[0], num_rx_fqs, 1, 0);
2283 [ # # ]: 0 : if (ret != num_rx_fqs) {
2284 : 0 : DPAA_PMD_WARN("insufficient CGRIDs available");
2285 : : ret = -EINVAL;
2286 : 0 : goto free_rx;
2287 : : }
2288 : : } else {
2289 : 0 : dpaa_intf->cgr_rx = NULL;
2290 : : }
2291 : :
2292 [ # # # # ]: 0 : if (!fmc_q && !default_q) {
2293 : 0 : ret = qman_alloc_fqid_range(dev_rx_fqids, num_rx_fqs,
2294 : : num_rx_fqs, 0);
2295 [ # # ]: 0 : if (ret < 0) {
2296 : 0 : DPAA_PMD_ERR("Failed to alloc rx fqid's");
2297 : 0 : goto free_rx;
2298 : : }
2299 : : }
2300 : :
2301 [ # # ]: 0 : for (loop = 0; loop < num_rx_fqs; loop++) {
2302 [ # # ]: 0 : if (default_q)
2303 : 0 : fqid = cfg->rx_def;
2304 : : else
2305 : 0 : fqid = dev_rx_fqids[loop];
2306 : :
2307 : 0 : vsp_id = dev_vspids[loop];
2308 : :
2309 [ # # ]: 0 : if (dpaa_intf->cgr_rx)
2310 : 0 : dpaa_intf->cgr_rx[loop].cgrid = cgrid[loop];
2311 : :
2312 [ # # ]: 0 : ret = dpaa_rx_queue_init(&dpaa_intf->rx_queues[loop],
2313 : 0 : dpaa_intf->cgr_rx ? &dpaa_intf->cgr_rx[loop] : NULL,
2314 : : fqid);
2315 [ # # ]: 0 : if (ret)
2316 : 0 : goto free_rx;
2317 : 0 : dpaa_intf->rx_queues[loop].vsp_id = vsp_id;
2318 : 0 : dpaa_intf->rx_queues[loop].dpaa_intf = dpaa_intf;
2319 : : }
2320 : 0 : dpaa_intf->nb_rx_queues = num_rx_fqs;
2321 : :
2322 : : /* Initialise Tx FQs.free_rx Have as many Tx FQ's as number of cores */
2323 : 0 : dpaa_intf->tx_queues = rte_zmalloc(NULL, sizeof(struct qman_fq) *
2324 : : MAX_DPAA_CORES, MAX_CACHELINE);
2325 [ # # ]: 0 : if (!dpaa_intf->tx_queues) {
2326 : 0 : DPAA_PMD_ERR("Failed to alloc mem for TX queues");
2327 : : ret = -ENOMEM;
2328 : 0 : goto free_rx;
2329 : : }
2330 : :
2331 : 0 : dpaa_intf->tx_conf_queues = rte_zmalloc(NULL, sizeof(struct qman_fq) *
2332 : : MAX_DPAA_CORES, MAX_CACHELINE);
2333 [ # # ]: 0 : if (!dpaa_intf->tx_conf_queues) {
2334 : 0 : DPAA_PMD_ERR("Failed to alloc mem for TX conf queues");
2335 : : ret = -ENOMEM;
2336 : 0 : goto free_rx;
2337 : : }
2338 : :
2339 : : /* If congestion control is enabled globally*/
2340 [ # # ]: 0 : if (td_tx_threshold) {
2341 : 0 : dpaa_intf->cgr_tx = rte_zmalloc(NULL,
2342 : : sizeof(struct qman_cgr) * MAX_DPAA_CORES,
2343 : : MAX_CACHELINE);
2344 [ # # ]: 0 : if (!dpaa_intf->cgr_tx) {
2345 : 0 : DPAA_PMD_ERR("Failed to alloc mem for cgr_tx");
2346 : : ret = -ENOMEM;
2347 : 0 : goto free_rx;
2348 : : }
2349 : :
2350 : 0 : ret = qman_alloc_cgrid_range(&cgrid_tx[0], MAX_DPAA_CORES,
2351 : : 1, 0);
2352 [ # # ]: 0 : if (ret != MAX_DPAA_CORES) {
2353 : 0 : DPAA_PMD_WARN("insufficient CGRIDs available");
2354 : : ret = -EINVAL;
2355 : 0 : goto free_rx;
2356 : : }
2357 : : } else {
2358 : 0 : dpaa_intf->cgr_tx = NULL;
2359 : : }
2360 : :
2361 : :
2362 [ # # ]: 0 : for (loop = 0; loop < MAX_DPAA_CORES; loop++) {
2363 [ # # ]: 0 : if (dpaa_intf->cgr_tx)
2364 : 0 : dpaa_intf->cgr_tx[loop].cgrid = cgrid_tx[loop];
2365 : :
2366 [ # # ]: 0 : ret = dpaa_tx_queue_init(&dpaa_intf->tx_queues[loop],
2367 : : fman_intf,
2368 : 0 : dpaa_intf->cgr_tx ? &dpaa_intf->cgr_tx[loop] : NULL);
2369 [ # # ]: 0 : if (ret)
2370 : 0 : goto free_tx;
2371 : 0 : dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf;
2372 : :
2373 [ # # ]: 0 : if (dpaa_ieee_1588) {
2374 : 0 : ret = dpaa_tx_conf_queue_init(&dpaa_intf->tx_conf_queues[loop]);
2375 [ # # ]: 0 : if (ret)
2376 : 0 : goto free_tx;
2377 : :
2378 : 0 : dpaa_intf->tx_conf_queues[loop].dpaa_intf = dpaa_intf;
2379 : 0 : dpaa_intf->tx_queues[loop].tx_conf_queue = &dpaa_intf->tx_conf_queues[loop];
2380 : : }
2381 : : }
2382 : 0 : dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
2383 : : #if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
2384 : : ret = dpaa_error_queue_init(dpaa_intf, fman_intf);
2385 : : if (ret)
2386 : : goto free_tx;
2387 : : #endif
2388 : 0 : DPAA_PMD_DEBUG("All frame queues created");
2389 : :
2390 : : /* Get the initial configuration for flow control */
2391 [ # # ]: 0 : if (fman_intf->mac_type != fman_offline_internal &&
2392 : : fman_intf->mac_type != fman_onic)
2393 : 0 : dpaa_fc_set_default(dpaa_intf, fman_intf);
2394 : :
2395 : : /* reset bpool list, initialize bpool dynamically */
2396 [ # # ]: 0 : list_for_each_entry_safe(bp, tmp_bp, &cfg->fman_if->bpool_list, node) {
2397 : 0 : list_del(&bp->node);
2398 : 0 : rte_free(bp);
2399 : : }
2400 : :
2401 : : /* Populate ethdev structure */
2402 : 0 : eth_dev->dev_ops = &dpaa_devops;
2403 : 0 : eth_dev->rx_queue_count = dpaa_dev_rx_queue_count;
2404 : 0 : eth_dev->rx_pkt_burst = dpaa_eth_queue_rx;
2405 : 0 : eth_dev->tx_pkt_burst = dpaa_eth_tx_drop_all;
2406 : :
2407 : : /* Allocate memory for storing MAC addresses */
2408 : 0 : eth_dev->data->mac_addrs = rte_zmalloc("mac_addr",
2409 : : RTE_ETHER_ADDR_LEN * DPAA_MAX_MAC_FILTER, 0);
2410 [ # # ]: 0 : if (eth_dev->data->mac_addrs == NULL) {
2411 : 0 : DPAA_PMD_ERR("Failed to allocate %d bytes needed to "
2412 : : "store MAC addresses",
2413 : : RTE_ETHER_ADDR_LEN * DPAA_MAX_MAC_FILTER);
2414 : : ret = -ENOMEM;
2415 : 0 : goto free_tx;
2416 : : }
2417 : :
2418 : : /* copy the primary mac address */
2419 : : rte_ether_addr_copy(&fman_intf->mac_addr, ð_dev->data->mac_addrs[0]);
2420 : :
2421 : 0 : DPAA_PMD_INFO("net: dpaa: %s: " RTE_ETHER_ADDR_PRT_FMT,
2422 : : dpaa_device->name, RTE_ETHER_ADDR_BYTES(&fman_intf->mac_addr));
2423 : :
2424 [ # # ]: 0 : if (!fman_intf->is_shared_mac &&
2425 [ # # # # ]: 0 : fman_intf->mac_type != fman_offline_internal &&
2426 : : fman_intf->mac_type != fman_onic) {
2427 : : /* Configure error packet handling */
2428 : 0 : fman_if_receive_rx_errors(fman_intf,
2429 : : FM_FD_RX_STATUS_ERR_MASK);
2430 : : /* Disable RX mode */
2431 : 0 : fman_if_disable_rx(fman_intf);
2432 : : /* Disable promiscuous mode */
2433 : 0 : fman_if_promiscuous_disable(fman_intf);
2434 : : /* Disable multicast */
2435 : 0 : fman_if_reset_mcast_filter_table(fman_intf);
2436 : : /* Reset interface statistics */
2437 : 0 : fman_if_stats_reset(fman_intf);
2438 : : /* Disable SG by default */
2439 : 0 : fman_if_set_sg(fman_intf, 0);
2440 : 0 : fman_if_set_maxfrm(fman_intf,
2441 : : RTE_ETHER_MAX_LEN + VLAN_TAG_SIZE);
2442 : : }
2443 : :
2444 : : return 0;
2445 : :
2446 : 0 : free_tx:
2447 : 0 : rte_free(dpaa_intf->tx_queues);
2448 : 0 : dpaa_intf->tx_queues = NULL;
2449 : 0 : dpaa_intf->nb_tx_queues = 0;
2450 : :
2451 : 0 : free_rx:
2452 : 0 : rte_free(dpaa_intf->cgr_rx);
2453 : 0 : rte_free(dpaa_intf->cgr_tx);
2454 : 0 : rte_free(dpaa_intf->rx_queues);
2455 : 0 : dpaa_intf->rx_queues = NULL;
2456 : 0 : dpaa_intf->nb_rx_queues = 0;
2457 : 0 : return ret;
2458 : : }
2459 : :
2460 : : static int
2461 : 0 : rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv,
2462 : : struct rte_dpaa_device *dpaa_dev)
2463 : : {
2464 : : int diag;
2465 : : int ret;
2466 : : struct rte_eth_dev *eth_dev;
2467 : :
2468 : 0 : PMD_INIT_FUNC_TRACE();
2469 : :
2470 : : if ((DPAA_MBUF_HW_ANNOTATION + DPAA_FD_PTA_SIZE) >
2471 : : RTE_PKTMBUF_HEADROOM) {
2472 : : DPAA_PMD_ERR(
2473 : : "RTE_PKTMBUF_HEADROOM(%d) shall be > DPAA Annotation req(%d)",
2474 : : RTE_PKTMBUF_HEADROOM,
2475 : : DPAA_MBUF_HW_ANNOTATION + DPAA_FD_PTA_SIZE);
2476 : :
2477 : : return -1;
2478 : : }
2479 : :
2480 : : /* In case of secondary process, the device is already configured
2481 : : * and no further action is required, except portal initialization
2482 : : * and verifying secondary attachment to port name.
2483 : : */
2484 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
2485 : 0 : eth_dev = rte_eth_dev_attach_secondary(dpaa_dev->name);
2486 [ # # ]: 0 : if (!eth_dev)
2487 : : return -ENOMEM;
2488 : 0 : eth_dev->device = &dpaa_dev->device;
2489 : 0 : eth_dev->dev_ops = &dpaa_devops;
2490 : :
2491 : 0 : ret = dpaa_dev_init_secondary(eth_dev);
2492 [ # # ]: 0 : if (ret != 0) {
2493 : 0 : DPAA_PMD_ERR("secondary dev init failed");
2494 : 0 : return ret;
2495 : : }
2496 : :
2497 : 0 : rte_eth_dev_probing_finish(eth_dev);
2498 : 0 : return 0;
2499 : : }
2500 : :
2501 [ # # # # ]: 0 : if (!is_global_init && (rte_eal_process_type() == RTE_PROC_PRIMARY)) {
2502 [ # # ]: 0 : if (access("/tmp/fmc.bin", F_OK) == -1) {
2503 : 0 : DPAA_PMD_INFO("* FMC not configured.Enabling default mode");
2504 : 0 : default_q = 1;
2505 : : }
2506 : :
2507 [ # # # # ]: 0 : if (!(default_q || fmc_q)) {
2508 [ # # ]: 0 : if (dpaa_fm_init()) {
2509 : 0 : DPAA_PMD_ERR("FM init failed");
2510 : 0 : return -1;
2511 : : }
2512 : : }
2513 : :
2514 : : /* disabling the default push mode for LS1043 */
2515 [ # # ]: 0 : if (dpaa_svr_family == SVR_LS1043A_FAMILY)
2516 : 0 : dpaa_push_mode_max_queue = 0;
2517 : :
2518 : : /* if push mode queues to be enabled. Currently we are allowing
2519 : : * only one queue per thread.
2520 : : */
2521 [ # # ]: 0 : if (getenv("DPAA_PUSH_QUEUES_NUMBER")) {
2522 : 0 : dpaa_push_mode_max_queue =
2523 : 0 : atoi(getenv("DPAA_PUSH_QUEUES_NUMBER"));
2524 [ # # ]: 0 : if (dpaa_push_mode_max_queue > DPAA_MAX_PUSH_MODE_QUEUE)
2525 : 0 : dpaa_push_mode_max_queue = DPAA_MAX_PUSH_MODE_QUEUE;
2526 : : }
2527 : :
2528 : 0 : is_global_init = 1;
2529 : : }
2530 : :
2531 [ # # ]: 0 : if (unlikely(!DPAA_PER_LCORE_PORTAL)) {
2532 : 0 : ret = rte_dpaa_portal_init((void *)1);
2533 [ # # ]: 0 : if (ret) {
2534 : 0 : DPAA_PMD_ERR("Unable to initialize portal");
2535 : 0 : return ret;
2536 : : }
2537 : : }
2538 : :
2539 : 0 : eth_dev = rte_eth_dev_allocate(dpaa_dev->name);
2540 [ # # ]: 0 : if (!eth_dev)
2541 : : return -ENOMEM;
2542 : :
2543 : 0 : eth_dev->data->dev_private =
2544 : 0 : rte_zmalloc("ethdev private structure",
2545 : : sizeof(struct dpaa_if),
2546 : : RTE_CACHE_LINE_SIZE);
2547 [ # # ]: 0 : if (!eth_dev->data->dev_private) {
2548 : 0 : DPAA_PMD_ERR("Cannot allocate memzone for port data");
2549 : 0 : rte_eth_dev_release_port(eth_dev);
2550 : 0 : return -ENOMEM;
2551 : : }
2552 : :
2553 : 0 : eth_dev->device = &dpaa_dev->device;
2554 : 0 : dpaa_dev->eth_dev = eth_dev;
2555 : :
2556 : 0 : qman_ern_register_cb(dpaa_free_mbuf);
2557 : :
2558 [ # # ]: 0 : if (dpaa_drv->drv_flags & RTE_DPAA_DRV_INTR_LSC)
2559 : 0 : eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
2560 : :
2561 : : /* Invoke PMD device initialization function */
2562 : 0 : diag = dpaa_dev_init(eth_dev);
2563 [ # # ]: 0 : if (diag == 0) {
2564 [ # # ]: 0 : if (!dpaa_tx_sg_pool) {
2565 : 0 : dpaa_tx_sg_pool =
2566 : 0 : rte_pktmbuf_pool_create("dpaa_mbuf_tx_sg_pool",
2567 : : DPAA_POOL_SIZE,
2568 : : DPAA_POOL_CACHE_SIZE, 0,
2569 : : DPAA_MAX_SGS * sizeof(struct qm_sg_entry),
2570 : 0 : rte_socket_id());
2571 [ # # ]: 0 : if (dpaa_tx_sg_pool == NULL) {
2572 : 0 : DPAA_PMD_ERR("SG pool creation failed");
2573 : 0 : return -ENOMEM;
2574 : : }
2575 : : }
2576 : 0 : rte_eth_dev_probing_finish(eth_dev);
2577 : 0 : dpaa_valid_dev++;
2578 : 0 : return 0;
2579 : : }
2580 : :
2581 : 0 : rte_eth_dev_release_port(eth_dev);
2582 : 0 : return diag;
2583 : : }
2584 : :
2585 : : static int
2586 : 0 : rte_dpaa_remove(struct rte_dpaa_device *dpaa_dev)
2587 : : {
2588 : : struct rte_eth_dev *eth_dev;
2589 : : int ret;
2590 : :
2591 : 0 : PMD_INIT_FUNC_TRACE();
2592 : :
2593 : 0 : eth_dev = dpaa_dev->eth_dev;
2594 : 0 : dpaa_eth_dev_close(eth_dev);
2595 : 0 : dpaa_valid_dev--;
2596 [ # # ]: 0 : if (!dpaa_valid_dev)
2597 : 0 : rte_mempool_free(dpaa_tx_sg_pool);
2598 : 0 : ret = rte_eth_dev_release_port(eth_dev);
2599 : :
2600 : 0 : return ret;
2601 : : }
2602 : :
2603 : 252 : static void __attribute__((destructor(102))) dpaa_finish(void)
2604 : : {
2605 : : /* For secondary, primary will do all the cleanup */
2606 [ + + ]: 252 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2607 : : return;
2608 : :
2609 [ + - - + ]: 224 : if (!(default_q || fmc_q)) {
2610 [ # # ]: 0 : if (is_global_init)
2611 [ # # ]: 0 : if (dpaa_fm_term())
2612 : 0 : DPAA_PMD_WARN("DPAA FM term failed");
2613 : :
2614 : 0 : is_global_init = 0;
2615 : :
2616 : 0 : DPAA_PMD_INFO("DPAA fman cleaned up");
2617 : : }
2618 : : }
2619 : :
2620 : : static struct rte_dpaa_driver rte_dpaa_pmd = {
2621 : : .drv_flags = RTE_DPAA_DRV_INTR_LSC,
2622 : : .drv_type = FSL_DPAA_ETH,
2623 : : .probe = rte_dpaa_probe,
2624 : : .remove = rte_dpaa_remove,
2625 : : };
2626 : :
2627 : 252 : RTE_PMD_REGISTER_DPAA(net_dpaa, rte_dpaa_pmd);
2628 : : RTE_PMD_REGISTER_PARAM_STRING(net_dpaa,
2629 : : DRIVER_IEEE1588 "=<int>");
2630 [ - + ]: 252 : RTE_LOG_REGISTER_DEFAULT(dpaa_logtype_pmd, NOTICE);
|