1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
12 #include <rte_alarm.h>
13 #include <rte_branch_prediction.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_cycles.h>
16 #include <rte_debug.h>
17 #include <rte_devargs.h>
19 #include <rte_kvargs.h>
20 #include <rte_malloc.h>
21 #include <rte_mbuf_pool_ops.h>
22 #include <rte_prefetch.h>
24 #include "octeontx_ethdev.h"
25 #include "octeontx_rxtx.h"
26 #include "octeontx_logs.h"
28 struct evdev_priv_data {
29 OFFLOAD_FLAGS; /*Sequence should not be changed */
30 } __rte_cache_aligned;
32 struct octeontx_vdev_init_params {
37 rte_octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX];
39 enum octeontx_link_speed {
40 OCTEONTX_LINK_SPEED_SGMII,
41 OCTEONTX_LINK_SPEED_XAUI,
42 OCTEONTX_LINK_SPEED_RXAUI,
43 OCTEONTX_LINK_SPEED_10G_R,
44 OCTEONTX_LINK_SPEED_40G_R,
45 OCTEONTX_LINK_SPEED_RESERVE1,
46 OCTEONTX_LINK_SPEED_QSGMII,
47 OCTEONTX_LINK_SPEED_RESERVE2
50 RTE_LOG_REGISTER(otx_net_logtype_mbox, pmd.net.octeontx.mbox, NOTICE);
51 RTE_LOG_REGISTER(otx_net_logtype_init, pmd.net.octeontx.init, NOTICE);
52 RTE_LOG_REGISTER(otx_net_logtype_driver, pmd.net.octeontx.driver, NOTICE);
54 /* Parse integer from integer argument */
56 parse_integer_arg(const char *key __rte_unused,
57 const char *value, void *extra_args)
59 int *i = (int *)extra_args;
63 octeontx_log_err("argument has to be positive.");
71 octeontx_parse_vdev_init_params(struct octeontx_vdev_init_params *params,
72 struct rte_vdev_device *dev)
74 struct rte_kvargs *kvlist = NULL;
77 static const char * const octeontx_vdev_valid_params[] = {
78 OCTEONTX_VDEV_NR_PORT_ARG,
82 const char *input_args = rte_vdev_device_args(dev);
88 kvlist = rte_kvargs_parse(input_args,
89 octeontx_vdev_valid_params);
93 ret = rte_kvargs_process(kvlist,
94 OCTEONTX_VDEV_NR_PORT_ARG,
102 rte_kvargs_free(kvlist);
107 octeontx_port_open(struct octeontx_nic *nic)
109 octeontx_mbox_bgx_port_conf_t bgx_port_conf;
110 octeontx_mbox_bgx_port_fifo_cfg_t fifo_cfg;
114 memset(&bgx_port_conf, 0x0, sizeof(bgx_port_conf));
115 PMD_INIT_FUNC_TRACE();
117 res = octeontx_bgx_port_open(nic->port_id, &bgx_port_conf);
119 octeontx_log_err("failed to open port %d", res);
123 nic->node = bgx_port_conf.node;
124 nic->port_ena = bgx_port_conf.enable;
125 nic->base_ichan = bgx_port_conf.base_chan;
126 nic->base_ochan = bgx_port_conf.base_chan;
127 nic->num_ichans = bgx_port_conf.num_chans;
128 nic->num_ochans = bgx_port_conf.num_chans;
129 nic->bgx_mtu = bgx_port_conf.mtu;
130 nic->bpen = bgx_port_conf.bpen;
131 nic->fcs_strip = bgx_port_conf.fcs_strip;
132 nic->bcast_mode = bgx_port_conf.bcast_mode;
133 nic->mcast_mode = bgx_port_conf.mcast_mode;
134 nic->speed = bgx_port_conf.mode;
136 memset(&fifo_cfg, 0x0, sizeof(fifo_cfg));
138 res = octeontx_bgx_port_get_fifo_cfg(nic->port_id, &fifo_cfg);
140 octeontx_log_err("failed to get port %d fifo cfg", res);
144 nic->fc.rx_fifosz = fifo_cfg.rx_fifosz;
146 memcpy(&nic->mac_addr[0], &bgx_port_conf.macaddr[0],
149 octeontx_log_dbg("port opened %d", nic->port_id);
154 octeontx_link_status_print(struct rte_eth_dev *eth_dev,
155 struct rte_eth_link *link)
157 if (link && link->link_status)
158 octeontx_log_info("Port %u: Link Up - speed %u Mbps - %s",
159 (eth_dev->data->port_id),
161 link->link_duplex == ETH_LINK_FULL_DUPLEX ?
162 "full-duplex" : "half-duplex");
164 octeontx_log_info("Port %d: Link Down",
165 (int)(eth_dev->data->port_id));
169 octeontx_link_status_update(struct octeontx_nic *nic,
170 struct rte_eth_link *link)
172 memset(link, 0, sizeof(*link));
174 link->link_status = nic->link_up ? ETH_LINK_UP : ETH_LINK_DOWN;
176 switch (nic->speed) {
177 case OCTEONTX_LINK_SPEED_SGMII:
178 link->link_speed = ETH_SPEED_NUM_1G;
181 case OCTEONTX_LINK_SPEED_XAUI:
182 link->link_speed = ETH_SPEED_NUM_10G;
185 case OCTEONTX_LINK_SPEED_RXAUI:
186 case OCTEONTX_LINK_SPEED_10G_R:
187 link->link_speed = ETH_SPEED_NUM_10G;
189 case OCTEONTX_LINK_SPEED_QSGMII:
190 link->link_speed = ETH_SPEED_NUM_5G;
192 case OCTEONTX_LINK_SPEED_40G_R:
193 link->link_speed = ETH_SPEED_NUM_40G;
196 case OCTEONTX_LINK_SPEED_RESERVE1:
197 case OCTEONTX_LINK_SPEED_RESERVE2:
199 link->link_speed = ETH_SPEED_NUM_NONE;
200 octeontx_log_err("incorrect link speed %d", nic->speed);
204 link->link_duplex = ETH_LINK_FULL_DUPLEX;
205 link->link_autoneg = ETH_LINK_AUTONEG;
209 octeontx_link_status_poll(void *arg)
211 struct octeontx_nic *nic = arg;
212 struct rte_eth_link link;
213 struct rte_eth_dev *dev;
216 PMD_INIT_FUNC_TRACE();
220 res = octeontx_bgx_port_link_status(nic->port_id);
222 octeontx_log_err("Failed to get port %d link status",
225 if (nic->link_up != (uint8_t)res) {
226 nic->link_up = (uint8_t)res;
227 octeontx_link_status_update(nic, &link);
228 octeontx_link_status_print(dev, &link);
229 rte_eth_linkstatus_set(dev, &link);
230 _rte_eth_dev_callback_process(dev,
231 RTE_ETH_EVENT_INTR_LSC,
236 res = rte_eal_alarm_set(OCCTX_INTR_POLL_INTERVAL_MS * 1000,
237 octeontx_link_status_poll, nic);
239 octeontx_log_err("Failed to restart alarm for port %d, err: %d",
244 octeontx_port_close(struct octeontx_nic *nic)
246 PMD_INIT_FUNC_TRACE();
248 rte_eal_alarm_cancel(octeontx_link_status_poll, nic);
249 octeontx_bgx_port_close(nic->port_id);
250 octeontx_log_dbg("port closed %d", nic->port_id);
254 octeontx_port_start(struct octeontx_nic *nic)
256 PMD_INIT_FUNC_TRACE();
258 return octeontx_bgx_port_start(nic->port_id);
262 octeontx_port_stop(struct octeontx_nic *nic)
264 PMD_INIT_FUNC_TRACE();
266 return octeontx_bgx_port_stop(nic->port_id);
270 octeontx_port_promisc_set(struct octeontx_nic *nic, int en)
272 struct rte_eth_dev *dev;
276 PMD_INIT_FUNC_TRACE();
279 res = octeontx_bgx_port_promisc_set(nic->port_id, en);
281 octeontx_log_err("failed to set promiscuous mode %d",
286 /* Set proper flag for the mode */
287 dev->data->promiscuous = (en != 0) ? 1 : 0;
289 octeontx_log_dbg("port %d : promiscuous mode %s",
290 nic->port_id, en ? "set" : "unset");
296 octeontx_port_stats(struct octeontx_nic *nic, struct rte_eth_stats *stats)
298 octeontx_mbox_bgx_port_stats_t bgx_stats;
301 PMD_INIT_FUNC_TRACE();
303 res = octeontx_bgx_port_stats(nic->port_id, &bgx_stats);
305 octeontx_log_err("failed to get port stats %d", nic->port_id);
309 stats->ipackets = bgx_stats.rx_packets;
310 stats->ibytes = bgx_stats.rx_bytes;
311 stats->imissed = bgx_stats.rx_dropped;
312 stats->ierrors = bgx_stats.rx_errors;
313 stats->opackets = bgx_stats.tx_packets;
314 stats->obytes = bgx_stats.tx_bytes;
315 stats->oerrors = bgx_stats.tx_errors;
317 octeontx_log_dbg("port%d stats inpkts=%" PRIx64 " outpkts=%" PRIx64 "",
318 nic->port_id, stats->ipackets, stats->opackets);
324 octeontx_port_stats_clr(struct octeontx_nic *nic)
326 PMD_INIT_FUNC_TRACE();
328 return octeontx_bgx_port_stats_clr(nic->port_id);
332 devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf,
333 struct rte_event_dev_info *info)
335 memset(dev_conf, 0, sizeof(struct rte_event_dev_config));
336 dev_conf->dequeue_timeout_ns = info->min_dequeue_timeout_ns;
338 dev_conf->nb_event_ports = info->max_event_ports;
339 dev_conf->nb_event_queues = info->max_event_queues;
341 dev_conf->nb_event_queue_flows = info->max_event_queue_flows;
342 dev_conf->nb_event_port_dequeue_depth =
343 info->max_event_port_dequeue_depth;
344 dev_conf->nb_event_port_enqueue_depth =
345 info->max_event_port_enqueue_depth;
346 dev_conf->nb_event_port_enqueue_depth =
347 info->max_event_port_enqueue_depth;
348 dev_conf->nb_events_limit =
349 info->max_num_events;
353 octeontx_tx_offload_flags(struct rte_eth_dev *eth_dev)
355 struct octeontx_nic *nic = octeontx_pmd_priv(eth_dev);
358 if (nic->tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM ||
359 nic->tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
360 flags |= OCCTX_TX_OFFLOAD_OL3_OL4_CSUM_F;
362 if (nic->tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM ||
363 nic->tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM ||
364 nic->tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM ||
365 nic->tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM)
366 flags |= OCCTX_TX_OFFLOAD_L3_L4_CSUM_F;
368 if (!(nic->tx_offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE))
369 flags |= OCCTX_TX_OFFLOAD_MBUF_NOFF_F;
371 if (nic->tx_offloads & DEV_TX_OFFLOAD_MULTI_SEGS)
372 flags |= OCCTX_TX_MULTI_SEG_F;
378 octeontx_rx_offload_flags(struct rte_eth_dev *eth_dev)
380 struct octeontx_nic *nic = octeontx_pmd_priv(eth_dev);
383 if (nic->rx_offloads & (DEV_RX_OFFLOAD_TCP_CKSUM |
384 DEV_RX_OFFLOAD_UDP_CKSUM))
385 flags |= OCCTX_RX_OFFLOAD_CSUM_F;
387 if (nic->rx_offloads & (DEV_RX_OFFLOAD_IPV4_CKSUM |
388 DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM))
389 flags |= OCCTX_RX_OFFLOAD_CSUM_F;
391 if (nic->rx_offloads & DEV_RX_OFFLOAD_SCATTER) {
392 flags |= OCCTX_RX_MULTI_SEG_F;
393 eth_dev->data->scattered_rx = 1;
394 /* If scatter mode is enabled, TX should also be in multi
395 * seg mode, else memory leak will occur
397 nic->tx_offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
404 octeontx_dev_configure(struct rte_eth_dev *dev)
406 struct rte_eth_dev_data *data = dev->data;
407 struct rte_eth_conf *conf = &data->dev_conf;
408 struct rte_eth_rxmode *rxmode = &conf->rxmode;
409 struct rte_eth_txmode *txmode = &conf->txmode;
410 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
413 PMD_INIT_FUNC_TRACE();
416 if (!rte_eal_has_hugepages()) {
417 octeontx_log_err("huge page is not configured");
421 if (txmode->mq_mode) {
422 octeontx_log_err("tx mq_mode DCB or VMDq not supported");
426 if (rxmode->mq_mode != ETH_MQ_RX_NONE &&
427 rxmode->mq_mode != ETH_MQ_RX_RSS) {
428 octeontx_log_err("unsupported rx qmode %d", rxmode->mq_mode);
432 if (!(txmode->offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) {
433 PMD_INIT_LOG(NOTICE, "cant disable lockfree tx");
434 txmode->offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE;
437 if (conf->link_speeds & ETH_LINK_SPEED_FIXED) {
438 octeontx_log_err("setting link speed/duplex not supported");
442 if (conf->dcb_capability_en) {
443 octeontx_log_err("DCB enable not supported");
447 if (conf->fdir_conf.mode != RTE_FDIR_MODE_NONE) {
448 octeontx_log_err("flow director not supported");
452 nic->num_tx_queues = dev->data->nb_tx_queues;
454 ret = octeontx_pko_channel_open(nic->pko_vfid * PKO_VF_NUM_DQ,
458 octeontx_log_err("failed to open channel %d no-of-txq %d",
459 nic->base_ochan, nic->num_tx_queues);
463 ret = octeontx_dev_vlan_offload_init(dev);
465 octeontx_log_err("failed to initialize vlan offload");
469 nic->pki.classifier_enable = false;
470 nic->pki.hash_enable = true;
471 nic->pki.initialized = false;
473 nic->rx_offloads |= rxmode->offloads;
474 nic->tx_offloads |= txmode->offloads;
475 nic->rx_offload_flags |= octeontx_rx_offload_flags(dev);
476 nic->tx_offload_flags |= octeontx_tx_offload_flags(dev);
482 octeontx_dev_close(struct rte_eth_dev *dev)
484 struct octeontx_txq *txq = NULL;
485 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
489 PMD_INIT_FUNC_TRACE();
491 rte_event_dev_close(nic->evdev);
493 octeontx_dev_flow_ctrl_fini(dev);
495 octeontx_dev_vlan_offload_fini(dev);
497 ret = octeontx_pko_channel_close(nic->base_ochan);
499 octeontx_log_err("failed to close channel %d VF%d %d %d",
500 nic->base_ochan, nic->port_id, nic->num_tx_queues,
503 /* Free txq resources for this port */
504 for (i = 0; i < nic->num_tx_queues; i++) {
505 txq = dev->data->tx_queues[i];
512 /* Free MAC address table */
513 rte_free(dev->data->mac_addrs);
514 dev->data->mac_addrs = NULL;
516 octeontx_port_close(nic);
518 dev->tx_pkt_burst = NULL;
519 dev->rx_pkt_burst = NULL;
523 octeontx_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
525 uint32_t buffsz, frame_size = mtu + OCCTX_L2_OVERHEAD;
526 struct octeontx_nic *nic = octeontx_pmd_priv(eth_dev);
527 struct rte_eth_dev_data *data = eth_dev->data;
530 /* Check if MTU is within the allowed range */
531 if (frame_size < OCCTX_MIN_FRS || frame_size > OCCTX_MAX_FRS)
534 buffsz = data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM;
536 /* Refuse MTU that requires the support of scattered packets
537 * when this feature has not been enabled before.
539 if (data->dev_started && frame_size > buffsz &&
540 !(nic->rx_offloads & DEV_RX_OFFLOAD_SCATTER)) {
541 octeontx_log_err("Scatter mode is disabled");
545 /* Check <seg size> * <max_seg> >= max_frame */
546 if ((nic->rx_offloads & DEV_RX_OFFLOAD_SCATTER) &&
547 (frame_size > buffsz * OCCTX_RX_NB_SEG_MAX))
550 rc = octeontx_pko_send_mtu(nic->port_id, frame_size);
554 rc = octeontx_bgx_port_mtu_set(nic->port_id, frame_size);
558 if (frame_size > RTE_ETHER_MAX_LEN)
559 nic->rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
561 nic->rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
563 /* Update max_rx_pkt_len */
564 data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
565 octeontx_log_info("Received pkt beyond maxlen %d will be dropped",
572 octeontx_recheck_rx_offloads(struct octeontx_rxq *rxq)
574 struct rte_eth_dev *eth_dev = rxq->eth_dev;
575 struct octeontx_nic *nic = octeontx_pmd_priv(eth_dev);
576 struct rte_eth_dev_data *data = eth_dev->data;
577 struct rte_pktmbuf_pool_private *mbp_priv;
578 struct evdev_priv_data *evdev_priv;
579 struct rte_eventdev *dev;
582 /* Get rx buffer size */
583 mbp_priv = rte_mempool_get_priv(rxq->pool);
584 buffsz = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
586 /* Setup scatter mode if needed by jumbo */
587 if (data->dev_conf.rxmode.max_rx_pkt_len > buffsz) {
588 nic->rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
589 nic->rx_offload_flags |= octeontx_rx_offload_flags(eth_dev);
590 nic->tx_offload_flags |= octeontx_tx_offload_flags(eth_dev);
593 /* Sharing offload flags via eventdev priv region */
594 dev = &rte_eventdevs[rxq->evdev];
595 evdev_priv = dev->data->dev_private;
596 evdev_priv->rx_offload_flags = nic->rx_offload_flags;
597 evdev_priv->tx_offload_flags = nic->tx_offload_flags;
599 /* Setup MTU based on max_rx_pkt_len */
600 nic->mtu = data->dev_conf.rxmode.max_rx_pkt_len - OCCTX_L2_OVERHEAD;
606 octeontx_dev_start(struct rte_eth_dev *dev)
608 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
609 struct octeontx_rxq *rxq;
612 PMD_INIT_FUNC_TRACE();
613 /* Rechecking if any new offload set to update
614 * rx/tx burst function pointer accordingly.
616 for (i = 0; i < dev->data->nb_rx_queues; i++) {
617 rxq = dev->data->rx_queues[i];
618 octeontx_recheck_rx_offloads(rxq);
621 /* Setting up the mtu based on max_rx_pkt_len */
622 ret = octeontx_dev_mtu_set(dev, nic->mtu);
624 octeontx_log_err("Failed to set default MTU size %d", ret);
631 octeontx_set_tx_function(dev);
632 ret = octeontx_pko_channel_start(nic->base_ochan);
634 octeontx_log_err("fail to conf VF%d no. txq %d chan %d ret %d",
635 nic->port_id, nic->num_tx_queues, nic->base_ochan,
643 dev->rx_pkt_burst = octeontx_recv_pkts;
644 ret = octeontx_pki_port_start(nic->port_id);
646 octeontx_log_err("fail to start Rx on port %d", nic->port_id);
647 goto channel_stop_error;
653 ret = octeontx_port_start(nic);
655 octeontx_log_err("failed start port %d", ret);
656 goto pki_port_stop_error;
659 PMD_TX_LOG(DEBUG, "pko: start channel %d no.of txq %d port %d",
660 nic->base_ochan, nic->num_tx_queues, nic->port_id);
662 ret = rte_event_dev_start(nic->evdev);
664 octeontx_log_err("failed to start evdev: ret (%d)", ret);
665 goto pki_port_stop_error;
672 octeontx_pki_port_stop(nic->port_id);
674 octeontx_pko_channel_stop(nic->base_ochan);
680 octeontx_dev_stop(struct rte_eth_dev *dev)
682 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
685 PMD_INIT_FUNC_TRACE();
687 rte_event_dev_stop(nic->evdev);
689 ret = octeontx_port_stop(nic);
691 octeontx_log_err("failed to req stop port %d res=%d",
696 ret = octeontx_pki_port_stop(nic->port_id);
698 octeontx_log_err("failed to stop pki port %d res=%d",
703 ret = octeontx_pko_channel_stop(nic->base_ochan);
705 octeontx_log_err("failed to stop channel %d VF%d %d %d",
706 nic->base_ochan, nic->port_id, nic->num_tx_queues,
713 octeontx_dev_promisc_enable(struct rte_eth_dev *dev)
715 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
717 PMD_INIT_FUNC_TRACE();
718 return octeontx_port_promisc_set(nic, 1);
722 octeontx_dev_promisc_disable(struct rte_eth_dev *dev)
724 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
726 PMD_INIT_FUNC_TRACE();
727 return octeontx_port_promisc_set(nic, 0);
731 octeontx_port_link_status(struct octeontx_nic *nic)
735 PMD_INIT_FUNC_TRACE();
736 res = octeontx_bgx_port_link_status(nic->port_id);
738 octeontx_log_err("failed to get port %d link status",
743 if (nic->link_up != (uint8_t)res || nic->print_flag == -1) {
744 nic->link_up = (uint8_t)res;
747 octeontx_log_dbg("port %d link status %d", nic->port_id, nic->link_up);
753 * Return 0 means link status changed, -1 means not changed
756 octeontx_dev_link_update(struct rte_eth_dev *dev,
757 int wait_to_complete __rte_unused)
759 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
760 struct rte_eth_link link;
763 PMD_INIT_FUNC_TRACE();
765 res = octeontx_port_link_status(nic);
767 octeontx_log_err("failed to request link status %d", res);
771 octeontx_link_status_update(nic, &link);
772 if (nic->print_flag) {
773 octeontx_link_status_print(nic->dev, &link);
777 return rte_eth_linkstatus_set(dev, &link);
781 octeontx_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
783 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
785 PMD_INIT_FUNC_TRACE();
786 return octeontx_port_stats(nic, stats);
790 octeontx_dev_stats_reset(struct rte_eth_dev *dev)
792 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
794 PMD_INIT_FUNC_TRACE();
795 return octeontx_port_stats_clr(nic);
799 octeontx_dev_mac_addr_del(struct rte_eth_dev *dev, uint32_t index)
801 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
804 ret = octeontx_bgx_port_mac_del(nic->port_id, index);
806 octeontx_log_err("failed to del MAC address filter on port %d",
811 octeontx_dev_mac_addr_add(struct rte_eth_dev *dev,
812 struct rte_ether_addr *mac_addr,
814 __rte_unused uint32_t vmdq)
816 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
819 ret = octeontx_bgx_port_mac_add(nic->port_id, mac_addr->addr_bytes,
822 octeontx_log_err("failed to add MAC address filter on port %d",
831 octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
832 struct rte_ether_addr *addr)
834 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
837 ret = octeontx_bgx_port_mac_set(nic->port_id, addr->addr_bytes);
839 /* Update same mac address to BGX CAM table */
840 ret = octeontx_bgx_port_mac_add(nic->port_id, addr->addr_bytes,
844 octeontx_log_err("failed to set MAC address on port %d",
852 octeontx_dev_info(struct rte_eth_dev *dev,
853 struct rte_eth_dev_info *dev_info)
855 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
857 /* Autonegotiation may be disabled */
858 dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
859 dev_info->speed_capa |= ETH_LINK_SPEED_10M | ETH_LINK_SPEED_100M |
860 ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
863 /* Min/Max MTU supported */
864 dev_info->min_rx_bufsize = OCCTX_MIN_FRS;
865 dev_info->max_rx_pktlen = OCCTX_MAX_FRS;
866 dev_info->max_mtu = dev_info->max_rx_pktlen - OCCTX_L2_OVERHEAD;
867 dev_info->min_mtu = dev_info->min_rx_bufsize - OCCTX_L2_OVERHEAD;
869 dev_info->max_mac_addrs =
870 octeontx_bgx_port_mac_entries_get(nic->port_id);
871 dev_info->max_rx_pktlen = PKI_MAX_PKTLEN;
872 dev_info->max_rx_queues = 1;
873 dev_info->max_tx_queues = PKO_MAX_NUM_DQ;
874 dev_info->min_rx_bufsize = 0;
876 dev_info->default_rxconf = (struct rte_eth_rxconf) {
879 .offloads = OCTEONTX_RX_OFFLOADS,
882 dev_info->default_txconf = (struct rte_eth_txconf) {
884 .offloads = OCTEONTX_TX_OFFLOADS,
887 dev_info->rx_offload_capa = OCTEONTX_RX_OFFLOADS;
888 dev_info->tx_offload_capa = OCTEONTX_TX_OFFLOADS;
889 dev_info->rx_queue_offload_capa = OCTEONTX_RX_OFFLOADS;
890 dev_info->tx_queue_offload_capa = OCTEONTX_TX_OFFLOADS;
896 octeontx_dq_info_getter(octeontx_dq_t *dq, void *out)
898 ((octeontx_dq_t *)out)->lmtline_va = dq->lmtline_va;
899 ((octeontx_dq_t *)out)->ioreg_va = dq->ioreg_va;
900 ((octeontx_dq_t *)out)->fc_status_va = dq->fc_status_va;
904 octeontx_vf_start_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic,
907 struct octeontx_txq *txq;
910 PMD_INIT_FUNC_TRACE();
912 if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED)
915 txq = dev->data->tx_queues[qidx];
917 res = octeontx_pko_channel_query_dqs(nic->base_ochan,
919 sizeof(octeontx_dq_t),
921 octeontx_dq_info_getter);
927 dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
931 (void)octeontx_port_stop(nic);
932 octeontx_pko_channel_stop(nic->base_ochan);
933 octeontx_pko_channel_close(nic->base_ochan);
934 dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
939 octeontx_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
941 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
943 PMD_INIT_FUNC_TRACE();
944 qidx = qidx % PKO_VF_NUM_DQ;
945 return octeontx_vf_start_tx_queue(dev, nic, qidx);
949 octeontx_vf_stop_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic,
955 PMD_INIT_FUNC_TRACE();
957 if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
960 dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
965 octeontx_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
967 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
969 PMD_INIT_FUNC_TRACE();
970 qidx = qidx % PKO_VF_NUM_DQ;
972 return octeontx_vf_stop_tx_queue(dev, nic, qidx);
976 octeontx_dev_tx_queue_release(void *tx_queue)
978 struct octeontx_txq *txq = tx_queue;
981 PMD_INIT_FUNC_TRACE();
984 res = octeontx_dev_tx_queue_stop(txq->eth_dev, txq->queue_id);
986 octeontx_log_err("failed stop tx_queue(%d)\n",
994 octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
995 uint16_t nb_desc, unsigned int socket_id,
996 const struct rte_eth_txconf *tx_conf __rte_unused)
998 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
999 struct octeontx_txq *txq = NULL;
1003 RTE_SET_USED(nb_desc);
1004 RTE_SET_USED(socket_id);
1006 dq_num = (nic->pko_vfid * PKO_VF_NUM_DQ) + qidx;
1008 /* Socket id check */
1009 if (socket_id != (unsigned int)SOCKET_ID_ANY &&
1010 socket_id != (unsigned int)nic->node)
1011 PMD_TX_LOG(INFO, "socket_id expected %d, configured %d",
1012 socket_id, nic->node);
1014 /* Free memory prior to re-allocation if needed. */
1015 if (dev->data->tx_queues[qidx] != NULL) {
1016 PMD_TX_LOG(DEBUG, "freeing memory prior to re-allocation %d",
1018 octeontx_dev_tx_queue_release(dev->data->tx_queues[qidx]);
1019 dev->data->tx_queues[qidx] = NULL;
1022 /* Allocating tx queue data structure */
1023 txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct octeontx_txq),
1024 RTE_CACHE_LINE_SIZE, nic->node);
1026 octeontx_log_err("failed to allocate txq=%d", qidx);
1032 txq->queue_id = dq_num;
1033 dev->data->tx_queues[qidx] = txq;
1034 dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
1036 res = octeontx_pko_channel_query_dqs(nic->base_ochan,
1038 sizeof(octeontx_dq_t),
1040 octeontx_dq_info_getter);
1046 PMD_TX_LOG(DEBUG, "[%d]:[%d] txq=%p nb_desc=%d lmtline=%p ioreg_va=%p fc_status_va=%p",
1047 qidx, txq->queue_id, txq, nb_desc, txq->dq.lmtline_va,
1049 txq->dq.fc_status_va);
1061 octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
1062 uint16_t nb_desc, unsigned int socket_id,
1063 const struct rte_eth_rxconf *rx_conf,
1064 struct rte_mempool *mb_pool)
1066 struct octeontx_nic *nic = octeontx_pmd_priv(dev);
1067 struct rte_mempool_ops *mp_ops = NULL;
1068 struct octeontx_rxq *rxq = NULL;
1069 pki_pktbuf_cfg_t pktbuf_conf;
1070 pki_hash_cfg_t pki_hash;
1071 pki_qos_cfg_t pki_qos;
1075 unsigned int ev_queues = (nic->ev_queues * nic->port_id) + qidx;
1076 unsigned int ev_ports = (nic->ev_ports * nic->port_id) + qidx;
1078 RTE_SET_USED(nb_desc);
1080 memset(&pktbuf_conf, 0, sizeof(pktbuf_conf));
1081 memset(&pki_hash, 0, sizeof(pki_hash));
1082 memset(&pki_qos, 0, sizeof(pki_qos));
1084 mp_ops = rte_mempool_get_ops(mb_pool->ops_index);
1085 if (strcmp(mp_ops->name, "octeontx_fpavf")) {
1086 octeontx_log_err("failed to find octeontx_fpavf mempool");
1090 /* Handle forbidden configurations */
1091 if (nic->pki.classifier_enable) {
1092 octeontx_log_err("cannot setup queue %d. "
1093 "Classifier option unsupported", qidx);
1097 port = nic->port_id;
1099 /* Rx deferred start is not supported */
1100 if (rx_conf->rx_deferred_start) {
1101 octeontx_log_err("rx deferred start not supported");
1105 /* Verify queue index */
1106 if (qidx >= dev->data->nb_rx_queues) {
1107 octeontx_log_err("QID %d not supporteded (0 - %d available)\n",
1108 qidx, (dev->data->nb_rx_queues - 1));
1112 /* Socket id check */
1113 if (socket_id != (unsigned int)SOCKET_ID_ANY &&
1114 socket_id != (unsigned int)nic->node)
1115 PMD_RX_LOG(INFO, "socket_id expected %d, configured %d",
1116 socket_id, nic->node);
1118 /* Allocating rx queue data structure */
1119 rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct octeontx_rxq),
1120 RTE_CACHE_LINE_SIZE, nic->node);
1122 octeontx_log_err("failed to allocate rxq=%d", qidx);
1126 if (!nic->pki.initialized) {
1127 pktbuf_conf.port_type = 0;
1128 pki_hash.port_type = 0;
1129 pki_qos.port_type = 0;
1131 pktbuf_conf.mmask.f_wqe_skip = 1;
1132 pktbuf_conf.mmask.f_first_skip = 1;
1133 pktbuf_conf.mmask.f_later_skip = 1;
1134 pktbuf_conf.mmask.f_mbuff_size = 1;
1135 pktbuf_conf.mmask.f_cache_mode = 1;
1137 pktbuf_conf.wqe_skip = OCTTX_PACKET_WQE_SKIP;
1138 pktbuf_conf.first_skip = OCTTX_PACKET_FIRST_SKIP(mb_pool);
1139 pktbuf_conf.later_skip = OCTTX_PACKET_LATER_SKIP;
1140 pktbuf_conf.mbuff_size = (mb_pool->elt_size -
1141 RTE_PKTMBUF_HEADROOM -
1142 rte_pktmbuf_priv_size(mb_pool) -
1143 sizeof(struct rte_mbuf));
1145 pktbuf_conf.cache_mode = PKI_OPC_MODE_STF2_STT;
1147 ret = octeontx_pki_port_pktbuf_config(port, &pktbuf_conf);
1149 octeontx_log_err("fail to configure pktbuf for port %d",
1154 PMD_RX_LOG(DEBUG, "Port %d Rx pktbuf configured:\n"
1155 "\tmbuf_size:\t0x%0x\n"
1156 "\twqe_skip:\t0x%0x\n"
1157 "\tfirst_skip:\t0x%0x\n"
1158 "\tlater_skip:\t0x%0x\n"
1159 "\tcache_mode:\t%s\n",
1161 pktbuf_conf.mbuff_size,
1162 pktbuf_conf.wqe_skip,
1163 pktbuf_conf.first_skip,
1164 pktbuf_conf.later_skip,
1165 (pktbuf_conf.cache_mode ==
1168 (pktbuf_conf.cache_mode ==
1171 (pktbuf_conf.cache_mode ==
1172 PKI_OPC_MODE_STF1_STT) ?
1173 "STF1_STT" : "STF2_STT");
1175 if (nic->pki.hash_enable) {
1176 pki_hash.tag_dlc = 1;
1177 pki_hash.tag_slc = 1;
1178 pki_hash.tag_dlf = 1;
1179 pki_hash.tag_slf = 1;
1180 pki_hash.tag_prt = 1;
1181 octeontx_pki_port_hash_config(port, &pki_hash);
1184 pool = (uintptr_t)mb_pool->pool_id;
1186 /* Get the gaura Id */
1187 gaura = octeontx_fpa_bufpool_gaura(pool);
1189 pki_qos.qpg_qos = PKI_QPG_QOS_NONE;
1190 pki_qos.num_entry = 1;
1191 pki_qos.drop_policy = 0;
1192 pki_qos.tag_type = 0L;
1193 pki_qos.qos_entry[0].port_add = 0;
1194 pki_qos.qos_entry[0].gaura = gaura;
1195 pki_qos.qos_entry[0].ggrp_ok = ev_queues;
1196 pki_qos.qos_entry[0].ggrp_bad = ev_queues;
1197 pki_qos.qos_entry[0].grptag_bad = 0;
1198 pki_qos.qos_entry[0].grptag_ok = 0;
1200 ret = octeontx_pki_port_create_qos(port, &pki_qos);
1202 octeontx_log_err("failed to create QOS port=%d, q=%d",
1207 nic->pki.initialized = true;
1210 rxq->port_id = nic->port_id;
1212 rxq->queue_id = qidx;
1213 rxq->evdev = nic->evdev;
1214 rxq->ev_queues = ev_queues;
1215 rxq->ev_ports = ev_ports;
1216 rxq->pool = mb_pool;
1218 octeontx_recheck_rx_offloads(rxq);
1219 dev->data->rx_queues[qidx] = rxq;
1220 dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
1226 octeontx_dev_rx_queue_release(void *rxq)
1231 static const uint32_t *
1232 octeontx_dev_supported_ptypes_get(struct rte_eth_dev *dev)
1234 static const uint32_t ptypes[] = {
1236 RTE_PTYPE_L3_IPV4_EXT,
1238 RTE_PTYPE_L3_IPV6_EXT,
1245 if (dev->rx_pkt_burst == octeontx_recv_pkts)
1252 octeontx_pool_ops(struct rte_eth_dev *dev, const char *pool)
1256 if (!strcmp(pool, "octeontx_fpavf"))
1262 /* Initialize and register driver with DPDK Application */
1263 static const struct eth_dev_ops octeontx_dev_ops = {
1264 .dev_configure = octeontx_dev_configure,
1265 .dev_infos_get = octeontx_dev_info,
1266 .dev_close = octeontx_dev_close,
1267 .dev_start = octeontx_dev_start,
1268 .dev_stop = octeontx_dev_stop,
1269 .promiscuous_enable = octeontx_dev_promisc_enable,
1270 .promiscuous_disable = octeontx_dev_promisc_disable,
1271 .link_update = octeontx_dev_link_update,
1272 .stats_get = octeontx_dev_stats_get,
1273 .stats_reset = octeontx_dev_stats_reset,
1274 .mac_addr_remove = octeontx_dev_mac_addr_del,
1275 .mac_addr_add = octeontx_dev_mac_addr_add,
1276 .mac_addr_set = octeontx_dev_default_mac_addr_set,
1277 .vlan_offload_set = octeontx_dev_vlan_offload_set,
1278 .vlan_filter_set = octeontx_dev_vlan_filter_set,
1279 .tx_queue_start = octeontx_dev_tx_queue_start,
1280 .tx_queue_stop = octeontx_dev_tx_queue_stop,
1281 .tx_queue_setup = octeontx_dev_tx_queue_setup,
1282 .tx_queue_release = octeontx_dev_tx_queue_release,
1283 .rx_queue_setup = octeontx_dev_rx_queue_setup,
1284 .rx_queue_release = octeontx_dev_rx_queue_release,
1285 .dev_set_link_up = octeontx_dev_set_link_up,
1286 .dev_set_link_down = octeontx_dev_set_link_down,
1287 .dev_supported_ptypes_get = octeontx_dev_supported_ptypes_get,
1288 .mtu_set = octeontx_dev_mtu_set,
1289 .pool_ops_supported = octeontx_pool_ops,
1290 .flow_ctrl_get = octeontx_dev_flow_ctrl_get,
1291 .flow_ctrl_set = octeontx_dev_flow_ctrl_set,
1294 /* Create Ethdev interface per BGX LMAC ports */
1296 octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
1301 char octtx_name[OCTEONTX_MAX_NAME_LEN];
1302 struct octeontx_nic *nic = NULL;
1303 struct rte_eth_dev *eth_dev = NULL;
1304 struct rte_eth_dev_data *data;
1305 const char *name = rte_vdev_device_name(dev);
1308 PMD_INIT_FUNC_TRACE();
1310 sprintf(octtx_name, "%s_%d", name, port);
1311 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1312 eth_dev = rte_eth_dev_attach_secondary(octtx_name);
1313 if (eth_dev == NULL)
1316 eth_dev->dev_ops = &octeontx_dev_ops;
1317 eth_dev->device = &dev->device;
1318 octeontx_set_tx_function(eth_dev);
1319 eth_dev->rx_pkt_burst = octeontx_recv_pkts;
1320 rte_eth_dev_probing_finish(eth_dev);
1324 /* Reserve an ethdev entry */
1325 eth_dev = rte_eth_dev_allocate(octtx_name);
1326 if (eth_dev == NULL) {
1327 octeontx_log_err("failed to allocate rte_eth_dev");
1331 data = eth_dev->data;
1333 nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id);
1335 octeontx_log_err("failed to allocate nic structure");
1339 data->dev_private = nic;
1340 pko_vfid = octeontx_pko_get_vfid();
1342 if (pko_vfid == SIZE_MAX) {
1343 octeontx_log_err("failed to get pko vfid");
1348 nic->pko_vfid = pko_vfid;
1349 nic->port_id = port;
1352 res = octeontx_port_open(nic);
1356 /* Rx side port configuration */
1357 res = octeontx_pki_port_open(port);
1359 octeontx_log_err("failed to open PKI port %d", port);
1364 eth_dev->device = &dev->device;
1365 eth_dev->intr_handle = NULL;
1366 eth_dev->data->numa_node = dev->device.numa_node;
1368 data->port_id = eth_dev->data->port_id;
1372 nic->print_flag = -1;
1374 data->dev_link.link_status = ETH_LINK_DOWN;
1375 data->dev_started = 0;
1376 data->promiscuous = 0;
1377 data->all_multicast = 0;
1378 data->scattered_rx = 0;
1380 /* Get maximum number of supported MAC entries */
1381 max_entries = octeontx_bgx_port_mac_entries_get(nic->port_id);
1382 if (max_entries < 0) {
1383 octeontx_log_err("Failed to get max entries for mac addr");
1388 data->mac_addrs = rte_zmalloc_socket(octtx_name, max_entries *
1389 RTE_ETHER_ADDR_LEN, 0,
1391 if (data->mac_addrs == NULL) {
1392 octeontx_log_err("failed to allocate memory for mac_addrs");
1397 eth_dev->dev_ops = &octeontx_dev_ops;
1399 /* Finally save ethdev pointer to the NIC structure */
1402 if (nic->port_id != data->port_id) {
1403 octeontx_log_err("eth_dev->port_id (%d) is diff to orig (%d)",
1404 data->port_id, nic->port_id);
1406 goto free_mac_addrs;
1409 res = rte_eal_alarm_set(OCCTX_INTR_POLL_INTERVAL_MS * 1000,
1410 octeontx_link_status_poll, nic);
1412 octeontx_log_err("Failed to start link polling alarm");
1416 /* Update port_id mac to eth_dev */
1417 memcpy(data->mac_addrs, nic->mac_addr, RTE_ETHER_ADDR_LEN);
1419 /* Update same mac address to BGX CAM table at index 0 */
1420 octeontx_bgx_port_mac_add(nic->port_id, nic->mac_addr, 0);
1422 res = octeontx_dev_flow_ctrl_init(eth_dev);
1426 PMD_INIT_LOG(DEBUG, "ethdev info: ");
1427 PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d",
1428 nic->port_id, nic->port_ena,
1429 nic->base_ochan, nic->num_ochans,
1430 nic->num_tx_queues);
1431 PMD_INIT_LOG(DEBUG, "speed %d mtu %d", nic->speed, nic->bgx_mtu);
1433 rte_octeontx_pchan_map[(nic->base_ochan >> 8) & 0x7]
1434 [(nic->base_ochan >> 4) & 0xF] = data->port_id;
1436 rte_eth_dev_probing_finish(eth_dev);
1437 return data->port_id;
1440 rte_free(data->mac_addrs);
1441 data->mac_addrs = NULL;
1444 octeontx_port_close(nic);
1446 rte_eth_dev_release_port(eth_dev);
1451 /* Un initialize octeontx device */
1453 octeontx_remove(struct rte_vdev_device *dev)
1455 char octtx_name[OCTEONTX_MAX_NAME_LEN];
1456 struct rte_eth_dev *eth_dev = NULL;
1457 struct octeontx_nic *nic = NULL;
1463 for (i = 0; i < OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT; i++) {
1464 sprintf(octtx_name, "eth_octeontx_%d", i);
1466 /* reserve an ethdev entry */
1467 eth_dev = rte_eth_dev_allocated(octtx_name);
1468 if (eth_dev == NULL)
1471 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1472 rte_eth_dev_release_port(eth_dev);
1476 nic = octeontx_pmd_priv(eth_dev);
1477 rte_event_dev_stop(nic->evdev);
1478 PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name);
1480 rte_eth_dev_release_port(eth_dev);
1481 rte_event_dev_close(nic->evdev);
1484 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1487 /* Free FC resource */
1488 octeontx_pko_fc_free();
1493 /* Initialize octeontx device */
1495 octeontx_probe(struct rte_vdev_device *dev)
1497 const char *dev_name;
1498 static int probe_once;
1499 uint8_t socket_id, qlist;
1500 int tx_vfcnt, port_id, evdev, qnum, pnum, res, i;
1501 struct rte_event_dev_config dev_conf;
1502 const char *eventdev_name = "event_octeontx";
1503 struct rte_event_dev_info info;
1504 struct rte_eth_dev *eth_dev;
1506 struct octeontx_vdev_init_params init_params = {
1507 OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT
1510 dev_name = rte_vdev_device_name(dev);
1512 if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
1513 strlen(rte_vdev_device_args(dev)) == 0) {
1514 eth_dev = rte_eth_dev_attach_secondary(dev_name);
1516 PMD_INIT_LOG(ERR, "Failed to probe %s", dev_name);
1519 /* TODO: request info from primary to set up Rx and Tx */
1520 eth_dev->dev_ops = &octeontx_dev_ops;
1521 eth_dev->device = &dev->device;
1522 rte_eth_dev_probing_finish(eth_dev);
1526 res = octeontx_parse_vdev_init_params(&init_params, dev);
1530 if (init_params.nr_port > OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT) {
1531 octeontx_log_err("nr_port (%d) > max (%d)", init_params.nr_port,
1532 OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT);
1536 PMD_INIT_LOG(DEBUG, "initializing %s pmd", dev_name);
1538 socket_id = rte_socket_id();
1540 tx_vfcnt = octeontx_pko_vf_count();
1542 if (tx_vfcnt < init_params.nr_port) {
1543 octeontx_log_err("not enough PKO (%d) for port number (%d)",
1544 tx_vfcnt, init_params.nr_port);
1547 evdev = rte_event_dev_get_dev_id(eventdev_name);
1549 octeontx_log_err("eventdev %s not found", eventdev_name);
1553 res = rte_event_dev_info_get(evdev, &info);
1555 octeontx_log_err("failed to eventdev info %d", res);
1559 PMD_INIT_LOG(DEBUG, "max_queue %d max_port %d",
1560 info.max_event_queues, info.max_event_ports);
1562 if (octeontx_pko_init_fc(tx_vfcnt))
1565 devconf_set_default_sane_values(&dev_conf, &info);
1566 res = rte_event_dev_configure(evdev, &dev_conf);
1570 rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_PORT_COUNT,
1572 rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
1575 octeontx_log_err("too few event ports (%d) for event_q(%d)",
1581 /* Enable all queues available */
1582 for (i = 0; i < qnum; i++) {
1583 res = rte_event_queue_setup(evdev, i, NULL);
1585 octeontx_log_err("failed to setup event_q(%d): res %d",
1591 /* Enable all ports available */
1592 for (i = 0; i < pnum; i++) {
1593 res = rte_event_port_setup(evdev, i, NULL);
1596 octeontx_log_err("failed to setup ev port(%d) res=%d",
1603 * Do 1:1 links for ports & queues. All queues would be mapped to
1604 * one port. If there are more ports than queues, then some ports
1605 * won't be linked to any queue.
1607 for (i = 0; i < qnum; i++) {
1608 /* Link one queue to one event port */
1610 res = rte_event_port_link(evdev, i, &qlist, NULL, 1);
1613 octeontx_log_err("failed to link port (%d): res=%d",
1619 /* Create ethdev interface */
1620 for (i = 0; i < init_params.nr_port; i++) {
1621 port_id = octeontx_create(dev, i, evdev, socket_id);
1623 octeontx_log_err("failed to create device %s",
1629 PMD_INIT_LOG(INFO, "created ethdev %s for port %d", dev_name,
1634 octeontx_log_err("interface %s not supported", dev_name);
1635 octeontx_remove(dev);
1639 rte_mbuf_set_platform_mempool_ops("octeontx_fpavf");
1645 octeontx_pko_fc_free();
1649 static struct rte_vdev_driver octeontx_pmd_drv = {
1650 .probe = octeontx_probe,
1651 .remove = octeontx_remove,
1654 RTE_PMD_REGISTER_VDEV(OCTEONTX_PMD, octeontx_pmd_drv);
1655 RTE_PMD_REGISTER_ALIAS(OCTEONTX_PMD, eth_octeontx);
1656 RTE_PMD_REGISTER_PARAM_STRING(OCTEONTX_PMD, "nr_port=<int> ");