928ff0a8fbdac46d709e8a0dd10b372e435be404
[dpdk.git] / drivers / net / ark / ark_global.h
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright (c) 2015-2017 Atomic Rules LLC
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _ARK_GLOBAL_H_
35 #define _ARK_GLOBAL_H_
36
37 #include <time.h>
38 #include <assert.h>
39
40 #include <rte_mbuf.h>
41 #include <rte_ethdev.h>
42 #include <rte_malloc.h>
43 #include <rte_memcpy.h>
44 #include <rte_string_fns.h>
45 #include <rte_cycles.h>
46 #include <rte_kvargs.h>
47 #include <rte_dev.h>
48 #include <rte_version.h>
49
50 #include "ark_pktdir.h"
51 #include "ark_pktgen.h"
52 #include "ark_pktchkr.h"
53
54 #define ETH_ARK_ARG_MAXLEN      64
55 #define ARK_SYSCTRL_BASE  0x0
56 #define ARK_PKTGEN_BASE   0x10000
57 #define ARK_MPU_RX_BASE   0x20000
58 #define ARK_UDM_BASE      0x30000
59 #define ARK_MPU_TX_BASE   0x40000
60 #define ARK_DDM_BASE      0x60000
61 #define ARK_CMAC_BASE     0x80000
62 #define ARK_PKTDIR_BASE   0xa0000
63 #define ARK_PKTCHKR_BASE  0x90000
64 #define ARK_RCPACING_BASE 0xb0000
65 #define ARK_EXTERNAL_BASE 0x100000
66 #define ARK_MPU_QOFFSET   0x00100
67 #define ARK_MAX_PORTS     8
68
69 #define offset8(n)     n
70 #define offset16(n)   ((n) / 2)
71 #define offset32(n)   ((n) / 4)
72 #define offset64(n)   ((n) / 8)
73
74 /* Maximum length of arg list in bytes */
75 #define ARK_MAX_ARG_LEN 256
76
77 /*
78  * Structure to store private data for each PF/VF instance.
79  */
80 #define def_ptr(type, name) \
81         union type {               \
82                 uint64_t *t64;     \
83                 uint32_t *t32;     \
84                 uint16_t *t16;     \
85                 uint8_t  *t8;      \
86                 void     *v;       \
87         } name
88
89 struct ark_adapter {
90         /* User extension private data */
91         void *user_data;
92
93         /* Pointers to packet generator and checker */
94         int start_pg;
95         ark_pkt_gen_t pg;
96         ark_pkt_chkr_t pc;
97         ark_pkt_dir_t pd;
98
99         int num_ports;
100
101         /* Packet generator/checker args */
102         char pkt_gen_args[ARK_MAX_ARG_LEN];
103         char pkt_chkr_args[ARK_MAX_ARG_LEN];
104         uint32_t pkt_dir_v;
105
106         /* eth device */
107         struct rte_eth_dev *eth_dev;
108
109         void *d_handle;
110
111         /* Our Bar 0 */
112         uint8_t *bar0;
113
114         /* Application Bar */
115         uint8_t *a_bar;
116
117         /* Arkville demo block offsets */
118         def_ptr(sys_ctrl, sysctrl);
119         def_ptr(pkt_gen, pktgen);
120         def_ptr(mpu_rx, mpurx);
121         def_ptr(UDM, udm);
122         def_ptr(mpu_tx, mputx);
123         def_ptr(DDM, ddm);
124         def_ptr(CMAC, cmac);
125         def_ptr(external, external);
126         def_ptr(pkt_dir, pktdir);
127         def_ptr(pkt_chkr, pktchkr);
128
129         int started;
130         uint16_t rx_queues;
131         uint16_t tx_queues;
132
133         struct ark_rqpace_t *rqpacing;
134 };
135
136 typedef uint32_t *ark_t;
137
138 #endif