xref: /dpdk/drivers/net/octeontx/octeontx_ethdev.c (revision a92870896b4a133b51fd476d748fed95911bfa6b)
1aaf4363eSJerin Jacob /* SPDX-License-Identifier: BSD-3-Clause
2aaf4363eSJerin Jacob  * Copyright(c) 2017 Cavium, Inc
3f7be70e5SJerin Jacob  */
4aaf4363eSJerin Jacob 
5f7be70e5SJerin Jacob #include <stdio.h>
6f7be70e5SJerin Jacob #include <stdarg.h>
7f7be70e5SJerin Jacob #include <stdbool.h>
8f7be70e5SJerin Jacob #include <stdint.h>
9f7be70e5SJerin Jacob #include <string.h>
10f7be70e5SJerin Jacob #include <unistd.h>
11f7be70e5SJerin Jacob 
12f7be70e5SJerin Jacob #include <rte_alarm.h>
13f7be70e5SJerin Jacob #include <rte_branch_prediction.h>
14f7be70e5SJerin Jacob #include <rte_debug.h>
15f7be70e5SJerin Jacob #include <rte_devargs.h>
16f7be70e5SJerin Jacob #include <rte_dev.h>
17f7be70e5SJerin Jacob #include <rte_kvargs.h>
18f7be70e5SJerin Jacob #include <rte_malloc.h>
19dfb0c75bSPavan Nikhilesh #include <rte_mbuf_pool_ops.h>
20f7be70e5SJerin Jacob #include <rte_prefetch.h>
21d4a586d2SJianfeng Tan #include <rte_bus_vdev.h>
22f7be70e5SJerin Jacob 
23f7be70e5SJerin Jacob #include "octeontx_ethdev.h"
2420186d43SJerin Jacob #include "octeontx_rxtx.h"
25f7be70e5SJerin Jacob #include "octeontx_logs.h"
26f7be70e5SJerin Jacob 
27f7be70e5SJerin Jacob struct octeontx_vdev_init_params {
28f7be70e5SJerin Jacob 	uint8_t	nr_port;
29f7be70e5SJerin Jacob };
30f7be70e5SJerin Jacob 
31989d4926SPavan Nikhilesh uint16_t
32989d4926SPavan Nikhilesh rte_octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX];
33989d4926SPavan Nikhilesh 
344fac7c0aSJerin Jacob enum octeontx_link_speed {
354fac7c0aSJerin Jacob 	OCTEONTX_LINK_SPEED_SGMII,
364fac7c0aSJerin Jacob 	OCTEONTX_LINK_SPEED_XAUI,
374fac7c0aSJerin Jacob 	OCTEONTX_LINK_SPEED_RXAUI,
384fac7c0aSJerin Jacob 	OCTEONTX_LINK_SPEED_10G_R,
394fac7c0aSJerin Jacob 	OCTEONTX_LINK_SPEED_40G_R,
404fac7c0aSJerin Jacob 	OCTEONTX_LINK_SPEED_RESERVE1,
414fac7c0aSJerin Jacob 	OCTEONTX_LINK_SPEED_QSGMII,
424fac7c0aSJerin Jacob 	OCTEONTX_LINK_SPEED_RESERVE2
434fac7c0aSJerin Jacob };
444fac7c0aSJerin Jacob 
454d35a276SPavan Nikhilesh int otx_net_logtype_mbox;
464d35a276SPavan Nikhilesh int otx_net_logtype_init;
474d35a276SPavan Nikhilesh int otx_net_logtype_driver;
484d35a276SPavan Nikhilesh 
494d35a276SPavan Nikhilesh RTE_INIT(otx_net_init_log);
504d35a276SPavan Nikhilesh static void
514d35a276SPavan Nikhilesh otx_net_init_log(void)
524d35a276SPavan Nikhilesh {
531a0eab3aSHarry van Haaren 	otx_net_logtype_mbox = rte_log_register("pmd.net.octeontx.mbox");
544d35a276SPavan Nikhilesh 	if (otx_net_logtype_mbox >= 0)
554d35a276SPavan Nikhilesh 		rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE);
564d35a276SPavan Nikhilesh 
571a0eab3aSHarry van Haaren 	otx_net_logtype_init = rte_log_register("pmd.net.octeontx.init");
584d35a276SPavan Nikhilesh 	if (otx_net_logtype_init >= 0)
594d35a276SPavan Nikhilesh 		rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE);
604d35a276SPavan Nikhilesh 
611a0eab3aSHarry van Haaren 	otx_net_logtype_driver = rte_log_register("pmd.net.octeontx.driver");
624d35a276SPavan Nikhilesh 	if (otx_net_logtype_driver >= 0)
634d35a276SPavan Nikhilesh 		rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE);
644d35a276SPavan Nikhilesh }
654d35a276SPavan Nikhilesh 
66f7be70e5SJerin Jacob /* Parse integer from integer argument */
67f7be70e5SJerin Jacob static int
68f7be70e5SJerin Jacob parse_integer_arg(const char *key __rte_unused,
69f7be70e5SJerin Jacob 		const char *value, void *extra_args)
70f7be70e5SJerin Jacob {
71f7be70e5SJerin Jacob 	int *i = (int *)extra_args;
72f7be70e5SJerin Jacob 
73f7be70e5SJerin Jacob 	*i = atoi(value);
74f7be70e5SJerin Jacob 	if (*i < 0) {
75f7be70e5SJerin Jacob 		octeontx_log_err("argument has to be positive.");
76f7be70e5SJerin Jacob 		return -1;
77f7be70e5SJerin Jacob 	}
78f7be70e5SJerin Jacob 
79f7be70e5SJerin Jacob 	return 0;
80f7be70e5SJerin Jacob }
81f7be70e5SJerin Jacob 
82f7be70e5SJerin Jacob static int
83f7be70e5SJerin Jacob octeontx_parse_vdev_init_params(struct octeontx_vdev_init_params *params,
84f7be70e5SJerin Jacob 				struct rte_vdev_device *dev)
85f7be70e5SJerin Jacob {
86f7be70e5SJerin Jacob 	struct rte_kvargs *kvlist = NULL;
87f7be70e5SJerin Jacob 	int ret = 0;
88f7be70e5SJerin Jacob 
89f7be70e5SJerin Jacob 	static const char * const octeontx_vdev_valid_params[] = {
90f7be70e5SJerin Jacob 		OCTEONTX_VDEV_NR_PORT_ARG,
91f7be70e5SJerin Jacob 		NULL
92f7be70e5SJerin Jacob 	};
93f7be70e5SJerin Jacob 
94f7be70e5SJerin Jacob 	const char *input_args = rte_vdev_device_args(dev);
95f7be70e5SJerin Jacob 	if (params == NULL)
96f7be70e5SJerin Jacob 		return -EINVAL;
97f7be70e5SJerin Jacob 
98f7be70e5SJerin Jacob 
99f7be70e5SJerin Jacob 	if (input_args) {
100f7be70e5SJerin Jacob 		kvlist = rte_kvargs_parse(input_args,
101f7be70e5SJerin Jacob 				octeontx_vdev_valid_params);
102f7be70e5SJerin Jacob 		if (kvlist == NULL)
103f7be70e5SJerin Jacob 			return -1;
104f7be70e5SJerin Jacob 
105f7be70e5SJerin Jacob 		ret = rte_kvargs_process(kvlist,
106f7be70e5SJerin Jacob 					OCTEONTX_VDEV_NR_PORT_ARG,
107f7be70e5SJerin Jacob 					&parse_integer_arg,
108f7be70e5SJerin Jacob 					&params->nr_port);
109f7be70e5SJerin Jacob 		if (ret < 0)
110f7be70e5SJerin Jacob 			goto free_kvlist;
111f7be70e5SJerin Jacob 	}
112f7be70e5SJerin Jacob 
113f7be70e5SJerin Jacob free_kvlist:
114f7be70e5SJerin Jacob 	rte_kvargs_free(kvlist);
115f7be70e5SJerin Jacob 	return ret;
116f7be70e5SJerin Jacob }
117f7be70e5SJerin Jacob 
118f18b146cSJerin Jacob static int
119f18b146cSJerin Jacob octeontx_port_open(struct octeontx_nic *nic)
120f18b146cSJerin Jacob {
121f18b146cSJerin Jacob 	octeontx_mbox_bgx_port_conf_t bgx_port_conf;
122f18b146cSJerin Jacob 	int res;
123f18b146cSJerin Jacob 
124f18b146cSJerin Jacob 	res = 0;
125a371fd79SSantosh Shukla 	memset(&bgx_port_conf, 0x0, sizeof(bgx_port_conf));
126f18b146cSJerin Jacob 	PMD_INIT_FUNC_TRACE();
127f18b146cSJerin Jacob 
128f18b146cSJerin Jacob 	res = octeontx_bgx_port_open(nic->port_id, &bgx_port_conf);
129f18b146cSJerin Jacob 	if (res < 0) {
130f18b146cSJerin Jacob 		octeontx_log_err("failed to open port %d", res);
131f18b146cSJerin Jacob 		return res;
132f18b146cSJerin Jacob 	}
133f18b146cSJerin Jacob 
134f18b146cSJerin Jacob 	nic->node = bgx_port_conf.node;
135f18b146cSJerin Jacob 	nic->port_ena = bgx_port_conf.enable;
136f18b146cSJerin Jacob 	nic->base_ichan = bgx_port_conf.base_chan;
137f18b146cSJerin Jacob 	nic->base_ochan = bgx_port_conf.base_chan;
138f18b146cSJerin Jacob 	nic->num_ichans = bgx_port_conf.num_chans;
139f18b146cSJerin Jacob 	nic->num_ochans = bgx_port_conf.num_chans;
140f18b146cSJerin Jacob 	nic->mtu = bgx_port_conf.mtu;
141f18b146cSJerin Jacob 	nic->bpen = bgx_port_conf.bpen;
142f18b146cSJerin Jacob 	nic->fcs_strip = bgx_port_conf.fcs_strip;
143f18b146cSJerin Jacob 	nic->bcast_mode = bgx_port_conf.bcast_mode;
144f18b146cSJerin Jacob 	nic->mcast_mode = bgx_port_conf.mcast_mode;
145f18b146cSJerin Jacob 	nic->speed	= bgx_port_conf.mode;
146f18b146cSJerin Jacob 
147f18b146cSJerin Jacob 	memcpy(&nic->mac_addr[0], &bgx_port_conf.macaddr[0], ETHER_ADDR_LEN);
148f18b146cSJerin Jacob 
149f18b146cSJerin Jacob 	octeontx_log_dbg("port opened %d", nic->port_id);
150f18b146cSJerin Jacob 	return res;
151f18b146cSJerin Jacob }
152f18b146cSJerin Jacob 
153f18b146cSJerin Jacob static void
154f18b146cSJerin Jacob octeontx_port_close(struct octeontx_nic *nic)
155f18b146cSJerin Jacob {
156f18b146cSJerin Jacob 	PMD_INIT_FUNC_TRACE();
157f18b146cSJerin Jacob 
158f18b146cSJerin Jacob 	octeontx_bgx_port_close(nic->port_id);
159f18b146cSJerin Jacob 	octeontx_log_dbg("port closed %d", nic->port_id);
160f18b146cSJerin Jacob }
161f18b146cSJerin Jacob 
1627fe7c98fSJerin Jacob static int
163da6c6874SJerin Jacob octeontx_port_start(struct octeontx_nic *nic)
164da6c6874SJerin Jacob {
165da6c6874SJerin Jacob 	PMD_INIT_FUNC_TRACE();
166da6c6874SJerin Jacob 
167da6c6874SJerin Jacob 	return octeontx_bgx_port_start(nic->port_id);
168da6c6874SJerin Jacob }
169da6c6874SJerin Jacob 
170da6c6874SJerin Jacob static int
1717fe7c98fSJerin Jacob octeontx_port_stop(struct octeontx_nic *nic)
1727fe7c98fSJerin Jacob {
1737fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
1747fe7c98fSJerin Jacob 
1757fe7c98fSJerin Jacob 	return octeontx_bgx_port_stop(nic->port_id);
1767fe7c98fSJerin Jacob }
1777fe7c98fSJerin Jacob 
17815bce35bSJerin Jacob static void
17915bce35bSJerin Jacob octeontx_port_promisc_set(struct octeontx_nic *nic, int en)
18015bce35bSJerin Jacob {
18115bce35bSJerin Jacob 	struct rte_eth_dev *dev;
18215bce35bSJerin Jacob 	int res;
18315bce35bSJerin Jacob 
18415bce35bSJerin Jacob 	res = 0;
18515bce35bSJerin Jacob 	PMD_INIT_FUNC_TRACE();
18615bce35bSJerin Jacob 	dev = nic->dev;
18715bce35bSJerin Jacob 
18815bce35bSJerin Jacob 	res = octeontx_bgx_port_promisc_set(nic->port_id, en);
18915bce35bSJerin Jacob 	if (res < 0)
19015bce35bSJerin Jacob 		octeontx_log_err("failed to set promiscuous mode %d",
19115bce35bSJerin Jacob 				nic->port_id);
19215bce35bSJerin Jacob 
19315bce35bSJerin Jacob 	/* Set proper flag for the mode */
19415bce35bSJerin Jacob 	dev->data->promiscuous = (en != 0) ? 1 : 0;
19515bce35bSJerin Jacob 
19615bce35bSJerin Jacob 	octeontx_log_dbg("port %d : promiscuous mode %s",
19715bce35bSJerin Jacob 			nic->port_id, en ? "set" : "unset");
19815bce35bSJerin Jacob }
19915bce35bSJerin Jacob 
200d5b0924bSMatan Azrad static int
20155389909SJerin Jacob octeontx_port_stats(struct octeontx_nic *nic, struct rte_eth_stats *stats)
20255389909SJerin Jacob {
20355389909SJerin Jacob 	octeontx_mbox_bgx_port_stats_t bgx_stats;
20455389909SJerin Jacob 	int res;
20555389909SJerin Jacob 
20655389909SJerin Jacob 	PMD_INIT_FUNC_TRACE();
20755389909SJerin Jacob 
20855389909SJerin Jacob 	res = octeontx_bgx_port_stats(nic->port_id, &bgx_stats);
209d5b0924bSMatan Azrad 	if (res < 0) {
21055389909SJerin Jacob 		octeontx_log_err("failed to get port stats %d", nic->port_id);
211d5b0924bSMatan Azrad 		return res;
212d5b0924bSMatan Azrad 	}
21355389909SJerin Jacob 
21455389909SJerin Jacob 	stats->ipackets = bgx_stats.rx_packets;
21555389909SJerin Jacob 	stats->ibytes = bgx_stats.rx_bytes;
21655389909SJerin Jacob 	stats->imissed = bgx_stats.rx_dropped;
21755389909SJerin Jacob 	stats->ierrors = bgx_stats.rx_errors;
21855389909SJerin Jacob 	stats->opackets = bgx_stats.tx_packets;
21955389909SJerin Jacob 	stats->obytes = bgx_stats.tx_bytes;
22055389909SJerin Jacob 	stats->oerrors = bgx_stats.tx_errors;
22155389909SJerin Jacob 
22255389909SJerin Jacob 	octeontx_log_dbg("port%d stats inpkts=%" PRIx64 " outpkts=%" PRIx64 "",
22355389909SJerin Jacob 			nic->port_id, stats->ipackets, stats->opackets);
224d5b0924bSMatan Azrad 
225d5b0924bSMatan Azrad 	return 0;
22655389909SJerin Jacob }
22755389909SJerin Jacob 
22855389909SJerin Jacob static void
22955389909SJerin Jacob octeontx_port_stats_clr(struct octeontx_nic *nic)
23055389909SJerin Jacob {
23155389909SJerin Jacob 	PMD_INIT_FUNC_TRACE();
23255389909SJerin Jacob 
23355389909SJerin Jacob 	octeontx_bgx_port_stats_clr(nic->port_id);
23455389909SJerin Jacob }
23555389909SJerin Jacob 
236f7be70e5SJerin Jacob static inline void
237f7be70e5SJerin Jacob devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf,
238f7be70e5SJerin Jacob 				struct rte_event_dev_info *info)
239f7be70e5SJerin Jacob {
240f7be70e5SJerin Jacob 	memset(dev_conf, 0, sizeof(struct rte_event_dev_config));
241f7be70e5SJerin Jacob 	dev_conf->dequeue_timeout_ns = info->min_dequeue_timeout_ns;
242f7be70e5SJerin Jacob 
243f7be70e5SJerin Jacob 	dev_conf->nb_event_ports = info->max_event_ports;
244f7be70e5SJerin Jacob 	dev_conf->nb_event_queues = info->max_event_queues;
245f7be70e5SJerin Jacob 
246f7be70e5SJerin Jacob 	dev_conf->nb_event_queue_flows = info->max_event_queue_flows;
247f7be70e5SJerin Jacob 	dev_conf->nb_event_port_dequeue_depth =
248f7be70e5SJerin Jacob 			info->max_event_port_dequeue_depth;
249f7be70e5SJerin Jacob 	dev_conf->nb_event_port_enqueue_depth =
250f7be70e5SJerin Jacob 			info->max_event_port_enqueue_depth;
251f7be70e5SJerin Jacob 	dev_conf->nb_event_port_enqueue_depth =
252f7be70e5SJerin Jacob 			info->max_event_port_enqueue_depth;
253f7be70e5SJerin Jacob 	dev_conf->nb_events_limit =
254f7be70e5SJerin Jacob 			info->max_num_events;
255f7be70e5SJerin Jacob }
256f7be70e5SJerin Jacob 
2577742c55aSJerin Jacob static int
2587742c55aSJerin Jacob octeontx_dev_configure(struct rte_eth_dev *dev)
2597742c55aSJerin Jacob {
2607742c55aSJerin Jacob 	struct rte_eth_dev_data *data = dev->data;
2617742c55aSJerin Jacob 	struct rte_eth_conf *conf = &data->dev_conf;
2627742c55aSJerin Jacob 	struct rte_eth_rxmode *rxmode = &conf->rxmode;
2637742c55aSJerin Jacob 	struct rte_eth_txmode *txmode = &conf->txmode;
2647742c55aSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
265*a9287089SPavan Nikhilesh 	uint64_t configured_offloads;
266*a9287089SPavan Nikhilesh 	uint64_t unsupported_offloads;
2677742c55aSJerin Jacob 	int ret;
2687742c55aSJerin Jacob 
2697742c55aSJerin Jacob 	PMD_INIT_FUNC_TRACE();
2707742c55aSJerin Jacob 	RTE_SET_USED(conf);
2717742c55aSJerin Jacob 
2727742c55aSJerin Jacob 	if (!rte_eal_has_hugepages()) {
2737742c55aSJerin Jacob 		octeontx_log_err("huge page is not configured");
2747742c55aSJerin Jacob 		return -EINVAL;
2757742c55aSJerin Jacob 	}
2767742c55aSJerin Jacob 
2777742c55aSJerin Jacob 	if (txmode->mq_mode) {
2787742c55aSJerin Jacob 		octeontx_log_err("tx mq_mode DCB or VMDq not supported");
2797742c55aSJerin Jacob 		return -EINVAL;
2807742c55aSJerin Jacob 	}
2817742c55aSJerin Jacob 
2827742c55aSJerin Jacob 	if (rxmode->mq_mode != ETH_MQ_RX_NONE &&
2837742c55aSJerin Jacob 		rxmode->mq_mode != ETH_MQ_RX_RSS) {
2847742c55aSJerin Jacob 		octeontx_log_err("unsupported rx qmode %d", rxmode->mq_mode);
2857742c55aSJerin Jacob 		return -EINVAL;
2867742c55aSJerin Jacob 	}
2877742c55aSJerin Jacob 
288*a9287089SPavan Nikhilesh 	configured_offloads = rxmode->offloads;
289*a9287089SPavan Nikhilesh 
290*a9287089SPavan Nikhilesh 	if (!(configured_offloads & DEV_RX_OFFLOAD_CRC_STRIP)) {
2917742c55aSJerin Jacob 		PMD_INIT_LOG(NOTICE, "can't disable hw crc strip");
292*a9287089SPavan Nikhilesh 		configured_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
2937742c55aSJerin Jacob 	}
2947742c55aSJerin Jacob 
295*a9287089SPavan Nikhilesh 	unsupported_offloads = configured_offloads & ~OCTEONTX_RX_OFFLOADS;
296*a9287089SPavan Nikhilesh 
297*a9287089SPavan Nikhilesh 	if (unsupported_offloads) {
298*a9287089SPavan Nikhilesh 		PMD_INIT_LOG(ERR, "Rx offloads 0x%" PRIx64 " are not supported. "
299*a9287089SPavan Nikhilesh 		      "Requested 0x%" PRIx64 " supported 0x%" PRIx64 "\n",
300*a9287089SPavan Nikhilesh 		      unsupported_offloads, configured_offloads,
301*a9287089SPavan Nikhilesh 		      (uint64_t)OCTEONTX_RX_OFFLOADS);
302*a9287089SPavan Nikhilesh 		return -ENOTSUP;
3037742c55aSJerin Jacob 	}
3047742c55aSJerin Jacob 
305*a9287089SPavan Nikhilesh 	configured_offloads = txmode->offloads;
306*a9287089SPavan Nikhilesh 
307*a9287089SPavan Nikhilesh 	if (!(configured_offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) {
308*a9287089SPavan Nikhilesh 		PMD_INIT_LOG(NOTICE, "cant disable lockfree tx");
309*a9287089SPavan Nikhilesh 		configured_offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE;
3107742c55aSJerin Jacob 	}
3117742c55aSJerin Jacob 
312*a9287089SPavan Nikhilesh 	unsupported_offloads = configured_offloads & ~OCTEONTX_TX_OFFLOADS;
3137742c55aSJerin Jacob 
314*a9287089SPavan Nikhilesh 	if (unsupported_offloads) {
315*a9287089SPavan Nikhilesh 		PMD_INIT_LOG(ERR, "Tx offloads 0x%" PRIx64 " are not supported."
316*a9287089SPavan Nikhilesh 		      "Requested 0x%" PRIx64 " supported 0x%" PRIx64 ".\n",
317*a9287089SPavan Nikhilesh 		      unsupported_offloads, configured_offloads,
318*a9287089SPavan Nikhilesh 		      (uint64_t)OCTEONTX_TX_OFFLOADS);
319*a9287089SPavan Nikhilesh 		return -ENOTSUP;
3207742c55aSJerin Jacob 	}
3217742c55aSJerin Jacob 
3227742c55aSJerin Jacob 	if (conf->link_speeds & ETH_LINK_SPEED_FIXED) {
3237742c55aSJerin Jacob 		octeontx_log_err("setting link speed/duplex not supported");
3247742c55aSJerin Jacob 		return -EINVAL;
3257742c55aSJerin Jacob 	}
3267742c55aSJerin Jacob 
3277742c55aSJerin Jacob 	if (conf->dcb_capability_en) {
3287742c55aSJerin Jacob 		octeontx_log_err("DCB enable not supported");
3297742c55aSJerin Jacob 		return -EINVAL;
3307742c55aSJerin Jacob 	}
3317742c55aSJerin Jacob 
3327742c55aSJerin Jacob 	if (conf->fdir_conf.mode != RTE_FDIR_MODE_NONE) {
3337742c55aSJerin Jacob 		octeontx_log_err("flow director not supported");
3347742c55aSJerin Jacob 		return -EINVAL;
3357742c55aSJerin Jacob 	}
3367742c55aSJerin Jacob 
3377742c55aSJerin Jacob 	nic->num_tx_queues = dev->data->nb_tx_queues;
3387742c55aSJerin Jacob 
3397742c55aSJerin Jacob 	ret = octeontx_pko_channel_open(nic->port_id * PKO_VF_NUM_DQ,
3407742c55aSJerin Jacob 					nic->num_tx_queues,
3417742c55aSJerin Jacob 					nic->base_ochan);
3427742c55aSJerin Jacob 	if (ret) {
3437742c55aSJerin Jacob 		octeontx_log_err("failed to open channel %d no-of-txq %d",
3447742c55aSJerin Jacob 			   nic->base_ochan, nic->num_tx_queues);
3457742c55aSJerin Jacob 		return -EFAULT;
3467742c55aSJerin Jacob 	}
3477742c55aSJerin Jacob 
3487742c55aSJerin Jacob 	nic->pki.classifier_enable = false;
3497742c55aSJerin Jacob 	nic->pki.hash_enable = true;
3507742c55aSJerin Jacob 	nic->pki.initialized = false;
3517742c55aSJerin Jacob 
3527742c55aSJerin Jacob 	return 0;
3537742c55aSJerin Jacob }
3547742c55aSJerin Jacob 
35515bce35bSJerin Jacob static void
356da6c6874SJerin Jacob octeontx_dev_close(struct rte_eth_dev *dev)
357da6c6874SJerin Jacob {
358da6c6874SJerin Jacob 	struct octeontx_txq *txq = NULL;
359da6c6874SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
360da6c6874SJerin Jacob 	unsigned int i;
361da6c6874SJerin Jacob 	int ret;
362da6c6874SJerin Jacob 
363da6c6874SJerin Jacob 	PMD_INIT_FUNC_TRACE();
364da6c6874SJerin Jacob 
365da6c6874SJerin Jacob 	rte_event_dev_close(nic->evdev);
366da6c6874SJerin Jacob 
367da6c6874SJerin Jacob 	ret = octeontx_pko_channel_close(nic->base_ochan);
368da6c6874SJerin Jacob 	if (ret < 0) {
369da6c6874SJerin Jacob 		octeontx_log_err("failed to close channel %d VF%d %d %d",
370da6c6874SJerin Jacob 			     nic->base_ochan, nic->port_id, nic->num_tx_queues,
371da6c6874SJerin Jacob 			     ret);
372da6c6874SJerin Jacob 	}
373da6c6874SJerin Jacob 	/* Free txq resources for this port */
374da6c6874SJerin Jacob 	for (i = 0; i < nic->num_tx_queues; i++) {
375da6c6874SJerin Jacob 		txq = dev->data->tx_queues[i];
376da6c6874SJerin Jacob 		if (!txq)
377da6c6874SJerin Jacob 			continue;
378da6c6874SJerin Jacob 
379da6c6874SJerin Jacob 		rte_free(txq);
380da6c6874SJerin Jacob 	}
381da6c6874SJerin Jacob }
382da6c6874SJerin Jacob 
383da6c6874SJerin Jacob static int
384da6c6874SJerin Jacob octeontx_dev_start(struct rte_eth_dev *dev)
385da6c6874SJerin Jacob {
386da6c6874SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
387da6c6874SJerin Jacob 	int ret;
388da6c6874SJerin Jacob 
389da6c6874SJerin Jacob 	ret = 0;
390da6c6874SJerin Jacob 
391da6c6874SJerin Jacob 	PMD_INIT_FUNC_TRACE();
392da6c6874SJerin Jacob 	/*
393da6c6874SJerin Jacob 	 * Tx start
394da6c6874SJerin Jacob 	 */
395da6c6874SJerin Jacob 	dev->tx_pkt_burst = octeontx_xmit_pkts;
396da6c6874SJerin Jacob 	ret = octeontx_pko_channel_start(nic->base_ochan);
397da6c6874SJerin Jacob 	if (ret < 0) {
398da6c6874SJerin Jacob 		octeontx_log_err("fail to conf VF%d no. txq %d chan %d ret %d",
399da6c6874SJerin Jacob 			   nic->port_id, nic->num_tx_queues, nic->base_ochan,
400da6c6874SJerin Jacob 			   ret);
401da6c6874SJerin Jacob 		goto error;
402da6c6874SJerin Jacob 	}
403da6c6874SJerin Jacob 
404da6c6874SJerin Jacob 	/*
405da6c6874SJerin Jacob 	 * Rx start
406da6c6874SJerin Jacob 	 */
407da6c6874SJerin Jacob 	dev->rx_pkt_burst = octeontx_recv_pkts;
408da6c6874SJerin Jacob 	ret = octeontx_pki_port_start(nic->port_id);
409da6c6874SJerin Jacob 	if (ret < 0) {
410da6c6874SJerin Jacob 		octeontx_log_err("fail to start Rx on port %d", nic->port_id);
411da6c6874SJerin Jacob 		goto channel_stop_error;
412da6c6874SJerin Jacob 	}
413da6c6874SJerin Jacob 
414da6c6874SJerin Jacob 	/*
415da6c6874SJerin Jacob 	 * Start port
416da6c6874SJerin Jacob 	 */
417da6c6874SJerin Jacob 	ret = octeontx_port_start(nic);
418da6c6874SJerin Jacob 	if (ret < 0) {
419da6c6874SJerin Jacob 		octeontx_log_err("failed start port %d", ret);
420da6c6874SJerin Jacob 		goto pki_port_stop_error;
421da6c6874SJerin Jacob 	}
422da6c6874SJerin Jacob 
423da6c6874SJerin Jacob 	PMD_TX_LOG(DEBUG, "pko: start channel %d no.of txq %d port %d",
424da6c6874SJerin Jacob 			nic->base_ochan, nic->num_tx_queues, nic->port_id);
425da6c6874SJerin Jacob 
426da6c6874SJerin Jacob 	ret = rte_event_dev_start(nic->evdev);
427da6c6874SJerin Jacob 	if (ret < 0) {
428da6c6874SJerin Jacob 		octeontx_log_err("failed to start evdev: ret (%d)", ret);
429da6c6874SJerin Jacob 		goto pki_port_stop_error;
430da6c6874SJerin Jacob 	}
431da6c6874SJerin Jacob 
432da6c6874SJerin Jacob 	/* Success */
433da6c6874SJerin Jacob 	return ret;
434da6c6874SJerin Jacob 
435da6c6874SJerin Jacob pki_port_stop_error:
436da6c6874SJerin Jacob 	octeontx_pki_port_stop(nic->port_id);
437da6c6874SJerin Jacob channel_stop_error:
438da6c6874SJerin Jacob 	octeontx_pko_channel_stop(nic->base_ochan);
439da6c6874SJerin Jacob error:
440da6c6874SJerin Jacob 	return ret;
441da6c6874SJerin Jacob }
442da6c6874SJerin Jacob 
443da6c6874SJerin Jacob static void
444da6c6874SJerin Jacob octeontx_dev_stop(struct rte_eth_dev *dev)
445da6c6874SJerin Jacob {
446da6c6874SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
447da6c6874SJerin Jacob 	int ret;
448da6c6874SJerin Jacob 
449da6c6874SJerin Jacob 	PMD_INIT_FUNC_TRACE();
450da6c6874SJerin Jacob 
451da6c6874SJerin Jacob 	rte_event_dev_stop(nic->evdev);
452da6c6874SJerin Jacob 
453da6c6874SJerin Jacob 	ret = octeontx_port_stop(nic);
454da6c6874SJerin Jacob 	if (ret < 0) {
455da6c6874SJerin Jacob 		octeontx_log_err("failed to req stop port %d res=%d",
456da6c6874SJerin Jacob 					nic->port_id, ret);
457da6c6874SJerin Jacob 		return;
458da6c6874SJerin Jacob 	}
459da6c6874SJerin Jacob 
460da6c6874SJerin Jacob 	ret = octeontx_pki_port_stop(nic->port_id);
461da6c6874SJerin Jacob 	if (ret < 0) {
462da6c6874SJerin Jacob 		octeontx_log_err("failed to stop pki port %d res=%d",
463da6c6874SJerin Jacob 					nic->port_id, ret);
464da6c6874SJerin Jacob 		return;
465da6c6874SJerin Jacob 	}
466da6c6874SJerin Jacob 
467da6c6874SJerin Jacob 	ret = octeontx_pko_channel_stop(nic->base_ochan);
468da6c6874SJerin Jacob 	if (ret < 0) {
469da6c6874SJerin Jacob 		octeontx_log_err("failed to stop channel %d VF%d %d %d",
470da6c6874SJerin Jacob 			     nic->base_ochan, nic->port_id, nic->num_tx_queues,
471da6c6874SJerin Jacob 			     ret);
472da6c6874SJerin Jacob 		return;
473da6c6874SJerin Jacob 	}
474da6c6874SJerin Jacob 
475da6c6874SJerin Jacob 	dev->tx_pkt_burst = NULL;
476da6c6874SJerin Jacob 	dev->rx_pkt_burst = NULL;
477da6c6874SJerin Jacob }
478da6c6874SJerin Jacob 
479da6c6874SJerin Jacob static void
48015bce35bSJerin Jacob octeontx_dev_promisc_enable(struct rte_eth_dev *dev)
48115bce35bSJerin Jacob {
48215bce35bSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
48315bce35bSJerin Jacob 
48415bce35bSJerin Jacob 	PMD_INIT_FUNC_TRACE();
48515bce35bSJerin Jacob 	octeontx_port_promisc_set(nic, 1);
48615bce35bSJerin Jacob }
48715bce35bSJerin Jacob 
48815bce35bSJerin Jacob static void
48915bce35bSJerin Jacob octeontx_dev_promisc_disable(struct rte_eth_dev *dev)
49015bce35bSJerin Jacob {
49115bce35bSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
49215bce35bSJerin Jacob 
49315bce35bSJerin Jacob 	PMD_INIT_FUNC_TRACE();
49415bce35bSJerin Jacob 	octeontx_port_promisc_set(nic, 0);
49515bce35bSJerin Jacob }
49615bce35bSJerin Jacob 
4974fac7c0aSJerin Jacob static int
4984fac7c0aSJerin Jacob octeontx_port_link_status(struct octeontx_nic *nic)
4994fac7c0aSJerin Jacob {
5004fac7c0aSJerin Jacob 	int res;
5014fac7c0aSJerin Jacob 
5024fac7c0aSJerin Jacob 	PMD_INIT_FUNC_TRACE();
5034fac7c0aSJerin Jacob 	res = octeontx_bgx_port_link_status(nic->port_id);
5044fac7c0aSJerin Jacob 	if (res < 0) {
5054fac7c0aSJerin Jacob 		octeontx_log_err("failed to get port %d link status",
5064fac7c0aSJerin Jacob 				nic->port_id);
5074fac7c0aSJerin Jacob 		return res;
5084fac7c0aSJerin Jacob 	}
5094fac7c0aSJerin Jacob 
5104fac7c0aSJerin Jacob 	nic->link_up = (uint8_t)res;
5114fac7c0aSJerin Jacob 	octeontx_log_dbg("port %d link status %d", nic->port_id, nic->link_up);
5124fac7c0aSJerin Jacob 
5134fac7c0aSJerin Jacob 	return res;
5144fac7c0aSJerin Jacob }
5154fac7c0aSJerin Jacob 
5164fac7c0aSJerin Jacob /*
5174fac7c0aSJerin Jacob  * Return 0 means link status changed, -1 means not changed
5184fac7c0aSJerin Jacob  */
5194fac7c0aSJerin Jacob static int
5204fac7c0aSJerin Jacob octeontx_dev_link_update(struct rte_eth_dev *dev,
5214fac7c0aSJerin Jacob 			 int wait_to_complete __rte_unused)
5224fac7c0aSJerin Jacob {
5234fac7c0aSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
5244fac7c0aSJerin Jacob 	struct rte_eth_link link;
5254fac7c0aSJerin Jacob 	int res;
5264fac7c0aSJerin Jacob 
5274fac7c0aSJerin Jacob 	res = 0;
5284fac7c0aSJerin Jacob 	PMD_INIT_FUNC_TRACE();
5294fac7c0aSJerin Jacob 
5304fac7c0aSJerin Jacob 	res = octeontx_port_link_status(nic);
5314fac7c0aSJerin Jacob 	if (res < 0) {
5324fac7c0aSJerin Jacob 		octeontx_log_err("failed to request link status %d", res);
5334fac7c0aSJerin Jacob 		return res;
5344fac7c0aSJerin Jacob 	}
5354fac7c0aSJerin Jacob 
5364fac7c0aSJerin Jacob 	link.link_status = nic->link_up;
5374fac7c0aSJerin Jacob 
5384fac7c0aSJerin Jacob 	switch (nic->speed) {
5394fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_SGMII:
5404fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_1G;
5414fac7c0aSJerin Jacob 		break;
5424fac7c0aSJerin Jacob 
5434fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_XAUI:
5444fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_10G;
5454fac7c0aSJerin Jacob 		break;
5464fac7c0aSJerin Jacob 
5474fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_RXAUI:
5484fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_10G_R:
5494fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_10G;
5504fac7c0aSJerin Jacob 		break;
5514fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_QSGMII:
5524fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_5G;
5534fac7c0aSJerin Jacob 		break;
5544fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_40G_R:
5554fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_40G;
5564fac7c0aSJerin Jacob 		break;
5574fac7c0aSJerin Jacob 
5584fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_RESERVE1:
5594fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_RESERVE2:
5604fac7c0aSJerin Jacob 	default:
5614fac7c0aSJerin Jacob 		octeontx_log_err("incorrect link speed %d", nic->speed);
5624fac7c0aSJerin Jacob 		break;
5634fac7c0aSJerin Jacob 	}
5644fac7c0aSJerin Jacob 
5651e3a958fSThomas Monjalon 	link.link_duplex = ETH_LINK_FULL_DUPLEX;
5661e3a958fSThomas Monjalon 	link.link_autoneg = ETH_LINK_AUTONEG;
5674fac7c0aSJerin Jacob 
5682b4ab422SStephen Hemminger 	return rte_eth_linkstatus_set(dev, &link);
5694fac7c0aSJerin Jacob }
5704fac7c0aSJerin Jacob 
571d5b0924bSMatan Azrad static int
57255389909SJerin Jacob octeontx_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
57355389909SJerin Jacob {
57455389909SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
57555389909SJerin Jacob 
57655389909SJerin Jacob 	PMD_INIT_FUNC_TRACE();
577d5b0924bSMatan Azrad 	return octeontx_port_stats(nic, stats);
57855389909SJerin Jacob }
57955389909SJerin Jacob 
58055389909SJerin Jacob static void
58155389909SJerin Jacob octeontx_dev_stats_reset(struct rte_eth_dev *dev)
58255389909SJerin Jacob {
58355389909SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
58455389909SJerin Jacob 
58555389909SJerin Jacob 	PMD_INIT_FUNC_TRACE();
58655389909SJerin Jacob 	octeontx_port_stats_clr(nic);
58755389909SJerin Jacob }
58855389909SJerin Jacob 
58955389909SJerin Jacob static void
590ef7308fcSJerin Jacob octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
591ef7308fcSJerin Jacob 					struct ether_addr *addr)
592ef7308fcSJerin Jacob {
593ef7308fcSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
594ef7308fcSJerin Jacob 	int ret;
595ef7308fcSJerin Jacob 
596ef7308fcSJerin Jacob 	ret = octeontx_bgx_port_mac_set(nic->port_id, addr->addr_bytes);
597ef7308fcSJerin Jacob 	if (ret != 0)
598ef7308fcSJerin Jacob 		octeontx_log_err("failed to set MAC address on port %d",
599ef7308fcSJerin Jacob 				nic->port_id);
600ef7308fcSJerin Jacob }
601ef7308fcSJerin Jacob 
602ef7308fcSJerin Jacob static void
6037c0347a2SJerin Jacob octeontx_dev_info(struct rte_eth_dev *dev,
6047c0347a2SJerin Jacob 		struct rte_eth_dev_info *dev_info)
6057c0347a2SJerin Jacob {
6067c0347a2SJerin Jacob 	RTE_SET_USED(dev);
6077c0347a2SJerin Jacob 
6087c0347a2SJerin Jacob 	/* Autonegotiation may be disabled */
6097c0347a2SJerin Jacob 	dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
6107c0347a2SJerin Jacob 	dev_info->speed_capa |= ETH_LINK_SPEED_10M | ETH_LINK_SPEED_100M |
6117c0347a2SJerin Jacob 			ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
6127c0347a2SJerin Jacob 			ETH_LINK_SPEED_40G;
6137c0347a2SJerin Jacob 
6147c0347a2SJerin Jacob 	dev_info->driver_name = RTE_STR(rte_octeontx_pmd);
6157c0347a2SJerin Jacob 	dev_info->max_mac_addrs = 1;
6167c0347a2SJerin Jacob 	dev_info->max_rx_pktlen = PKI_MAX_PKTLEN;
6177c0347a2SJerin Jacob 	dev_info->max_rx_queues = 1;
6187c0347a2SJerin Jacob 	dev_info->max_tx_queues = PKO_MAX_NUM_DQ;
6197c0347a2SJerin Jacob 	dev_info->min_rx_bufsize = 0;
6207c0347a2SJerin Jacob 	dev_info->pci_dev = NULL;
6217c0347a2SJerin Jacob 
6227c0347a2SJerin Jacob 	dev_info->default_rxconf = (struct rte_eth_rxconf) {
6237c0347a2SJerin Jacob 		.rx_free_thresh = 0,
6247c0347a2SJerin Jacob 		.rx_drop_en = 0,
625*a9287089SPavan Nikhilesh 		.offloads = OCTEONTX_RX_OFFLOADS,
6267c0347a2SJerin Jacob 	};
6277c0347a2SJerin Jacob 
6287c0347a2SJerin Jacob 	dev_info->default_txconf = (struct rte_eth_txconf) {
6297c0347a2SJerin Jacob 		.tx_free_thresh = 0,
6307c0347a2SJerin Jacob 		.txq_flags =
6317c0347a2SJerin Jacob 			ETH_TXQ_FLAGS_NOMULTSEGS |
6327c0347a2SJerin Jacob 			ETH_TXQ_FLAGS_NOOFFLOADS |
6337c0347a2SJerin Jacob 			ETH_TXQ_FLAGS_NOXSUMS,
6347c0347a2SJerin Jacob 	};
6357c0347a2SJerin Jacob 
636*a9287089SPavan Nikhilesh 	dev_info->rx_offload_capa = OCTEONTX_RX_OFFLOADS;
637*a9287089SPavan Nikhilesh 	dev_info->tx_offload_capa = OCTEONTX_TX_OFFLOADS;
6387c0347a2SJerin Jacob }
6397c0347a2SJerin Jacob 
6407fe7c98fSJerin Jacob static void
6417fe7c98fSJerin Jacob octeontx_dq_info_getter(octeontx_dq_t *dq, void *out)
6427fe7c98fSJerin Jacob {
6437fe7c98fSJerin Jacob 	((octeontx_dq_t *)out)->lmtline_va = dq->lmtline_va;
6447fe7c98fSJerin Jacob 	((octeontx_dq_t *)out)->ioreg_va = dq->ioreg_va;
6457fe7c98fSJerin Jacob 	((octeontx_dq_t *)out)->fc_status_va = dq->fc_status_va;
6467fe7c98fSJerin Jacob }
6477fe7c98fSJerin Jacob 
6487fe7c98fSJerin Jacob static int
6497fe7c98fSJerin Jacob octeontx_vf_start_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic,
6507fe7c98fSJerin Jacob 				uint16_t qidx)
6517fe7c98fSJerin Jacob {
6527fe7c98fSJerin Jacob 	struct octeontx_txq *txq;
6537fe7c98fSJerin Jacob 	int res;
6547fe7c98fSJerin Jacob 
6557fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
6567fe7c98fSJerin Jacob 
6577fe7c98fSJerin Jacob 	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED)
6587fe7c98fSJerin Jacob 		return 0;
6597fe7c98fSJerin Jacob 
6607fe7c98fSJerin Jacob 	txq = dev->data->tx_queues[qidx];
6617fe7c98fSJerin Jacob 
6627fe7c98fSJerin Jacob 	res = octeontx_pko_channel_query_dqs(nic->base_ochan,
6637fe7c98fSJerin Jacob 						&txq->dq,
6647fe7c98fSJerin Jacob 						sizeof(octeontx_dq_t),
6657fe7c98fSJerin Jacob 						txq->queue_id,
6667fe7c98fSJerin Jacob 						octeontx_dq_info_getter);
6677fe7c98fSJerin Jacob 	if (res < 0) {
6687fe7c98fSJerin Jacob 		res = -EFAULT;
6697fe7c98fSJerin Jacob 		goto close_port;
6707fe7c98fSJerin Jacob 	}
6717fe7c98fSJerin Jacob 
6727fe7c98fSJerin Jacob 	dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
6737fe7c98fSJerin Jacob 	return res;
6747fe7c98fSJerin Jacob 
6757fe7c98fSJerin Jacob close_port:
6767fe7c98fSJerin Jacob 	(void)octeontx_port_stop(nic);
6777fe7c98fSJerin Jacob 	octeontx_pko_channel_stop(nic->base_ochan);
6787fe7c98fSJerin Jacob 	octeontx_pko_channel_close(nic->base_ochan);
6797fe7c98fSJerin Jacob 	dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
6807fe7c98fSJerin Jacob 	return res;
6817fe7c98fSJerin Jacob }
6827fe7c98fSJerin Jacob 
6837fe7c98fSJerin Jacob static int
6847fe7c98fSJerin Jacob octeontx_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
6857fe7c98fSJerin Jacob {
6867fe7c98fSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
6877fe7c98fSJerin Jacob 
6887fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
6897fe7c98fSJerin Jacob 	qidx = qidx % PKO_VF_NUM_DQ;
6907fe7c98fSJerin Jacob 	return octeontx_vf_start_tx_queue(dev, nic, qidx);
6917fe7c98fSJerin Jacob }
6927fe7c98fSJerin Jacob 
6937fe7c98fSJerin Jacob static inline int
6947fe7c98fSJerin Jacob octeontx_vf_stop_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic,
6957fe7c98fSJerin Jacob 			  uint16_t qidx)
6967fe7c98fSJerin Jacob {
6977fe7c98fSJerin Jacob 	int ret = 0;
6987fe7c98fSJerin Jacob 
6997fe7c98fSJerin Jacob 	RTE_SET_USED(nic);
7007fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
7017fe7c98fSJerin Jacob 
7027fe7c98fSJerin Jacob 	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
7037fe7c98fSJerin Jacob 		return 0;
7047fe7c98fSJerin Jacob 
7057fe7c98fSJerin Jacob 	dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
7067fe7c98fSJerin Jacob 	return ret;
7077fe7c98fSJerin Jacob }
7087fe7c98fSJerin Jacob 
7097fe7c98fSJerin Jacob static int
7107fe7c98fSJerin Jacob octeontx_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
7117fe7c98fSJerin Jacob {
7127fe7c98fSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
7137fe7c98fSJerin Jacob 
7147fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
7157fe7c98fSJerin Jacob 	qidx = qidx % PKO_VF_NUM_DQ;
7167fe7c98fSJerin Jacob 
7177fe7c98fSJerin Jacob 	return octeontx_vf_stop_tx_queue(dev, nic, qidx);
7187fe7c98fSJerin Jacob }
7197fe7c98fSJerin Jacob 
720150cbc84SJerin Jacob static void
721150cbc84SJerin Jacob octeontx_dev_tx_queue_release(void *tx_queue)
722150cbc84SJerin Jacob {
723150cbc84SJerin Jacob 	struct octeontx_txq *txq = tx_queue;
724150cbc84SJerin Jacob 	int res;
725150cbc84SJerin Jacob 
726150cbc84SJerin Jacob 	PMD_INIT_FUNC_TRACE();
727150cbc84SJerin Jacob 
728150cbc84SJerin Jacob 	if (txq) {
729150cbc84SJerin Jacob 		res = octeontx_dev_tx_queue_stop(txq->eth_dev, txq->queue_id);
730150cbc84SJerin Jacob 		if (res < 0)
731150cbc84SJerin Jacob 			octeontx_log_err("failed stop tx_queue(%d)\n",
732150cbc84SJerin Jacob 				   txq->queue_id);
733150cbc84SJerin Jacob 
734150cbc84SJerin Jacob 		rte_free(txq);
735150cbc84SJerin Jacob 	}
736150cbc84SJerin Jacob }
737150cbc84SJerin Jacob 
738150cbc84SJerin Jacob static int
739150cbc84SJerin Jacob octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
740150cbc84SJerin Jacob 			    uint16_t nb_desc, unsigned int socket_id,
741150cbc84SJerin Jacob 			    const struct rte_eth_txconf *tx_conf)
742150cbc84SJerin Jacob {
743150cbc84SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
744150cbc84SJerin Jacob 	struct octeontx_txq *txq = NULL;
745150cbc84SJerin Jacob 	uint16_t dq_num;
746150cbc84SJerin Jacob 	int res = 0;
747*a9287089SPavan Nikhilesh 	uint64_t configured_offloads;
748*a9287089SPavan Nikhilesh 	uint64_t unsupported_offloads;
749150cbc84SJerin Jacob 
750150cbc84SJerin Jacob 	RTE_SET_USED(nb_desc);
751150cbc84SJerin Jacob 	RTE_SET_USED(socket_id);
752150cbc84SJerin Jacob 
753150cbc84SJerin Jacob 	dq_num = (nic->port_id * PKO_VF_NUM_DQ) + qidx;
754150cbc84SJerin Jacob 
755150cbc84SJerin Jacob 	/* Socket id check */
756150cbc84SJerin Jacob 	if (socket_id != (unsigned int)SOCKET_ID_ANY &&
757150cbc84SJerin Jacob 			socket_id != (unsigned int)nic->node)
758150cbc84SJerin Jacob 		PMD_TX_LOG(INFO, "socket_id expected %d, configured %d",
759150cbc84SJerin Jacob 						socket_id, nic->node);
760150cbc84SJerin Jacob 
761150cbc84SJerin Jacob 	/* Free memory prior to re-allocation if needed. */
762150cbc84SJerin Jacob 	if (dev->data->tx_queues[qidx] != NULL) {
763150cbc84SJerin Jacob 		PMD_TX_LOG(DEBUG, "freeing memory prior to re-allocation %d",
764150cbc84SJerin Jacob 				qidx);
765150cbc84SJerin Jacob 		octeontx_dev_tx_queue_release(dev->data->tx_queues[qidx]);
766150cbc84SJerin Jacob 		dev->data->tx_queues[qidx] = NULL;
767150cbc84SJerin Jacob 	}
768150cbc84SJerin Jacob 
769*a9287089SPavan Nikhilesh 	configured_offloads = tx_conf->offloads;
770*a9287089SPavan Nikhilesh 
771*a9287089SPavan Nikhilesh 	if (!(configured_offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) {
772*a9287089SPavan Nikhilesh 		PMD_INIT_LOG(NOTICE, "cant disable lockfree tx");
773*a9287089SPavan Nikhilesh 		configured_offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE;
774*a9287089SPavan Nikhilesh 	}
775*a9287089SPavan Nikhilesh 
776*a9287089SPavan Nikhilesh 	unsupported_offloads = configured_offloads & ~OCTEONTX_TX_OFFLOADS;
777*a9287089SPavan Nikhilesh 	if (unsupported_offloads) {
778*a9287089SPavan Nikhilesh 		PMD_INIT_LOG(ERR, "Tx offloads 0x%" PRIx64 " are not supported."
779*a9287089SPavan Nikhilesh 		      "Requested 0x%" PRIx64 " supported 0x%" PRIx64 ".\n",
780*a9287089SPavan Nikhilesh 		      unsupported_offloads, configured_offloads,
781*a9287089SPavan Nikhilesh 		      (uint64_t)OCTEONTX_TX_OFFLOADS);
782*a9287089SPavan Nikhilesh 		return -ENOTSUP;
783*a9287089SPavan Nikhilesh 	}
784*a9287089SPavan Nikhilesh 
785150cbc84SJerin Jacob 	/* Allocating tx queue data structure */
786150cbc84SJerin Jacob 	txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct octeontx_txq),
787150cbc84SJerin Jacob 				 RTE_CACHE_LINE_SIZE, nic->node);
788150cbc84SJerin Jacob 	if (txq == NULL) {
789150cbc84SJerin Jacob 		octeontx_log_err("failed to allocate txq=%d", qidx);
790150cbc84SJerin Jacob 		res = -ENOMEM;
791150cbc84SJerin Jacob 		goto err;
792150cbc84SJerin Jacob 	}
793150cbc84SJerin Jacob 
794150cbc84SJerin Jacob 	txq->eth_dev = dev;
795150cbc84SJerin Jacob 	txq->queue_id = dq_num;
796150cbc84SJerin Jacob 	dev->data->tx_queues[qidx] = txq;
797150cbc84SJerin Jacob 	dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
798150cbc84SJerin Jacob 
799150cbc84SJerin Jacob 	res = octeontx_pko_channel_query_dqs(nic->base_ochan,
800150cbc84SJerin Jacob 						&txq->dq,
801150cbc84SJerin Jacob 						sizeof(octeontx_dq_t),
802150cbc84SJerin Jacob 						txq->queue_id,
803150cbc84SJerin Jacob 						octeontx_dq_info_getter);
804150cbc84SJerin Jacob 	if (res < 0) {
805150cbc84SJerin Jacob 		res = -EFAULT;
806150cbc84SJerin Jacob 		goto err;
807150cbc84SJerin Jacob 	}
808150cbc84SJerin Jacob 
809150cbc84SJerin Jacob 	PMD_TX_LOG(DEBUG, "[%d]:[%d] txq=%p nb_desc=%d lmtline=%p ioreg_va=%p fc_status_va=%p",
810150cbc84SJerin Jacob 			qidx, txq->queue_id, txq, nb_desc, txq->dq.lmtline_va,
811150cbc84SJerin Jacob 			txq->dq.ioreg_va,
812150cbc84SJerin Jacob 			txq->dq.fc_status_va);
813150cbc84SJerin Jacob 
814150cbc84SJerin Jacob 	return res;
815150cbc84SJerin Jacob 
816150cbc84SJerin Jacob err:
817150cbc84SJerin Jacob 	if (txq)
818150cbc84SJerin Jacob 		rte_free(txq);
819150cbc84SJerin Jacob 
820150cbc84SJerin Jacob 	return res;
821150cbc84SJerin Jacob }
822150cbc84SJerin Jacob 
823197438eeSJerin Jacob static int
824197438eeSJerin Jacob octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
825197438eeSJerin Jacob 				uint16_t nb_desc, unsigned int socket_id,
826197438eeSJerin Jacob 				const struct rte_eth_rxconf *rx_conf,
827197438eeSJerin Jacob 				struct rte_mempool *mb_pool)
828197438eeSJerin Jacob {
829197438eeSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
830197438eeSJerin Jacob 	struct rte_mempool_ops *mp_ops = NULL;
831197438eeSJerin Jacob 	struct octeontx_rxq *rxq = NULL;
832197438eeSJerin Jacob 	pki_pktbuf_cfg_t pktbuf_conf;
833197438eeSJerin Jacob 	pki_hash_cfg_t pki_hash;
834197438eeSJerin Jacob 	pki_qos_cfg_t pki_qos;
835197438eeSJerin Jacob 	uintptr_t pool;
836197438eeSJerin Jacob 	int ret, port;
837197438eeSJerin Jacob 	uint8_t gaura;
838197438eeSJerin Jacob 	unsigned int ev_queues = (nic->ev_queues * nic->port_id) + qidx;
839197438eeSJerin Jacob 	unsigned int ev_ports = (nic->ev_ports * nic->port_id) + qidx;
840*a9287089SPavan Nikhilesh 	uint64_t configured_offloads;
841*a9287089SPavan Nikhilesh 	uint64_t unsupported_offloads;
842197438eeSJerin Jacob 
843197438eeSJerin Jacob 	RTE_SET_USED(nb_desc);
844197438eeSJerin Jacob 
845197438eeSJerin Jacob 	memset(&pktbuf_conf, 0, sizeof(pktbuf_conf));
846197438eeSJerin Jacob 	memset(&pki_hash, 0, sizeof(pki_hash));
847197438eeSJerin Jacob 	memset(&pki_qos, 0, sizeof(pki_qos));
848197438eeSJerin Jacob 
849197438eeSJerin Jacob 	mp_ops = rte_mempool_get_ops(mb_pool->ops_index);
850197438eeSJerin Jacob 	if (strcmp(mp_ops->name, "octeontx_fpavf")) {
851197438eeSJerin Jacob 		octeontx_log_err("failed to find octeontx_fpavf mempool");
852197438eeSJerin Jacob 		return -ENOTSUP;
853197438eeSJerin Jacob 	}
854197438eeSJerin Jacob 
855197438eeSJerin Jacob 	/* Handle forbidden configurations */
856197438eeSJerin Jacob 	if (nic->pki.classifier_enable) {
857197438eeSJerin Jacob 		octeontx_log_err("cannot setup queue %d. "
858197438eeSJerin Jacob 					"Classifier option unsupported", qidx);
859197438eeSJerin Jacob 		return -EINVAL;
860197438eeSJerin Jacob 	}
861197438eeSJerin Jacob 
862197438eeSJerin Jacob 	port = nic->port_id;
863197438eeSJerin Jacob 
864*a9287089SPavan Nikhilesh 	configured_offloads = rx_conf->offloads;
865*a9287089SPavan Nikhilesh 
866*a9287089SPavan Nikhilesh 	if (!(configured_offloads & DEV_RX_OFFLOAD_CRC_STRIP)) {
867*a9287089SPavan Nikhilesh 		PMD_INIT_LOG(NOTICE, "can't disable hw crc strip");
868*a9287089SPavan Nikhilesh 		configured_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
869*a9287089SPavan Nikhilesh 	}
870*a9287089SPavan Nikhilesh 
871*a9287089SPavan Nikhilesh 	unsupported_offloads = configured_offloads & ~OCTEONTX_RX_OFFLOADS;
872*a9287089SPavan Nikhilesh 
873*a9287089SPavan Nikhilesh 	if (unsupported_offloads) {
874*a9287089SPavan Nikhilesh 		PMD_INIT_LOG(ERR, "Rx offloads 0x%" PRIx64 " are not supported. "
875*a9287089SPavan Nikhilesh 		      "Requested 0x%" PRIx64 " supported 0x%" PRIx64 "\n",
876*a9287089SPavan Nikhilesh 		      unsupported_offloads, configured_offloads,
877*a9287089SPavan Nikhilesh 		      (uint64_t)OCTEONTX_RX_OFFLOADS);
878*a9287089SPavan Nikhilesh 		return -ENOTSUP;
879*a9287089SPavan Nikhilesh 	}
880197438eeSJerin Jacob 	/* Rx deferred start is not supported */
881197438eeSJerin Jacob 	if (rx_conf->rx_deferred_start) {
882197438eeSJerin Jacob 		octeontx_log_err("rx deferred start not supported");
883197438eeSJerin Jacob 		return -EINVAL;
884197438eeSJerin Jacob 	}
885197438eeSJerin Jacob 
886197438eeSJerin Jacob 	/* Verify queue index */
887197438eeSJerin Jacob 	if (qidx >= dev->data->nb_rx_queues) {
888197438eeSJerin Jacob 		octeontx_log_err("QID %d not supporteded (0 - %d available)\n",
889197438eeSJerin Jacob 				qidx, (dev->data->nb_rx_queues - 1));
890197438eeSJerin Jacob 		return -ENOTSUP;
891197438eeSJerin Jacob 	}
892197438eeSJerin Jacob 
893197438eeSJerin Jacob 	/* Socket id check */
894197438eeSJerin Jacob 	if (socket_id != (unsigned int)SOCKET_ID_ANY &&
895197438eeSJerin Jacob 			socket_id != (unsigned int)nic->node)
896197438eeSJerin Jacob 		PMD_RX_LOG(INFO, "socket_id expected %d, configured %d",
897197438eeSJerin Jacob 						socket_id, nic->node);
898197438eeSJerin Jacob 
899197438eeSJerin Jacob 	/* Allocating rx queue data structure */
900197438eeSJerin Jacob 	rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct octeontx_rxq),
901197438eeSJerin Jacob 				 RTE_CACHE_LINE_SIZE, nic->node);
902197438eeSJerin Jacob 	if (rxq == NULL) {
903197438eeSJerin Jacob 		octeontx_log_err("failed to allocate rxq=%d", qidx);
904197438eeSJerin Jacob 		return -ENOMEM;
905197438eeSJerin Jacob 	}
906197438eeSJerin Jacob 
907197438eeSJerin Jacob 	if (!nic->pki.initialized) {
908197438eeSJerin Jacob 		pktbuf_conf.port_type = 0;
909197438eeSJerin Jacob 		pki_hash.port_type = 0;
910197438eeSJerin Jacob 		pki_qos.port_type = 0;
911197438eeSJerin Jacob 
912197438eeSJerin Jacob 		pktbuf_conf.mmask.f_wqe_skip = 1;
913197438eeSJerin Jacob 		pktbuf_conf.mmask.f_first_skip = 1;
914197438eeSJerin Jacob 		pktbuf_conf.mmask.f_later_skip = 1;
915197438eeSJerin Jacob 		pktbuf_conf.mmask.f_mbuff_size = 1;
916197438eeSJerin Jacob 		pktbuf_conf.mmask.f_cache_mode = 1;
917197438eeSJerin Jacob 
918197438eeSJerin Jacob 		pktbuf_conf.wqe_skip = OCTTX_PACKET_WQE_SKIP;
919197438eeSJerin Jacob 		pktbuf_conf.first_skip = OCTTX_PACKET_FIRST_SKIP;
920197438eeSJerin Jacob 		pktbuf_conf.later_skip = OCTTX_PACKET_LATER_SKIP;
921197438eeSJerin Jacob 		pktbuf_conf.mbuff_size = (mb_pool->elt_size -
922197438eeSJerin Jacob 					RTE_PKTMBUF_HEADROOM -
923197438eeSJerin Jacob 					sizeof(struct rte_mbuf));
924197438eeSJerin Jacob 
925197438eeSJerin Jacob 		pktbuf_conf.cache_mode = PKI_OPC_MODE_STF2_STT;
926197438eeSJerin Jacob 
927197438eeSJerin Jacob 		ret = octeontx_pki_port_pktbuf_config(port, &pktbuf_conf);
928197438eeSJerin Jacob 		if (ret != 0) {
929197438eeSJerin Jacob 			octeontx_log_err("fail to configure pktbuf for port %d",
930197438eeSJerin Jacob 					port);
931197438eeSJerin Jacob 			rte_free(rxq);
932197438eeSJerin Jacob 			return ret;
933197438eeSJerin Jacob 		}
934197438eeSJerin Jacob 		PMD_RX_LOG(DEBUG, "Port %d Rx pktbuf configured:\n"
935197438eeSJerin Jacob 				"\tmbuf_size:\t0x%0x\n"
936197438eeSJerin Jacob 				"\twqe_skip:\t0x%0x\n"
937197438eeSJerin Jacob 				"\tfirst_skip:\t0x%0x\n"
938197438eeSJerin Jacob 				"\tlater_skip:\t0x%0x\n"
939197438eeSJerin Jacob 				"\tcache_mode:\t%s\n",
940197438eeSJerin Jacob 				port,
941197438eeSJerin Jacob 				pktbuf_conf.mbuff_size,
942197438eeSJerin Jacob 				pktbuf_conf.wqe_skip,
943197438eeSJerin Jacob 				pktbuf_conf.first_skip,
944197438eeSJerin Jacob 				pktbuf_conf.later_skip,
945197438eeSJerin Jacob 				(pktbuf_conf.cache_mode ==
946197438eeSJerin Jacob 						PKI_OPC_MODE_STT) ?
947197438eeSJerin Jacob 				"STT" :
948197438eeSJerin Jacob 				(pktbuf_conf.cache_mode ==
949197438eeSJerin Jacob 						PKI_OPC_MODE_STF) ?
950197438eeSJerin Jacob 				"STF" :
951197438eeSJerin Jacob 				(pktbuf_conf.cache_mode ==
952197438eeSJerin Jacob 						PKI_OPC_MODE_STF1_STT) ?
953197438eeSJerin Jacob 				"STF1_STT" : "STF2_STT");
954197438eeSJerin Jacob 
955197438eeSJerin Jacob 		if (nic->pki.hash_enable) {
956197438eeSJerin Jacob 			pki_hash.tag_dlc = 1;
957197438eeSJerin Jacob 			pki_hash.tag_slc = 1;
958197438eeSJerin Jacob 			pki_hash.tag_dlf = 1;
959197438eeSJerin Jacob 			pki_hash.tag_slf = 1;
960d0d65498SPavan Nikhilesh 			pki_hash.tag_prt = 1;
961197438eeSJerin Jacob 			octeontx_pki_port_hash_config(port, &pki_hash);
962197438eeSJerin Jacob 		}
963197438eeSJerin Jacob 
964197438eeSJerin Jacob 		pool = (uintptr_t)mb_pool->pool_id;
965197438eeSJerin Jacob 
966197438eeSJerin Jacob 		/* Get the gpool Id */
967197438eeSJerin Jacob 		gaura = octeontx_fpa_bufpool_gpool(pool);
968197438eeSJerin Jacob 
969197438eeSJerin Jacob 		pki_qos.qpg_qos = PKI_QPG_QOS_NONE;
970197438eeSJerin Jacob 		pki_qos.num_entry = 1;
971197438eeSJerin Jacob 		pki_qos.drop_policy = 0;
972d0d65498SPavan Nikhilesh 		pki_qos.tag_type = 0L;
973197438eeSJerin Jacob 		pki_qos.qos_entry[0].port_add = 0;
974197438eeSJerin Jacob 		pki_qos.qos_entry[0].gaura = gaura;
975197438eeSJerin Jacob 		pki_qos.qos_entry[0].ggrp_ok = ev_queues;
976197438eeSJerin Jacob 		pki_qos.qos_entry[0].ggrp_bad = ev_queues;
977197438eeSJerin Jacob 		pki_qos.qos_entry[0].grptag_bad = 0;
978197438eeSJerin Jacob 		pki_qos.qos_entry[0].grptag_ok = 0;
979197438eeSJerin Jacob 
980197438eeSJerin Jacob 		ret = octeontx_pki_port_create_qos(port, &pki_qos);
981197438eeSJerin Jacob 		if (ret < 0) {
982197438eeSJerin Jacob 			octeontx_log_err("failed to create QOS port=%d, q=%d",
983197438eeSJerin Jacob 					port, qidx);
984197438eeSJerin Jacob 			rte_free(rxq);
985197438eeSJerin Jacob 			return ret;
986197438eeSJerin Jacob 		}
987197438eeSJerin Jacob 		nic->pki.initialized = true;
988197438eeSJerin Jacob 	}
989197438eeSJerin Jacob 
990197438eeSJerin Jacob 	rxq->port_id = nic->port_id;
991197438eeSJerin Jacob 	rxq->eth_dev = dev;
992197438eeSJerin Jacob 	rxq->queue_id = qidx;
993197438eeSJerin Jacob 	rxq->evdev = nic->evdev;
994197438eeSJerin Jacob 	rxq->ev_queues = ev_queues;
995197438eeSJerin Jacob 	rxq->ev_ports = ev_ports;
996197438eeSJerin Jacob 
997197438eeSJerin Jacob 	dev->data->rx_queues[qidx] = rxq;
998197438eeSJerin Jacob 	dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
999197438eeSJerin Jacob 	return 0;
1000197438eeSJerin Jacob }
1001197438eeSJerin Jacob 
1002197438eeSJerin Jacob static void
1003197438eeSJerin Jacob octeontx_dev_rx_queue_release(void *rxq)
1004197438eeSJerin Jacob {
1005197438eeSJerin Jacob 	rte_free(rxq);
1006197438eeSJerin Jacob }
1007197438eeSJerin Jacob 
100820186d43SJerin Jacob static const uint32_t *
100920186d43SJerin Jacob octeontx_dev_supported_ptypes_get(struct rte_eth_dev *dev)
101020186d43SJerin Jacob {
101120186d43SJerin Jacob 	static const uint32_t ptypes[] = {
101220186d43SJerin Jacob 		RTE_PTYPE_L3_IPV4,
101320186d43SJerin Jacob 		RTE_PTYPE_L3_IPV4_EXT,
101420186d43SJerin Jacob 		RTE_PTYPE_L3_IPV6,
101520186d43SJerin Jacob 		RTE_PTYPE_L3_IPV6_EXT,
101620186d43SJerin Jacob 		RTE_PTYPE_L4_TCP,
101720186d43SJerin Jacob 		RTE_PTYPE_L4_UDP,
101820186d43SJerin Jacob 		RTE_PTYPE_L4_FRAG,
101920186d43SJerin Jacob 		RTE_PTYPE_UNKNOWN
102020186d43SJerin Jacob 	};
102120186d43SJerin Jacob 
102220186d43SJerin Jacob 	if (dev->rx_pkt_burst == octeontx_recv_pkts)
102320186d43SJerin Jacob 		return ptypes;
102420186d43SJerin Jacob 
102520186d43SJerin Jacob 	return NULL;
102620186d43SJerin Jacob }
102720186d43SJerin Jacob 
10285452a17dSPavan Nikhilesh static int
10295452a17dSPavan Nikhilesh octeontx_pool_ops(struct rte_eth_dev *dev, const char *pool)
10305452a17dSPavan Nikhilesh {
10315452a17dSPavan Nikhilesh 	RTE_SET_USED(dev);
10325452a17dSPavan Nikhilesh 
10335452a17dSPavan Nikhilesh 	if (!strcmp(pool, "octeontx_fpavf"))
10345452a17dSPavan Nikhilesh 		return 0;
10355452a17dSPavan Nikhilesh 
10365452a17dSPavan Nikhilesh 	return -ENOTSUP;
10375452a17dSPavan Nikhilesh }
10385452a17dSPavan Nikhilesh 
1039f18b146cSJerin Jacob /* Initialize and register driver with DPDK Application */
1040f18b146cSJerin Jacob static const struct eth_dev_ops octeontx_dev_ops = {
10417742c55aSJerin Jacob 	.dev_configure		 = octeontx_dev_configure,
10427c0347a2SJerin Jacob 	.dev_infos_get		 = octeontx_dev_info,
1043da6c6874SJerin Jacob 	.dev_close		 = octeontx_dev_close,
1044da6c6874SJerin Jacob 	.dev_start		 = octeontx_dev_start,
1045da6c6874SJerin Jacob 	.dev_stop		 = octeontx_dev_stop,
104615bce35bSJerin Jacob 	.promiscuous_enable	 = octeontx_dev_promisc_enable,
104715bce35bSJerin Jacob 	.promiscuous_disable	 = octeontx_dev_promisc_disable,
10484fac7c0aSJerin Jacob 	.link_update		 = octeontx_dev_link_update,
104955389909SJerin Jacob 	.stats_get		 = octeontx_dev_stats_get,
105055389909SJerin Jacob 	.stats_reset		 = octeontx_dev_stats_reset,
1051ef7308fcSJerin Jacob 	.mac_addr_set		 = octeontx_dev_default_mac_addr_set,
10527fe7c98fSJerin Jacob 	.tx_queue_start		 = octeontx_dev_tx_queue_start,
10537fe7c98fSJerin Jacob 	.tx_queue_stop		 = octeontx_dev_tx_queue_stop,
1054150cbc84SJerin Jacob 	.tx_queue_setup		 = octeontx_dev_tx_queue_setup,
1055150cbc84SJerin Jacob 	.tx_queue_release	 = octeontx_dev_tx_queue_release,
1056197438eeSJerin Jacob 	.rx_queue_setup		 = octeontx_dev_rx_queue_setup,
1057197438eeSJerin Jacob 	.rx_queue_release	 = octeontx_dev_rx_queue_release,
105820186d43SJerin Jacob 	.dev_supported_ptypes_get = octeontx_dev_supported_ptypes_get,
10595452a17dSPavan Nikhilesh 	.pool_ops_supported      = octeontx_pool_ops,
1060f18b146cSJerin Jacob };
1061f18b146cSJerin Jacob 
1062f7be70e5SJerin Jacob /* Create Ethdev interface per BGX LMAC ports */
1063f7be70e5SJerin Jacob static int
1064f7be70e5SJerin Jacob octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
1065f7be70e5SJerin Jacob 			int socket_id)
1066f7be70e5SJerin Jacob {
1067f18b146cSJerin Jacob 	int res;
1068f18b146cSJerin Jacob 	char octtx_name[OCTEONTX_MAX_NAME_LEN];
1069f18b146cSJerin Jacob 	struct octeontx_nic *nic = NULL;
1070f18b146cSJerin Jacob 	struct rte_eth_dev *eth_dev = NULL;
1071f18b146cSJerin Jacob 	struct rte_eth_dev_data *data = NULL;
1072f18b146cSJerin Jacob 	const char *name = rte_vdev_device_name(dev);
1073f7be70e5SJerin Jacob 
1074f18b146cSJerin Jacob 	PMD_INIT_FUNC_TRACE();
1075f18b146cSJerin Jacob 
1076f18b146cSJerin Jacob 	sprintf(octtx_name, "%s_%d", name, port);
1077f18b146cSJerin Jacob 	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1078f18b146cSJerin Jacob 		eth_dev = rte_eth_dev_attach_secondary(octtx_name);
1079f18b146cSJerin Jacob 		if (eth_dev == NULL)
1080f7be70e5SJerin Jacob 			return -ENODEV;
1081f18b146cSJerin Jacob 
1082da6c6874SJerin Jacob 		eth_dev->tx_pkt_burst = octeontx_xmit_pkts;
1083da6c6874SJerin Jacob 		eth_dev->rx_pkt_burst = octeontx_recv_pkts;
1084f18b146cSJerin Jacob 		return 0;
1085f18b146cSJerin Jacob 	}
1086f18b146cSJerin Jacob 
1087f18b146cSJerin Jacob 	data = rte_zmalloc_socket(octtx_name, sizeof(*data), 0, socket_id);
1088f18b146cSJerin Jacob 	if (data == NULL) {
1089f18b146cSJerin Jacob 		octeontx_log_err("failed to allocate devdata");
1090f18b146cSJerin Jacob 		res = -ENOMEM;
1091f18b146cSJerin Jacob 		goto err;
1092f18b146cSJerin Jacob 	}
1093f18b146cSJerin Jacob 
1094f18b146cSJerin Jacob 	nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id);
1095f18b146cSJerin Jacob 	if (nic == NULL) {
1096f18b146cSJerin Jacob 		octeontx_log_err("failed to allocate nic structure");
1097f18b146cSJerin Jacob 		res = -ENOMEM;
1098f18b146cSJerin Jacob 		goto err;
1099f18b146cSJerin Jacob 	}
1100f18b146cSJerin Jacob 
1101f18b146cSJerin Jacob 	nic->port_id = port;
1102f18b146cSJerin Jacob 	nic->evdev = evdev;
1103f18b146cSJerin Jacob 
1104f18b146cSJerin Jacob 	res = octeontx_port_open(nic);
1105f18b146cSJerin Jacob 	if (res < 0)
1106f18b146cSJerin Jacob 		goto err;
1107f18b146cSJerin Jacob 
1108f18b146cSJerin Jacob 	/* Rx side port configuration */
1109f18b146cSJerin Jacob 	res = octeontx_pki_port_open(port);
1110f18b146cSJerin Jacob 	if (res != 0) {
1111f18b146cSJerin Jacob 		octeontx_log_err("failed to open PKI port %d", port);
1112f18b146cSJerin Jacob 		res = -ENODEV;
1113f18b146cSJerin Jacob 		goto err;
1114f18b146cSJerin Jacob 	}
1115f18b146cSJerin Jacob 
1116f18b146cSJerin Jacob 	/* Reserve an ethdev entry */
1117f18b146cSJerin Jacob 	eth_dev = rte_eth_dev_allocate(octtx_name);
1118f18b146cSJerin Jacob 	if (eth_dev == NULL) {
1119f18b146cSJerin Jacob 		octeontx_log_err("failed to allocate rte_eth_dev");
1120f18b146cSJerin Jacob 		res = -ENOMEM;
1121f18b146cSJerin Jacob 		goto err;
1122f18b146cSJerin Jacob 	}
1123f18b146cSJerin Jacob 
1124f18b146cSJerin Jacob 	eth_dev->device = &dev->device;
1125f18b146cSJerin Jacob 	eth_dev->intr_handle = NULL;
1126f18b146cSJerin Jacob 	eth_dev->data->kdrv = RTE_KDRV_NONE;
1127f18b146cSJerin Jacob 	eth_dev->data->numa_node = dev->device.numa_node;
1128f18b146cSJerin Jacob 
1129f18b146cSJerin Jacob 	rte_memcpy(data, (eth_dev)->data, sizeof(*data));
1130f18b146cSJerin Jacob 	data->dev_private = nic;
1131f18b146cSJerin Jacob 
1132f18b146cSJerin Jacob 	data->port_id = eth_dev->data->port_id;
1133f18b146cSJerin Jacob 	snprintf(data->name, sizeof(data->name), "%s", eth_dev->data->name);
1134f18b146cSJerin Jacob 
1135f18b146cSJerin Jacob 	nic->ev_queues = 1;
1136f18b146cSJerin Jacob 	nic->ev_ports = 1;
1137f18b146cSJerin Jacob 
1138f18b146cSJerin Jacob 	data->dev_link.link_status = ETH_LINK_DOWN;
1139f18b146cSJerin Jacob 	data->dev_started = 0;
1140f18b146cSJerin Jacob 	data->promiscuous = 0;
1141f18b146cSJerin Jacob 	data->all_multicast = 0;
1142f18b146cSJerin Jacob 	data->scattered_rx = 0;
1143f18b146cSJerin Jacob 
1144f18b146cSJerin Jacob 	data->mac_addrs = rte_zmalloc_socket(octtx_name, ETHER_ADDR_LEN, 0,
1145f18b146cSJerin Jacob 							socket_id);
1146f18b146cSJerin Jacob 	if (data->mac_addrs == NULL) {
1147f18b146cSJerin Jacob 		octeontx_log_err("failed to allocate memory for mac_addrs");
1148f18b146cSJerin Jacob 		res = -ENOMEM;
1149f18b146cSJerin Jacob 		goto err;
1150f18b146cSJerin Jacob 	}
1151f18b146cSJerin Jacob 
1152f18b146cSJerin Jacob 	eth_dev->data = data;
1153f18b146cSJerin Jacob 	eth_dev->dev_ops = &octeontx_dev_ops;
1154f18b146cSJerin Jacob 
1155f18b146cSJerin Jacob 	/* Finally save ethdev pointer to the NIC structure */
1156f18b146cSJerin Jacob 	nic->dev = eth_dev;
1157f18b146cSJerin Jacob 
1158f18b146cSJerin Jacob 	if (nic->port_id != data->port_id) {
1159f18b146cSJerin Jacob 		octeontx_log_err("eth_dev->port_id (%d) is diff to orig (%d)",
1160f18b146cSJerin Jacob 				data->port_id, nic->port_id);
1161f18b146cSJerin Jacob 		res = -EINVAL;
1162f18b146cSJerin Jacob 		goto err;
1163f18b146cSJerin Jacob 	}
1164f18b146cSJerin Jacob 
1165f18b146cSJerin Jacob 	/* Update port_id mac to eth_dev */
1166f18b146cSJerin Jacob 	memcpy(data->mac_addrs, nic->mac_addr, ETHER_ADDR_LEN);
1167f18b146cSJerin Jacob 
1168f18b146cSJerin Jacob 	PMD_INIT_LOG(DEBUG, "ethdev info: ");
1169f18b146cSJerin Jacob 	PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d",
1170f18b146cSJerin Jacob 				nic->port_id, nic->port_ena,
1171f18b146cSJerin Jacob 				nic->base_ochan, nic->num_ochans,
1172f18b146cSJerin Jacob 				nic->num_tx_queues);
1173f18b146cSJerin Jacob 	PMD_INIT_LOG(DEBUG, "speed %d mtu %d", nic->speed, nic->mtu);
1174f18b146cSJerin Jacob 
1175989d4926SPavan Nikhilesh 	rte_octeontx_pchan_map[(nic->base_ochan >> 8) & 0x7]
1176989d4926SPavan Nikhilesh 		[(nic->base_ochan >> 4) & 0xF] = data->port_id;
1177989d4926SPavan Nikhilesh 
1178f18b146cSJerin Jacob 	return data->port_id;
1179f18b146cSJerin Jacob 
1180f18b146cSJerin Jacob err:
1181a98122efSSantosh Shukla 	if (nic)
1182f18b146cSJerin Jacob 		octeontx_port_close(nic);
1183f18b146cSJerin Jacob 
1184f18b146cSJerin Jacob 	if (eth_dev != NULL) {
1185f18b146cSJerin Jacob 		rte_free(eth_dev->data->mac_addrs);
1186f18b146cSJerin Jacob 		rte_free(data);
1187f18b146cSJerin Jacob 		rte_free(nic);
1188f18b146cSJerin Jacob 		rte_eth_dev_release_port(eth_dev);
1189f18b146cSJerin Jacob 	}
1190f18b146cSJerin Jacob 
1191f18b146cSJerin Jacob 	return res;
1192f7be70e5SJerin Jacob }
1193f7be70e5SJerin Jacob 
1194f7be70e5SJerin Jacob /* Un initialize octeontx device */
1195f7be70e5SJerin Jacob static int
1196f7be70e5SJerin Jacob octeontx_remove(struct rte_vdev_device *dev)
1197f7be70e5SJerin Jacob {
1198f7be70e5SJerin Jacob 	char octtx_name[OCTEONTX_MAX_NAME_LEN];
1199f7be70e5SJerin Jacob 	struct rte_eth_dev *eth_dev = NULL;
1200f7be70e5SJerin Jacob 	struct octeontx_nic *nic = NULL;
1201f7be70e5SJerin Jacob 	int i;
1202f7be70e5SJerin Jacob 
1203f7be70e5SJerin Jacob 	if (dev == NULL)
1204f7be70e5SJerin Jacob 		return -EINVAL;
1205f7be70e5SJerin Jacob 
1206f7be70e5SJerin Jacob 	for (i = 0; i < OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT; i++) {
1207f7be70e5SJerin Jacob 		sprintf(octtx_name, "eth_octeontx_%d", i);
1208f7be70e5SJerin Jacob 
1209f7be70e5SJerin Jacob 		/* reserve an ethdev entry */
1210f7be70e5SJerin Jacob 		eth_dev = rte_eth_dev_allocated(octtx_name);
1211f7be70e5SJerin Jacob 		if (eth_dev == NULL)
1212f7be70e5SJerin Jacob 			return -ENODEV;
1213f7be70e5SJerin Jacob 
1214f7be70e5SJerin Jacob 		nic = octeontx_pmd_priv(eth_dev);
1215f7be70e5SJerin Jacob 		rte_event_dev_stop(nic->evdev);
1216f7be70e5SJerin Jacob 		PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name);
1217f7be70e5SJerin Jacob 
1218f7be70e5SJerin Jacob 		rte_free(eth_dev->data->mac_addrs);
1219f7be70e5SJerin Jacob 		rte_free(eth_dev->data->dev_private);
1220f7be70e5SJerin Jacob 		rte_free(eth_dev->data);
1221f7be70e5SJerin Jacob 		rte_eth_dev_release_port(eth_dev);
1222f7be70e5SJerin Jacob 		rte_event_dev_close(nic->evdev);
1223f7be70e5SJerin Jacob 	}
1224f7be70e5SJerin Jacob 
1225f7be70e5SJerin Jacob 	/* Free FC resource */
1226f7be70e5SJerin Jacob 	octeontx_pko_fc_free();
1227f7be70e5SJerin Jacob 
1228f7be70e5SJerin Jacob 	return 0;
1229f7be70e5SJerin Jacob }
1230f7be70e5SJerin Jacob 
1231f7be70e5SJerin Jacob /* Initialize octeontx device */
1232f7be70e5SJerin Jacob static int
1233f7be70e5SJerin Jacob octeontx_probe(struct rte_vdev_device *dev)
1234f7be70e5SJerin Jacob {
1235f7be70e5SJerin Jacob 	const char *dev_name;
1236f7be70e5SJerin Jacob 	static int probe_once;
1237f7be70e5SJerin Jacob 	uint8_t socket_id, qlist;
1238f7be70e5SJerin Jacob 	int tx_vfcnt, port_id, evdev, qnum, pnum, res, i;
1239f7be70e5SJerin Jacob 	struct rte_event_dev_config dev_conf;
1240f7be70e5SJerin Jacob 	const char *eventdev_name = "event_octeontx";
1241f7be70e5SJerin Jacob 	struct rte_event_dev_info info;
1242f7be70e5SJerin Jacob 
1243f7be70e5SJerin Jacob 	struct octeontx_vdev_init_params init_params = {
1244f7be70e5SJerin Jacob 		OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT
1245f7be70e5SJerin Jacob 	};
1246f7be70e5SJerin Jacob 
1247f7be70e5SJerin Jacob 	dev_name = rte_vdev_device_name(dev);
1248f7be70e5SJerin Jacob 	res = octeontx_parse_vdev_init_params(&init_params, dev);
1249f7be70e5SJerin Jacob 	if (res < 0)
1250f7be70e5SJerin Jacob 		return -EINVAL;
1251f7be70e5SJerin Jacob 
1252f7be70e5SJerin Jacob 	if (init_params.nr_port > OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT) {
1253f7be70e5SJerin Jacob 		octeontx_log_err("nr_port (%d) > max (%d)", init_params.nr_port,
1254f7be70e5SJerin Jacob 				OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT);
1255f7be70e5SJerin Jacob 		return -ENOTSUP;
1256f7be70e5SJerin Jacob 	}
1257f7be70e5SJerin Jacob 
1258f7be70e5SJerin Jacob 	PMD_INIT_LOG(DEBUG, "initializing %s pmd", dev_name);
1259f7be70e5SJerin Jacob 
1260f7be70e5SJerin Jacob 	socket_id = rte_socket_id();
1261f7be70e5SJerin Jacob 
1262f7be70e5SJerin Jacob 	tx_vfcnt = octeontx_pko_vf_count();
1263f7be70e5SJerin Jacob 
1264f7be70e5SJerin Jacob 	if (tx_vfcnt < init_params.nr_port) {
1265f7be70e5SJerin Jacob 		octeontx_log_err("not enough PKO (%d) for port number (%d)",
1266f7be70e5SJerin Jacob 				tx_vfcnt, init_params.nr_port);
1267f7be70e5SJerin Jacob 		return -EINVAL;
1268f7be70e5SJerin Jacob 	}
1269f7be70e5SJerin Jacob 	evdev = rte_event_dev_get_dev_id(eventdev_name);
1270f7be70e5SJerin Jacob 	if (evdev < 0) {
1271f7be70e5SJerin Jacob 		octeontx_log_err("eventdev %s not found", eventdev_name);
1272f7be70e5SJerin Jacob 		return -ENODEV;
1273f7be70e5SJerin Jacob 	}
1274f7be70e5SJerin Jacob 
1275f7be70e5SJerin Jacob 	res = rte_event_dev_info_get(evdev, &info);
1276f7be70e5SJerin Jacob 	if (res < 0) {
1277f7be70e5SJerin Jacob 		octeontx_log_err("failed to eventdev info %d", res);
1278f7be70e5SJerin Jacob 		return -EINVAL;
1279f7be70e5SJerin Jacob 	}
1280f7be70e5SJerin Jacob 
1281f7be70e5SJerin Jacob 	PMD_INIT_LOG(DEBUG, "max_queue %d max_port %d",
1282f7be70e5SJerin Jacob 			info.max_event_queues, info.max_event_ports);
1283f7be70e5SJerin Jacob 
1284f7be70e5SJerin Jacob 	if (octeontx_pko_init_fc(tx_vfcnt))
1285f7be70e5SJerin Jacob 		return -ENOMEM;
1286f7be70e5SJerin Jacob 
1287f7be70e5SJerin Jacob 	devconf_set_default_sane_values(&dev_conf, &info);
1288f7be70e5SJerin Jacob 	res = rte_event_dev_configure(evdev, &dev_conf);
1289f7be70e5SJerin Jacob 	if (res < 0)
1290f7be70e5SJerin Jacob 		goto parse_error;
1291f7be70e5SJerin Jacob 
1292f7be70e5SJerin Jacob 	rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_PORT_COUNT,
1293f7be70e5SJerin Jacob 			(uint32_t *)&pnum);
1294f7be70e5SJerin Jacob 	rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
1295f7be70e5SJerin Jacob 			(uint32_t *)&qnum);
1296f7be70e5SJerin Jacob 	if (pnum < qnum) {
1297f7be70e5SJerin Jacob 		octeontx_log_err("too few event ports (%d) for event_q(%d)",
1298f7be70e5SJerin Jacob 				pnum, qnum);
1299f7be70e5SJerin Jacob 		res = -EINVAL;
1300f7be70e5SJerin Jacob 		goto parse_error;
1301f7be70e5SJerin Jacob 	}
1302f7be70e5SJerin Jacob 	if (pnum > qnum) {
1303f7be70e5SJerin Jacob 		/*
1304f7be70e5SJerin Jacob 		 * We don't poll on event ports
1305f7be70e5SJerin Jacob 		 * that do not have any queues assigned.
1306f7be70e5SJerin Jacob 		 */
1307f7be70e5SJerin Jacob 		pnum = qnum;
1308f7be70e5SJerin Jacob 		PMD_INIT_LOG(INFO,
1309f7be70e5SJerin Jacob 			"reducing number of active event ports to %d", pnum);
1310f7be70e5SJerin Jacob 	}
1311f7be70e5SJerin Jacob 	for (i = 0; i < qnum; i++) {
1312f7be70e5SJerin Jacob 		res = rte_event_queue_setup(evdev, i, NULL);
1313f7be70e5SJerin Jacob 		if (res < 0) {
1314f7be70e5SJerin Jacob 			octeontx_log_err("failed to setup event_q(%d): res %d",
1315f7be70e5SJerin Jacob 					i, res);
1316f7be70e5SJerin Jacob 			goto parse_error;
1317f7be70e5SJerin Jacob 		}
1318f7be70e5SJerin Jacob 	}
1319f7be70e5SJerin Jacob 
1320f7be70e5SJerin Jacob 	for (i = 0; i < pnum; i++) {
1321f7be70e5SJerin Jacob 		res = rte_event_port_setup(evdev, i, NULL);
1322f7be70e5SJerin Jacob 		if (res < 0) {
1323f7be70e5SJerin Jacob 			res = -ENODEV;
1324f7be70e5SJerin Jacob 			octeontx_log_err("failed to setup ev port(%d) res=%d",
1325f7be70e5SJerin Jacob 						i, res);
1326f7be70e5SJerin Jacob 			goto parse_error;
1327f7be70e5SJerin Jacob 		}
1328f7be70e5SJerin Jacob 		/* Link one queue to one event port */
1329f7be70e5SJerin Jacob 		qlist = i;
1330f7be70e5SJerin Jacob 		res = rte_event_port_link(evdev, i, &qlist, NULL, 1);
1331f7be70e5SJerin Jacob 		if (res < 0) {
1332f7be70e5SJerin Jacob 			res = -ENODEV;
1333f7be70e5SJerin Jacob 			octeontx_log_err("failed to link port (%d): res=%d",
1334f7be70e5SJerin Jacob 					i, res);
1335f7be70e5SJerin Jacob 			goto parse_error;
1336f7be70e5SJerin Jacob 		}
1337f7be70e5SJerin Jacob 	}
1338f7be70e5SJerin Jacob 
1339f7be70e5SJerin Jacob 	/* Create ethdev interface */
1340f7be70e5SJerin Jacob 	for (i = 0; i < init_params.nr_port; i++) {
1341f7be70e5SJerin Jacob 		port_id = octeontx_create(dev, i, evdev, socket_id);
1342f7be70e5SJerin Jacob 		if (port_id < 0) {
1343f7be70e5SJerin Jacob 			octeontx_log_err("failed to create device %s",
1344f7be70e5SJerin Jacob 					dev_name);
1345f7be70e5SJerin Jacob 			res = -ENODEV;
1346f7be70e5SJerin Jacob 			goto parse_error;
1347f7be70e5SJerin Jacob 		}
1348f7be70e5SJerin Jacob 
1349f7be70e5SJerin Jacob 		PMD_INIT_LOG(INFO, "created ethdev %s for port %d", dev_name,
1350f7be70e5SJerin Jacob 					port_id);
1351f7be70e5SJerin Jacob 	}
1352f7be70e5SJerin Jacob 
1353f7be70e5SJerin Jacob 	if (probe_once) {
1354f7be70e5SJerin Jacob 		octeontx_log_err("interface %s not supported", dev_name);
1355f7be70e5SJerin Jacob 		octeontx_remove(dev);
1356f7be70e5SJerin Jacob 		res = -ENOTSUP;
1357f7be70e5SJerin Jacob 		goto parse_error;
1358f7be70e5SJerin Jacob 	}
1359dfb0c75bSPavan Nikhilesh 	rte_mbuf_set_platform_mempool_ops("octeontx_fpavf");
1360f7be70e5SJerin Jacob 	probe_once = 1;
1361f7be70e5SJerin Jacob 
1362f7be70e5SJerin Jacob 	return 0;
1363f7be70e5SJerin Jacob 
1364f7be70e5SJerin Jacob parse_error:
1365f7be70e5SJerin Jacob 	octeontx_pko_fc_free();
1366f7be70e5SJerin Jacob 	return res;
1367f7be70e5SJerin Jacob }
1368f7be70e5SJerin Jacob 
1369f7be70e5SJerin Jacob static struct rte_vdev_driver octeontx_pmd_drv = {
1370f7be70e5SJerin Jacob 	.probe = octeontx_probe,
1371f7be70e5SJerin Jacob 	.remove = octeontx_remove,
1372f7be70e5SJerin Jacob };
1373f7be70e5SJerin Jacob 
1374f7be70e5SJerin Jacob RTE_PMD_REGISTER_VDEV(OCTEONTX_PMD, octeontx_pmd_drv);
1375f7be70e5SJerin Jacob RTE_PMD_REGISTER_ALIAS(OCTEONTX_PMD, eth_octeontx);
1376f7be70e5SJerin Jacob RTE_PMD_REGISTER_PARAM_STRING(OCTEONTX_PMD, "nr_port=<int> ");
1377