1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2017 Cavium, Inc 3 */ 4 5 #include <stdio.h> 6 #include <stdarg.h> 7 #include <stdbool.h> 8 #include <stdint.h> 9 #include <string.h> 10 #include <unistd.h> 11 12 #include <rte_alarm.h> 13 #include <rte_branch_prediction.h> 14 #include <rte_debug.h> 15 #include <rte_devargs.h> 16 #include <rte_dev.h> 17 #include <rte_kvargs.h> 18 #include <rte_malloc.h> 19 #include <rte_mbuf_pool_ops.h> 20 #include <rte_prefetch.h> 21 #include <rte_bus_vdev.h> 22 23 #include "octeontx_ethdev.h" 24 #include "octeontx_rxtx.h" 25 #include "octeontx_logs.h" 26 27 struct octeontx_vdev_init_params { 28 uint8_t nr_port; 29 }; 30 31 uint16_t 32 rte_octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX]; 33 34 enum octeontx_link_speed { 35 OCTEONTX_LINK_SPEED_SGMII, 36 OCTEONTX_LINK_SPEED_XAUI, 37 OCTEONTX_LINK_SPEED_RXAUI, 38 OCTEONTX_LINK_SPEED_10G_R, 39 OCTEONTX_LINK_SPEED_40G_R, 40 OCTEONTX_LINK_SPEED_RESERVE1, 41 OCTEONTX_LINK_SPEED_QSGMII, 42 OCTEONTX_LINK_SPEED_RESERVE2 43 }; 44 45 int otx_net_logtype_mbox; 46 int otx_net_logtype_init; 47 int otx_net_logtype_driver; 48 49 RTE_INIT(otx_net_init_log) 50 { 51 otx_net_logtype_mbox = rte_log_register("pmd.net.octeontx.mbox"); 52 if (otx_net_logtype_mbox >= 0) 53 rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE); 54 55 otx_net_logtype_init = rte_log_register("pmd.net.octeontx.init"); 56 if (otx_net_logtype_init >= 0) 57 rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE); 58 59 otx_net_logtype_driver = rte_log_register("pmd.net.octeontx.driver"); 60 if (otx_net_logtype_driver >= 0) 61 rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE); 62 } 63 64 /* Parse integer from integer argument */ 65 static int 66 parse_integer_arg(const char *key __rte_unused, 67 const char *value, void *extra_args) 68 { 69 int *i = (int *)extra_args; 70 71 *i = atoi(value); 72 if (*i < 0) { 73 octeontx_log_err("argument has to be positive."); 74 return -1; 75 } 76 77 return 0; 78 } 79 80 static int 81 octeontx_parse_vdev_init_params(struct octeontx_vdev_init_params *params, 82 struct rte_vdev_device *dev) 83 { 84 struct rte_kvargs *kvlist = NULL; 85 int ret = 0; 86 87 static const char * const octeontx_vdev_valid_params[] = { 88 OCTEONTX_VDEV_NR_PORT_ARG, 89 NULL 90 }; 91 92 const char *input_args = rte_vdev_device_args(dev); 93 if (params == NULL) 94 return -EINVAL; 95 96 97 if (input_args) { 98 kvlist = rte_kvargs_parse(input_args, 99 octeontx_vdev_valid_params); 100 if (kvlist == NULL) 101 return -1; 102 103 ret = rte_kvargs_process(kvlist, 104 OCTEONTX_VDEV_NR_PORT_ARG, 105 &parse_integer_arg, 106 ¶ms->nr_port); 107 if (ret < 0) 108 goto free_kvlist; 109 } 110 111 free_kvlist: 112 rte_kvargs_free(kvlist); 113 return ret; 114 } 115 116 static int 117 octeontx_port_open(struct octeontx_nic *nic) 118 { 119 octeontx_mbox_bgx_port_conf_t bgx_port_conf; 120 int res; 121 122 res = 0; 123 memset(&bgx_port_conf, 0x0, sizeof(bgx_port_conf)); 124 PMD_INIT_FUNC_TRACE(); 125 126 res = octeontx_bgx_port_open(nic->port_id, &bgx_port_conf); 127 if (res < 0) { 128 octeontx_log_err("failed to open port %d", res); 129 return res; 130 } 131 132 nic->node = bgx_port_conf.node; 133 nic->port_ena = bgx_port_conf.enable; 134 nic->base_ichan = bgx_port_conf.base_chan; 135 nic->base_ochan = bgx_port_conf.base_chan; 136 nic->num_ichans = bgx_port_conf.num_chans; 137 nic->num_ochans = bgx_port_conf.num_chans; 138 nic->mtu = bgx_port_conf.mtu; 139 nic->bpen = bgx_port_conf.bpen; 140 nic->fcs_strip = bgx_port_conf.fcs_strip; 141 nic->bcast_mode = bgx_port_conf.bcast_mode; 142 nic->mcast_mode = bgx_port_conf.mcast_mode; 143 nic->speed = bgx_port_conf.mode; 144 145 memcpy(&nic->mac_addr[0], &bgx_port_conf.macaddr[0], 146 RTE_ETHER_ADDR_LEN); 147 148 octeontx_log_dbg("port opened %d", nic->port_id); 149 return res; 150 } 151 152 static void 153 octeontx_port_close(struct octeontx_nic *nic) 154 { 155 PMD_INIT_FUNC_TRACE(); 156 157 octeontx_bgx_port_close(nic->port_id); 158 octeontx_log_dbg("port closed %d", nic->port_id); 159 } 160 161 static int 162 octeontx_port_start(struct octeontx_nic *nic) 163 { 164 PMD_INIT_FUNC_TRACE(); 165 166 return octeontx_bgx_port_start(nic->port_id); 167 } 168 169 static int 170 octeontx_port_stop(struct octeontx_nic *nic) 171 { 172 PMD_INIT_FUNC_TRACE(); 173 174 return octeontx_bgx_port_stop(nic->port_id); 175 } 176 177 static int 178 octeontx_port_promisc_set(struct octeontx_nic *nic, int en) 179 { 180 struct rte_eth_dev *dev; 181 int res; 182 183 res = 0; 184 PMD_INIT_FUNC_TRACE(); 185 dev = nic->dev; 186 187 res = octeontx_bgx_port_promisc_set(nic->port_id, en); 188 if (res < 0) { 189 octeontx_log_err("failed to set promiscuous mode %d", 190 nic->port_id); 191 return res; 192 } 193 194 /* Set proper flag for the mode */ 195 dev->data->promiscuous = (en != 0) ? 1 : 0; 196 197 octeontx_log_dbg("port %d : promiscuous mode %s", 198 nic->port_id, en ? "set" : "unset"); 199 200 return 0; 201 } 202 203 static int 204 octeontx_port_stats(struct octeontx_nic *nic, struct rte_eth_stats *stats) 205 { 206 octeontx_mbox_bgx_port_stats_t bgx_stats; 207 int res; 208 209 PMD_INIT_FUNC_TRACE(); 210 211 res = octeontx_bgx_port_stats(nic->port_id, &bgx_stats); 212 if (res < 0) { 213 octeontx_log_err("failed to get port stats %d", nic->port_id); 214 return res; 215 } 216 217 stats->ipackets = bgx_stats.rx_packets; 218 stats->ibytes = bgx_stats.rx_bytes; 219 stats->imissed = bgx_stats.rx_dropped; 220 stats->ierrors = bgx_stats.rx_errors; 221 stats->opackets = bgx_stats.tx_packets; 222 stats->obytes = bgx_stats.tx_bytes; 223 stats->oerrors = bgx_stats.tx_errors; 224 225 octeontx_log_dbg("port%d stats inpkts=%" PRIx64 " outpkts=%" PRIx64 "", 226 nic->port_id, stats->ipackets, stats->opackets); 227 228 return 0; 229 } 230 231 static int 232 octeontx_port_stats_clr(struct octeontx_nic *nic) 233 { 234 PMD_INIT_FUNC_TRACE(); 235 236 return octeontx_bgx_port_stats_clr(nic->port_id); 237 } 238 239 static inline void 240 devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf, 241 struct rte_event_dev_info *info) 242 { 243 memset(dev_conf, 0, sizeof(struct rte_event_dev_config)); 244 dev_conf->dequeue_timeout_ns = info->min_dequeue_timeout_ns; 245 246 dev_conf->nb_event_ports = info->max_event_ports; 247 dev_conf->nb_event_queues = info->max_event_queues; 248 249 dev_conf->nb_event_queue_flows = info->max_event_queue_flows; 250 dev_conf->nb_event_port_dequeue_depth = 251 info->max_event_port_dequeue_depth; 252 dev_conf->nb_event_port_enqueue_depth = 253 info->max_event_port_enqueue_depth; 254 dev_conf->nb_event_port_enqueue_depth = 255 info->max_event_port_enqueue_depth; 256 dev_conf->nb_events_limit = 257 info->max_num_events; 258 } 259 260 static int 261 octeontx_dev_configure(struct rte_eth_dev *dev) 262 { 263 struct rte_eth_dev_data *data = dev->data; 264 struct rte_eth_conf *conf = &data->dev_conf; 265 struct rte_eth_rxmode *rxmode = &conf->rxmode; 266 struct rte_eth_txmode *txmode = &conf->txmode; 267 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 268 int ret; 269 270 PMD_INIT_FUNC_TRACE(); 271 RTE_SET_USED(conf); 272 273 if (!rte_eal_has_hugepages()) { 274 octeontx_log_err("huge page is not configured"); 275 return -EINVAL; 276 } 277 278 if (txmode->mq_mode) { 279 octeontx_log_err("tx mq_mode DCB or VMDq not supported"); 280 return -EINVAL; 281 } 282 283 if (rxmode->mq_mode != ETH_MQ_RX_NONE && 284 rxmode->mq_mode != ETH_MQ_RX_RSS) { 285 octeontx_log_err("unsupported rx qmode %d", rxmode->mq_mode); 286 return -EINVAL; 287 } 288 289 if (!(txmode->offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) { 290 PMD_INIT_LOG(NOTICE, "cant disable lockfree tx"); 291 txmode->offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE; 292 } 293 294 if (conf->link_speeds & ETH_LINK_SPEED_FIXED) { 295 octeontx_log_err("setting link speed/duplex not supported"); 296 return -EINVAL; 297 } 298 299 if (conf->dcb_capability_en) { 300 octeontx_log_err("DCB enable not supported"); 301 return -EINVAL; 302 } 303 304 if (conf->fdir_conf.mode != RTE_FDIR_MODE_NONE) { 305 octeontx_log_err("flow director not supported"); 306 return -EINVAL; 307 } 308 309 nic->num_tx_queues = dev->data->nb_tx_queues; 310 311 ret = octeontx_pko_channel_open(nic->pko_vfid * PKO_VF_NUM_DQ, 312 nic->num_tx_queues, 313 nic->base_ochan); 314 if (ret) { 315 octeontx_log_err("failed to open channel %d no-of-txq %d", 316 nic->base_ochan, nic->num_tx_queues); 317 return -EFAULT; 318 } 319 320 nic->pki.classifier_enable = false; 321 nic->pki.hash_enable = true; 322 nic->pki.initialized = false; 323 324 return 0; 325 } 326 327 static void 328 octeontx_dev_close(struct rte_eth_dev *dev) 329 { 330 struct octeontx_txq *txq = NULL; 331 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 332 unsigned int i; 333 int ret; 334 335 PMD_INIT_FUNC_TRACE(); 336 337 rte_event_dev_close(nic->evdev); 338 339 ret = octeontx_pko_channel_close(nic->base_ochan); 340 if (ret < 0) { 341 octeontx_log_err("failed to close channel %d VF%d %d %d", 342 nic->base_ochan, nic->port_id, nic->num_tx_queues, 343 ret); 344 } 345 /* Free txq resources for this port */ 346 for (i = 0; i < nic->num_tx_queues; i++) { 347 txq = dev->data->tx_queues[i]; 348 if (!txq) 349 continue; 350 351 rte_free(txq); 352 } 353 354 dev->tx_pkt_burst = NULL; 355 dev->rx_pkt_burst = NULL; 356 } 357 358 static int 359 octeontx_dev_start(struct rte_eth_dev *dev) 360 { 361 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 362 int ret; 363 364 ret = 0; 365 366 PMD_INIT_FUNC_TRACE(); 367 /* 368 * Tx start 369 */ 370 dev->tx_pkt_burst = octeontx_xmit_pkts; 371 ret = octeontx_pko_channel_start(nic->base_ochan); 372 if (ret < 0) { 373 octeontx_log_err("fail to conf VF%d no. txq %d chan %d ret %d", 374 nic->port_id, nic->num_tx_queues, nic->base_ochan, 375 ret); 376 goto error; 377 } 378 379 /* 380 * Rx start 381 */ 382 dev->rx_pkt_burst = octeontx_recv_pkts; 383 ret = octeontx_pki_port_start(nic->port_id); 384 if (ret < 0) { 385 octeontx_log_err("fail to start Rx on port %d", nic->port_id); 386 goto channel_stop_error; 387 } 388 389 /* 390 * Start port 391 */ 392 ret = octeontx_port_start(nic); 393 if (ret < 0) { 394 octeontx_log_err("failed start port %d", ret); 395 goto pki_port_stop_error; 396 } 397 398 PMD_TX_LOG(DEBUG, "pko: start channel %d no.of txq %d port %d", 399 nic->base_ochan, nic->num_tx_queues, nic->port_id); 400 401 ret = rte_event_dev_start(nic->evdev); 402 if (ret < 0) { 403 octeontx_log_err("failed to start evdev: ret (%d)", ret); 404 goto pki_port_stop_error; 405 } 406 407 /* Success */ 408 return ret; 409 410 pki_port_stop_error: 411 octeontx_pki_port_stop(nic->port_id); 412 channel_stop_error: 413 octeontx_pko_channel_stop(nic->base_ochan); 414 error: 415 return ret; 416 } 417 418 static void 419 octeontx_dev_stop(struct rte_eth_dev *dev) 420 { 421 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 422 int ret; 423 424 PMD_INIT_FUNC_TRACE(); 425 426 rte_event_dev_stop(nic->evdev); 427 428 ret = octeontx_port_stop(nic); 429 if (ret < 0) { 430 octeontx_log_err("failed to req stop port %d res=%d", 431 nic->port_id, ret); 432 return; 433 } 434 435 ret = octeontx_pki_port_stop(nic->port_id); 436 if (ret < 0) { 437 octeontx_log_err("failed to stop pki port %d res=%d", 438 nic->port_id, ret); 439 return; 440 } 441 442 ret = octeontx_pko_channel_stop(nic->base_ochan); 443 if (ret < 0) { 444 octeontx_log_err("failed to stop channel %d VF%d %d %d", 445 nic->base_ochan, nic->port_id, nic->num_tx_queues, 446 ret); 447 return; 448 } 449 } 450 451 static int 452 octeontx_dev_promisc_enable(struct rte_eth_dev *dev) 453 { 454 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 455 456 PMD_INIT_FUNC_TRACE(); 457 return octeontx_port_promisc_set(nic, 1); 458 } 459 460 static int 461 octeontx_dev_promisc_disable(struct rte_eth_dev *dev) 462 { 463 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 464 465 PMD_INIT_FUNC_TRACE(); 466 return octeontx_port_promisc_set(nic, 0); 467 } 468 469 static int 470 octeontx_port_link_status(struct octeontx_nic *nic) 471 { 472 int res; 473 474 PMD_INIT_FUNC_TRACE(); 475 res = octeontx_bgx_port_link_status(nic->port_id); 476 if (res < 0) { 477 octeontx_log_err("failed to get port %d link status", 478 nic->port_id); 479 return res; 480 } 481 482 nic->link_up = (uint8_t)res; 483 octeontx_log_dbg("port %d link status %d", nic->port_id, nic->link_up); 484 485 return res; 486 } 487 488 /* 489 * Return 0 means link status changed, -1 means not changed 490 */ 491 static int 492 octeontx_dev_link_update(struct rte_eth_dev *dev, 493 int wait_to_complete __rte_unused) 494 { 495 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 496 struct rte_eth_link link; 497 int res; 498 499 PMD_INIT_FUNC_TRACE(); 500 501 res = octeontx_port_link_status(nic); 502 if (res < 0) { 503 octeontx_log_err("failed to request link status %d", res); 504 return res; 505 } 506 507 link.link_status = nic->link_up; 508 509 switch (nic->speed) { 510 case OCTEONTX_LINK_SPEED_SGMII: 511 link.link_speed = ETH_SPEED_NUM_1G; 512 break; 513 514 case OCTEONTX_LINK_SPEED_XAUI: 515 link.link_speed = ETH_SPEED_NUM_10G; 516 break; 517 518 case OCTEONTX_LINK_SPEED_RXAUI: 519 case OCTEONTX_LINK_SPEED_10G_R: 520 link.link_speed = ETH_SPEED_NUM_10G; 521 break; 522 case OCTEONTX_LINK_SPEED_QSGMII: 523 link.link_speed = ETH_SPEED_NUM_5G; 524 break; 525 case OCTEONTX_LINK_SPEED_40G_R: 526 link.link_speed = ETH_SPEED_NUM_40G; 527 break; 528 529 case OCTEONTX_LINK_SPEED_RESERVE1: 530 case OCTEONTX_LINK_SPEED_RESERVE2: 531 default: 532 link.link_speed = ETH_SPEED_NUM_NONE; 533 octeontx_log_err("incorrect link speed %d", nic->speed); 534 break; 535 } 536 537 link.link_duplex = ETH_LINK_FULL_DUPLEX; 538 link.link_autoneg = ETH_LINK_AUTONEG; 539 540 return rte_eth_linkstatus_set(dev, &link); 541 } 542 543 static int 544 octeontx_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) 545 { 546 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 547 548 PMD_INIT_FUNC_TRACE(); 549 return octeontx_port_stats(nic, stats); 550 } 551 552 static int 553 octeontx_dev_stats_reset(struct rte_eth_dev *dev) 554 { 555 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 556 557 PMD_INIT_FUNC_TRACE(); 558 return octeontx_port_stats_clr(nic); 559 } 560 561 static void 562 octeontx_dev_mac_addr_del(struct rte_eth_dev *dev, uint32_t index) 563 { 564 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 565 int ret; 566 567 ret = octeontx_bgx_port_mac_del(nic->port_id, index); 568 if (ret != 0) 569 octeontx_log_err("failed to del MAC address filter on port %d", 570 nic->port_id); 571 } 572 573 static int 574 octeontx_dev_mac_addr_add(struct rte_eth_dev *dev, 575 struct rte_ether_addr *mac_addr, 576 __rte_unused uint32_t index, 577 __rte_unused uint32_t vmdq) 578 { 579 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 580 int ret; 581 582 ret = octeontx_bgx_port_mac_add(nic->port_id, mac_addr->addr_bytes); 583 if (ret < 0) { 584 octeontx_log_err("failed to add MAC address filter on port %d", 585 nic->port_id); 586 return ret; 587 } 588 589 return 0; 590 } 591 592 static int 593 octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev, 594 struct rte_ether_addr *addr) 595 { 596 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 597 int ret; 598 599 ret = octeontx_bgx_port_mac_set(nic->port_id, addr->addr_bytes); 600 if (ret != 0) 601 octeontx_log_err("failed to set MAC address on port %d", 602 nic->port_id); 603 604 return ret; 605 } 606 607 static int 608 octeontx_dev_info(struct rte_eth_dev *dev, 609 struct rte_eth_dev_info *dev_info) 610 { 611 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 612 613 /* Autonegotiation may be disabled */ 614 dev_info->speed_capa = ETH_LINK_SPEED_FIXED; 615 dev_info->speed_capa |= ETH_LINK_SPEED_10M | ETH_LINK_SPEED_100M | 616 ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G | 617 ETH_LINK_SPEED_40G; 618 619 dev_info->max_mac_addrs = 620 octeontx_bgx_port_mac_entries_get(nic->port_id); 621 dev_info->max_rx_pktlen = PKI_MAX_PKTLEN; 622 dev_info->max_rx_queues = 1; 623 dev_info->max_tx_queues = PKO_MAX_NUM_DQ; 624 dev_info->min_rx_bufsize = 0; 625 626 dev_info->default_rxconf = (struct rte_eth_rxconf) { 627 .rx_free_thresh = 0, 628 .rx_drop_en = 0, 629 .offloads = OCTEONTX_RX_OFFLOADS, 630 }; 631 632 dev_info->default_txconf = (struct rte_eth_txconf) { 633 .tx_free_thresh = 0, 634 .offloads = OCTEONTX_TX_OFFLOADS, 635 }; 636 637 dev_info->rx_offload_capa = OCTEONTX_RX_OFFLOADS; 638 dev_info->tx_offload_capa = OCTEONTX_TX_OFFLOADS; 639 dev_info->rx_queue_offload_capa = OCTEONTX_RX_OFFLOADS; 640 dev_info->tx_queue_offload_capa = OCTEONTX_TX_OFFLOADS; 641 642 return 0; 643 } 644 645 static void 646 octeontx_dq_info_getter(octeontx_dq_t *dq, void *out) 647 { 648 ((octeontx_dq_t *)out)->lmtline_va = dq->lmtline_va; 649 ((octeontx_dq_t *)out)->ioreg_va = dq->ioreg_va; 650 ((octeontx_dq_t *)out)->fc_status_va = dq->fc_status_va; 651 } 652 653 static int 654 octeontx_vf_start_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic, 655 uint16_t qidx) 656 { 657 struct octeontx_txq *txq; 658 int res; 659 660 PMD_INIT_FUNC_TRACE(); 661 662 if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) 663 return 0; 664 665 txq = dev->data->tx_queues[qidx]; 666 667 res = octeontx_pko_channel_query_dqs(nic->base_ochan, 668 &txq->dq, 669 sizeof(octeontx_dq_t), 670 txq->queue_id, 671 octeontx_dq_info_getter); 672 if (res < 0) { 673 res = -EFAULT; 674 goto close_port; 675 } 676 677 dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED; 678 return res; 679 680 close_port: 681 (void)octeontx_port_stop(nic); 682 octeontx_pko_channel_stop(nic->base_ochan); 683 octeontx_pko_channel_close(nic->base_ochan); 684 dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED; 685 return res; 686 } 687 688 static int 689 octeontx_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx) 690 { 691 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 692 693 PMD_INIT_FUNC_TRACE(); 694 qidx = qidx % PKO_VF_NUM_DQ; 695 return octeontx_vf_start_tx_queue(dev, nic, qidx); 696 } 697 698 static inline int 699 octeontx_vf_stop_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic, 700 uint16_t qidx) 701 { 702 int ret = 0; 703 704 RTE_SET_USED(nic); 705 PMD_INIT_FUNC_TRACE(); 706 707 if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) 708 return 0; 709 710 dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED; 711 return ret; 712 } 713 714 static int 715 octeontx_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx) 716 { 717 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 718 719 PMD_INIT_FUNC_TRACE(); 720 qidx = qidx % PKO_VF_NUM_DQ; 721 722 return octeontx_vf_stop_tx_queue(dev, nic, qidx); 723 } 724 725 static void 726 octeontx_dev_tx_queue_release(void *tx_queue) 727 { 728 struct octeontx_txq *txq = tx_queue; 729 int res; 730 731 PMD_INIT_FUNC_TRACE(); 732 733 if (txq) { 734 res = octeontx_dev_tx_queue_stop(txq->eth_dev, txq->queue_id); 735 if (res < 0) 736 octeontx_log_err("failed stop tx_queue(%d)\n", 737 txq->queue_id); 738 739 rte_free(txq); 740 } 741 } 742 743 static int 744 octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, 745 uint16_t nb_desc, unsigned int socket_id, 746 const struct rte_eth_txconf *tx_conf __rte_unused) 747 { 748 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 749 struct octeontx_txq *txq = NULL; 750 uint16_t dq_num; 751 int res = 0; 752 753 RTE_SET_USED(nb_desc); 754 RTE_SET_USED(socket_id); 755 756 dq_num = (nic->pko_vfid * PKO_VF_NUM_DQ) + qidx; 757 758 /* Socket id check */ 759 if (socket_id != (unsigned int)SOCKET_ID_ANY && 760 socket_id != (unsigned int)nic->node) 761 PMD_TX_LOG(INFO, "socket_id expected %d, configured %d", 762 socket_id, nic->node); 763 764 /* Free memory prior to re-allocation if needed. */ 765 if (dev->data->tx_queues[qidx] != NULL) { 766 PMD_TX_LOG(DEBUG, "freeing memory prior to re-allocation %d", 767 qidx); 768 octeontx_dev_tx_queue_release(dev->data->tx_queues[qidx]); 769 dev->data->tx_queues[qidx] = NULL; 770 } 771 772 /* Allocating tx queue data structure */ 773 txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct octeontx_txq), 774 RTE_CACHE_LINE_SIZE, nic->node); 775 if (txq == NULL) { 776 octeontx_log_err("failed to allocate txq=%d", qidx); 777 res = -ENOMEM; 778 goto err; 779 } 780 781 txq->eth_dev = dev; 782 txq->queue_id = dq_num; 783 dev->data->tx_queues[qidx] = txq; 784 dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED; 785 786 res = octeontx_pko_channel_query_dqs(nic->base_ochan, 787 &txq->dq, 788 sizeof(octeontx_dq_t), 789 txq->queue_id, 790 octeontx_dq_info_getter); 791 if (res < 0) { 792 res = -EFAULT; 793 goto err; 794 } 795 796 PMD_TX_LOG(DEBUG, "[%d]:[%d] txq=%p nb_desc=%d lmtline=%p ioreg_va=%p fc_status_va=%p", 797 qidx, txq->queue_id, txq, nb_desc, txq->dq.lmtline_va, 798 txq->dq.ioreg_va, 799 txq->dq.fc_status_va); 800 801 return res; 802 803 err: 804 if (txq) 805 rte_free(txq); 806 807 return res; 808 } 809 810 static int 811 octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, 812 uint16_t nb_desc, unsigned int socket_id, 813 const struct rte_eth_rxconf *rx_conf, 814 struct rte_mempool *mb_pool) 815 { 816 struct octeontx_nic *nic = octeontx_pmd_priv(dev); 817 struct rte_mempool_ops *mp_ops = NULL; 818 struct octeontx_rxq *rxq = NULL; 819 pki_pktbuf_cfg_t pktbuf_conf; 820 pki_hash_cfg_t pki_hash; 821 pki_qos_cfg_t pki_qos; 822 uintptr_t pool; 823 int ret, port; 824 uint16_t gaura; 825 unsigned int ev_queues = (nic->ev_queues * nic->port_id) + qidx; 826 unsigned int ev_ports = (nic->ev_ports * nic->port_id) + qidx; 827 828 RTE_SET_USED(nb_desc); 829 830 memset(&pktbuf_conf, 0, sizeof(pktbuf_conf)); 831 memset(&pki_hash, 0, sizeof(pki_hash)); 832 memset(&pki_qos, 0, sizeof(pki_qos)); 833 834 mp_ops = rte_mempool_get_ops(mb_pool->ops_index); 835 if (strcmp(mp_ops->name, "octeontx_fpavf")) { 836 octeontx_log_err("failed to find octeontx_fpavf mempool"); 837 return -ENOTSUP; 838 } 839 840 /* Handle forbidden configurations */ 841 if (nic->pki.classifier_enable) { 842 octeontx_log_err("cannot setup queue %d. " 843 "Classifier option unsupported", qidx); 844 return -EINVAL; 845 } 846 847 port = nic->port_id; 848 849 /* Rx deferred start is not supported */ 850 if (rx_conf->rx_deferred_start) { 851 octeontx_log_err("rx deferred start not supported"); 852 return -EINVAL; 853 } 854 855 /* Verify queue index */ 856 if (qidx >= dev->data->nb_rx_queues) { 857 octeontx_log_err("QID %d not supporteded (0 - %d available)\n", 858 qidx, (dev->data->nb_rx_queues - 1)); 859 return -ENOTSUP; 860 } 861 862 /* Socket id check */ 863 if (socket_id != (unsigned int)SOCKET_ID_ANY && 864 socket_id != (unsigned int)nic->node) 865 PMD_RX_LOG(INFO, "socket_id expected %d, configured %d", 866 socket_id, nic->node); 867 868 /* Allocating rx queue data structure */ 869 rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct octeontx_rxq), 870 RTE_CACHE_LINE_SIZE, nic->node); 871 if (rxq == NULL) { 872 octeontx_log_err("failed to allocate rxq=%d", qidx); 873 return -ENOMEM; 874 } 875 876 if (!nic->pki.initialized) { 877 pktbuf_conf.port_type = 0; 878 pki_hash.port_type = 0; 879 pki_qos.port_type = 0; 880 881 pktbuf_conf.mmask.f_wqe_skip = 1; 882 pktbuf_conf.mmask.f_first_skip = 1; 883 pktbuf_conf.mmask.f_later_skip = 1; 884 pktbuf_conf.mmask.f_mbuff_size = 1; 885 pktbuf_conf.mmask.f_cache_mode = 1; 886 887 pktbuf_conf.wqe_skip = OCTTX_PACKET_WQE_SKIP; 888 pktbuf_conf.first_skip = OCTTX_PACKET_FIRST_SKIP(mb_pool); 889 pktbuf_conf.later_skip = OCTTX_PACKET_LATER_SKIP; 890 pktbuf_conf.mbuff_size = (mb_pool->elt_size - 891 RTE_PKTMBUF_HEADROOM - 892 rte_pktmbuf_priv_size(mb_pool) - 893 sizeof(struct rte_mbuf)); 894 895 pktbuf_conf.cache_mode = PKI_OPC_MODE_STF2_STT; 896 897 ret = octeontx_pki_port_pktbuf_config(port, &pktbuf_conf); 898 if (ret != 0) { 899 octeontx_log_err("fail to configure pktbuf for port %d", 900 port); 901 rte_free(rxq); 902 return ret; 903 } 904 PMD_RX_LOG(DEBUG, "Port %d Rx pktbuf configured:\n" 905 "\tmbuf_size:\t0x%0x\n" 906 "\twqe_skip:\t0x%0x\n" 907 "\tfirst_skip:\t0x%0x\n" 908 "\tlater_skip:\t0x%0x\n" 909 "\tcache_mode:\t%s\n", 910 port, 911 pktbuf_conf.mbuff_size, 912 pktbuf_conf.wqe_skip, 913 pktbuf_conf.first_skip, 914 pktbuf_conf.later_skip, 915 (pktbuf_conf.cache_mode == 916 PKI_OPC_MODE_STT) ? 917 "STT" : 918 (pktbuf_conf.cache_mode == 919 PKI_OPC_MODE_STF) ? 920 "STF" : 921 (pktbuf_conf.cache_mode == 922 PKI_OPC_MODE_STF1_STT) ? 923 "STF1_STT" : "STF2_STT"); 924 925 if (nic->pki.hash_enable) { 926 pki_hash.tag_dlc = 1; 927 pki_hash.tag_slc = 1; 928 pki_hash.tag_dlf = 1; 929 pki_hash.tag_slf = 1; 930 pki_hash.tag_prt = 1; 931 octeontx_pki_port_hash_config(port, &pki_hash); 932 } 933 934 pool = (uintptr_t)mb_pool->pool_id; 935 936 /* Get the gaura Id */ 937 gaura = octeontx_fpa_bufpool_gaura(pool); 938 939 pki_qos.qpg_qos = PKI_QPG_QOS_NONE; 940 pki_qos.num_entry = 1; 941 pki_qos.drop_policy = 0; 942 pki_qos.tag_type = 0L; 943 pki_qos.qos_entry[0].port_add = 0; 944 pki_qos.qos_entry[0].gaura = gaura; 945 pki_qos.qos_entry[0].ggrp_ok = ev_queues; 946 pki_qos.qos_entry[0].ggrp_bad = ev_queues; 947 pki_qos.qos_entry[0].grptag_bad = 0; 948 pki_qos.qos_entry[0].grptag_ok = 0; 949 950 ret = octeontx_pki_port_create_qos(port, &pki_qos); 951 if (ret < 0) { 952 octeontx_log_err("failed to create QOS port=%d, q=%d", 953 port, qidx); 954 rte_free(rxq); 955 return ret; 956 } 957 nic->pki.initialized = true; 958 } 959 960 rxq->port_id = nic->port_id; 961 rxq->eth_dev = dev; 962 rxq->queue_id = qidx; 963 rxq->evdev = nic->evdev; 964 rxq->ev_queues = ev_queues; 965 rxq->ev_ports = ev_ports; 966 967 dev->data->rx_queues[qidx] = rxq; 968 dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED; 969 return 0; 970 } 971 972 static void 973 octeontx_dev_rx_queue_release(void *rxq) 974 { 975 rte_free(rxq); 976 } 977 978 static const uint32_t * 979 octeontx_dev_supported_ptypes_get(struct rte_eth_dev *dev) 980 { 981 static const uint32_t ptypes[] = { 982 RTE_PTYPE_L3_IPV4, 983 RTE_PTYPE_L3_IPV4_EXT, 984 RTE_PTYPE_L3_IPV6, 985 RTE_PTYPE_L3_IPV6_EXT, 986 RTE_PTYPE_L4_TCP, 987 RTE_PTYPE_L4_UDP, 988 RTE_PTYPE_L4_FRAG, 989 RTE_PTYPE_UNKNOWN 990 }; 991 992 if (dev->rx_pkt_burst == octeontx_recv_pkts) 993 return ptypes; 994 995 return NULL; 996 } 997 998 static int 999 octeontx_pool_ops(struct rte_eth_dev *dev, const char *pool) 1000 { 1001 RTE_SET_USED(dev); 1002 1003 if (!strcmp(pool, "octeontx_fpavf")) 1004 return 0; 1005 1006 return -ENOTSUP; 1007 } 1008 1009 /* Initialize and register driver with DPDK Application */ 1010 static const struct eth_dev_ops octeontx_dev_ops = { 1011 .dev_configure = octeontx_dev_configure, 1012 .dev_infos_get = octeontx_dev_info, 1013 .dev_close = octeontx_dev_close, 1014 .dev_start = octeontx_dev_start, 1015 .dev_stop = octeontx_dev_stop, 1016 .promiscuous_enable = octeontx_dev_promisc_enable, 1017 .promiscuous_disable = octeontx_dev_promisc_disable, 1018 .link_update = octeontx_dev_link_update, 1019 .stats_get = octeontx_dev_stats_get, 1020 .stats_reset = octeontx_dev_stats_reset, 1021 .mac_addr_remove = octeontx_dev_mac_addr_del, 1022 .mac_addr_add = octeontx_dev_mac_addr_add, 1023 .mac_addr_set = octeontx_dev_default_mac_addr_set, 1024 .tx_queue_start = octeontx_dev_tx_queue_start, 1025 .tx_queue_stop = octeontx_dev_tx_queue_stop, 1026 .tx_queue_setup = octeontx_dev_tx_queue_setup, 1027 .tx_queue_release = octeontx_dev_tx_queue_release, 1028 .rx_queue_setup = octeontx_dev_rx_queue_setup, 1029 .rx_queue_release = octeontx_dev_rx_queue_release, 1030 .dev_supported_ptypes_get = octeontx_dev_supported_ptypes_get, 1031 .pool_ops_supported = octeontx_pool_ops, 1032 }; 1033 1034 /* Create Ethdev interface per BGX LMAC ports */ 1035 static int 1036 octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, 1037 int socket_id) 1038 { 1039 int res; 1040 size_t pko_vfid; 1041 char octtx_name[OCTEONTX_MAX_NAME_LEN]; 1042 struct octeontx_nic *nic = NULL; 1043 struct rte_eth_dev *eth_dev = NULL; 1044 struct rte_eth_dev_data *data; 1045 const char *name = rte_vdev_device_name(dev); 1046 int max_entries; 1047 1048 PMD_INIT_FUNC_TRACE(); 1049 1050 sprintf(octtx_name, "%s_%d", name, port); 1051 if (rte_eal_process_type() != RTE_PROC_PRIMARY) { 1052 eth_dev = rte_eth_dev_attach_secondary(octtx_name); 1053 if (eth_dev == NULL) 1054 return -ENODEV; 1055 1056 eth_dev->dev_ops = &octeontx_dev_ops; 1057 eth_dev->device = &dev->device; 1058 eth_dev->tx_pkt_burst = octeontx_xmit_pkts; 1059 eth_dev->rx_pkt_burst = octeontx_recv_pkts; 1060 rte_eth_dev_probing_finish(eth_dev); 1061 return 0; 1062 } 1063 1064 /* Reserve an ethdev entry */ 1065 eth_dev = rte_eth_dev_allocate(octtx_name); 1066 if (eth_dev == NULL) { 1067 octeontx_log_err("failed to allocate rte_eth_dev"); 1068 res = -ENOMEM; 1069 goto err; 1070 } 1071 data = eth_dev->data; 1072 1073 nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id); 1074 if (nic == NULL) { 1075 octeontx_log_err("failed to allocate nic structure"); 1076 res = -ENOMEM; 1077 goto err; 1078 } 1079 data->dev_private = nic; 1080 pko_vfid = octeontx_pko_get_vfid(); 1081 1082 if (pko_vfid == SIZE_MAX) { 1083 octeontx_log_err("failed to get pko vfid"); 1084 res = -ENODEV; 1085 goto err; 1086 } 1087 1088 nic->pko_vfid = pko_vfid; 1089 nic->port_id = port; 1090 nic->evdev = evdev; 1091 1092 res = octeontx_port_open(nic); 1093 if (res < 0) 1094 goto err; 1095 1096 /* Rx side port configuration */ 1097 res = octeontx_pki_port_open(port); 1098 if (res != 0) { 1099 octeontx_log_err("failed to open PKI port %d", port); 1100 res = -ENODEV; 1101 goto err; 1102 } 1103 1104 eth_dev->device = &dev->device; 1105 eth_dev->intr_handle = NULL; 1106 eth_dev->data->kdrv = RTE_KDRV_NONE; 1107 eth_dev->data->numa_node = dev->device.numa_node; 1108 1109 data->port_id = eth_dev->data->port_id; 1110 1111 nic->ev_queues = 1; 1112 nic->ev_ports = 1; 1113 1114 data->dev_link.link_status = ETH_LINK_DOWN; 1115 data->dev_started = 0; 1116 data->promiscuous = 0; 1117 data->all_multicast = 0; 1118 data->scattered_rx = 0; 1119 1120 /* Get maximum number of supported MAC entries */ 1121 max_entries = octeontx_bgx_port_mac_entries_get(nic->port_id); 1122 if (max_entries < 0) { 1123 octeontx_log_err("Failed to get max entries for mac addr"); 1124 res = -ENOTSUP; 1125 goto err; 1126 } 1127 1128 data->mac_addrs = rte_zmalloc_socket(octtx_name, max_entries * 1129 RTE_ETHER_ADDR_LEN, 0, 1130 socket_id); 1131 if (data->mac_addrs == NULL) { 1132 octeontx_log_err("failed to allocate memory for mac_addrs"); 1133 res = -ENOMEM; 1134 goto err; 1135 } 1136 1137 eth_dev->dev_ops = &octeontx_dev_ops; 1138 1139 /* Finally save ethdev pointer to the NIC structure */ 1140 nic->dev = eth_dev; 1141 1142 if (nic->port_id != data->port_id) { 1143 octeontx_log_err("eth_dev->port_id (%d) is diff to orig (%d)", 1144 data->port_id, nic->port_id); 1145 res = -EINVAL; 1146 goto err; 1147 } 1148 1149 /* Update port_id mac to eth_dev */ 1150 memcpy(data->mac_addrs, nic->mac_addr, RTE_ETHER_ADDR_LEN); 1151 1152 PMD_INIT_LOG(DEBUG, "ethdev info: "); 1153 PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d", 1154 nic->port_id, nic->port_ena, 1155 nic->base_ochan, nic->num_ochans, 1156 nic->num_tx_queues); 1157 PMD_INIT_LOG(DEBUG, "speed %d mtu %d", nic->speed, nic->mtu); 1158 1159 rte_octeontx_pchan_map[(nic->base_ochan >> 8) & 0x7] 1160 [(nic->base_ochan >> 4) & 0xF] = data->port_id; 1161 1162 rte_eth_dev_probing_finish(eth_dev); 1163 return data->port_id; 1164 1165 err: 1166 if (nic) 1167 octeontx_port_close(nic); 1168 1169 rte_eth_dev_release_port(eth_dev); 1170 1171 return res; 1172 } 1173 1174 /* Un initialize octeontx device */ 1175 static int 1176 octeontx_remove(struct rte_vdev_device *dev) 1177 { 1178 char octtx_name[OCTEONTX_MAX_NAME_LEN]; 1179 struct rte_eth_dev *eth_dev = NULL; 1180 struct octeontx_nic *nic = NULL; 1181 int i; 1182 1183 if (dev == NULL) 1184 return -EINVAL; 1185 1186 for (i = 0; i < OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT; i++) { 1187 sprintf(octtx_name, "eth_octeontx_%d", i); 1188 1189 /* reserve an ethdev entry */ 1190 eth_dev = rte_eth_dev_allocated(octtx_name); 1191 if (eth_dev == NULL) 1192 return -ENODEV; 1193 1194 if (rte_eal_process_type() != RTE_PROC_PRIMARY) { 1195 rte_eth_dev_release_port(eth_dev); 1196 continue; 1197 } 1198 1199 nic = octeontx_pmd_priv(eth_dev); 1200 rte_event_dev_stop(nic->evdev); 1201 PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name); 1202 1203 rte_eth_dev_release_port(eth_dev); 1204 rte_event_dev_close(nic->evdev); 1205 } 1206 1207 if (rte_eal_process_type() != RTE_PROC_PRIMARY) 1208 return 0; 1209 1210 /* Free FC resource */ 1211 octeontx_pko_fc_free(); 1212 1213 return 0; 1214 } 1215 1216 /* Initialize octeontx device */ 1217 static int 1218 octeontx_probe(struct rte_vdev_device *dev) 1219 { 1220 const char *dev_name; 1221 static int probe_once; 1222 uint8_t socket_id, qlist; 1223 int tx_vfcnt, port_id, evdev, qnum, pnum, res, i; 1224 struct rte_event_dev_config dev_conf; 1225 const char *eventdev_name = "event_octeontx"; 1226 struct rte_event_dev_info info; 1227 struct rte_eth_dev *eth_dev; 1228 1229 struct octeontx_vdev_init_params init_params = { 1230 OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT 1231 }; 1232 1233 dev_name = rte_vdev_device_name(dev); 1234 1235 if (rte_eal_process_type() == RTE_PROC_SECONDARY && 1236 strlen(rte_vdev_device_args(dev)) == 0) { 1237 eth_dev = rte_eth_dev_attach_secondary(dev_name); 1238 if (!eth_dev) { 1239 PMD_INIT_LOG(ERR, "Failed to probe %s", dev_name); 1240 return -1; 1241 } 1242 /* TODO: request info from primary to set up Rx and Tx */ 1243 eth_dev->dev_ops = &octeontx_dev_ops; 1244 eth_dev->device = &dev->device; 1245 rte_eth_dev_probing_finish(eth_dev); 1246 return 0; 1247 } 1248 1249 res = octeontx_parse_vdev_init_params(&init_params, dev); 1250 if (res < 0) 1251 return -EINVAL; 1252 1253 if (init_params.nr_port > OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT) { 1254 octeontx_log_err("nr_port (%d) > max (%d)", init_params.nr_port, 1255 OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT); 1256 return -ENOTSUP; 1257 } 1258 1259 PMD_INIT_LOG(DEBUG, "initializing %s pmd", dev_name); 1260 1261 socket_id = rte_socket_id(); 1262 1263 tx_vfcnt = octeontx_pko_vf_count(); 1264 1265 if (tx_vfcnt < init_params.nr_port) { 1266 octeontx_log_err("not enough PKO (%d) for port number (%d)", 1267 tx_vfcnt, init_params.nr_port); 1268 return -EINVAL; 1269 } 1270 evdev = rte_event_dev_get_dev_id(eventdev_name); 1271 if (evdev < 0) { 1272 octeontx_log_err("eventdev %s not found", eventdev_name); 1273 return -ENODEV; 1274 } 1275 1276 res = rte_event_dev_info_get(evdev, &info); 1277 if (res < 0) { 1278 octeontx_log_err("failed to eventdev info %d", res); 1279 return -EINVAL; 1280 } 1281 1282 PMD_INIT_LOG(DEBUG, "max_queue %d max_port %d", 1283 info.max_event_queues, info.max_event_ports); 1284 1285 if (octeontx_pko_init_fc(tx_vfcnt)) 1286 return -ENOMEM; 1287 1288 devconf_set_default_sane_values(&dev_conf, &info); 1289 res = rte_event_dev_configure(evdev, &dev_conf); 1290 if (res < 0) 1291 goto parse_error; 1292 1293 rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_PORT_COUNT, 1294 (uint32_t *)&pnum); 1295 rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_QUEUE_COUNT, 1296 (uint32_t *)&qnum); 1297 if (pnum < qnum) { 1298 octeontx_log_err("too few event ports (%d) for event_q(%d)", 1299 pnum, qnum); 1300 res = -EINVAL; 1301 goto parse_error; 1302 } 1303 1304 /* Enable all queues available */ 1305 for (i = 0; i < qnum; i++) { 1306 res = rte_event_queue_setup(evdev, i, NULL); 1307 if (res < 0) { 1308 octeontx_log_err("failed to setup event_q(%d): res %d", 1309 i, res); 1310 goto parse_error; 1311 } 1312 } 1313 1314 /* Enable all ports available */ 1315 for (i = 0; i < pnum; i++) { 1316 res = rte_event_port_setup(evdev, i, NULL); 1317 if (res < 0) { 1318 res = -ENODEV; 1319 octeontx_log_err("failed to setup ev port(%d) res=%d", 1320 i, res); 1321 goto parse_error; 1322 } 1323 } 1324 1325 /* 1326 * Do 1:1 links for ports & queues. All queues would be mapped to 1327 * one port. If there are more ports than queues, then some ports 1328 * won't be linked to any queue. 1329 */ 1330 for (i = 0; i < qnum; i++) { 1331 /* Link one queue to one event port */ 1332 qlist = i; 1333 res = rte_event_port_link(evdev, i, &qlist, NULL, 1); 1334 if (res < 0) { 1335 res = -ENODEV; 1336 octeontx_log_err("failed to link port (%d): res=%d", 1337 i, res); 1338 goto parse_error; 1339 } 1340 } 1341 1342 /* Create ethdev interface */ 1343 for (i = 0; i < init_params.nr_port; i++) { 1344 port_id = octeontx_create(dev, i, evdev, socket_id); 1345 if (port_id < 0) { 1346 octeontx_log_err("failed to create device %s", 1347 dev_name); 1348 res = -ENODEV; 1349 goto parse_error; 1350 } 1351 1352 PMD_INIT_LOG(INFO, "created ethdev %s for port %d", dev_name, 1353 port_id); 1354 } 1355 1356 if (probe_once) { 1357 octeontx_log_err("interface %s not supported", dev_name); 1358 octeontx_remove(dev); 1359 res = -ENOTSUP; 1360 goto parse_error; 1361 } 1362 rte_mbuf_set_platform_mempool_ops("octeontx_fpavf"); 1363 probe_once = 1; 1364 1365 return 0; 1366 1367 parse_error: 1368 octeontx_pko_fc_free(); 1369 return res; 1370 } 1371 1372 static struct rte_vdev_driver octeontx_pmd_drv = { 1373 .probe = octeontx_probe, 1374 .remove = octeontx_remove, 1375 }; 1376 1377 RTE_PMD_REGISTER_VDEV(OCTEONTX_PMD, octeontx_pmd_drv); 1378 RTE_PMD_REGISTER_ALIAS(OCTEONTX_PMD, eth_octeontx); 1379 RTE_PMD_REGISTER_PARAM_STRING(OCTEONTX_PMD, "nr_port=<int> "); 1380