1 /* * SPDX-License-Identifier: BSD-3-Clause 2 * 3 * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. 4 * Copyright 2016 NXP 5 * 6 */ 7 8 #include <time.h> 9 #include <net/if.h> 10 11 #include <rte_mbuf.h> 12 #include <rte_ethdev_driver.h> 13 #include <rte_malloc.h> 14 #include <rte_memcpy.h> 15 #include <rte_string_fns.h> 16 #include <rte_cycles.h> 17 #include <rte_kvargs.h> 18 #include <rte_dev.h> 19 #include <rte_fslmc.h> 20 #include <rte_flow_driver.h> 21 22 #include "dpaa2_pmd_logs.h" 23 #include <fslmc_vfio.h> 24 #include <dpaa2_hw_pvt.h> 25 #include <dpaa2_hw_mempool.h> 26 #include <dpaa2_hw_dpio.h> 27 #include <mc/fsl_dpmng.h> 28 #include "dpaa2_ethdev.h" 29 #include <fsl_qbman_debug.h> 30 31 #define DRIVER_LOOPBACK_MODE "drv_loopback" 32 33 /* Supported Rx offloads */ 34 static uint64_t dev_rx_offloads_sup = 35 DEV_RX_OFFLOAD_VLAN_STRIP | 36 DEV_RX_OFFLOAD_IPV4_CKSUM | 37 DEV_RX_OFFLOAD_UDP_CKSUM | 38 DEV_RX_OFFLOAD_TCP_CKSUM | 39 DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | 40 DEV_RX_OFFLOAD_VLAN_FILTER | 41 DEV_RX_OFFLOAD_JUMBO_FRAME; 42 43 /* Rx offloads which cannot be disabled */ 44 static uint64_t dev_rx_offloads_nodis = 45 DEV_RX_OFFLOAD_SCATTER; 46 47 /* Supported Tx offloads */ 48 static uint64_t dev_tx_offloads_sup = 49 DEV_TX_OFFLOAD_VLAN_INSERT | 50 DEV_TX_OFFLOAD_IPV4_CKSUM | 51 DEV_TX_OFFLOAD_UDP_CKSUM | 52 DEV_TX_OFFLOAD_TCP_CKSUM | 53 DEV_TX_OFFLOAD_SCTP_CKSUM | 54 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 55 56 /* Tx offloads which cannot be disabled */ 57 static uint64_t dev_tx_offloads_nodis = 58 DEV_TX_OFFLOAD_MULTI_SEGS | 59 DEV_TX_OFFLOAD_MT_LOCKFREE | 60 DEV_TX_OFFLOAD_MBUF_FAST_FREE; 61 62 /* enable timestamp in mbuf */ 63 enum pmd_dpaa2_ts dpaa2_enable_ts; 64 65 struct rte_dpaa2_xstats_name_off { 66 char name[RTE_ETH_XSTATS_NAME_SIZE]; 67 uint8_t page_id; /* dpni statistics page id */ 68 uint8_t stats_id; /* stats id in the given page */ 69 }; 70 71 static const struct rte_dpaa2_xstats_name_off dpaa2_xstats_strings[] = { 72 {"ingress_multicast_frames", 0, 2}, 73 {"ingress_multicast_bytes", 0, 3}, 74 {"ingress_broadcast_frames", 0, 4}, 75 {"ingress_broadcast_bytes", 0, 5}, 76 {"egress_multicast_frames", 1, 2}, 77 {"egress_multicast_bytes", 1, 3}, 78 {"egress_broadcast_frames", 1, 4}, 79 {"egress_broadcast_bytes", 1, 5}, 80 {"ingress_filtered_frames", 2, 0}, 81 {"ingress_discarded_frames", 2, 1}, 82 {"ingress_nobuffer_discards", 2, 2}, 83 {"egress_discarded_frames", 2, 3}, 84 {"egress_confirmed_frames", 2, 4}, 85 }; 86 87 static const enum rte_filter_op dpaa2_supported_filter_ops[] = { 88 RTE_ETH_FILTER_ADD, 89 RTE_ETH_FILTER_DELETE, 90 RTE_ETH_FILTER_UPDATE, 91 RTE_ETH_FILTER_FLUSH, 92 RTE_ETH_FILTER_GET 93 }; 94 95 static struct rte_dpaa2_driver rte_dpaa2_pmd; 96 static int dpaa2_dev_uninit(struct rte_eth_dev *eth_dev); 97 static int dpaa2_dev_link_update(struct rte_eth_dev *dev, 98 int wait_to_complete); 99 static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev); 100 static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev); 101 static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); 102 103 int dpaa2_logtype_pmd; 104 105 void 106 rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts enable) 107 { 108 dpaa2_enable_ts = enable; 109 } 110 111 static int 112 dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) 113 { 114 int ret; 115 struct dpaa2_dev_priv *priv = dev->data->dev_private; 116 struct fsl_mc_io *dpni = priv->hw; 117 118 PMD_INIT_FUNC_TRACE(); 119 120 if (dpni == NULL) { 121 DPAA2_PMD_ERR("dpni is NULL"); 122 return -1; 123 } 124 125 if (on) 126 ret = dpni_add_vlan_id(dpni, CMD_PRI_LOW, 127 priv->token, vlan_id); 128 else 129 ret = dpni_remove_vlan_id(dpni, CMD_PRI_LOW, 130 priv->token, vlan_id); 131 132 if (ret < 0) 133 DPAA2_PMD_ERR("ret = %d Unable to add/rem vlan %d hwid =%d", 134 ret, vlan_id, priv->hw_id); 135 136 return ret; 137 } 138 139 static int 140 dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) 141 { 142 struct dpaa2_dev_priv *priv = dev->data->dev_private; 143 struct fsl_mc_io *dpni = priv->hw; 144 int ret; 145 146 PMD_INIT_FUNC_TRACE(); 147 148 if (mask & ETH_VLAN_FILTER_MASK) { 149 /* VLAN Filter not avaialble */ 150 if (!priv->max_vlan_filters) { 151 DPAA2_PMD_INFO("VLAN filter not available"); 152 goto next_mask; 153 } 154 155 if (dev->data->dev_conf.rxmode.offloads & 156 DEV_RX_OFFLOAD_VLAN_FILTER) 157 ret = dpni_enable_vlan_filter(dpni, CMD_PRI_LOW, 158 priv->token, true); 159 else 160 ret = dpni_enable_vlan_filter(dpni, CMD_PRI_LOW, 161 priv->token, false); 162 if (ret < 0) 163 DPAA2_PMD_INFO("Unable to set vlan filter = %d", ret); 164 } 165 next_mask: 166 if (mask & ETH_VLAN_EXTEND_MASK) { 167 if (dev->data->dev_conf.rxmode.offloads & 168 DEV_RX_OFFLOAD_VLAN_EXTEND) 169 DPAA2_PMD_INFO("VLAN extend offload not supported"); 170 } 171 172 return 0; 173 } 174 175 static int 176 dpaa2_vlan_tpid_set(struct rte_eth_dev *dev, 177 enum rte_vlan_type vlan_type __rte_unused, 178 uint16_t tpid) 179 { 180 struct dpaa2_dev_priv *priv = dev->data->dev_private; 181 struct fsl_mc_io *dpni = priv->hw; 182 int ret = -ENOTSUP; 183 184 PMD_INIT_FUNC_TRACE(); 185 186 /* nothing to be done for standard vlan tpids */ 187 if (tpid == 0x8100 || tpid == 0x88A8) 188 return 0; 189 190 ret = dpni_add_custom_tpid(dpni, CMD_PRI_LOW, 191 priv->token, tpid); 192 if (ret < 0) 193 DPAA2_PMD_INFO("Unable to set vlan tpid = %d", ret); 194 /* if already configured tpids, remove them first */ 195 if (ret == -EBUSY) { 196 struct dpni_custom_tpid_cfg tpid_list = {0}; 197 198 ret = dpni_get_custom_tpid(dpni, CMD_PRI_LOW, 199 priv->token, &tpid_list); 200 if (ret < 0) 201 goto fail; 202 ret = dpni_remove_custom_tpid(dpni, CMD_PRI_LOW, 203 priv->token, tpid_list.tpid1); 204 if (ret < 0) 205 goto fail; 206 ret = dpni_add_custom_tpid(dpni, CMD_PRI_LOW, 207 priv->token, tpid); 208 } 209 fail: 210 return ret; 211 } 212 213 static int 214 dpaa2_fw_version_get(struct rte_eth_dev *dev, 215 char *fw_version, 216 size_t fw_size) 217 { 218 int ret; 219 struct dpaa2_dev_priv *priv = dev->data->dev_private; 220 struct fsl_mc_io *dpni = priv->hw; 221 struct mc_soc_version mc_plat_info = {0}; 222 struct mc_version mc_ver_info = {0}; 223 224 PMD_INIT_FUNC_TRACE(); 225 226 if (mc_get_soc_version(dpni, CMD_PRI_LOW, &mc_plat_info)) 227 DPAA2_PMD_WARN("\tmc_get_soc_version failed"); 228 229 if (mc_get_version(dpni, CMD_PRI_LOW, &mc_ver_info)) 230 DPAA2_PMD_WARN("\tmc_get_version failed"); 231 232 ret = snprintf(fw_version, fw_size, 233 "%x-%d.%d.%d", 234 mc_plat_info.svr, 235 mc_ver_info.major, 236 mc_ver_info.minor, 237 mc_ver_info.revision); 238 239 ret += 1; /* add the size of '\0' */ 240 if (fw_size < (uint32_t)ret) 241 return ret; 242 else 243 return 0; 244 } 245 246 static int 247 dpaa2_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) 248 { 249 struct dpaa2_dev_priv *priv = dev->data->dev_private; 250 251 PMD_INIT_FUNC_TRACE(); 252 253 dev_info->if_index = priv->hw_id; 254 255 dev_info->max_mac_addrs = priv->max_mac_filters; 256 dev_info->max_rx_pktlen = DPAA2_MAX_RX_PKT_LEN; 257 dev_info->min_rx_bufsize = DPAA2_MIN_RX_BUF_SIZE; 258 dev_info->max_rx_queues = (uint16_t)priv->nb_rx_queues; 259 dev_info->max_tx_queues = (uint16_t)priv->nb_tx_queues; 260 dev_info->rx_offload_capa = dev_rx_offloads_sup | 261 dev_rx_offloads_nodis; 262 dev_info->tx_offload_capa = dev_tx_offloads_sup | 263 dev_tx_offloads_nodis; 264 dev_info->speed_capa = ETH_LINK_SPEED_1G | 265 ETH_LINK_SPEED_2_5G | 266 ETH_LINK_SPEED_10G; 267 268 dev_info->max_hash_mac_addrs = 0; 269 dev_info->max_vfs = 0; 270 dev_info->max_vmdq_pools = ETH_16_POOLS; 271 dev_info->flow_type_rss_offloads = DPAA2_RSS_OFFLOAD_ALL; 272 273 return 0; 274 } 275 276 static int 277 dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) 278 { 279 struct dpaa2_dev_priv *priv = dev->data->dev_private; 280 uint16_t dist_idx; 281 uint32_t vq_id; 282 uint8_t num_rxqueue_per_tc; 283 struct dpaa2_queue *mc_q, *mcq; 284 uint32_t tot_queues; 285 int i; 286 struct dpaa2_queue *dpaa2_q; 287 288 PMD_INIT_FUNC_TRACE(); 289 290 num_rxqueue_per_tc = (priv->nb_rx_queues / priv->num_rx_tc); 291 tot_queues = priv->nb_rx_queues + priv->nb_tx_queues; 292 mc_q = rte_malloc(NULL, sizeof(struct dpaa2_queue) * tot_queues, 293 RTE_CACHE_LINE_SIZE); 294 if (!mc_q) { 295 DPAA2_PMD_ERR("Memory allocation failed for rx/tx queues"); 296 return -1; 297 } 298 299 for (i = 0; i < priv->nb_rx_queues; i++) { 300 mc_q->eth_data = dev->data; 301 priv->rx_vq[i] = mc_q++; 302 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i]; 303 dpaa2_q->q_storage = rte_malloc("dq_storage", 304 sizeof(struct queue_storage_info_t), 305 RTE_CACHE_LINE_SIZE); 306 if (!dpaa2_q->q_storage) 307 goto fail; 308 309 memset(dpaa2_q->q_storage, 0, 310 sizeof(struct queue_storage_info_t)); 311 if (dpaa2_alloc_dq_storage(dpaa2_q->q_storage)) 312 goto fail; 313 } 314 315 for (i = 0; i < priv->nb_tx_queues; i++) { 316 mc_q->eth_data = dev->data; 317 mc_q->flow_id = 0xffff; 318 priv->tx_vq[i] = mc_q++; 319 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i]; 320 dpaa2_q->cscn = rte_malloc(NULL, 321 sizeof(struct qbman_result), 16); 322 if (!dpaa2_q->cscn) 323 goto fail_tx; 324 } 325 326 vq_id = 0; 327 for (dist_idx = 0; dist_idx < priv->nb_rx_queues; dist_idx++) { 328 mcq = (struct dpaa2_queue *)priv->rx_vq[vq_id]; 329 mcq->tc_index = dist_idx / num_rxqueue_per_tc; 330 mcq->flow_id = dist_idx % num_rxqueue_per_tc; 331 vq_id++; 332 } 333 334 return 0; 335 fail_tx: 336 i -= 1; 337 while (i >= 0) { 338 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i]; 339 rte_free(dpaa2_q->cscn); 340 priv->tx_vq[i--] = NULL; 341 } 342 i = priv->nb_rx_queues; 343 fail: 344 i -= 1; 345 mc_q = priv->rx_vq[0]; 346 while (i >= 0) { 347 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i]; 348 dpaa2_free_dq_storage(dpaa2_q->q_storage); 349 rte_free(dpaa2_q->q_storage); 350 priv->rx_vq[i--] = NULL; 351 } 352 rte_free(mc_q); 353 return -1; 354 } 355 356 static void 357 dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev) 358 { 359 struct dpaa2_dev_priv *priv = dev->data->dev_private; 360 struct dpaa2_queue *dpaa2_q; 361 int i; 362 363 PMD_INIT_FUNC_TRACE(); 364 365 /* Queue allocation base */ 366 if (priv->rx_vq[0]) { 367 /* cleaning up queue storage */ 368 for (i = 0; i < priv->nb_rx_queues; i++) { 369 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i]; 370 if (dpaa2_q->q_storage) 371 rte_free(dpaa2_q->q_storage); 372 } 373 /* cleanup tx queue cscn */ 374 for (i = 0; i < priv->nb_tx_queues; i++) { 375 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i]; 376 rte_free(dpaa2_q->cscn); 377 } 378 /*free memory for all queues (RX+TX) */ 379 rte_free(priv->rx_vq[0]); 380 priv->rx_vq[0] = NULL; 381 } 382 } 383 384 static int 385 dpaa2_eth_dev_configure(struct rte_eth_dev *dev) 386 { 387 struct dpaa2_dev_priv *priv = dev->data->dev_private; 388 struct fsl_mc_io *dpni = priv->hw; 389 struct rte_eth_conf *eth_conf = &dev->data->dev_conf; 390 uint64_t rx_offloads = eth_conf->rxmode.offloads; 391 uint64_t tx_offloads = eth_conf->txmode.offloads; 392 int rx_l3_csum_offload = false; 393 int rx_l4_csum_offload = false; 394 int tx_l3_csum_offload = false; 395 int tx_l4_csum_offload = false; 396 int ret; 397 398 PMD_INIT_FUNC_TRACE(); 399 400 /* Rx offloads validation */ 401 if (dev_rx_offloads_nodis & ~rx_offloads) { 402 DPAA2_PMD_WARN( 403 "Rx offloads non configurable - requested 0x%" PRIx64 404 " ignored 0x%" PRIx64, 405 rx_offloads, dev_rx_offloads_nodis); 406 } 407 408 /* Tx offloads validation */ 409 if (dev_tx_offloads_nodis & ~tx_offloads) { 410 DPAA2_PMD_WARN( 411 "Tx offloads non configurable - requested 0x%" PRIx64 412 " ignored 0x%" PRIx64, 413 tx_offloads, dev_tx_offloads_nodis); 414 } 415 416 if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { 417 if (eth_conf->rxmode.max_rx_pkt_len <= DPAA2_MAX_RX_PKT_LEN) { 418 ret = dpni_set_max_frame_length(dpni, CMD_PRI_LOW, 419 priv->token, eth_conf->rxmode.max_rx_pkt_len); 420 if (ret) { 421 DPAA2_PMD_ERR( 422 "Unable to set mtu. check config"); 423 return ret; 424 } 425 } else { 426 return -1; 427 } 428 } 429 430 if (eth_conf->rxmode.mq_mode == ETH_MQ_RX_RSS) { 431 ret = dpaa2_setup_flow_dist(dev, 432 eth_conf->rx_adv_conf.rss_conf.rss_hf); 433 if (ret) { 434 DPAA2_PMD_ERR("Unable to set flow distribution." 435 "Check queue config"); 436 return ret; 437 } 438 } 439 440 if (rx_offloads & DEV_RX_OFFLOAD_IPV4_CKSUM) 441 rx_l3_csum_offload = true; 442 443 if ((rx_offloads & DEV_RX_OFFLOAD_UDP_CKSUM) || 444 (rx_offloads & DEV_RX_OFFLOAD_TCP_CKSUM)) 445 rx_l4_csum_offload = true; 446 447 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token, 448 DPNI_OFF_RX_L3_CSUM, rx_l3_csum_offload); 449 if (ret) { 450 DPAA2_PMD_ERR("Error to set RX l3 csum:Error = %d", ret); 451 return ret; 452 } 453 454 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token, 455 DPNI_OFF_RX_L4_CSUM, rx_l4_csum_offload); 456 if (ret) { 457 DPAA2_PMD_ERR("Error to get RX l4 csum:Error = %d", ret); 458 return ret; 459 } 460 461 if (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) 462 tx_l3_csum_offload = true; 463 464 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) || 465 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) || 466 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM)) 467 tx_l4_csum_offload = true; 468 469 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token, 470 DPNI_OFF_TX_L3_CSUM, tx_l3_csum_offload); 471 if (ret) { 472 DPAA2_PMD_ERR("Error to set TX l3 csum:Error = %d", ret); 473 return ret; 474 } 475 476 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token, 477 DPNI_OFF_TX_L4_CSUM, tx_l4_csum_offload); 478 if (ret) { 479 DPAA2_PMD_ERR("Error to get TX l4 csum:Error = %d", ret); 480 return ret; 481 } 482 483 /* Enabling hash results in FD requires setting DPNI_FLCTYPE_HASH in 484 * dpni_set_offload API. Setting this FLCTYPE for DPNI sets the FD[SC] 485 * to 0 for LS2 in the hardware thus disabling data/annotation 486 * stashing. For LX2 this is fixed in hardware and thus hash result and 487 * parse results can be received in FD using this option. 488 */ 489 if (dpaa2_svr_family == SVR_LX2160A) { 490 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token, 491 DPNI_FLCTYPE_HASH, true); 492 if (ret) { 493 DPAA2_PMD_ERR("Error setting FLCTYPE: Err = %d", ret); 494 return ret; 495 } 496 } 497 498 if (rx_offloads & DEV_RX_OFFLOAD_VLAN_FILTER) 499 dpaa2_vlan_offload_set(dev, ETH_VLAN_FILTER_MASK); 500 501 /* update the current status */ 502 dpaa2_dev_link_update(dev, 0); 503 504 return 0; 505 } 506 507 /* Function to setup RX flow information. It contains traffic class ID, 508 * flow ID, destination configuration etc. 509 */ 510 static int 511 dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev, 512 uint16_t rx_queue_id, 513 uint16_t nb_rx_desc __rte_unused, 514 unsigned int socket_id __rte_unused, 515 const struct rte_eth_rxconf *rx_conf __rte_unused, 516 struct rte_mempool *mb_pool) 517 { 518 struct dpaa2_dev_priv *priv = dev->data->dev_private; 519 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 520 struct dpaa2_queue *dpaa2_q; 521 struct dpni_queue cfg; 522 uint8_t options = 0; 523 uint8_t flow_id; 524 uint32_t bpid; 525 int ret; 526 527 PMD_INIT_FUNC_TRACE(); 528 529 DPAA2_PMD_DEBUG("dev =%p, queue =%d, pool = %p, conf =%p", 530 dev, rx_queue_id, mb_pool, rx_conf); 531 532 if (!priv->bp_list || priv->bp_list->mp != mb_pool) { 533 bpid = mempool_to_bpid(mb_pool); 534 ret = dpaa2_attach_bp_list(priv, 535 rte_dpaa2_bpid_info[bpid].bp_list); 536 if (ret) 537 return ret; 538 } 539 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[rx_queue_id]; 540 dpaa2_q->mb_pool = mb_pool; /**< mbuf pool to populate RX ring. */ 541 dpaa2_q->bp_array = rte_dpaa2_bpid_info; 542 543 /*Get the flow id from given VQ id*/ 544 flow_id = rx_queue_id % priv->nb_rx_queues; 545 memset(&cfg, 0, sizeof(struct dpni_queue)); 546 547 options = options | DPNI_QUEUE_OPT_USER_CTX; 548 cfg.user_context = (size_t)(dpaa2_q); 549 550 /*if ls2088 or rev2 device, enable the stashing */ 551 552 if ((dpaa2_svr_family & 0xffff0000) != SVR_LS2080A) { 553 options |= DPNI_QUEUE_OPT_FLC; 554 cfg.flc.stash_control = true; 555 cfg.flc.value &= 0xFFFFFFFFFFFFFFC0; 556 /* 00 00 00 - last 6 bit represent annotation, context stashing, 557 * data stashing setting 01 01 00 (0x14) 558 * (in following order ->DS AS CS) 559 * to enable 1 line data, 1 line annotation. 560 * For LX2, this setting should be 01 00 00 (0x10) 561 */ 562 if ((dpaa2_svr_family & 0xffff0000) == SVR_LX2160A) 563 cfg.flc.value |= 0x10; 564 else 565 cfg.flc.value |= 0x14; 566 } 567 ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_RX, 568 dpaa2_q->tc_index, flow_id, options, &cfg); 569 if (ret) { 570 DPAA2_PMD_ERR("Error in setting the rx flow: = %d", ret); 571 return -1; 572 } 573 574 if (!(priv->flags & DPAA2_RX_TAILDROP_OFF)) { 575 struct dpni_taildrop taildrop; 576 577 taildrop.enable = 1; 578 /*enabling per rx queue congestion control */ 579 taildrop.threshold = CONG_THRESHOLD_RX_Q; 580 taildrop.units = DPNI_CONGESTION_UNIT_BYTES; 581 taildrop.oal = CONG_RX_OAL; 582 DPAA2_PMD_DEBUG("Enabling Early Drop on queue = %d", 583 rx_queue_id); 584 ret = dpni_set_taildrop(dpni, CMD_PRI_LOW, priv->token, 585 DPNI_CP_QUEUE, DPNI_QUEUE_RX, 586 dpaa2_q->tc_index, flow_id, &taildrop); 587 if (ret) { 588 DPAA2_PMD_ERR("Error in setting taildrop. err=(%d)", 589 ret); 590 return -1; 591 } 592 } 593 594 dev->data->rx_queues[rx_queue_id] = dpaa2_q; 595 return 0; 596 } 597 598 static int 599 dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev, 600 uint16_t tx_queue_id, 601 uint16_t nb_tx_desc __rte_unused, 602 unsigned int socket_id __rte_unused, 603 const struct rte_eth_txconf *tx_conf __rte_unused) 604 { 605 struct dpaa2_dev_priv *priv = dev->data->dev_private; 606 struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *) 607 priv->tx_vq[tx_queue_id]; 608 struct fsl_mc_io *dpni = priv->hw; 609 struct dpni_queue tx_conf_cfg; 610 struct dpni_queue tx_flow_cfg; 611 uint8_t options = 0, flow_id; 612 uint32_t tc_id; 613 int ret; 614 615 PMD_INIT_FUNC_TRACE(); 616 617 /* Return if queue already configured */ 618 if (dpaa2_q->flow_id != 0xffff) { 619 dev->data->tx_queues[tx_queue_id] = dpaa2_q; 620 return 0; 621 } 622 623 memset(&tx_conf_cfg, 0, sizeof(struct dpni_queue)); 624 memset(&tx_flow_cfg, 0, sizeof(struct dpni_queue)); 625 626 tc_id = tx_queue_id; 627 flow_id = 0; 628 629 ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_TX, 630 tc_id, flow_id, options, &tx_flow_cfg); 631 if (ret) { 632 DPAA2_PMD_ERR("Error in setting the tx flow: " 633 "tc_id=%d, flow=%d err=%d", 634 tc_id, flow_id, ret); 635 return -1; 636 } 637 638 dpaa2_q->flow_id = flow_id; 639 640 if (tx_queue_id == 0) { 641 /*Set tx-conf and error configuration*/ 642 ret = dpni_set_tx_confirmation_mode(dpni, CMD_PRI_LOW, 643 priv->token, 644 DPNI_CONF_DISABLE); 645 if (ret) { 646 DPAA2_PMD_ERR("Error in set tx conf mode settings: " 647 "err=%d", ret); 648 return -1; 649 } 650 } 651 dpaa2_q->tc_index = tc_id; 652 653 if (!(priv->flags & DPAA2_TX_CGR_OFF)) { 654 struct dpni_congestion_notification_cfg cong_notif_cfg; 655 656 cong_notif_cfg.units = DPNI_CONGESTION_UNIT_FRAMES; 657 cong_notif_cfg.threshold_entry = CONG_ENTER_TX_THRESHOLD; 658 /* Notify that the queue is not congested when the data in 659 * the queue is below this thershold. 660 */ 661 cong_notif_cfg.threshold_exit = CONG_EXIT_TX_THRESHOLD; 662 cong_notif_cfg.message_ctx = 0; 663 cong_notif_cfg.message_iova = 664 (size_t)DPAA2_VADDR_TO_IOVA(dpaa2_q->cscn); 665 cong_notif_cfg.dest_cfg.dest_type = DPNI_DEST_NONE; 666 cong_notif_cfg.notification_mode = 667 DPNI_CONG_OPT_WRITE_MEM_ON_ENTER | 668 DPNI_CONG_OPT_WRITE_MEM_ON_EXIT | 669 DPNI_CONG_OPT_COHERENT_WRITE; 670 cong_notif_cfg.cg_point = DPNI_CP_QUEUE; 671 672 ret = dpni_set_congestion_notification(dpni, CMD_PRI_LOW, 673 priv->token, 674 DPNI_QUEUE_TX, 675 tc_id, 676 &cong_notif_cfg); 677 if (ret) { 678 DPAA2_PMD_ERR( 679 "Error in setting tx congestion notification: " 680 "err=%d", ret); 681 return -ret; 682 } 683 } 684 dpaa2_q->cb_eqresp_free = dpaa2_dev_free_eqresp_buf; 685 dev->data->tx_queues[tx_queue_id] = dpaa2_q; 686 return 0; 687 } 688 689 static void 690 dpaa2_dev_rx_queue_release(void *q __rte_unused) 691 { 692 PMD_INIT_FUNC_TRACE(); 693 } 694 695 static void 696 dpaa2_dev_tx_queue_release(void *q __rte_unused) 697 { 698 PMD_INIT_FUNC_TRACE(); 699 } 700 701 static uint32_t 702 dpaa2_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) 703 { 704 int32_t ret; 705 struct dpaa2_dev_priv *priv = dev->data->dev_private; 706 struct dpaa2_queue *dpaa2_q; 707 struct qbman_swp *swp; 708 struct qbman_fq_query_np_rslt state; 709 uint32_t frame_cnt = 0; 710 711 PMD_INIT_FUNC_TRACE(); 712 713 if (unlikely(!DPAA2_PER_LCORE_DPIO)) { 714 ret = dpaa2_affine_qbman_swp(); 715 if (ret) { 716 DPAA2_PMD_ERR("Failure in affining portal"); 717 return -EINVAL; 718 } 719 } 720 swp = DPAA2_PER_LCORE_PORTAL; 721 722 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[rx_queue_id]; 723 724 if (qbman_fq_query_state(swp, dpaa2_q->fqid, &state) == 0) { 725 frame_cnt = qbman_fq_state_frame_count(&state); 726 DPAA2_PMD_DEBUG("RX frame count for q(%d) is %u", 727 rx_queue_id, frame_cnt); 728 } 729 return frame_cnt; 730 } 731 732 static const uint32_t * 733 dpaa2_supported_ptypes_get(struct rte_eth_dev *dev) 734 { 735 static const uint32_t ptypes[] = { 736 /*todo -= add more types */ 737 RTE_PTYPE_L2_ETHER, 738 RTE_PTYPE_L3_IPV4, 739 RTE_PTYPE_L3_IPV4_EXT, 740 RTE_PTYPE_L3_IPV6, 741 RTE_PTYPE_L3_IPV6_EXT, 742 RTE_PTYPE_L4_TCP, 743 RTE_PTYPE_L4_UDP, 744 RTE_PTYPE_L4_SCTP, 745 RTE_PTYPE_L4_ICMP, 746 RTE_PTYPE_UNKNOWN 747 }; 748 749 if (dev->rx_pkt_burst == dpaa2_dev_prefetch_rx || 750 dev->rx_pkt_burst == dpaa2_dev_loopback_rx) 751 return ptypes; 752 return NULL; 753 } 754 755 /** 756 * Dpaa2 link Interrupt handler 757 * 758 * @param param 759 * The address of parameter (struct rte_eth_dev *) regsitered before. 760 * 761 * @return 762 * void 763 */ 764 static void 765 dpaa2_interrupt_handler(void *param) 766 { 767 struct rte_eth_dev *dev = param; 768 struct dpaa2_dev_priv *priv = dev->data->dev_private; 769 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 770 int ret; 771 int irq_index = DPNI_IRQ_INDEX; 772 unsigned int status = 0, clear = 0; 773 774 PMD_INIT_FUNC_TRACE(); 775 776 if (dpni == NULL) { 777 DPAA2_PMD_ERR("dpni is NULL"); 778 return; 779 } 780 781 ret = dpni_get_irq_status(dpni, CMD_PRI_LOW, priv->token, 782 irq_index, &status); 783 if (unlikely(ret)) { 784 DPAA2_PMD_ERR("Can't get irq status (err %d)", ret); 785 clear = 0xffffffff; 786 goto out; 787 } 788 789 if (status & DPNI_IRQ_EVENT_LINK_CHANGED) { 790 clear = DPNI_IRQ_EVENT_LINK_CHANGED; 791 dpaa2_dev_link_update(dev, 0); 792 /* calling all the apps registered for link status event */ 793 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, 794 NULL); 795 } 796 out: 797 ret = dpni_clear_irq_status(dpni, CMD_PRI_LOW, priv->token, 798 irq_index, clear); 799 if (unlikely(ret)) 800 DPAA2_PMD_ERR("Can't clear irq status (err %d)", ret); 801 } 802 803 static int 804 dpaa2_eth_setup_irqs(struct rte_eth_dev *dev, int enable) 805 { 806 int err = 0; 807 struct dpaa2_dev_priv *priv = dev->data->dev_private; 808 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 809 int irq_index = DPNI_IRQ_INDEX; 810 unsigned int mask = DPNI_IRQ_EVENT_LINK_CHANGED; 811 812 PMD_INIT_FUNC_TRACE(); 813 814 err = dpni_set_irq_mask(dpni, CMD_PRI_LOW, priv->token, 815 irq_index, mask); 816 if (err < 0) { 817 DPAA2_PMD_ERR("Error: dpni_set_irq_mask():%d (%s)", err, 818 strerror(-err)); 819 return err; 820 } 821 822 err = dpni_set_irq_enable(dpni, CMD_PRI_LOW, priv->token, 823 irq_index, enable); 824 if (err < 0) 825 DPAA2_PMD_ERR("Error: dpni_set_irq_enable():%d (%s)", err, 826 strerror(-err)); 827 828 return err; 829 } 830 831 static int 832 dpaa2_dev_start(struct rte_eth_dev *dev) 833 { 834 struct rte_device *rdev = dev->device; 835 struct rte_dpaa2_device *dpaa2_dev; 836 struct rte_eth_dev_data *data = dev->data; 837 struct dpaa2_dev_priv *priv = data->dev_private; 838 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 839 struct dpni_queue cfg; 840 struct dpni_error_cfg err_cfg; 841 uint16_t qdid; 842 struct dpni_queue_id qid; 843 struct dpaa2_queue *dpaa2_q; 844 int ret, i; 845 struct rte_intr_handle *intr_handle; 846 847 dpaa2_dev = container_of(rdev, struct rte_dpaa2_device, device); 848 intr_handle = &dpaa2_dev->intr_handle; 849 850 PMD_INIT_FUNC_TRACE(); 851 852 ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token); 853 if (ret) { 854 DPAA2_PMD_ERR("Failure in enabling dpni %d device: err=%d", 855 priv->hw_id, ret); 856 return ret; 857 } 858 859 /* Power up the phy. Needed to make the link go UP */ 860 dpaa2_dev_set_link_up(dev); 861 862 ret = dpni_get_qdid(dpni, CMD_PRI_LOW, priv->token, 863 DPNI_QUEUE_TX, &qdid); 864 if (ret) { 865 DPAA2_PMD_ERR("Error in getting qdid: err=%d", ret); 866 return ret; 867 } 868 priv->qdid = qdid; 869 870 for (i = 0; i < data->nb_rx_queues; i++) { 871 dpaa2_q = (struct dpaa2_queue *)data->rx_queues[i]; 872 ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token, 873 DPNI_QUEUE_RX, dpaa2_q->tc_index, 874 dpaa2_q->flow_id, &cfg, &qid); 875 if (ret) { 876 DPAA2_PMD_ERR("Error in getting flow information: " 877 "err=%d", ret); 878 return ret; 879 } 880 dpaa2_q->fqid = qid.fqid; 881 } 882 883 /*checksum errors, send them to normal path and set it in annotation */ 884 err_cfg.errors = DPNI_ERROR_L3CE | DPNI_ERROR_L4CE; 885 err_cfg.errors |= DPNI_ERROR_PHE; 886 887 err_cfg.error_action = DPNI_ERROR_ACTION_CONTINUE; 888 err_cfg.set_frame_annotation = true; 889 890 ret = dpni_set_errors_behavior(dpni, CMD_PRI_LOW, 891 priv->token, &err_cfg); 892 if (ret) { 893 DPAA2_PMD_ERR("Error to dpni_set_errors_behavior: code = %d", 894 ret); 895 return ret; 896 } 897 898 /* if the interrupts were configured on this devices*/ 899 if (intr_handle && (intr_handle->fd) && 900 (dev->data->dev_conf.intr_conf.lsc != 0)) { 901 /* Registering LSC interrupt handler */ 902 rte_intr_callback_register(intr_handle, 903 dpaa2_interrupt_handler, 904 (void *)dev); 905 906 /* enable vfio intr/eventfd mapping 907 * Interrupt index 0 is required, so we can not use 908 * rte_intr_enable. 909 */ 910 rte_dpaa2_intr_enable(intr_handle, DPNI_IRQ_INDEX); 911 912 /* enable dpni_irqs */ 913 dpaa2_eth_setup_irqs(dev, 1); 914 } 915 916 /* Change the tx burst function if ordered queues are used */ 917 if (priv->en_ordered) 918 dev->tx_pkt_burst = dpaa2_dev_tx_ordered; 919 920 return 0; 921 } 922 923 /** 924 * This routine disables all traffic on the adapter by issuing a 925 * global reset on the MAC. 926 */ 927 static void 928 dpaa2_dev_stop(struct rte_eth_dev *dev) 929 { 930 struct dpaa2_dev_priv *priv = dev->data->dev_private; 931 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 932 int ret; 933 struct rte_eth_link link; 934 struct rte_intr_handle *intr_handle = dev->intr_handle; 935 936 PMD_INIT_FUNC_TRACE(); 937 938 /* reset interrupt callback */ 939 if (intr_handle && (intr_handle->fd) && 940 (dev->data->dev_conf.intr_conf.lsc != 0)) { 941 /*disable dpni irqs */ 942 dpaa2_eth_setup_irqs(dev, 0); 943 944 /* disable vfio intr before callback unregister */ 945 rte_dpaa2_intr_disable(intr_handle, DPNI_IRQ_INDEX); 946 947 /* Unregistering LSC interrupt handler */ 948 rte_intr_callback_unregister(intr_handle, 949 dpaa2_interrupt_handler, 950 (void *)dev); 951 } 952 953 dpaa2_dev_set_link_down(dev); 954 955 ret = dpni_disable(dpni, CMD_PRI_LOW, priv->token); 956 if (ret) { 957 DPAA2_PMD_ERR("Failure (ret %d) in disabling dpni %d dev", 958 ret, priv->hw_id); 959 return; 960 } 961 962 /* clear the recorded link status */ 963 memset(&link, 0, sizeof(link)); 964 rte_eth_linkstatus_set(dev, &link); 965 } 966 967 static void 968 dpaa2_dev_close(struct rte_eth_dev *dev) 969 { 970 struct dpaa2_dev_priv *priv = dev->data->dev_private; 971 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 972 int ret; 973 struct rte_eth_link link; 974 975 PMD_INIT_FUNC_TRACE(); 976 977 dpaa2_flow_clean(dev); 978 979 /* Clean the device first */ 980 ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token); 981 if (ret) { 982 DPAA2_PMD_ERR("Failure cleaning dpni device: err=%d", ret); 983 return; 984 } 985 986 memset(&link, 0, sizeof(link)); 987 rte_eth_linkstatus_set(dev, &link); 988 } 989 990 static void 991 dpaa2_dev_promiscuous_enable( 992 struct rte_eth_dev *dev) 993 { 994 int ret; 995 struct dpaa2_dev_priv *priv = dev->data->dev_private; 996 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 997 998 PMD_INIT_FUNC_TRACE(); 999 1000 if (dpni == NULL) { 1001 DPAA2_PMD_ERR("dpni is NULL"); 1002 return; 1003 } 1004 1005 ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, true); 1006 if (ret < 0) 1007 DPAA2_PMD_ERR("Unable to enable U promisc mode %d", ret); 1008 1009 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, true); 1010 if (ret < 0) 1011 DPAA2_PMD_ERR("Unable to enable M promisc mode %d", ret); 1012 } 1013 1014 static void 1015 dpaa2_dev_promiscuous_disable( 1016 struct rte_eth_dev *dev) 1017 { 1018 int ret; 1019 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1020 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1021 1022 PMD_INIT_FUNC_TRACE(); 1023 1024 if (dpni == NULL) { 1025 DPAA2_PMD_ERR("dpni is NULL"); 1026 return; 1027 } 1028 1029 ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, false); 1030 if (ret < 0) 1031 DPAA2_PMD_ERR("Unable to disable U promisc mode %d", ret); 1032 1033 if (dev->data->all_multicast == 0) { 1034 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, 1035 priv->token, false); 1036 if (ret < 0) 1037 DPAA2_PMD_ERR("Unable to disable M promisc mode %d", 1038 ret); 1039 } 1040 } 1041 1042 static void 1043 dpaa2_dev_allmulticast_enable( 1044 struct rte_eth_dev *dev) 1045 { 1046 int ret; 1047 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1048 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1049 1050 PMD_INIT_FUNC_TRACE(); 1051 1052 if (dpni == NULL) { 1053 DPAA2_PMD_ERR("dpni is NULL"); 1054 return; 1055 } 1056 1057 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, true); 1058 if (ret < 0) 1059 DPAA2_PMD_ERR("Unable to enable multicast mode %d", ret); 1060 } 1061 1062 static void 1063 dpaa2_dev_allmulticast_disable(struct rte_eth_dev *dev) 1064 { 1065 int ret; 1066 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1067 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1068 1069 PMD_INIT_FUNC_TRACE(); 1070 1071 if (dpni == NULL) { 1072 DPAA2_PMD_ERR("dpni is NULL"); 1073 return; 1074 } 1075 1076 /* must remain on for all promiscuous */ 1077 if (dev->data->promiscuous == 1) 1078 return; 1079 1080 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, false); 1081 if (ret < 0) 1082 DPAA2_PMD_ERR("Unable to disable multicast mode %d", ret); 1083 } 1084 1085 static int 1086 dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) 1087 { 1088 int ret; 1089 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1090 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1091 uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN 1092 + VLAN_TAG_SIZE; 1093 1094 PMD_INIT_FUNC_TRACE(); 1095 1096 if (dpni == NULL) { 1097 DPAA2_PMD_ERR("dpni is NULL"); 1098 return -EINVAL; 1099 } 1100 1101 /* check that mtu is within the allowed range */ 1102 if (mtu < RTE_ETHER_MIN_MTU || frame_size > DPAA2_MAX_RX_PKT_LEN) 1103 return -EINVAL; 1104 1105 if (frame_size > RTE_ETHER_MAX_LEN) 1106 dev->data->dev_conf.rxmode.offloads &= 1107 DEV_RX_OFFLOAD_JUMBO_FRAME; 1108 else 1109 dev->data->dev_conf.rxmode.offloads &= 1110 ~DEV_RX_OFFLOAD_JUMBO_FRAME; 1111 1112 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size; 1113 1114 /* Set the Max Rx frame length as 'mtu' + 1115 * Maximum Ethernet header length 1116 */ 1117 ret = dpni_set_max_frame_length(dpni, CMD_PRI_LOW, priv->token, 1118 frame_size); 1119 if (ret) { 1120 DPAA2_PMD_ERR("Setting the max frame length failed"); 1121 return -1; 1122 } 1123 DPAA2_PMD_INFO("MTU configured for the device: %d", mtu); 1124 return 0; 1125 } 1126 1127 static int 1128 dpaa2_dev_add_mac_addr(struct rte_eth_dev *dev, 1129 struct rte_ether_addr *addr, 1130 __rte_unused uint32_t index, 1131 __rte_unused uint32_t pool) 1132 { 1133 int ret; 1134 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1135 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1136 1137 PMD_INIT_FUNC_TRACE(); 1138 1139 if (dpni == NULL) { 1140 DPAA2_PMD_ERR("dpni is NULL"); 1141 return -1; 1142 } 1143 1144 ret = dpni_add_mac_addr(dpni, CMD_PRI_LOW, 1145 priv->token, addr->addr_bytes); 1146 if (ret) 1147 DPAA2_PMD_ERR( 1148 "error: Adding the MAC ADDR failed: err = %d", ret); 1149 return 0; 1150 } 1151 1152 static void 1153 dpaa2_dev_remove_mac_addr(struct rte_eth_dev *dev, 1154 uint32_t index) 1155 { 1156 int ret; 1157 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1158 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1159 struct rte_eth_dev_data *data = dev->data; 1160 struct rte_ether_addr *macaddr; 1161 1162 PMD_INIT_FUNC_TRACE(); 1163 1164 macaddr = &data->mac_addrs[index]; 1165 1166 if (dpni == NULL) { 1167 DPAA2_PMD_ERR("dpni is NULL"); 1168 return; 1169 } 1170 1171 ret = dpni_remove_mac_addr(dpni, CMD_PRI_LOW, 1172 priv->token, macaddr->addr_bytes); 1173 if (ret) 1174 DPAA2_PMD_ERR( 1175 "error: Removing the MAC ADDR failed: err = %d", ret); 1176 } 1177 1178 static int 1179 dpaa2_dev_set_mac_addr(struct rte_eth_dev *dev, 1180 struct rte_ether_addr *addr) 1181 { 1182 int ret; 1183 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1184 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1185 1186 PMD_INIT_FUNC_TRACE(); 1187 1188 if (dpni == NULL) { 1189 DPAA2_PMD_ERR("dpni is NULL"); 1190 return -EINVAL; 1191 } 1192 1193 ret = dpni_set_primary_mac_addr(dpni, CMD_PRI_LOW, 1194 priv->token, addr->addr_bytes); 1195 1196 if (ret) 1197 DPAA2_PMD_ERR( 1198 "error: Setting the MAC ADDR failed %d", ret); 1199 1200 return ret; 1201 } 1202 1203 static 1204 int dpaa2_dev_stats_get(struct rte_eth_dev *dev, 1205 struct rte_eth_stats *stats) 1206 { 1207 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1208 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1209 int32_t retcode; 1210 uint8_t page0 = 0, page1 = 1, page2 = 2; 1211 union dpni_statistics value; 1212 int i; 1213 struct dpaa2_queue *dpaa2_rxq, *dpaa2_txq; 1214 1215 memset(&value, 0, sizeof(union dpni_statistics)); 1216 1217 PMD_INIT_FUNC_TRACE(); 1218 1219 if (!dpni) { 1220 DPAA2_PMD_ERR("dpni is NULL"); 1221 return -EINVAL; 1222 } 1223 1224 if (!stats) { 1225 DPAA2_PMD_ERR("stats is NULL"); 1226 return -EINVAL; 1227 } 1228 1229 /*Get Counters from page_0*/ 1230 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, 1231 page0, 0, &value); 1232 if (retcode) 1233 goto err; 1234 1235 stats->ipackets = value.page_0.ingress_all_frames; 1236 stats->ibytes = value.page_0.ingress_all_bytes; 1237 1238 /*Get Counters from page_1*/ 1239 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, 1240 page1, 0, &value); 1241 if (retcode) 1242 goto err; 1243 1244 stats->opackets = value.page_1.egress_all_frames; 1245 stats->obytes = value.page_1.egress_all_bytes; 1246 1247 /*Get Counters from page_2*/ 1248 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, 1249 page2, 0, &value); 1250 if (retcode) 1251 goto err; 1252 1253 /* Ingress drop frame count due to configured rules */ 1254 stats->ierrors = value.page_2.ingress_filtered_frames; 1255 /* Ingress drop frame count due to error */ 1256 stats->ierrors += value.page_2.ingress_discarded_frames; 1257 1258 stats->oerrors = value.page_2.egress_discarded_frames; 1259 stats->imissed = value.page_2.ingress_nobuffer_discards; 1260 1261 /* Fill in per queue stats */ 1262 for (i = 0; (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) && 1263 (i < priv->nb_rx_queues || i < priv->nb_tx_queues); ++i) { 1264 dpaa2_rxq = (struct dpaa2_queue *)priv->rx_vq[i]; 1265 dpaa2_txq = (struct dpaa2_queue *)priv->tx_vq[i]; 1266 if (dpaa2_rxq) 1267 stats->q_ipackets[i] = dpaa2_rxq->rx_pkts; 1268 if (dpaa2_txq) 1269 stats->q_opackets[i] = dpaa2_txq->tx_pkts; 1270 1271 /* Byte counting is not implemented */ 1272 stats->q_ibytes[i] = 0; 1273 stats->q_obytes[i] = 0; 1274 } 1275 1276 return 0; 1277 1278 err: 1279 DPAA2_PMD_ERR("Operation not completed:Error Code = %d", retcode); 1280 return retcode; 1281 }; 1282 1283 static int 1284 dpaa2_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, 1285 unsigned int n) 1286 { 1287 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1288 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1289 int32_t retcode; 1290 union dpni_statistics value[3] = {}; 1291 unsigned int i = 0, num = RTE_DIM(dpaa2_xstats_strings); 1292 1293 if (n < num) 1294 return num; 1295 1296 if (xstats == NULL) 1297 return 0; 1298 1299 /* Get Counters from page_0*/ 1300 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, 1301 0, 0, &value[0]); 1302 if (retcode) 1303 goto err; 1304 1305 /* Get Counters from page_1*/ 1306 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, 1307 1, 0, &value[1]); 1308 if (retcode) 1309 goto err; 1310 1311 /* Get Counters from page_2*/ 1312 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, 1313 2, 0, &value[2]); 1314 if (retcode) 1315 goto err; 1316 1317 for (i = 0; i < num; i++) { 1318 xstats[i].id = i; 1319 xstats[i].value = value[dpaa2_xstats_strings[i].page_id]. 1320 raw.counter[dpaa2_xstats_strings[i].stats_id]; 1321 } 1322 return i; 1323 err: 1324 DPAA2_PMD_ERR("Error in obtaining extended stats (%d)", retcode); 1325 return retcode; 1326 } 1327 1328 static int 1329 dpaa2_xstats_get_names(__rte_unused struct rte_eth_dev *dev, 1330 struct rte_eth_xstat_name *xstats_names, 1331 unsigned int limit) 1332 { 1333 unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings); 1334 1335 if (limit < stat_cnt) 1336 return stat_cnt; 1337 1338 if (xstats_names != NULL) 1339 for (i = 0; i < stat_cnt; i++) 1340 strlcpy(xstats_names[i].name, 1341 dpaa2_xstats_strings[i].name, 1342 sizeof(xstats_names[i].name)); 1343 1344 return stat_cnt; 1345 } 1346 1347 static int 1348 dpaa2_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, 1349 uint64_t *values, unsigned int n) 1350 { 1351 unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings); 1352 uint64_t values_copy[stat_cnt]; 1353 1354 if (!ids) { 1355 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1356 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1357 int32_t retcode; 1358 union dpni_statistics value[3] = {}; 1359 1360 if (n < stat_cnt) 1361 return stat_cnt; 1362 1363 if (!values) 1364 return 0; 1365 1366 /* Get Counters from page_0*/ 1367 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, 1368 0, 0, &value[0]); 1369 if (retcode) 1370 return 0; 1371 1372 /* Get Counters from page_1*/ 1373 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, 1374 1, 0, &value[1]); 1375 if (retcode) 1376 return 0; 1377 1378 /* Get Counters from page_2*/ 1379 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, 1380 2, 0, &value[2]); 1381 if (retcode) 1382 return 0; 1383 1384 for (i = 0; i < stat_cnt; i++) { 1385 values[i] = value[dpaa2_xstats_strings[i].page_id]. 1386 raw.counter[dpaa2_xstats_strings[i].stats_id]; 1387 } 1388 return stat_cnt; 1389 } 1390 1391 dpaa2_xstats_get_by_id(dev, NULL, values_copy, stat_cnt); 1392 1393 for (i = 0; i < n; i++) { 1394 if (ids[i] >= stat_cnt) { 1395 DPAA2_PMD_ERR("xstats id value isn't valid"); 1396 return -1; 1397 } 1398 values[i] = values_copy[ids[i]]; 1399 } 1400 return n; 1401 } 1402 1403 static int 1404 dpaa2_xstats_get_names_by_id( 1405 struct rte_eth_dev *dev, 1406 struct rte_eth_xstat_name *xstats_names, 1407 const uint64_t *ids, 1408 unsigned int limit) 1409 { 1410 unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings); 1411 struct rte_eth_xstat_name xstats_names_copy[stat_cnt]; 1412 1413 if (!ids) 1414 return dpaa2_xstats_get_names(dev, xstats_names, limit); 1415 1416 dpaa2_xstats_get_names(dev, xstats_names_copy, limit); 1417 1418 for (i = 0; i < limit; i++) { 1419 if (ids[i] >= stat_cnt) { 1420 DPAA2_PMD_ERR("xstats id value isn't valid"); 1421 return -1; 1422 } 1423 strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name); 1424 } 1425 return limit; 1426 } 1427 1428 static void 1429 dpaa2_dev_stats_reset(struct rte_eth_dev *dev) 1430 { 1431 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1432 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1433 int32_t retcode; 1434 int i; 1435 struct dpaa2_queue *dpaa2_q; 1436 1437 PMD_INIT_FUNC_TRACE(); 1438 1439 if (dpni == NULL) { 1440 DPAA2_PMD_ERR("dpni is NULL"); 1441 return; 1442 } 1443 1444 retcode = dpni_reset_statistics(dpni, CMD_PRI_LOW, priv->token); 1445 if (retcode) 1446 goto error; 1447 1448 /* Reset the per queue stats in dpaa2_queue structure */ 1449 for (i = 0; i < priv->nb_rx_queues; i++) { 1450 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i]; 1451 if (dpaa2_q) 1452 dpaa2_q->rx_pkts = 0; 1453 } 1454 1455 for (i = 0; i < priv->nb_tx_queues; i++) { 1456 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i]; 1457 if (dpaa2_q) 1458 dpaa2_q->tx_pkts = 0; 1459 } 1460 1461 return; 1462 1463 error: 1464 DPAA2_PMD_ERR("Operation not completed:Error Code = %d", retcode); 1465 return; 1466 }; 1467 1468 /* return 0 means link status changed, -1 means not changed */ 1469 static int 1470 dpaa2_dev_link_update(struct rte_eth_dev *dev, 1471 int wait_to_complete __rte_unused) 1472 { 1473 int ret; 1474 struct dpaa2_dev_priv *priv = dev->data->dev_private; 1475 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 1476 struct rte_eth_link link; 1477 struct dpni_link_state state = {0}; 1478 1479 if (dpni == NULL) { 1480 DPAA2_PMD_ERR("dpni is NULL"); 1481 return 0; 1482 } 1483 1484 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state); 1485 if (ret < 0) { 1486 DPAA2_PMD_DEBUG("error: dpni_get_link_state %d", ret); 1487 return -1; 1488 } 1489 1490 memset(&link, 0, sizeof(struct rte_eth_link)); 1491 link.link_status = state.up; 1492 link.link_speed = state.rate; 1493 1494 if (state.options & DPNI_LINK_OPT_HALF_DUPLEX) 1495 link.link_duplex = ETH_LINK_HALF_DUPLEX; 1496 else 1497 link.link_duplex = ETH_LINK_FULL_DUPLEX; 1498 1499 ret = rte_eth_linkstatus_set(dev, &link); 1500 if (ret == -1) 1501 DPAA2_PMD_DEBUG("No change in status"); 1502 else 1503 DPAA2_PMD_INFO("Port %d Link is %s\n", dev->data->port_id, 1504 link.link_status ? "Up" : "Down"); 1505 1506 return ret; 1507 } 1508 1509 /** 1510 * Toggle the DPNI to enable, if not already enabled. 1511 * This is not strictly PHY up/down - it is more of logical toggling. 1512 */ 1513 static int 1514 dpaa2_dev_set_link_up(struct rte_eth_dev *dev) 1515 { 1516 int ret = -EINVAL; 1517 struct dpaa2_dev_priv *priv; 1518 struct fsl_mc_io *dpni; 1519 int en = 0; 1520 struct dpni_link_state state = {0}; 1521 1522 priv = dev->data->dev_private; 1523 dpni = (struct fsl_mc_io *)priv->hw; 1524 1525 if (dpni == NULL) { 1526 DPAA2_PMD_ERR("dpni is NULL"); 1527 return ret; 1528 } 1529 1530 /* Check if DPNI is currently enabled */ 1531 ret = dpni_is_enabled(dpni, CMD_PRI_LOW, priv->token, &en); 1532 if (ret) { 1533 /* Unable to obtain dpni status; Not continuing */ 1534 DPAA2_PMD_ERR("Interface Link UP failed (%d)", ret); 1535 return -EINVAL; 1536 } 1537 1538 /* Enable link if not already enabled */ 1539 if (!en) { 1540 ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token); 1541 if (ret) { 1542 DPAA2_PMD_ERR("Interface Link UP failed (%d)", ret); 1543 return -EINVAL; 1544 } 1545 } 1546 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state); 1547 if (ret < 0) { 1548 DPAA2_PMD_DEBUG("Unable to get link state (%d)", ret); 1549 return -1; 1550 } 1551 1552 /* changing tx burst function to start enqueues */ 1553 dev->tx_pkt_burst = dpaa2_dev_tx; 1554 dev->data->dev_link.link_status = state.up; 1555 1556 if (state.up) 1557 DPAA2_PMD_INFO("Port %d Link is Up", dev->data->port_id); 1558 else 1559 DPAA2_PMD_INFO("Port %d Link is Down", dev->data->port_id); 1560 return ret; 1561 } 1562 1563 /** 1564 * Toggle the DPNI to disable, if not already disabled. 1565 * This is not strictly PHY up/down - it is more of logical toggling. 1566 */ 1567 static int 1568 dpaa2_dev_set_link_down(struct rte_eth_dev *dev) 1569 { 1570 int ret = -EINVAL; 1571 struct dpaa2_dev_priv *priv; 1572 struct fsl_mc_io *dpni; 1573 int dpni_enabled = 0; 1574 int retries = 10; 1575 1576 PMD_INIT_FUNC_TRACE(); 1577 1578 priv = dev->data->dev_private; 1579 dpni = (struct fsl_mc_io *)priv->hw; 1580 1581 if (dpni == NULL) { 1582 DPAA2_PMD_ERR("Device has not yet been configured"); 1583 return ret; 1584 } 1585 1586 /*changing tx burst function to avoid any more enqueues */ 1587 dev->tx_pkt_burst = dummy_dev_tx; 1588 1589 /* Loop while dpni_disable() attempts to drain the egress FQs 1590 * and confirm them back to us. 1591 */ 1592 do { 1593 ret = dpni_disable(dpni, 0, priv->token); 1594 if (ret) { 1595 DPAA2_PMD_ERR("dpni disable failed (%d)", ret); 1596 return ret; 1597 } 1598 ret = dpni_is_enabled(dpni, 0, priv->token, &dpni_enabled); 1599 if (ret) { 1600 DPAA2_PMD_ERR("dpni enable check failed (%d)", ret); 1601 return ret; 1602 } 1603 if (dpni_enabled) 1604 /* Allow the MC some slack */ 1605 rte_delay_us(100 * 1000); 1606 } while (dpni_enabled && --retries); 1607 1608 if (!retries) { 1609 DPAA2_PMD_WARN("Retry count exceeded disabling dpni"); 1610 /* todo- we may have to manually cleanup queues. 1611 */ 1612 } else { 1613 DPAA2_PMD_INFO("Port %d Link DOWN successful", 1614 dev->data->port_id); 1615 } 1616 1617 dev->data->dev_link.link_status = 0; 1618 1619 return ret; 1620 } 1621 1622 static int 1623 dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) 1624 { 1625 int ret = -EINVAL; 1626 struct dpaa2_dev_priv *priv; 1627 struct fsl_mc_io *dpni; 1628 struct dpni_link_state state = {0}; 1629 1630 PMD_INIT_FUNC_TRACE(); 1631 1632 priv = dev->data->dev_private; 1633 dpni = (struct fsl_mc_io *)priv->hw; 1634 1635 if (dpni == NULL || fc_conf == NULL) { 1636 DPAA2_PMD_ERR("device not configured"); 1637 return ret; 1638 } 1639 1640 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state); 1641 if (ret) { 1642 DPAA2_PMD_ERR("error: dpni_get_link_state %d", ret); 1643 return ret; 1644 } 1645 1646 memset(fc_conf, 0, sizeof(struct rte_eth_fc_conf)); 1647 if (state.options & DPNI_LINK_OPT_PAUSE) { 1648 /* DPNI_LINK_OPT_PAUSE set 1649 * if ASYM_PAUSE not set, 1650 * RX Side flow control (handle received Pause frame) 1651 * TX side flow control (send Pause frame) 1652 * if ASYM_PAUSE set, 1653 * RX Side flow control (handle received Pause frame) 1654 * No TX side flow control (send Pause frame disabled) 1655 */ 1656 if (!(state.options & DPNI_LINK_OPT_ASYM_PAUSE)) 1657 fc_conf->mode = RTE_FC_FULL; 1658 else 1659 fc_conf->mode = RTE_FC_RX_PAUSE; 1660 } else { 1661 /* DPNI_LINK_OPT_PAUSE not set 1662 * if ASYM_PAUSE set, 1663 * TX side flow control (send Pause frame) 1664 * No RX side flow control (No action on pause frame rx) 1665 * if ASYM_PAUSE not set, 1666 * Flow control disabled 1667 */ 1668 if (state.options & DPNI_LINK_OPT_ASYM_PAUSE) 1669 fc_conf->mode = RTE_FC_TX_PAUSE; 1670 else 1671 fc_conf->mode = RTE_FC_NONE; 1672 } 1673 1674 return ret; 1675 } 1676 1677 static int 1678 dpaa2_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) 1679 { 1680 int ret = -EINVAL; 1681 struct dpaa2_dev_priv *priv; 1682 struct fsl_mc_io *dpni; 1683 struct dpni_link_state state = {0}; 1684 struct dpni_link_cfg cfg = {0}; 1685 1686 PMD_INIT_FUNC_TRACE(); 1687 1688 priv = dev->data->dev_private; 1689 dpni = (struct fsl_mc_io *)priv->hw; 1690 1691 if (dpni == NULL) { 1692 DPAA2_PMD_ERR("dpni is NULL"); 1693 return ret; 1694 } 1695 1696 /* It is necessary to obtain the current state before setting fc_conf 1697 * as MC would return error in case rate, autoneg or duplex values are 1698 * different. 1699 */ 1700 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state); 1701 if (ret) { 1702 DPAA2_PMD_ERR("Unable to get link state (err=%d)", ret); 1703 return -1; 1704 } 1705 1706 /* Disable link before setting configuration */ 1707 dpaa2_dev_set_link_down(dev); 1708 1709 /* Based on fc_conf, update cfg */ 1710 cfg.rate = state.rate; 1711 cfg.options = state.options; 1712 1713 /* update cfg with fc_conf */ 1714 switch (fc_conf->mode) { 1715 case RTE_FC_FULL: 1716 /* Full flow control; 1717 * OPT_PAUSE set, ASYM_PAUSE not set 1718 */ 1719 cfg.options |= DPNI_LINK_OPT_PAUSE; 1720 cfg.options &= ~DPNI_LINK_OPT_ASYM_PAUSE; 1721 break; 1722 case RTE_FC_TX_PAUSE: 1723 /* Enable RX flow control 1724 * OPT_PAUSE not set; 1725 * ASYM_PAUSE set; 1726 */ 1727 cfg.options |= DPNI_LINK_OPT_ASYM_PAUSE; 1728 cfg.options &= ~DPNI_LINK_OPT_PAUSE; 1729 break; 1730 case RTE_FC_RX_PAUSE: 1731 /* Enable TX Flow control 1732 * OPT_PAUSE set 1733 * ASYM_PAUSE set 1734 */ 1735 cfg.options |= DPNI_LINK_OPT_PAUSE; 1736 cfg.options |= DPNI_LINK_OPT_ASYM_PAUSE; 1737 break; 1738 case RTE_FC_NONE: 1739 /* Disable Flow control 1740 * OPT_PAUSE not set 1741 * ASYM_PAUSE not set 1742 */ 1743 cfg.options &= ~DPNI_LINK_OPT_PAUSE; 1744 cfg.options &= ~DPNI_LINK_OPT_ASYM_PAUSE; 1745 break; 1746 default: 1747 DPAA2_PMD_ERR("Incorrect Flow control flag (%d)", 1748 fc_conf->mode); 1749 return -1; 1750 } 1751 1752 ret = dpni_set_link_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg); 1753 if (ret) 1754 DPAA2_PMD_ERR("Unable to set Link configuration (err=%d)", 1755 ret); 1756 1757 /* Enable link */ 1758 dpaa2_dev_set_link_up(dev); 1759 1760 return ret; 1761 } 1762 1763 static int 1764 dpaa2_dev_rss_hash_update(struct rte_eth_dev *dev, 1765 struct rte_eth_rss_conf *rss_conf) 1766 { 1767 struct rte_eth_dev_data *data = dev->data; 1768 struct rte_eth_conf *eth_conf = &data->dev_conf; 1769 int ret; 1770 1771 PMD_INIT_FUNC_TRACE(); 1772 1773 if (rss_conf->rss_hf) { 1774 ret = dpaa2_setup_flow_dist(dev, rss_conf->rss_hf); 1775 if (ret) { 1776 DPAA2_PMD_ERR("Unable to set flow dist"); 1777 return ret; 1778 } 1779 } else { 1780 ret = dpaa2_remove_flow_dist(dev, 0); 1781 if (ret) { 1782 DPAA2_PMD_ERR("Unable to remove flow dist"); 1783 return ret; 1784 } 1785 } 1786 eth_conf->rx_adv_conf.rss_conf.rss_hf = rss_conf->rss_hf; 1787 return 0; 1788 } 1789 1790 static int 1791 dpaa2_dev_rss_hash_conf_get(struct rte_eth_dev *dev, 1792 struct rte_eth_rss_conf *rss_conf) 1793 { 1794 struct rte_eth_dev_data *data = dev->data; 1795 struct rte_eth_conf *eth_conf = &data->dev_conf; 1796 1797 /* dpaa2 does not support rss_key, so length should be 0*/ 1798 rss_conf->rss_key_len = 0; 1799 rss_conf->rss_hf = eth_conf->rx_adv_conf.rss_conf.rss_hf; 1800 return 0; 1801 } 1802 1803 int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev, 1804 int eth_rx_queue_id, 1805 uint16_t dpcon_id, 1806 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf) 1807 { 1808 struct dpaa2_dev_priv *eth_priv = dev->data->dev_private; 1809 struct fsl_mc_io *dpni = (struct fsl_mc_io *)eth_priv->hw; 1810 struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id]; 1811 uint8_t flow_id = dpaa2_ethq->flow_id; 1812 struct dpni_queue cfg; 1813 uint8_t options; 1814 int ret; 1815 1816 if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_PARALLEL) 1817 dpaa2_ethq->cb = dpaa2_dev_process_parallel_event; 1818 else if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_ATOMIC) 1819 dpaa2_ethq->cb = dpaa2_dev_process_atomic_event; 1820 else if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_ORDERED) 1821 dpaa2_ethq->cb = dpaa2_dev_process_ordered_event; 1822 else 1823 return -EINVAL; 1824 1825 memset(&cfg, 0, sizeof(struct dpni_queue)); 1826 options = DPNI_QUEUE_OPT_DEST; 1827 cfg.destination.type = DPNI_DEST_DPCON; 1828 cfg.destination.id = dpcon_id; 1829 cfg.destination.priority = queue_conf->ev.priority; 1830 1831 if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_ATOMIC) { 1832 options |= DPNI_QUEUE_OPT_HOLD_ACTIVE; 1833 cfg.destination.hold_active = 1; 1834 } 1835 1836 if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_ORDERED && 1837 !eth_priv->en_ordered) { 1838 struct opr_cfg ocfg; 1839 1840 /* Restoration window size = 256 frames */ 1841 ocfg.oprrws = 3; 1842 /* Restoration window size = 512 frames for LX2 */ 1843 if (dpaa2_svr_family == SVR_LX2160A) 1844 ocfg.oprrws = 4; 1845 /* Auto advance NESN window enabled */ 1846 ocfg.oa = 1; 1847 /* Late arrival window size disabled */ 1848 ocfg.olws = 0; 1849 /* ORL resource exhaustaion advance NESN disabled */ 1850 ocfg.oeane = 0; 1851 /* Loose ordering enabled */ 1852 ocfg.oloe = 1; 1853 eth_priv->en_loose_ordered = 1; 1854 /* Strict ordering enabled if explicitly set */ 1855 if (getenv("DPAA2_STRICT_ORDERING_ENABLE")) { 1856 ocfg.oloe = 0; 1857 eth_priv->en_loose_ordered = 0; 1858 } 1859 1860 ret = dpni_set_opr(dpni, CMD_PRI_LOW, eth_priv->token, 1861 dpaa2_ethq->tc_index, flow_id, 1862 OPR_OPT_CREATE, &ocfg); 1863 if (ret) { 1864 DPAA2_PMD_ERR("Error setting opr: ret: %d\n", ret); 1865 return ret; 1866 } 1867 1868 eth_priv->en_ordered = 1; 1869 } 1870 1871 options |= DPNI_QUEUE_OPT_USER_CTX; 1872 cfg.user_context = (size_t)(dpaa2_ethq); 1873 1874 ret = dpni_set_queue(dpni, CMD_PRI_LOW, eth_priv->token, DPNI_QUEUE_RX, 1875 dpaa2_ethq->tc_index, flow_id, options, &cfg); 1876 if (ret) { 1877 DPAA2_PMD_ERR("Error in dpni_set_queue: ret: %d", ret); 1878 return ret; 1879 } 1880 1881 memcpy(&dpaa2_ethq->ev, &queue_conf->ev, sizeof(struct rte_event)); 1882 1883 return 0; 1884 } 1885 1886 int dpaa2_eth_eventq_detach(const struct rte_eth_dev *dev, 1887 int eth_rx_queue_id) 1888 { 1889 struct dpaa2_dev_priv *eth_priv = dev->data->dev_private; 1890 struct fsl_mc_io *dpni = (struct fsl_mc_io *)eth_priv->hw; 1891 struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id]; 1892 uint8_t flow_id = dpaa2_ethq->flow_id; 1893 struct dpni_queue cfg; 1894 uint8_t options; 1895 int ret; 1896 1897 memset(&cfg, 0, sizeof(struct dpni_queue)); 1898 options = DPNI_QUEUE_OPT_DEST; 1899 cfg.destination.type = DPNI_DEST_NONE; 1900 1901 ret = dpni_set_queue(dpni, CMD_PRI_LOW, eth_priv->token, DPNI_QUEUE_RX, 1902 dpaa2_ethq->tc_index, flow_id, options, &cfg); 1903 if (ret) 1904 DPAA2_PMD_ERR("Error in dpni_set_queue: ret: %d", ret); 1905 1906 return ret; 1907 } 1908 1909 static inline int 1910 dpaa2_dev_verify_filter_ops(enum rte_filter_op filter_op) 1911 { 1912 unsigned int i; 1913 1914 for (i = 0; i < RTE_DIM(dpaa2_supported_filter_ops); i++) { 1915 if (dpaa2_supported_filter_ops[i] == filter_op) 1916 return 0; 1917 } 1918 return -ENOTSUP; 1919 } 1920 1921 static int 1922 dpaa2_dev_flow_ctrl(struct rte_eth_dev *dev, 1923 enum rte_filter_type filter_type, 1924 enum rte_filter_op filter_op, 1925 void *arg) 1926 { 1927 int ret = 0; 1928 1929 if (!dev) 1930 return -ENODEV; 1931 1932 switch (filter_type) { 1933 case RTE_ETH_FILTER_GENERIC: 1934 if (dpaa2_dev_verify_filter_ops(filter_op) < 0) { 1935 ret = -ENOTSUP; 1936 break; 1937 } 1938 *(const void **)arg = &dpaa2_flow_ops; 1939 dpaa2_filter_type |= filter_type; 1940 break; 1941 default: 1942 RTE_LOG(ERR, PMD, "Filter type (%d) not supported", 1943 filter_type); 1944 ret = -ENOTSUP; 1945 break; 1946 } 1947 return ret; 1948 } 1949 1950 static struct eth_dev_ops dpaa2_ethdev_ops = { 1951 .dev_configure = dpaa2_eth_dev_configure, 1952 .dev_start = dpaa2_dev_start, 1953 .dev_stop = dpaa2_dev_stop, 1954 .dev_close = dpaa2_dev_close, 1955 .promiscuous_enable = dpaa2_dev_promiscuous_enable, 1956 .promiscuous_disable = dpaa2_dev_promiscuous_disable, 1957 .allmulticast_enable = dpaa2_dev_allmulticast_enable, 1958 .allmulticast_disable = dpaa2_dev_allmulticast_disable, 1959 .dev_set_link_up = dpaa2_dev_set_link_up, 1960 .dev_set_link_down = dpaa2_dev_set_link_down, 1961 .link_update = dpaa2_dev_link_update, 1962 .stats_get = dpaa2_dev_stats_get, 1963 .xstats_get = dpaa2_dev_xstats_get, 1964 .xstats_get_by_id = dpaa2_xstats_get_by_id, 1965 .xstats_get_names_by_id = dpaa2_xstats_get_names_by_id, 1966 .xstats_get_names = dpaa2_xstats_get_names, 1967 .stats_reset = dpaa2_dev_stats_reset, 1968 .xstats_reset = dpaa2_dev_stats_reset, 1969 .fw_version_get = dpaa2_fw_version_get, 1970 .dev_infos_get = dpaa2_dev_info_get, 1971 .dev_supported_ptypes_get = dpaa2_supported_ptypes_get, 1972 .mtu_set = dpaa2_dev_mtu_set, 1973 .vlan_filter_set = dpaa2_vlan_filter_set, 1974 .vlan_offload_set = dpaa2_vlan_offload_set, 1975 .vlan_tpid_set = dpaa2_vlan_tpid_set, 1976 .rx_queue_setup = dpaa2_dev_rx_queue_setup, 1977 .rx_queue_release = dpaa2_dev_rx_queue_release, 1978 .tx_queue_setup = dpaa2_dev_tx_queue_setup, 1979 .tx_queue_release = dpaa2_dev_tx_queue_release, 1980 .rx_queue_count = dpaa2_dev_rx_queue_count, 1981 .flow_ctrl_get = dpaa2_flow_ctrl_get, 1982 .flow_ctrl_set = dpaa2_flow_ctrl_set, 1983 .mac_addr_add = dpaa2_dev_add_mac_addr, 1984 .mac_addr_remove = dpaa2_dev_remove_mac_addr, 1985 .mac_addr_set = dpaa2_dev_set_mac_addr, 1986 .rss_hash_update = dpaa2_dev_rss_hash_update, 1987 .rss_hash_conf_get = dpaa2_dev_rss_hash_conf_get, 1988 .filter_ctrl = dpaa2_dev_flow_ctrl, 1989 }; 1990 1991 /* Populate the mac address from physically available (u-boot/firmware) and/or 1992 * one set by higher layers like MC (restool) etc. 1993 * Returns the table of MAC entries (multiple entries) 1994 */ 1995 static int 1996 populate_mac_addr(struct fsl_mc_io *dpni_dev, struct dpaa2_dev_priv *priv, 1997 struct rte_ether_addr *mac_entry) 1998 { 1999 int ret; 2000 struct rte_ether_addr phy_mac, prime_mac; 2001 2002 memset(&phy_mac, 0, sizeof(struct rte_ether_addr)); 2003 memset(&prime_mac, 0, sizeof(struct rte_ether_addr)); 2004 2005 /* Get the physical device MAC address */ 2006 ret = dpni_get_port_mac_addr(dpni_dev, CMD_PRI_LOW, priv->token, 2007 phy_mac.addr_bytes); 2008 if (ret) { 2009 DPAA2_PMD_ERR("DPNI get physical port MAC failed: %d", ret); 2010 goto cleanup; 2011 } 2012 2013 ret = dpni_get_primary_mac_addr(dpni_dev, CMD_PRI_LOW, priv->token, 2014 prime_mac.addr_bytes); 2015 if (ret) { 2016 DPAA2_PMD_ERR("DPNI get Prime port MAC failed: %d", ret); 2017 goto cleanup; 2018 } 2019 2020 /* Now that both MAC have been obtained, do: 2021 * if not_empty_mac(phy) && phy != Prime, overwrite prime with Phy 2022 * and return phy 2023 * If empty_mac(phy), return prime. 2024 * if both are empty, create random MAC, set as prime and return 2025 */ 2026 if (!rte_is_zero_ether_addr(&phy_mac)) { 2027 /* If the addresses are not same, overwrite prime */ 2028 if (!rte_is_same_ether_addr(&phy_mac, &prime_mac)) { 2029 ret = dpni_set_primary_mac_addr(dpni_dev, CMD_PRI_LOW, 2030 priv->token, 2031 phy_mac.addr_bytes); 2032 if (ret) { 2033 DPAA2_PMD_ERR("Unable to set MAC Address: %d", 2034 ret); 2035 goto cleanup; 2036 } 2037 memcpy(&prime_mac, &phy_mac, 2038 sizeof(struct rte_ether_addr)); 2039 } 2040 } else if (rte_is_zero_ether_addr(&prime_mac)) { 2041 /* In case phys and prime, both are zero, create random MAC */ 2042 rte_eth_random_addr(prime_mac.addr_bytes); 2043 ret = dpni_set_primary_mac_addr(dpni_dev, CMD_PRI_LOW, 2044 priv->token, 2045 prime_mac.addr_bytes); 2046 if (ret) { 2047 DPAA2_PMD_ERR("Unable to set MAC Address: %d", ret); 2048 goto cleanup; 2049 } 2050 } 2051 2052 /* prime_mac the final MAC address */ 2053 memcpy(mac_entry, &prime_mac, sizeof(struct rte_ether_addr)); 2054 return 0; 2055 2056 cleanup: 2057 return -1; 2058 } 2059 2060 static int 2061 check_devargs_handler(__rte_unused const char *key, const char *value, 2062 __rte_unused void *opaque) 2063 { 2064 if (strcmp(value, "1")) 2065 return -1; 2066 2067 return 0; 2068 } 2069 2070 static int 2071 dpaa2_get_devargs(struct rte_devargs *devargs, const char *key) 2072 { 2073 struct rte_kvargs *kvlist; 2074 2075 if (!devargs) 2076 return 0; 2077 2078 kvlist = rte_kvargs_parse(devargs->args, NULL); 2079 if (!kvlist) 2080 return 0; 2081 2082 if (!rte_kvargs_count(kvlist, key)) { 2083 rte_kvargs_free(kvlist); 2084 return 0; 2085 } 2086 2087 if (rte_kvargs_process(kvlist, key, 2088 check_devargs_handler, NULL) < 0) { 2089 rte_kvargs_free(kvlist); 2090 return 0; 2091 } 2092 rte_kvargs_free(kvlist); 2093 2094 return 1; 2095 } 2096 2097 static int 2098 dpaa2_dev_init(struct rte_eth_dev *eth_dev) 2099 { 2100 struct rte_device *dev = eth_dev->device; 2101 struct rte_dpaa2_device *dpaa2_dev; 2102 struct fsl_mc_io *dpni_dev; 2103 struct dpni_attr attr; 2104 struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; 2105 struct dpni_buffer_layout layout; 2106 int ret, hw_id, i; 2107 2108 PMD_INIT_FUNC_TRACE(); 2109 2110 /* For secondary processes, the primary has done all the work */ 2111 if (rte_eal_process_type() != RTE_PROC_PRIMARY) { 2112 /* In case of secondary, only burst and ops API need to be 2113 * plugged. 2114 */ 2115 eth_dev->dev_ops = &dpaa2_ethdev_ops; 2116 if (dpaa2_get_devargs(dev->devargs, DRIVER_LOOPBACK_MODE)) 2117 eth_dev->rx_pkt_burst = dpaa2_dev_loopback_rx; 2118 else 2119 eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx; 2120 eth_dev->tx_pkt_burst = dpaa2_dev_tx; 2121 return 0; 2122 } 2123 2124 dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device); 2125 2126 hw_id = dpaa2_dev->object_id; 2127 2128 dpni_dev = rte_malloc(NULL, sizeof(struct fsl_mc_io), 0); 2129 if (!dpni_dev) { 2130 DPAA2_PMD_ERR("Memory allocation failed for dpni device"); 2131 return -1; 2132 } 2133 2134 dpni_dev->regs = rte_mcp_ptr_list[0]; 2135 ret = dpni_open(dpni_dev, CMD_PRI_LOW, hw_id, &priv->token); 2136 if (ret) { 2137 DPAA2_PMD_ERR( 2138 "Failure in opening dpni@%d with err code %d", 2139 hw_id, ret); 2140 rte_free(dpni_dev); 2141 return -1; 2142 } 2143 2144 /* Clean the device first */ 2145 ret = dpni_reset(dpni_dev, CMD_PRI_LOW, priv->token); 2146 if (ret) { 2147 DPAA2_PMD_ERR("Failure cleaning dpni@%d with err code %d", 2148 hw_id, ret); 2149 goto init_err; 2150 } 2151 2152 ret = dpni_get_attributes(dpni_dev, CMD_PRI_LOW, priv->token, &attr); 2153 if (ret) { 2154 DPAA2_PMD_ERR( 2155 "Failure in get dpni@%d attribute, err code %d", 2156 hw_id, ret); 2157 goto init_err; 2158 } 2159 2160 priv->num_rx_tc = attr.num_rx_tcs; 2161 2162 for (i = 0; i < attr.num_rx_tcs; i++) 2163 priv->nb_rx_queues += attr.num_queues; 2164 2165 /* Using number of TX queues as number of TX TCs */ 2166 priv->nb_tx_queues = attr.num_tx_tcs; 2167 2168 DPAA2_PMD_DEBUG("RX-TC= %d, nb_rx_queues= %d, nb_tx_queues=%d", 2169 priv->num_rx_tc, priv->nb_rx_queues, 2170 priv->nb_tx_queues); 2171 2172 priv->hw = dpni_dev; 2173 priv->hw_id = hw_id; 2174 priv->options = attr.options; 2175 priv->max_mac_filters = attr.mac_filter_entries; 2176 priv->max_vlan_filters = attr.vlan_filter_entries; 2177 priv->flags = 0; 2178 2179 /* Allocate memory for hardware structure for queues */ 2180 ret = dpaa2_alloc_rx_tx_queues(eth_dev); 2181 if (ret) { 2182 DPAA2_PMD_ERR("Queue allocation Failed"); 2183 goto init_err; 2184 } 2185 2186 /* Allocate memory for storing MAC addresses. 2187 * Table of mac_filter_entries size is allocated so that RTE ether lib 2188 * can add MAC entries when rte_eth_dev_mac_addr_add is called. 2189 */ 2190 eth_dev->data->mac_addrs = rte_zmalloc("dpni", 2191 RTE_ETHER_ADDR_LEN * attr.mac_filter_entries, 0); 2192 if (eth_dev->data->mac_addrs == NULL) { 2193 DPAA2_PMD_ERR( 2194 "Failed to allocate %d bytes needed to store MAC addresses", 2195 RTE_ETHER_ADDR_LEN * attr.mac_filter_entries); 2196 ret = -ENOMEM; 2197 goto init_err; 2198 } 2199 2200 ret = populate_mac_addr(dpni_dev, priv, ð_dev->data->mac_addrs[0]); 2201 if (ret) { 2202 DPAA2_PMD_ERR("Unable to fetch MAC Address for device"); 2203 rte_free(eth_dev->data->mac_addrs); 2204 eth_dev->data->mac_addrs = NULL; 2205 goto init_err; 2206 } 2207 2208 /* ... tx buffer layout ... */ 2209 memset(&layout, 0, sizeof(struct dpni_buffer_layout)); 2210 layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS; 2211 layout.pass_frame_status = 1; 2212 ret = dpni_set_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token, 2213 DPNI_QUEUE_TX, &layout); 2214 if (ret) { 2215 DPAA2_PMD_ERR("Error (%d) in setting tx buffer layout", ret); 2216 goto init_err; 2217 } 2218 2219 /* ... tx-conf and error buffer layout ... */ 2220 memset(&layout, 0, sizeof(struct dpni_buffer_layout)); 2221 layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS; 2222 layout.pass_frame_status = 1; 2223 ret = dpni_set_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token, 2224 DPNI_QUEUE_TX_CONFIRM, &layout); 2225 if (ret) { 2226 DPAA2_PMD_ERR("Error (%d) in setting tx-conf buffer layout", 2227 ret); 2228 goto init_err; 2229 } 2230 2231 eth_dev->dev_ops = &dpaa2_ethdev_ops; 2232 2233 if (dpaa2_get_devargs(dev->devargs, DRIVER_LOOPBACK_MODE)) { 2234 eth_dev->rx_pkt_burst = dpaa2_dev_loopback_rx; 2235 DPAA2_PMD_INFO("Loopback mode"); 2236 } else { 2237 eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx; 2238 } 2239 eth_dev->tx_pkt_burst = dpaa2_dev_tx; 2240 2241 /*Init fields w.r.t. classficaition*/ 2242 memset(&priv->extract.qos_key_cfg, 0, sizeof(struct dpkg_profile_cfg)); 2243 priv->extract.qos_extract_param = (size_t)rte_malloc(NULL, 256, 64); 2244 if (!priv->extract.qos_extract_param) { 2245 DPAA2_PMD_ERR(" Error(%d) in allocation resources for flow " 2246 " classificaiton ", ret); 2247 goto init_err; 2248 } 2249 for (i = 0; i < MAX_TCS; i++) { 2250 memset(&priv->extract.fs_key_cfg[i], 0, 2251 sizeof(struct dpkg_profile_cfg)); 2252 priv->extract.fs_extract_param[i] = 2253 (size_t)rte_malloc(NULL, 256, 64); 2254 if (!priv->extract.fs_extract_param[i]) { 2255 DPAA2_PMD_ERR(" Error(%d) in allocation resources for flow classificaiton", 2256 ret); 2257 goto init_err; 2258 } 2259 } 2260 2261 RTE_LOG(INFO, PMD, "%s: netdev created\n", eth_dev->data->name); 2262 return 0; 2263 init_err: 2264 dpaa2_dev_uninit(eth_dev); 2265 return ret; 2266 } 2267 2268 static int 2269 dpaa2_dev_uninit(struct rte_eth_dev *eth_dev) 2270 { 2271 struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; 2272 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; 2273 int i, ret; 2274 2275 PMD_INIT_FUNC_TRACE(); 2276 2277 if (rte_eal_process_type() != RTE_PROC_PRIMARY) 2278 return 0; 2279 2280 if (!dpni) { 2281 DPAA2_PMD_WARN("Already closed or not started"); 2282 return -1; 2283 } 2284 2285 dpaa2_dev_close(eth_dev); 2286 2287 dpaa2_free_rx_tx_queues(eth_dev); 2288 2289 /* Close the device at underlying layer*/ 2290 ret = dpni_close(dpni, CMD_PRI_LOW, priv->token); 2291 if (ret) { 2292 DPAA2_PMD_ERR( 2293 "Failure closing dpni device with err code %d", 2294 ret); 2295 } 2296 2297 /* Free the allocated memory for ethernet private data and dpni*/ 2298 priv->hw = NULL; 2299 rte_free(dpni); 2300 2301 for (i = 0; i < MAX_TCS; i++) { 2302 if (priv->extract.fs_extract_param[i]) 2303 rte_free((void *)(size_t)priv->extract.fs_extract_param[i]); 2304 } 2305 2306 if (priv->extract.qos_extract_param) 2307 rte_free((void *)(size_t)priv->extract.qos_extract_param); 2308 2309 eth_dev->dev_ops = NULL; 2310 eth_dev->rx_pkt_burst = NULL; 2311 eth_dev->tx_pkt_burst = NULL; 2312 2313 DPAA2_PMD_INFO("%s: netdev deleted", eth_dev->data->name); 2314 return 0; 2315 } 2316 2317 static int 2318 rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv, 2319 struct rte_dpaa2_device *dpaa2_dev) 2320 { 2321 struct rte_eth_dev *eth_dev; 2322 int diag; 2323 2324 if ((DPAA2_MBUF_HW_ANNOTATION + DPAA2_FD_PTA_SIZE) > 2325 RTE_PKTMBUF_HEADROOM) { 2326 DPAA2_PMD_ERR( 2327 "RTE_PKTMBUF_HEADROOM(%d) shall be > DPAA2 Annotation req(%d)", 2328 RTE_PKTMBUF_HEADROOM, 2329 DPAA2_MBUF_HW_ANNOTATION + DPAA2_FD_PTA_SIZE); 2330 2331 return -1; 2332 } 2333 2334 if (rte_eal_process_type() == RTE_PROC_PRIMARY) { 2335 eth_dev = rte_eth_dev_allocate(dpaa2_dev->device.name); 2336 if (!eth_dev) 2337 return -ENODEV; 2338 eth_dev->data->dev_private = rte_zmalloc( 2339 "ethdev private structure", 2340 sizeof(struct dpaa2_dev_priv), 2341 RTE_CACHE_LINE_SIZE); 2342 if (eth_dev->data->dev_private == NULL) { 2343 DPAA2_PMD_CRIT( 2344 "Unable to allocate memory for private data"); 2345 rte_eth_dev_release_port(eth_dev); 2346 return -ENOMEM; 2347 } 2348 } else { 2349 eth_dev = rte_eth_dev_attach_secondary(dpaa2_dev->device.name); 2350 if (!eth_dev) 2351 return -ENODEV; 2352 } 2353 2354 eth_dev->device = &dpaa2_dev->device; 2355 2356 dpaa2_dev->eth_dev = eth_dev; 2357 eth_dev->data->rx_mbuf_alloc_failed = 0; 2358 2359 if (dpaa2_drv->drv_flags & RTE_DPAA2_DRV_INTR_LSC) 2360 eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; 2361 2362 /* Invoke PMD device initialization function */ 2363 diag = dpaa2_dev_init(eth_dev); 2364 if (diag == 0) { 2365 rte_eth_dev_probing_finish(eth_dev); 2366 return 0; 2367 } 2368 2369 rte_eth_dev_release_port(eth_dev); 2370 return diag; 2371 } 2372 2373 static int 2374 rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) 2375 { 2376 struct rte_eth_dev *eth_dev; 2377 2378 eth_dev = dpaa2_dev->eth_dev; 2379 dpaa2_dev_uninit(eth_dev); 2380 2381 rte_eth_dev_release_port(eth_dev); 2382 2383 return 0; 2384 } 2385 2386 static struct rte_dpaa2_driver rte_dpaa2_pmd = { 2387 .drv_flags = RTE_DPAA2_DRV_INTR_LSC | RTE_DPAA2_DRV_IOVA_AS_VA, 2388 .drv_type = DPAA2_ETH, 2389 .probe = rte_dpaa2_probe, 2390 .remove = rte_dpaa2_remove, 2391 }; 2392 2393 RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd); 2394 RTE_PMD_REGISTER_PARAM_STRING(net_dpaa2, 2395 DRIVER_LOOPBACK_MODE "=<int>"); 2396 RTE_INIT(dpaa2_pmd_init_log) 2397 { 2398 dpaa2_logtype_pmd = rte_log_register("pmd.net.dpaa2"); 2399 if (dpaa2_logtype_pmd >= 0) 2400 rte_log_set_level(dpaa2_logtype_pmd, RTE_LOG_NOTICE); 2401 } 2402