4 * Copyright (C) Cavium Inc. 2017. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
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.
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.
33 #ifndef __OCTEONTX_PKI_H__
34 #define __OCTEONTX_PKI_H__
38 #include <octeontx_mbox.h>
40 #define OCTEONTX_PKI_COPROC 5
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
65 #define MBOX_PKI_MAX_QOS_ENTRY 64
67 /* pki pkind parse mode */
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
76 /* Interface types: */
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 */
85 typedef struct mbox_pki_port_type {
90 typedef struct mbox_pki_port_cfg {
97 uint8_t inst_hdr_parse:1;
107 uint8_t inst_hdr_parse;
112 } mbox_pki_prt_cfg_t;
114 /* pki Flow/style packet buffer config */
115 typedef struct mbox_pki_port_pktbuf_cfg {
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;
130 uint8_t pkt_outside_wqe;
133 } mbox_pki_pktbuf_cfg_t;
135 /* pki flow/style tag config */
136 typedef struct mbox_pki_port_hash_cfg {
147 uint32_t tag_vlan0:1;
148 uint32_t tag_vlan1:1;
149 uint32_t tag_ip_pctl:1;
154 } mbox_pki_hash_cfg_t;
156 /* pki flow/style errcheck config */
157 typedef struct mbox_pki_port_errcheck_cfg {
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;
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;
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;
182 uint64_t fcs_strip:1;
191 uint64_t min_frame_len;
192 uint64_t max_frame_len;
193 } mbox_pki_errcheck_cfg_t;
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
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,
213 struct mbox_pki_qos_entry {
222 /* pki flow/style enable qos */
223 typedef struct mbox_pki_port_create_qos {
229 struct mbox_pki_qos_entry qos_entry[MBOX_PKI_MAX_QOS_ENTRY];
230 } mbox_pki_qos_cfg_t;
232 /* pki flow/style enable qos */
233 typedef struct mbox_pki_port_modify_qos_entry {
237 uint8_t f_port_add:1;
241 uint8_t f_grptag_ok:1;
242 uint8_t f_grptag_bad:1;
243 uint8_t f_tag_type:1;
246 struct mbox_pki_qos_entry qos_entry;
247 } mbox_pki_mod_qos_t;
249 /* pki flow/style enable qos */
250 typedef struct mbox_pki_port_delete_qos_entry {
253 } mbox_pki_del_qos_t;
255 /* PKI maximum constants */
256 #define PKI_VF_MAX (1)
257 #define PKI_MAX_PKTLEN (32768)
259 /* pki pkind parse mode */
261 PKI_PARSE_LA_TO_LG = 0,
262 PKI_PARSE_LB_TO_LG = 1,
263 PKI_PARSE_LC_TO_LG = 3,
265 PKI_PARSE_NOTHING = 0x7f
268 /* pki port config */
269 typedef struct pki_port_cfg {
274 uint8_t parse_mode:1;
275 uint8_t mpls_parse:1;
276 uint8_t inst_hdr_parse:1;
277 uint8_t fulc_parse:1;
286 uint8_t inst_hdr_parse;
294 /* pki Flow/style packet buffer config */
295 typedef struct pki_port_pktbuf_cfg {
298 uint16_t f_mbuff_size:1;
299 uint16_t f_wqe_skip:1;
300 uint16_t f_first_skip:1;
301 uint16_t f_later_skip:1;
302 uint16_t f_pkt_outside_wqe:1;
303 uint16_t f_wqe_endian:1;
304 uint16_t f_cache_mode:1;
310 uint8_t pkt_outside_wqe;
315 /* pki flow/style tag config */
316 typedef struct pki_port_hash_cfg {
327 uint32_t tag_vlan0:1;
328 uint32_t tag_vlan1:1;
329 uint32_t tag_ip_pctl:1;
336 /* pki flow/style errcheck config */
337 typedef struct pki_port_errcheck_cfg {
340 uint32_t f_ip6_udp_opt:1;
341 uint32_t f_lenerr_en:1;
342 uint32_t f_maxerr_en:1;
343 uint32_t f_minerr_en:1;
344 uint32_t f_fcs_chk:1;
345 uint32_t f_fcs_strip:1;
350 uint32_t f_csum_lf:1;
351 uint32_t f_csum_le:1;
352 uint32_t f_csum_ld:1;
353 uint32_t f_csum_lc:1;
354 uint32_t f_min_frame_len;
355 uint32_t f_max_frame_len;
357 uint64_t ip6_udp_opt:1;
358 uint64_t lenerr_en:1;
359 uint64_t maxerr_en:1;
360 uint64_t minerr_en:1;
362 uint64_t fcs_strip:1;
371 uint64_t min_frame_len;
372 uint64_t max_frame_len;
378 PKI_OPC_MODE_STT = 0LL,
379 PKI_OPC_MODE_STF = 1LL,
380 PKI_OPC_MODE_STF1_STT = 2LL,
381 PKI_OPC_MODE_STF2_STT = 3LL
386 PKI_QPG_QOS_NONE = 0,
390 PKI_QPG_QOS_DIFFSERV,
394 struct pki_qos_entry {
405 #define PKO_MAX_QOS_ENTRY 64
407 /* pki flow/style enable qos */
408 typedef struct pki_port_create_qos {
414 struct pki_qos_entry qos_entry[PKO_MAX_QOS_ENTRY];
417 /* pki flow/style enable qos */
418 typedef struct pki_port_delete_qos_entry {
423 /* pki flow/style enable qos */
424 typedef struct pki_port_modify_qos_entry {
428 uint8_t f_port_add:1;
432 uint8_t f_grptag_ok:1;
433 uint8_t f_grptag_bad:1;
434 uint8_t f_tag_type:1;
437 struct pki_qos_entry qos_entry;
441 octeontx_pki_port_modify_qos(int port, pki_mod_qos_t *qos_cfg)
443 struct octeontx_mbox_hdr hdr;
446 mbox_pki_mod_qos_t q_cfg = *(mbox_pki_mod_qos_t *)qos_cfg;
447 int len = sizeof(mbox_pki_mod_qos_t);
449 hdr.coproc = OCTEONTX_PKI_COPROC;
450 hdr.msg = MBOX_PKI_PORT_MODIFY_QOS;
453 res = octeontx_ssovf_mbox_send(&hdr, &q_cfg, len, NULL, 0);
461 octeontx_pki_port_delete_qos(int port, pki_del_qos_t *qos_cfg)
463 struct octeontx_mbox_hdr hdr;
466 mbox_pki_del_qos_t q_cfg = *(mbox_pki_del_qos_t *)qos_cfg;
467 int len = sizeof(mbox_pki_del_qos_t);
469 hdr.coproc = OCTEONTX_PKI_COPROC;
470 hdr.msg = MBOX_PKI_PORT_DELETE_QOS;
473 res = octeontx_ssovf_mbox_send(&hdr, &q_cfg, len, NULL, 0);
481 octeontx_pki_port_close(int port)
483 struct octeontx_mbox_hdr hdr;
486 mbox_pki_port_t ptype;
487 int len = sizeof(mbox_pki_port_t);
488 memset(&ptype, 0, len);
489 ptype.port_type = OCTTX_PORT_TYPE_NET;
491 hdr.coproc = OCTEONTX_PKI_COPROC;
492 hdr.msg = MBOX_PKI_PORT_CLOSE;
495 res = octeontx_ssovf_mbox_send(&hdr, &ptype, len, NULL, 0);
503 octeontx_pki_port_start(int port)
505 struct octeontx_mbox_hdr hdr;
508 mbox_pki_port_t ptype;
509 int len = sizeof(mbox_pki_port_t);
510 memset(&ptype, 0, len);
511 ptype.port_type = OCTTX_PORT_TYPE_NET;
513 hdr.coproc = OCTEONTX_PKI_COPROC;
514 hdr.msg = MBOX_PKI_PORT_START;
517 res = octeontx_ssovf_mbox_send(&hdr, &ptype, len, NULL, 0);
525 octeontx_pki_port_stop(int port)
527 struct octeontx_mbox_hdr hdr;
530 mbox_pki_port_t ptype;
531 int len = sizeof(mbox_pki_port_t);
532 memset(&ptype, 0, len);
533 ptype.port_type = OCTTX_PORT_TYPE_NET;
535 hdr.coproc = OCTEONTX_PKI_COPROC;
536 hdr.msg = MBOX_PKI_PORT_STOP;
539 res = octeontx_ssovf_mbox_send(&hdr, &ptype, len, NULL, 0);
546 int octeontx_pki_port_open(int port);
547 int octeontx_pki_port_hash_config(int port, pki_hash_cfg_t *hash_cfg);
548 int octeontx_pki_port_pktbuf_config(int port, pki_pktbuf_cfg_t *buf_cfg);
549 int octeontx_pki_port_create_qos(int port, pki_qos_cfg_t *qos_cfg);
550 int octeontx_pki_port_close(int port);
551 int octeontx_pki_port_errchk_config(int port, pki_errchk_cfg_t *cfg);
553 #endif /* __OCTEONTX_PKI_H__ */