1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) 2015-2018 Atomic Rules LLC 3 */ 4 5 #ifndef _ARK_GLOBAL_H_ 6 #define _ARK_GLOBAL_H_ 7 8 #include <time.h> 9 #include <assert.h> 10 11 #include <rte_mbuf.h> 12 #include <rte_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> 18 #include <rte_dev.h> 19 #include <rte_version.h> 20 21 #include "ark_pktdir.h" 22 #include "ark_pktgen.h" 23 #include "ark_pktchkr.h" 24 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 39 40 #define offset8(n) n 41 #define offset16(n) ((n) / 2) 42 #define offset32(n) ((n) / 4) 43 #define offset64(n) ((n) / 8) 44 45 /* Maximum length of arg list in bytes */ 46 #define ARK_MAX_ARG_LEN 256 47 48 /* 49 * Structure to store private data for each PF/VF instance. 50 */ 51 #define def_ptr(type, name) \ 52 union type { \ 53 uint64_t *t64; \ 54 uint32_t *t32; \ 55 uint16_t *t16; \ 56 uint8_t *t8; \ 57 void *v; \ 58 } name 59 60 struct ark_user_ext { 61 void *(*dev_init)(struct rte_eth_dev *, void *abar, int port_id); 62 void (*dev_uninit)(struct rte_eth_dev *, void *); 63 int (*dev_get_port_count)(struct rte_eth_dev *, void *); 64 int (*dev_configure)(struct rte_eth_dev *, void *); 65 int (*dev_start)(struct rte_eth_dev *, void *); 66 void (*dev_stop)(struct rte_eth_dev *, void *); 67 void (*dev_close)(struct rte_eth_dev *, void *); 68 int (*link_update)(struct rte_eth_dev *, int wait_to_complete, void *); 69 int (*dev_set_link_up)(struct rte_eth_dev *, void *); 70 int (*dev_set_link_down)(struct rte_eth_dev *, void *); 71 int (*stats_get)(struct rte_eth_dev *, struct rte_eth_stats *, void *); 72 void (*stats_reset)(struct rte_eth_dev *, void *); 73 void (*mac_addr_add)(struct rte_eth_dev *, 74 struct rte_ether_addr *, 75 uint32_t, 76 uint32_t, 77 void *); 78 void (*mac_addr_remove)(struct rte_eth_dev *, uint32_t, void *); 79 void (*mac_addr_set)(struct rte_eth_dev *, struct rte_ether_addr *, 80 void *); 81 int (*set_mtu)(struct rte_eth_dev *, uint16_t, void *); 82 }; 83 84 struct ark_adapter { 85 /* User extension private data */ 86 void *user_data[ARK_MAX_PORTS]; 87 88 /* Pointers to packet generator and checker */ 89 int start_pg; 90 ark_pkt_gen_t pg; 91 ark_pkt_chkr_t pc; 92 ark_pkt_dir_t pd; 93 94 int num_ports; 95 96 /* Packet generator/checker args */ 97 char pkt_gen_args[ARK_MAX_ARG_LEN]; 98 char pkt_chkr_args[ARK_MAX_ARG_LEN]; 99 uint32_t pkt_dir_v; 100 101 /* eth device */ 102 struct rte_eth_dev *eth_dev; 103 104 void *d_handle; 105 struct ark_user_ext user_ext; 106 107 /* Our Bar 0 */ 108 uint8_t *bar0; 109 110 /* Application Bar */ 111 uint8_t *a_bar; 112 113 /* Arkville demo block offsets */ 114 def_ptr(sys_ctrl, sysctrl); 115 def_ptr(pkt_gen, pktgen); 116 def_ptr(mpu_rx, mpurx); 117 def_ptr(UDM, udm); 118 def_ptr(mpu_tx, mputx); 119 def_ptr(DDM, ddm); 120 def_ptr(CMAC, cmac); 121 def_ptr(external, external); 122 def_ptr(pkt_dir, pktdir); 123 def_ptr(pkt_chkr, pktchkr); 124 125 int started; 126 uint16_t rx_queues; 127 uint16_t tx_queues; 128 129 struct ark_rqpace_t *rqpacing; 130 }; 131 132 typedef uint32_t *ark_t; 133 134 #endif 135