xref: /dpdk/drivers/net/ark/ark_ethdev.c (revision d5b0924ba6baae2cb6ac7c880db0977d4befedc6)
11131cbf0SEd Czeck /*-
21131cbf0SEd Czeck  * BSD LICENSE
31131cbf0SEd Czeck  *
41131cbf0SEd Czeck  * Copyright (c) 2015-2017 Atomic Rules LLC
51131cbf0SEd Czeck  * All rights reserved.
61131cbf0SEd Czeck  *
71131cbf0SEd Czeck  * Redistribution and use in source and binary forms, with or without
81131cbf0SEd Czeck  * modification, are permitted provided that the following conditions
91131cbf0SEd Czeck  * are met:
101131cbf0SEd Czeck  *
111131cbf0SEd Czeck  * * Redistributions of source code must retain the above copyright
121131cbf0SEd Czeck  * notice, this list of conditions and the following disclaimer.
131131cbf0SEd Czeck  * * Redistributions in binary form must reproduce the above copyright
141131cbf0SEd Czeck  * notice, this list of conditions and the following disclaimer in
151131cbf0SEd Czeck  * the documentation and/or other materials provided with the
161131cbf0SEd Czeck  * distribution.
171131cbf0SEd Czeck  * * Neither the name of copyright holder nor the names of its
181131cbf0SEd Czeck  * contributors may be used to endorse or promote products derived
191131cbf0SEd Czeck  * from this software without specific prior written permission.
201131cbf0SEd Czeck  *
211131cbf0SEd Czeck  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
221131cbf0SEd Czeck  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
231131cbf0SEd Czeck  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
241131cbf0SEd Czeck  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
251131cbf0SEd Czeck  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
261131cbf0SEd Czeck  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
271131cbf0SEd Czeck  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
281131cbf0SEd Czeck  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
291131cbf0SEd Czeck  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
301131cbf0SEd Czeck  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
311131cbf0SEd Czeck  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
321131cbf0SEd Czeck  */
331131cbf0SEd Czeck 
341131cbf0SEd Czeck #include <unistd.h>
351131cbf0SEd Czeck #include <sys/stat.h>
361131cbf0SEd Czeck #include <dlfcn.h>
371131cbf0SEd Czeck 
381131cbf0SEd Czeck #include <rte_ethdev_pci.h>
391131cbf0SEd Czeck #include <rte_kvargs.h>
401131cbf0SEd Czeck 
411131cbf0SEd Czeck #include "ark_global.h"
421131cbf0SEd Czeck #include "ark_logs.h"
43727b3fe2SEd Czeck #include "ark_ethdev_tx.h"
44727b3fe2SEd Czeck #include "ark_ethdev_rx.h"
45727b3fe2SEd Czeck #include "ark_mpu.h"
46727b3fe2SEd Czeck #include "ark_ddm.h"
47727b3fe2SEd Czeck #include "ark_udm.h"
48727b3fe2SEd Czeck #include "ark_rqp.h"
49727b3fe2SEd Czeck #include "ark_pktdir.h"
50727b3fe2SEd Czeck #include "ark_pktgen.h"
51727b3fe2SEd Czeck #include "ark_pktchkr.h"
521131cbf0SEd Czeck 
531131cbf0SEd Czeck /*  Internal prototypes */
541131cbf0SEd Czeck static int eth_ark_check_args(struct ark_adapter *ark, const char *params);
551131cbf0SEd Czeck static int eth_ark_dev_init(struct rte_eth_dev *dev);
56727b3fe2SEd Czeck static int ark_config_device(struct rte_eth_dev *dev);
571131cbf0SEd Czeck static int eth_ark_dev_uninit(struct rte_eth_dev *eth_dev);
581131cbf0SEd Czeck static int eth_ark_dev_configure(struct rte_eth_dev *dev);
59727b3fe2SEd Czeck static int eth_ark_dev_start(struct rte_eth_dev *dev);
60727b3fe2SEd Czeck static void eth_ark_dev_stop(struct rte_eth_dev *dev);
61727b3fe2SEd Czeck static void eth_ark_dev_close(struct rte_eth_dev *dev);
621131cbf0SEd Czeck static void eth_ark_dev_info_get(struct rte_eth_dev *dev,
631131cbf0SEd Czeck 				 struct rte_eth_dev_info *dev_info);
64727b3fe2SEd Czeck static int eth_ark_dev_link_update(struct rte_eth_dev *dev,
65727b3fe2SEd Czeck 				   int wait_to_complete);
66727b3fe2SEd Czeck static int eth_ark_dev_set_link_up(struct rte_eth_dev *dev);
67727b3fe2SEd Czeck static int eth_ark_dev_set_link_down(struct rte_eth_dev *dev);
68*d5b0924bSMatan Azrad static int eth_ark_dev_stats_get(struct rte_eth_dev *dev,
69727b3fe2SEd Czeck 				  struct rte_eth_stats *stats);
70727b3fe2SEd Czeck static void eth_ark_dev_stats_reset(struct rte_eth_dev *dev);
71727b3fe2SEd Czeck static void eth_ark_set_default_mac_addr(struct rte_eth_dev *dev,
72727b3fe2SEd Czeck 					 struct ether_addr *mac_addr);
736d01e580SWei Dai static int eth_ark_macaddr_add(struct rte_eth_dev *dev,
74727b3fe2SEd Czeck 			       struct ether_addr *mac_addr,
75727b3fe2SEd Czeck 			       uint32_t index,
76727b3fe2SEd Czeck 			       uint32_t pool);
77727b3fe2SEd Czeck static void eth_ark_macaddr_remove(struct rte_eth_dev *dev,
78727b3fe2SEd Czeck 				   uint32_t index);
799ae74488SJohn Miller static int  eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
801131cbf0SEd Czeck 
811131cbf0SEd Czeck /*
821131cbf0SEd Czeck  * The packet generator is a functional block used to generate packet
831131cbf0SEd Czeck  * patterns for testing.  It is not intended for nominal use.
841131cbf0SEd Czeck  */
851131cbf0SEd Czeck #define ARK_PKTGEN_ARG "Pkt_gen"
861131cbf0SEd Czeck 
871131cbf0SEd Czeck /*
881131cbf0SEd Czeck  * The packet checker is a functional block used to verify packet
891131cbf0SEd Czeck  * patterns for testing.  It is not intended for nominal use.
901131cbf0SEd Czeck  */
911131cbf0SEd Czeck #define ARK_PKTCHKR_ARG "Pkt_chkr"
921131cbf0SEd Czeck 
931131cbf0SEd Czeck /*
941131cbf0SEd Czeck  * The packet director is used to select the internal ingress and
951131cbf0SEd Czeck  * egress packets paths during testing.  It is not intended for
961131cbf0SEd Czeck  * nominal use.
971131cbf0SEd Czeck  */
981131cbf0SEd Czeck #define ARK_PKTDIR_ARG "Pkt_dir"
991131cbf0SEd Czeck 
1001131cbf0SEd Czeck /* Devinfo configurations */
1011131cbf0SEd Czeck #define ARK_RX_MAX_QUEUE (4096 * 4)
1021131cbf0SEd Czeck #define ARK_RX_MIN_QUEUE (512)
1031131cbf0SEd Czeck #define ARK_RX_MAX_PKT_LEN ((16 * 1024) - 128)
1041131cbf0SEd Czeck #define ARK_RX_MIN_BUFSIZE (1024)
1051131cbf0SEd Czeck 
1061131cbf0SEd Czeck #define ARK_TX_MAX_QUEUE (4096 * 4)
1071131cbf0SEd Czeck #define ARK_TX_MIN_QUEUE (256)
1081131cbf0SEd Czeck 
1091131cbf0SEd Czeck static const char * const valid_arguments[] = {
1101131cbf0SEd Czeck 	ARK_PKTGEN_ARG,
1111131cbf0SEd Czeck 	ARK_PKTCHKR_ARG,
1121131cbf0SEd Czeck 	ARK_PKTDIR_ARG,
1131131cbf0SEd Czeck 	NULL
1141131cbf0SEd Czeck };
1151131cbf0SEd Czeck 
1161131cbf0SEd Czeck static const struct rte_pci_id pci_id_ark_map[] = {
1171131cbf0SEd Czeck 	{RTE_PCI_DEVICE(0x1d6c, 0x100d)},
1181131cbf0SEd Czeck 	{RTE_PCI_DEVICE(0x1d6c, 0x100e)},
1191131cbf0SEd Czeck 	{.vendor_id = 0, /* sentinel */ },
1201131cbf0SEd Czeck };
1211131cbf0SEd Czeck 
1221131cbf0SEd Czeck static int
1231131cbf0SEd Czeck eth_ark_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1241131cbf0SEd Czeck 		struct rte_pci_device *pci_dev)
1251131cbf0SEd Czeck {
1261131cbf0SEd Czeck 	struct rte_eth_dev *eth_dev;
1271131cbf0SEd Czeck 	int ret;
1281131cbf0SEd Czeck 
1291131cbf0SEd Czeck 	eth_dev = rte_eth_dev_pci_allocate(pci_dev, sizeof(struct ark_adapter));
1301131cbf0SEd Czeck 
1311131cbf0SEd Czeck 	if (eth_dev == NULL)
1321131cbf0SEd Czeck 		return -ENOMEM;
1331131cbf0SEd Czeck 
1341131cbf0SEd Czeck 	ret = eth_ark_dev_init(eth_dev);
1351131cbf0SEd Czeck 	if (ret)
1361131cbf0SEd Czeck 		rte_eth_dev_pci_release(eth_dev);
1371131cbf0SEd Czeck 
1381131cbf0SEd Czeck 	return ret;
1391131cbf0SEd Czeck }
1401131cbf0SEd Czeck 
1411131cbf0SEd Czeck static int
1421131cbf0SEd Czeck eth_ark_pci_remove(struct rte_pci_device *pci_dev)
1431131cbf0SEd Czeck {
1441131cbf0SEd Czeck 	return rte_eth_dev_pci_generic_remove(pci_dev, eth_ark_dev_uninit);
1451131cbf0SEd Czeck }
1461131cbf0SEd Czeck 
1471131cbf0SEd Czeck static struct rte_pci_driver rte_ark_pmd = {
1481131cbf0SEd Czeck 	.id_table = pci_id_ark_map,
1491131cbf0SEd Czeck 	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
1501131cbf0SEd Czeck 	.probe = eth_ark_pci_probe,
1511131cbf0SEd Czeck 	.remove = eth_ark_pci_remove,
1521131cbf0SEd Czeck };
1531131cbf0SEd Czeck 
1541131cbf0SEd Czeck static const struct eth_dev_ops ark_eth_dev_ops = {
1551131cbf0SEd Czeck 	.dev_configure = eth_ark_dev_configure,
156727b3fe2SEd Czeck 	.dev_start = eth_ark_dev_start,
157727b3fe2SEd Czeck 	.dev_stop = eth_ark_dev_stop,
158727b3fe2SEd Czeck 	.dev_close = eth_ark_dev_close,
159727b3fe2SEd Czeck 
1601131cbf0SEd Czeck 	.dev_infos_get = eth_ark_dev_info_get,
161727b3fe2SEd Czeck 
162727b3fe2SEd Czeck 	.rx_queue_setup = eth_ark_dev_rx_queue_setup,
163727b3fe2SEd Czeck 	.rx_queue_count = eth_ark_dev_rx_queue_count,
164727b3fe2SEd Czeck 	.tx_queue_setup = eth_ark_tx_queue_setup,
165727b3fe2SEd Czeck 
166727b3fe2SEd Czeck 	.link_update = eth_ark_dev_link_update,
167727b3fe2SEd Czeck 	.dev_set_link_up = eth_ark_dev_set_link_up,
168727b3fe2SEd Czeck 	.dev_set_link_down = eth_ark_dev_set_link_down,
169727b3fe2SEd Czeck 
170727b3fe2SEd Czeck 	.rx_queue_start = eth_ark_rx_start_queue,
171727b3fe2SEd Czeck 	.rx_queue_stop = eth_ark_rx_stop_queue,
172727b3fe2SEd Czeck 
173727b3fe2SEd Czeck 	.tx_queue_start = eth_ark_tx_queue_start,
174727b3fe2SEd Czeck 	.tx_queue_stop = eth_ark_tx_queue_stop,
175727b3fe2SEd Czeck 
176727b3fe2SEd Czeck 	.stats_get = eth_ark_dev_stats_get,
177727b3fe2SEd Czeck 	.stats_reset = eth_ark_dev_stats_reset,
178727b3fe2SEd Czeck 
179727b3fe2SEd Czeck 	.mac_addr_add = eth_ark_macaddr_add,
180727b3fe2SEd Czeck 	.mac_addr_remove = eth_ark_macaddr_remove,
181727b3fe2SEd Czeck 	.mac_addr_set = eth_ark_set_default_mac_addr,
1829ae74488SJohn Miller 
1839ae74488SJohn Miller 	.mtu_set = eth_ark_set_mtu,
1841131cbf0SEd Czeck };
1851131cbf0SEd Czeck 
1861131cbf0SEd Czeck static int
187727b3fe2SEd Czeck check_for_ext(struct ark_adapter *ark)
188727b3fe2SEd Czeck {
189727b3fe2SEd Czeck 	int found = 0;
190727b3fe2SEd Czeck 
191727b3fe2SEd Czeck 	/* Get the env */
192727b3fe2SEd Czeck 	const char *dllpath = getenv("ARK_EXT_PATH");
193727b3fe2SEd Czeck 
194727b3fe2SEd Czeck 	if (dllpath == NULL) {
195727b3fe2SEd Czeck 		PMD_DEBUG_LOG(DEBUG, "ARK EXT NO dll path specified\n");
196727b3fe2SEd Czeck 		return 0;
197727b3fe2SEd Czeck 	}
198727b3fe2SEd Czeck 	PMD_DRV_LOG(INFO, "ARK EXT found dll path at %s\n", dllpath);
199727b3fe2SEd Czeck 
200727b3fe2SEd Czeck 	/* Open and load the .so */
201727b3fe2SEd Czeck 	ark->d_handle = dlopen(dllpath, RTLD_LOCAL | RTLD_LAZY);
202727b3fe2SEd Czeck 	if (ark->d_handle == NULL) {
203727b3fe2SEd Czeck 		PMD_DRV_LOG(ERR, "Could not load user extension %s\n",
204727b3fe2SEd Czeck 			    dllpath);
205727b3fe2SEd Czeck 		return -1;
206727b3fe2SEd Czeck 	}
207727b3fe2SEd Czeck 	PMD_DRV_LOG(INFO, "SUCCESS: loaded user extension %s\n",
208727b3fe2SEd Czeck 			    dllpath);
209727b3fe2SEd Czeck 
210727b3fe2SEd Czeck 	/* Get the entry points */
211727b3fe2SEd Czeck 	ark->user_ext.dev_init =
212727b3fe2SEd Czeck 		(void *(*)(struct rte_eth_dev *, void *, int))
213727b3fe2SEd Czeck 		dlsym(ark->d_handle, "dev_init");
214727b3fe2SEd Czeck 	PMD_DEBUG_LOG(DEBUG, "device ext init pointer = %p\n",
215727b3fe2SEd Czeck 		      ark->user_ext.dev_init);
216727b3fe2SEd Czeck 	ark->user_ext.dev_get_port_count =
217727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
218727b3fe2SEd Czeck 		dlsym(ark->d_handle, "dev_get_port_count");
219727b3fe2SEd Czeck 	ark->user_ext.dev_uninit =
220727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, void *))
221727b3fe2SEd Czeck 		dlsym(ark->d_handle, "dev_uninit");
222727b3fe2SEd Czeck 	ark->user_ext.dev_configure =
223727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
224727b3fe2SEd Czeck 		dlsym(ark->d_handle, "dev_configure");
225727b3fe2SEd Czeck 	ark->user_ext.dev_start =
226727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
227727b3fe2SEd Czeck 		dlsym(ark->d_handle, "dev_start");
228727b3fe2SEd Czeck 	ark->user_ext.dev_stop =
229727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, void *))
230727b3fe2SEd Czeck 		dlsym(ark->d_handle, "dev_stop");
231727b3fe2SEd Czeck 	ark->user_ext.dev_close =
232727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, void *))
233727b3fe2SEd Czeck 		dlsym(ark->d_handle, "dev_close");
234727b3fe2SEd Czeck 	ark->user_ext.link_update =
235727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, int, void *))
236727b3fe2SEd Czeck 		dlsym(ark->d_handle, "link_update");
237727b3fe2SEd Czeck 	ark->user_ext.dev_set_link_up =
238727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
239727b3fe2SEd Czeck 		dlsym(ark->d_handle, "dev_set_link_up");
240727b3fe2SEd Czeck 	ark->user_ext.dev_set_link_down =
241727b3fe2SEd Czeck 		(int (*)(struct rte_eth_dev *, void *))
242727b3fe2SEd Czeck 		dlsym(ark->d_handle, "dev_set_link_down");
243727b3fe2SEd Czeck 	ark->user_ext.stats_get =
244*d5b0924bSMatan Azrad 		(int (*)(struct rte_eth_dev *, struct rte_eth_stats *,
245727b3fe2SEd Czeck 			  void *))
246727b3fe2SEd Czeck 		dlsym(ark->d_handle, "stats_get");
247727b3fe2SEd Czeck 	ark->user_ext.stats_reset =
248727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, void *))
249727b3fe2SEd Czeck 		dlsym(ark->d_handle, "stats_reset");
250727b3fe2SEd Czeck 	ark->user_ext.mac_addr_add =
251727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, struct ether_addr *, uint32_t,
252727b3fe2SEd Czeck 			  uint32_t, void *))
253727b3fe2SEd Czeck 		dlsym(ark->d_handle, "mac_addr_add");
254727b3fe2SEd Czeck 	ark->user_ext.mac_addr_remove =
255727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, uint32_t, void *))
256727b3fe2SEd Czeck 		dlsym(ark->d_handle, "mac_addr_remove");
257727b3fe2SEd Czeck 	ark->user_ext.mac_addr_set =
258727b3fe2SEd Czeck 		(void (*)(struct rte_eth_dev *, struct ether_addr *,
259727b3fe2SEd Czeck 			  void *))
260727b3fe2SEd Czeck 		dlsym(ark->d_handle, "mac_addr_set");
2619ae74488SJohn Miller 	ark->user_ext.set_mtu =
2629ae74488SJohn Miller 		(int (*)(struct rte_eth_dev *, uint16_t,
2639ae74488SJohn Miller 			  void *))
2649ae74488SJohn Miller 		dlsym(ark->d_handle, "set_mtu");
265727b3fe2SEd Czeck 
266727b3fe2SEd Czeck 	return found;
267727b3fe2SEd Czeck }
268727b3fe2SEd Czeck 
269727b3fe2SEd Czeck static int
2701131cbf0SEd Czeck eth_ark_dev_init(struct rte_eth_dev *dev)
2711131cbf0SEd Czeck {
2721131cbf0SEd Czeck 	struct ark_adapter *ark =
2731131cbf0SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
2741131cbf0SEd Czeck 	struct rte_pci_device *pci_dev;
275727b3fe2SEd Czeck 	int ret;
276727b3fe2SEd Czeck 	int port_count = 1;
277727b3fe2SEd Czeck 	int p;
2781131cbf0SEd Czeck 
2791131cbf0SEd Czeck 	ark->eth_dev = dev;
2801131cbf0SEd Czeck 
2811131cbf0SEd Czeck 	PMD_FUNC_LOG(DEBUG, "\n");
2821131cbf0SEd Czeck 
283727b3fe2SEd Czeck 	/* Check to see if there is an extension that we need to load */
284727b3fe2SEd Czeck 	ret = check_for_ext(ark);
285727b3fe2SEd Czeck 	if (ret)
286727b3fe2SEd Czeck 		return ret;
287c0802544SFerruh Yigit 	pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2881131cbf0SEd Czeck 	rte_eth_copy_pci_info(dev, pci_dev);
2891131cbf0SEd Czeck 
290727b3fe2SEd Czeck 	/* Use dummy function until setup */
291727b3fe2SEd Czeck 	dev->rx_pkt_burst = &eth_ark_recv_pkts_noop;
292727b3fe2SEd Czeck 	dev->tx_pkt_burst = &eth_ark_xmit_pkts_noop;
293727b3fe2SEd Czeck 
2941131cbf0SEd Czeck 	ark->bar0 = (uint8_t *)pci_dev->mem_resource[0].addr;
2951131cbf0SEd Czeck 	ark->a_bar = (uint8_t *)pci_dev->mem_resource[2].addr;
2961131cbf0SEd Czeck 
297727b3fe2SEd Czeck 	ark->sysctrl.v  = (void *)&ark->bar0[ARK_SYSCTRL_BASE];
298727b3fe2SEd Czeck 	ark->mpurx.v  = (void *)&ark->bar0[ARK_MPU_RX_BASE];
299727b3fe2SEd Czeck 	ark->udm.v  = (void *)&ark->bar0[ARK_UDM_BASE];
300727b3fe2SEd Czeck 	ark->mputx.v  = (void *)&ark->bar0[ARK_MPU_TX_BASE];
301727b3fe2SEd Czeck 	ark->ddm.v  = (void *)&ark->bar0[ARK_DDM_BASE];
302727b3fe2SEd Czeck 	ark->cmac.v  = (void *)&ark->bar0[ARK_CMAC_BASE];
303727b3fe2SEd Czeck 	ark->external.v  = (void *)&ark->bar0[ARK_EXTERNAL_BASE];
304727b3fe2SEd Czeck 	ark->pktdir.v  = (void *)&ark->bar0[ARK_PKTDIR_BASE];
305727b3fe2SEd Czeck 	ark->pktgen.v  = (void *)&ark->bar0[ARK_PKTGEN_BASE];
306727b3fe2SEd Czeck 	ark->pktchkr.v  = (void *)&ark->bar0[ARK_PKTCHKR_BASE];
307727b3fe2SEd Czeck 
308727b3fe2SEd Czeck 	ark->rqpacing =
309727b3fe2SEd Czeck 		(struct ark_rqpace_t *)(ark->bar0 + ARK_RCPACING_BASE);
310727b3fe2SEd Czeck 	ark->started = 0;
311727b3fe2SEd Czeck 
312727b3fe2SEd Czeck 	PMD_DEBUG_LOG(INFO, "Sys Ctrl Const = 0x%x  HW Commit_ID: %08x\n",
313727b3fe2SEd Czeck 		      ark->sysctrl.t32[4],
314727b3fe2SEd Czeck 		      rte_be_to_cpu_32(ark->sysctrl.t32[0x20 / 4]));
315727b3fe2SEd Czeck 	PMD_DRV_LOG(INFO, "Arkville HW Commit_ID: %08x\n",
316727b3fe2SEd Czeck 		    rte_be_to_cpu_32(ark->sysctrl.t32[0x20 / 4]));
317727b3fe2SEd Czeck 
318727b3fe2SEd Czeck 	/* If HW sanity test fails, return an error */
319727b3fe2SEd Czeck 	if (ark->sysctrl.t32[4] != 0xcafef00d) {
320727b3fe2SEd Czeck 		PMD_DRV_LOG(ERR,
321727b3fe2SEd Czeck 			    "HW Sanity test has failed, expected constant"
322727b3fe2SEd Czeck 			    " 0x%x, read 0x%x (%s)\n",
323727b3fe2SEd Czeck 			    0xcafef00d,
324727b3fe2SEd Czeck 			    ark->sysctrl.t32[4], __func__);
325727b3fe2SEd Czeck 		return -1;
326727b3fe2SEd Czeck 	}
3279ff8fe95SEd Czeck 	if (ark->sysctrl.t32[3] != 0) {
3289ff8fe95SEd Czeck 		if (ark_rqp_lasped(ark->rqpacing)) {
3299ff8fe95SEd Czeck 			PMD_DRV_LOG(ERR, "Arkville Evaluation System - "
3309ff8fe95SEd Czeck 				    "Timer has Expired\n");
3319ff8fe95SEd Czeck 			return -1;
3329ff8fe95SEd Czeck 		}
3339ff8fe95SEd Czeck 		PMD_DRV_LOG(WARNING, "Arkville Evaluation System - "
3349ff8fe95SEd Czeck 			    "Timer is Running\n");
3359ff8fe95SEd Czeck 	}
336727b3fe2SEd Czeck 
337727b3fe2SEd Czeck 	PMD_DRV_LOG(INFO,
338727b3fe2SEd Czeck 		    "HW Sanity test has PASSED, expected constant"
339727b3fe2SEd Czeck 		    " 0x%x, read 0x%x (%s)\n",
340727b3fe2SEd Czeck 		    0xcafef00d, ark->sysctrl.t32[4], __func__);
341727b3fe2SEd Czeck 
342727b3fe2SEd Czeck 	/* We are a single function multi-port device. */
343727b3fe2SEd Czeck 	ret = ark_config_device(dev);
3441131cbf0SEd Czeck 	dev->dev_ops = &ark_eth_dev_ops;
3451131cbf0SEd Czeck 	dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
3461131cbf0SEd Czeck 
347727b3fe2SEd Czeck 	dev->data->mac_addrs = rte_zmalloc("ark", ETHER_ADDR_LEN, 0);
348727b3fe2SEd Czeck 	if (!dev->data->mac_addrs) {
349727b3fe2SEd Czeck 		PMD_DRV_LOG(ERR,
350727b3fe2SEd Czeck 			    "Failed to allocated memory for storing mac address"
351727b3fe2SEd Czeck 			    );
352727b3fe2SEd Czeck 	}
353727b3fe2SEd Czeck 
354727b3fe2SEd Czeck 	if (ark->user_ext.dev_init) {
355428046b4SJohn Miller 		ark->user_data[dev->data->port_id] =
356428046b4SJohn Miller 			ark->user_ext.dev_init(dev, ark->a_bar, 0);
357428046b4SJohn Miller 		if (!ark->user_data[dev->data->port_id]) {
358727b3fe2SEd Czeck 			PMD_DRV_LOG(INFO,
359727b3fe2SEd Czeck 				    "Failed to initialize PMD extension!"
360727b3fe2SEd Czeck 				    " continuing without it\n");
361727b3fe2SEd Czeck 			memset(&ark->user_ext, 0, sizeof(struct ark_user_ext));
362727b3fe2SEd Czeck 			dlclose(ark->d_handle);
363727b3fe2SEd Czeck 		}
364727b3fe2SEd Czeck 	}
365727b3fe2SEd Czeck 
3661131cbf0SEd Czeck 	if (pci_dev->device.devargs)
3671131cbf0SEd Czeck 		ret = eth_ark_check_args(ark, pci_dev->device.devargs->args);
3681131cbf0SEd Czeck 	else
3691131cbf0SEd Czeck 		PMD_DRV_LOG(INFO, "No Device args found\n");
3701131cbf0SEd Czeck 
371727b3fe2SEd Czeck 	if (ret)
372727b3fe2SEd Czeck 		goto error;
373727b3fe2SEd Czeck 	/*
374727b3fe2SEd Czeck 	 * We will create additional devices based on the number of requested
375727b3fe2SEd Czeck 	 * ports
376727b3fe2SEd Czeck 	 */
377727b3fe2SEd Czeck 	if (ark->user_ext.dev_get_port_count)
378727b3fe2SEd Czeck 		port_count =
379428046b4SJohn Miller 			ark->user_ext.dev_get_port_count(dev,
380428046b4SJohn Miller 				 ark->user_data[dev->data->port_id]);
381727b3fe2SEd Czeck 	ark->num_ports = port_count;
382727b3fe2SEd Czeck 
383727b3fe2SEd Czeck 	for (p = 0; p < port_count; p++) {
384727b3fe2SEd Czeck 		struct rte_eth_dev *eth_dev;
385727b3fe2SEd Czeck 		char name[RTE_ETH_NAME_MAX_LEN];
386727b3fe2SEd Czeck 
387727b3fe2SEd Czeck 		snprintf(name, sizeof(name), "arketh%d",
388727b3fe2SEd Czeck 			 dev->data->port_id + p);
389727b3fe2SEd Czeck 
390727b3fe2SEd Czeck 		if (p == 0) {
391727b3fe2SEd Czeck 			/* First port is already allocated by DPDK */
392727b3fe2SEd Czeck 			eth_dev = ark->eth_dev;
393727b3fe2SEd Czeck 			continue;
394727b3fe2SEd Czeck 		}
395727b3fe2SEd Czeck 
396727b3fe2SEd Czeck 		/* reserve an ethdev entry */
397727b3fe2SEd Czeck 		eth_dev = rte_eth_dev_allocate(name);
398727b3fe2SEd Czeck 		if (!eth_dev) {
399727b3fe2SEd Czeck 			PMD_DRV_LOG(ERR,
400727b3fe2SEd Czeck 				    "Could not allocate eth_dev for port %d\n",
401727b3fe2SEd Czeck 				    p);
402727b3fe2SEd Czeck 			goto error;
403727b3fe2SEd Czeck 		}
404727b3fe2SEd Czeck 
405727b3fe2SEd Czeck 		eth_dev->device = &pci_dev->device;
406727b3fe2SEd Czeck 		eth_dev->data->dev_private = ark;
407727b3fe2SEd Czeck 		eth_dev->dev_ops = ark->eth_dev->dev_ops;
408727b3fe2SEd Czeck 		eth_dev->tx_pkt_burst = ark->eth_dev->tx_pkt_burst;
409727b3fe2SEd Czeck 		eth_dev->rx_pkt_burst = ark->eth_dev->rx_pkt_burst;
410727b3fe2SEd Czeck 
411727b3fe2SEd Czeck 		rte_eth_copy_pci_info(eth_dev, pci_dev);
412727b3fe2SEd Czeck 
413727b3fe2SEd Czeck 		eth_dev->data->mac_addrs = rte_zmalloc(name, ETHER_ADDR_LEN, 0);
414727b3fe2SEd Czeck 		if (!eth_dev->data->mac_addrs) {
415727b3fe2SEd Czeck 			PMD_DRV_LOG(ERR,
416727b3fe2SEd Czeck 				    "Memory allocation for MAC failed!"
417727b3fe2SEd Czeck 				    " Exiting.\n");
418727b3fe2SEd Czeck 			goto error;
419727b3fe2SEd Czeck 		}
420727b3fe2SEd Czeck 
421428046b4SJohn Miller 		if (ark->user_ext.dev_init) {
422428046b4SJohn Miller 			ark->user_data[eth_dev->data->port_id] =
423727b3fe2SEd Czeck 				ark->user_ext.dev_init(dev, ark->a_bar, p);
424727b3fe2SEd Czeck 		}
425428046b4SJohn Miller 	}
426727b3fe2SEd Czeck 
4271131cbf0SEd Czeck 	return ret;
428727b3fe2SEd Czeck 
429727b3fe2SEd Czeck  error:
430727b3fe2SEd Czeck 	if (dev->data->mac_addrs)
431727b3fe2SEd Czeck 		rte_free(dev->data->mac_addrs);
432727b3fe2SEd Czeck 	return -1;
433727b3fe2SEd Czeck }
434727b3fe2SEd Czeck 
435727b3fe2SEd Czeck /*
436727b3fe2SEd Czeck  *Initial device configuration when device is opened
437727b3fe2SEd Czeck  * setup the DDM, and UDM
438727b3fe2SEd Czeck  * Called once per PCIE device
439727b3fe2SEd Czeck  */
440727b3fe2SEd Czeck static int
441727b3fe2SEd Czeck ark_config_device(struct rte_eth_dev *dev)
442727b3fe2SEd Czeck {
443727b3fe2SEd Czeck 	struct ark_adapter *ark =
444727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
445727b3fe2SEd Czeck 	uint16_t num_q, i;
446727b3fe2SEd Czeck 	struct ark_mpu_t *mpu;
447727b3fe2SEd Czeck 
448727b3fe2SEd Czeck 	/*
449727b3fe2SEd Czeck 	 * Make sure that the packet director, generator and checker are in a
450727b3fe2SEd Czeck 	 * known state
451727b3fe2SEd Czeck 	 */
452727b3fe2SEd Czeck 	ark->start_pg = 0;
453727b3fe2SEd Czeck 	ark->pg = ark_pktgen_init(ark->pktgen.v, 0, 1);
45453a9ba13SYong Wang 	if (ark->pg == NULL)
45553a9ba13SYong Wang 		return -1;
456727b3fe2SEd Czeck 	ark_pktgen_reset(ark->pg);
457727b3fe2SEd Czeck 	ark->pc = ark_pktchkr_init(ark->pktchkr.v, 0, 1);
45853a9ba13SYong Wang 	if (ark->pc == NULL)
45953a9ba13SYong Wang 		return -1;
460727b3fe2SEd Czeck 	ark_pktchkr_stop(ark->pc);
461727b3fe2SEd Czeck 	ark->pd = ark_pktdir_init(ark->pktdir.v);
46253a9ba13SYong Wang 	if (ark->pd == NULL)
46353a9ba13SYong Wang 		return -1;
464727b3fe2SEd Czeck 
465727b3fe2SEd Czeck 	/* Verify HW */
466727b3fe2SEd Czeck 	if (ark_udm_verify(ark->udm.v))
467727b3fe2SEd Czeck 		return -1;
468727b3fe2SEd Czeck 	if (ark_ddm_verify(ark->ddm.v))
469727b3fe2SEd Czeck 		return -1;
470727b3fe2SEd Czeck 
471727b3fe2SEd Czeck 	/* UDM */
472727b3fe2SEd Czeck 	if (ark_udm_reset(ark->udm.v)) {
473727b3fe2SEd Czeck 		PMD_DRV_LOG(ERR, "Unable to stop and reset UDM\n");
474727b3fe2SEd Czeck 		return -1;
475727b3fe2SEd Czeck 	}
476727b3fe2SEd Czeck 	/* Keep in reset until the MPU are cleared */
477727b3fe2SEd Czeck 
478727b3fe2SEd Czeck 	/* MPU reset */
479727b3fe2SEd Czeck 	mpu = ark->mpurx.v;
480727b3fe2SEd Czeck 	num_q = ark_api_num_queues(mpu);
481727b3fe2SEd Czeck 	ark->rx_queues = num_q;
482727b3fe2SEd Czeck 	for (i = 0; i < num_q; i++) {
483727b3fe2SEd Czeck 		ark_mpu_reset(mpu);
484727b3fe2SEd Czeck 		mpu = RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET);
485727b3fe2SEd Czeck 	}
486727b3fe2SEd Czeck 
487727b3fe2SEd Czeck 	ark_udm_stop(ark->udm.v, 0);
488727b3fe2SEd Czeck 	ark_udm_configure(ark->udm.v,
489727b3fe2SEd Czeck 			  RTE_PKTMBUF_HEADROOM,
490727b3fe2SEd Czeck 			  RTE_MBUF_DEFAULT_DATAROOM,
491727b3fe2SEd Czeck 			  ARK_RX_WRITE_TIME_NS);
492727b3fe2SEd Czeck 	ark_udm_stats_reset(ark->udm.v);
493727b3fe2SEd Czeck 	ark_udm_stop(ark->udm.v, 0);
494727b3fe2SEd Czeck 
495727b3fe2SEd Czeck 	/* TX -- DDM */
496727b3fe2SEd Czeck 	if (ark_ddm_stop(ark->ddm.v, 1))
497727b3fe2SEd Czeck 		PMD_DRV_LOG(ERR, "Unable to stop DDM\n");
498727b3fe2SEd Czeck 
499727b3fe2SEd Czeck 	mpu = ark->mputx.v;
500727b3fe2SEd Czeck 	num_q = ark_api_num_queues(mpu);
501727b3fe2SEd Czeck 	ark->tx_queues = num_q;
502727b3fe2SEd Czeck 	for (i = 0; i < num_q; i++) {
503727b3fe2SEd Czeck 		ark_mpu_reset(mpu);
504727b3fe2SEd Czeck 		mpu = RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET);
505727b3fe2SEd Czeck 	}
506727b3fe2SEd Czeck 
507727b3fe2SEd Czeck 	ark_ddm_reset(ark->ddm.v);
508727b3fe2SEd Czeck 	ark_ddm_stats_reset(ark->ddm.v);
509727b3fe2SEd Czeck 
510727b3fe2SEd Czeck 	ark_ddm_stop(ark->ddm.v, 0);
511727b3fe2SEd Czeck 	ark_rqp_stats_reset(ark->rqpacing);
512727b3fe2SEd Czeck 
513727b3fe2SEd Czeck 	return 0;
5141131cbf0SEd Czeck }
5151131cbf0SEd Czeck 
5161131cbf0SEd Czeck static int
5171131cbf0SEd Czeck eth_ark_dev_uninit(struct rte_eth_dev *dev)
5181131cbf0SEd Czeck {
519727b3fe2SEd Czeck 	struct ark_adapter *ark =
520727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
521727b3fe2SEd Czeck 
5221131cbf0SEd Czeck 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
5231131cbf0SEd Czeck 		return 0;
5241131cbf0SEd Czeck 
525727b3fe2SEd Czeck 	if (ark->user_ext.dev_uninit)
526428046b4SJohn Miller 		ark->user_ext.dev_uninit(dev,
527428046b4SJohn Miller 			 ark->user_data[dev->data->port_id]);
528727b3fe2SEd Czeck 
529727b3fe2SEd Czeck 	ark_pktgen_uninit(ark->pg);
530727b3fe2SEd Czeck 	ark_pktchkr_uninit(ark->pc);
531727b3fe2SEd Czeck 
5321131cbf0SEd Czeck 	dev->dev_ops = NULL;
5331131cbf0SEd Czeck 	dev->rx_pkt_burst = NULL;
5341131cbf0SEd Czeck 	dev->tx_pkt_burst = NULL;
535727b3fe2SEd Czeck 	rte_free(dev->data->mac_addrs);
5361131cbf0SEd Czeck 	return 0;
5371131cbf0SEd Czeck }
5381131cbf0SEd Czeck 
5391131cbf0SEd Czeck static int
540727b3fe2SEd Czeck eth_ark_dev_configure(struct rte_eth_dev *dev)
5411131cbf0SEd Czeck {
5421131cbf0SEd Czeck 	PMD_FUNC_LOG(DEBUG, "\n");
543727b3fe2SEd Czeck 	struct ark_adapter *ark =
544727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
545727b3fe2SEd Czeck 
546727b3fe2SEd Czeck 	eth_ark_dev_set_link_up(dev);
547727b3fe2SEd Czeck 	if (ark->user_ext.dev_configure)
548428046b4SJohn Miller 		return ark->user_ext.dev_configure(dev,
549428046b4SJohn Miller 			   ark->user_data[dev->data->port_id]);
5501131cbf0SEd Czeck 	return 0;
5511131cbf0SEd Czeck }
5521131cbf0SEd Czeck 
553727b3fe2SEd Czeck static void *
554727b3fe2SEd Czeck delay_pg_start(void *arg)
555727b3fe2SEd Czeck {
556727b3fe2SEd Czeck 	struct ark_adapter *ark = (struct ark_adapter *)arg;
557727b3fe2SEd Czeck 
558727b3fe2SEd Czeck 	/* This function is used exclusively for regression testing, We
559727b3fe2SEd Czeck 	 * perform a blind sleep here to ensure that the external test
560727b3fe2SEd Czeck 	 * application has time to setup the test before we generate packets
561727b3fe2SEd Czeck 	 */
562727b3fe2SEd Czeck 	usleep(100000);
563727b3fe2SEd Czeck 	ark_pktgen_run(ark->pg);
564727b3fe2SEd Czeck 	return NULL;
565727b3fe2SEd Czeck }
566727b3fe2SEd Czeck 
567727b3fe2SEd Czeck static int
568727b3fe2SEd Czeck eth_ark_dev_start(struct rte_eth_dev *dev)
569727b3fe2SEd Czeck {
570727b3fe2SEd Czeck 	struct ark_adapter *ark =
571727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
572727b3fe2SEd Czeck 	int i;
573727b3fe2SEd Czeck 
574727b3fe2SEd Czeck 	PMD_FUNC_LOG(DEBUG, "\n");
575727b3fe2SEd Czeck 
576727b3fe2SEd Czeck 	/* RX Side */
577727b3fe2SEd Czeck 	/* start UDM */
578727b3fe2SEd Czeck 	ark_udm_start(ark->udm.v);
579727b3fe2SEd Czeck 
580727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_rx_queues; i++)
581727b3fe2SEd Czeck 		eth_ark_rx_start_queue(dev, i);
582727b3fe2SEd Czeck 
583727b3fe2SEd Czeck 	/* TX Side */
584727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++)
585727b3fe2SEd Czeck 		eth_ark_tx_queue_start(dev, i);
586727b3fe2SEd Czeck 
587727b3fe2SEd Czeck 	/* start DDM */
588727b3fe2SEd Czeck 	ark_ddm_start(ark->ddm.v);
589727b3fe2SEd Czeck 
590727b3fe2SEd Czeck 	ark->started = 1;
591727b3fe2SEd Czeck 	/* set xmit and receive function */
592727b3fe2SEd Czeck 	dev->rx_pkt_burst = &eth_ark_recv_pkts;
593727b3fe2SEd Czeck 	dev->tx_pkt_burst = &eth_ark_xmit_pkts;
594727b3fe2SEd Czeck 
595727b3fe2SEd Czeck 	if (ark->start_pg)
596727b3fe2SEd Czeck 		ark_pktchkr_run(ark->pc);
597727b3fe2SEd Czeck 
598727b3fe2SEd Czeck 	if (ark->start_pg && (dev->data->port_id == 0)) {
599727b3fe2SEd Czeck 		pthread_t thread;
600727b3fe2SEd Czeck 
601727b3fe2SEd Czeck 		/* Delay packet generatpr start allow the hardware to be ready
602727b3fe2SEd Czeck 		 * This is only used for sanity checking with internal generator
603727b3fe2SEd Czeck 		 */
604d1434c04SJohn Miller 		if (pthread_create(&thread, NULL, delay_pg_start, ark)) {
605d1434c04SJohn Miller 			PMD_DRV_LOG(ERR, "Could not create pktgen "
606d1434c04SJohn Miller 				    "starter thread\n");
607d1434c04SJohn Miller 			return -1;
608d1434c04SJohn Miller 		}
609727b3fe2SEd Czeck 	}
610727b3fe2SEd Czeck 
611727b3fe2SEd Czeck 	if (ark->user_ext.dev_start)
612428046b4SJohn Miller 		ark->user_ext.dev_start(dev,
613428046b4SJohn Miller 			ark->user_data[dev->data->port_id]);
614727b3fe2SEd Czeck 
615727b3fe2SEd Czeck 	return 0;
616727b3fe2SEd Czeck }
617727b3fe2SEd Czeck 
618727b3fe2SEd Czeck static void
619727b3fe2SEd Czeck eth_ark_dev_stop(struct rte_eth_dev *dev)
620727b3fe2SEd Czeck {
621727b3fe2SEd Czeck 	uint16_t i;
622727b3fe2SEd Czeck 	int status;
623727b3fe2SEd Czeck 	struct ark_adapter *ark =
624727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
625727b3fe2SEd Czeck 	struct ark_mpu_t *mpu;
626727b3fe2SEd Czeck 
627727b3fe2SEd Czeck 	PMD_FUNC_LOG(DEBUG, "\n");
628727b3fe2SEd Czeck 
629727b3fe2SEd Czeck 	if (ark->started == 0)
630727b3fe2SEd Czeck 		return;
631727b3fe2SEd Czeck 	ark->started = 0;
632727b3fe2SEd Czeck 
633727b3fe2SEd Czeck 	/* Stop the extension first */
634727b3fe2SEd Czeck 	if (ark->user_ext.dev_stop)
635428046b4SJohn Miller 		ark->user_ext.dev_stop(dev,
636428046b4SJohn Miller 		       ark->user_data[dev->data->port_id]);
637727b3fe2SEd Czeck 
638727b3fe2SEd Czeck 	/* Stop the packet generator */
639727b3fe2SEd Czeck 	if (ark->start_pg)
640727b3fe2SEd Czeck 		ark_pktgen_pause(ark->pg);
641727b3fe2SEd Czeck 
642727b3fe2SEd Czeck 	dev->rx_pkt_burst = &eth_ark_recv_pkts_noop;
643727b3fe2SEd Czeck 	dev->tx_pkt_burst = &eth_ark_xmit_pkts_noop;
644727b3fe2SEd Czeck 
645727b3fe2SEd Czeck 	/* STOP TX Side */
646727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
647727b3fe2SEd Czeck 		status = eth_ark_tx_queue_stop(dev, i);
648727b3fe2SEd Czeck 		if (status != 0) {
649f8244c63SZhiyong Yang 			uint16_t port = dev->data->port_id;
650727b3fe2SEd Czeck 			PMD_DRV_LOG(ERR,
651727b3fe2SEd Czeck 				    "tx_queue stop anomaly"
652727b3fe2SEd Czeck 				    " port %u, queue %u\n",
653727b3fe2SEd Czeck 				    port, i);
654727b3fe2SEd Czeck 		}
655727b3fe2SEd Czeck 	}
656727b3fe2SEd Czeck 
657727b3fe2SEd Czeck 	/* Stop DDM */
658727b3fe2SEd Czeck 	/* Wait up to 0.1 second.  each stop is up to 1000 * 10 useconds */
659727b3fe2SEd Czeck 	for (i = 0; i < 10; i++) {
660727b3fe2SEd Czeck 		status = ark_ddm_stop(ark->ddm.v, 1);
661727b3fe2SEd Czeck 		if (status == 0)
662727b3fe2SEd Czeck 			break;
663727b3fe2SEd Czeck 	}
664727b3fe2SEd Czeck 	if (status || i != 0) {
665727b3fe2SEd Czeck 		PMD_DRV_LOG(ERR, "DDM stop anomaly. status:"
666727b3fe2SEd Czeck 			    " %d iter: %u. (%s)\n",
667727b3fe2SEd Czeck 			    status,
668727b3fe2SEd Czeck 			    i,
669727b3fe2SEd Czeck 			    __func__);
670727b3fe2SEd Czeck 		ark_ddm_dump(ark->ddm.v, "Stop anomaly");
671727b3fe2SEd Czeck 
672727b3fe2SEd Czeck 		mpu = ark->mputx.v;
673727b3fe2SEd Czeck 		for (i = 0; i < ark->tx_queues; i++) {
674727b3fe2SEd Czeck 			ark_mpu_dump(mpu, "DDM failure dump", i);
675727b3fe2SEd Czeck 			mpu = RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET);
676727b3fe2SEd Czeck 		}
677727b3fe2SEd Czeck 	}
678727b3fe2SEd Czeck 
679727b3fe2SEd Czeck 	/* STOP RX Side */
680727b3fe2SEd Czeck 	/* Stop UDM  multiple tries attempted */
681727b3fe2SEd Czeck 	for (i = 0; i < 10; i++) {
682727b3fe2SEd Czeck 		status = ark_udm_stop(ark->udm.v, 1);
683727b3fe2SEd Czeck 		if (status == 0)
684727b3fe2SEd Czeck 			break;
685727b3fe2SEd Czeck 	}
686727b3fe2SEd Czeck 	if (status || i != 0) {
687727b3fe2SEd Czeck 		PMD_DRV_LOG(ERR, "UDM stop anomaly. status %d iter: %u. (%s)\n",
688727b3fe2SEd Czeck 			    status, i, __func__);
689727b3fe2SEd Czeck 		ark_udm_dump(ark->udm.v, "Stop anomaly");
690727b3fe2SEd Czeck 
691727b3fe2SEd Czeck 		mpu = ark->mpurx.v;
692727b3fe2SEd Czeck 		for (i = 0; i < ark->rx_queues; i++) {
693727b3fe2SEd Czeck 			ark_mpu_dump(mpu, "UDM Stop anomaly", i);
694727b3fe2SEd Czeck 			mpu = RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET);
695727b3fe2SEd Czeck 		}
696727b3fe2SEd Czeck 	}
697727b3fe2SEd Czeck 
698727b3fe2SEd Czeck 	ark_udm_dump_stats(ark->udm.v, "Post stop");
699727b3fe2SEd Czeck 	ark_udm_dump_perf(ark->udm.v, "Post stop");
700727b3fe2SEd Czeck 
70122862a02SJohn Miller 	for (i = 0; i < dev->data->nb_rx_queues; i++)
702727b3fe2SEd Czeck 		eth_ark_rx_dump_queue(dev, i, __func__);
703727b3fe2SEd Czeck 
704727b3fe2SEd Czeck 	/* Stop the packet checker if it is running */
705727b3fe2SEd Czeck 	if (ark->start_pg) {
706727b3fe2SEd Czeck 		ark_pktchkr_dump_stats(ark->pc);
707727b3fe2SEd Czeck 		ark_pktchkr_stop(ark->pc);
708727b3fe2SEd Czeck 	}
709727b3fe2SEd Czeck }
710727b3fe2SEd Czeck 
711727b3fe2SEd Czeck static void
712727b3fe2SEd Czeck eth_ark_dev_close(struct rte_eth_dev *dev)
713727b3fe2SEd Czeck {
714727b3fe2SEd Czeck 	struct ark_adapter *ark =
715727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
716727b3fe2SEd Czeck 	uint16_t i;
717727b3fe2SEd Czeck 
718727b3fe2SEd Czeck 	if (ark->user_ext.dev_close)
719428046b4SJohn Miller 		ark->user_ext.dev_close(dev,
720428046b4SJohn Miller 		 ark->user_data[dev->data->port_id]);
721727b3fe2SEd Czeck 
722727b3fe2SEd Czeck 	eth_ark_dev_stop(dev);
723727b3fe2SEd Czeck 	eth_ark_udm_force_close(dev);
724727b3fe2SEd Czeck 
725727b3fe2SEd Czeck 	/*
726727b3fe2SEd Czeck 	 * TODO This should only be called once for the device during shutdown
727727b3fe2SEd Czeck 	 */
728727b3fe2SEd Czeck 	ark_rqp_dump(ark->rqpacing);
729727b3fe2SEd Czeck 
730727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
731727b3fe2SEd Czeck 		eth_ark_tx_queue_release(dev->data->tx_queues[i]);
732727b3fe2SEd Czeck 		dev->data->tx_queues[i] = 0;
733727b3fe2SEd Czeck 	}
734727b3fe2SEd Czeck 
735727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
736727b3fe2SEd Czeck 		eth_ark_dev_rx_queue_release(dev->data->rx_queues[i]);
737727b3fe2SEd Czeck 		dev->data->rx_queues[i] = 0;
738727b3fe2SEd Czeck 	}
739727b3fe2SEd Czeck }
740727b3fe2SEd Czeck 
7411131cbf0SEd Czeck static void
7421131cbf0SEd Czeck eth_ark_dev_info_get(struct rte_eth_dev *dev,
7431131cbf0SEd Czeck 		     struct rte_eth_dev_info *dev_info)
7441131cbf0SEd Czeck {
745727b3fe2SEd Czeck 	struct ark_adapter *ark =
746727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
747727b3fe2SEd Czeck 	struct ark_mpu_t *tx_mpu = RTE_PTR_ADD(ark->bar0, ARK_MPU_TX_BASE);
748727b3fe2SEd Czeck 	struct ark_mpu_t *rx_mpu = RTE_PTR_ADD(ark->bar0, ARK_MPU_RX_BASE);
749727b3fe2SEd Czeck 	uint16_t ports = ark->num_ports;
750727b3fe2SEd Czeck 
7511131cbf0SEd Czeck 	dev_info->max_rx_pktlen = ARK_RX_MAX_PKT_LEN;
7521131cbf0SEd Czeck 	dev_info->min_rx_bufsize = ARK_RX_MIN_BUFSIZE;
7531131cbf0SEd Czeck 
754727b3fe2SEd Czeck 	dev_info->max_rx_queues = ark_api_num_queues_per_port(rx_mpu, ports);
755727b3fe2SEd Czeck 	dev_info->max_tx_queues = ark_api_num_queues_per_port(tx_mpu, ports);
756727b3fe2SEd Czeck 
7571131cbf0SEd Czeck 	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
7581131cbf0SEd Czeck 		.nb_max = ARK_RX_MAX_QUEUE,
7591131cbf0SEd Czeck 		.nb_min = ARK_RX_MIN_QUEUE,
7601131cbf0SEd Czeck 		.nb_align = ARK_RX_MIN_QUEUE}; /* power of 2 */
7611131cbf0SEd Czeck 
7621131cbf0SEd Czeck 	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
7631131cbf0SEd Czeck 		.nb_max = ARK_TX_MAX_QUEUE,
7641131cbf0SEd Czeck 		.nb_min = ARK_TX_MIN_QUEUE,
7651131cbf0SEd Czeck 		.nb_align = ARK_TX_MIN_QUEUE}; /* power of 2 */
7661131cbf0SEd Czeck 
7671131cbf0SEd Czeck 	/* ARK PMD supports all line rates, how do we indicate that here ?? */
7681131cbf0SEd Czeck 	dev_info->speed_capa = (ETH_LINK_SPEED_1G |
7691131cbf0SEd Czeck 				ETH_LINK_SPEED_10G |
7701131cbf0SEd Czeck 				ETH_LINK_SPEED_25G |
7711131cbf0SEd Czeck 				ETH_LINK_SPEED_40G |
7721131cbf0SEd Czeck 				ETH_LINK_SPEED_50G |
7731131cbf0SEd Czeck 				ETH_LINK_SPEED_100G);
774c0802544SFerruh Yigit 	dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
7751131cbf0SEd Czeck }
7761131cbf0SEd Czeck 
777727b3fe2SEd Czeck static int
778727b3fe2SEd Czeck eth_ark_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
779727b3fe2SEd Czeck {
780727b3fe2SEd Czeck 	PMD_DEBUG_LOG(DEBUG, "link status = %d\n",
781727b3fe2SEd Czeck 			dev->data->dev_link.link_status);
782727b3fe2SEd Czeck 	struct ark_adapter *ark =
783727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
784727b3fe2SEd Czeck 
785727b3fe2SEd Czeck 	if (ark->user_ext.link_update) {
786727b3fe2SEd Czeck 		return ark->user_ext.link_update
787727b3fe2SEd Czeck 			(dev, wait_to_complete,
788428046b4SJohn Miller 			 ark->user_data[dev->data->port_id]);
789727b3fe2SEd Czeck 	}
790727b3fe2SEd Czeck 	return 0;
791727b3fe2SEd Czeck }
792727b3fe2SEd Czeck 
793727b3fe2SEd Czeck static int
794727b3fe2SEd Czeck eth_ark_dev_set_link_up(struct rte_eth_dev *dev)
795727b3fe2SEd Czeck {
796727b3fe2SEd Czeck 	dev->data->dev_link.link_status = 1;
797727b3fe2SEd Czeck 	struct ark_adapter *ark =
798727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
799727b3fe2SEd Czeck 
800727b3fe2SEd Czeck 	if (ark->user_ext.dev_set_link_up)
801428046b4SJohn Miller 		return ark->user_ext.dev_set_link_up(dev,
802428046b4SJohn Miller 			     ark->user_data[dev->data->port_id]);
803727b3fe2SEd Czeck 	return 0;
804727b3fe2SEd Czeck }
805727b3fe2SEd Czeck 
806727b3fe2SEd Czeck static int
807727b3fe2SEd Czeck eth_ark_dev_set_link_down(struct rte_eth_dev *dev)
808727b3fe2SEd Czeck {
809727b3fe2SEd Czeck 	dev->data->dev_link.link_status = 0;
810727b3fe2SEd Czeck 	struct ark_adapter *ark =
811727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
812727b3fe2SEd Czeck 
813727b3fe2SEd Czeck 	if (ark->user_ext.dev_set_link_down)
814428046b4SJohn Miller 		return ark->user_ext.dev_set_link_down(dev,
815428046b4SJohn Miller 		       ark->user_data[dev->data->port_id]);
816727b3fe2SEd Czeck 	return 0;
817727b3fe2SEd Czeck }
818727b3fe2SEd Czeck 
819*d5b0924bSMatan Azrad static int
820727b3fe2SEd Czeck eth_ark_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
821727b3fe2SEd Czeck {
822727b3fe2SEd Czeck 	uint16_t i;
823727b3fe2SEd Czeck 	struct ark_adapter *ark =
824727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
825727b3fe2SEd Czeck 
826727b3fe2SEd Czeck 	stats->ipackets = 0;
827727b3fe2SEd Czeck 	stats->ibytes = 0;
828727b3fe2SEd Czeck 	stats->opackets = 0;
829727b3fe2SEd Czeck 	stats->obytes = 0;
830727b3fe2SEd Czeck 	stats->imissed = 0;
831727b3fe2SEd Czeck 	stats->oerrors = 0;
832727b3fe2SEd Czeck 
833727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++)
834727b3fe2SEd Czeck 		eth_tx_queue_stats_get(dev->data->tx_queues[i], stats);
835727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_rx_queues; i++)
836727b3fe2SEd Czeck 		eth_rx_queue_stats_get(dev->data->rx_queues[i], stats);
837727b3fe2SEd Czeck 	if (ark->user_ext.stats_get)
838*d5b0924bSMatan Azrad 		return ark->user_ext.stats_get(dev, stats,
839428046b4SJohn Miller 			ark->user_data[dev->data->port_id]);
840*d5b0924bSMatan Azrad 	return 0;
841727b3fe2SEd Czeck }
842727b3fe2SEd Czeck 
843727b3fe2SEd Czeck static void
844727b3fe2SEd Czeck eth_ark_dev_stats_reset(struct rte_eth_dev *dev)
845727b3fe2SEd Czeck {
846727b3fe2SEd Czeck 	uint16_t i;
847727b3fe2SEd Czeck 	struct ark_adapter *ark =
848727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
849727b3fe2SEd Czeck 
850727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_tx_queues; i++)
851f588d3a5SJohn Miller 		eth_tx_queue_stats_reset(dev->data->tx_queues[i]);
852727b3fe2SEd Czeck 	for (i = 0; i < dev->data->nb_rx_queues; i++)
853727b3fe2SEd Czeck 		eth_rx_queue_stats_reset(dev->data->rx_queues[i]);
854727b3fe2SEd Czeck 	if (ark->user_ext.stats_reset)
855428046b4SJohn Miller 		ark->user_ext.stats_reset(dev,
856428046b4SJohn Miller 			  ark->user_data[dev->data->port_id]);
857727b3fe2SEd Czeck }
858727b3fe2SEd Czeck 
8596d01e580SWei Dai static int
860727b3fe2SEd Czeck eth_ark_macaddr_add(struct rte_eth_dev *dev,
861727b3fe2SEd Czeck 		    struct ether_addr *mac_addr,
862727b3fe2SEd Czeck 		    uint32_t index,
863727b3fe2SEd Czeck 		    uint32_t pool)
864727b3fe2SEd Czeck {
865727b3fe2SEd Czeck 	struct ark_adapter *ark =
866727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
867727b3fe2SEd Czeck 
8686d01e580SWei Dai 	if (ark->user_ext.mac_addr_add) {
869727b3fe2SEd Czeck 		ark->user_ext.mac_addr_add(dev,
870727b3fe2SEd Czeck 					   mac_addr,
871727b3fe2SEd Czeck 					   index,
872727b3fe2SEd Czeck 					   pool,
873428046b4SJohn Miller 			   ark->user_data[dev->data->port_id]);
8746d01e580SWei Dai 		return 0;
8756d01e580SWei Dai 	}
8766d01e580SWei Dai 	return -ENOTSUP;
877727b3fe2SEd Czeck }
878727b3fe2SEd Czeck 
879727b3fe2SEd Czeck static void
880727b3fe2SEd Czeck eth_ark_macaddr_remove(struct rte_eth_dev *dev, uint32_t index)
881727b3fe2SEd Czeck {
882727b3fe2SEd Czeck 	struct ark_adapter *ark =
883727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
884727b3fe2SEd Czeck 
885727b3fe2SEd Czeck 	if (ark->user_ext.mac_addr_remove)
886428046b4SJohn Miller 		ark->user_ext.mac_addr_remove(dev, index,
887428046b4SJohn Miller 			      ark->user_data[dev->data->port_id]);
888727b3fe2SEd Czeck }
889727b3fe2SEd Czeck 
890727b3fe2SEd Czeck static void
891727b3fe2SEd Czeck eth_ark_set_default_mac_addr(struct rte_eth_dev *dev,
892727b3fe2SEd Czeck 			     struct ether_addr *mac_addr)
893727b3fe2SEd Czeck {
894727b3fe2SEd Czeck 	struct ark_adapter *ark =
895727b3fe2SEd Czeck 		(struct ark_adapter *)dev->data->dev_private;
896727b3fe2SEd Czeck 
897727b3fe2SEd Czeck 	if (ark->user_ext.mac_addr_set)
898428046b4SJohn Miller 		ark->user_ext.mac_addr_set(dev, mac_addr,
899428046b4SJohn Miller 			   ark->user_data[dev->data->port_id]);
900727b3fe2SEd Czeck }
901727b3fe2SEd Czeck 
9029ae74488SJohn Miller static int
9039ae74488SJohn Miller eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t  size)
9049ae74488SJohn Miller {
9059ae74488SJohn Miller 	struct ark_adapter *ark =
9069ae74488SJohn Miller 		(struct ark_adapter *)dev->data->dev_private;
9079ae74488SJohn Miller 
9089ae74488SJohn Miller 	if (ark->user_ext.set_mtu)
9099ae74488SJohn Miller 		return ark->user_ext.set_mtu(dev, size,
9109ae74488SJohn Miller 			     ark->user_data[dev->data->port_id]);
9119ae74488SJohn Miller 
9129ae74488SJohn Miller 	return -ENOTSUP;
9139ae74488SJohn Miller }
9149ae74488SJohn Miller 
9151131cbf0SEd Czeck static inline int
9161131cbf0SEd Czeck process_pktdir_arg(const char *key, const char *value,
9171131cbf0SEd Czeck 		   void *extra_args)
9181131cbf0SEd Czeck {
9191131cbf0SEd Czeck 	PMD_FUNC_LOG(DEBUG, "key = %s, value = %s\n",
9201131cbf0SEd Czeck 		    key, value);
9211131cbf0SEd Czeck 	struct ark_adapter *ark =
9221131cbf0SEd Czeck 		(struct ark_adapter *)extra_args;
9231131cbf0SEd Czeck 
9241131cbf0SEd Czeck 	ark->pkt_dir_v = strtol(value, NULL, 16);
9251131cbf0SEd Czeck 	PMD_FUNC_LOG(DEBUG, "pkt_dir_v = 0x%x\n", ark->pkt_dir_v);
9261131cbf0SEd Czeck 	return 0;
9271131cbf0SEd Czeck }
9281131cbf0SEd Czeck 
9291131cbf0SEd Czeck static inline int
9301131cbf0SEd Czeck process_file_args(const char *key, const char *value, void *extra_args)
9311131cbf0SEd Czeck {
9321131cbf0SEd Czeck 	PMD_FUNC_LOG(DEBUG, "key = %s, value = %s\n",
9331131cbf0SEd Czeck 		    key, value);
9341131cbf0SEd Czeck 	char *args = (char *)extra_args;
9351131cbf0SEd Czeck 
9361131cbf0SEd Czeck 	/* Open the configuration file */
9371131cbf0SEd Czeck 	FILE *file = fopen(value, "r");
9381131cbf0SEd Czeck 	char line[ARK_MAX_ARG_LEN];
9391131cbf0SEd Czeck 	int  size = 0;
9401131cbf0SEd Czeck 	int first = 1;
9411131cbf0SEd Czeck 
9422f3b88fbSJohn Miller 	if (file == NULL) {
9432f3b88fbSJohn Miller 		PMD_DRV_LOG(ERR, "Unable to open "
9442f3b88fbSJohn Miller 			    "config file %s\n", value);
9452f3b88fbSJohn Miller 		return -1;
9462f3b88fbSJohn Miller 	}
9472f3b88fbSJohn Miller 
9481131cbf0SEd Czeck 	while (fgets(line, sizeof(line), file)) {
9491131cbf0SEd Czeck 		size += strlen(line);
9501131cbf0SEd Czeck 		if (size >= ARK_MAX_ARG_LEN) {
9511131cbf0SEd Czeck 			PMD_DRV_LOG(ERR, "Unable to parse file %s args, "
9521131cbf0SEd Czeck 				    "parameter list is too long\n", value);
9531131cbf0SEd Czeck 			fclose(file);
9541131cbf0SEd Czeck 			return -1;
9551131cbf0SEd Czeck 		}
9561131cbf0SEd Czeck 		if (first) {
9571131cbf0SEd Czeck 			strncpy(args, line, ARK_MAX_ARG_LEN);
9581131cbf0SEd Czeck 			first = 0;
9591131cbf0SEd Czeck 		} else {
9601131cbf0SEd Czeck 			strncat(args, line, ARK_MAX_ARG_LEN);
9611131cbf0SEd Czeck 		}
9621131cbf0SEd Czeck 	}
9631131cbf0SEd Czeck 	PMD_FUNC_LOG(DEBUG, "file = %s\n", args);
9641131cbf0SEd Czeck 	fclose(file);
9651131cbf0SEd Czeck 	return 0;
9661131cbf0SEd Czeck }
9671131cbf0SEd Czeck 
9681131cbf0SEd Czeck static int
9691131cbf0SEd Czeck eth_ark_check_args(struct ark_adapter *ark, const char *params)
9701131cbf0SEd Czeck {
9711131cbf0SEd Czeck 	struct rte_kvargs *kvlist;
9721131cbf0SEd Czeck 	unsigned int k_idx;
9731131cbf0SEd Czeck 	struct rte_kvargs_pair *pair = NULL;
9740f31eb0cSFerruh Yigit 	int ret = -1;
9751131cbf0SEd Czeck 
9761131cbf0SEd Czeck 	kvlist = rte_kvargs_parse(params, valid_arguments);
9771131cbf0SEd Czeck 	if (kvlist == NULL)
9781131cbf0SEd Czeck 		return 0;
9791131cbf0SEd Czeck 
9801131cbf0SEd Czeck 	ark->pkt_gen_args[0] = 0;
9811131cbf0SEd Czeck 	ark->pkt_chkr_args[0] = 0;
9821131cbf0SEd Czeck 
9831131cbf0SEd Czeck 	for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
9841131cbf0SEd Czeck 		pair = &kvlist->pairs[k_idx];
9851131cbf0SEd Czeck 		PMD_FUNC_LOG(DEBUG, "**** Arg passed to PMD = %s:%s\n",
9861131cbf0SEd Czeck 			     pair->key,
9871131cbf0SEd Czeck 			     pair->value);
9881131cbf0SEd Czeck 	}
9891131cbf0SEd Czeck 
9901131cbf0SEd Czeck 	if (rte_kvargs_process(kvlist,
9911131cbf0SEd Czeck 			       ARK_PKTDIR_ARG,
9921131cbf0SEd Czeck 			       &process_pktdir_arg,
9931131cbf0SEd Czeck 			       ark) != 0) {
9941131cbf0SEd Czeck 		PMD_DRV_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTDIR_ARG);
9950f31eb0cSFerruh Yigit 		goto free_kvlist;
9961131cbf0SEd Czeck 	}
9971131cbf0SEd Czeck 
9981131cbf0SEd Czeck 	if (rte_kvargs_process(kvlist,
9991131cbf0SEd Czeck 			       ARK_PKTGEN_ARG,
10001131cbf0SEd Czeck 			       &process_file_args,
10011131cbf0SEd Czeck 			       ark->pkt_gen_args) != 0) {
10021131cbf0SEd Czeck 		PMD_DRV_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTGEN_ARG);
10030f31eb0cSFerruh Yigit 		goto free_kvlist;
10041131cbf0SEd Czeck 	}
10051131cbf0SEd Czeck 
10061131cbf0SEd Czeck 	if (rte_kvargs_process(kvlist,
10071131cbf0SEd Czeck 			       ARK_PKTCHKR_ARG,
10081131cbf0SEd Czeck 			       &process_file_args,
10091131cbf0SEd Czeck 			       ark->pkt_chkr_args) != 0) {
10101131cbf0SEd Czeck 		PMD_DRV_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTCHKR_ARG);
10110f31eb0cSFerruh Yigit 		goto free_kvlist;
10121131cbf0SEd Czeck 	}
10131131cbf0SEd Czeck 
10141131cbf0SEd Czeck 	PMD_DRV_LOG(INFO, "packet director set to 0x%x\n", ark->pkt_dir_v);
1015727b3fe2SEd Czeck 	/* Setup the packet director */
1016727b3fe2SEd Czeck 	ark_pktdir_setup(ark->pd, ark->pkt_dir_v);
1017727b3fe2SEd Czeck 
1018727b3fe2SEd Czeck 	/* Setup the packet generator */
1019727b3fe2SEd Czeck 	if (ark->pkt_gen_args[0]) {
1020727b3fe2SEd Czeck 		PMD_DRV_LOG(INFO, "Setting up the packet generator\n");
1021727b3fe2SEd Czeck 		ark_pktgen_parse(ark->pkt_gen_args);
1022727b3fe2SEd Czeck 		ark_pktgen_reset(ark->pg);
1023727b3fe2SEd Czeck 		ark_pktgen_setup(ark->pg);
1024727b3fe2SEd Czeck 		ark->start_pg = 1;
1025727b3fe2SEd Czeck 	}
1026727b3fe2SEd Czeck 
1027727b3fe2SEd Czeck 	/* Setup the packet checker */
1028727b3fe2SEd Czeck 	if (ark->pkt_chkr_args[0]) {
1029727b3fe2SEd Czeck 		ark_pktchkr_parse(ark->pkt_chkr_args);
1030727b3fe2SEd Czeck 		ark_pktchkr_setup(ark->pc);
1031727b3fe2SEd Czeck 	}
10321131cbf0SEd Czeck 
10330f31eb0cSFerruh Yigit 	ret = 0;
10340f31eb0cSFerruh Yigit 
10350f31eb0cSFerruh Yigit free_kvlist:
10360f31eb0cSFerruh Yigit 	rte_kvargs_free(kvlist);
10370f31eb0cSFerruh Yigit 
10380f31eb0cSFerruh Yigit 	return ret;
10391131cbf0SEd Czeck }
10401131cbf0SEd Czeck 
10411131cbf0SEd Czeck RTE_PMD_REGISTER_PCI(net_ark, rte_ark_pmd);
10421131cbf0SEd Czeck RTE_PMD_REGISTER_KMOD_DEP(net_ark, "* igb_uio | uio_pci_generic ");
10431131cbf0SEd Czeck RTE_PMD_REGISTER_PCI_TABLE(net_ark, pci_id_ark_map);
10441131cbf0SEd Czeck RTE_PMD_REGISTER_PARAM_STRING(net_ark,
10451131cbf0SEd Czeck 			      ARK_PKTGEN_ARG "=<filename> "
10461131cbf0SEd Czeck 			      ARK_PKTCHKR_ARG "=<filename> "
10471131cbf0SEd Czeck 			      ARK_PKTDIR_ARG "=<bitmap>");
1048