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 */
239 /* Decap and strip VLAN */
241 /* Remove outer VLAN */
243 /* Set Egress port */
245 /* Steer to an RQ without entering EMIT state */
247 /* Set VLAN when replicating encapped packets */
249 /* Enter EMIT state */
251 /* Enter MODIFY state */
258 * Complex actions are achieved by a series of "transform operations"
259 * We can have complex transform operations like "decap" or "vxlan
260 * encap" and also simple ops like insert this data, add PACKET_LEN to
263 struct fm_action_op {
264 uint32_t fa_op; /* FMOP flags */
273 uint8_t template_offset;
274 uint8_t template_len;
275 } __rte_packed encap;
279 uint64_t vnic_handle;
280 } __rte_packed rq_steer;
283 } __rte_packed ovlan;
286 } __rte_packed set_encap_vlan;
292 } __rte_packed ext_mark;
298 } __rte_packed exact;
301 } __rte_packed set_egport;
305 #define FM_ACTION_OP_MAX 64
306 #define FM_ACTION_DATA_MAX 96
309 * Action is a series of action operations applied to matched
310 * packet. FMA (flowman action).
313 struct fm_action_op fma_action_ops[FM_ACTION_OP_MAX];
314 uint8_t fma_data[FM_ACTION_DATA_MAX];
317 /* Match entry flags. FMEF (flow match entry flag) */
318 #define FMEF_COUNTER 0x0001 /* counter index is valid */
320 /* FEM (flow exact match) entry */
321 struct fm_exact_match_entry {
322 struct fm_key_template fem_data; /* Match data. Mask is per table */
323 uint32_t fem_flags; /* FMEF_xxx */
324 uint64_t fem_action; /* Action handle */
325 uint32_t fem_counter; /* Counter index */
328 /* FTM (flow TCAM match) entry */
329 struct fm_tcam_match_entry {
330 struct fm_key_template ftm_mask; /* Key mask */
331 struct fm_key_template ftm_data; /* Match data */
332 uint32_t ftm_flags; /* FMEF_xxx */
333 uint32_t ftm_position; /* Entry position */
334 uint64_t ftm_action; /* Action handle */
335 uint32_t ftm_counter; /* Counter index */
338 /* Match directions */
345 /* Last stage ID, independent of the number of stages in hardware */
346 #define FM_STAGE_LAST 0xff
348 /* Hash based exact match table. FET (flow exact match table) */
349 struct fm_exact_match_table {
350 uint8_t fet_direction; /* FM_INGRESS or EGRESS*/
353 uint32_t fet_max_entries;
354 uint64_t fet_dflt_action;
355 struct fm_key_template fet_key;
358 /* TCAM based match table. FTT (flow TCAM match table) */
359 struct fm_tcam_match_table {
360 uint8_t ftt_direction;
363 uint32_t ftt_max_entries;
366 struct fm_counter_counts {
367 uint64_t fcc_packets;
372 * Return structure for FM_INFO_QUERY devcmd
374 #define FM_VERSION 1 /* This header file is for version 1 */
377 uint64_t fm_op_mask; /* Bitmask of action supported ops */
378 uint64_t fm_current_ts; /* Current VIC timestamp */
379 uint64_t fm_clock_freq; /* Timestamp clock frequency */
380 uint16_t fm_max_ops; /* Max ops in an action */
381 uint8_t fm_stages; /* Number of match-action stages */
383 uint32_t fm_counter_count; /* Number of allocated counters */
386 #endif /* _VNIC_FLOWMAN_H_ */