xref: /dpdk/drivers/net/ark/ark_ethdev.c (revision a861d5a2994d3205fe5b702e761534740cd745dd)
1540914bcSEd Czeck /* SPDX-License-Identifier: BSD-3-Clause
2540914bcSEd Czeck  * Copyright (c) 2015-2018 Atomic Rules LLC
31131cbf0SEd Czeck  */
41131cbf0SEd Czeck 
51131cbf0SEd Czeck #include <unistd.h>
61131cbf0SEd Czeck #include <sys/stat.h>
71131cbf0SEd Czeck #include <dlfcn.h>
81131cbf0SEd Czeck 
91f37cb2bSDavid Marchand #include <bus_pci_driver.h>
10df96fd0dSBruce Richardson #include <ethdev_pci.h>
111131cbf0SEd Czeck #include <rte_kvargs.h>
121131cbf0SEd Czeck 
131131cbf0SEd Czeck #include "ark_global.h"
141131cbf0SEd Czeck #include "ark_logs.h"
15727b3fe2SEd Czeck #include "ark_ethdev_tx.h"
16727b3fe2SEd Czeck #include "ark_ethdev_rx.h"
17727b3fe2SEd Czeck #include "ark_mpu.h"
18727b3fe2SEd Czeck #include "ark_ddm.h"
19727b3fe2SEd Czeck #include "ark_udm.h"
20727b3fe2SEd Czeck #include "ark_pktdir.h"
21727b3fe2SEd Czeck #include "ark_pktgen.h"
22727b3fe2SEd Czeck #include "ark_pktchkr.h"
231131cbf0SEd Czeck 
241131cbf0SEd Czeck /*  Internal prototypes */
251131cbf0SEd Czeck static int eth_ark_check_args(struct ark_adapter *ark, const char *params);
261131cbf0SEd Czeck static int eth_ark_dev_init(struct rte_eth_dev *dev);
27727b3fe2SEd Czeck static int ark_config_device(struct rte_eth_dev *dev);
281131cbf0SEd Czeck static int eth_ark_dev_uninit(struct rte_eth_dev *eth_dev);
291131cbf0SEd Czeck static int eth_ark_dev_configure(struct rte_eth_dev *dev);
30727b3fe2SEd Czeck static int eth_ark_dev_start(struct rte_eth_dev *dev);
3162024eb8SIvan Ilchenko static int eth_ark_dev_stop(struct rte_eth_dev *dev);
32b142387bSThomas Monjalon static int eth_ark_dev_close(struct rte_eth_dev *dev);
33bdad90d1SIvan Ilchenko static int eth_ark_dev_info_get(struct rte_eth_dev *dev,
341131cbf0SEd Czeck 				struct rte_eth_dev_info *dev_info);
35727b3fe2SEd Czeck static int eth_ark_dev_link_update(struct rte_eth_dev *dev,
36727b3fe2SEd Czeck 				   int wait_to_complete);
37727b3fe2SEd Czeck static int eth_ark_dev_set_link_up(struct rte_eth_dev *dev);
38727b3fe2SEd Czeck static int eth_ark_dev_set_link_down(struct rte_eth_dev *dev);
39d5b0924bSMatan Azrad static int eth_ark_dev_stats_get(struct rte_eth_dev *dev,
40727b3fe2SEd Czeck 				  struct rte_eth_stats *stats);
419970a9adSIgor Romanov static int eth_ark_dev_stats_reset(struct rte_eth_dev *dev);
42caccf8b3SOlivier Matz static int eth_ark_set_default_mac_addr(struct rte_eth_dev *dev,
436d13ea8eSOlivier Matz 					 struct rte_ether_addr *mac_addr);
446d01e580SWei Dai static int eth_ark_macaddr_add(struct rte_eth_dev *dev,
456d13ea8eSOlivier Matz 			       struct rte_ether_addr *mac_addr,
46727b3fe2SEd Czeck 			       uint32_t index,
47727b3fe2SEd Czeck 			       uint32_t pool);
48727b3fe2SEd Czeck static void eth_ark_macaddr_remove(struct rte_eth_dev *dev,
49727b3fe2SEd Czeck 				   uint32_t index);
509ae74488SJohn Miller static int  eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
511131cbf0SEd Czeck 
521131cbf0SEd Czeck /*
531131cbf0SEd Czeck  * The packet generator is a functional block used to generate packet
541131cbf0SEd Czeck  * patterns for testing.  It is not intended for nominal use.
551131cbf0SEd Czeck  */
561131cbf0SEd Czeck #define ARK_PKTGEN_ARG "Pkt_gen"
571131cbf0SEd Czeck 
581131cbf0SEd Czeck /*
591131cbf0SEd Czeck  * The packet checker is a functional block used to verify packet
601131cbf0SEd Czeck  * patterns for testing.  It is not intended for nominal use.
611131cbf0SEd Czeck  */
621131cbf0SEd Czeck #define ARK_PKTCHKR_ARG "Pkt_chkr"
631131cbf0SEd Czeck 
641131cbf0SEd Czeck /*
651131cbf0SEd Czeck  * The packet director is used to select the internal ingress and
661131cbf0SEd Czeck  * egress packets paths during testing.  It is not intended for
671131cbf0SEd Czeck  * nominal use.
681131cbf0SEd Czeck  */
691131cbf0SEd Czeck #define ARK_PKTDIR_ARG "Pkt_dir"
701131cbf0SEd Czeck 
711131cbf0SEd Czeck /* Devinfo configurations */
721131cbf0SEd Czeck #define ARK_RX_MAX_QUEUE (4096 * 4)
731131cbf0SEd Czeck #define ARK_RX_MIN_QUEUE (512)
741131cbf0SEd Czeck #define ARK_RX_MAX_PKT_LEN ((16 * 1024) - 128)
751131cbf0SEd Czeck #define ARK_RX_MIN_BUFSIZE (1024)
761131cbf0SEd Czeck 
771131cbf0SEd Czeck #define ARK_TX_MAX_QUEUE (4096 * 4)
781131cbf0SEd Czeck #define ARK_TX_MIN_QUEUE (256)
791131cbf0SEd Czeck 
801131cbf0SEd Czeck static const char * const valid_arguments[] = {
811131cbf0SEd Czeck 	ARK_PKTGEN_ARG,
821131cbf0SEd Czeck 	ARK_PKTCHKR_ARG,
831131cbf0SEd Czeck 	ARK_PKTDIR_ARG,
841131cbf0SEd Czeck 	NULL
851131cbf0SEd Czeck };
861131cbf0SEd Czeck 
87c5314a53SJohn Miller #define AR_VENDOR_ID 0x1d6c
881131cbf0SEd Czeck static const struct rte_pci_id pci_id_ark_map[] = {
89c5314a53SJohn Miller 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x100d)},
90c5314a53SJohn Miller 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x100e)},
91c5314a53SJohn Miller 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x100f)},
92c5314a53SJohn Miller 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1010)},
93c5314a53SJohn Miller 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1017)},
94c5314a53SJohn Miller 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1018)},
95c5314a53SJohn Miller 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1019)},
96b5c58298SEd Czeck 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x101a)},
97b5c58298SEd Czeck 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x101b)},
98b5c58298SEd Czeck 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x101c)},
9951ec6c74SJohn Miller 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x101e)},
10051ec6c74SJohn Miller 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x101f)},
101cdfaa85eSShepard Siegel 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1022)},
102*a861d5a2SEd Czeck 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1024)},
103*a861d5a2SEd Czeck 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1025)},
104*a861d5a2SEd Czeck 	{RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1026)},
1051131cbf0SEd Czeck 	{.vendor_id = 0, /* sentinel */ },
1061131cbf0SEd Czeck };
1071131cbf0SEd Czeck 
108c5314a53SJohn Miller /*
109c5314a53SJohn Miller  * This structure is used to statically define the capabilities
110c5314a53SJohn Miller  * of supported devices.
111c5314a53SJohn Miller  * Capabilities:
1128d1136d4SEd Czeck  *    isvf -- defined for function id that are virtual
113c5314a53SJohn Miller  */
114c5314a53SJohn Miller struct ark_caps {
1156799275eSEd Czeck 	bool isvf;
116c5314a53SJohn Miller };
117c5314a53SJohn Miller struct ark_dev_caps {
118c5314a53SJohn Miller 	uint32_t  device_id;
119c5314a53SJohn Miller 	struct ark_caps  caps;
120c5314a53SJohn Miller };
1218d1136d4SEd Czeck #define SET_DEV_CAPS(id, vf)			\
1228d1136d4SEd Czeck 	{id, {.isvf = vf} }
123c5314a53SJohn Miller 
124c5314a53SJohn Miller static const struct ark_dev_caps
125c5314a53SJohn Miller ark_device_caps[] = {
1268d1136d4SEd Czeck 		     SET_DEV_CAPS(0x100d, false),
1278d1136d4SEd Czeck 		     SET_DEV_CAPS(0x100e, false),
1288d1136d4SEd Czeck 		     SET_DEV_CAPS(0x100f, false),
1298d1136d4SEd Czeck 		     SET_DEV_CAPS(0x1010, false),
1308d1136d4SEd Czeck 		     SET_DEV_CAPS(0x1017, false),
1318d1136d4SEd Czeck 		     SET_DEV_CAPS(0x1018, false),
1328d1136d4SEd Czeck 		     SET_DEV_CAPS(0x1019, false),
1338d1136d4SEd Czeck 		     SET_DEV_CAPS(0x101a, false),
1348d1136d4SEd Czeck 		     SET_DEV_CAPS(0x101b, false),
1358d1136d4SEd Czeck 		     SET_DEV_CAPS(0x101c, true),
1368d1136d4SEd Czeck 		     SET_DEV_CAPS(0x101e, false),
1378d1136d4SEd Czeck 		     SET_DEV_CAPS(0x101f, false),
138c5314a53SJohn Miller 		     {.device_id = 0,}
139c5314a53SJohn Miller };
140c5314a53SJohn Miller 
1411131cbf0SEd Czeck static int
eth_ark_pci_probe(struct rte_pci_driver * pci_drv __rte_unused,struct rte_pci_device * pci_dev)1421131cbf0SEd Czeck eth_ark_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1431131cbf0SEd Czeck 		struct rte_pci_device *pci_dev)
1441131cbf0SEd Czeck {
1451131cbf0SEd Czeck 	struct rte_eth_dev *eth_dev;
1461131cbf0SEd Czeck 	int ret;
1471131cbf0SEd Czeck 
1481131cbf0SEd Czeck 	eth_dev = rte_eth_dev_pci_allocate(pci_dev, sizeof(struct ark_adapter));
1491131cbf0SEd Czeck 
1501131cbf0SEd Czeck 	if (eth_dev == NULL)
1511131cbf0SEd Czeck 		return -ENOMEM;
1521131cbf0SEd Czeck 
1531131cbf0SEd Czeck 	ret = eth_ark_dev_init(eth_dev);
1541131cbf0SEd Czeck 	if (ret)
1552c65898bSThomas Monjalon 		rte_eth_dev_release_port(eth_dev);
1561131cbf0SEd Czeck 
1571131cbf0SEd Czeck 	return ret;
1581131cbf0SEd Czeck }
1591131cbf0SEd Czeck 
1601131cbf0SEd Czeck static int
eth_ark_pci_remove(struct rte_pci_device * pci_dev)1611131cbf0SEd Czeck eth_ark_pci_remove(struct rte_pci_device *pci_dev)
1621131cbf0SEd Czeck {
1631131cbf0SEd Czeck 	return rte_eth_dev_pci_generic_remove(pci_dev, eth_ark_dev_uninit);
1641131cbf0SEd Czeck }
1651131cbf0SEd Czeck 
1661131cbf0SEd Czeck static struct rte_pci_driver rte_ark_pmd = {
1671131cbf0SEd Czeck 	.id_table = pci_id_ark_map,
1681131cbf0SEd Czeck 	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
1691131cbf0SEd Czeck 	.probe = eth_ark_pci_probe,
1701131cbf0SEd Czeck 	.remove = eth_ark_pci_remove,
1711131cbf0SEd Czeck };
1721131cbf0SEd Czeck 
1731131cbf0SEd Czeck static const struct eth_dev_ops ark_eth_dev_ops = {
1741131cbf0SEd Czeck 	.dev_configure = eth_ark_dev_configure,
175727b3fe2SEd Czeck 	.dev_start = eth_ark_dev_start,
176727b3fe2SEd Czeck 	.dev_stop = eth_ark_dev_stop,
177727b3fe2SEd Czeck 	.dev_close = eth_ark_dev_close,
178727b3fe2SEd Czeck 
1791131cbf0SEd Czeck 	.dev_infos_get = eth_ark_dev_info_get,
180727b3fe2SEd Czeck 
181727b3fe2SEd Czeck 	.rx_queue_setup = eth_ark_dev_rx_queue_setup,
182727b3fe2SEd Czeck 	.tx_queue_setup = eth_ark_tx_queue_setup,
183727b3fe2SEd Czeck 
184727b3fe2SEd Czeck 	.link_update = eth_ark_dev_link_update,
185727b3fe2SEd Czeck 	.dev_set_link_up = eth_ark_dev_set_link_up,
186727b3fe2SEd Czeck 	.dev_set_link_down = eth_ark_dev_set_link_down,
187727b3fe2SEd Czeck 
188727b3fe2SEd Czeck 	.rx_queue_start = eth_ark_rx_start_queue,
189727b3fe2SEd Czeck 	.rx_queue_stop = eth_ark_rx_stop_queue,
190727b3fe2SEd Czeck 
191727b3fe2SEd Czeck 	.tx_queue_start = eth_ark_tx_queue_start,
192727b3fe2SEd Czeck 	.tx_queue_stop = eth_ark_tx_queue_stop,
193727b3fe2SEd Czeck 
194727b3fe2SEd Czeck 	.stats_get = eth_ark_dev_stats_get,
195727b3fe2SEd Czeck 	.stats_reset = eth_ark_dev_stats_reset,
196727b3fe2SEd Czeck 
197727b3fe2SEd Czeck 	.mac_addr_add = eth_ark_macaddr_add,
198727b3fe2SEd Czeck 	.mac_addr_remove = eth_ark_macaddr_remove,
199727b3fe2SEd Czeck 	.mac_addr_set = eth_ark_set_default_mac_addr,
2009ae74488SJohn Miller 
2019ae74488SJohn Miller 	.mtu_set = eth_ark_set_mtu,
2021131cbf0SEd Czeck };
2031131cbf0SEd Czeck 
2041131cbf0SEd Czeck static int
check_for_ext(struct ark_adapter * ark)205727b3fe2SEd Czeck check_for_ext(struct ark_adapter *ark)
206727b3fe2SEd Czeck {
207727b3fe2SEd Czeck 	int found = 0;
208727b3fe2SEd Czeck 
209727b3fe2SEd Czeck 	/* Get the env */
210727b3fe2SEd Czeck 	const char *dllpath = getenv("ARK_EXT_PATH");
211727b3fe2SEd Czeck 
212727b3fe2SEd Czeck 	if (dllpath == NULL) {
2131502d443SEd Czeck 		ARK_PMD_LOG(DEBUG, "EXT NO dll path specified\n");
214727b3fe2SEd Czeck 		return 0;
215727b3fe2SEd Czeck 	}
2161502d443SEd Czeck 	ARK_PMD_LOG(NOTICE, "EXT found dll path at %s\n", dllpath);
217727b3fe2SEd Czeck 
218727b3fe2SEd Czeck 	/* Open and load the .so */
219727b3fe2SEd Czeck 	ark->d_handle = dlopen(dllpath, RTLD_LOCAL | RTLD_LAZY);
220727b3fe2SEd Czeck 	if (ark->d_handle == NULL) {
2211502d443SEd Czeck 		ARK_PMD_LOG(ERR, "Could not load user extension %s\n",
222727b3fe2SEd Czeck 			    dllpath);
223727b3fe2SEd Czeck 		return -1;
224727b3fe2SEd Czeck 	}
2251502d443SEd Czeck 	ARK_PMD_LOG(DEBUG, "SUCCESS: loaded user extension %s\n",
226727b3fe2SEd Czeck 			    dllpath);
227727b3fe2SEd Czeck 
228727b3fe2SEd Czeck 	/* Get the entry points */
229727b3fe2SEd Czeck 	ark->user_ext.dev_init =
230727b3fe2SEd Czeck 		(void *(*)(struct rte_eth_dev *, void *, int))
231f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_dev_init");
2321502d443SEd Czeck 	ARK_PMD_LOG(DEBUG, "device ext init pointer = %p\n",
233727b3fe2SEd Czeck 		      ark->user_ext.dev_init);
234727b3fe2SEd Czeck 	ark->user_ext.dev_get_port_count =
235727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
236f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_dev_get_port_count");
237727b3fe2SEd Czeck 	ark->user_ext.dev_uninit =
238727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, void *))
239f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_dev_uninit");
240727b3fe2SEd Czeck 	ark->user_ext.dev_configure =
241727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
242f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_dev_configure");
243727b3fe2SEd Czeck 	ark->user_ext.dev_start =
244727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
245f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_dev_start");
246727b3fe2SEd Czeck 	ark->user_ext.dev_stop =
247727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, void *))
248f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_dev_stop");
249727b3fe2SEd Czeck 	ark->user_ext.dev_close =
250727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, void *))
251f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_dev_close");
252727b3fe2SEd Czeck 	ark->user_ext.link_update =
253727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, int, void *))
254f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_link_update");
255727b3fe2SEd Czeck 	ark->user_ext.dev_set_link_up =
256727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
257f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_dev_set_link_up");
258727b3fe2SEd Czeck 	ark->user_ext.dev_set_link_down =
259727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
260f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_dev_set_link_down");
261727b3fe2SEd Czeck 	ark->user_ext.stats_get =
262d5b0924bSMatan Azrad 		(int (*)(struct rte_eth_dev *, struct rte_eth_stats *,
263727b3fe2SEd Czeck 			  void *))
264f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_stats_get");
265727b3fe2SEd Czeck 	ark->user_ext.stats_reset =
266727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, void *))
267f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_stats_reset");
268727b3fe2SEd Czeck 	ark->user_ext.mac_addr_add =
2696d13ea8eSOlivier Matz 		(void (*)(struct rte_eth_dev *, struct rte_ether_addr *,
2706d13ea8eSOlivier Matz 			uint32_t, uint32_t, void *))
271f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_mac_addr_add");
272727b3fe2SEd Czeck 	ark->user_ext.mac_addr_remove =
273727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, uint32_t, void *))
274f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_mac_addr_remove");
275727b3fe2SEd Czeck 	ark->user_ext.mac_addr_set =
2766d13ea8eSOlivier Matz 		(void (*)(struct rte_eth_dev *, struct rte_ether_addr *,
277727b3fe2SEd Czeck 			  void *))
278f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_mac_addr_set");
2799ae74488SJohn Miller 	ark->user_ext.set_mtu =
2809ae74488SJohn Miller 		(int (*)(struct rte_eth_dev *, uint16_t,
2819ae74488SJohn Miller 			  void *))
282f2764c36SEd Czeck 		dlsym(ark->d_handle, "rte_pmd_ark_set_mtu");
2836c7f491eSEd Czeck 	ark->user_ext.rx_user_meta_hook =
2846c7f491eSEd Czeck 		(rx_user_meta_hook_fn)dlsym(ark->d_handle,
2856c7f491eSEd Czeck 					    "rte_pmd_ark_rx_user_meta_hook");
2866c7f491eSEd Czeck 	ark->user_ext.tx_user_meta_hook =
2876c7f491eSEd Czeck 		(tx_user_meta_hook_fn)dlsym(ark->d_handle,
2886c7f491eSEd Czeck 					    "rte_pmd_ark_tx_user_meta_hook");
289727b3fe2SEd Czeck 
290727b3fe2SEd Czeck 	return found;
291727b3fe2SEd Czeck }
292727b3fe2SEd Czeck 
293727b3fe2SEd Czeck static int
eth_ark_dev_init(struct rte_eth_dev * dev)2941131cbf0SEd Czeck eth_ark_dev_init(struct rte_eth_dev *dev)
2951131cbf0SEd Czeck {
2960bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
2971131cbf0SEd Czeck 	struct rte_pci_device *pci_dev;
298727b3fe2SEd Czeck 	int ret;
299727b3fe2SEd Czeck 	int port_count = 1;
300727b3fe2SEd Czeck 	int p;
301bf73ee28SEd Czeck 	uint16_t num_queues;
3021131cbf0SEd Czeck 
3031131cbf0SEd Czeck 	ark->eth_dev = dev;
3041131cbf0SEd Czeck 
3051502d443SEd Czeck 	ARK_PMD_LOG(DEBUG, "\n");
3061131cbf0SEd Czeck 
307727b3fe2SEd Czeck 	/* Check to see if there is an extension that we need to load */
308727b3fe2SEd Czeck 	ret = check_for_ext(ark);
309727b3fe2SEd Czeck 	if (ret)
310727b3fe2SEd Czeck 		return ret;
3111abc7209SEd Czeck 
312c0802544SFerruh Yigit 	pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3131131cbf0SEd Czeck 	rte_eth_copy_pci_info(dev, pci_dev);
314f30e69b4SFerruh Yigit 	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
3151131cbf0SEd Czeck 
316c5314a53SJohn Miller 	p = 0;
317c5314a53SJohn Miller 	while (ark_device_caps[p].device_id != 0) {
318c5314a53SJohn Miller 		if (pci_dev->id.device_id == ark_device_caps[p].device_id) {
3196799275eSEd Czeck 			ark->isvf = ark_device_caps[p].caps.isvf;
320c5314a53SJohn Miller 			break;
321c5314a53SJohn Miller 		}
322c5314a53SJohn Miller 		p++;
323c5314a53SJohn Miller 	}
324c5314a53SJohn Miller 
325727b3fe2SEd Czeck 	/* Use dummy function until setup */
326a41f593fSFerruh Yigit 	dev->rx_pkt_burst = rte_eth_pkt_burst_dummy;
327a41f593fSFerruh Yigit 	dev->tx_pkt_burst = rte_eth_pkt_burst_dummy;
328727b3fe2SEd Czeck 
3291131cbf0SEd Czeck 	ark->bar0 = (uint8_t *)pci_dev->mem_resource[0].addr;
3301131cbf0SEd Czeck 	ark->a_bar = (uint8_t *)pci_dev->mem_resource[2].addr;
3311131cbf0SEd Czeck 
332727b3fe2SEd Czeck 	ark->sysctrl.v  = (void *)&ark->bar0[ARK_SYSCTRL_BASE];
333727b3fe2SEd Czeck 	ark->mpurx.v  = (void *)&ark->bar0[ARK_MPU_RX_BASE];
334727b3fe2SEd Czeck 	ark->udm.v  = (void *)&ark->bar0[ARK_UDM_BASE];
335727b3fe2SEd Czeck 	ark->mputx.v  = (void *)&ark->bar0[ARK_MPU_TX_BASE];
336727b3fe2SEd Czeck 	ark->ddm.v  = (void *)&ark->bar0[ARK_DDM_BASE];
337727b3fe2SEd Czeck 	ark->cmac.v  = (void *)&ark->bar0[ARK_CMAC_BASE];
338727b3fe2SEd Czeck 	ark->external.v  = (void *)&ark->bar0[ARK_EXTERNAL_BASE];
339727b3fe2SEd Czeck 	ark->pktdir.v  = (void *)&ark->bar0[ARK_PKTDIR_BASE];
340727b3fe2SEd Czeck 	ark->pktgen.v  = (void *)&ark->bar0[ARK_PKTGEN_BASE];
341727b3fe2SEd Czeck 	ark->pktchkr.v  = (void *)&ark->bar0[ARK_PKTCHKR_BASE];
342727b3fe2SEd Czeck 
343727b3fe2SEd Czeck 	ark->started = 0;
3443b4f34f6SEd Czeck 	ark->pkt_dir_v = ARK_PKT_DIR_INIT_VAL;
345727b3fe2SEd Czeck 
3461502d443SEd Czeck 	ARK_PMD_LOG(INFO, "Sys Ctrl Const = 0x%x  HW Commit_ID: %08x\n",
347727b3fe2SEd Czeck 		      ark->sysctrl.t32[4],
348727b3fe2SEd Czeck 		      rte_be_to_cpu_32(ark->sysctrl.t32[0x20 / 4]));
3491502d443SEd Czeck 	ARK_PMD_LOG(NOTICE, "Arkville HW Commit_ID: %08x\n",
350727b3fe2SEd Czeck 		    rte_be_to_cpu_32(ark->sysctrl.t32[0x20 / 4]));
351727b3fe2SEd Czeck 
352727b3fe2SEd Czeck 	/* If HW sanity test fails, return an error */
353727b3fe2SEd Czeck 	if (ark->sysctrl.t32[4] != 0xcafef00d) {
3541502d443SEd Czeck 		ARK_PMD_LOG(ERR,
355727b3fe2SEd Czeck 			    "HW Sanity test has failed, expected constant"
356727b3fe2SEd Czeck 			    " 0x%x, read 0x%x (%s)\n",
357727b3fe2SEd Czeck 			    0xcafef00d,
358727b3fe2SEd Czeck 			    ark->sysctrl.t32[4], __func__);
359727b3fe2SEd Czeck 		return -1;
360727b3fe2SEd Czeck 	}
361727b3fe2SEd Czeck 
3621502d443SEd Czeck 	ARK_PMD_LOG(DEBUG,
363727b3fe2SEd Czeck 		    "HW Sanity test has PASSED, expected constant"
364727b3fe2SEd Czeck 		    " 0x%x, read 0x%x (%s)\n",
365727b3fe2SEd Czeck 		    0xcafef00d, ark->sysctrl.t32[4], __func__);
366727b3fe2SEd Czeck 
367727b3fe2SEd Czeck 	/* We are a single function multi-port device. */
368727b3fe2SEd Czeck 	ret = ark_config_device(dev);
369589876bfSEd Czeck 	if (ret)
370589876bfSEd Czeck 		return -1;
371589876bfSEd Czeck 
3721131cbf0SEd Czeck 	dev->dev_ops = &ark_eth_dev_ops;
373cbfc6111SFerruh Yigit 	dev->rx_queue_count = eth_ark_dev_rx_queue_count;
3741131cbf0SEd Czeck 
37535b2d13fSOlivier Matz 	dev->data->mac_addrs = rte_zmalloc("ark", RTE_ETHER_ADDR_LEN, 0);
376727b3fe2SEd Czeck 	if (!dev->data->mac_addrs) {
3771502d443SEd Czeck 		ARK_PMD_LOG(ERR,
378727b3fe2SEd Czeck 			    "Failed to allocated memory for storing mac address"
379727b3fe2SEd Czeck 			    );
380727b3fe2SEd Czeck 	}
381727b3fe2SEd Czeck 
382727b3fe2SEd Czeck 	if (ark->user_ext.dev_init) {
383428046b4SJohn Miller 		ark->user_data[dev->data->port_id] =
384428046b4SJohn Miller 			ark->user_ext.dev_init(dev, ark->a_bar, 0);
385428046b4SJohn Miller 		if (!ark->user_data[dev->data->port_id]) {
3861502d443SEd Czeck 			ARK_PMD_LOG(WARNING,
387727b3fe2SEd Czeck 				    "Failed to initialize PMD extension!"
388727b3fe2SEd Czeck 				    " continuing without it\n");
389727b3fe2SEd Czeck 			memset(&ark->user_ext, 0, sizeof(struct ark_user_ext));
390727b3fe2SEd Czeck 			dlclose(ark->d_handle);
391727b3fe2SEd Czeck 		}
392727b3fe2SEd Czeck 	}
393727b3fe2SEd Czeck 
3941131cbf0SEd Czeck 	if (pci_dev->device.devargs)
3951131cbf0SEd Czeck 		ret = eth_ark_check_args(ark, pci_dev->device.devargs->args);
3961131cbf0SEd Czeck 	else
3971502d443SEd Czeck 		ARK_PMD_LOG(INFO, "No Device args found\n");
3981131cbf0SEd Czeck 
399727b3fe2SEd Czeck 	if (ret)
400727b3fe2SEd Czeck 		goto error;
401727b3fe2SEd Czeck 	/*
402727b3fe2SEd Czeck 	 * We will create additional devices based on the number of requested
403727b3fe2SEd Czeck 	 * ports
404727b3fe2SEd Czeck 	 */
405727b3fe2SEd Czeck 	if (ark->user_ext.dev_get_port_count)
406727b3fe2SEd Czeck 		port_count =
407428046b4SJohn Miller 			ark->user_ext.dev_get_port_count(dev,
408428046b4SJohn Miller 				 ark->user_data[dev->data->port_id]);
409727b3fe2SEd Czeck 	ark->num_ports = port_count;
410bf73ee28SEd Czeck 	num_queues = ark_api_num_queues_per_port(ark->mpurx.v, port_count);
411727b3fe2SEd Czeck 
412727b3fe2SEd Czeck 	for (p = 0; p < port_count; p++) {
413727b3fe2SEd Czeck 		struct rte_eth_dev *eth_dev;
414727b3fe2SEd Czeck 		char name[RTE_ETH_NAME_MAX_LEN];
415727b3fe2SEd Czeck 
416727b3fe2SEd Czeck 		snprintf(name, sizeof(name), "arketh%d",
417727b3fe2SEd Czeck 			 dev->data->port_id + p);
418727b3fe2SEd Czeck 
419727b3fe2SEd Czeck 		if (p == 0) {
420727b3fe2SEd Czeck 			/* First port is already allocated by DPDK */
421727b3fe2SEd Czeck 			eth_dev = ark->eth_dev;
4225bfe551dSEd Czeck 			rte_eth_dev_probing_finish(eth_dev);
423727b3fe2SEd Czeck 			continue;
424727b3fe2SEd Czeck 		}
425727b3fe2SEd Czeck 
426727b3fe2SEd Czeck 		/* reserve an ethdev entry */
427727b3fe2SEd Czeck 		eth_dev = rte_eth_dev_allocate(name);
428727b3fe2SEd Czeck 		if (!eth_dev) {
4291502d443SEd Czeck 			ARK_PMD_LOG(ERR,
430727b3fe2SEd Czeck 				    "Could not allocate eth_dev for port %d\n",
431727b3fe2SEd Czeck 				    p);
432727b3fe2SEd Czeck 			goto error;
433727b3fe2SEd Czeck 		}
434727b3fe2SEd Czeck 
435727b3fe2SEd Czeck 		eth_dev->device = &pci_dev->device;
436bf73ee28SEd Czeck 		/* Device requires new dev_private data */
437bf73ee28SEd Czeck 		eth_dev->data->dev_private =
438bf73ee28SEd Czeck 			rte_zmalloc_socket(name,
439bf73ee28SEd Czeck 					   sizeof(struct ark_adapter),
440bf73ee28SEd Czeck 					   RTE_CACHE_LINE_SIZE,
441bf73ee28SEd Czeck 					   rte_socket_id());
442bf73ee28SEd Czeck 
443bf73ee28SEd Czeck 		memcpy(eth_dev->data->dev_private, ark,
444bf73ee28SEd Czeck 		       sizeof(struct ark_adapter));
445bf73ee28SEd Czeck 		ark = eth_dev->data->dev_private;
446bf73ee28SEd Czeck 		ark->qbase = p * num_queues;
447bf73ee28SEd Czeck 
448727b3fe2SEd Czeck 		eth_dev->dev_ops = ark->eth_dev->dev_ops;
449727b3fe2SEd Czeck 		eth_dev->tx_pkt_burst = ark->eth_dev->tx_pkt_burst;
450727b3fe2SEd Czeck 		eth_dev->rx_pkt_burst = ark->eth_dev->rx_pkt_burst;
451727b3fe2SEd Czeck 
452727b3fe2SEd Czeck 		rte_eth_copy_pci_info(eth_dev, pci_dev);
453f30e69b4SFerruh Yigit 		eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
454727b3fe2SEd Czeck 
45535b2d13fSOlivier Matz 		eth_dev->data->mac_addrs = rte_zmalloc(name,
45635b2d13fSOlivier Matz 						RTE_ETHER_ADDR_LEN, 0);
457727b3fe2SEd Czeck 		if (!eth_dev->data->mac_addrs) {
4581502d443SEd Czeck 			ARK_PMD_LOG(ERR,
459727b3fe2SEd Czeck 				    "Memory allocation for MAC failed!"
460727b3fe2SEd Czeck 				    " Exiting.\n");
461727b3fe2SEd Czeck 			goto error;
462727b3fe2SEd Czeck 		}
463727b3fe2SEd Czeck 
464428046b4SJohn Miller 		if (ark->user_ext.dev_init) {
465428046b4SJohn Miller 			ark->user_data[eth_dev->data->port_id] =
466727b3fe2SEd Czeck 				ark->user_ext.dev_init(dev, ark->a_bar, p);
467727b3fe2SEd Czeck 		}
468fbe90cddSThomas Monjalon 
469fbe90cddSThomas Monjalon 		rte_eth_dev_probing_finish(eth_dev);
470428046b4SJohn Miller 	}
471727b3fe2SEd Czeck 
4721131cbf0SEd Czeck 	return ret;
473727b3fe2SEd Czeck 
474727b3fe2SEd Czeck error:
475727b3fe2SEd Czeck 	rte_free(dev->data->mac_addrs);
476e7f2fa88SDavid Marchand 	dev->data->mac_addrs = NULL;
477727b3fe2SEd Czeck 	return -1;
478727b3fe2SEd Czeck }
479727b3fe2SEd Czeck 
480727b3fe2SEd Czeck /*
481727b3fe2SEd Czeck  *Initial device configuration when device is opened
482727b3fe2SEd Czeck  * setup the DDM, and UDM
483727b3fe2SEd Czeck  * Called once per PCIE device
484727b3fe2SEd Czeck  */
485727b3fe2SEd Czeck static int
ark_config_device(struct rte_eth_dev * dev)486727b3fe2SEd Czeck ark_config_device(struct rte_eth_dev *dev)
487727b3fe2SEd Czeck {
4880bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
489727b3fe2SEd Czeck 	uint16_t num_q, i;
490727b3fe2SEd Czeck 	struct ark_mpu_t *mpu;
491727b3fe2SEd Czeck 
492727b3fe2SEd Czeck 	/*
493727b3fe2SEd Czeck 	 * Make sure that the packet director, generator and checker are in a
494727b3fe2SEd Czeck 	 * known state
495727b3fe2SEd Czeck 	 */
4966799275eSEd Czeck 	if (!ark->isvf) {
497727b3fe2SEd Czeck 		ark->start_pg = 0;
498c7ff3d78SJohn Miller 		ark->pg_running = 0;
499727b3fe2SEd Czeck 		ark->pg = ark_pktgen_init(ark->pktgen.v, 0, 1);
50053a9ba13SYong Wang 		if (ark->pg == NULL)
50153a9ba13SYong Wang 			return -1;
502727b3fe2SEd Czeck 		ark_pktgen_reset(ark->pg);
503727b3fe2SEd Czeck 		ark->pc = ark_pktchkr_init(ark->pktchkr.v, 0, 1);
50453a9ba13SYong Wang 		if (ark->pc == NULL)
50553a9ba13SYong Wang 			return -1;
506727b3fe2SEd Czeck 		ark_pktchkr_stop(ark->pc);
507727b3fe2SEd Czeck 		ark->pd = ark_pktdir_init(ark->pktdir.v);
50853a9ba13SYong Wang 		if (ark->pd == NULL)
50953a9ba13SYong Wang 			return -1;
5106799275eSEd Czeck 	}
511727b3fe2SEd Czeck 	/* Verify HW */
512727b3fe2SEd Czeck 	if (ark_udm_verify(ark->udm.v))
513727b3fe2SEd Czeck 		return -1;
514727b3fe2SEd Czeck 	if (ark_ddm_verify(ark->ddm.v))
515727b3fe2SEd Czeck 		return -1;
516727b3fe2SEd Czeck 
517727b3fe2SEd Czeck 	/* MPU reset */
518727b3fe2SEd Czeck 	mpu = ark->mpurx.v;
519727b3fe2SEd Czeck 	num_q = ark_api_num_queues(mpu);
520727b3fe2SEd Czeck 	ark->rx_queues = num_q;
521727b3fe2SEd Czeck 	for (i = 0; i < num_q; i++) {
522727b3fe2SEd Czeck 		mpu = RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET);
523727b3fe2SEd Czeck 	}
524727b3fe2SEd Czeck 
525727b3fe2SEd Czeck 	mpu = ark->mputx.v;
526727b3fe2SEd Czeck 	num_q = ark_api_num_queues(mpu);
527727b3fe2SEd Czeck 	ark->tx_queues = num_q;
528727b3fe2SEd Czeck 	for (i = 0; i < num_q; i++) {
529727b3fe2SEd Czeck 		mpu = RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET);
530727b3fe2SEd Czeck 	}
531727b3fe2SEd Czeck 
532727b3fe2SEd Czeck 	return 0;
5331131cbf0SEd Czeck }
5341131cbf0SEd Czeck 
5351131cbf0SEd Czeck static int
eth_ark_dev_uninit(struct rte_eth_dev * dev)5361131cbf0SEd Czeck eth_ark_dev_uninit(struct rte_eth_dev *dev)
5371131cbf0SEd Czeck {
5380bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
539727b3fe2SEd Czeck 
5401131cbf0SEd Czeck 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
5411131cbf0SEd Czeck 		return 0;
5421131cbf0SEd Czeck 
543727b3fe2SEd Czeck 	if (ark->user_ext.dev_uninit)
544428046b4SJohn Miller 		ark->user_ext.dev_uninit(dev,
545428046b4SJohn Miller 			 ark->user_data[dev->data->port_id]);
546727b3fe2SEd Czeck 
5476799275eSEd Czeck 	if (!ark->isvf) {
548727b3fe2SEd Czeck 		ark_pktgen_uninit(ark->pg);
549727b3fe2SEd Czeck 		ark_pktchkr_uninit(ark->pc);
5506799275eSEd Czeck 	}
551727b3fe2SEd Czeck 
5521131cbf0SEd Czeck 	return 0;
5531131cbf0SEd Czeck }
5541131cbf0SEd Czeck 
5551131cbf0SEd Czeck static int
eth_ark_dev_configure(struct rte_eth_dev * dev)556727b3fe2SEd Czeck eth_ark_dev_configure(struct rte_eth_dev *dev)
5571131cbf0SEd Czeck {
5580bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
559727b3fe2SEd Czeck 
560727b3fe2SEd Czeck 	eth_ark_dev_set_link_up(dev);
561727b3fe2SEd Czeck 	if (ark->user_ext.dev_configure)
562428046b4SJohn Miller 		return ark->user_ext.dev_configure(dev,
563428046b4SJohn Miller 			   ark->user_data[dev->data->port_id]);
5641131cbf0SEd Czeck 	return 0;
5651131cbf0SEd Czeck }
5661131cbf0SEd Czeck 
567727b3fe2SEd Czeck static int
eth_ark_dev_start(struct rte_eth_dev * dev)568727b3fe2SEd Czeck eth_ark_dev_start(struct rte_eth_dev *dev)
569727b3fe2SEd Czeck {
5700bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
571727b3fe2SEd Czeck 	int i;
572727b3fe2SEd Czeck 
573727b3fe2SEd Czeck 	/* RX Side */
574727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_rx_queues; i++)
575727b3fe2SEd Czeck 		eth_ark_rx_start_queue(dev, i);
576727b3fe2SEd Czeck 
577727b3fe2SEd Czeck 	/* TX Side */
578727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++)
579727b3fe2SEd Czeck 		eth_ark_tx_queue_start(dev, i);
580727b3fe2SEd Czeck 
581727b3fe2SEd Czeck 	ark->started = 1;
582727b3fe2SEd Czeck 	/* set xmit and receive function */
583727b3fe2SEd Czeck 	dev->rx_pkt_burst = &eth_ark_recv_pkts;
584727b3fe2SEd Czeck 	dev->tx_pkt_burst = &eth_ark_xmit_pkts;
585727b3fe2SEd Czeck 
5866799275eSEd Czeck 	if (!ark->isvf && ark->start_pg)
587727b3fe2SEd Czeck 		ark_pktchkr_run(ark->pc);
588727b3fe2SEd Czeck 
5896799275eSEd Czeck 	if (!ark->isvf && ark->start_pg && !ark->pg_running) {
590a7ba40b2SThomas Monjalon 		rte_thread_t thread;
591727b3fe2SEd Czeck 
59262774b78SThomas Monjalon 		/* Delay packet generator start allow the hardware to be ready
593727b3fe2SEd Czeck 		 * This is only used for sanity checking with internal generator
594727b3fe2SEd Czeck 		 */
595a7ba40b2SThomas Monjalon 		char tname[RTE_THREAD_INTERNAL_NAME_SIZE];
596a7ba40b2SThomas Monjalon 		snprintf(tname, sizeof(tname), "ark-pg%d", dev->data->port_id);
597c7ff3d78SJohn Miller 
598a7ba40b2SThomas Monjalon 		if (rte_thread_create_internal_control(&thread, tname,
5994b42104cSEd Czeck 					ark_pktgen_delay_start, ark->pg)) {
6001502d443SEd Czeck 			ARK_PMD_LOG(ERR, "Could not create pktgen "
601d1434c04SJohn Miller 				    "starter thread\n");
602d1434c04SJohn Miller 			return -1;
603d1434c04SJohn Miller 		}
604c7ff3d78SJohn Miller 		ark->pg_running = 1;
605727b3fe2SEd Czeck 	}
606727b3fe2SEd Czeck 
607727b3fe2SEd Czeck 	if (ark->user_ext.dev_start)
608428046b4SJohn Miller 		ark->user_ext.dev_start(dev,
609428046b4SJohn Miller 			ark->user_data[dev->data->port_id]);
610727b3fe2SEd Czeck 
611727b3fe2SEd Czeck 	return 0;
612727b3fe2SEd Czeck }
613727b3fe2SEd Czeck 
61462024eb8SIvan Ilchenko static int
eth_ark_dev_stop(struct rte_eth_dev * dev)615727b3fe2SEd Czeck eth_ark_dev_stop(struct rte_eth_dev *dev)
616727b3fe2SEd Czeck {
617727b3fe2SEd Czeck 	uint16_t i;
618727b3fe2SEd Czeck 	int status;
6190bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
620727b3fe2SEd Czeck 
621727b3fe2SEd Czeck 	if (ark->started == 0)
62262024eb8SIvan Ilchenko 		return 0;
623727b3fe2SEd Czeck 	ark->started = 0;
624b8f5d2aeSThomas Monjalon 	dev->data->dev_started = 0;
625727b3fe2SEd Czeck 
626727b3fe2SEd Czeck 	/* Stop the extension first */
627727b3fe2SEd Czeck 	if (ark->user_ext.dev_stop)
628428046b4SJohn Miller 		ark->user_ext.dev_stop(dev,
629428046b4SJohn Miller 		       ark->user_data[dev->data->port_id]);
630727b3fe2SEd Czeck 
631727b3fe2SEd Czeck 	/* Stop the packet generator */
6326799275eSEd Czeck 	if (!ark->isvf && ark->start_pg && ark->pg_running) {
633727b3fe2SEd Czeck 		ark_pktgen_pause(ark->pg);
634c7ff3d78SJohn Miller 		ark->pg_running = 0;
635c7ff3d78SJohn Miller 	}
636727b3fe2SEd Czeck 
637a41f593fSFerruh Yigit 	dev->rx_pkt_burst = rte_eth_pkt_burst_dummy;
638a41f593fSFerruh Yigit 	dev->tx_pkt_burst = rte_eth_pkt_burst_dummy;
639727b3fe2SEd Czeck 
640f0d33f78SEd Czeck 	/* Stop RX Side */
641f0d33f78SEd Czeck 	for (i = 0; i < dev->data->nb_rx_queues; i++)
642f0d33f78SEd Czeck 		eth_ark_rx_stop_queue(dev, i);
643f0d33f78SEd Czeck 
644727b3fe2SEd Czeck 	/* STOP TX Side */
645727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
646727b3fe2SEd Czeck 		status = eth_ark_tx_queue_stop(dev, i);
647727b3fe2SEd Czeck 		if (status != 0) {
648f8244c63SZhiyong Yang 			uint16_t port = dev->data->port_id;
6491502d443SEd Czeck 			ARK_PMD_LOG(ERR,
650727b3fe2SEd Czeck 				    "tx_queue stop anomaly"
651727b3fe2SEd Czeck 				    " port %u, queue %u\n",
652727b3fe2SEd Czeck 				    port, i);
653727b3fe2SEd Czeck 		}
654727b3fe2SEd Czeck 	}
655727b3fe2SEd Czeck 
656727b3fe2SEd Czeck 	ark_udm_dump_stats(ark->udm.v, "Post stop");
657727b3fe2SEd Czeck 
65822862a02SJohn Miller 	for (i = 0; i < dev->data->nb_rx_queues; i++)
659727b3fe2SEd Czeck 		eth_ark_rx_dump_queue(dev, i, __func__);
660727b3fe2SEd Czeck 
661727b3fe2SEd Czeck 	/* Stop the packet checker if it is running */
6626799275eSEd Czeck 	if (!ark->isvf && ark->start_pg) {
663727b3fe2SEd Czeck 		ark_pktchkr_dump_stats(ark->pc);
664727b3fe2SEd Czeck 		ark_pktchkr_stop(ark->pc);
665727b3fe2SEd Czeck 	}
66662024eb8SIvan Ilchenko 
66762024eb8SIvan Ilchenko 	return 0;
668727b3fe2SEd Czeck }
669727b3fe2SEd Czeck 
670b142387bSThomas Monjalon static int
eth_ark_dev_close(struct rte_eth_dev * dev)671727b3fe2SEd Czeck eth_ark_dev_close(struct rte_eth_dev *dev)
672727b3fe2SEd Czeck {
6730bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
674727b3fe2SEd Czeck 	uint16_t i;
675727b3fe2SEd Czeck 
67630410493SThomas Monjalon 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
67730410493SThomas Monjalon 		return 0;
67830410493SThomas Monjalon 
679727b3fe2SEd Czeck 	if (ark->user_ext.dev_close)
680428046b4SJohn Miller 		ark->user_ext.dev_close(dev,
681428046b4SJohn Miller 		 ark->user_data[dev->data->port_id]);
682727b3fe2SEd Czeck 
683727b3fe2SEd Czeck 	eth_ark_dev_stop(dev);
684727b3fe2SEd Czeck 
685727b3fe2SEd Czeck 	/*
686f0d33f78SEd Czeck 	 * This should only be called once for the device during shutdown
687727b3fe2SEd Czeck 	 */
6886799275eSEd Czeck 	/* return to power-on state */
6896799275eSEd Czeck 	if (ark->pd)
6906799275eSEd Czeck 		ark_pktdir_setup(ark->pd, ARK_PKT_DIR_INIT_VAL);
6916799275eSEd Czeck 
692727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
693727b3fe2SEd Czeck 		eth_ark_tx_queue_release(dev->data->tx_queues[i]);
694727b3fe2SEd Czeck 		dev->data->tx_queues[i] = 0;
695727b3fe2SEd Czeck 	}
696727b3fe2SEd Czeck 
697727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
698727b3fe2SEd Czeck 		eth_ark_dev_rx_queue_release(dev->data->rx_queues[i]);
699727b3fe2SEd Czeck 		dev->data->rx_queues[i] = 0;
700727b3fe2SEd Czeck 	}
701c5ddc9b9SEd Czeck 
702b142387bSThomas Monjalon 	return 0;
703727b3fe2SEd Czeck }
704727b3fe2SEd Czeck 
705bdad90d1SIvan Ilchenko static int
eth_ark_dev_info_get(struct rte_eth_dev * dev,struct rte_eth_dev_info * dev_info)7061131cbf0SEd Czeck eth_ark_dev_info_get(struct rte_eth_dev *dev,
7071131cbf0SEd Czeck 		     struct rte_eth_dev_info *dev_info)
7081131cbf0SEd Czeck {
7090bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
710727b3fe2SEd Czeck 	struct ark_mpu_t *tx_mpu = RTE_PTR_ADD(ark->bar0, ARK_MPU_TX_BASE);
711727b3fe2SEd Czeck 	struct ark_mpu_t *rx_mpu = RTE_PTR_ADD(ark->bar0, ARK_MPU_RX_BASE);
712727b3fe2SEd Czeck 	uint16_t ports = ark->num_ports;
713727b3fe2SEd Czeck 
7141131cbf0SEd Czeck 	dev_info->max_rx_pktlen = ARK_RX_MAX_PKT_LEN;
7151131cbf0SEd Czeck 	dev_info->min_rx_bufsize = ARK_RX_MIN_BUFSIZE;
7161131cbf0SEd Czeck 
717727b3fe2SEd Czeck 	dev_info->max_rx_queues = ark_api_num_queues_per_port(rx_mpu, ports);
718727b3fe2SEd Czeck 	dev_info->max_tx_queues = ark_api_num_queues_per_port(tx_mpu, ports);
719727b3fe2SEd Czeck 
7201131cbf0SEd Czeck 	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
7211131cbf0SEd Czeck 		.nb_max = ARK_RX_MAX_QUEUE,
7221131cbf0SEd Czeck 		.nb_min = ARK_RX_MIN_QUEUE,
7231131cbf0SEd Czeck 		.nb_align = ARK_RX_MIN_QUEUE}; /* power of 2 */
7241131cbf0SEd Czeck 
7251131cbf0SEd Czeck 	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
7261131cbf0SEd Czeck 		.nb_max = ARK_TX_MAX_QUEUE,
7271131cbf0SEd Czeck 		.nb_min = ARK_TX_MIN_QUEUE,
7281131cbf0SEd Czeck 		.nb_align = ARK_TX_MIN_QUEUE}; /* power of 2 */
7291131cbf0SEd Czeck 
7301131cbf0SEd Czeck 	/* ARK PMD supports all line rates, how do we indicate that here ?? */
731295968d1SFerruh Yigit 	dev_info->speed_capa = (RTE_ETH_LINK_SPEED_1G |
732295968d1SFerruh Yigit 				RTE_ETH_LINK_SPEED_10G |
733295968d1SFerruh Yigit 				RTE_ETH_LINK_SPEED_25G |
734295968d1SFerruh Yigit 				RTE_ETH_LINK_SPEED_40G |
735295968d1SFerruh Yigit 				RTE_ETH_LINK_SPEED_50G |
736295968d1SFerruh Yigit 				RTE_ETH_LINK_SPEED_100G);
737bdad90d1SIvan Ilchenko 
738295968d1SFerruh Yigit 	dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_TIMESTAMP;
739a926951aSThomas Monjalon 
740bdad90d1SIvan Ilchenko 	return 0;
7411131cbf0SEd Czeck }
7421131cbf0SEd Czeck 
743727b3fe2SEd Czeck static int
eth_ark_dev_link_update(struct rte_eth_dev * dev,int wait_to_complete)744727b3fe2SEd Czeck eth_ark_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
745727b3fe2SEd Czeck {
7461502d443SEd Czeck 	ARK_PMD_LOG(DEBUG, "link status = %d\n",
747727b3fe2SEd Czeck 			dev->data->dev_link.link_status);
7480bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
749727b3fe2SEd Czeck 
750727b3fe2SEd Czeck 	if (ark->user_ext.link_update) {
751727b3fe2SEd Czeck 		return ark->user_ext.link_update
752727b3fe2SEd Czeck 			(dev, wait_to_complete,
753428046b4SJohn Miller 			 ark->user_data[dev->data->port_id]);
754727b3fe2SEd Czeck 	}
755727b3fe2SEd Czeck 	return 0;
756727b3fe2SEd Czeck }
757727b3fe2SEd Czeck 
758727b3fe2SEd Czeck static int
eth_ark_dev_set_link_up(struct rte_eth_dev * dev)759727b3fe2SEd Czeck eth_ark_dev_set_link_up(struct rte_eth_dev *dev)
760727b3fe2SEd Czeck {
761727b3fe2SEd Czeck 	dev->data->dev_link.link_status = 1;
7620bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
763727b3fe2SEd Czeck 
764727b3fe2SEd Czeck 	if (ark->user_ext.dev_set_link_up)
765428046b4SJohn Miller 		return ark->user_ext.dev_set_link_up(dev,
766428046b4SJohn Miller 			     ark->user_data[dev->data->port_id]);
767727b3fe2SEd Czeck 	return 0;
768727b3fe2SEd Czeck }
769727b3fe2SEd Czeck 
770727b3fe2SEd Czeck static int
eth_ark_dev_set_link_down(struct rte_eth_dev * dev)771727b3fe2SEd Czeck eth_ark_dev_set_link_down(struct rte_eth_dev *dev)
772727b3fe2SEd Czeck {
773727b3fe2SEd Czeck 	dev->data->dev_link.link_status = 0;
7740bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
775727b3fe2SEd Czeck 
776727b3fe2SEd Czeck 	if (ark->user_ext.dev_set_link_down)
777428046b4SJohn Miller 		return ark->user_ext.dev_set_link_down(dev,
778428046b4SJohn Miller 		       ark->user_data[dev->data->port_id]);
779727b3fe2SEd Czeck 	return 0;
780727b3fe2SEd Czeck }
781727b3fe2SEd Czeck 
782d5b0924bSMatan Azrad static int
eth_ark_dev_stats_get(struct rte_eth_dev * dev,struct rte_eth_stats * stats)783727b3fe2SEd Czeck eth_ark_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
784727b3fe2SEd Czeck {
785727b3fe2SEd Czeck 	uint16_t i;
7860bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
787727b3fe2SEd Czeck 
788727b3fe2SEd Czeck 	stats->ipackets = 0;
789727b3fe2SEd Czeck 	stats->ibytes = 0;
790727b3fe2SEd Czeck 	stats->opackets = 0;
791727b3fe2SEd Czeck 	stats->obytes = 0;
792727b3fe2SEd Czeck 	stats->imissed = 0;
793727b3fe2SEd Czeck 	stats->oerrors = 0;
794727b3fe2SEd Czeck 
795727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++)
796727b3fe2SEd Czeck 		eth_tx_queue_stats_get(dev->data->tx_queues[i], stats);
797727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_rx_queues; i++)
798727b3fe2SEd Czeck 		eth_rx_queue_stats_get(dev->data->rx_queues[i], stats);
799727b3fe2SEd Czeck 	if (ark->user_ext.stats_get)
800d5b0924bSMatan Azrad 		return ark->user_ext.stats_get(dev, stats,
801428046b4SJohn Miller 			ark->user_data[dev->data->port_id]);
802d5b0924bSMatan Azrad 	return 0;
803727b3fe2SEd Czeck }
804727b3fe2SEd Czeck 
8059970a9adSIgor Romanov static int
eth_ark_dev_stats_reset(struct rte_eth_dev * dev)806727b3fe2SEd Czeck eth_ark_dev_stats_reset(struct rte_eth_dev *dev)
807727b3fe2SEd Czeck {
808727b3fe2SEd Czeck 	uint16_t i;
8090bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
810727b3fe2SEd Czeck 
811727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++)
812f588d3a5SJohn Miller 		eth_tx_queue_stats_reset(dev->data->tx_queues[i]);
813727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_rx_queues; i++)
814727b3fe2SEd Czeck 		eth_rx_queue_stats_reset(dev->data->rx_queues[i]);
815727b3fe2SEd Czeck 	if (ark->user_ext.stats_reset)
816428046b4SJohn Miller 		ark->user_ext.stats_reset(dev,
817428046b4SJohn Miller 			  ark->user_data[dev->data->port_id]);
8189970a9adSIgor Romanov 
8199970a9adSIgor Romanov 	return 0;
820727b3fe2SEd Czeck }
821727b3fe2SEd Czeck 
8226d01e580SWei Dai static int
eth_ark_macaddr_add(struct rte_eth_dev * dev,struct rte_ether_addr * mac_addr,uint32_t index,uint32_t pool)823727b3fe2SEd Czeck eth_ark_macaddr_add(struct rte_eth_dev *dev,
8246d13ea8eSOlivier Matz 		    struct rte_ether_addr *mac_addr,
825727b3fe2SEd Czeck 		    uint32_t index,
826727b3fe2SEd Czeck 		    uint32_t pool)
827727b3fe2SEd Czeck {
8280bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
829727b3fe2SEd Czeck 
8306d01e580SWei Dai 	if (ark->user_ext.mac_addr_add) {
831727b3fe2SEd Czeck 		ark->user_ext.mac_addr_add(dev,
832727b3fe2SEd Czeck 					   mac_addr,
833727b3fe2SEd Czeck 					   index,
834727b3fe2SEd Czeck 					   pool,
835428046b4SJohn Miller 			   ark->user_data[dev->data->port_id]);
8366d01e580SWei Dai 		return 0;
8376d01e580SWei Dai 	}
8386d01e580SWei Dai 	return -ENOTSUP;
839727b3fe2SEd Czeck }
840727b3fe2SEd Czeck 
841727b3fe2SEd Czeck static void
eth_ark_macaddr_remove(struct rte_eth_dev * dev,uint32_t index)842727b3fe2SEd Czeck eth_ark_macaddr_remove(struct rte_eth_dev *dev, uint32_t index)
843727b3fe2SEd Czeck {
8440bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
845727b3fe2SEd Czeck 
846727b3fe2SEd Czeck 	if (ark->user_ext.mac_addr_remove)
847428046b4SJohn Miller 		ark->user_ext.mac_addr_remove(dev, index,
848428046b4SJohn Miller 			      ark->user_data[dev->data->port_id]);
849727b3fe2SEd Czeck }
850727b3fe2SEd Czeck 
851caccf8b3SOlivier Matz static int
eth_ark_set_default_mac_addr(struct rte_eth_dev * dev,struct rte_ether_addr * mac_addr)852727b3fe2SEd Czeck eth_ark_set_default_mac_addr(struct rte_eth_dev *dev,
8536d13ea8eSOlivier Matz 			     struct rte_ether_addr *mac_addr)
854727b3fe2SEd Czeck {
8550bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
856727b3fe2SEd Czeck 
857caccf8b3SOlivier Matz 	if (ark->user_ext.mac_addr_set) {
858428046b4SJohn Miller 		ark->user_ext.mac_addr_set(dev, mac_addr,
859428046b4SJohn Miller 			   ark->user_data[dev->data->port_id]);
860caccf8b3SOlivier Matz 		return 0;
861caccf8b3SOlivier Matz 	}
862caccf8b3SOlivier Matz 	return -ENOTSUP;
863727b3fe2SEd Czeck }
864727b3fe2SEd Czeck 
8659ae74488SJohn Miller static int
eth_ark_set_mtu(struct rte_eth_dev * dev,uint16_t size)8669ae74488SJohn Miller eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t  size)
8679ae74488SJohn Miller {
8680bf8b0f1SStephen Hemminger 	struct ark_adapter *ark = dev->data->dev_private;
8699ae74488SJohn Miller 
8709ae74488SJohn Miller 	if (ark->user_ext.set_mtu)
8719ae74488SJohn Miller 		return ark->user_ext.set_mtu(dev, size,
8729ae74488SJohn Miller 			     ark->user_data[dev->data->port_id]);
8739ae74488SJohn Miller 
8749ae74488SJohn Miller 	return -ENOTSUP;
8759ae74488SJohn Miller }
8769ae74488SJohn Miller 
8771131cbf0SEd Czeck static inline int
process_pktdir_arg(const char * key,const char * value,void * extra_args)8781131cbf0SEd Czeck process_pktdir_arg(const char *key, const char *value,
8791131cbf0SEd Czeck 		   void *extra_args)
8801131cbf0SEd Czeck {
8811502d443SEd Czeck 	ARK_PMD_LOG(DEBUG, "key = %s, value = %s\n",
8821131cbf0SEd Czeck 		    key, value);
8831131cbf0SEd Czeck 	struct ark_adapter *ark =
8841131cbf0SEd Czeck 		(struct ark_adapter *)extra_args;
8851131cbf0SEd Czeck 
8861131cbf0SEd Czeck 	ark->pkt_dir_v = strtol(value, NULL, 16);
8871502d443SEd Czeck 	ARK_PMD_LOG(DEBUG, "pkt_dir_v = 0x%x\n", ark->pkt_dir_v);
8881131cbf0SEd Czeck 	return 0;
8891131cbf0SEd Czeck }
8901131cbf0SEd Czeck 
8911131cbf0SEd Czeck static inline int
process_file_args(const char * key,const char * value,void * extra_args)8921131cbf0SEd Czeck process_file_args(const char *key, const char *value, void *extra_args)
8931131cbf0SEd Czeck {
8941502d443SEd Czeck 	ARK_PMD_LOG(DEBUG, "key = %s, value = %s\n",
8951131cbf0SEd Czeck 		    key, value);
8961131cbf0SEd Czeck 	char *args = (char *)extra_args;
8971131cbf0SEd Czeck 
8981131cbf0SEd Czeck 	/* Open the configuration file */
8991131cbf0SEd Czeck 	FILE *file = fopen(value, "r");
9001131cbf0SEd Czeck 	char line[ARK_MAX_ARG_LEN];
9011131cbf0SEd Czeck 	int  size = 0;
9021131cbf0SEd Czeck 	int first = 1;
9031131cbf0SEd Czeck 
9042f3b88fbSJohn Miller 	if (file == NULL) {
9051502d443SEd Czeck 		ARK_PMD_LOG(ERR, "Unable to open "
9062f3b88fbSJohn Miller 			    "config file %s\n", value);
9072f3b88fbSJohn Miller 		return -1;
9082f3b88fbSJohn Miller 	}
9092f3b88fbSJohn Miller 
9101131cbf0SEd Czeck 	while (fgets(line, sizeof(line), file)) {
9111131cbf0SEd Czeck 		size += strlen(line);
9121131cbf0SEd Czeck 		if (size >= ARK_MAX_ARG_LEN) {
9131502d443SEd Czeck 			ARK_PMD_LOG(ERR, "Unable to parse file %s args, "
9141131cbf0SEd Czeck 				    "parameter list is too long\n", value);
9151131cbf0SEd Czeck 			fclose(file);
9161131cbf0SEd Czeck 			return -1;
9171131cbf0SEd Czeck 		}
9181131cbf0SEd Czeck 		if (first) {
9191131cbf0SEd Czeck 			strncpy(args, line, ARK_MAX_ARG_LEN);
9201131cbf0SEd Czeck 			first = 0;
9211131cbf0SEd Czeck 		} else {
9221131cbf0SEd Czeck 			strncat(args, line, ARK_MAX_ARG_LEN);
9231131cbf0SEd Czeck 		}
9241131cbf0SEd Czeck 	}
9251502d443SEd Czeck 	ARK_PMD_LOG(DEBUG, "file = %s\n", args);
9261131cbf0SEd Czeck 	fclose(file);
9271131cbf0SEd Czeck 	return 0;
9281131cbf0SEd Czeck }
9291131cbf0SEd Czeck 
9301131cbf0SEd Czeck static int
eth_ark_check_args(struct ark_adapter * ark,const char * params)9311131cbf0SEd Czeck eth_ark_check_args(struct ark_adapter *ark, const char *params)
9321131cbf0SEd Czeck {
9331131cbf0SEd Czeck 	struct rte_kvargs *kvlist;
9341131cbf0SEd Czeck 	unsigned int k_idx;
9351131cbf0SEd Czeck 	struct rte_kvargs_pair *pair = NULL;
9360f31eb0cSFerruh Yigit 	int ret = -1;
9371131cbf0SEd Czeck 
9381131cbf0SEd Czeck 	kvlist = rte_kvargs_parse(params, valid_arguments);
9391131cbf0SEd Czeck 	if (kvlist == NULL)
9401131cbf0SEd Czeck 		return 0;
9411131cbf0SEd Czeck 
9421131cbf0SEd Czeck 	ark->pkt_gen_args[0] = 0;
9431131cbf0SEd Czeck 	ark->pkt_chkr_args[0] = 0;
9441131cbf0SEd Czeck 
9451131cbf0SEd Czeck 	for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
9461131cbf0SEd Czeck 		pair = &kvlist->pairs[k_idx];
9471502d443SEd Czeck 		ARK_PMD_LOG(DEBUG, "**** Arg passed to PMD = %s:%s\n",
9481131cbf0SEd Czeck 			     pair->key,
9491131cbf0SEd Czeck 			     pair->value);
9501131cbf0SEd Czeck 	}
9511131cbf0SEd Czeck 
9521131cbf0SEd Czeck 	if (rte_kvargs_process(kvlist,
9531131cbf0SEd Czeck 			       ARK_PKTDIR_ARG,
9541131cbf0SEd Czeck 			       &process_pktdir_arg,
9551131cbf0SEd Czeck 			       ark) != 0) {
9561502d443SEd Czeck 		ARK_PMD_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTDIR_ARG);
9570f31eb0cSFerruh Yigit 		goto free_kvlist;
9581131cbf0SEd Czeck 	}
9591131cbf0SEd Czeck 
9601131cbf0SEd Czeck 	if (rte_kvargs_process(kvlist,
9611131cbf0SEd Czeck 			       ARK_PKTGEN_ARG,
9621131cbf0SEd Czeck 			       &process_file_args,
9631131cbf0SEd Czeck 			       ark->pkt_gen_args) != 0) {
9641502d443SEd Czeck 		ARK_PMD_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTGEN_ARG);
9650f31eb0cSFerruh Yigit 		goto free_kvlist;
9661131cbf0SEd Czeck 	}
9671131cbf0SEd Czeck 
9681131cbf0SEd Czeck 	if (rte_kvargs_process(kvlist,
9691131cbf0SEd Czeck 			       ARK_PKTCHKR_ARG,
9701131cbf0SEd Czeck 			       &process_file_args,
9711131cbf0SEd Czeck 			       ark->pkt_chkr_args) != 0) {
9721502d443SEd Czeck 		ARK_PMD_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTCHKR_ARG);
9730f31eb0cSFerruh Yigit 		goto free_kvlist;
9741131cbf0SEd Czeck 	}
9751131cbf0SEd Czeck 
9766799275eSEd Czeck 	if (ark->isvf) {
9776799275eSEd Czeck 		ret = 0;
9786799275eSEd Czeck 		goto free_kvlist;
9796799275eSEd Czeck 	}
9801502d443SEd Czeck 	ARK_PMD_LOG(INFO, "packet director set to 0x%x\n", ark->pkt_dir_v);
981727b3fe2SEd Czeck 	/* Setup the packet director */
982727b3fe2SEd Czeck 	ark_pktdir_setup(ark->pd, ark->pkt_dir_v);
983727b3fe2SEd Czeck 
984727b3fe2SEd Czeck 	/* Setup the packet generator */
985727b3fe2SEd Czeck 	if (ark->pkt_gen_args[0]) {
9861502d443SEd Czeck 		ARK_PMD_LOG(DEBUG, "Setting up the packet generator\n");
987727b3fe2SEd Czeck 		ark_pktgen_parse(ark->pkt_gen_args);
988727b3fe2SEd Czeck 		ark_pktgen_reset(ark->pg);
989727b3fe2SEd Czeck 		ark_pktgen_setup(ark->pg);
990727b3fe2SEd Czeck 		ark->start_pg = 1;
991727b3fe2SEd Czeck 	}
992727b3fe2SEd Czeck 
993727b3fe2SEd Czeck 	/* Setup the packet checker */
994727b3fe2SEd Czeck 	if (ark->pkt_chkr_args[0]) {
995727b3fe2SEd Czeck 		ark_pktchkr_parse(ark->pkt_chkr_args);
996727b3fe2SEd Czeck 		ark_pktchkr_setup(ark->pc);
997727b3fe2SEd Czeck 	}
9981131cbf0SEd Czeck 
9990f31eb0cSFerruh Yigit 	ret = 0;
10000f31eb0cSFerruh Yigit 
10010f31eb0cSFerruh Yigit free_kvlist:
10020f31eb0cSFerruh Yigit 	rte_kvargs_free(kvlist);
10030f31eb0cSFerruh Yigit 
10040f31eb0cSFerruh Yigit 	return ret;
10051131cbf0SEd Czeck }
10061131cbf0SEd Czeck 
10071131cbf0SEd Czeck RTE_PMD_REGISTER_PCI(net_ark, rte_ark_pmd);
10081131cbf0SEd Czeck RTE_PMD_REGISTER_KMOD_DEP(net_ark, "* igb_uio | uio_pci_generic ");
10091131cbf0SEd Czeck RTE_PMD_REGISTER_PCI_TABLE(net_ark, pci_id_ark_map);
10101131cbf0SEd Czeck RTE_PMD_REGISTER_PARAM_STRING(net_ark,
10111131cbf0SEd Czeck 			      ARK_PKTGEN_ARG "=<filename> "
10121131cbf0SEd Czeck 			      ARK_PKTCHKR_ARG "=<filename> "
10131131cbf0SEd Czeck 			      ARK_PKTDIR_ARG "=<bitmap>");
1014eeded204SDavid Marchand RTE_LOG_REGISTER_DEFAULT(ark_logtype, NOTICE);
1015