1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2015-2018 Atomic Rules LLC
12 #include <ethdev_driver.h>
13 #include <rte_malloc.h>
14 #include <rte_memcpy.h>
15 #include <rte_string_fns.h>
16 #include <rte_cycles.h>
17 #include <rte_kvargs.h>
19 #include <rte_version.h>
21 #include "ark_pktdir.h"
22 #include "ark_pktgen.h"
23 #include "ark_pktchkr.h"
25 #define ETH_ARK_ARG_MAXLEN 64
26 #define ARK_SYSCTRL_BASE 0x0
27 #define ARK_PKTGEN_BASE 0x10000
28 #define ARK_MPU_RX_BASE 0x20000
29 #define ARK_UDM_BASE 0x30000
30 #define ARK_MPU_TX_BASE 0x40000
31 #define ARK_DDM_BASE 0x60000
32 #define ARK_CMAC_BASE 0x80000
33 #define ARK_PKTDIR_BASE 0xa0000
34 #define ARK_PKTCHKR_BASE 0x90000
35 #define ARK_RCPACING_BASE 0xb0000
36 #define ARK_EXTERNAL_BASE 0x100000
37 #define ARK_MPU_QOFFSET 0x00100
38 #define ARK_MAX_PORTS RTE_MAX_ETHPORTS
41 #define offset16(n) ((n) / 2)
42 #define offset32(n) ((n) / 4)
43 #define offset64(n) ((n) / 8)
45 /* Maximum length of arg list in bytes */
46 #define ARK_MAX_ARG_LEN 256
49 * Structure to store private data for each PF/VF instance.
51 #define def_ptr(type, name) \
61 /* Extension hooks for extraction and placement of user meta data
62 * during RX an TX operations. These functions are the bridge
63 * between the mbuf struct and the tuser fields on the AXIS
64 * interfaces in the FPGA
66 /* RX hook populates mbuf fields from user defined *meta up to 20 bytes */
67 typedef void (*rx_user_meta_hook_fn)(struct rte_mbuf *mbuf,
70 /* TX hook poplulate *meta, with up to 20 bytes. meta_cnt
71 * returns the number of uint32_t words populated, 0 to 5
73 typedef void (*tx_user_meta_hook_fn)(const struct rte_mbuf *mbuf,
74 uint32_t *meta, uint8_t *meta_cnt,
78 void *(*dev_init)(struct rte_eth_dev *, void *abar, int port_id);
79 void (*dev_uninit)(struct rte_eth_dev *, void *);
80 int (*dev_get_port_count)(struct rte_eth_dev *, void *);
81 int (*dev_configure)(struct rte_eth_dev *, void *);
82 int (*dev_start)(struct rte_eth_dev *, void *);
83 void (*dev_stop)(struct rte_eth_dev *, void *);
84 void (*dev_close)(struct rte_eth_dev *, void *);
85 int (*link_update)(struct rte_eth_dev *, int wait_to_complete, void *);
86 int (*dev_set_link_up)(struct rte_eth_dev *, void *);
87 int (*dev_set_link_down)(struct rte_eth_dev *, void *);
88 int (*stats_get)(struct rte_eth_dev *, struct rte_eth_stats *, void *);
89 void (*stats_reset)(struct rte_eth_dev *, void *);
90 void (*mac_addr_add)(struct rte_eth_dev *,
91 struct rte_ether_addr *,
95 void (*mac_addr_remove)(struct rte_eth_dev *, uint32_t, void *);
96 void (*mac_addr_set)(struct rte_eth_dev *, struct rte_ether_addr *,
98 int (*set_mtu)(struct rte_eth_dev *, uint16_t, void *);
99 /* user meta, hook functions */
100 rx_user_meta_hook_fn rx_user_meta_hook;
101 tx_user_meta_hook_fn tx_user_meta_hook;
105 /* User extension private data */
106 void *user_data[ARK_MAX_PORTS];
108 /* Pointers to packet generator and checker */
116 /* Packet generator/checker args */
117 char pkt_gen_args[ARK_MAX_ARG_LEN];
118 char pkt_chkr_args[ARK_MAX_ARG_LEN];
122 struct rte_eth_dev *eth_dev;
125 struct ark_user_ext user_ext;
130 /* Application Bar */
133 /* Arkville demo block offsets */
134 def_ptr(sys_ctrl, sysctrl);
135 def_ptr(pkt_gen, pktgen);
136 def_ptr(mpu_rx, mpurx);
138 def_ptr(mpu_tx, mputx);
141 def_ptr(external, external);
142 def_ptr(pkt_dir, pktdir);
143 def_ptr(pkt_chkr, pktchkr);
149 struct ark_rqpace_t *rqpacing;
152 typedef uint32_t *ark_t;