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
39 #define MBOX_PKI_PORT_VLAN_FILTER_CONFIG 24
40 #define MBOX_PKI_PORT_VLAN_FILTER_ENTRY_CONFIG 25
42 #define MBOX_PKI_MAX_QOS_ENTRY 64
44 /* PKI maximum constants */
45 #define PKI_VF_MAX (32)
46 #define PKI_MAX_PKTLEN (32768)
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 */
56 /* pki pkind parse mode */
58 PKI_PARSE_LA_TO_LG = 0,
59 PKI_PARSE_LB_TO_LG = 1,
60 PKI_PARSE_LC_TO_LG = 3,
62 PKI_PARSE_NOTHING = 0x7f
67 PKI_OPC_MODE_STT = 0LL,
68 PKI_OPC_MODE_STF = 1LL,
69 PKI_OPC_MODE_STF1_STT = 2LL,
70 PKI_OPC_MODE_STF2_STT = 3LL
84 typedef struct pki_port_type {
89 typedef struct pki_port_cfg {
96 uint8_t inst_hdr_parse:1;
106 uint8_t inst_hdr_parse;
114 /* pki Flow/style packet buffer config */
115 typedef struct 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;
135 /* pki flow/style tag config */
136 typedef struct pki_port_hash_cfg {
147 uint32_t tag_vlan0:1;
148 uint32_t tag_vlan1:1;
149 uint32_t tag_ip_pctl:1;
156 /* pki flow/style errcheck config */
157 typedef struct 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;
195 struct pki_qos_entry {
207 #define PKO_MAX_QOS_ENTRY 64
209 /* pki flow/style enable qos */
210 typedef struct pki_port_create_qos {
216 struct pki_qos_entry qos_entry[PKO_MAX_QOS_ENTRY];
219 /* pki flow/style enable qos */
220 typedef struct pki_port_delete_qos_entry {
225 /* pki flow/style enable qos */
226 typedef struct pki_port_modify_qos_entry {
230 uint8_t f_port_add:1;
234 uint8_t f_grptag_ok:1;
235 uint8_t f_grptag_bad:1;
236 uint8_t f_tag_type:1;
238 struct pki_qos_entry qos_entry;
241 /* pki port VLAN filter config */
242 typedef struct pki_port_vlan_filter_config {
243 uint8_t port_type; /* OCTTX_PORT_TYPE_[NET/INT/PCI] */
244 uint8_t fltr_conf; /* '1' to enable & '0' to disable */
245 } pki_port_vlan_filter_config_t;
247 /* pki port VLAN filter entry config */
248 typedef struct pki_port_vlan_filter_entry_config {
249 uint8_t port_type; /* OCTTX_PORT_TYPE_[NET/INT/PCI] */
250 uint8_t entry_conf; /* '1' to add & '0' to remove */
251 uint16_t vlan_tpid; /* in host byte-order */
252 uint16_t vlan_id; /* in host byte-order */
253 } pki_port_vlan_filter_entry_config_t;
256 octeontx_pki_port_modify_qos(int port, pki_mod_qos_t *qos_cfg)
258 struct octeontx_mbox_hdr hdr;
261 pki_mod_qos_t q_cfg = *(pki_mod_qos_t *)qos_cfg;
262 int len = sizeof(pki_mod_qos_t);
264 hdr.coproc = OCTEONTX_PKI_COPROC;
265 hdr.msg = MBOX_PKI_PORT_MODIFY_QOS;
268 res = octeontx_mbox_send(&hdr, &q_cfg, len, NULL, 0);
276 octeontx_pki_port_delete_qos(int port, pki_del_qos_t *qos_cfg)
278 struct octeontx_mbox_hdr hdr;
281 pki_del_qos_t q_cfg = *(pki_del_qos_t *)qos_cfg;
282 int len = sizeof(pki_del_qos_t);
284 hdr.coproc = OCTEONTX_PKI_COPROC;
285 hdr.msg = MBOX_PKI_PORT_DELETE_QOS;
288 res = octeontx_mbox_send(&hdr, &q_cfg, len, NULL, 0);
296 octeontx_pki_port_close(int port)
298 struct octeontx_mbox_hdr hdr;
301 pki_port_type_t ptype;
302 int len = sizeof(pki_port_type_t);
303 memset(&ptype, 0, len);
304 ptype.port_type = OCTTX_PORT_TYPE_NET;
306 hdr.coproc = OCTEONTX_PKI_COPROC;
307 hdr.msg = MBOX_PKI_PORT_CLOSE;
310 res = octeontx_mbox_send(&hdr, &ptype, len, NULL, 0);
318 octeontx_pki_port_start(int port)
320 struct octeontx_mbox_hdr hdr;
323 pki_port_type_t ptype;
324 int len = sizeof(pki_port_type_t);
325 memset(&ptype, 0, len);
326 ptype.port_type = OCTTX_PORT_TYPE_NET;
328 hdr.coproc = OCTEONTX_PKI_COPROC;
329 hdr.msg = MBOX_PKI_PORT_START;
332 res = octeontx_mbox_send(&hdr, &ptype, len, NULL, 0);
340 octeontx_pki_port_stop(int port)
342 struct octeontx_mbox_hdr hdr;
345 pki_port_type_t ptype;
346 int len = sizeof(pki_port_type_t);
347 memset(&ptype, 0, len);
348 ptype.port_type = OCTTX_PORT_TYPE_NET;
350 hdr.coproc = OCTEONTX_PKI_COPROC;
351 hdr.msg = MBOX_PKI_PORT_STOP;
354 res = octeontx_mbox_send(&hdr, &ptype, len, NULL, 0);
361 int octeontx_pki_port_open(int port);
362 int octeontx_pki_port_hash_config(int port, pki_hash_cfg_t *hash_cfg);
363 int octeontx_pki_port_pktbuf_config(int port, pki_pktbuf_cfg_t *buf_cfg);
364 int octeontx_pki_port_create_qos(int port, pki_qos_cfg_t *qos_cfg);
365 int octeontx_pki_port_close(int port);
366 int octeontx_pki_port_errchk_config(int port, pki_errchk_cfg_t *cfg);
367 int octeontx_pki_port_vlan_fltr_config(int port,
368 pki_port_vlan_filter_config_t *fltr_cfg);
369 int octeontx_pki_port_vlan_fltr_entry_config(int port,
370 pki_port_vlan_filter_entry_config_t *entry_cfg);
372 #endif /* __OCTEONTX_PKI_H__ */