b6e9edc6a195b235dece0bddfb451f1219201727
[dpdk.git] / drivers / net / octeontx / base / octeontx_pkivf.h
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright (C) Cavium Inc. 2017. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *     * Neither the name of Cavium networks nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef __OCTEONTX_PKI_H__
34 #define __OCTEONTX_PKI_H__
35
36 #include <stdint.h>
37
38 #include <rte_pmd_octeontx_ssovf.h>
39
40 #define OCTEONTX_PKI_COPROC                     5
41
42 /* PKI messages */
43
44 #define MBOX_PKI_PORT_OPEN                      1
45 #define MBOX_PKI_PORT_START                     2
46 #define MBOX_PKI_PORT_STOP                      3
47 #define MBOX_PKI_PORT_CLOSE                     4
48 #define MBOX_PKI_PORT_CONFIG                    5
49 #define MBOX_PKI_PORT_OPT_PARSER_CONFIG         6
50 #define MBOX_PKI_PORT_CUSTOM_PARSER_CONFIG      7
51 #define MBOX_PKI_PORT_PKTBUF_CONFIG             8
52 #define MBOX_PKI_PORT_HASH_CONFIG               9
53 #define MBOX_PKI_PORT_ERRCHK_CONFIG             10
54 #define MBOX_PKI_PORT_CREATE_QOS                11
55 #define MBOX_PKI_PORT_MODIFY_QOS                12
56 #define MBOX_PKI_PORT_DELETE_QOS                13
57 #define MBOX_PKI_PORT_PKTDROP_CONFIG            14
58 #define MBOX_PKI_PORT_WQE_GEN_CONFIG            15
59 #define MBOX_PKI_BACKPRESSURE_CONFIG            16
60 #define MBOX_PKI_PORT_GET_STATS                 17
61 #define MBOX_PKI_PORT_RESET_STATS               18
62 #define MBOX_PKI_GET_PORT_CONFIG                19
63 #define MBOX_PKI_GET_PORT_QOS_CONFIG            20
64
65 #define MBOX_PKI_MAX_QOS_ENTRY 64
66
67 /* pki pkind parse mode */
68 enum  {
69         MBOX_PKI_PARSE_LA_TO_LG = 0,
70         MBOX_PKI_PARSE_LB_TO_LG = 1,
71         MBOX_PKI_PARSE_LC_TO_LG = 3,
72         MBOX_PKI_PARSE_LG = 0x3f,
73         MBOX_PKI_PARSE_NOTHING = 0x7f
74 };
75
76 /* Interface types: */
77 enum {
78         OCTTX_PORT_TYPE_NET, /* Network interface ports */
79         OCTTX_PORT_TYPE_INT, /* CPU internal interface ports */
80         OCTTX_PORT_TYPE_PCI, /* DPI/PCIe interface ports */
81         OCTTX_PORT_TYPE_MAX
82 };
83
84 /* pki port config */
85 typedef struct mbox_pki_port_type {
86         uint8_t port_type;
87 } mbox_pki_port_t;
88
89 /* pki port config */
90 typedef struct mbox_pki_port_cfg {
91         uint8_t port_type;
92         struct {
93                 uint8_t fcs_pres:1;
94                 uint8_t fcs_skip:1;
95                 uint8_t parse_mode:1;
96                 uint8_t mpls_parse:1;
97                 uint8_t inst_hdr_parse:1;
98                 uint8_t fulc_parse:1;
99                 uint8_t dsa_parse:1;
100                 uint8_t hg2_parse:1;
101                 uint8_t hg_parse:1;
102         } mmask;
103         uint8_t fcs_pres;
104         uint8_t fcs_skip;
105         uint8_t parse_mode;
106         uint8_t mpls_parse;
107         uint8_t inst_hdr_parse;
108         uint8_t fulc_parse;
109         uint8_t dsa_parse;
110         uint8_t hg2_parse;
111         uint8_t hg_parse;
112 } mbox_pki_prt_cfg_t;
113
114 /* pki Flow/style packet buffer config */
115 typedef struct mbox_pki_port_pktbuf_cfg {
116         uint8_t port_type;
117         struct {
118                 uint16_t f_mbuff_size:1;
119                 uint16_t f_wqe_skip:1;
120                 uint16_t f_first_skip:1;
121                 uint16_t f_later_skip:1;
122                 uint16_t f_pkt_outside_wqe:1;
123                 uint16_t f_wqe_endian:1;
124                 uint16_t f_cache_mode:1;
125         } mmask;
126         uint16_t mbuff_size;
127         uint16_t wqe_skip;
128         uint16_t first_skip;
129         uint16_t later_skip;
130         uint8_t pkt_outside_wqe;
131         uint8_t wqe_endian;
132         uint8_t cache_mode;
133 } mbox_pki_pktbuf_cfg_t;
134
135 /* pki flow/style tag config */
136 typedef struct mbox_pki_port_hash_cfg {
137         uint8_t port_type;
138         uint32_t tag_slf:1;
139         uint32_t tag_sle:1;
140         uint32_t tag_sld:1;
141         uint32_t tag_slc:1;
142         uint32_t tag_dlf:1;
143         uint32_t tag_dle:1;
144         uint32_t tag_dld:1;
145         uint32_t tag_dlc:1;
146         uint32_t tag_prt:1;
147         uint32_t tag_vlan0:1;
148         uint32_t tag_vlan1:1;
149         uint32_t tag_ip_pctl:1;
150         uint32_t tag_sync:1;
151         uint32_t tag_spi:1;
152         uint32_t tag_gtp:1;
153         uint32_t tag_vni:1;
154 } mbox_pki_hash_cfg_t;
155
156 /* pki flow/style errcheck config */
157 typedef struct mbox_pki_port_errcheck_cfg {
158         uint8_t port_type;
159         struct {
160                 uint32_t f_ip6_udp_opt:1;
161                 uint32_t f_lenerr_en:1;
162                 uint32_t f_maxerr_en:1;
163                 uint32_t f_minerr_en:1;
164                 uint32_t f_fcs_chk:1;
165                 uint32_t f_fcs_strip:1;
166                 uint32_t f_len_lf:1;
167                 uint32_t f_len_le:1;
168                 uint32_t f_len_ld:1;
169                 uint32_t f_len_lc:1;
170                 uint32_t f_csum_lf:1;
171                 uint32_t f_csum_le:1;
172                 uint32_t f_csum_ld:1;
173                 uint32_t f_csum_lc:1;
174                 uint32_t f_min_frame_len;
175                 uint32_t f_max_frame_len;
176         } mmask;
177         uint64_t ip6_udp_opt:1;
178         uint64_t lenerr_en:1;
179         uint64_t maxerr_en:1;
180         uint64_t minerr_en:1;
181         uint64_t fcs_chk:1;
182         uint64_t fcs_strip:1;
183         uint64_t len_lf:1;
184         uint64_t len_le:1;
185         uint64_t len_ld:1;
186         uint64_t len_lc:1;
187         uint64_t csum_lf:1;
188         uint64_t csum_le:1;
189         uint64_t csum_ld:1;
190         uint64_t csum_lc:1;
191         uint64_t min_frame_len;
192         uint64_t max_frame_len;
193 } mbox_pki_errcheck_cfg_t;
194
195 /* CACHE MODE*/
196 enum {
197         MBOX_PKI_OPC_MODE_STT = 0LL,
198         MBOX_PKI_OPC_MODE_STF = 1LL,
199         MBOX_PKI_OPC_MODE_STF1_STT = 2LL,
200         MBOX_PKI_OPC_MODE_STF2_STT = 3LL
201 };
202
203 /* PKI QPG QOS*/
204 enum {
205         MBOX_PKI_QPG_QOS_NONE = 0,
206         MBOX_PKI_QPG_QOS_VLAN,
207         MBOX_PKI_QPG_QOS_MPLS,
208         MBOX_PKI_QPG_QOS_DSA_SRC,
209         MBOX_PKI_QPG_QOS_DIFFSERV,
210         MBOX_PKI_QPG_QOS_HIGIG,
211 };
212
213 struct mbox_pki_qos_entry {
214         uint16_t port_add;
215         uint16_t ggrp_ok;
216         uint16_t ggrp_bad;
217         uint16_t gaura;
218         uint8_t grptag_ok;
219         uint8_t grptag_bad;
220 };
221
222 /* pki flow/style enable qos */
223 typedef struct mbox_pki_port_create_qos {
224         uint8_t port_type;
225         uint8_t qpg_qos;
226         uint8_t num_entry;
227         uint8_t tag_type;
228         uint8_t drop_policy;
229         struct mbox_pki_qos_entry qos_entry[MBOX_PKI_MAX_QOS_ENTRY];
230 } mbox_pki_qos_cfg_t;
231
232 /* pki flow/style enable qos */
233 typedef struct mbox_pki_port_modify_qos_entry {
234         uint8_t port_type;
235         uint16_t index;
236         struct {
237                 uint8_t f_port_add:1;
238                 uint8_t f_grp_ok:1;
239                 uint8_t f_grp_bad:1;
240                 uint8_t f_gaura:1;
241                 uint8_t f_grptag_ok:1;
242                 uint8_t f_grptag_bad:1;
243         } mmask;
244         struct mbox_pki_qos_entry qos_entry;
245 } mbox_pki_mod_qos_t;
246
247 /* PKI maximum constants */
248 #define PKI_VF_MAX                      (1)
249 #define PKI_MAX_PKTLEN                  (32768)
250
251 /* pki pkind parse mode */
252 enum  {
253         PKI_PARSE_LA_TO_LG = 0,
254         PKI_PARSE_LB_TO_LG = 1,
255         PKI_PARSE_LC_TO_LG = 3,
256         PKI_PARSE_LG = 0x3f,
257         PKI_PARSE_NOTHING = 0x7f
258 };
259
260 /* pki port config */
261 typedef struct pki_port_cfg {
262         uint8_t port_type;
263         struct {
264                 uint8_t fcs_pres:1;
265                 uint8_t fcs_skip:1;
266                 uint8_t parse_mode:1;
267                 uint8_t mpls_parse:1;
268                 uint8_t inst_hdr_parse:1;
269                 uint8_t fulc_parse:1;
270                 uint8_t dsa_parse:1;
271                 uint8_t hg2_parse:1;
272                 uint8_t hg_parse:1;
273         } mmask;
274         uint8_t fcs_pres;
275         uint8_t fcs_skip;
276         uint8_t parse_mode;
277         uint8_t mpls_parse;
278         uint8_t inst_hdr_parse;
279         uint8_t fulc_parse;
280         uint8_t dsa_parse;
281         uint8_t hg2_parse;
282         uint8_t hg_parse;
283 } pki_prt_cfg_t;
284
285
286 /* pki Flow/style packet buffer config */
287 typedef struct pki_port_pktbuf_cfg {
288         uint8_t port_type;
289         struct {
290                 uint16_t f_mbuff_size:1;
291                 uint16_t f_wqe_skip:1;
292                 uint16_t f_first_skip:1;
293                 uint16_t f_later_skip:1;
294                 uint16_t f_pkt_outside_wqe:1;
295                 uint16_t f_wqe_endian:1;
296                 uint16_t f_cache_mode:1;
297         } mmask;
298         uint16_t mbuff_size;
299         uint16_t wqe_skip;
300         uint16_t first_skip;
301         uint16_t later_skip;
302         uint8_t pkt_outside_wqe;
303         uint8_t wqe_endian;
304         uint8_t cache_mode;
305 } pki_pktbuf_cfg_t;
306
307 /* pki flow/style tag config */
308 typedef struct pki_port_hash_cfg {
309         uint8_t port_type;
310         uint32_t tag_slf:1;
311         uint32_t tag_sle:1;
312         uint32_t tag_sld:1;
313         uint32_t tag_slc:1;
314         uint32_t tag_dlf:1;
315         uint32_t tag_dle:1;
316         uint32_t tag_dld:1;
317         uint32_t tag_dlc:1;
318         uint32_t tag_prt:1;
319         uint32_t tag_vlan0:1;
320         uint32_t tag_vlan1:1;
321         uint32_t tag_ip_pctl:1;
322         uint32_t tag_sync:1;
323         uint32_t tag_spi:1;
324         uint32_t tag_gtp:1;
325         uint32_t tag_vni:1;
326 } pki_hash_cfg_t;
327
328 /* pki flow/style errcheck config */
329 typedef struct pki_port_errcheck_cfg {
330         uint8_t port_type;
331         struct {
332                 uint32_t f_ip6_udp_opt:1;
333                 uint32_t f_lenerr_en:1;
334                 uint32_t f_maxerr_en:1;
335                 uint32_t f_minerr_en:1;
336                 uint32_t f_fcs_chk:1;
337                 uint32_t f_fcs_strip:1;
338                 uint32_t f_len_lf:1;
339                 uint32_t f_len_le:1;
340                 uint32_t f_len_ld:1;
341                 uint32_t f_len_lc:1;
342                 uint32_t f_csum_lf:1;
343                 uint32_t f_csum_le:1;
344                 uint32_t f_csum_ld:1;
345                 uint32_t f_csum_lc:1;
346                 uint32_t f_min_frame_len;
347                 uint32_t f_max_frame_len;
348         } mmask;
349         uint64_t ip6_udp_opt:1;
350         uint64_t lenerr_en:1;
351         uint64_t maxerr_en:1;
352         uint64_t minerr_en:1;
353         uint64_t fcs_chk:1;
354         uint64_t fcs_strip:1;
355         uint64_t len_lf:1;
356         uint64_t len_le:1;
357         uint64_t len_ld:1;
358         uint64_t len_lc:1;
359         uint64_t csum_lf:1;
360         uint64_t csum_le:1;
361         uint64_t csum_ld:1;
362         uint64_t csum_lc:1;
363         uint64_t min_frame_len;
364         uint64_t max_frame_len;
365 } pki_errchk_cfg_t;
366
367
368 /* CACHE MODE*/
369 enum {
370         PKI_OPC_MODE_STT = 0LL,
371         PKI_OPC_MODE_STF = 1LL,
372         PKI_OPC_MODE_STF1_STT = 2LL,
373         PKI_OPC_MODE_STF2_STT = 3LL
374 };
375
376 /* PKI QPG QOS*/
377 enum {
378         PKI_QPG_QOS_NONE = 0,
379         PKI_QPG_QOS_VLAN,
380         PKI_QPG_QOS_MPLS,
381         PKI_QPG_QOS_DSA_SRC,
382         PKI_QPG_QOS_DIFFSERV,
383         PKI_QPG_QOS_HIGIG,
384 };
385
386 struct pki_qos_entry {
387         uint16_t port_add;
388         uint16_t ggrp_ok;
389         uint16_t ggrp_bad;
390         uint16_t gaura;
391         uint8_t grptag_ok;
392         uint8_t grptag_bad;
393         uint8_t ena_red;
394         uint8_t ena_drop;
395 };
396
397 #define PKO_MAX_QOS_ENTRY 64
398
399 /* pki flow/style enable qos */
400 typedef struct pki_port_create_qos {
401         uint8_t port_type;
402         uint8_t qpg_qos;
403         uint8_t num_entry;
404         uint8_t tag_type;
405         uint8_t drop_policy;
406         struct pki_qos_entry qos_entry[PKO_MAX_QOS_ENTRY];
407 } pki_qos_cfg_t;
408
409 /* pki flow/style enable qos */
410 typedef struct pki_port_modify_qos_entry {
411         uint8_t port_type;
412         uint16_t index;
413         struct {
414                 uint8_t f_port_add:1;
415                 uint8_t f_grp_ok:1;
416                 uint8_t f_grp_bad:1;
417                 uint8_t f_gaura:1;
418         } mmask;
419         struct pki_qos_entry qos_entry;
420 } pki_mod_qos_t;
421
422 int octeontx_pki_port_open(int port);
423 int octeontx_pki_port_hash_config(int port, pki_hash_cfg_t *hash_cfg);
424 int octeontx_pki_port_pktbuf_config(int port, pki_pktbuf_cfg_t *buf_cfg);
425 int octeontx_pki_port_create_qos(int port, pki_qos_cfg_t *qos_cfg);
426 int octeontx_pki_port_close(int port);
427 int octeontx_pki_port_start(int port);
428 int octeontx_pki_port_stop(int port);
429 int octeontx_pki_port_errchk_config(int port, pki_errchk_cfg_t *cfg);
430
431 #endif /* __OCTEONTX_PKI_H__ */