xref: /dpdk/drivers/net/octeontx/octeontx_ethdev.c (revision 9614459b1eaa31ca074519ace4bbfdadb9b12fde)
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 
49f8e99896SThomas Monjalon RTE_INIT(otx_net_init_log)
504d35a276SPavan Nikhilesh {
511a0eab3aSHarry van Haaren 	otx_net_logtype_mbox = rte_log_register("pmd.net.octeontx.mbox");
524d35a276SPavan Nikhilesh 	if (otx_net_logtype_mbox >= 0)
534d35a276SPavan Nikhilesh 		rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE);
544d35a276SPavan Nikhilesh 
551a0eab3aSHarry van Haaren 	otx_net_logtype_init = rte_log_register("pmd.net.octeontx.init");
564d35a276SPavan Nikhilesh 	if (otx_net_logtype_init >= 0)
574d35a276SPavan Nikhilesh 		rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE);
584d35a276SPavan Nikhilesh 
591a0eab3aSHarry van Haaren 	otx_net_logtype_driver = rte_log_register("pmd.net.octeontx.driver");
604d35a276SPavan Nikhilesh 	if (otx_net_logtype_driver >= 0)
614d35a276SPavan Nikhilesh 		rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE);
624d35a276SPavan Nikhilesh }
634d35a276SPavan Nikhilesh 
64f7be70e5SJerin Jacob /* Parse integer from integer argument */
65f7be70e5SJerin Jacob static int
66f7be70e5SJerin Jacob parse_integer_arg(const char *key __rte_unused,
67f7be70e5SJerin Jacob 		const char *value, void *extra_args)
68f7be70e5SJerin Jacob {
69f7be70e5SJerin Jacob 	int *i = (int *)extra_args;
70f7be70e5SJerin Jacob 
71f7be70e5SJerin Jacob 	*i = atoi(value);
72f7be70e5SJerin Jacob 	if (*i < 0) {
73f7be70e5SJerin Jacob 		octeontx_log_err("argument has to be positive.");
74f7be70e5SJerin Jacob 		return -1;
75f7be70e5SJerin Jacob 	}
76f7be70e5SJerin Jacob 
77f7be70e5SJerin Jacob 	return 0;
78f7be70e5SJerin Jacob }
79f7be70e5SJerin Jacob 
80f7be70e5SJerin Jacob static int
81f7be70e5SJerin Jacob octeontx_parse_vdev_init_params(struct octeontx_vdev_init_params *params,
82f7be70e5SJerin Jacob 				struct rte_vdev_device *dev)
83f7be70e5SJerin Jacob {
84f7be70e5SJerin Jacob 	struct rte_kvargs *kvlist = NULL;
85f7be70e5SJerin Jacob 	int ret = 0;
86f7be70e5SJerin Jacob 
87f7be70e5SJerin Jacob 	static const char * const octeontx_vdev_valid_params[] = {
88f7be70e5SJerin Jacob 		OCTEONTX_VDEV_NR_PORT_ARG,
89f7be70e5SJerin Jacob 		NULL
90f7be70e5SJerin Jacob 	};
91f7be70e5SJerin Jacob 
92f7be70e5SJerin Jacob 	const char *input_args = rte_vdev_device_args(dev);
93f7be70e5SJerin Jacob 	if (params == NULL)
94f7be70e5SJerin Jacob 		return -EINVAL;
95f7be70e5SJerin Jacob 
96f7be70e5SJerin Jacob 
97f7be70e5SJerin Jacob 	if (input_args) {
98f7be70e5SJerin Jacob 		kvlist = rte_kvargs_parse(input_args,
99f7be70e5SJerin Jacob 				octeontx_vdev_valid_params);
100f7be70e5SJerin Jacob 		if (kvlist == NULL)
101f7be70e5SJerin Jacob 			return -1;
102f7be70e5SJerin Jacob 
103f7be70e5SJerin Jacob 		ret = rte_kvargs_process(kvlist,
104f7be70e5SJerin Jacob 					OCTEONTX_VDEV_NR_PORT_ARG,
105f7be70e5SJerin Jacob 					&parse_integer_arg,
106f7be70e5SJerin Jacob 					&params->nr_port);
107f7be70e5SJerin Jacob 		if (ret < 0)
108f7be70e5SJerin Jacob 			goto free_kvlist;
109f7be70e5SJerin Jacob 	}
110f7be70e5SJerin Jacob 
111f7be70e5SJerin Jacob free_kvlist:
112f7be70e5SJerin Jacob 	rte_kvargs_free(kvlist);
113f7be70e5SJerin Jacob 	return ret;
114f7be70e5SJerin Jacob }
115f7be70e5SJerin Jacob 
116f18b146cSJerin Jacob static int
117f18b146cSJerin Jacob octeontx_port_open(struct octeontx_nic *nic)
118f18b146cSJerin Jacob {
119f18b146cSJerin Jacob 	octeontx_mbox_bgx_port_conf_t bgx_port_conf;
120f18b146cSJerin Jacob 	int res;
121f18b146cSJerin Jacob 
122f18b146cSJerin Jacob 	res = 0;
123a371fd79SSantosh Shukla 	memset(&bgx_port_conf, 0x0, sizeof(bgx_port_conf));
124f18b146cSJerin Jacob 	PMD_INIT_FUNC_TRACE();
125f18b146cSJerin Jacob 
126f18b146cSJerin Jacob 	res = octeontx_bgx_port_open(nic->port_id, &bgx_port_conf);
127f18b146cSJerin Jacob 	if (res < 0) {
128f18b146cSJerin Jacob 		octeontx_log_err("failed to open port %d", res);
129f18b146cSJerin Jacob 		return res;
130f18b146cSJerin Jacob 	}
131f18b146cSJerin Jacob 
132f18b146cSJerin Jacob 	nic->node = bgx_port_conf.node;
133f18b146cSJerin Jacob 	nic->port_ena = bgx_port_conf.enable;
134f18b146cSJerin Jacob 	nic->base_ichan = bgx_port_conf.base_chan;
135f18b146cSJerin Jacob 	nic->base_ochan = bgx_port_conf.base_chan;
136f18b146cSJerin Jacob 	nic->num_ichans = bgx_port_conf.num_chans;
137f18b146cSJerin Jacob 	nic->num_ochans = bgx_port_conf.num_chans;
138f18b146cSJerin Jacob 	nic->mtu = bgx_port_conf.mtu;
139f18b146cSJerin Jacob 	nic->bpen = bgx_port_conf.bpen;
140f18b146cSJerin Jacob 	nic->fcs_strip = bgx_port_conf.fcs_strip;
141f18b146cSJerin Jacob 	nic->bcast_mode = bgx_port_conf.bcast_mode;
142f18b146cSJerin Jacob 	nic->mcast_mode = bgx_port_conf.mcast_mode;
143f18b146cSJerin Jacob 	nic->speed	= bgx_port_conf.mode;
144f18b146cSJerin Jacob 
14535b2d13fSOlivier Matz 	memcpy(&nic->mac_addr[0], &bgx_port_conf.macaddr[0],
14635b2d13fSOlivier Matz 		RTE_ETHER_ADDR_LEN);
147f18b146cSJerin Jacob 
148f18b146cSJerin Jacob 	octeontx_log_dbg("port opened %d", nic->port_id);
149f18b146cSJerin Jacob 	return res;
150f18b146cSJerin Jacob }
151f18b146cSJerin Jacob 
152f18b146cSJerin Jacob static void
153f18b146cSJerin Jacob octeontx_port_close(struct octeontx_nic *nic)
154f18b146cSJerin Jacob {
155f18b146cSJerin Jacob 	PMD_INIT_FUNC_TRACE();
156f18b146cSJerin Jacob 
157f18b146cSJerin Jacob 	octeontx_bgx_port_close(nic->port_id);
158f18b146cSJerin Jacob 	octeontx_log_dbg("port closed %d", nic->port_id);
159f18b146cSJerin Jacob }
160f18b146cSJerin Jacob 
1617fe7c98fSJerin Jacob static int
162da6c6874SJerin Jacob octeontx_port_start(struct octeontx_nic *nic)
163da6c6874SJerin Jacob {
164da6c6874SJerin Jacob 	PMD_INIT_FUNC_TRACE();
165da6c6874SJerin Jacob 
166da6c6874SJerin Jacob 	return octeontx_bgx_port_start(nic->port_id);
167da6c6874SJerin Jacob }
168da6c6874SJerin Jacob 
169da6c6874SJerin Jacob static int
1707fe7c98fSJerin Jacob octeontx_port_stop(struct octeontx_nic *nic)
1717fe7c98fSJerin Jacob {
1727fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
1737fe7c98fSJerin Jacob 
1747fe7c98fSJerin Jacob 	return octeontx_bgx_port_stop(nic->port_id);
1757fe7c98fSJerin Jacob }
1767fe7c98fSJerin Jacob 
1779039c812SAndrew Rybchenko static int
17815bce35bSJerin Jacob octeontx_port_promisc_set(struct octeontx_nic *nic, int en)
17915bce35bSJerin Jacob {
18015bce35bSJerin Jacob 	struct rte_eth_dev *dev;
18115bce35bSJerin Jacob 	int res;
18215bce35bSJerin Jacob 
18315bce35bSJerin Jacob 	res = 0;
18415bce35bSJerin Jacob 	PMD_INIT_FUNC_TRACE();
18515bce35bSJerin Jacob 	dev = nic->dev;
18615bce35bSJerin Jacob 
18715bce35bSJerin Jacob 	res = octeontx_bgx_port_promisc_set(nic->port_id, en);
1889039c812SAndrew Rybchenko 	if (res < 0) {
18915bce35bSJerin Jacob 		octeontx_log_err("failed to set promiscuous mode %d",
19015bce35bSJerin Jacob 				nic->port_id);
1919039c812SAndrew Rybchenko 		return res;
1929039c812SAndrew Rybchenko 	}
19315bce35bSJerin Jacob 
19415bce35bSJerin Jacob 	/* Set proper flag for the mode */
19515bce35bSJerin Jacob 	dev->data->promiscuous = (en != 0) ? 1 : 0;
19615bce35bSJerin Jacob 
19715bce35bSJerin Jacob 	octeontx_log_dbg("port %d : promiscuous mode %s",
19815bce35bSJerin Jacob 			nic->port_id, en ? "set" : "unset");
1999039c812SAndrew Rybchenko 
2009039c812SAndrew Rybchenko 	return 0;
20115bce35bSJerin Jacob }
20215bce35bSJerin Jacob 
203d5b0924bSMatan Azrad static int
20455389909SJerin Jacob octeontx_port_stats(struct octeontx_nic *nic, struct rte_eth_stats *stats)
20555389909SJerin Jacob {
20655389909SJerin Jacob 	octeontx_mbox_bgx_port_stats_t bgx_stats;
20755389909SJerin Jacob 	int res;
20855389909SJerin Jacob 
20955389909SJerin Jacob 	PMD_INIT_FUNC_TRACE();
21055389909SJerin Jacob 
21155389909SJerin Jacob 	res = octeontx_bgx_port_stats(nic->port_id, &bgx_stats);
212d5b0924bSMatan Azrad 	if (res < 0) {
21355389909SJerin Jacob 		octeontx_log_err("failed to get port stats %d", nic->port_id);
214d5b0924bSMatan Azrad 		return res;
215d5b0924bSMatan Azrad 	}
21655389909SJerin Jacob 
21755389909SJerin Jacob 	stats->ipackets = bgx_stats.rx_packets;
21855389909SJerin Jacob 	stats->ibytes = bgx_stats.rx_bytes;
21955389909SJerin Jacob 	stats->imissed = bgx_stats.rx_dropped;
22055389909SJerin Jacob 	stats->ierrors = bgx_stats.rx_errors;
22155389909SJerin Jacob 	stats->opackets = bgx_stats.tx_packets;
22255389909SJerin Jacob 	stats->obytes = bgx_stats.tx_bytes;
22355389909SJerin Jacob 	stats->oerrors = bgx_stats.tx_errors;
22455389909SJerin Jacob 
22555389909SJerin Jacob 	octeontx_log_dbg("port%d stats inpkts=%" PRIx64 " outpkts=%" PRIx64 "",
22655389909SJerin Jacob 			nic->port_id, stats->ipackets, stats->opackets);
227d5b0924bSMatan Azrad 
228d5b0924bSMatan Azrad 	return 0;
22955389909SJerin Jacob }
23055389909SJerin Jacob 
2319970a9adSIgor Romanov static int
23255389909SJerin Jacob octeontx_port_stats_clr(struct octeontx_nic *nic)
23355389909SJerin Jacob {
23455389909SJerin Jacob 	PMD_INIT_FUNC_TRACE();
23555389909SJerin Jacob 
2369970a9adSIgor Romanov 	return octeontx_bgx_port_stats_clr(nic->port_id);
23755389909SJerin Jacob }
23855389909SJerin Jacob 
239f7be70e5SJerin Jacob static inline void
240f7be70e5SJerin Jacob devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf,
241f7be70e5SJerin Jacob 				struct rte_event_dev_info *info)
242f7be70e5SJerin Jacob {
243f7be70e5SJerin Jacob 	memset(dev_conf, 0, sizeof(struct rte_event_dev_config));
244f7be70e5SJerin Jacob 	dev_conf->dequeue_timeout_ns = info->min_dequeue_timeout_ns;
245f7be70e5SJerin Jacob 
246f7be70e5SJerin Jacob 	dev_conf->nb_event_ports = info->max_event_ports;
247f7be70e5SJerin Jacob 	dev_conf->nb_event_queues = info->max_event_queues;
248f7be70e5SJerin Jacob 
249f7be70e5SJerin Jacob 	dev_conf->nb_event_queue_flows = info->max_event_queue_flows;
250f7be70e5SJerin Jacob 	dev_conf->nb_event_port_dequeue_depth =
251f7be70e5SJerin Jacob 			info->max_event_port_dequeue_depth;
252f7be70e5SJerin Jacob 	dev_conf->nb_event_port_enqueue_depth =
253f7be70e5SJerin Jacob 			info->max_event_port_enqueue_depth;
254f7be70e5SJerin Jacob 	dev_conf->nb_event_port_enqueue_depth =
255f7be70e5SJerin Jacob 			info->max_event_port_enqueue_depth;
256f7be70e5SJerin Jacob 	dev_conf->nb_events_limit =
257f7be70e5SJerin Jacob 			info->max_num_events;
258f7be70e5SJerin Jacob }
259f7be70e5SJerin Jacob 
2607742c55aSJerin Jacob static int
2617742c55aSJerin Jacob octeontx_dev_configure(struct rte_eth_dev *dev)
2627742c55aSJerin Jacob {
2637742c55aSJerin Jacob 	struct rte_eth_dev_data *data = dev->data;
2647742c55aSJerin Jacob 	struct rte_eth_conf *conf = &data->dev_conf;
2657742c55aSJerin Jacob 	struct rte_eth_rxmode *rxmode = &conf->rxmode;
2667742c55aSJerin Jacob 	struct rte_eth_txmode *txmode = &conf->txmode;
2677742c55aSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
2687742c55aSJerin Jacob 	int ret;
2697742c55aSJerin Jacob 
2707742c55aSJerin Jacob 	PMD_INIT_FUNC_TRACE();
2717742c55aSJerin Jacob 	RTE_SET_USED(conf);
2727742c55aSJerin Jacob 
2737742c55aSJerin Jacob 	if (!rte_eal_has_hugepages()) {
2747742c55aSJerin Jacob 		octeontx_log_err("huge page is not configured");
2757742c55aSJerin Jacob 		return -EINVAL;
2767742c55aSJerin Jacob 	}
2777742c55aSJerin Jacob 
2787742c55aSJerin Jacob 	if (txmode->mq_mode) {
2797742c55aSJerin Jacob 		octeontx_log_err("tx mq_mode DCB or VMDq not supported");
2807742c55aSJerin Jacob 		return -EINVAL;
2817742c55aSJerin Jacob 	}
2827742c55aSJerin Jacob 
2837742c55aSJerin Jacob 	if (rxmode->mq_mode != ETH_MQ_RX_NONE &&
2847742c55aSJerin Jacob 		rxmode->mq_mode != ETH_MQ_RX_RSS) {
2857742c55aSJerin Jacob 		octeontx_log_err("unsupported rx qmode %d", rxmode->mq_mode);
2867742c55aSJerin Jacob 		return -EINVAL;
2877742c55aSJerin Jacob 	}
2887742c55aSJerin Jacob 
289a4996bd8SWei Dai 	if (!(txmode->offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) {
290a9287089SPavan Nikhilesh 		PMD_INIT_LOG(NOTICE, "cant disable lockfree tx");
291a4996bd8SWei Dai 		txmode->offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE;
2927742c55aSJerin Jacob 	}
2937742c55aSJerin Jacob 
2947742c55aSJerin Jacob 	if (conf->link_speeds & ETH_LINK_SPEED_FIXED) {
2957742c55aSJerin Jacob 		octeontx_log_err("setting link speed/duplex not supported");
2967742c55aSJerin Jacob 		return -EINVAL;
2977742c55aSJerin Jacob 	}
2987742c55aSJerin Jacob 
2997742c55aSJerin Jacob 	if (conf->dcb_capability_en) {
3007742c55aSJerin Jacob 		octeontx_log_err("DCB enable not supported");
3017742c55aSJerin Jacob 		return -EINVAL;
3027742c55aSJerin Jacob 	}
3037742c55aSJerin Jacob 
3047742c55aSJerin Jacob 	if (conf->fdir_conf.mode != RTE_FDIR_MODE_NONE) {
3057742c55aSJerin Jacob 		octeontx_log_err("flow director not supported");
3067742c55aSJerin Jacob 		return -EINVAL;
3077742c55aSJerin Jacob 	}
3087742c55aSJerin Jacob 
3097742c55aSJerin Jacob 	nic->num_tx_queues = dev->data->nb_tx_queues;
3107742c55aSJerin Jacob 
311a6d6f0afSPavan Nikhilesh 	ret = octeontx_pko_channel_open(nic->pko_vfid * PKO_VF_NUM_DQ,
3127742c55aSJerin Jacob 					nic->num_tx_queues,
3137742c55aSJerin Jacob 					nic->base_ochan);
3147742c55aSJerin Jacob 	if (ret) {
3157742c55aSJerin Jacob 		octeontx_log_err("failed to open channel %d no-of-txq %d",
3167742c55aSJerin Jacob 			   nic->base_ochan, nic->num_tx_queues);
3177742c55aSJerin Jacob 		return -EFAULT;
3187742c55aSJerin Jacob 	}
3197742c55aSJerin Jacob 
3207742c55aSJerin Jacob 	nic->pki.classifier_enable = false;
3217742c55aSJerin Jacob 	nic->pki.hash_enable = true;
3227742c55aSJerin Jacob 	nic->pki.initialized = false;
3237742c55aSJerin Jacob 
3247742c55aSJerin Jacob 	return 0;
3257742c55aSJerin Jacob }
3267742c55aSJerin Jacob 
32715bce35bSJerin Jacob static void
328da6c6874SJerin Jacob octeontx_dev_close(struct rte_eth_dev *dev)
329da6c6874SJerin Jacob {
330da6c6874SJerin Jacob 	struct octeontx_txq *txq = NULL;
331da6c6874SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
332da6c6874SJerin Jacob 	unsigned int i;
333da6c6874SJerin Jacob 	int ret;
334da6c6874SJerin Jacob 
335da6c6874SJerin Jacob 	PMD_INIT_FUNC_TRACE();
336da6c6874SJerin Jacob 
337da6c6874SJerin Jacob 	rte_event_dev_close(nic->evdev);
338da6c6874SJerin Jacob 
339da6c6874SJerin Jacob 	ret = octeontx_pko_channel_close(nic->base_ochan);
340da6c6874SJerin Jacob 	if (ret < 0) {
341da6c6874SJerin Jacob 		octeontx_log_err("failed to close channel %d VF%d %d %d",
342da6c6874SJerin Jacob 			     nic->base_ochan, nic->port_id, nic->num_tx_queues,
343da6c6874SJerin Jacob 			     ret);
344da6c6874SJerin Jacob 	}
345da6c6874SJerin Jacob 	/* Free txq resources for this port */
346da6c6874SJerin Jacob 	for (i = 0; i < nic->num_tx_queues; i++) {
347da6c6874SJerin Jacob 		txq = dev->data->tx_queues[i];
348da6c6874SJerin Jacob 		if (!txq)
349da6c6874SJerin Jacob 			continue;
350da6c6874SJerin Jacob 
351da6c6874SJerin Jacob 		rte_free(txq);
352da6c6874SJerin Jacob 	}
353efb9dd14SPavan Nikhilesh 
3549e399b88SSunil Kumar Kori 	/* Free MAC address table */
3559e399b88SSunil Kumar Kori 	rte_free(dev->data->mac_addrs);
3569e399b88SSunil Kumar Kori 	dev->data->mac_addrs = NULL;
3579e399b88SSunil Kumar Kori 
358efb9dd14SPavan Nikhilesh 	dev->tx_pkt_burst = NULL;
359efb9dd14SPavan Nikhilesh 	dev->rx_pkt_burst = NULL;
360da6c6874SJerin Jacob }
361da6c6874SJerin Jacob 
362da6c6874SJerin Jacob static int
363da6c6874SJerin Jacob octeontx_dev_start(struct rte_eth_dev *dev)
364da6c6874SJerin Jacob {
365da6c6874SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
366da6c6874SJerin Jacob 	int ret;
367da6c6874SJerin Jacob 
368da6c6874SJerin Jacob 	ret = 0;
369da6c6874SJerin Jacob 
370da6c6874SJerin Jacob 	PMD_INIT_FUNC_TRACE();
371da6c6874SJerin Jacob 	/*
372da6c6874SJerin Jacob 	 * Tx start
373da6c6874SJerin Jacob 	 */
374da6c6874SJerin Jacob 	dev->tx_pkt_burst = octeontx_xmit_pkts;
375da6c6874SJerin Jacob 	ret = octeontx_pko_channel_start(nic->base_ochan);
376da6c6874SJerin Jacob 	if (ret < 0) {
377da6c6874SJerin Jacob 		octeontx_log_err("fail to conf VF%d no. txq %d chan %d ret %d",
378da6c6874SJerin Jacob 			   nic->port_id, nic->num_tx_queues, nic->base_ochan,
379da6c6874SJerin Jacob 			   ret);
380da6c6874SJerin Jacob 		goto error;
381da6c6874SJerin Jacob 	}
382da6c6874SJerin Jacob 
383da6c6874SJerin Jacob 	/*
384da6c6874SJerin Jacob 	 * Rx start
385da6c6874SJerin Jacob 	 */
386da6c6874SJerin Jacob 	dev->rx_pkt_burst = octeontx_recv_pkts;
387da6c6874SJerin Jacob 	ret = octeontx_pki_port_start(nic->port_id);
388da6c6874SJerin Jacob 	if (ret < 0) {
389da6c6874SJerin Jacob 		octeontx_log_err("fail to start Rx on port %d", nic->port_id);
390da6c6874SJerin Jacob 		goto channel_stop_error;
391da6c6874SJerin Jacob 	}
392da6c6874SJerin Jacob 
393da6c6874SJerin Jacob 	/*
394da6c6874SJerin Jacob 	 * Start port
395da6c6874SJerin Jacob 	 */
396da6c6874SJerin Jacob 	ret = octeontx_port_start(nic);
397da6c6874SJerin Jacob 	if (ret < 0) {
398da6c6874SJerin Jacob 		octeontx_log_err("failed start port %d", ret);
399da6c6874SJerin Jacob 		goto pki_port_stop_error;
400da6c6874SJerin Jacob 	}
401da6c6874SJerin Jacob 
402da6c6874SJerin Jacob 	PMD_TX_LOG(DEBUG, "pko: start channel %d no.of txq %d port %d",
403da6c6874SJerin Jacob 			nic->base_ochan, nic->num_tx_queues, nic->port_id);
404da6c6874SJerin Jacob 
405da6c6874SJerin Jacob 	ret = rte_event_dev_start(nic->evdev);
406da6c6874SJerin Jacob 	if (ret < 0) {
407da6c6874SJerin Jacob 		octeontx_log_err("failed to start evdev: ret (%d)", ret);
408da6c6874SJerin Jacob 		goto pki_port_stop_error;
409da6c6874SJerin Jacob 	}
410da6c6874SJerin Jacob 
411da6c6874SJerin Jacob 	/* Success */
412da6c6874SJerin Jacob 	return ret;
413da6c6874SJerin Jacob 
414da6c6874SJerin Jacob pki_port_stop_error:
415da6c6874SJerin Jacob 	octeontx_pki_port_stop(nic->port_id);
416da6c6874SJerin Jacob channel_stop_error:
417da6c6874SJerin Jacob 	octeontx_pko_channel_stop(nic->base_ochan);
418da6c6874SJerin Jacob error:
419da6c6874SJerin Jacob 	return ret;
420da6c6874SJerin Jacob }
421da6c6874SJerin Jacob 
422da6c6874SJerin Jacob static void
423da6c6874SJerin Jacob octeontx_dev_stop(struct rte_eth_dev *dev)
424da6c6874SJerin Jacob {
425da6c6874SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
426da6c6874SJerin Jacob 	int ret;
427da6c6874SJerin Jacob 
428da6c6874SJerin Jacob 	PMD_INIT_FUNC_TRACE();
429da6c6874SJerin Jacob 
430da6c6874SJerin Jacob 	rte_event_dev_stop(nic->evdev);
431da6c6874SJerin Jacob 
432da6c6874SJerin Jacob 	ret = octeontx_port_stop(nic);
433da6c6874SJerin Jacob 	if (ret < 0) {
434da6c6874SJerin Jacob 		octeontx_log_err("failed to req stop port %d res=%d",
435da6c6874SJerin Jacob 					nic->port_id, ret);
436da6c6874SJerin Jacob 		return;
437da6c6874SJerin Jacob 	}
438da6c6874SJerin Jacob 
439da6c6874SJerin Jacob 	ret = octeontx_pki_port_stop(nic->port_id);
440da6c6874SJerin Jacob 	if (ret < 0) {
441da6c6874SJerin Jacob 		octeontx_log_err("failed to stop pki port %d res=%d",
442da6c6874SJerin Jacob 					nic->port_id, ret);
443da6c6874SJerin Jacob 		return;
444da6c6874SJerin Jacob 	}
445da6c6874SJerin Jacob 
446da6c6874SJerin Jacob 	ret = octeontx_pko_channel_stop(nic->base_ochan);
447da6c6874SJerin Jacob 	if (ret < 0) {
448da6c6874SJerin Jacob 		octeontx_log_err("failed to stop channel %d VF%d %d %d",
449da6c6874SJerin Jacob 			     nic->base_ochan, nic->port_id, nic->num_tx_queues,
450da6c6874SJerin Jacob 			     ret);
451da6c6874SJerin Jacob 		return;
452da6c6874SJerin Jacob 	}
453da6c6874SJerin Jacob }
454da6c6874SJerin Jacob 
4559039c812SAndrew Rybchenko static int
45615bce35bSJerin Jacob octeontx_dev_promisc_enable(struct rte_eth_dev *dev)
45715bce35bSJerin Jacob {
45815bce35bSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
45915bce35bSJerin Jacob 
46015bce35bSJerin Jacob 	PMD_INIT_FUNC_TRACE();
4619039c812SAndrew Rybchenko 	return octeontx_port_promisc_set(nic, 1);
46215bce35bSJerin Jacob }
46315bce35bSJerin Jacob 
4649039c812SAndrew Rybchenko static int
46515bce35bSJerin Jacob octeontx_dev_promisc_disable(struct rte_eth_dev *dev)
46615bce35bSJerin Jacob {
46715bce35bSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
46815bce35bSJerin Jacob 
46915bce35bSJerin Jacob 	PMD_INIT_FUNC_TRACE();
4709039c812SAndrew Rybchenko 	return octeontx_port_promisc_set(nic, 0);
47115bce35bSJerin Jacob }
47215bce35bSJerin Jacob 
4734fac7c0aSJerin Jacob static int
4744fac7c0aSJerin Jacob octeontx_port_link_status(struct octeontx_nic *nic)
4754fac7c0aSJerin Jacob {
4764fac7c0aSJerin Jacob 	int res;
4774fac7c0aSJerin Jacob 
4784fac7c0aSJerin Jacob 	PMD_INIT_FUNC_TRACE();
4794fac7c0aSJerin Jacob 	res = octeontx_bgx_port_link_status(nic->port_id);
4804fac7c0aSJerin Jacob 	if (res < 0) {
4814fac7c0aSJerin Jacob 		octeontx_log_err("failed to get port %d link status",
4824fac7c0aSJerin Jacob 				nic->port_id);
4834fac7c0aSJerin Jacob 		return res;
4844fac7c0aSJerin Jacob 	}
4854fac7c0aSJerin Jacob 
4864fac7c0aSJerin Jacob 	nic->link_up = (uint8_t)res;
4874fac7c0aSJerin Jacob 	octeontx_log_dbg("port %d link status %d", nic->port_id, nic->link_up);
4884fac7c0aSJerin Jacob 
4894fac7c0aSJerin Jacob 	return res;
4904fac7c0aSJerin Jacob }
4914fac7c0aSJerin Jacob 
4924fac7c0aSJerin Jacob /*
4934fac7c0aSJerin Jacob  * Return 0 means link status changed, -1 means not changed
4944fac7c0aSJerin Jacob  */
4954fac7c0aSJerin Jacob static int
4964fac7c0aSJerin Jacob octeontx_dev_link_update(struct rte_eth_dev *dev,
4974fac7c0aSJerin Jacob 			 int wait_to_complete __rte_unused)
4984fac7c0aSJerin Jacob {
4994fac7c0aSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
5004fac7c0aSJerin Jacob 	struct rte_eth_link link;
5014fac7c0aSJerin Jacob 	int res;
5024fac7c0aSJerin Jacob 
5034fac7c0aSJerin Jacob 	PMD_INIT_FUNC_TRACE();
5044fac7c0aSJerin Jacob 
5054fac7c0aSJerin Jacob 	res = octeontx_port_link_status(nic);
5064fac7c0aSJerin Jacob 	if (res < 0) {
5074fac7c0aSJerin Jacob 		octeontx_log_err("failed to request link status %d", res);
5084fac7c0aSJerin Jacob 		return res;
5094fac7c0aSJerin Jacob 	}
5104fac7c0aSJerin Jacob 
5114fac7c0aSJerin Jacob 	link.link_status = nic->link_up;
5124fac7c0aSJerin Jacob 
5134fac7c0aSJerin Jacob 	switch (nic->speed) {
5144fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_SGMII:
5154fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_1G;
5164fac7c0aSJerin Jacob 		break;
5174fac7c0aSJerin Jacob 
5184fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_XAUI:
5194fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_10G;
5204fac7c0aSJerin Jacob 		break;
5214fac7c0aSJerin Jacob 
5224fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_RXAUI:
5234fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_10G_R:
5244fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_10G;
5254fac7c0aSJerin Jacob 		break;
5264fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_QSGMII:
5274fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_5G;
5284fac7c0aSJerin Jacob 		break;
5294fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_40G_R:
5304fac7c0aSJerin Jacob 		link.link_speed = ETH_SPEED_NUM_40G;
5314fac7c0aSJerin Jacob 		break;
5324fac7c0aSJerin Jacob 
5334fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_RESERVE1:
5344fac7c0aSJerin Jacob 	case OCTEONTX_LINK_SPEED_RESERVE2:
5354fac7c0aSJerin Jacob 	default:
5363a4b87c8SStephen Hemminger 		link.link_speed = ETH_SPEED_NUM_NONE;
5374fac7c0aSJerin Jacob 		octeontx_log_err("incorrect link speed %d", nic->speed);
5384fac7c0aSJerin Jacob 		break;
5394fac7c0aSJerin Jacob 	}
5404fac7c0aSJerin Jacob 
5411e3a958fSThomas Monjalon 	link.link_duplex = ETH_LINK_FULL_DUPLEX;
5421e3a958fSThomas Monjalon 	link.link_autoneg = ETH_LINK_AUTONEG;
5434fac7c0aSJerin Jacob 
5442b4ab422SStephen Hemminger 	return rte_eth_linkstatus_set(dev, &link);
5454fac7c0aSJerin Jacob }
5464fac7c0aSJerin Jacob 
547d5b0924bSMatan Azrad static int
54855389909SJerin Jacob octeontx_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
54955389909SJerin Jacob {
55055389909SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
55155389909SJerin Jacob 
55255389909SJerin Jacob 	PMD_INIT_FUNC_TRACE();
553d5b0924bSMatan Azrad 	return octeontx_port_stats(nic, stats);
55455389909SJerin Jacob }
55555389909SJerin Jacob 
5569970a9adSIgor Romanov static int
55755389909SJerin Jacob octeontx_dev_stats_reset(struct rte_eth_dev *dev)
55855389909SJerin Jacob {
55955389909SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
56055389909SJerin Jacob 
56155389909SJerin Jacob 	PMD_INIT_FUNC_TRACE();
5629970a9adSIgor Romanov 	return octeontx_port_stats_clr(nic);
56355389909SJerin Jacob }
56455389909SJerin Jacob 
565e4373bf1SSunil Kumar Kori static void
566e4373bf1SSunil Kumar Kori octeontx_dev_mac_addr_del(struct rte_eth_dev *dev, uint32_t index)
567e4373bf1SSunil Kumar Kori {
568e4373bf1SSunil Kumar Kori 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
569e4373bf1SSunil Kumar Kori 	int ret;
570e4373bf1SSunil Kumar Kori 
571e4373bf1SSunil Kumar Kori 	ret = octeontx_bgx_port_mac_del(nic->port_id, index);
572e4373bf1SSunil Kumar Kori 	if (ret != 0)
573e4373bf1SSunil Kumar Kori 		octeontx_log_err("failed to del MAC address filter on port %d",
574e4373bf1SSunil Kumar Kori 				 nic->port_id);
575e4373bf1SSunil Kumar Kori }
576e4373bf1SSunil Kumar Kori 
577e4373bf1SSunil Kumar Kori static int
578e4373bf1SSunil Kumar Kori octeontx_dev_mac_addr_add(struct rte_eth_dev *dev,
579e4373bf1SSunil Kumar Kori 			  struct rte_ether_addr *mac_addr,
580*9614459bSSunil Kumar Kori 			  uint32_t index,
581e4373bf1SSunil Kumar Kori 			  __rte_unused uint32_t vmdq)
582e4373bf1SSunil Kumar Kori {
583e4373bf1SSunil Kumar Kori 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
584e4373bf1SSunil Kumar Kori 	int ret;
585e4373bf1SSunil Kumar Kori 
586*9614459bSSunil Kumar Kori 	ret = octeontx_bgx_port_mac_add(nic->port_id, mac_addr->addr_bytes,
587*9614459bSSunil Kumar Kori 					index);
588e4373bf1SSunil Kumar Kori 	if (ret < 0) {
589e4373bf1SSunil Kumar Kori 		octeontx_log_err("failed to add MAC address filter on port %d",
590e4373bf1SSunil Kumar Kori 				 nic->port_id);
591e4373bf1SSunil Kumar Kori 		return ret;
592e4373bf1SSunil Kumar Kori 	}
593e4373bf1SSunil Kumar Kori 
594e4373bf1SSunil Kumar Kori 	return 0;
595e4373bf1SSunil Kumar Kori }
596e4373bf1SSunil Kumar Kori 
597caccf8b3SOlivier Matz static int
598ef7308fcSJerin Jacob octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
5996d13ea8eSOlivier Matz 					struct rte_ether_addr *addr)
600ef7308fcSJerin Jacob {
601ef7308fcSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
602*9614459bSSunil Kumar Kori 	uint8_t prom_mode = dev->data->promiscuous;
603ef7308fcSJerin Jacob 	int ret;
604ef7308fcSJerin Jacob 
605*9614459bSSunil Kumar Kori 	dev->data->promiscuous = 0;
606ef7308fcSJerin Jacob 	ret = octeontx_bgx_port_mac_set(nic->port_id, addr->addr_bytes);
607*9614459bSSunil Kumar Kori 	if (ret == 0) {
608*9614459bSSunil Kumar Kori 		/* Update same mac address to BGX CAM table */
609*9614459bSSunil Kumar Kori 		ret = octeontx_bgx_port_mac_add(nic->port_id, addr->addr_bytes,
610*9614459bSSunil Kumar Kori 						0);
611*9614459bSSunil Kumar Kori 	}
612*9614459bSSunil Kumar Kori 	if (ret < 0) {
613*9614459bSSunil Kumar Kori 		dev->data->promiscuous = prom_mode;
614ef7308fcSJerin Jacob 		octeontx_log_err("failed to set MAC address on port %d",
615ef7308fcSJerin Jacob 				 nic->port_id);
616*9614459bSSunil Kumar Kori 	}
617caccf8b3SOlivier Matz 
618caccf8b3SOlivier Matz 	return ret;
619ef7308fcSJerin Jacob }
620ef7308fcSJerin Jacob 
621bdad90d1SIvan Ilchenko static int
6227c0347a2SJerin Jacob octeontx_dev_info(struct rte_eth_dev *dev,
6237c0347a2SJerin Jacob 		struct rte_eth_dev_info *dev_info)
6247c0347a2SJerin Jacob {
625e4373bf1SSunil Kumar Kori 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
6267c0347a2SJerin Jacob 
6277c0347a2SJerin Jacob 	/* Autonegotiation may be disabled */
6287c0347a2SJerin Jacob 	dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
6297c0347a2SJerin Jacob 	dev_info->speed_capa |= ETH_LINK_SPEED_10M | ETH_LINK_SPEED_100M |
6307c0347a2SJerin Jacob 			ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
6317c0347a2SJerin Jacob 			ETH_LINK_SPEED_40G;
6327c0347a2SJerin Jacob 
633e4373bf1SSunil Kumar Kori 	dev_info->max_mac_addrs =
634e4373bf1SSunil Kumar Kori 				octeontx_bgx_port_mac_entries_get(nic->port_id);
6357c0347a2SJerin Jacob 	dev_info->max_rx_pktlen = PKI_MAX_PKTLEN;
6367c0347a2SJerin Jacob 	dev_info->max_rx_queues = 1;
6377c0347a2SJerin Jacob 	dev_info->max_tx_queues = PKO_MAX_NUM_DQ;
6387c0347a2SJerin Jacob 	dev_info->min_rx_bufsize = 0;
6397c0347a2SJerin Jacob 
6407c0347a2SJerin Jacob 	dev_info->default_rxconf = (struct rte_eth_rxconf) {
6417c0347a2SJerin Jacob 		.rx_free_thresh = 0,
6427c0347a2SJerin Jacob 		.rx_drop_en = 0,
643a9287089SPavan Nikhilesh 		.offloads = OCTEONTX_RX_OFFLOADS,
6447c0347a2SJerin Jacob 	};
6457c0347a2SJerin Jacob 
6467c0347a2SJerin Jacob 	dev_info->default_txconf = (struct rte_eth_txconf) {
6477c0347a2SJerin Jacob 		.tx_free_thresh = 0,
6482fd41a15SPavan Nikhilesh 		.offloads = OCTEONTX_TX_OFFLOADS,
6497c0347a2SJerin Jacob 	};
6507c0347a2SJerin Jacob 
651a9287089SPavan Nikhilesh 	dev_info->rx_offload_capa = OCTEONTX_RX_OFFLOADS;
652a9287089SPavan Nikhilesh 	dev_info->tx_offload_capa = OCTEONTX_TX_OFFLOADS;
65379c25ae2SPavan Nikhilesh 	dev_info->rx_queue_offload_capa = OCTEONTX_RX_OFFLOADS;
65479c25ae2SPavan Nikhilesh 	dev_info->tx_queue_offload_capa = OCTEONTX_TX_OFFLOADS;
655bdad90d1SIvan Ilchenko 
656bdad90d1SIvan Ilchenko 	return 0;
6577c0347a2SJerin Jacob }
6587c0347a2SJerin Jacob 
6597fe7c98fSJerin Jacob static void
6607fe7c98fSJerin Jacob octeontx_dq_info_getter(octeontx_dq_t *dq, void *out)
6617fe7c98fSJerin Jacob {
6627fe7c98fSJerin Jacob 	((octeontx_dq_t *)out)->lmtline_va = dq->lmtline_va;
6637fe7c98fSJerin Jacob 	((octeontx_dq_t *)out)->ioreg_va = dq->ioreg_va;
6647fe7c98fSJerin Jacob 	((octeontx_dq_t *)out)->fc_status_va = dq->fc_status_va;
6657fe7c98fSJerin Jacob }
6667fe7c98fSJerin Jacob 
6677fe7c98fSJerin Jacob static int
6687fe7c98fSJerin Jacob octeontx_vf_start_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic,
6697fe7c98fSJerin Jacob 				uint16_t qidx)
6707fe7c98fSJerin Jacob {
6717fe7c98fSJerin Jacob 	struct octeontx_txq *txq;
6727fe7c98fSJerin Jacob 	int res;
6737fe7c98fSJerin Jacob 
6747fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
6757fe7c98fSJerin Jacob 
6767fe7c98fSJerin Jacob 	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED)
6777fe7c98fSJerin Jacob 		return 0;
6787fe7c98fSJerin Jacob 
6797fe7c98fSJerin Jacob 	txq = dev->data->tx_queues[qidx];
6807fe7c98fSJerin Jacob 
6817fe7c98fSJerin Jacob 	res = octeontx_pko_channel_query_dqs(nic->base_ochan,
6827fe7c98fSJerin Jacob 						&txq->dq,
6837fe7c98fSJerin Jacob 						sizeof(octeontx_dq_t),
6847fe7c98fSJerin Jacob 						txq->queue_id,
6857fe7c98fSJerin Jacob 						octeontx_dq_info_getter);
6867fe7c98fSJerin Jacob 	if (res < 0) {
6877fe7c98fSJerin Jacob 		res = -EFAULT;
6887fe7c98fSJerin Jacob 		goto close_port;
6897fe7c98fSJerin Jacob 	}
6907fe7c98fSJerin Jacob 
6917fe7c98fSJerin Jacob 	dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
6927fe7c98fSJerin Jacob 	return res;
6937fe7c98fSJerin Jacob 
6947fe7c98fSJerin Jacob close_port:
6957fe7c98fSJerin Jacob 	(void)octeontx_port_stop(nic);
6967fe7c98fSJerin Jacob 	octeontx_pko_channel_stop(nic->base_ochan);
6977fe7c98fSJerin Jacob 	octeontx_pko_channel_close(nic->base_ochan);
6987fe7c98fSJerin Jacob 	dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
6997fe7c98fSJerin Jacob 	return res;
7007fe7c98fSJerin Jacob }
7017fe7c98fSJerin Jacob 
7027fe7c98fSJerin Jacob static int
7037fe7c98fSJerin Jacob octeontx_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
7047fe7c98fSJerin Jacob {
7057fe7c98fSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
7067fe7c98fSJerin Jacob 
7077fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
7087fe7c98fSJerin Jacob 	qidx = qidx % PKO_VF_NUM_DQ;
7097fe7c98fSJerin Jacob 	return octeontx_vf_start_tx_queue(dev, nic, qidx);
7107fe7c98fSJerin Jacob }
7117fe7c98fSJerin Jacob 
7127fe7c98fSJerin Jacob static inline int
7137fe7c98fSJerin Jacob octeontx_vf_stop_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic,
7147fe7c98fSJerin Jacob 			  uint16_t qidx)
7157fe7c98fSJerin Jacob {
7167fe7c98fSJerin Jacob 	int ret = 0;
7177fe7c98fSJerin Jacob 
7187fe7c98fSJerin Jacob 	RTE_SET_USED(nic);
7197fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
7207fe7c98fSJerin Jacob 
7217fe7c98fSJerin Jacob 	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
7227fe7c98fSJerin Jacob 		return 0;
7237fe7c98fSJerin Jacob 
7247fe7c98fSJerin Jacob 	dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
7257fe7c98fSJerin Jacob 	return ret;
7267fe7c98fSJerin Jacob }
7277fe7c98fSJerin Jacob 
7287fe7c98fSJerin Jacob static int
7297fe7c98fSJerin Jacob octeontx_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
7307fe7c98fSJerin Jacob {
7317fe7c98fSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
7327fe7c98fSJerin Jacob 
7337fe7c98fSJerin Jacob 	PMD_INIT_FUNC_TRACE();
7347fe7c98fSJerin Jacob 	qidx = qidx % PKO_VF_NUM_DQ;
7357fe7c98fSJerin Jacob 
7367fe7c98fSJerin Jacob 	return octeontx_vf_stop_tx_queue(dev, nic, qidx);
7377fe7c98fSJerin Jacob }
7387fe7c98fSJerin Jacob 
739150cbc84SJerin Jacob static void
740150cbc84SJerin Jacob octeontx_dev_tx_queue_release(void *tx_queue)
741150cbc84SJerin Jacob {
742150cbc84SJerin Jacob 	struct octeontx_txq *txq = tx_queue;
743150cbc84SJerin Jacob 	int res;
744150cbc84SJerin Jacob 
745150cbc84SJerin Jacob 	PMD_INIT_FUNC_TRACE();
746150cbc84SJerin Jacob 
747150cbc84SJerin Jacob 	if (txq) {
748150cbc84SJerin Jacob 		res = octeontx_dev_tx_queue_stop(txq->eth_dev, txq->queue_id);
749150cbc84SJerin Jacob 		if (res < 0)
750150cbc84SJerin Jacob 			octeontx_log_err("failed stop tx_queue(%d)\n",
751150cbc84SJerin Jacob 				   txq->queue_id);
752150cbc84SJerin Jacob 
753150cbc84SJerin Jacob 		rte_free(txq);
754150cbc84SJerin Jacob 	}
755150cbc84SJerin Jacob }
756150cbc84SJerin Jacob 
757150cbc84SJerin Jacob static int
758150cbc84SJerin Jacob octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
759150cbc84SJerin Jacob 			    uint16_t nb_desc, unsigned int socket_id,
760a4996bd8SWei Dai 			    const struct rte_eth_txconf *tx_conf __rte_unused)
761150cbc84SJerin Jacob {
762150cbc84SJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
763150cbc84SJerin Jacob 	struct octeontx_txq *txq = NULL;
764150cbc84SJerin Jacob 	uint16_t dq_num;
765150cbc84SJerin Jacob 	int res = 0;
766150cbc84SJerin Jacob 
767150cbc84SJerin Jacob 	RTE_SET_USED(nb_desc);
768150cbc84SJerin Jacob 	RTE_SET_USED(socket_id);
769150cbc84SJerin Jacob 
770a6d6f0afSPavan Nikhilesh 	dq_num = (nic->pko_vfid * PKO_VF_NUM_DQ) + qidx;
771150cbc84SJerin Jacob 
772150cbc84SJerin Jacob 	/* Socket id check */
773150cbc84SJerin Jacob 	if (socket_id != (unsigned int)SOCKET_ID_ANY &&
774150cbc84SJerin Jacob 			socket_id != (unsigned int)nic->node)
775150cbc84SJerin Jacob 		PMD_TX_LOG(INFO, "socket_id expected %d, configured %d",
776150cbc84SJerin Jacob 						socket_id, nic->node);
777150cbc84SJerin Jacob 
778150cbc84SJerin Jacob 	/* Free memory prior to re-allocation if needed. */
779150cbc84SJerin Jacob 	if (dev->data->tx_queues[qidx] != NULL) {
780150cbc84SJerin Jacob 		PMD_TX_LOG(DEBUG, "freeing memory prior to re-allocation %d",
781150cbc84SJerin Jacob 				qidx);
782150cbc84SJerin Jacob 		octeontx_dev_tx_queue_release(dev->data->tx_queues[qidx]);
783150cbc84SJerin Jacob 		dev->data->tx_queues[qidx] = NULL;
784150cbc84SJerin Jacob 	}
785150cbc84SJerin Jacob 
786150cbc84SJerin Jacob 	/* Allocating tx queue data structure */
787150cbc84SJerin Jacob 	txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct octeontx_txq),
788150cbc84SJerin Jacob 				 RTE_CACHE_LINE_SIZE, nic->node);
789150cbc84SJerin Jacob 	if (txq == NULL) {
790150cbc84SJerin Jacob 		octeontx_log_err("failed to allocate txq=%d", qidx);
791150cbc84SJerin Jacob 		res = -ENOMEM;
792150cbc84SJerin Jacob 		goto err;
793150cbc84SJerin Jacob 	}
794150cbc84SJerin Jacob 
795150cbc84SJerin Jacob 	txq->eth_dev = dev;
796150cbc84SJerin Jacob 	txq->queue_id = dq_num;
797150cbc84SJerin Jacob 	dev->data->tx_queues[qidx] = txq;
798150cbc84SJerin Jacob 	dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
799150cbc84SJerin Jacob 
800150cbc84SJerin Jacob 	res = octeontx_pko_channel_query_dqs(nic->base_ochan,
801150cbc84SJerin Jacob 						&txq->dq,
802150cbc84SJerin Jacob 						sizeof(octeontx_dq_t),
803150cbc84SJerin Jacob 						txq->queue_id,
804150cbc84SJerin Jacob 						octeontx_dq_info_getter);
805150cbc84SJerin Jacob 	if (res < 0) {
806150cbc84SJerin Jacob 		res = -EFAULT;
807150cbc84SJerin Jacob 		goto err;
808150cbc84SJerin Jacob 	}
809150cbc84SJerin Jacob 
810150cbc84SJerin Jacob 	PMD_TX_LOG(DEBUG, "[%d]:[%d] txq=%p nb_desc=%d lmtline=%p ioreg_va=%p fc_status_va=%p",
811150cbc84SJerin Jacob 			qidx, txq->queue_id, txq, nb_desc, txq->dq.lmtline_va,
812150cbc84SJerin Jacob 			txq->dq.ioreg_va,
813150cbc84SJerin Jacob 			txq->dq.fc_status_va);
814150cbc84SJerin Jacob 
815150cbc84SJerin Jacob 	return res;
816150cbc84SJerin Jacob 
817150cbc84SJerin Jacob err:
818150cbc84SJerin Jacob 	if (txq)
819150cbc84SJerin Jacob 		rte_free(txq);
820150cbc84SJerin Jacob 
821150cbc84SJerin Jacob 	return res;
822150cbc84SJerin Jacob }
823150cbc84SJerin Jacob 
824197438eeSJerin Jacob static int
825197438eeSJerin Jacob octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
826197438eeSJerin Jacob 				uint16_t nb_desc, unsigned int socket_id,
827197438eeSJerin Jacob 				const struct rte_eth_rxconf *rx_conf,
828197438eeSJerin Jacob 				struct rte_mempool *mb_pool)
829197438eeSJerin Jacob {
830197438eeSJerin Jacob 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
831197438eeSJerin Jacob 	struct rte_mempool_ops *mp_ops = NULL;
832197438eeSJerin Jacob 	struct octeontx_rxq *rxq = NULL;
833197438eeSJerin Jacob 	pki_pktbuf_cfg_t pktbuf_conf;
834197438eeSJerin Jacob 	pki_hash_cfg_t pki_hash;
835197438eeSJerin Jacob 	pki_qos_cfg_t pki_qos;
836197438eeSJerin Jacob 	uintptr_t pool;
837197438eeSJerin Jacob 	int ret, port;
838179c7e89SPavan Nikhilesh 	uint16_t gaura;
839197438eeSJerin Jacob 	unsigned int ev_queues = (nic->ev_queues * nic->port_id) + qidx;
840197438eeSJerin Jacob 	unsigned int ev_ports = (nic->ev_ports * nic->port_id) + qidx;
841197438eeSJerin Jacob 
842197438eeSJerin Jacob 	RTE_SET_USED(nb_desc);
843197438eeSJerin Jacob 
844197438eeSJerin Jacob 	memset(&pktbuf_conf, 0, sizeof(pktbuf_conf));
845197438eeSJerin Jacob 	memset(&pki_hash, 0, sizeof(pki_hash));
846197438eeSJerin Jacob 	memset(&pki_qos, 0, sizeof(pki_qos));
847197438eeSJerin Jacob 
848197438eeSJerin Jacob 	mp_ops = rte_mempool_get_ops(mb_pool->ops_index);
849197438eeSJerin Jacob 	if (strcmp(mp_ops->name, "octeontx_fpavf")) {
850197438eeSJerin Jacob 		octeontx_log_err("failed to find octeontx_fpavf mempool");
851197438eeSJerin Jacob 		return -ENOTSUP;
852197438eeSJerin Jacob 	}
853197438eeSJerin Jacob 
854197438eeSJerin Jacob 	/* Handle forbidden configurations */
855197438eeSJerin Jacob 	if (nic->pki.classifier_enable) {
856197438eeSJerin Jacob 		octeontx_log_err("cannot setup queue %d. "
857197438eeSJerin Jacob 					"Classifier option unsupported", qidx);
858197438eeSJerin Jacob 		return -EINVAL;
859197438eeSJerin Jacob 	}
860197438eeSJerin Jacob 
861197438eeSJerin Jacob 	port = nic->port_id;
862197438eeSJerin Jacob 
863197438eeSJerin Jacob 	/* Rx deferred start is not supported */
864197438eeSJerin Jacob 	if (rx_conf->rx_deferred_start) {
865197438eeSJerin Jacob 		octeontx_log_err("rx deferred start not supported");
866197438eeSJerin Jacob 		return -EINVAL;
867197438eeSJerin Jacob 	}
868197438eeSJerin Jacob 
869197438eeSJerin Jacob 	/* Verify queue index */
870197438eeSJerin Jacob 	if (qidx >= dev->data->nb_rx_queues) {
871197438eeSJerin Jacob 		octeontx_log_err("QID %d not supporteded (0 - %d available)\n",
872197438eeSJerin Jacob 				qidx, (dev->data->nb_rx_queues - 1));
873197438eeSJerin Jacob 		return -ENOTSUP;
874197438eeSJerin Jacob 	}
875197438eeSJerin Jacob 
876197438eeSJerin Jacob 	/* Socket id check */
877197438eeSJerin Jacob 	if (socket_id != (unsigned int)SOCKET_ID_ANY &&
878197438eeSJerin Jacob 			socket_id != (unsigned int)nic->node)
879197438eeSJerin Jacob 		PMD_RX_LOG(INFO, "socket_id expected %d, configured %d",
880197438eeSJerin Jacob 						socket_id, nic->node);
881197438eeSJerin Jacob 
882197438eeSJerin Jacob 	/* Allocating rx queue data structure */
883197438eeSJerin Jacob 	rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct octeontx_rxq),
884197438eeSJerin Jacob 				 RTE_CACHE_LINE_SIZE, nic->node);
885197438eeSJerin Jacob 	if (rxq == NULL) {
886197438eeSJerin Jacob 		octeontx_log_err("failed to allocate rxq=%d", qidx);
887197438eeSJerin Jacob 		return -ENOMEM;
888197438eeSJerin Jacob 	}
889197438eeSJerin Jacob 
890197438eeSJerin Jacob 	if (!nic->pki.initialized) {
891197438eeSJerin Jacob 		pktbuf_conf.port_type = 0;
892197438eeSJerin Jacob 		pki_hash.port_type = 0;
893197438eeSJerin Jacob 		pki_qos.port_type = 0;
894197438eeSJerin Jacob 
895197438eeSJerin Jacob 		pktbuf_conf.mmask.f_wqe_skip = 1;
896197438eeSJerin Jacob 		pktbuf_conf.mmask.f_first_skip = 1;
897197438eeSJerin Jacob 		pktbuf_conf.mmask.f_later_skip = 1;
898197438eeSJerin Jacob 		pktbuf_conf.mmask.f_mbuff_size = 1;
899197438eeSJerin Jacob 		pktbuf_conf.mmask.f_cache_mode = 1;
900197438eeSJerin Jacob 
901197438eeSJerin Jacob 		pktbuf_conf.wqe_skip = OCTTX_PACKET_WQE_SKIP;
902679dfdc9SNitin Saxena 		pktbuf_conf.first_skip = OCTTX_PACKET_FIRST_SKIP(mb_pool);
903197438eeSJerin Jacob 		pktbuf_conf.later_skip = OCTTX_PACKET_LATER_SKIP;
904197438eeSJerin Jacob 		pktbuf_conf.mbuff_size = (mb_pool->elt_size -
905197438eeSJerin Jacob 					RTE_PKTMBUF_HEADROOM -
906679dfdc9SNitin Saxena 					rte_pktmbuf_priv_size(mb_pool) -
907197438eeSJerin Jacob 					sizeof(struct rte_mbuf));
908197438eeSJerin Jacob 
909197438eeSJerin Jacob 		pktbuf_conf.cache_mode = PKI_OPC_MODE_STF2_STT;
910197438eeSJerin Jacob 
911197438eeSJerin Jacob 		ret = octeontx_pki_port_pktbuf_config(port, &pktbuf_conf);
912197438eeSJerin Jacob 		if (ret != 0) {
913197438eeSJerin Jacob 			octeontx_log_err("fail to configure pktbuf for port %d",
914197438eeSJerin Jacob 					port);
915197438eeSJerin Jacob 			rte_free(rxq);
916197438eeSJerin Jacob 			return ret;
917197438eeSJerin Jacob 		}
918197438eeSJerin Jacob 		PMD_RX_LOG(DEBUG, "Port %d Rx pktbuf configured:\n"
919197438eeSJerin Jacob 				"\tmbuf_size:\t0x%0x\n"
920197438eeSJerin Jacob 				"\twqe_skip:\t0x%0x\n"
921197438eeSJerin Jacob 				"\tfirst_skip:\t0x%0x\n"
922197438eeSJerin Jacob 				"\tlater_skip:\t0x%0x\n"
923197438eeSJerin Jacob 				"\tcache_mode:\t%s\n",
924197438eeSJerin Jacob 				port,
925197438eeSJerin Jacob 				pktbuf_conf.mbuff_size,
926197438eeSJerin Jacob 				pktbuf_conf.wqe_skip,
927197438eeSJerin Jacob 				pktbuf_conf.first_skip,
928197438eeSJerin Jacob 				pktbuf_conf.later_skip,
929197438eeSJerin Jacob 				(pktbuf_conf.cache_mode ==
930197438eeSJerin Jacob 						PKI_OPC_MODE_STT) ?
931197438eeSJerin Jacob 				"STT" :
932197438eeSJerin Jacob 				(pktbuf_conf.cache_mode ==
933197438eeSJerin Jacob 						PKI_OPC_MODE_STF) ?
934197438eeSJerin Jacob 				"STF" :
935197438eeSJerin Jacob 				(pktbuf_conf.cache_mode ==
936197438eeSJerin Jacob 						PKI_OPC_MODE_STF1_STT) ?
937197438eeSJerin Jacob 				"STF1_STT" : "STF2_STT");
938197438eeSJerin Jacob 
939197438eeSJerin Jacob 		if (nic->pki.hash_enable) {
940197438eeSJerin Jacob 			pki_hash.tag_dlc = 1;
941197438eeSJerin Jacob 			pki_hash.tag_slc = 1;
942197438eeSJerin Jacob 			pki_hash.tag_dlf = 1;
943197438eeSJerin Jacob 			pki_hash.tag_slf = 1;
944d0d65498SPavan Nikhilesh 			pki_hash.tag_prt = 1;
945197438eeSJerin Jacob 			octeontx_pki_port_hash_config(port, &pki_hash);
946197438eeSJerin Jacob 		}
947197438eeSJerin Jacob 
948197438eeSJerin Jacob 		pool = (uintptr_t)mb_pool->pool_id;
949197438eeSJerin Jacob 
950179c7e89SPavan Nikhilesh 		/* Get the gaura Id */
951179c7e89SPavan Nikhilesh 		gaura = octeontx_fpa_bufpool_gaura(pool);
952197438eeSJerin Jacob 
953197438eeSJerin Jacob 		pki_qos.qpg_qos = PKI_QPG_QOS_NONE;
954197438eeSJerin Jacob 		pki_qos.num_entry = 1;
955197438eeSJerin Jacob 		pki_qos.drop_policy = 0;
956d0d65498SPavan Nikhilesh 		pki_qos.tag_type = 0L;
957197438eeSJerin Jacob 		pki_qos.qos_entry[0].port_add = 0;
958197438eeSJerin Jacob 		pki_qos.qos_entry[0].gaura = gaura;
959197438eeSJerin Jacob 		pki_qos.qos_entry[0].ggrp_ok = ev_queues;
960197438eeSJerin Jacob 		pki_qos.qos_entry[0].ggrp_bad = ev_queues;
961197438eeSJerin Jacob 		pki_qos.qos_entry[0].grptag_bad = 0;
962197438eeSJerin Jacob 		pki_qos.qos_entry[0].grptag_ok = 0;
963197438eeSJerin Jacob 
964197438eeSJerin Jacob 		ret = octeontx_pki_port_create_qos(port, &pki_qos);
965197438eeSJerin Jacob 		if (ret < 0) {
966197438eeSJerin Jacob 			octeontx_log_err("failed to create QOS port=%d, q=%d",
967197438eeSJerin Jacob 					port, qidx);
968197438eeSJerin Jacob 			rte_free(rxq);
969197438eeSJerin Jacob 			return ret;
970197438eeSJerin Jacob 		}
971197438eeSJerin Jacob 		nic->pki.initialized = true;
972197438eeSJerin Jacob 	}
973197438eeSJerin Jacob 
974197438eeSJerin Jacob 	rxq->port_id = nic->port_id;
975197438eeSJerin Jacob 	rxq->eth_dev = dev;
976197438eeSJerin Jacob 	rxq->queue_id = qidx;
977197438eeSJerin Jacob 	rxq->evdev = nic->evdev;
978197438eeSJerin Jacob 	rxq->ev_queues = ev_queues;
979197438eeSJerin Jacob 	rxq->ev_ports = ev_ports;
980197438eeSJerin Jacob 
981197438eeSJerin Jacob 	dev->data->rx_queues[qidx] = rxq;
982197438eeSJerin Jacob 	dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
983197438eeSJerin Jacob 	return 0;
984197438eeSJerin Jacob }
985197438eeSJerin Jacob 
986197438eeSJerin Jacob static void
987197438eeSJerin Jacob octeontx_dev_rx_queue_release(void *rxq)
988197438eeSJerin Jacob {
989197438eeSJerin Jacob 	rte_free(rxq);
990197438eeSJerin Jacob }
991197438eeSJerin Jacob 
99220186d43SJerin Jacob static const uint32_t *
99320186d43SJerin Jacob octeontx_dev_supported_ptypes_get(struct rte_eth_dev *dev)
99420186d43SJerin Jacob {
99520186d43SJerin Jacob 	static const uint32_t ptypes[] = {
99620186d43SJerin Jacob 		RTE_PTYPE_L3_IPV4,
99720186d43SJerin Jacob 		RTE_PTYPE_L3_IPV4_EXT,
99820186d43SJerin Jacob 		RTE_PTYPE_L3_IPV6,
99920186d43SJerin Jacob 		RTE_PTYPE_L3_IPV6_EXT,
100020186d43SJerin Jacob 		RTE_PTYPE_L4_TCP,
100120186d43SJerin Jacob 		RTE_PTYPE_L4_UDP,
100220186d43SJerin Jacob 		RTE_PTYPE_L4_FRAG,
100320186d43SJerin Jacob 		RTE_PTYPE_UNKNOWN
100420186d43SJerin Jacob 	};
100520186d43SJerin Jacob 
100620186d43SJerin Jacob 	if (dev->rx_pkt_burst == octeontx_recv_pkts)
100720186d43SJerin Jacob 		return ptypes;
100820186d43SJerin Jacob 
100920186d43SJerin Jacob 	return NULL;
101020186d43SJerin Jacob }
101120186d43SJerin Jacob 
10125452a17dSPavan Nikhilesh static int
10135452a17dSPavan Nikhilesh octeontx_pool_ops(struct rte_eth_dev *dev, const char *pool)
10145452a17dSPavan Nikhilesh {
10155452a17dSPavan Nikhilesh 	RTE_SET_USED(dev);
10165452a17dSPavan Nikhilesh 
10175452a17dSPavan Nikhilesh 	if (!strcmp(pool, "octeontx_fpavf"))
10185452a17dSPavan Nikhilesh 		return 0;
10195452a17dSPavan Nikhilesh 
10205452a17dSPavan Nikhilesh 	return -ENOTSUP;
10215452a17dSPavan Nikhilesh }
10225452a17dSPavan Nikhilesh 
1023f18b146cSJerin Jacob /* Initialize and register driver with DPDK Application */
1024f18b146cSJerin Jacob static const struct eth_dev_ops octeontx_dev_ops = {
10257742c55aSJerin Jacob 	.dev_configure		 = octeontx_dev_configure,
10267c0347a2SJerin Jacob 	.dev_infos_get		 = octeontx_dev_info,
1027da6c6874SJerin Jacob 	.dev_close		 = octeontx_dev_close,
1028da6c6874SJerin Jacob 	.dev_start		 = octeontx_dev_start,
1029da6c6874SJerin Jacob 	.dev_stop		 = octeontx_dev_stop,
103015bce35bSJerin Jacob 	.promiscuous_enable	 = octeontx_dev_promisc_enable,
103115bce35bSJerin Jacob 	.promiscuous_disable	 = octeontx_dev_promisc_disable,
10324fac7c0aSJerin Jacob 	.link_update		 = octeontx_dev_link_update,
103355389909SJerin Jacob 	.stats_get		 = octeontx_dev_stats_get,
103455389909SJerin Jacob 	.stats_reset		 = octeontx_dev_stats_reset,
1035e4373bf1SSunil Kumar Kori 	.mac_addr_remove	 = octeontx_dev_mac_addr_del,
1036e4373bf1SSunil Kumar Kori 	.mac_addr_add		 = octeontx_dev_mac_addr_add,
1037ef7308fcSJerin Jacob 	.mac_addr_set		 = octeontx_dev_default_mac_addr_set,
10387fe7c98fSJerin Jacob 	.tx_queue_start		 = octeontx_dev_tx_queue_start,
10397fe7c98fSJerin Jacob 	.tx_queue_stop		 = octeontx_dev_tx_queue_stop,
1040150cbc84SJerin Jacob 	.tx_queue_setup		 = octeontx_dev_tx_queue_setup,
1041150cbc84SJerin Jacob 	.tx_queue_release	 = octeontx_dev_tx_queue_release,
1042197438eeSJerin Jacob 	.rx_queue_setup		 = octeontx_dev_rx_queue_setup,
1043197438eeSJerin Jacob 	.rx_queue_release	 = octeontx_dev_rx_queue_release,
104420186d43SJerin Jacob 	.dev_supported_ptypes_get = octeontx_dev_supported_ptypes_get,
10455452a17dSPavan Nikhilesh 	.pool_ops_supported      = octeontx_pool_ops,
1046f18b146cSJerin Jacob };
1047f18b146cSJerin Jacob 
1048f7be70e5SJerin Jacob /* Create Ethdev interface per BGX LMAC ports */
1049f7be70e5SJerin Jacob static int
1050f7be70e5SJerin Jacob octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
1051f7be70e5SJerin Jacob 			int socket_id)
1052f7be70e5SJerin Jacob {
1053f18b146cSJerin Jacob 	int res;
1054a6d6f0afSPavan Nikhilesh 	size_t pko_vfid;
1055f18b146cSJerin Jacob 	char octtx_name[OCTEONTX_MAX_NAME_LEN];
1056f18b146cSJerin Jacob 	struct octeontx_nic *nic = NULL;
1057f18b146cSJerin Jacob 	struct rte_eth_dev *eth_dev = NULL;
10585f19dee6SJianfeng Tan 	struct rte_eth_dev_data *data;
1059f18b146cSJerin Jacob 	const char *name = rte_vdev_device_name(dev);
1060e4373bf1SSunil Kumar Kori 	int max_entries;
1061f7be70e5SJerin Jacob 
1062f18b146cSJerin Jacob 	PMD_INIT_FUNC_TRACE();
1063f18b146cSJerin Jacob 
1064f18b146cSJerin Jacob 	sprintf(octtx_name, "%s_%d", name, port);
1065f18b146cSJerin Jacob 	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1066f18b146cSJerin Jacob 		eth_dev = rte_eth_dev_attach_secondary(octtx_name);
1067f18b146cSJerin Jacob 		if (eth_dev == NULL)
1068f7be70e5SJerin Jacob 			return -ENODEV;
1069f18b146cSJerin Jacob 
1070d1c3ab22SFerruh Yigit 		eth_dev->dev_ops = &octeontx_dev_ops;
1071d1c3ab22SFerruh Yigit 		eth_dev->device = &dev->device;
1072da6c6874SJerin Jacob 		eth_dev->tx_pkt_burst = octeontx_xmit_pkts;
1073da6c6874SJerin Jacob 		eth_dev->rx_pkt_burst = octeontx_recv_pkts;
1074fbe90cddSThomas Monjalon 		rte_eth_dev_probing_finish(eth_dev);
1075f18b146cSJerin Jacob 		return 0;
1076f18b146cSJerin Jacob 	}
1077f18b146cSJerin Jacob 
1078e16adf08SThomas Monjalon 	/* Reserve an ethdev entry */
1079e16adf08SThomas Monjalon 	eth_dev = rte_eth_dev_allocate(octtx_name);
1080e16adf08SThomas Monjalon 	if (eth_dev == NULL) {
1081e16adf08SThomas Monjalon 		octeontx_log_err("failed to allocate rte_eth_dev");
1082e16adf08SThomas Monjalon 		res = -ENOMEM;
1083e16adf08SThomas Monjalon 		goto err;
1084e16adf08SThomas Monjalon 	}
1085e16adf08SThomas Monjalon 	data = eth_dev->data;
1086e16adf08SThomas Monjalon 
1087f18b146cSJerin Jacob 	nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id);
1088f18b146cSJerin Jacob 	if (nic == NULL) {
1089f18b146cSJerin Jacob 		octeontx_log_err("failed to allocate nic structure");
1090f18b146cSJerin Jacob 		res = -ENOMEM;
1091f18b146cSJerin Jacob 		goto err;
1092f18b146cSJerin Jacob 	}
1093e16adf08SThomas Monjalon 	data->dev_private = nic;
1094a6d6f0afSPavan Nikhilesh 	pko_vfid = octeontx_pko_get_vfid();
1095f18b146cSJerin Jacob 
1096a6d6f0afSPavan Nikhilesh 	if (pko_vfid == SIZE_MAX) {
1097a6d6f0afSPavan Nikhilesh 		octeontx_log_err("failed to get pko vfid");
1098a6d6f0afSPavan Nikhilesh 		res = -ENODEV;
1099a6d6f0afSPavan Nikhilesh 		goto err;
1100a6d6f0afSPavan Nikhilesh 	}
1101a6d6f0afSPavan Nikhilesh 
1102a6d6f0afSPavan Nikhilesh 	nic->pko_vfid = pko_vfid;
1103f18b146cSJerin Jacob 	nic->port_id = port;
1104f18b146cSJerin Jacob 	nic->evdev = evdev;
1105f18b146cSJerin Jacob 
1106f18b146cSJerin Jacob 	res = octeontx_port_open(nic);
1107f18b146cSJerin Jacob 	if (res < 0)
1108f18b146cSJerin Jacob 		goto err;
1109f18b146cSJerin Jacob 
1110f18b146cSJerin Jacob 	/* Rx side port configuration */
1111f18b146cSJerin Jacob 	res = octeontx_pki_port_open(port);
1112f18b146cSJerin Jacob 	if (res != 0) {
1113f18b146cSJerin Jacob 		octeontx_log_err("failed to open PKI port %d", port);
1114f18b146cSJerin Jacob 		res = -ENODEV;
1115f18b146cSJerin Jacob 		goto err;
1116f18b146cSJerin Jacob 	}
1117f18b146cSJerin Jacob 
1118f18b146cSJerin Jacob 	eth_dev->device = &dev->device;
1119f18b146cSJerin Jacob 	eth_dev->intr_handle = NULL;
1120f18b146cSJerin Jacob 	eth_dev->data->kdrv = RTE_KDRV_NONE;
1121f18b146cSJerin Jacob 	eth_dev->data->numa_node = dev->device.numa_node;
1122f18b146cSJerin Jacob 
1123f18b146cSJerin Jacob 	data->port_id = eth_dev->data->port_id;
1124f18b146cSJerin Jacob 
1125f18b146cSJerin Jacob 	nic->ev_queues = 1;
1126f18b146cSJerin Jacob 	nic->ev_ports = 1;
1127f18b146cSJerin Jacob 
1128f18b146cSJerin Jacob 	data->dev_link.link_status = ETH_LINK_DOWN;
1129f18b146cSJerin Jacob 	data->dev_started = 0;
1130f18b146cSJerin Jacob 	data->promiscuous = 0;
1131f18b146cSJerin Jacob 	data->all_multicast = 0;
1132f18b146cSJerin Jacob 	data->scattered_rx = 0;
1133f18b146cSJerin Jacob 
1134e4373bf1SSunil Kumar Kori 	/* Get maximum number of supported MAC entries */
1135e4373bf1SSunil Kumar Kori 	max_entries = octeontx_bgx_port_mac_entries_get(nic->port_id);
1136e4373bf1SSunil Kumar Kori 	if (max_entries < 0) {
1137e4373bf1SSunil Kumar Kori 		octeontx_log_err("Failed to get max entries for mac addr");
1138e4373bf1SSunil Kumar Kori 		res = -ENOTSUP;
1139e4373bf1SSunil Kumar Kori 		goto err;
1140e4373bf1SSunil Kumar Kori 	}
1141e4373bf1SSunil Kumar Kori 
1142e4373bf1SSunil Kumar Kori 	data->mac_addrs = rte_zmalloc_socket(octtx_name, max_entries *
1143e4373bf1SSunil Kumar Kori 					     RTE_ETHER_ADDR_LEN, 0,
1144f18b146cSJerin Jacob 							socket_id);
1145f18b146cSJerin Jacob 	if (data->mac_addrs == NULL) {
1146f18b146cSJerin Jacob 		octeontx_log_err("failed to allocate memory for mac_addrs");
1147f18b146cSJerin Jacob 		res = -ENOMEM;
1148f18b146cSJerin Jacob 		goto err;
1149f18b146cSJerin Jacob 	}
1150f18b146cSJerin Jacob 
1151f18b146cSJerin Jacob 	eth_dev->dev_ops = &octeontx_dev_ops;
1152f18b146cSJerin Jacob 
1153f18b146cSJerin Jacob 	/* Finally save ethdev pointer to the NIC structure */
1154f18b146cSJerin Jacob 	nic->dev = eth_dev;
1155f18b146cSJerin Jacob 
1156f18b146cSJerin Jacob 	if (nic->port_id != data->port_id) {
1157f18b146cSJerin Jacob 		octeontx_log_err("eth_dev->port_id (%d) is diff to orig (%d)",
1158f18b146cSJerin Jacob 				data->port_id, nic->port_id);
1159f18b146cSJerin Jacob 		res = -EINVAL;
11609e399b88SSunil Kumar Kori 		goto free_mac_addrs;
1161f18b146cSJerin Jacob 	}
1162f18b146cSJerin Jacob 
1163f18b146cSJerin Jacob 	/* Update port_id mac to eth_dev */
116435b2d13fSOlivier Matz 	memcpy(data->mac_addrs, nic->mac_addr, RTE_ETHER_ADDR_LEN);
1165f18b146cSJerin Jacob 
1166*9614459bSSunil Kumar Kori 	/* Update same mac address to BGX CAM table at index 0 */
1167*9614459bSSunil Kumar Kori 	octeontx_bgx_port_mac_add(nic->port_id, nic->mac_addr, 0);
1168*9614459bSSunil Kumar Kori 
1169f18b146cSJerin Jacob 	PMD_INIT_LOG(DEBUG, "ethdev info: ");
1170f18b146cSJerin Jacob 	PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d",
1171f18b146cSJerin Jacob 				nic->port_id, nic->port_ena,
1172f18b146cSJerin Jacob 				nic->base_ochan, nic->num_ochans,
1173f18b146cSJerin Jacob 				nic->num_tx_queues);
1174f18b146cSJerin Jacob 	PMD_INIT_LOG(DEBUG, "speed %d mtu %d", nic->speed, nic->mtu);
1175f18b146cSJerin Jacob 
1176989d4926SPavan Nikhilesh 	rte_octeontx_pchan_map[(nic->base_ochan >> 8) & 0x7]
1177989d4926SPavan Nikhilesh 		[(nic->base_ochan >> 4) & 0xF] = data->port_id;
1178989d4926SPavan Nikhilesh 
1179fbe90cddSThomas Monjalon 	rte_eth_dev_probing_finish(eth_dev);
1180f18b146cSJerin Jacob 	return data->port_id;
1181f18b146cSJerin Jacob 
11829e399b88SSunil Kumar Kori free_mac_addrs:
11839e399b88SSunil Kumar Kori 	rte_free(data->mac_addrs);
1184f18b146cSJerin Jacob err:
1185a98122efSSantosh Shukla 	if (nic)
1186f18b146cSJerin Jacob 		octeontx_port_close(nic);
1187f18b146cSJerin Jacob 
1188f18b146cSJerin Jacob 	rte_eth_dev_release_port(eth_dev);
1189f18b146cSJerin Jacob 
1190f18b146cSJerin Jacob 	return res;
1191f7be70e5SJerin Jacob }
1192f7be70e5SJerin Jacob 
1193f7be70e5SJerin Jacob /* Un initialize octeontx device */
1194f7be70e5SJerin Jacob static int
1195f7be70e5SJerin Jacob octeontx_remove(struct rte_vdev_device *dev)
1196f7be70e5SJerin Jacob {
1197f7be70e5SJerin Jacob 	char octtx_name[OCTEONTX_MAX_NAME_LEN];
1198f7be70e5SJerin Jacob 	struct rte_eth_dev *eth_dev = NULL;
1199f7be70e5SJerin Jacob 	struct octeontx_nic *nic = NULL;
1200f7be70e5SJerin Jacob 	int i;
1201f7be70e5SJerin Jacob 
1202f7be70e5SJerin Jacob 	if (dev == NULL)
1203f7be70e5SJerin Jacob 		return -EINVAL;
1204f7be70e5SJerin Jacob 
1205f7be70e5SJerin Jacob 	for (i = 0; i < OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT; i++) {
1206f7be70e5SJerin Jacob 		sprintf(octtx_name, "eth_octeontx_%d", i);
1207f7be70e5SJerin Jacob 
1208f7be70e5SJerin Jacob 		/* reserve an ethdev entry */
1209f7be70e5SJerin Jacob 		eth_dev = rte_eth_dev_allocated(octtx_name);
1210f7be70e5SJerin Jacob 		if (eth_dev == NULL)
1211f7be70e5SJerin Jacob 			return -ENODEV;
1212f7be70e5SJerin Jacob 
12134852aa8fSQi Zhang 		if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1214662dbc32SThomas Monjalon 			rte_eth_dev_release_port(eth_dev);
12154852aa8fSQi Zhang 			continue;
12164852aa8fSQi Zhang 		}
12174852aa8fSQi Zhang 
1218f7be70e5SJerin Jacob 		nic = octeontx_pmd_priv(eth_dev);
1219f7be70e5SJerin Jacob 		rte_event_dev_stop(nic->evdev);
1220f7be70e5SJerin Jacob 		PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name);
1221f7be70e5SJerin Jacob 
1222f7be70e5SJerin Jacob 		rte_eth_dev_release_port(eth_dev);
1223f7be70e5SJerin Jacob 		rte_event_dev_close(nic->evdev);
1224f7be70e5SJerin Jacob 	}
1225f7be70e5SJerin Jacob 
12264852aa8fSQi Zhang 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
12274852aa8fSQi Zhang 		return 0;
12284852aa8fSQi Zhang 
1229f7be70e5SJerin Jacob 	/* Free FC resource */
1230f7be70e5SJerin Jacob 	octeontx_pko_fc_free();
1231f7be70e5SJerin Jacob 
1232f7be70e5SJerin Jacob 	return 0;
1233f7be70e5SJerin Jacob }
1234f7be70e5SJerin Jacob 
1235f7be70e5SJerin Jacob /* Initialize octeontx device */
1236f7be70e5SJerin Jacob static int
1237f7be70e5SJerin Jacob octeontx_probe(struct rte_vdev_device *dev)
1238f7be70e5SJerin Jacob {
1239f7be70e5SJerin Jacob 	const char *dev_name;
1240f7be70e5SJerin Jacob 	static int probe_once;
1241f7be70e5SJerin Jacob 	uint8_t socket_id, qlist;
1242f7be70e5SJerin Jacob 	int tx_vfcnt, port_id, evdev, qnum, pnum, res, i;
1243f7be70e5SJerin Jacob 	struct rte_event_dev_config dev_conf;
1244f7be70e5SJerin Jacob 	const char *eventdev_name = "event_octeontx";
1245f7be70e5SJerin Jacob 	struct rte_event_dev_info info;
1246ee27edbeSJianfeng Tan 	struct rte_eth_dev *eth_dev;
1247f7be70e5SJerin Jacob 
1248f7be70e5SJerin Jacob 	struct octeontx_vdev_init_params init_params = {
1249f7be70e5SJerin Jacob 		OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT
1250f7be70e5SJerin Jacob 	};
1251f7be70e5SJerin Jacob 
1252f7be70e5SJerin Jacob 	dev_name = rte_vdev_device_name(dev);
1253ee27edbeSJianfeng Tan 
1254ee27edbeSJianfeng Tan 	if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
1255ee27edbeSJianfeng Tan 	    strlen(rte_vdev_device_args(dev)) == 0) {
1256ee27edbeSJianfeng Tan 		eth_dev = rte_eth_dev_attach_secondary(dev_name);
1257ee27edbeSJianfeng Tan 		if (!eth_dev) {
1258e6da1f00SStephen Hemminger 			PMD_INIT_LOG(ERR, "Failed to probe %s", dev_name);
1259ee27edbeSJianfeng Tan 			return -1;
1260ee27edbeSJianfeng Tan 		}
1261ee27edbeSJianfeng Tan 		/* TODO: request info from primary to set up Rx and Tx */
1262ee27edbeSJianfeng Tan 		eth_dev->dev_ops = &octeontx_dev_ops;
1263d1c3ab22SFerruh Yigit 		eth_dev->device = &dev->device;
1264fbe90cddSThomas Monjalon 		rte_eth_dev_probing_finish(eth_dev);
1265ee27edbeSJianfeng Tan 		return 0;
1266ee27edbeSJianfeng Tan 	}
1267ee27edbeSJianfeng Tan 
1268f7be70e5SJerin Jacob 	res = octeontx_parse_vdev_init_params(&init_params, dev);
1269f7be70e5SJerin Jacob 	if (res < 0)
1270f7be70e5SJerin Jacob 		return -EINVAL;
1271f7be70e5SJerin Jacob 
1272f7be70e5SJerin Jacob 	if (init_params.nr_port > OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT) {
1273f7be70e5SJerin Jacob 		octeontx_log_err("nr_port (%d) > max (%d)", init_params.nr_port,
1274f7be70e5SJerin Jacob 				OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT);
1275f7be70e5SJerin Jacob 		return -ENOTSUP;
1276f7be70e5SJerin Jacob 	}
1277f7be70e5SJerin Jacob 
1278f7be70e5SJerin Jacob 	PMD_INIT_LOG(DEBUG, "initializing %s pmd", dev_name);
1279f7be70e5SJerin Jacob 
1280f7be70e5SJerin Jacob 	socket_id = rte_socket_id();
1281f7be70e5SJerin Jacob 
1282f7be70e5SJerin Jacob 	tx_vfcnt = octeontx_pko_vf_count();
1283f7be70e5SJerin Jacob 
1284f7be70e5SJerin Jacob 	if (tx_vfcnt < init_params.nr_port) {
1285f7be70e5SJerin Jacob 		octeontx_log_err("not enough PKO (%d) for port number (%d)",
1286f7be70e5SJerin Jacob 				tx_vfcnt, init_params.nr_port);
1287f7be70e5SJerin Jacob 		return -EINVAL;
1288f7be70e5SJerin Jacob 	}
1289f7be70e5SJerin Jacob 	evdev = rte_event_dev_get_dev_id(eventdev_name);
1290f7be70e5SJerin Jacob 	if (evdev < 0) {
1291f7be70e5SJerin Jacob 		octeontx_log_err("eventdev %s not found", eventdev_name);
1292f7be70e5SJerin Jacob 		return -ENODEV;
1293f7be70e5SJerin Jacob 	}
1294f7be70e5SJerin Jacob 
1295f7be70e5SJerin Jacob 	res = rte_event_dev_info_get(evdev, &info);
1296f7be70e5SJerin Jacob 	if (res < 0) {
1297f7be70e5SJerin Jacob 		octeontx_log_err("failed to eventdev info %d", res);
1298f7be70e5SJerin Jacob 		return -EINVAL;
1299f7be70e5SJerin Jacob 	}
1300f7be70e5SJerin Jacob 
1301f7be70e5SJerin Jacob 	PMD_INIT_LOG(DEBUG, "max_queue %d max_port %d",
1302f7be70e5SJerin Jacob 			info.max_event_queues, info.max_event_ports);
1303f7be70e5SJerin Jacob 
1304f7be70e5SJerin Jacob 	if (octeontx_pko_init_fc(tx_vfcnt))
1305f7be70e5SJerin Jacob 		return -ENOMEM;
1306f7be70e5SJerin Jacob 
1307f7be70e5SJerin Jacob 	devconf_set_default_sane_values(&dev_conf, &info);
1308f7be70e5SJerin Jacob 	res = rte_event_dev_configure(evdev, &dev_conf);
1309f7be70e5SJerin Jacob 	if (res < 0)
1310f7be70e5SJerin Jacob 		goto parse_error;
1311f7be70e5SJerin Jacob 
1312f7be70e5SJerin Jacob 	rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_PORT_COUNT,
1313f7be70e5SJerin Jacob 			(uint32_t *)&pnum);
1314f7be70e5SJerin Jacob 	rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
1315f7be70e5SJerin Jacob 			(uint32_t *)&qnum);
1316f7be70e5SJerin Jacob 	if (pnum < qnum) {
1317f7be70e5SJerin Jacob 		octeontx_log_err("too few event ports (%d) for event_q(%d)",
1318f7be70e5SJerin Jacob 				pnum, qnum);
1319f7be70e5SJerin Jacob 		res = -EINVAL;
1320f7be70e5SJerin Jacob 		goto parse_error;
1321f7be70e5SJerin Jacob 	}
13227efd5202SAnoob Joseph 
13237efd5202SAnoob Joseph 	/* Enable all queues available */
1324f7be70e5SJerin Jacob 	for (i = 0; i < qnum; i++) {
1325f7be70e5SJerin Jacob 		res = rte_event_queue_setup(evdev, i, NULL);
1326f7be70e5SJerin Jacob 		if (res < 0) {
1327f7be70e5SJerin Jacob 			octeontx_log_err("failed to setup event_q(%d): res %d",
1328f7be70e5SJerin Jacob 					i, res);
1329f7be70e5SJerin Jacob 			goto parse_error;
1330f7be70e5SJerin Jacob 		}
1331f7be70e5SJerin Jacob 	}
1332f7be70e5SJerin Jacob 
13337efd5202SAnoob Joseph 	/* Enable all ports available */
1334f7be70e5SJerin Jacob 	for (i = 0; i < pnum; i++) {
1335f7be70e5SJerin Jacob 		res = rte_event_port_setup(evdev, i, NULL);
1336f7be70e5SJerin Jacob 		if (res < 0) {
1337f7be70e5SJerin Jacob 			res = -ENODEV;
1338f7be70e5SJerin Jacob 			octeontx_log_err("failed to setup ev port(%d) res=%d",
1339f7be70e5SJerin Jacob 						i, res);
1340f7be70e5SJerin Jacob 			goto parse_error;
1341f7be70e5SJerin Jacob 		}
13427efd5202SAnoob Joseph 	}
13437efd5202SAnoob Joseph 
13447efd5202SAnoob Joseph 	/*
13457efd5202SAnoob Joseph 	 * Do 1:1 links for ports & queues. All queues would be mapped to
13467efd5202SAnoob Joseph 	 * one port. If there are more ports than queues, then some ports
13477efd5202SAnoob Joseph 	 * won't be linked to any queue.
13487efd5202SAnoob Joseph 	 */
13497efd5202SAnoob Joseph 	for (i = 0; i < qnum; i++) {
1350f7be70e5SJerin Jacob 		/* Link one queue to one event port */
1351f7be70e5SJerin Jacob 		qlist = i;
1352f7be70e5SJerin Jacob 		res = rte_event_port_link(evdev, i, &qlist, NULL, 1);
1353f7be70e5SJerin Jacob 		if (res < 0) {
1354f7be70e5SJerin Jacob 			res = -ENODEV;
1355f7be70e5SJerin Jacob 			octeontx_log_err("failed to link port (%d): res=%d",
1356f7be70e5SJerin Jacob 					i, res);
1357f7be70e5SJerin Jacob 			goto parse_error;
1358f7be70e5SJerin Jacob 		}
1359f7be70e5SJerin Jacob 	}
1360f7be70e5SJerin Jacob 
1361f7be70e5SJerin Jacob 	/* Create ethdev interface */
1362f7be70e5SJerin Jacob 	for (i = 0; i < init_params.nr_port; i++) {
1363f7be70e5SJerin Jacob 		port_id = octeontx_create(dev, i, evdev, socket_id);
1364f7be70e5SJerin Jacob 		if (port_id < 0) {
1365f7be70e5SJerin Jacob 			octeontx_log_err("failed to create device %s",
1366f7be70e5SJerin Jacob 					dev_name);
1367f7be70e5SJerin Jacob 			res = -ENODEV;
1368f7be70e5SJerin Jacob 			goto parse_error;
1369f7be70e5SJerin Jacob 		}
1370f7be70e5SJerin Jacob 
1371f7be70e5SJerin Jacob 		PMD_INIT_LOG(INFO, "created ethdev %s for port %d", dev_name,
1372f7be70e5SJerin Jacob 					port_id);
1373f7be70e5SJerin Jacob 	}
1374f7be70e5SJerin Jacob 
1375f7be70e5SJerin Jacob 	if (probe_once) {
1376f7be70e5SJerin Jacob 		octeontx_log_err("interface %s not supported", dev_name);
1377f7be70e5SJerin Jacob 		octeontx_remove(dev);
1378f7be70e5SJerin Jacob 		res = -ENOTSUP;
1379f7be70e5SJerin Jacob 		goto parse_error;
1380f7be70e5SJerin Jacob 	}
1381dfb0c75bSPavan Nikhilesh 	rte_mbuf_set_platform_mempool_ops("octeontx_fpavf");
1382f7be70e5SJerin Jacob 	probe_once = 1;
1383f7be70e5SJerin Jacob 
1384f7be70e5SJerin Jacob 	return 0;
1385f7be70e5SJerin Jacob 
1386f7be70e5SJerin Jacob parse_error:
1387f7be70e5SJerin Jacob 	octeontx_pko_fc_free();
1388f7be70e5SJerin Jacob 	return res;
1389f7be70e5SJerin Jacob }
1390f7be70e5SJerin Jacob 
1391f7be70e5SJerin Jacob static struct rte_vdev_driver octeontx_pmd_drv = {
1392f7be70e5SJerin Jacob 	.probe = octeontx_probe,
1393f7be70e5SJerin Jacob 	.remove = octeontx_remove,
1394f7be70e5SJerin Jacob };
1395f7be70e5SJerin Jacob 
1396f7be70e5SJerin Jacob RTE_PMD_REGISTER_VDEV(OCTEONTX_PMD, octeontx_pmd_drv);
1397f7be70e5SJerin Jacob RTE_PMD_REGISTER_ALIAS(OCTEONTX_PMD, eth_octeontx);
1398f7be70e5SJerin Jacob RTE_PMD_REGISTER_PARAM_STRING(OCTEONTX_PMD, "nr_port=<int> ");
1399