net/octeontx: cleanup redundant mbox structs
[dpdk.git] / drivers / net / octeontx / base / octeontx_pkivf.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Cavium, Inc
3  */
4
5 #ifndef __OCTEONTX_PKI_H__
6 #define __OCTEONTX_PKI_H__
7
8 #include <stdint.h>
9
10 #include <octeontx_mbox.h>
11
12 #define OCTEONTX_PKI_COPROC                     5
13
14 /* PKI messages */
15
16 #define MBOX_PKI_PORT_OPEN                      1
17 #define MBOX_PKI_PORT_START                     2
18 #define MBOX_PKI_PORT_STOP                      3
19 #define MBOX_PKI_PORT_CLOSE                     4
20 #define MBOX_PKI_PORT_CONFIG                    5
21 #define MBOX_PKI_PORT_OPT_PARSER_CONFIG         6
22 #define MBOX_PKI_PORT_CUSTOM_PARSER_CONFIG      7
23 #define MBOX_PKI_PORT_PKTBUF_CONFIG             8
24 #define MBOX_PKI_PORT_HASH_CONFIG               9
25 #define MBOX_PKI_PORT_ERRCHK_CONFIG             10
26 #define MBOX_PKI_PORT_CREATE_QOS                11
27 #define MBOX_PKI_PORT_MODIFY_QOS                12
28 #define MBOX_PKI_PORT_DELETE_QOS                13
29 #define MBOX_PKI_PORT_PKTDROP_CONFIG            14
30 #define MBOX_PKI_PORT_WQE_GEN_CONFIG            15
31 #define MBOX_PKI_BACKPRESSURE_CONFIG            16
32 #define MBOX_PKI_PORT_GET_STATS                 17
33 #define MBOX_PKI_PORT_RESET_STATS               18
34 #define MBOX_PKI_GET_PORT_CONFIG                19
35 #define MBOX_PKI_GET_PORT_QOS_CONFIG            20
36 #define MBOX_PKI_PORT_ALLOC_QPG                 21
37 #define MBOX_PKI_PORT_FREE_QPG                  22
38 #define MBOX_PKI_SET_PORT_CONFIG                23
39
40 #define MBOX_PKI_MAX_QOS_ENTRY 64
41
42 /* PKI maximum constants */
43 #define PKI_VF_MAX                      (32)
44 #define PKI_MAX_PKTLEN                  (32768)
45
46 /* Interface types: */
47 enum {
48         OCTTX_PORT_TYPE_NET, /* Network interface ports */
49         OCTTX_PORT_TYPE_INT, /* CPU internal interface ports */
50         OCTTX_PORT_TYPE_PCI, /* DPI/PCIe interface ports */
51         OCTTX_PORT_TYPE_MAX
52 };
53
54 /* pki pkind parse mode */
55 enum  {
56         PKI_PARSE_LA_TO_LG = 0,
57         PKI_PARSE_LB_TO_LG = 1,
58         PKI_PARSE_LC_TO_LG = 3,
59         PKI_PARSE_LG = 0x3f,
60         PKI_PARSE_NOTHING = 0x7f
61 };
62
63 /* CACHE MODE*/
64 enum {
65         PKI_OPC_MODE_STT = 0LL,
66         PKI_OPC_MODE_STF = 1LL,
67         PKI_OPC_MODE_STF1_STT = 2LL,
68         PKI_OPC_MODE_STF2_STT = 3LL
69 };
70
71 /* PKI QPG QOS*/
72 enum {
73         PKI_QPG_QOS_NONE = 0,
74         PKI_QPG_QOS_VLAN,
75         PKI_QPG_QOS_MPLS,
76         PKI_QPG_QOS_DSA_SRC,
77         PKI_QPG_QOS_DIFFSERV,
78         PKI_QPG_QOS_HIGIG,
79 };
80
81 /* pki port config */
82 typedef struct pki_port_type {
83         uint8_t port_type;
84 } pki_port_type_t;
85
86 /* pki port config */
87 typedef struct pki_port_cfg {
88         uint8_t port_type;
89         struct {
90                 uint8_t fcs_pres:1;
91                 uint8_t fcs_skip:1;
92                 uint8_t parse_mode:1;
93                 uint8_t mpls_parse:1;
94                 uint8_t inst_hdr_parse:1;
95                 uint8_t fulc_parse:1;
96                 uint8_t dsa_parse:1;
97                 uint8_t hg2_parse:1;
98                 uint8_t hg_parse:1;
99         } mmask;
100         uint8_t fcs_pres;
101         uint8_t fcs_skip;
102         uint8_t parse_mode;
103         uint8_t mpls_parse;
104         uint8_t inst_hdr_parse;
105         uint8_t fulc_parse;
106         uint8_t dsa_parse;
107         uint8_t hg2_parse;
108         uint8_t hg_parse;
109 } pki_prt_cfg_t;
110
111
112 /* pki Flow/style packet buffer config */
113 typedef struct pki_port_pktbuf_cfg {
114         uint8_t port_type;
115         struct {
116                 uint16_t f_mbuff_size:1;
117                 uint16_t f_wqe_skip:1;
118                 uint16_t f_first_skip:1;
119                 uint16_t f_later_skip:1;
120                 uint16_t f_pkt_outside_wqe:1;
121                 uint16_t f_wqe_endian:1;
122                 uint16_t f_cache_mode:1;
123         } mmask;
124         uint16_t mbuff_size;
125         uint16_t wqe_skip;
126         uint16_t first_skip;
127         uint16_t later_skip;
128         uint8_t pkt_outside_wqe;
129         uint8_t wqe_endian;
130         uint8_t cache_mode;
131 } pki_pktbuf_cfg_t;
132
133 /* pki flow/style tag config */
134 typedef struct pki_port_hash_cfg {
135         uint8_t port_type;
136         uint32_t tag_slf:1;
137         uint32_t tag_sle:1;
138         uint32_t tag_sld:1;
139         uint32_t tag_slc:1;
140         uint32_t tag_dlf:1;
141         uint32_t tag_dle:1;
142         uint32_t tag_dld:1;
143         uint32_t tag_dlc:1;
144         uint32_t tag_prt:1;
145         uint32_t tag_vlan0:1;
146         uint32_t tag_vlan1:1;
147         uint32_t tag_ip_pctl:1;
148         uint32_t tag_sync:1;
149         uint32_t tag_spi:1;
150         uint32_t tag_gtp:1;
151         uint32_t tag_vni:1;
152 } pki_hash_cfg_t;
153
154 /* pki flow/style errcheck config */
155 typedef struct pki_port_errcheck_cfg {
156         uint8_t port_type;
157         struct {
158                 uint32_t f_ip6_udp_opt:1;
159                 uint32_t f_lenerr_en:1;
160                 uint32_t f_maxerr_en:1;
161                 uint32_t f_minerr_en:1;
162                 uint32_t f_fcs_chk:1;
163                 uint32_t f_fcs_strip:1;
164                 uint32_t f_len_lf:1;
165                 uint32_t f_len_le:1;
166                 uint32_t f_len_ld:1;
167                 uint32_t f_len_lc:1;
168                 uint32_t f_csum_lf:1;
169                 uint32_t f_csum_le:1;
170                 uint32_t f_csum_ld:1;
171                 uint32_t f_csum_lc:1;
172                 uint32_t f_min_frame_len;
173                 uint32_t f_max_frame_len;
174         } mmask;
175         uint64_t ip6_udp_opt:1;
176         uint64_t lenerr_en:1;
177         uint64_t maxerr_en:1;
178         uint64_t minerr_en:1;
179         uint64_t fcs_chk:1;
180         uint64_t fcs_strip:1;
181         uint64_t len_lf:1;
182         uint64_t len_le:1;
183         uint64_t len_ld:1;
184         uint64_t len_lc:1;
185         uint64_t csum_lf:1;
186         uint64_t csum_le:1;
187         uint64_t csum_ld:1;
188         uint64_t csum_lc:1;
189         uint64_t min_frame_len;
190         uint64_t max_frame_len;
191 } pki_errchk_cfg_t;
192
193 struct pki_qos_entry {
194         uint16_t port_add;
195         uint16_t ggrp_ok;
196         uint16_t ggrp_bad;
197         uint16_t gaura;
198         uint8_t grptag_ok;
199         uint8_t grptag_bad;
200         uint8_t ena_red;
201         uint8_t ena_drop;
202         uint8_t tag_type;
203 };
204
205 #define PKO_MAX_QOS_ENTRY 64
206
207 /* pki flow/style enable qos */
208 typedef struct pki_port_create_qos {
209         uint8_t port_type;
210         uint8_t qpg_qos;
211         uint8_t num_entry;
212         uint8_t tag_type;
213         uint8_t drop_policy;
214         struct pki_qos_entry qos_entry[PKO_MAX_QOS_ENTRY];
215 } pki_qos_cfg_t;
216
217 /* pki flow/style enable qos */
218 typedef struct pki_port_delete_qos_entry {
219         uint8_t port_type;
220         uint16_t index;
221 } pki_del_qos_t;
222
223 /* pki flow/style enable qos */
224 typedef struct pki_port_modify_qos_entry {
225         uint8_t port_type;
226         uint16_t index;
227         struct {
228                 uint8_t f_port_add:1;
229                 uint8_t f_grp_ok:1;
230                 uint8_t f_grp_bad:1;
231                 uint8_t f_gaura:1;
232                 uint8_t f_grptag_ok:1;
233                 uint8_t f_grptag_bad:1;
234                 uint8_t f_tag_type:1;
235         } mmask;
236         struct pki_qos_entry qos_entry;
237 } pki_mod_qos_t;
238
239 static inline int
240 octeontx_pki_port_modify_qos(int port, pki_mod_qos_t *qos_cfg)
241 {
242         struct octeontx_mbox_hdr hdr;
243         int res;
244
245         pki_mod_qos_t q_cfg = *(pki_mod_qos_t *)qos_cfg;
246         int len = sizeof(pki_mod_qos_t);
247
248         hdr.coproc = OCTEONTX_PKI_COPROC;
249         hdr.msg = MBOX_PKI_PORT_MODIFY_QOS;
250         hdr.vfid = port;
251
252         res = octeontx_mbox_send(&hdr, &q_cfg, len, NULL, 0);
253         if (res < 0)
254                 return -EACCES;
255
256         return res;
257 }
258
259 static inline int
260 octeontx_pki_port_delete_qos(int port, pki_del_qos_t *qos_cfg)
261 {
262         struct octeontx_mbox_hdr hdr;
263         int res;
264
265         pki_del_qos_t q_cfg = *(pki_del_qos_t *)qos_cfg;
266         int len = sizeof(pki_del_qos_t);
267
268         hdr.coproc = OCTEONTX_PKI_COPROC;
269         hdr.msg = MBOX_PKI_PORT_DELETE_QOS;
270         hdr.vfid = port;
271
272         res = octeontx_mbox_send(&hdr, &q_cfg, len, NULL, 0);
273         if (res < 0)
274                 return -EACCES;
275
276         return res;
277 }
278
279 static inline int
280 octeontx_pki_port_close(int port)
281 {
282         struct octeontx_mbox_hdr hdr;
283         int res;
284
285         pki_port_type_t ptype;
286         int len = sizeof(pki_port_type_t);
287         memset(&ptype, 0, len);
288         ptype.port_type = OCTTX_PORT_TYPE_NET;
289
290         hdr.coproc = OCTEONTX_PKI_COPROC;
291         hdr.msg = MBOX_PKI_PORT_CLOSE;
292         hdr.vfid = port;
293
294         res = octeontx_mbox_send(&hdr, &ptype, len, NULL, 0);
295         if (res < 0)
296                 return -EACCES;
297
298         return res;
299 }
300
301 static inline int
302 octeontx_pki_port_start(int port)
303 {
304         struct octeontx_mbox_hdr hdr;
305         int res;
306
307         pki_port_type_t ptype;
308         int len = sizeof(pki_port_type_t);
309         memset(&ptype, 0, len);
310         ptype.port_type = OCTTX_PORT_TYPE_NET;
311
312         hdr.coproc = OCTEONTX_PKI_COPROC;
313         hdr.msg = MBOX_PKI_PORT_START;
314         hdr.vfid = port;
315
316         res = octeontx_mbox_send(&hdr, &ptype, len, NULL, 0);
317         if (res < 0)
318                 return -EACCES;
319
320         return res;
321 }
322
323 static inline int
324 octeontx_pki_port_stop(int port)
325 {
326         struct octeontx_mbox_hdr hdr;
327         int res;
328
329         pki_port_type_t ptype;
330         int len = sizeof(pki_port_type_t);
331         memset(&ptype, 0, len);
332         ptype.port_type = OCTTX_PORT_TYPE_NET;
333
334         hdr.coproc = OCTEONTX_PKI_COPROC;
335         hdr.msg = MBOX_PKI_PORT_STOP;
336         hdr.vfid = port;
337
338         res = octeontx_mbox_send(&hdr, &ptype, len, NULL, 0);
339         if (res < 0)
340                 return -EACCES;
341
342         return res;
343 }
344
345 int octeontx_pki_port_open(int port);
346 int octeontx_pki_port_hash_config(int port, pki_hash_cfg_t *hash_cfg);
347 int octeontx_pki_port_pktbuf_config(int port, pki_pktbuf_cfg_t *buf_cfg);
348 int octeontx_pki_port_create_qos(int port, pki_qos_cfg_t *qos_cfg);
349 int octeontx_pki_port_close(int port);
350 int octeontx_pki_port_errchk_config(int port, pki_errchk_cfg_t *cfg);
351
352 #endif /* __OCTEONTX_PKI_H__ */