1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
5 #ifndef __OCTEONTX_PKI_H__
6 #define __OCTEONTX_PKI_H__
10 #include <octeontx_mbox.h>
12 #define OCTEONTX_PKI_COPROC 5
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
37 #define MBOX_PKI_MAX_QOS_ENTRY 64
39 /* pki pkind parse mode */
41 MBOX_PKI_PARSE_LA_TO_LG = 0,
42 MBOX_PKI_PARSE_LB_TO_LG = 1,
43 MBOX_PKI_PARSE_LC_TO_LG = 3,
44 MBOX_PKI_PARSE_LG = 0x3f,
45 MBOX_PKI_PARSE_NOTHING = 0x7f
48 /* Interface types: */
50 OCTTX_PORT_TYPE_NET, /* Network interface ports */
51 OCTTX_PORT_TYPE_INT, /* CPU internal interface ports */
52 OCTTX_PORT_TYPE_PCI, /* DPI/PCIe interface ports */
57 typedef struct mbox_pki_port_type {
62 typedef struct mbox_pki_port_cfg {
69 uint8_t inst_hdr_parse:1;
79 uint8_t inst_hdr_parse;
86 /* pki Flow/style packet buffer config */
87 typedef struct mbox_pki_port_pktbuf_cfg {
90 uint16_t f_mbuff_size:1;
91 uint16_t f_wqe_skip:1;
92 uint16_t f_first_skip:1;
93 uint16_t f_later_skip:1;
94 uint16_t f_pkt_outside_wqe:1;
95 uint16_t f_wqe_endian:1;
96 uint16_t f_cache_mode:1;
102 uint8_t pkt_outside_wqe;
105 } mbox_pki_pktbuf_cfg_t;
107 /* pki flow/style tag config */
108 typedef struct mbox_pki_port_hash_cfg {
119 uint32_t tag_vlan0:1;
120 uint32_t tag_vlan1:1;
121 uint32_t tag_ip_pctl:1;
126 } mbox_pki_hash_cfg_t;
128 /* pki flow/style errcheck config */
129 typedef struct mbox_pki_port_errcheck_cfg {
132 uint32_t f_ip6_udp_opt:1;
133 uint32_t f_lenerr_en:1;
134 uint32_t f_maxerr_en:1;
135 uint32_t f_minerr_en:1;
136 uint32_t f_fcs_chk:1;
137 uint32_t f_fcs_strip:1;
142 uint32_t f_csum_lf:1;
143 uint32_t f_csum_le:1;
144 uint32_t f_csum_ld:1;
145 uint32_t f_csum_lc:1;
146 uint32_t f_min_frame_len;
147 uint32_t f_max_frame_len;
149 uint64_t ip6_udp_opt:1;
150 uint64_t lenerr_en:1;
151 uint64_t maxerr_en:1;
152 uint64_t minerr_en:1;
154 uint64_t fcs_strip:1;
163 uint64_t min_frame_len;
164 uint64_t max_frame_len;
165 } mbox_pki_errcheck_cfg_t;
169 MBOX_PKI_OPC_MODE_STT = 0LL,
170 MBOX_PKI_OPC_MODE_STF = 1LL,
171 MBOX_PKI_OPC_MODE_STF1_STT = 2LL,
172 MBOX_PKI_OPC_MODE_STF2_STT = 3LL
177 MBOX_PKI_QPG_QOS_NONE = 0,
178 MBOX_PKI_QPG_QOS_VLAN,
179 MBOX_PKI_QPG_QOS_MPLS,
180 MBOX_PKI_QPG_QOS_DSA_SRC,
181 MBOX_PKI_QPG_QOS_DIFFSERV,
182 MBOX_PKI_QPG_QOS_HIGIG,
185 struct mbox_pki_qos_entry {
194 /* pki flow/style enable qos */
195 typedef struct mbox_pki_port_create_qos {
201 struct mbox_pki_qos_entry qos_entry[MBOX_PKI_MAX_QOS_ENTRY];
202 } mbox_pki_qos_cfg_t;
204 /* pki flow/style enable qos */
205 typedef struct mbox_pki_port_modify_qos_entry {
209 uint8_t f_port_add:1;
213 uint8_t f_grptag_ok:1;
214 uint8_t f_grptag_bad:1;
215 uint8_t f_tag_type:1;
218 struct mbox_pki_qos_entry qos_entry;
219 } mbox_pki_mod_qos_t;
221 /* pki flow/style enable qos */
222 typedef struct mbox_pki_port_delete_qos_entry {
225 } mbox_pki_del_qos_t;
227 /* PKI maximum constants */
228 #define PKI_VF_MAX (1)
229 #define PKI_MAX_PKTLEN (32768)
231 /* pki pkind parse mode */
233 PKI_PARSE_LA_TO_LG = 0,
234 PKI_PARSE_LB_TO_LG = 1,
235 PKI_PARSE_LC_TO_LG = 3,
237 PKI_PARSE_NOTHING = 0x7f
240 /* pki port config */
241 typedef struct pki_port_cfg {
246 uint8_t parse_mode:1;
247 uint8_t mpls_parse:1;
248 uint8_t inst_hdr_parse:1;
249 uint8_t fulc_parse:1;
258 uint8_t inst_hdr_parse;
266 /* pki Flow/style packet buffer config */
267 typedef struct pki_port_pktbuf_cfg {
270 uint16_t f_mbuff_size:1;
271 uint16_t f_wqe_skip:1;
272 uint16_t f_first_skip:1;
273 uint16_t f_later_skip:1;
274 uint16_t f_pkt_outside_wqe:1;
275 uint16_t f_wqe_endian:1;
276 uint16_t f_cache_mode:1;
282 uint8_t pkt_outside_wqe;
287 /* pki flow/style tag config */
288 typedef struct pki_port_hash_cfg {
299 uint32_t tag_vlan0:1;
300 uint32_t tag_vlan1:1;
301 uint32_t tag_ip_pctl:1;
308 /* pki flow/style errcheck config */
309 typedef struct pki_port_errcheck_cfg {
312 uint32_t f_ip6_udp_opt:1;
313 uint32_t f_lenerr_en:1;
314 uint32_t f_maxerr_en:1;
315 uint32_t f_minerr_en:1;
316 uint32_t f_fcs_chk:1;
317 uint32_t f_fcs_strip:1;
322 uint32_t f_csum_lf:1;
323 uint32_t f_csum_le:1;
324 uint32_t f_csum_ld:1;
325 uint32_t f_csum_lc:1;
326 uint32_t f_min_frame_len;
327 uint32_t f_max_frame_len;
329 uint64_t ip6_udp_opt:1;
330 uint64_t lenerr_en:1;
331 uint64_t maxerr_en:1;
332 uint64_t minerr_en:1;
334 uint64_t fcs_strip:1;
343 uint64_t min_frame_len;
344 uint64_t max_frame_len;
350 PKI_OPC_MODE_STT = 0LL,
351 PKI_OPC_MODE_STF = 1LL,
352 PKI_OPC_MODE_STF1_STT = 2LL,
353 PKI_OPC_MODE_STF2_STT = 3LL
358 PKI_QPG_QOS_NONE = 0,
362 PKI_QPG_QOS_DIFFSERV,
366 struct pki_qos_entry {
377 #define PKO_MAX_QOS_ENTRY 64
379 /* pki flow/style enable qos */
380 typedef struct pki_port_create_qos {
386 struct pki_qos_entry qos_entry[PKO_MAX_QOS_ENTRY];
389 /* pki flow/style enable qos */
390 typedef struct pki_port_delete_qos_entry {
395 /* pki flow/style enable qos */
396 typedef struct pki_port_modify_qos_entry {
400 uint8_t f_port_add:1;
404 uint8_t f_grptag_ok:1;
405 uint8_t f_grptag_bad:1;
406 uint8_t f_tag_type:1;
409 struct pki_qos_entry qos_entry;
413 octeontx_pki_port_modify_qos(int port, pki_mod_qos_t *qos_cfg)
415 struct octeontx_mbox_hdr hdr;
418 mbox_pki_mod_qos_t q_cfg = *(mbox_pki_mod_qos_t *)qos_cfg;
419 int len = sizeof(mbox_pki_mod_qos_t);
421 hdr.coproc = OCTEONTX_PKI_COPROC;
422 hdr.msg = MBOX_PKI_PORT_MODIFY_QOS;
425 res = octeontx_ssovf_mbox_send(&hdr, &q_cfg, len, NULL, 0);
433 octeontx_pki_port_delete_qos(int port, pki_del_qos_t *qos_cfg)
435 struct octeontx_mbox_hdr hdr;
438 mbox_pki_del_qos_t q_cfg = *(mbox_pki_del_qos_t *)qos_cfg;
439 int len = sizeof(mbox_pki_del_qos_t);
441 hdr.coproc = OCTEONTX_PKI_COPROC;
442 hdr.msg = MBOX_PKI_PORT_DELETE_QOS;
445 res = octeontx_ssovf_mbox_send(&hdr, &q_cfg, len, NULL, 0);
453 octeontx_pki_port_close(int port)
455 struct octeontx_mbox_hdr hdr;
458 mbox_pki_port_t ptype;
459 int len = sizeof(mbox_pki_port_t);
460 memset(&ptype, 0, len);
461 ptype.port_type = OCTTX_PORT_TYPE_NET;
463 hdr.coproc = OCTEONTX_PKI_COPROC;
464 hdr.msg = MBOX_PKI_PORT_CLOSE;
467 res = octeontx_ssovf_mbox_send(&hdr, &ptype, len, NULL, 0);
475 octeontx_pki_port_start(int port)
477 struct octeontx_mbox_hdr hdr;
480 mbox_pki_port_t ptype;
481 int len = sizeof(mbox_pki_port_t);
482 memset(&ptype, 0, len);
483 ptype.port_type = OCTTX_PORT_TYPE_NET;
485 hdr.coproc = OCTEONTX_PKI_COPROC;
486 hdr.msg = MBOX_PKI_PORT_START;
489 res = octeontx_ssovf_mbox_send(&hdr, &ptype, len, NULL, 0);
497 octeontx_pki_port_stop(int port)
499 struct octeontx_mbox_hdr hdr;
502 mbox_pki_port_t ptype;
503 int len = sizeof(mbox_pki_port_t);
504 memset(&ptype, 0, len);
505 ptype.port_type = OCTTX_PORT_TYPE_NET;
507 hdr.coproc = OCTEONTX_PKI_COPROC;
508 hdr.msg = MBOX_PKI_PORT_STOP;
511 res = octeontx_ssovf_mbox_send(&hdr, &ptype, len, NULL, 0);
518 int octeontx_pki_port_open(int port);
519 int octeontx_pki_port_hash_config(int port, pki_hash_cfg_t *hash_cfg);
520 int octeontx_pki_port_pktbuf_config(int port, pki_pktbuf_cfg_t *buf_cfg);
521 int octeontx_pki_port_create_qos(int port, pki_qos_cfg_t *qos_cfg);
522 int octeontx_pki_port_close(int port);
523 int octeontx_pki_port_errchk_config(int port, pki_errchk_cfg_t *cfg);
525 #endif /* __OCTEONTX_PKI_H__ */