xref: /linux/drivers/net/ethernet/sfc/tc.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
167ab160eSEdward Cree /* SPDX-License-Identifier: GPL-2.0-only */
267ab160eSEdward Cree /****************************************************************************
367ab160eSEdward Cree  * Driver for Solarflare network controllers and boards
467ab160eSEdward Cree  * Copyright 2019 Solarflare Communications Inc.
567ab160eSEdward Cree  * Copyright 2020-2022 Xilinx Inc.
667ab160eSEdward Cree  *
767ab160eSEdward Cree  * This program is free software; you can redistribute it and/or modify it
867ab160eSEdward Cree  * under the terms of the GNU General Public License version 2 as published
967ab160eSEdward Cree  * by the Free Software Foundation, incorporated herein by reference.
1067ab160eSEdward Cree  */
1167ab160eSEdward Cree 
1267ab160eSEdward Cree #ifndef EFX_TC_H
1367ab160eSEdward Cree #define EFX_TC_H
149dc0cad2SEdward Cree #include <net/flow_offload.h>
15f54a28a2SEdward Cree #include <linux/rhashtable.h>
1667ab160eSEdward Cree #include "net_driver.h"
1725730d8bSEdward Cree #include "tc_counters.h"
1867ab160eSEdward Cree 
19c178dff3SEdward Cree #define IS_ALL_ONES(v)	(!(typeof (v))~(v))
20c178dff3SEdward Cree 
21439c4be9SPieter Jansen van Vuuren /**
22439c4be9SPieter Jansen van Vuuren  * struct efx_tc_mac_pedit_action - mac pedit action fields
23439c4be9SPieter Jansen van Vuuren  *
24439c4be9SPieter Jansen van Vuuren  * @h_addr:	mac address field of ethernet header
25439c4be9SPieter Jansen van Vuuren  * @linkage:	rhashtable reference
26439c4be9SPieter Jansen van Vuuren  * @ref:	reference count
27439c4be9SPieter Jansen van Vuuren  * @fw_id:	index of this entry in firmware MAC address table
28439c4be9SPieter Jansen van Vuuren  *
29439c4be9SPieter Jansen van Vuuren  * MAC address edits are indirected through a table in the hardware
30439c4be9SPieter Jansen van Vuuren  */
31439c4be9SPieter Jansen van Vuuren struct efx_tc_mac_pedit_action {
32439c4be9SPieter Jansen van Vuuren 	u8 h_addr[ETH_ALEN];
33439c4be9SPieter Jansen van Vuuren 	struct rhash_head linkage;
34439c4be9SPieter Jansen van Vuuren 	refcount_t ref;
35439c4be9SPieter Jansen van Vuuren 	u32 fw_id; /* index of this entry in firmware MAC address table */
36439c4be9SPieter Jansen van Vuuren };
37439c4be9SPieter Jansen van Vuuren 
efx_ipv6_addr_all_ones(struct in6_addr * addr)38746224cdSEdward Cree static inline bool efx_ipv6_addr_all_ones(struct in6_addr *addr)
39746224cdSEdward Cree {
40746224cdSEdward Cree 	return !memchr_inv(addr, 0xff, sizeof(*addr));
41746224cdSEdward Cree }
42746224cdSEdward Cree 
43b4da4235SEdward Cree struct efx_tc_encap_action; /* see tc_encap_actions.h */
44b4da4235SEdward Cree 
45439c4be9SPieter Jansen van Vuuren /**
46439c4be9SPieter Jansen van Vuuren  * struct efx_tc_action_set - collection of tc action fields
47439c4be9SPieter Jansen van Vuuren  *
48439c4be9SPieter Jansen van Vuuren  * @vlan_push: the number of vlan headers to push
49439c4be9SPieter Jansen van Vuuren  * @vlan_pop: the number of vlan headers to pop
50439c4be9SPieter Jansen van Vuuren  * @decap: used to indicate a tunnel header decapsulation should take place
51*0c7fe3b3SEdward Cree  * @do_nat: perform NAT/NPT with values returned by conntrack match
5266f72887SPieter Jansen van Vuuren  * @do_ttl_dec: used to indicate IP TTL / Hop Limit should be decremented
53439c4be9SPieter Jansen van Vuuren  * @deliver: used to indicate a deliver action should take place
54439c4be9SPieter Jansen van Vuuren  * @vlan_tci: tci fields for vlan push actions
55439c4be9SPieter Jansen van Vuuren  * @vlan_proto: ethernet types for vlan push actions
56439c4be9SPieter Jansen van Vuuren  * @count: counter mapping
57439c4be9SPieter Jansen van Vuuren  * @encap_md: encap entry in tc_encap_ht table
58439c4be9SPieter Jansen van Vuuren  * @encap_user: linked list of encap users (encap_md->users)
59439c4be9SPieter Jansen van Vuuren  * @user: owning action-set-list. Only populated if @encap_md is; used by efx_tc_update_encap() fallback handling
60439c4be9SPieter Jansen van Vuuren  * @count_user: linked list of counter users (counter->users)
61439c4be9SPieter Jansen van Vuuren  * @dest_mport: destination mport
62439c4be9SPieter Jansen van Vuuren  * @src_mac: source mac entry in tc_mac_ht table
63439c4be9SPieter Jansen van Vuuren  * @dst_mac: destination mac entry in tc_mac_ht table
64439c4be9SPieter Jansen van Vuuren  * @fw_id: index of this entry in firmware actions table
65439c4be9SPieter Jansen van Vuuren  * @list: linked list of tc actions
66439c4be9SPieter Jansen van Vuuren  *
67439c4be9SPieter Jansen van Vuuren  */
6867ab160eSEdward Cree struct efx_tc_action_set {
6905ccd8d8SEdward Cree 	u16 vlan_push:2;
7005ccd8d8SEdward Cree 	u16 vlan_pop:2;
7117654d84SEdward Cree 	u16 decap:1;
72*0c7fe3b3SEdward Cree 	u16 do_nat:1;
7366f72887SPieter Jansen van Vuuren 	u16 do_ttl_dec:1;
7467ab160eSEdward Cree 	u16 deliver:1;
75439c4be9SPieter Jansen van Vuuren 	__be16 vlan_tci[2];
76439c4be9SPieter Jansen van Vuuren 	__be16 vlan_proto[2];
772e0f1eb0SEdward Cree 	struct efx_tc_counter_index *count;
78439c4be9SPieter Jansen van Vuuren 	struct efx_tc_encap_action *encap_md;
79439c4be9SPieter Jansen van Vuuren 	struct list_head encap_user;
80439c4be9SPieter Jansen van Vuuren 	struct efx_tc_action_set_list *user;
81439c4be9SPieter Jansen van Vuuren 	struct list_head count_user;
8267ab160eSEdward Cree 	u32 dest_mport;
83439c4be9SPieter Jansen van Vuuren 	struct efx_tc_mac_pedit_action *src_mac;
84439c4be9SPieter Jansen van Vuuren 	struct efx_tc_mac_pedit_action *dst_mac;
85439c4be9SPieter Jansen van Vuuren 	u32 fw_id;
8667ab160eSEdward Cree 	struct list_head list;
8767ab160eSEdward Cree };
8867ab160eSEdward Cree 
8967ab160eSEdward Cree struct efx_tc_match_fields {
9067ab160eSEdward Cree 	/* L1 */
9167ab160eSEdward Cree 	u32 ingress_port;
9229416025SEdward Cree 	u8 recirc_id; /* mapped from (u32) TC chain_index to smaller space */
936d1c604dSEdward Cree 	/* L2 (inner when encap) */
946d1c604dSEdward Cree 	__be16 eth_proto;
956d1c604dSEdward Cree 	__be16 vlan_tci[2], vlan_proto[2];
966d1c604dSEdward Cree 	u8 eth_saddr[ETH_ALEN], eth_daddr[ETH_ALEN];
97c178dff3SEdward Cree 	/* L3 (when IP) */
98c178dff3SEdward Cree 	u8 ip_proto, ip_tos, ip_ttl;
99c178dff3SEdward Cree 	__be32 src_ip, dst_ip;
100c178dff3SEdward Cree #ifdef CONFIG_IPV6
101c178dff3SEdward Cree 	struct in6_addr src_ip6, dst_ip6;
102c178dff3SEdward Cree #endif
1035ca7ef29SEdward Cree 	bool ip_frag, ip_firstfrag;
1045d1d24daSEdward Cree 	/* L4 */
1055d1d24daSEdward Cree 	__be16 l4_sport, l4_dport; /* Ports (UDP, TCP) */
1065d1d24daSEdward Cree 	__be16 tcp_flags;
1071dfc29beSEdward Cree 	bool tcp_syn_fin_rst; /* true if ANY of SYN/FIN/RST are set */
108b9d5c9b7SEdward Cree 	/* Encap.  The following are *outer* fields.  Note that there are no
109b9d5c9b7SEdward Cree 	 * outer eth (L2) fields; this is because TC doesn't have them.
110b9d5c9b7SEdward Cree 	 */
111b9d5c9b7SEdward Cree 	__be32 enc_src_ip, enc_dst_ip;
112b9d5c9b7SEdward Cree 	struct in6_addr enc_src_ip6, enc_dst_ip6;
113b9d5c9b7SEdward Cree 	u8 enc_ip_tos, enc_ip_ttl;
114b9d5c9b7SEdward Cree 	__be16 enc_sport, enc_dport;
115b9d5c9b7SEdward Cree 	__be32 enc_keyid; /* e.g. VNI, VSID */
1161dfc29beSEdward Cree 	/* Conntrack. */
1171dfc29beSEdward Cree 	u16 ct_state_trk:1, ct_state_est:1;
1181dfc29beSEdward Cree 	u32 ct_mark;
1191dfc29beSEdward Cree 	u16 ct_zone;
120b9d5c9b7SEdward Cree };
121b9d5c9b7SEdward Cree 
efx_tc_match_is_encap(const struct efx_tc_match_fields * mask)122b9d5c9b7SEdward Cree static inline bool efx_tc_match_is_encap(const struct efx_tc_match_fields *mask)
123b9d5c9b7SEdward Cree {
124b9d5c9b7SEdward Cree 	return mask->enc_src_ip || mask->enc_dst_ip ||
125b9d5c9b7SEdward Cree 	       !ipv6_addr_any(&mask->enc_src_ip6) ||
126b9d5c9b7SEdward Cree 	       !ipv6_addr_any(&mask->enc_dst_ip6) || mask->enc_ip_tos ||
127b9d5c9b7SEdward Cree 	       mask->enc_ip_ttl || mask->enc_sport || mask->enc_dport;
128b9d5c9b7SEdward Cree }
129b9d5c9b7SEdward Cree 
1303c9561c0SEdward Cree /**
1313c9561c0SEdward Cree  * enum efx_tc_em_pseudo_type - &struct efx_tc_encap_match pseudo type
1323c9561c0SEdward Cree  *
1333c9561c0SEdward Cree  * These are used to classify "pseudo" encap matches, which don't refer
1343c9561c0SEdward Cree  * to an entry in hardware but rather indicate that a section of the
1353c9561c0SEdward Cree  * match space is in use by another Outer Rule.
1363c9561c0SEdward Cree  *
1373c9561c0SEdward Cree  * @EFX_TC_EM_DIRECT: real HW entry in Outer Rule table; not a pseudo.
1383c9561c0SEdward Cree  *	Hardware index in &struct efx_tc_encap_match.fw_id is valid.
1393c9561c0SEdward Cree  * @EFX_TC_EM_PSEUDO_MASK: registered by an encap match which includes a
140b6583d5eSEdward Cree  *	match on an optional field (currently ip_tos and/or udp_sport),
141b6583d5eSEdward Cree  *	to prevent an overlapping encap match _without_ optional fields.
1423c9561c0SEdward Cree  *	The pseudo encap match may be referenced again by an encap match
143b6583d5eSEdward Cree  *	with different values for these fields, but all masks must match the
144b6583d5eSEdward Cree  *	first (stored in our child_* fields).
145ec1dc6c8SEdward Cree  * @EFX_TC_EM_PSEUDO_OR: registered by an fLHS rule that fits in the OR
146ec1dc6c8SEdward Cree  *	table.  The &struct efx_tc_lhs_rule already holds the HW OR entry.
147ec1dc6c8SEdward Cree  *	Only one reference to this encap match may exist.
1483c9561c0SEdward Cree  */
1493c9561c0SEdward Cree enum efx_tc_em_pseudo_type {
1503c9561c0SEdward Cree 	EFX_TC_EM_DIRECT,
1513c9561c0SEdward Cree 	EFX_TC_EM_PSEUDO_MASK,
152ec1dc6c8SEdward Cree 	EFX_TC_EM_PSEUDO_OR,
1533c9561c0SEdward Cree };
1543c9561c0SEdward Cree 
155b9d5c9b7SEdward Cree struct efx_tc_encap_match {
156b9d5c9b7SEdward Cree 	__be32 src_ip, dst_ip;
157b9d5c9b7SEdward Cree 	struct in6_addr src_ip6, dst_ip6;
158b9d5c9b7SEdward Cree 	__be16 udp_dport;
159b6583d5eSEdward Cree 	__be16 udp_sport, udp_sport_mask;
16056beb35dSEdward Cree 	u8 ip_tos, ip_tos_mask;
161746224cdSEdward Cree 	struct rhash_head linkage;
1622245eb00SEdward Cree 	enum efx_encap_type tun_type;
1633c9561c0SEdward Cree 	u8 child_ip_tos_mask;
164b6583d5eSEdward Cree 	__be16 child_udp_sport_mask;
165746224cdSEdward Cree 	refcount_t ref;
1663c9561c0SEdward Cree 	enum efx_tc_em_pseudo_type type;
167b9d5c9b7SEdward Cree 	u32 fw_id; /* index of this entry in firmware encap match table */
1683c9561c0SEdward Cree 	struct efx_tc_encap_match *pseudo; /* Referenced pseudo EM if needed */
16967ab160eSEdward Cree };
17067ab160eSEdward Cree 
17129416025SEdward Cree struct efx_tc_recirc_id {
17229416025SEdward Cree 	u32 chain_index;
17329416025SEdward Cree 	struct net_device *net_dev;
17429416025SEdward Cree 	struct rhash_head linkage;
17529416025SEdward Cree 	refcount_t ref;
17629416025SEdward Cree 	u8 fw_id; /* index allocated for use in the MAE */
17729416025SEdward Cree };
17829416025SEdward Cree 
17967ab160eSEdward Cree struct efx_tc_match {
18067ab160eSEdward Cree 	struct efx_tc_match_fields value;
18167ab160eSEdward Cree 	struct efx_tc_match_fields mask;
182b9d5c9b7SEdward Cree 	struct efx_tc_encap_match *encap;
18329416025SEdward Cree 	struct efx_tc_recirc_id *rid;
18467ab160eSEdward Cree };
18567ab160eSEdward Cree 
18667ab160eSEdward Cree struct efx_tc_action_set_list {
18767ab160eSEdward Cree 	struct list_head list;
18867ab160eSEdward Cree 	u32 fw_id;
18967ab160eSEdward Cree };
19067ab160eSEdward Cree 
19101ad088fSEdward Cree struct efx_tc_lhs_action {
192ec1dc6c8SEdward Cree 	enum efx_encap_type tun_type;
19301ad088fSEdward Cree 	struct efx_tc_recirc_id *rid;
19401ad088fSEdward Cree 	struct efx_tc_ct_zone *zone;
19501ad088fSEdward Cree 	struct efx_tc_counter_index *count;
19601ad088fSEdward Cree };
19701ad088fSEdward Cree 
19867ab160eSEdward Cree struct efx_tc_flow_rule {
199f54a28a2SEdward Cree 	unsigned long cookie;
200f54a28a2SEdward Cree 	struct rhash_head linkage;
20167ab160eSEdward Cree 	struct efx_tc_match match;
20267ab160eSEdward Cree 	struct efx_tc_action_set_list acts;
203b4da4235SEdward Cree 	struct efx_tc_action_set_list *fallback; /* what to use when unready? */
20467ab160eSEdward Cree 	u32 fw_id;
20567ab160eSEdward Cree };
20667ab160eSEdward Cree 
20701ad088fSEdward Cree struct efx_tc_lhs_rule {
20801ad088fSEdward Cree 	unsigned long cookie;
20901ad088fSEdward Cree 	struct efx_tc_match match;
21001ad088fSEdward Cree 	struct efx_tc_lhs_action lhs_act;
21101ad088fSEdward Cree 	struct rhash_head linkage;
21201ad088fSEdward Cree 	u32 fw_id;
213e4470561SEdward Cree 	bool is_ar; /* Action Rule (for OR-AR-CT-AR sequence) */
21401ad088fSEdward Cree };
21501ad088fSEdward Cree 
21667ab160eSEdward Cree enum efx_tc_rule_prios {
217d902e1a7SEdward Cree 	EFX_TC_PRIO_TC, /* Rule inserted by TC */
21867ab160eSEdward Cree 	EFX_TC_PRIO_DFLT, /* Default switch rule; one of efx_tc_default_rules */
21967ab160eSEdward Cree 	EFX_TC_PRIO__NUM
22067ab160eSEdward Cree };
22167ab160eSEdward Cree 
2223bf969e8SEdward Cree struct efx_tc_table_field_fmt {
2233bf969e8SEdward Cree 	u16 field_id;
2243bf969e8SEdward Cree 	u16 lbn;
2253bf969e8SEdward Cree 	u16 width;
2263bf969e8SEdward Cree 	u8 masking;
2273bf969e8SEdward Cree 	u8 scheme;
2283bf969e8SEdward Cree };
2293bf969e8SEdward Cree 
2303bf969e8SEdward Cree struct efx_tc_table_desc {
2313bf969e8SEdward Cree 	u16 type;
2323bf969e8SEdward Cree 	u16 key_width;
2333bf969e8SEdward Cree 	u16 resp_width;
2343bf969e8SEdward Cree 	u16 n_keys;
2353bf969e8SEdward Cree 	u16 n_resps;
2363bf969e8SEdward Cree 	u16 n_prios;
2373bf969e8SEdward Cree 	u8 flags;
2383bf969e8SEdward Cree 	u8 scheme;
2393bf969e8SEdward Cree 	struct efx_tc_table_field_fmt *keys;
2403bf969e8SEdward Cree 	struct efx_tc_table_field_fmt *resps;
2413bf969e8SEdward Cree };
2423bf969e8SEdward Cree 
2433bf969e8SEdward Cree struct efx_tc_table_ct { /* TABLE_ID_CONNTRACK_TABLE */
2443bf969e8SEdward Cree 	struct efx_tc_table_desc desc;
2453bf969e8SEdward Cree 	bool hooked;
2463bf969e8SEdward Cree 	struct { /* indices of named fields within @desc.keys */
2473bf969e8SEdward Cree 		u8 eth_proto_idx;
2483bf969e8SEdward Cree 		u8 ip_proto_idx;
2493bf969e8SEdward Cree 		u8 src_ip_idx; /* either v4 or v6 */
2503bf969e8SEdward Cree 		u8 dst_ip_idx;
2513bf969e8SEdward Cree 		u8 l4_sport_idx;
2523bf969e8SEdward Cree 		u8 l4_dport_idx;
2533bf969e8SEdward Cree 		u8 zone_idx; /* for TABLE_FIELD_ID_DOMAIN */
2543bf969e8SEdward Cree 	} keys;
2553bf969e8SEdward Cree 	struct { /* indices of named fields within @desc.resps */
2563bf969e8SEdward Cree 		u8 dnat_idx;
2573bf969e8SEdward Cree 		u8 nat_ip_idx;
2583bf969e8SEdward Cree 		u8 l4_natport_idx;
2593bf969e8SEdward Cree 		u8 mark_idx;
2603bf969e8SEdward Cree 		u8 counter_id_idx;
2613bf969e8SEdward Cree 	} resps;
2623bf969e8SEdward Cree };
2633bf969e8SEdward Cree 
26467ab160eSEdward Cree /**
26567ab160eSEdward Cree  * struct efx_tc_state - control plane data for TC offload
26667ab160eSEdward Cree  *
2677ce3e235SEdward Cree  * @caps: MAE capabilities reported by MCDI
2689dc0cad2SEdward Cree  * @block_list: List of &struct efx_tc_block_binding
269f54a28a2SEdward Cree  * @mutex: Used to serialise operations on TC hashtables
27019a0c989SEdward Cree  * @counter_ht: Hashtable of TC counters (FW IDs and counter values)
27119a0c989SEdward Cree  * @counter_id_ht: Hashtable mapping TC counter cookies to counters
272b4da4235SEdward Cree  * @encap_ht: Hashtable of TC encap actions
273439c4be9SPieter Jansen van Vuuren  * @mac_ht: Hashtable of MAC address entries (for pedits)
274746224cdSEdward Cree  * @encap_match_ht: Hashtable of TC encap matches
275f54a28a2SEdward Cree  * @match_action_ht: Hashtable of TC match-action rules
27601ad088fSEdward Cree  * @lhs_rule_ht: Hashtable of TC left-hand (act ct & goto chain) rules
277c3bb5c6aSEdward Cree  * @ct_zone_ht: Hashtable of TC conntrack flowtable bindings
2781909387fSEdward Cree  * @ct_ht: Hashtable of TC conntrack flow entries
2797e5e7d80SEdward Cree  * @neigh_ht: Hashtable of neighbour watches (&struct efx_neigh_binder)
28029416025SEdward Cree  * @recirc_ht: Hashtable of recirculation ID mappings (&struct efx_tc_recirc_id)
28129416025SEdward Cree  * @recirc_ida: Recirculation ID allocator
2823bf969e8SEdward Cree  * @meta_ct: MAE table layout for conntrack table
283e37f3b15SEdward Cree  * @reps_mport_id: MAE port allocated for representor RX
284e37f3b15SEdward Cree  * @reps_filter_uc: VNIC filter for representor unicast RX (promisc)
285e37f3b15SEdward Cree  * @reps_filter_mc: VNIC filter for representor multicast RX (allmulti)
286e37f3b15SEdward Cree  * @reps_mport_vport_id: vport_id for representor RX filters
287e5731274SEdward Cree  * @flush_counters: counters have been stopped, waiting for drain
288e5731274SEdward Cree  * @flush_gen: final generation count per type array as reported by
289e5731274SEdward Cree  *             MC_CMD_MAE_COUNTERS_STREAM_STOP
290e5731274SEdward Cree  * @seen_gen: most recent generation count per type as seen by efx_tc_rx()
291e5731274SEdward Cree  * @flush_wq: wait queue used by efx_mae_stop_counters() to wait for
292e5731274SEdward Cree  *	MAE counters RXQ to finish draining
29367ab160eSEdward Cree  * @dflt: Match-action rules for default switching; at priority
29467ab160eSEdward Cree  *	%EFX_TC_PRIO_DFLT.  Named by *ingress* port
29567ab160eSEdward Cree  * @dflt.pf: rule for traffic ingressing from PF (egresses to wire)
29667ab160eSEdward Cree  * @dflt.wire: rule for traffic ingressing from wire (egresses to PF)
297e16ca7fbSEdward Cree  * @facts: Fallback action-set-lists for unready rules.  Named by *egress* port
298e16ca7fbSEdward Cree  * @facts.pf: action-set-list for unready rules on PF netdev, hence applying to
299e16ca7fbSEdward Cree  *	traffic from wire, and egressing to PF
300e16ca7fbSEdward Cree  * @facts.reps: action-set-list for unready rules on representors, hence
301e16ca7fbSEdward Cree  *	applying to traffic from representees, and egressing to the reps mport
3029dc0cad2SEdward Cree  * @up: have TC datastructures been set up?
30367ab160eSEdward Cree  */
30467ab160eSEdward Cree struct efx_tc_state {
3057ce3e235SEdward Cree 	struct mae_caps *caps;
3069dc0cad2SEdward Cree 	struct list_head block_list;
307f54a28a2SEdward Cree 	struct mutex mutex;
30819a0c989SEdward Cree 	struct rhashtable counter_ht;
30919a0c989SEdward Cree 	struct rhashtable counter_id_ht;
310b4da4235SEdward Cree 	struct rhashtable encap_ht;
311439c4be9SPieter Jansen van Vuuren 	struct rhashtable mac_ht;
312746224cdSEdward Cree 	struct rhashtable encap_match_ht;
313f54a28a2SEdward Cree 	struct rhashtable match_action_ht;
31401ad088fSEdward Cree 	struct rhashtable lhs_rule_ht;
315c3bb5c6aSEdward Cree 	struct rhashtable ct_zone_ht;
3161909387fSEdward Cree 	struct rhashtable ct_ht;
3177e5e7d80SEdward Cree 	struct rhashtable neigh_ht;
31829416025SEdward Cree 	struct rhashtable recirc_ht;
31929416025SEdward Cree 	struct ida recirc_ida;
3203bf969e8SEdward Cree 	struct efx_tc_table_ct meta_ct;
321e37f3b15SEdward Cree 	u32 reps_mport_id, reps_mport_vport_id;
322e37f3b15SEdward Cree 	s32 reps_filter_uc, reps_filter_mc;
323e5731274SEdward Cree 	bool flush_counters;
324e5731274SEdward Cree 	u32 flush_gen[EFX_TC_COUNTER_TYPE_MAX];
325e5731274SEdward Cree 	u32 seen_gen[EFX_TC_COUNTER_TYPE_MAX];
326e5731274SEdward Cree 	wait_queue_head_t flush_wq;
32767ab160eSEdward Cree 	struct {
32867ab160eSEdward Cree 		struct efx_tc_flow_rule pf;
32967ab160eSEdward Cree 		struct efx_tc_flow_rule wire;
33067ab160eSEdward Cree 	} dflt;
331e16ca7fbSEdward Cree 	struct {
332e16ca7fbSEdward Cree 		struct efx_tc_action_set_list pf;
333e16ca7fbSEdward Cree 		struct efx_tc_action_set_list reps;
334e16ca7fbSEdward Cree 	} facts;
3359dc0cad2SEdward Cree 	bool up;
33667ab160eSEdward Cree };
33767ab160eSEdward Cree 
33867ab160eSEdward Cree struct efx_rep;
33967ab160eSEdward Cree 
340b4da4235SEdward Cree enum efx_encap_type efx_tc_indr_netdev_type(struct net_device *net_dev);
3417e5e7d80SEdward Cree struct efx_rep *efx_tc_flower_lookup_efv(struct efx_nic *efx,
3427e5e7d80SEdward Cree 					 struct net_device *dev);
3437e5e7d80SEdward Cree s64 efx_tc_flower_external_mport(struct efx_nic *efx, struct efx_rep *efv);
34467ab160eSEdward Cree int efx_tc_configure_default_rule_rep(struct efx_rep *efv);
34567ab160eSEdward Cree void efx_tc_deconfigure_default_rule(struct efx_nic *efx,
34667ab160eSEdward Cree 				     struct efx_tc_flow_rule *rule);
3479dc0cad2SEdward Cree int efx_tc_flower(struct efx_nic *efx, struct net_device *net_dev,
3489dc0cad2SEdward Cree 		  struct flow_cls_offload *tc, struct efx_rep *efv);
34967ab160eSEdward Cree 
350e37f3b15SEdward Cree int efx_tc_insert_rep_filters(struct efx_nic *efx);
351e37f3b15SEdward Cree void efx_tc_remove_rep_filters(struct efx_nic *efx);
352e37f3b15SEdward Cree 
35367ab160eSEdward Cree int efx_init_tc(struct efx_nic *efx);
35467ab160eSEdward Cree void efx_fini_tc(struct efx_nic *efx);
35567ab160eSEdward Cree 
35667ab160eSEdward Cree int efx_init_struct_tc(struct efx_nic *efx);
35767ab160eSEdward Cree void efx_fini_struct_tc(struct efx_nic *efx);
35867ab160eSEdward Cree 
35967ab160eSEdward Cree #endif /* EFX_TC_H */
360