1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018-2019 Cisco Systems, Inc. All rights reserved.
4 #ifndef _VNIC_FLOWMAN_H_
5 #define _VNIC_FLOWMAN_H_
7 /* This file contains Flow Manager (FM) API of the firmware */
9 /* Flow manager sub-ops */
20 FM_EXACT_ENTRY_INSTALL,
21 FM_TCAM_ENTRY_INSTALL,
22 FM_MATCH_ENTRY_REMOVE,
25 FM_API_VERSION_SELECT,
30 * FKM (flow key metadata) flags used to match packet metadata
31 * (e.g. packet is tcp)
55 FBIT(FKM_EG_HAIRPINNED)
58 * FKH (flow key header) flags.
59 * This selects which headers are valid in the struct.
60 * This is distinct from metadata in that metadata is requesting actual
61 * selection criteria. If, for example, a TCAM match with metadata "FKM_UDP"
62 * is feeding into an exact match table, there may be no need for the
63 * exact match table to also specify FKM_UDP, so FKH_UDP is used to
64 * specify that the UDP header fields should be used in the match.
79 #define FBIT(X) X##_BIT,
90 #define FBIT(X) X = (1 << X##_BIT),
100 #define FM_LAYER_SIZE 64
102 /* Header match pattern */
103 struct fm_header_set {
104 uint32_t fk_metadata; /* FKM flags */
105 uint32_t fk_header_select; /* FKH flags */
107 /* L2: Ethernet Header (valid if FKH_ETHER) */
110 uint8_t fk_dstmac[FM_ETH_ALEN];
111 uint8_t fk_srcmac[FM_ETH_ALEN];
114 uint8_t rawdata[FM_LAYER_SIZE];
116 /* L3: IPv4 or IPv6 (valid if FKH_IPV4,6) */
118 /* Valid if FKH_IPV4 */
124 uint16_t fk_frag_off;
131 /* Valid if FKH_IPV6 */
135 uint32_t fk_un1_flow;
136 uint16_t fk_un1_plen;
142 uint8_t fk_srcip[16];
143 uint8_t fk_dstip[16];
145 uint8_t rawdata[FM_LAYER_SIZE];
147 /* L4: UDP, TCP, or ICMP (valid if FKH_UDP,TCP,ICMP) */
169 uint8_t rawdata[FM_LAYER_SIZE];
171 /* VXLAN (valid if FKH_VXLAN) */
174 uint8_t fkvx_res0[3];
177 } __rte_packed vxlan;
178 /* Payload or unknown inner-most protocol */
179 uint8_t fk_l5_data[64];
183 * FK (flow key) template.
184 * fk_hdrset specifies a set of headers per layer of encapsulation.
185 * Currently FM supports two header sets: outer (0) and inner(1)
187 #define FM_HDRSET_MAX 2
189 struct fm_key_template {
190 struct fm_header_set fk_hdrset[FM_HDRSET_MAX];
192 uint16_t fk_packet_tag;
193 uint16_t fk_packet_size;
195 uint32_t fk_wq_id; /* WQ index */
196 uint64_t fk_wq_vnic; /* VNIC handle for WQ index */
199 /* Action operation types */
202 /* End the action chain. */
204 /* Drop packet and end the action chain. */
206 /* Steer packet to an RQ. */
209 * Jump to an exact match table.
210 * arg1: exact match table handle
213 /* Apply CQ-visible mark on packet. Mark is written to RSS HASH. */
216 * Apply CQ-visible mark on packet. Mark is written to a field in
217 * extended CQ. RSS HASH is preserved.
221 * Apply internal tag which can be matched in subsequent
225 /* Hairpin packet from EG -> IG */
227 /* Hairpin packet from IG -> EG */
229 /* Encap with VXLAN and inner VLAN from metadata. */
231 /* Encap, no inner VLAN. */
233 /* Encap, add inner VLAN if present. */
235 /* Set outer VLAN. */
237 /* Decap when vlan_strip is off */
244 * Complex actions are achieved by a series of "transform operations"
245 * We can have complex transform operations like "decap" or "vxlan
246 * encap" and also simple ops like insert this data, add PACKET_LEN to
249 struct fm_action_op {
250 uint32_t fa_op; /* FMOP flags */
259 uint8_t template_offset;
260 uint8_t template_len;
261 } __rte_packed encap;
264 uint64_t vnic_handle;
265 } __rte_packed rq_steer;
268 } __rte_packed ovlan;
274 } __rte_packed ext_mark;
280 } __rte_packed exact;
284 #define FM_ACTION_OP_MAX 64
285 #define FM_ACTION_DATA_MAX 96
288 * Action is a series of action operations applied to matched
289 * packet. FMA (flowman action).
292 struct fm_action_op fma_action_ops[FM_ACTION_OP_MAX];
293 uint8_t fma_data[FM_ACTION_DATA_MAX];
296 /* Match entry flags. FMEF (flow match entry flag) */
297 #define FMEF_COUNTER 0x0001 /* counter index is valid */
299 /* FEM (flow exact match) entry */
300 struct fm_exact_match_entry {
301 struct fm_key_template fem_data; /* Match data. Mask is per table */
302 uint32_t fem_flags; /* FMEF_xxx */
303 uint64_t fem_action; /* Action handle */
304 uint32_t fem_counter; /* Counter index */
307 /* FTM (flow TCAM match) entry */
308 struct fm_tcam_match_entry {
309 struct fm_key_template ftm_mask; /* Key mask */
310 struct fm_key_template ftm_data; /* Match data */
311 uint32_t ftm_flags; /* FMEF_xxx */
312 uint32_t ftm_position; /* Entry position */
313 uint64_t ftm_action; /* Action handle */
314 uint32_t ftm_counter; /* Counter index */
317 /* Match directions */
324 /* Last stage ID, independent of the number of stages in hardware */
325 #define FM_STAGE_LAST 0xff
327 /* Hash based exact match table. FET (flow exact match table) */
328 struct fm_exact_match_table {
329 uint8_t fet_direction; /* FM_INGRESS or EGRESS*/
332 uint32_t fet_max_entries;
333 uint64_t fet_dflt_action;
334 struct fm_key_template fet_key;
337 /* TCAM based match table. FTT (flow TCAM match table) */
338 struct fm_tcam_match_table {
339 uint8_t ftt_direction;
342 uint32_t ftt_max_entries;
345 struct fm_counter_counts {
346 uint64_t fcc_packets;
351 * Return structure for FM_INFO_QUERY devcmd
353 #define FM_VERSION 1 /* This header file is for version 1 */
356 uint64_t fm_op_mask; /* Bitmask of action supported ops */
357 uint64_t fm_current_ts; /* Current VIC timestamp */
358 uint64_t fm_clock_freq; /* Timestamp clock frequency */
359 uint16_t fm_max_ops; /* Max ops in an action */
360 uint8_t fm_stages; /* Number of match-action stages */
362 uint32_t fm_counter_count; /* Number of allocated counters */
365 #endif /* _VNIC_FLOWMAN_H_ */