Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : :
5 : : #ifndef _ROC_NPC_PRIV_H_
6 : : #define _ROC_NPC_PRIV_H_
7 : :
8 : : #define NPC_IH_LENGTH 8
9 : : #define NPC_TPID_LENGTH 2
10 : : #define NPC_HIGIG2_LENGTH 16
11 : : #define NPC_MAX_RAW_ITEM_LEN 16
12 : : #define NPC_COUNTER_NONE (-1)
13 : :
14 : : #define NPC_RSS_GRPS 8
15 : :
16 : : #define NPC_ACTION_FLAG_DEFAULT 0xffff
17 : :
18 : : #define NPC_PFVF_FUNC_MASK 0x3FF
19 : :
20 : : /* 32 bytes from LDATA_CFG & 32 bytes from FLAGS_CFG */
21 : : #define NPC_MAX_EXTRACT_DATA_LEN (64)
22 : : #define NPC_MAX_EXTRACT_HW_LEN (4 * NPC_MAX_EXTRACT_DATA_LEN)
23 : : #define NPC_LDATA_LFLAG_LEN (16)
24 : : #define NPC_MAX_KEY_NIBBLES (31)
25 : :
26 : : /* Nibble offsets */
27 : : #define NPC_LAYER_KEYX_SZ (3)
28 : : #define NPC_PARSE_KEX_S_LA_OFFSET (7)
29 : : #define NPC_PARSE_KEX_S_LID_OFFSET(lid) \
30 : : ((((lid) - (NPC_LID_LA)) * NPC_LAYER_KEYX_SZ) + \
31 : : NPC_PARSE_KEX_S_LA_OFFSET)
32 : :
33 : : #define NPC_LAYER_KEYX_SZ_CN20K (2)
34 : : #define NPC_PARSE_KEX_S_LID_OFFSET_CN20K(lid) \
35 : : ((((lid) - (NPC_LID_LA)) * NPC_LAYER_KEYX_SZ_CN20K) + NPC_PARSE_KEX_S_LA_OFFSET)
36 : :
37 : : /* This mark value indicates flag action */
38 : : #define NPC_FLOW_FLAG_VAL (0xffff)
39 : :
40 : : #define NPC_RX_ACT_MATCH_OFFSET (40)
41 : : #define NPC_RX_ACT_MATCH_MASK (0xFFFF)
42 : :
43 : : #define NPC_RSS_ACT_GRP_OFFSET (20)
44 : : #define NPC_RSS_ACT_ALG_OFFSET (56)
45 : : #define NPC_RSS_ACT_GRP_MASK (0xFFFFF)
46 : : #define NPC_RSS_ACT_ALG_MASK (0x1F)
47 : :
48 : : #define NPC_MCAM_KEX_FIELD_MAX 23
49 : : #define NPC_MCAM_MAX_PROTO_FIELDS (NPC_MCAM_KEX_FIELD_MAX + 1)
50 : : #if defined(ROC_PLATFORM_CN20K)
51 : : #define NPC_MCAM_KEY_X4_WORDS 8 /* Number of 64-bit words */
52 : : #else
53 : : #define NPC_MCAM_KEY_X4_WORDS 7 /* Number of 64-bit words */
54 : : #endif
55 : :
56 : : #define NPC_RVUPF_MAX_9XXX 0x10 /* HRM: RVU_PRIV_CONST */
57 : : #define NPC_RVUPF_MAX_98XX 0x18 /* HRM: RVU_PRIV_CONST */
58 : : #define NPC_RVUPF_MAX_10XX 0x20 /* HRM: RVU_PRIV_CONST */
59 : : #define NPC_NIXLF_MAX 0x80 /* HRM: NIX_AF_CONST2 */
60 : : #define NPC_MCAME_PER_PF 3 /* DRV: RSVD_MCAM_ENTRIES_PER_PF */
61 : : #define NPC_MCAME_PER_LF 1 /* DRV: RSVD_MCAM_ENTRIES_PER_NIXLF */
62 : : #define NPC_NIXLF_MAX_98XX (2 * NPC_NIXLF_MAX) /*2 NIXLFs */
63 : : #define NPC_MCAME_RESVD_9XXX \
64 : : (NPC_NIXLF_MAX * NPC_MCAME_PER_LF + \
65 : : (NPC_RVUPF_MAX_9XXX - 1) * NPC_MCAME_PER_PF)
66 : :
67 : : #define NPC_MCAME_RESVD_10XX \
68 : : (NPC_NIXLF_MAX * NPC_MCAME_PER_LF + \
69 : : (NPC_RVUPF_MAX_10XX - 1) * NPC_MCAME_PER_PF)
70 : :
71 : : #define NPC_MCAME_RESVD_98XX \
72 : : (NPC_NIXLF_MAX_98XX * NPC_MCAME_PER_LF + \
73 : : (NPC_RVUPF_MAX_98XX - 1) * NPC_MCAME_PER_PF)
74 : :
75 : : #define NPC_ACTION_MAX_VLAN_PARAMS 3
76 : : #define NPC_ACTION_MAX_VLANS_STRIPPED 2
77 : :
78 : : #define NPC_LTYPE_OFFSET_START 7
79 : : /* LB OFFSET : START + LA (2b flags + 1b ltype) + LB (2b flags) */
80 : : #define NPC_LTYPE_LB_OFFSET (NPC_LTYPE_OFFSET_START + 5)
81 : : #define NPC_LFLAG_LB_OFFSET (NPC_LTYPE_OFFSET_START + 3)
82 : : /* LC OFFSET : START + LA (2b flags + 1b ltype) + LB (2b flags + 1b ltype) + LC
83 : : * (2b flags)
84 : : */
85 : : #define NPC_LFLAG_LC_OFFSET (NPC_LTYPE_OFFSET_START + 6)
86 : : #define NPC_LTYPE_LC_OFFSET (NPC_LTYPE_OFFSET_START + 8)
87 : :
88 : : /* LB OFFSET : START + LA (1b flags + 1b ltype) + LB (1b flags) */
89 : : #define NPC_CN20K_LTYPE_LB_OFFSET (NPC_LTYPE_OFFSET_START + 3)
90 : : #define NPC_CN20K_LFLAG_LB_OFFSET (NPC_LTYPE_OFFSET_START + 2)
91 : :
92 : : /* LC OFFSET : START + LA (1b flags + 1b ltype) + LB (1b flags + 1b ltype) + LC
93 : : * (1b flags)
94 : : */
95 : : #define NPC_CN20K_LFLAG_LC_OFFSET (NPC_LTYPE_OFFSET_START + 4)
96 : : #define NPC_CN20K_LTYPE_LC_OFFSET (NPC_LTYPE_OFFSET_START + 5)
97 : :
98 : : #define CN10K_SDP_CH_START 0x80
99 : : #define CN10K_SDP_CH_MASK 0xF80
100 : :
101 : : struct npc_action_vtag_info {
102 : : uint16_t vlan_id;
103 : : uint16_t vlan_ethtype;
104 : : uint8_t vlan_pcp;
105 : : };
106 : :
107 : : enum npc_err_status {
108 : : NPC_ERR_PARAM = -1024,
109 : : NPC_ERR_NO_MEM,
110 : : NPC_ERR_INVALID_SPEC,
111 : : NPC_ERR_INVALID_MASK,
112 : : NPC_ERR_INVALID_RANGE,
113 : : NPC_ERR_INVALID_KEX,
114 : : NPC_ERR_INVALID_SIZE,
115 : : NPC_ERR_INTERNAL,
116 : : NPC_ERR_MCAM_ALLOC,
117 : : NPC_ERR_ACTION_NOTSUP,
118 : : NPC_ERR_PATTERN_NOTSUP,
119 : : };
120 : :
121 : : enum npc_mcam_intf { NPC_MCAM_RX, NPC_MCAM_TX };
122 : :
123 : : typedef union npc_kex_cap_terms_t {
124 : : /** Packet Matching Rule term fields */
125 : : struct {
126 : : /** Total length of received packet */
127 : : uint64_t len : 1;
128 : : /** Initial (outer) Ethertype only */
129 : : uint64_t ethtype_0 : 1;
130 : : /** Ethertype of most inner VLAN tag */
131 : : uint64_t ethtype_x : 1;
132 : : /** First VLAN ID (outer) */
133 : : uint64_t vlan_id_0 : 1;
134 : : /** Last VLAN ID (inner) */
135 : : uint64_t vlan_id_x : 1;
136 : : /** PCP in the first VLAN header */
137 : : uint64_t vlan_pcp_0 : 1;
138 : : /** destination MAC address */
139 : : uint64_t dmac : 1;
140 : : /** IP Protocol or IPv6 Next Header */
141 : : uint64_t ip_proto : 1;
142 : : /** DSCP in IP header */
143 : : uint64_t ip_dscp : 1;
144 : : /** Destination UDP port, implies IPPROTO=17 */
145 : : uint64_t udp_dport : 1;
146 : : /** Destination TCP port implies IPPROTO=6 */
147 : : uint64_t tcp_dport : 1;
148 : : /** Source UDP Port */
149 : : uint64_t udp_sport : 1;
150 : : /** Source TCP port */
151 : : uint64_t tcp_sport : 1;
152 : : /** Source IP address */
153 : : uint64_t sip_addr : 1;
154 : : /** Destination IP address */
155 : : uint64_t dip_addr : 1;
156 : : /** Source IP address */
157 : : uint64_t sip6_addr : 1;
158 : : /** Destination IP address */
159 : : uint64_t dip6_addr : 1;
160 : : /** IPsec session identifier */
161 : : uint64_t ipsec_spi : 1;
162 : : /** NVGRE/VXLAN network identifier */
163 : : uint64_t ld_vni : 1;
164 : : /** Custom frame match rule. PMR offset is counted from
165 : : * the start of the packet.
166 : : */
167 : : uint64_t custom_frame : 1;
168 : : /** Custom layer 3 match rule. PMR offset is counted from
169 : : * the start of layer 3 in the packet.
170 : : */
171 : : uint64_t custom_l3 : 1;
172 : : /** IGMP Group address */
173 : : uint64_t igmp_grp_addr : 1;
174 : : /** ICMP identifier */
175 : : uint64_t icmp_id : 1;
176 : : /** ICMP type */
177 : : uint64_t icmp_type : 1;
178 : : /** ICMP code */
179 : : uint64_t icmp_code : 1;
180 : : /** Source SCTP port */
181 : : uint64_t sctp_sport : 1;
182 : : /** Destination SCTP port */
183 : : uint64_t sctp_dport : 1;
184 : : /** GTPv1 tunnel endpoint identifier */
185 : : uint64_t gtpv1_teid : 1;
186 : : } bit;
187 : :
188 : : /** All bits of the bit field structure */
189 : : uint64_t all_bits;
190 : :
191 : : } npc_kex_cap_terms_t;
192 : :
193 : : struct npc_parse_item_info {
194 : : const void *def_mask; /* default mask */
195 : : void *hw_mask; /* hardware supported mask */
196 : : int len; /* length of item */
197 : : uint8_t hw_hdr_len; /* Extra data len at each layer*/
198 : : const void *spec; /* spec to use, NULL implies match any */
199 : : const void *mask; /* mask to use */
200 : : };
201 : :
202 : : struct npc_parse_state {
203 : : struct npc *npc;
204 : : const struct roc_npc_item_info *pattern;
205 : : const struct roc_npc_item_info *last_pattern;
206 : : struct roc_npc_flow *flow;
207 : : uint8_t nix_intf;
208 : : uint8_t tunnel;
209 : : uint8_t terminate;
210 : : uint8_t layer_mask;
211 : : uint8_t lt[NPC_MAX_LID];
212 : : uint8_t flags[NPC_MAX_LID];
213 : : bool has_eth_type;
214 : : bool is_second_pass_rule;
215 : : bool set_ipv6ext_ltype_mask;
216 : : /* adjust ltype in MCAM to match at least one vlan */
217 : : bool set_vlan_ltype_mask;
218 : : uint8_t *mcam_data; /* point to flow->mcam_data + key_len */
219 : : uint8_t *mcam_mask; /* point to flow->mcam_mask + key_len */
220 : : bool is_vf;
221 : : uint16_t dst_pf_func;
222 : : uint64_t npc_default_action;
223 : : uint16_t nb_tx_queues;
224 : : };
225 : :
226 : : enum npc_kpu_parser_flag {
227 : : NPC_F_NA = 0,
228 : : NPC_F_PKI,
229 : : NPC_F_PKI_VLAN,
230 : : NPC_F_PKI_ETAG,
231 : : NPC_F_PKI_ITAG,
232 : : NPC_F_PKI_MPLS,
233 : : NPC_F_PKI_NSH,
234 : : NPC_F_ETYPE_UNK,
235 : : NPC_F_ETHER_VLAN,
236 : : NPC_F_ETHER_ETAG,
237 : : NPC_F_ETHER_ITAG,
238 : : NPC_F_ETHER_MPLS,
239 : : NPC_F_ETHER_NSH,
240 : : NPC_F_STAG_CTAG,
241 : : NPC_F_STAG_CTAG_UNK,
242 : : NPC_F_STAG_STAG_CTAG,
243 : : NPC_F_STAG_STAG_STAG,
244 : : NPC_F_QINQ_CTAG,
245 : : NPC_F_QINQ_CTAG_UNK,
246 : : NPC_F_QINQ_QINQ_CTAG,
247 : : NPC_F_QINQ_QINQ_QINQ,
248 : : NPC_F_BTAG_ITAG,
249 : : NPC_F_BTAG_ITAG_STAG,
250 : : NPC_F_BTAG_ITAG_CTAG,
251 : : NPC_F_BTAG_ITAG_UNK,
252 : : NPC_F_ETAG_CTAG,
253 : : NPC_F_ETAG_BTAG_ITAG,
254 : : NPC_F_ETAG_STAG,
255 : : NPC_F_ETAG_QINQ,
256 : : NPC_F_ETAG_ITAG,
257 : : NPC_F_ETAG_ITAG_STAG,
258 : : NPC_F_ETAG_ITAG_CTAG,
259 : : NPC_F_ETAG_ITAG_UNK,
260 : : NPC_F_ITAG_STAG_CTAG,
261 : : NPC_F_ITAG_STAG,
262 : : NPC_F_ITAG_CTAG,
263 : : NPC_F_MPLS_4_LABELS,
264 : : NPC_F_MPLS_3_LABELS,
265 : : NPC_F_MPLS_2_LABELS,
266 : : NPC_F_IP_HAS_OPTIONS,
267 : : NPC_F_IP_IP_IN_IP,
268 : : NPC_F_IP_6TO4,
269 : : NPC_F_IP_MPLS_IN_IP,
270 : : NPC_F_IP_UNK_PROTO,
271 : : NPC_F_IP_IP_IN_IP_HAS_OPTIONS,
272 : : NPC_F_IP_6TO4_HAS_OPTIONS,
273 : : NPC_F_IP_MPLS_IN_IP_HAS_OPTIONS,
274 : : NPC_F_IP_UNK_PROTO_HAS_OPTIONS,
275 : : NPC_F_IP6_HAS_EXT,
276 : : NPC_F_IP6_TUN_IP6,
277 : : NPC_F_IP6_MPLS_IN_IP,
278 : : NPC_F_TCP_HAS_OPTIONS,
279 : : NPC_F_TCP_HTTP,
280 : : NPC_F_TCP_HTTPS,
281 : : NPC_F_TCP_PPTP,
282 : : NPC_F_TCP_UNK_PORT,
283 : : NPC_F_TCP_HTTP_HAS_OPTIONS,
284 : : NPC_F_TCP_HTTPS_HAS_OPTIONS,
285 : : NPC_F_TCP_PPTP_HAS_OPTIONS,
286 : : NPC_F_TCP_UNK_PORT_HAS_OPTIONS,
287 : : NPC_F_UDP_VXLAN,
288 : : NPC_F_UDP_VXLAN_NOVNI,
289 : : NPC_F_UDP_VXLAN_NOVNI_NSH,
290 : : NPC_F_UDP_VXLANGPE,
291 : : NPC_F_UDP_VXLANGPE_NSH,
292 : : NPC_F_UDP_VXLANGPE_MPLS,
293 : : NPC_F_UDP_VXLANGPE_NOVNI,
294 : : NPC_F_UDP_VXLANGPE_NOVNI_NSH,
295 : : NPC_F_UDP_VXLANGPE_NOVNI_MPLS,
296 : : NPC_F_UDP_VXLANGPE_UNK,
297 : : NPC_F_UDP_VXLANGPE_NONP,
298 : : NPC_F_UDP_GTP_GTPC,
299 : : NPC_F_UDP_GTP_GTPU_G_PDU,
300 : : NPC_F_UDP_GTP_GTPU_UNK,
301 : : NPC_F_UDP_UNK_PORT,
302 : : NPC_F_UDP_GENEVE,
303 : : NPC_F_UDP_GENEVE_OAM,
304 : : NPC_F_UDP_GENEVE_CRI_OPT,
305 : : NPC_F_UDP_GENEVE_OAM_CRI_OPT,
306 : : NPC_F_GRE_NVGRE,
307 : : NPC_F_GRE_HAS_SRE,
308 : : NPC_F_GRE_HAS_CSUM,
309 : : NPC_F_GRE_HAS_KEY,
310 : : NPC_F_GRE_HAS_SEQ,
311 : : NPC_F_GRE_HAS_CSUM_KEY,
312 : : NPC_F_GRE_HAS_CSUM_SEQ,
313 : : NPC_F_GRE_HAS_KEY_SEQ,
314 : : NPC_F_GRE_HAS_CSUM_KEY_SEQ,
315 : : NPC_F_GRE_HAS_ROUTE,
316 : : NPC_F_GRE_UNK_PROTO,
317 : : NPC_F_GRE_VER1,
318 : : NPC_F_GRE_VER1_HAS_SEQ,
319 : : NPC_F_GRE_VER1_HAS_ACK,
320 : : NPC_F_GRE_VER1_HAS_SEQ_ACK,
321 : : NPC_F_GRE_VER1_UNK_PROTO,
322 : : NPC_F_TU_ETHER_UNK,
323 : : NPC_F_TU_ETHER_CTAG,
324 : : NPC_F_TU_ETHER_CTAG_UNK,
325 : : NPC_F_TU_ETHER_STAG_CTAG,
326 : : NPC_F_TU_ETHER_STAG_CTAG_UNK,
327 : : NPC_F_TU_ETHER_STAG,
328 : : NPC_F_TU_ETHER_STAG_UNK,
329 : : NPC_F_TU_ETHER_QINQ_CTAG,
330 : : NPC_F_TU_ETHER_QINQ_CTAG_UNK,
331 : : NPC_F_TU_ETHER_QINQ,
332 : : NPC_F_TU_ETHER_QINQ_UNK,
333 : : NPC_F_LAST /* has to be the last item */
334 : : };
335 : :
336 : : enum npc_mcam_cn20k_key_width {
337 : : NPC_CN20K_MCAM_KEY_X1 = 0,
338 : : NPC_CN20K_MCAM_KEY_DYN = NPC_CN20K_MCAM_KEY_X1,
339 : : NPC_CN20K_MCAM_KEY_X2,
340 : : NPC_CN20K_MCAM_KEY_X4,
341 : : NPC_CN20K_MCAM_KEY_MAX,
342 : : };
343 : :
344 : : #define NPC_ACTION_TERM \
345 : : (ROC_NPC_ACTION_TYPE_DROP | ROC_NPC_ACTION_TYPE_QUEUE | ROC_NPC_ACTION_TYPE_RSS | \
346 : : ROC_NPC_ACTION_TYPE_DUP | ROC_NPC_ACTION_TYPE_SEC)
347 : :
348 : : struct npc_xtract_info {
349 : : /* Length in bytes of pkt data extracted. len = 0
350 : : * indicates that extraction is disabled.
351 : : */
352 : : uint8_t len;
353 : : uint8_t hdr_off; /* Byte offset of proto hdr: extract_src */
354 : : uint8_t key_off; /* Byte offset in MCAM key where data is placed */
355 : : uint8_t enable; /* Extraction enabled or disabled */
356 : : uint8_t flags_enable; /* Flags extraction enabled */
357 : : uint8_t use_hash; /* Use field hash */
358 : : };
359 : :
360 : : /* Information for a given {LAYER, LTYPE} */
361 : : struct npc_lid_lt_xtract_info {
362 : : /* Info derived from parser configuration */
363 : : uint16_t npc_proto; /* Network protocol identified */
364 : : uint8_t valid_flags_mask; /* Flags applicable */
365 : : uint8_t is_terminating : 1; /* No more parsing */
366 : : struct npc_xtract_info xtract[NPC_MAX_LD];
367 : : };
368 : :
369 : : struct npc_lid_lt_xtract_info_cn20k {
370 : : /* Info derived from parser configuration */
371 : : uint16_t npc_proto; /* Network protocol identified */
372 : : uint8_t valid_flags_mask; /* Flags applicable */
373 : : uint8_t is_terminating : 1; /* No more parsing */
374 : : struct npc_xtract_info xtract;
375 : : };
376 : :
377 : : union npc_kex_ldata_flags_cfg {
378 : : struct {
379 : : uint64_t lid : 3;
380 : : uint64_t rvsd_62_1 : 61;
381 : : } s;
382 : :
383 : : uint64_t i;
384 : : };
385 : :
386 : : #define NPC_MAX_EXTRACTTORS 24
387 : : typedef struct npc_lid_lt_xtract_info_cn20k npc_dxcfg_cn20k_t[NPC_MAX_INTF][NPC_MAX_EXTRACTTORS]
388 : : [NPC_MAX_LT];
389 : : typedef union npc_kex_ldata_flags_cfg npc_lid_cn20k_t[NPC_MAX_INTF][NPC_MAX_EXTRACTTORS];
390 : :
391 : : typedef struct npc_lid_lt_xtract_info npc_dxcfg_t[NPC_MAX_INTF][NPC_MAX_LID]
392 : : [NPC_MAX_LT];
393 : : typedef struct npc_lid_lt_xtract_info npc_fxcfg_t[NPC_MAX_INTF][NPC_MAX_LD]
394 : : [NPC_MAX_LFL];
395 : : typedef union npc_kex_ldata_flags_cfg npc_ld_flags_t[NPC_MAX_LD];
396 : :
397 : : /* MBOX_MSG_NPC_GET_DATAX_CFG Response */
398 : : struct npc_get_datax_cfg {
399 : : /* NPC_AF_KEX_LDATA(0..1)_FLAGS_CFG */
400 : : union npc_kex_ldata_flags_cfg ld_flags[NPC_MAX_LD];
401 : : /* Extract information indexed with [LID][LTYPE] */
402 : : struct npc_lid_lt_xtract_info lid_lt_xtract[NPC_MAX_LID][NPC_MAX_LT];
403 : : /* Flags based extract indexed with [LDATA][FLAGS_LOWER_NIBBLE]
404 : : * Fields flags_ena_ld0, flags_ena_ld1 in
405 : : * struct npc_lid_lt_xtract_info indicate if this is applicable
406 : : * for a given {LAYER, LTYPE}
407 : : */
408 : : struct npc_xtract_info flag_xtract[NPC_MAX_LD][NPC_MAX_LT];
409 : : };
410 : :
411 : : TAILQ_HEAD(npc_flow_list, roc_npc_flow);
412 : :
413 : : struct npc_prio_flow_entry {
414 : : struct roc_npc_flow *flow;
415 : : TAILQ_ENTRY(npc_prio_flow_entry) next;
416 : : };
417 : :
418 : : TAILQ_HEAD(npc_prio_flow_list_head, npc_prio_flow_entry);
419 : :
420 : : struct npc_age_flow_entry {
421 : : struct roc_npc_flow *flow;
422 : : TAILQ_ENTRY(npc_age_flow_entry) next;
423 : : };
424 : :
425 : : TAILQ_HEAD(npc_age_flow_list_head, npc_age_flow_entry);
426 : :
427 : : struct npc {
428 : : struct mbox *mbox; /* Mbox */
429 : : uint64_t keyx_supp_nmask[NPC_MAX_INTF]; /* nibble mask */
430 : : uint8_t hash_extract_cap; /* hash extract support */
431 : : uint8_t profile_name[MKEX_NAME_LEN]; /* KEX profile name */
432 : : bool is_sdp_link;
433 : : uint16_t channel; /* RX Channel number */
434 : : uint32_t keyx_len[NPC_MAX_INTF]; /* per intf key len in bits */
435 : : uint32_t datax_len[NPC_MAX_INTF]; /* per intf data len in bits */
436 : : uint32_t keyw[NPC_MAX_INTF]; /* max key + data len bits */
437 : : uint32_t mcam_entries; /* mcam entries supported */
438 : : uint16_t switch_header_type; /* Supported switch header type */
439 : : uint16_t flow_max_priority; /* Max priority for flow */
440 : : uint16_t sdp_channel;
441 : : uint16_t sdp_channel_mask;
442 : : uint32_t rss_grps; /* rss groups supported */
443 : : uint16_t flow_prealloc_size; /* Pre allocated mcam size */
444 : : uint8_t exact_match_ena;
445 : : uint16_t pf_func; /* pf_func of device */
446 : : uint32_t mark_actions;
447 : : uint32_t vtag_strip_actions; /* vtag insert/strip actions */
448 : : npc_dxcfg_t prx_dxcfg; /* intf, lid, lt, extract */
449 : : npc_dxcfg_cn20k_t prx_dxcfg_cn20k; /* intf, ext, lt, extract */
450 : : npc_lid_cn20k_t lid_cfg; /* KEX LD_Flags CFG */
451 : : npc_fxcfg_t prx_fxcfg; /* Flag extract */
452 : : npc_ld_flags_t prx_lfcfg; /* KEX LD_Flags CFG */
453 : : struct npc_flow_list *flow_list;
454 : : struct npc_prio_flow_list_head *prio_flow_list;
455 : : struct npc_age_flow_list_head age_flow_list;
456 : : struct plt_bitmap *rss_grp_entries;
457 : : struct npc_flow_list ipsec_list;
458 : : uint8_t enable_debug;
459 : : };
460 : :
461 : : #define NPC_HASH_FIELD_LEN 16
462 : :
463 : : struct npc_hash_cfg {
464 : : uint64_t secret_key[3];
465 : : /* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
466 : : uint64_t hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
467 : : /* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
468 : : uint64_t hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
469 : : };
470 : :
471 : : static inline struct npc *
472 : : roc_npc_to_npc_priv(struct roc_npc *npc)
473 : : {
474 [ # # # # : 0 : return (struct npc *)npc->reserved;
# # ]
475 : : }
476 : :
477 : : static inline bool
478 : : roc_npc_action_is_rx_inline(uint64_t npc_action)
479 : : {
480 : 0 : uint64_t op = npc_action & 0xFULL;
481 : :
482 [ # # # # : 0 : return (op == NIX_RX_ACTIONOP_UCAST_IPSEC || op == NIX_RX_ACTIONOP_UCAST_CPT);
# # ]
483 : : }
484 : :
485 : : int npc_mcam_get_stats(struct mbox *mbox, struct roc_npc_flow *flow, uint64_t *count);
486 : : int npc_mcam_alloc_counter(struct mbox *mbox, uint16_t *ctr);
487 : : int npc_mcam_free_counter(struct mbox *mbox, uint16_t ctr_id);
488 : : int npc_mcam_read_counter(struct mbox *mbox, uint32_t ctr_id, uint64_t *count);
489 : : int npc_mcam_clear_counter(struct mbox *mbox, uint32_t ctr_id);
490 : : int npc_mcam_free_entry(struct mbox *mbox, uint32_t entry);
491 : : int npc_mcam_free_all_entries(struct npc *npc);
492 : : int npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow,
493 : : struct npc_parse_state *pst);
494 : : int npc_mcam_alloc_entry(struct npc *npc, struct roc_npc_flow *mcam, struct roc_npc_flow *ref_mcam,
495 : : uint8_t prio, int *resp_count);
496 : : int npc_mcam_alloc_entry_cn20k(struct npc *npc, struct roc_npc_flow *mcam, int *resp_count);
497 : :
498 : : int npc_mcam_alloc_entries(struct mbox *mbox, int ref_mcam, int *alloc_entry, int req_count,
499 : : int prio, int *resp_count, bool is_conti);
500 : :
501 : : int npc_mcam_ena_dis_entry(struct npc *npc, struct roc_npc_flow *mcam, bool enable);
502 : : int npc_mcam_write_entry(struct mbox *mbox, struct roc_npc_flow *mcam);
503 : : int npc_flow_enable_all_entries(struct npc *npc, bool enable);
504 : : int npc_update_parse_state(struct npc_parse_state *pst, struct npc_parse_item_info *info, int lid,
505 : : int lt, uint8_t flags);
506 : : void npc_get_hw_supp_mask(struct npc_parse_state *pst, struct npc_parse_item_info *info, int lid,
507 : : int lt);
508 : : uint8_t npc_get_key_type(struct npc *npc, struct roc_npc_flow *flow);
509 : : uint8_t npc_kex_key_type_config_get(struct npc *npc);
510 : : int npc_mask_is_supported(const char *mask, const char *hw_mask, int len);
511 : : int npc_parse_item_basic(const struct roc_npc_item_info *item, struct npc_parse_item_info *info);
512 : : int npc_parse_meta_items(struct npc_parse_state *pst);
513 : : int npc_parse_mark_item(struct npc_parse_state *pst);
514 : : int npc_parse_port_representor_id(struct npc_parse_state *pst);
515 : : int npc_parse_represented_port_id(struct npc_parse_state *pst);
516 : : int npc_parse_pre_l2(struct npc_parse_state *pst);
517 : : int npc_parse_higig2_hdr(struct npc_parse_state *pst);
518 : : int npc_parse_cpt_hdr(struct npc_parse_state *pst);
519 : : int npc_parse_tx_queue(struct npc_parse_state *pst);
520 : : int npc_parse_la(struct npc_parse_state *pst);
521 : : int npc_parse_lb(struct npc_parse_state *pst);
522 : : int npc_parse_lc(struct npc_parse_state *pst);
523 : : int npc_parse_ld(struct npc_parse_state *pst);
524 : : int npc_parse_le(struct npc_parse_state *pst);
525 : : int npc_parse_lf(struct npc_parse_state *pst);
526 : : int npc_parse_lg(struct npc_parse_state *pst);
527 : : int npc_parse_lh(struct npc_parse_state *pst);
528 : : int npc_mcam_fetch_kex_cfg(struct npc *npc);
529 : : int npc_mcam_fetch_hw_cap(struct npc *npc, uint8_t *npc_hw_cap);
530 : : int npc_get_free_mcam_entry(struct mbox *mbox, struct roc_npc_flow *flow, struct npc *npc);
531 : : void npc_delete_prio_list_entry(struct npc *npc, struct roc_npc_flow *flow);
532 : : int npc_flow_free_all_resources(struct npc *npc);
533 : : const struct roc_npc_item_info *
534 : : npc_parse_skip_void_and_any_items(const struct roc_npc_item_info *pattern);
535 : : int npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc);
536 : : uint64_t npc_get_kex_capability(struct npc *npc);
537 : : int npc_process_ipv6_field_hash(const struct roc_npc_flow_item_ipv6 *ipv6_spec,
538 : : const struct roc_npc_flow_item_ipv6 *ipv6_mask,
539 : : struct npc_parse_state *pst, uint8_t type);
540 : : int npc_rss_action_configure(struct roc_npc *roc_npc, const struct roc_npc_action_rss *rss,
541 : : uint8_t *alg_idx, uint32_t *rss_grp, uint32_t mcam_id,
542 : : uint16_t rss_repte_pf_func);
543 : : int npc_rss_action_program(struct roc_npc *roc_npc, const struct roc_npc_action actions[],
544 : : struct roc_npc_flow *flow);
545 : : int npc_rss_group_free(struct npc *npc, struct roc_npc_flow *flow);
546 : : int npc_mcam_init(struct npc *npc, struct roc_npc_flow *flow, int mcam_id);
547 : : int npc_mcam_move(struct mbox *mbox, uint16_t old_ent, uint16_t new_ent);
548 : : void npc_age_flow_list_entry_add(struct roc_npc *npc, struct roc_npc_flow *flow);
549 : : void npc_age_flow_list_entry_delete(struct roc_npc *npc, struct roc_npc_flow *flow);
550 : : uint32_t npc_aged_flows_get(void *args);
551 : : int npc_aged_flows_bitmap_alloc(struct roc_npc *roc_npc);
552 : : void npc_aged_flows_bitmap_free(struct roc_npc *roc_npc);
553 : : int npc_aging_ctrl_thread_create(struct roc_npc *roc_npc, const struct roc_npc_action_age *age,
554 : : struct roc_npc_flow *flow);
555 : : void npc_aging_ctrl_thread_destroy(struct roc_npc *roc_npc);
556 : : int npc_rss_free_grp_get(struct npc *npc, uint32_t *pos);
557 : : #endif /* _ROC_NPC_PRIV_H_ */
|