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
36 #define MBOX_PKI_PORT_ALLOC_QPG 21
37 #define MBOX_PKI_PORT_FREE_QPG 22
38 #define MBOX_PKI_SET_PORT_CONFIG 23
40 #define MBOX_PKI_MAX_QOS_ENTRY 64
42 /* PKI maximum constants */
43 #define PKI_VF_MAX (32)
44 #define PKI_MAX_PKTLEN (32768)
46 /* Interface types: */
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 */
54 /* pki pkind parse mode */
56 PKI_PARSE_LA_TO_LG = 0,
57 PKI_PARSE_LB_TO_LG = 1,
58 PKI_PARSE_LC_TO_LG = 3,
60 PKI_PARSE_NOTHING = 0x7f
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
82 typedef struct pki_port_type {
87 typedef struct pki_port_cfg {
94 uint8_t inst_hdr_parse:1;
104 uint8_t inst_hdr_parse;
112 /* pki Flow/style packet buffer config */
113 typedef struct pki_port_pktbuf_cfg {
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;
128 uint8_t pkt_outside_wqe;
133 /* pki flow/style tag config */
134 typedef struct pki_port_hash_cfg {
145 uint32_t tag_vlan0:1;
146 uint32_t tag_vlan1:1;
147 uint32_t tag_ip_pctl:1;
154 /* pki flow/style errcheck config */
155 typedef struct pki_port_errcheck_cfg {
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;
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;
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;
180 uint64_t fcs_strip:1;
189 uint64_t min_frame_len;
190 uint64_t max_frame_len;
193 struct pki_qos_entry {
205 #define PKO_MAX_QOS_ENTRY 64
207 /* pki flow/style enable qos */
208 typedef struct pki_port_create_qos {
214 struct pki_qos_entry qos_entry[PKO_MAX_QOS_ENTRY];
217 /* pki flow/style enable qos */
218 typedef struct pki_port_delete_qos_entry {
223 /* pki flow/style enable qos */
224 typedef struct pki_port_modify_qos_entry {
228 uint8_t f_port_add:1;
232 uint8_t f_grptag_ok:1;
233 uint8_t f_grptag_bad:1;
234 uint8_t f_tag_type:1;
236 struct pki_qos_entry qos_entry;
240 octeontx_pki_port_modify_qos(int port, pki_mod_qos_t *qos_cfg)
242 struct octeontx_mbox_hdr hdr;
245 pki_mod_qos_t q_cfg = *(pki_mod_qos_t *)qos_cfg;
246 int len = sizeof(pki_mod_qos_t);
248 hdr.coproc = OCTEONTX_PKI_COPROC;
249 hdr.msg = MBOX_PKI_PORT_MODIFY_QOS;
252 res = octeontx_mbox_send(&hdr, &q_cfg, len, NULL, 0);
260 octeontx_pki_port_delete_qos(int port, pki_del_qos_t *qos_cfg)
262 struct octeontx_mbox_hdr hdr;
265 pki_del_qos_t q_cfg = *(pki_del_qos_t *)qos_cfg;
266 int len = sizeof(pki_del_qos_t);
268 hdr.coproc = OCTEONTX_PKI_COPROC;
269 hdr.msg = MBOX_PKI_PORT_DELETE_QOS;
272 res = octeontx_mbox_send(&hdr, &q_cfg, len, NULL, 0);
280 octeontx_pki_port_close(int port)
282 struct octeontx_mbox_hdr hdr;
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;
290 hdr.coproc = OCTEONTX_PKI_COPROC;
291 hdr.msg = MBOX_PKI_PORT_CLOSE;
294 res = octeontx_mbox_send(&hdr, &ptype, len, NULL, 0);
302 octeontx_pki_port_start(int port)
304 struct octeontx_mbox_hdr hdr;
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;
312 hdr.coproc = OCTEONTX_PKI_COPROC;
313 hdr.msg = MBOX_PKI_PORT_START;
316 res = octeontx_mbox_send(&hdr, &ptype, len, NULL, 0);
324 octeontx_pki_port_stop(int port)
326 struct octeontx_mbox_hdr hdr;
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;
334 hdr.coproc = OCTEONTX_PKI_COPROC;
335 hdr.msg = MBOX_PKI_PORT_STOP;
338 res = octeontx_mbox_send(&hdr, &ptype, len, NULL, 0);
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);
352 #endif /* __OCTEONTX_PKI_H__ */