xref: /linux/drivers/net/ethernet/netronome/nfp/flower/main.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2017-2018 Netronome Systems, Inc. */
3 
4 #ifndef __NFP_FLOWER_H__
5 #define __NFP_FLOWER_H__ 1
6 
7 #include "cmsg.h"
8 #include "../nfp_net.h"
9 
10 #include <linux/circ_buf.h>
11 #include <linux/hashtable.h>
12 #include <linux/rhashtable.h>
13 #include <linux/time64.h>
14 #include <linux/types.h>
15 #include <net/flow_offload.h>
16 #include <net/pkt_cls.h>
17 #include <net/pkt_sched.h>
18 #include <net/tcp.h>
19 #include <linux/workqueue.h>
20 #include <linux/idr.h>
21 
22 struct nfp_fl_pre_lag;
23 struct net_device;
24 struct nfp_app;
25 
26 #define NFP_FL_STAT_ID_MU_NUM		GENMASK(31, 22)
27 #define NFP_FL_STAT_ID_STAT		GENMASK(21, 0)
28 
29 #define NFP_FL_STATS_ELEM_RS		sizeof_field(struct nfp_fl_stats_id, \
30 						     init_unalloc)
31 #define NFP_FLOWER_MASK_ENTRY_RS	256
32 #define NFP_FLOWER_MASK_ELEMENT_RS	1
33 #define NFP_FLOWER_MASK_HASH_BITS	10
34 
35 #define NFP_FLOWER_KEY_MAX_LW		32
36 
37 #define NFP_FL_META_FLAG_MANAGE_MASK	BIT(7)
38 
39 #define NFP_FL_MASK_REUSE_TIME_NS	40000
40 #define NFP_FL_MASK_ID_LOCATION		1
41 
42 /* Extra features bitmap. */
43 #define NFP_FL_FEATS_GENEVE		BIT(0)
44 #define NFP_FL_NBI_MTU_SETTING		BIT(1)
45 #define NFP_FL_FEATS_GENEVE_OPT		BIT(2)
46 #define NFP_FL_FEATS_VLAN_PCP		BIT(3)
47 #define NFP_FL_FEATS_VF_RLIM		BIT(4)
48 #define NFP_FL_FEATS_FLOW_MOD		BIT(5)
49 #define NFP_FL_FEATS_PRE_TUN_RULES	BIT(6)
50 #define NFP_FL_FEATS_IPV6_TUN		BIT(7)
51 #define NFP_FL_FEATS_VLAN_QINQ		BIT(8)
52 #define NFP_FL_FEATS_QOS_PPS		BIT(9)
53 #define NFP_FL_FEATS_QOS_METER		BIT(10)
54 #define NFP_FL_FEATS_DECAP_V2		BIT(11)
55 #define NFP_FL_FEATS_TUNNEL_NEIGH_LAG	BIT(12)
56 #define NFP_FL_FEATS_HOST_ACK		BIT(31)
57 
58 #define NFP_FL_ENABLE_FLOW_MERGE	BIT(0)
59 #define NFP_FL_ENABLE_LAG		BIT(1)
60 
61 #define NFP_FL_FEATS_HOST \
62 	(NFP_FL_FEATS_GENEVE | \
63 	NFP_FL_NBI_MTU_SETTING | \
64 	NFP_FL_FEATS_GENEVE_OPT | \
65 	NFP_FL_FEATS_VLAN_PCP | \
66 	NFP_FL_FEATS_VF_RLIM | \
67 	NFP_FL_FEATS_FLOW_MOD | \
68 	NFP_FL_FEATS_PRE_TUN_RULES | \
69 	NFP_FL_FEATS_IPV6_TUN | \
70 	NFP_FL_FEATS_VLAN_QINQ | \
71 	NFP_FL_FEATS_QOS_PPS | \
72 	NFP_FL_FEATS_QOS_METER | \
73 	NFP_FL_FEATS_DECAP_V2 | \
74 	NFP_FL_FEATS_TUNNEL_NEIGH_LAG)
75 
76 struct nfp_fl_mask_id {
77 	struct circ_buf mask_id_free_list;
78 	ktime_t *last_used;
79 	u8 init_unallocated;
80 };
81 
82 struct nfp_fl_stats_id {
83 	struct circ_buf free_list;
84 	u32 init_unalloc;
85 	u8 repeated_em_count;
86 };
87 
88 /**
89  * struct nfp_fl_tunnel_offloads - priv data for tunnel offloads
90  * @offloaded_macs:	Hashtable of the offloaded MAC addresses
91  * @ipv4_off_list:	List of IPv4 addresses to offload
92  * @ipv6_off_list:	List of IPv6 addresses to offload
93  * @ipv4_off_lock:	Lock for the IPv4 address list
94  * @ipv6_off_lock:	Lock for the IPv6 address list
95  * @mac_off_ids:	IDA to manage id assignment for offloaded MACs
96  * @neigh_nb:		Notifier to monitor neighbour state
97  */
98 struct nfp_fl_tunnel_offloads {
99 	struct rhashtable offloaded_macs;
100 	struct list_head ipv4_off_list;
101 	struct list_head ipv6_off_list;
102 	struct mutex ipv4_off_lock;
103 	struct mutex ipv6_off_lock;
104 	struct ida mac_off_ids;
105 	struct notifier_block neigh_nb;
106 };
107 
108 /**
109  * struct nfp_tun_neigh_lag - lag info
110  * @lag_version:	lag version
111  * @lag_instance:	lag instance
112  */
113 struct nfp_tun_neigh_lag {
114 	u8 lag_version[3];
115 	u8 lag_instance;
116 };
117 
118 /**
119  * struct nfp_tun_neigh - basic neighbour data
120  * @dst_addr:	Destination MAC address
121  * @src_addr:	Source MAC address
122  * @port_id:	NFP port to output packet on - associated with source IPv4
123  */
124 struct nfp_tun_neigh {
125 	u8 dst_addr[ETH_ALEN];
126 	u8 src_addr[ETH_ALEN];
127 	__be32 port_id;
128 };
129 
130 /**
131  * struct nfp_tun_neigh_ext - extended neighbour data
132  * @vlan_tpid:	VLAN_TPID match field
133  * @vlan_tci:	VLAN_TCI match field
134  * @host_ctx:	Host context ID to be saved here
135  */
136 struct nfp_tun_neigh_ext {
137 	__be16 vlan_tpid;
138 	__be16 vlan_tci;
139 	__be32 host_ctx;
140 };
141 
142 /**
143  * struct nfp_tun_neigh_v4 - neighbour/route entry on the NFP for IPv4
144  * @dst_ipv4:	Destination IPv4 address
145  * @src_ipv4:	Source IPv4 address
146  * @common:	Neighbour/route common info
147  * @ext:	Neighbour/route extended info
148  * @lag:	lag port info
149  */
150 struct nfp_tun_neigh_v4 {
151 	__be32 dst_ipv4;
152 	__be32 src_ipv4;
153 	struct nfp_tun_neigh common;
154 	struct nfp_tun_neigh_ext ext;
155 	struct nfp_tun_neigh_lag lag;
156 };
157 
158 /**
159  * struct nfp_tun_neigh_v6 - neighbour/route entry on the NFP for IPv6
160  * @dst_ipv6:	Destination IPv6 address
161  * @src_ipv6:	Source IPv6 address
162  * @common:	Neighbour/route common info
163  * @ext:	Neighbour/route extended info
164  * @lag:	lag port info
165  */
166 struct nfp_tun_neigh_v6 {
167 	struct in6_addr dst_ipv6;
168 	struct in6_addr src_ipv6;
169 	struct nfp_tun_neigh common;
170 	struct nfp_tun_neigh_ext ext;
171 	struct nfp_tun_neigh_lag lag;
172 };
173 
174 /**
175  * struct nfp_neigh_entry
176  * @neigh_cookie:	Cookie for hashtable lookup
177  * @ht_node:		rhash_head entry for hashtable
178  * @list_head:		Needed as member of linked_nn_entries list
179  * @payload:		The neighbour info payload
180  * @flow:		Linked flow rule
181  * @is_ipv6:		Flag to indicate if payload is ipv6 or ipv4
182  */
183 struct nfp_neigh_entry {
184 	unsigned long neigh_cookie;
185 	struct rhash_head ht_node;
186 	struct list_head list_head;
187 	char *payload;
188 	struct nfp_predt_entry *flow;
189 	bool is_ipv6;
190 };
191 
192 /**
193  * struct nfp_predt_entry
194  * @list_head:		List head to attach to predt_list
195  * @flow_pay:		Direct link to flow_payload
196  * @nn_list:		List of linked nfp_neigh_entries
197  */
198 struct nfp_predt_entry {
199 	struct list_head list_head;
200 	struct nfp_fl_payload *flow_pay;
201 	struct list_head nn_list;
202 };
203 
204 /**
205  * struct nfp_mtu_conf - manage MTU setting
206  * @portnum:		NFP port number of repr with requested MTU change
207  * @requested_val:	MTU value requested for repr
208  * @ack:		Received ack that MTU has been correctly set
209  * @wait_q:		Wait queue for MTU acknowledgements
210  * @lock:		Lock for setting/reading MTU variables
211  */
212 struct nfp_mtu_conf {
213 	u32 portnum;
214 	unsigned int requested_val;
215 	bool ack;
216 	wait_queue_head_t wait_q;
217 	spinlock_t lock;
218 };
219 
220 /**
221  * struct nfp_fl_lag - Flower APP priv data for link aggregation
222  * @work:		Work queue for writing configs to the HW
223  * @lock:		Lock to protect lag_group_list
224  * @group_list:		List of all master/slave groups offloaded
225  * @ida_handle:		IDA to handle group ids
226  * @pkt_num:		Incremented for each config packet sent
227  * @batch_ver:		Incremented for each batch of config packets
228  * @global_inst:	Instance allocator for groups
229  * @rst_cfg:		Marker to reset HW LAG config
230  * @retrans_skbs:	Cmsgs that could not be processed by HW and require
231  *			retransmission
232  */
233 struct nfp_fl_lag {
234 	struct delayed_work work;
235 	struct mutex lock;
236 	struct list_head group_list;
237 	struct ida ida_handle;
238 	unsigned int pkt_num;
239 	unsigned int batch_ver;
240 	u8 global_inst;
241 	bool rst_cfg;
242 	struct sk_buff_head retrans_skbs;
243 };
244 
245 /**
246  * struct nfp_fl_internal_ports - Flower APP priv data for additional ports
247  * @port_ids:	Assignment of ids to any additional ports
248  * @lock:	Lock for extra ports list
249  */
250 struct nfp_fl_internal_ports {
251 	struct idr port_ids;
252 	spinlock_t lock;
253 };
254 
255 /**
256  * struct nfp_flower_priv - Flower APP per-vNIC priv data
257  * @app:		Back pointer to app
258  * @nn:			Pointer to vNIC
259  * @mask_id_seed:	Seed used for mask hash table
260  * @flower_version:	HW version of flower
261  * @flower_ext_feats:	Bitmap of extra features the HW supports
262  * @flower_en_feats:	Bitmap of features enabled by HW
263  * @stats_ids:		List of free stats ids
264  * @mask_ids:		List of free mask ids
265  * @mask_table:		Hash table used to store masks
266  * @stats_ring_size:	Maximum number of allowed stats ids
267  * @flow_table:		Hash table used to store flower rules
268  * @stats:		Stored stats updates for flower rules
269  * @stats_lock:		Lock for flower rule stats updates
270  * @stats_ctx_table:	Hash table to map stats contexts to its flow rule
271  * @cmsg_work:		Workqueue for control messages processing
272  * @cmsg_skbs_high:	List of higher priority skbs for control message
273  *			processing
274  * @cmsg_skbs_low:	List of lower priority skbs for control message
275  *			processing
276  * @tun:		Tunnel offload data
277  * @reify_replies:	atomically stores the number of replies received
278  *			from firmware for repr reify
279  * @reify_wait_queue:	wait queue for repr reify response counting
280  * @mtu_conf:		Configuration of repr MTU value
281  * @nfp_lag:		Link aggregation data block
282  * @indr_block_cb_priv:	List of priv data passed to indirect block cbs
283  * @non_repr_priv:	List of offloaded non-repr ports and their priv data
284  * @active_mem_unit:	Current active memory unit for flower rules
285  * @total_mem_units:	Total number of available memory units for flower rules
286  * @internal_ports:	Internal port ids used in offloaded rules
287  * @qos_stats_work:	Workqueue for qos stats processing
288  * @qos_rate_limiters:	Current active qos rate limiters
289  * @qos_stats_lock:	Lock on qos stats updates
290  * @meter_stats_lock:   Lock on meter stats updates
291  * @meter_table:	Hash table used to store the meter table
292  * @pre_tun_rule_cnt:	Number of pre-tunnel rules offloaded
293  * @merge_table:	Hash table to store merged flows
294  * @ct_zone_table:	Hash table used to store the different zones
295  * @ct_zone_wc:		Special zone entry for wildcarded zone matches
296  * @ct_map_table:	Hash table used to referennce ct flows
297  * @predt_list:		List to keep track of decap pretun flows
298  * @neigh_table:	Table to keep track of neighbor entries
299  * @predt_lock:		Lock to serialise predt/neigh table updates
300  * @nfp_fl_lock:	Lock to protect the flow offload operation
301  */
302 struct nfp_flower_priv {
303 	struct nfp_app *app;
304 	struct nfp_net *nn;
305 	u32 mask_id_seed;
306 	u64 flower_version;
307 	u64 flower_ext_feats;
308 	u8 flower_en_feats;
309 	struct nfp_fl_stats_id stats_ids;
310 	struct nfp_fl_mask_id mask_ids;
311 	DECLARE_HASHTABLE(mask_table, NFP_FLOWER_MASK_HASH_BITS);
312 	u32 stats_ring_size;
313 	struct rhashtable flow_table;
314 	struct nfp_fl_stats *stats;
315 	spinlock_t stats_lock; /* lock stats */
316 	struct rhashtable stats_ctx_table;
317 	struct work_struct cmsg_work;
318 	struct sk_buff_head cmsg_skbs_high;
319 	struct sk_buff_head cmsg_skbs_low;
320 	struct nfp_fl_tunnel_offloads tun;
321 	atomic_t reify_replies;
322 	wait_queue_head_t reify_wait_queue;
323 	struct nfp_mtu_conf mtu_conf;
324 	struct nfp_fl_lag nfp_lag;
325 	struct list_head indr_block_cb_priv;
326 	struct list_head non_repr_priv;
327 	unsigned int active_mem_unit;
328 	unsigned int total_mem_units;
329 	struct nfp_fl_internal_ports internal_ports;
330 	struct delayed_work qos_stats_work;
331 	unsigned int qos_rate_limiters;
332 	spinlock_t qos_stats_lock; /* Protect the qos stats */
333 	struct mutex meter_stats_lock; /* Protect the meter stats */
334 	struct rhashtable meter_table;
335 	int pre_tun_rule_cnt;
336 	struct rhashtable merge_table;
337 	struct rhashtable ct_zone_table;
338 	struct nfp_fl_ct_zone_entry *ct_zone_wc;
339 	struct rhashtable ct_map_table;
340 	struct list_head predt_list;
341 	struct rhashtable neigh_table;
342 	spinlock_t predt_lock; /* Lock to serialise predt/neigh table updates */
343 	struct mutex nfp_fl_lock; /* Protect the flow operation */
344 };
345 
346 /**
347  * struct nfp_fl_qos - Flower APP priv data for quality of service
348  * @netdev_port_id:	NFP port number of repr with qos info
349  * @curr_stats:		Currently stored stats updates for qos info
350  * @prev_stats:		Previously stored updates for qos info
351  * @last_update:	Stored time when last stats were updated
352  */
353 struct nfp_fl_qos {
354 	u32 netdev_port_id;
355 	struct nfp_stat_pair curr_stats;
356 	struct nfp_stat_pair prev_stats;
357 	u64 last_update;
358 };
359 
360 /**
361  * struct nfp_flower_repr_priv - Flower APP per-repr priv data
362  * @nfp_repr:		Back pointer to nfp_repr
363  * @lag_port_flags:	Extended port flags to record lag state of repr
364  * @mac_offloaded:	Flag indicating a MAC address is offloaded for repr
365  * @offloaded_mac_addr:	MAC address that has been offloaded for repr
366  * @block_shared:	Flag indicating if offload applies to shared blocks
367  * @mac_list:		List entry of reprs that share the same offloaded MAC
368  * @qos_table:		Stored info on filters implementing qos
369  * @on_bridge:		Indicates if the repr is attached to a bridge
370  */
371 struct nfp_flower_repr_priv {
372 	struct nfp_repr *nfp_repr;
373 	unsigned long lag_port_flags;
374 	bool mac_offloaded;
375 	u8 offloaded_mac_addr[ETH_ALEN];
376 	bool block_shared;
377 	struct list_head mac_list;
378 	struct nfp_fl_qos qos_table;
379 	bool on_bridge;
380 };
381 
382 /**
383  * struct nfp_flower_non_repr_priv - Priv data for non-repr offloaded ports
384  * @list:		List entry of offloaded reprs
385  * @netdev:		Pointer to non-repr net_device
386  * @ref_count:		Number of references held for this priv data
387  * @mac_offloaded:	Flag indicating a MAC address is offloaded for device
388  * @offloaded_mac_addr:	MAC address that has been offloaded for dev
389  */
390 struct nfp_flower_non_repr_priv {
391 	struct list_head list;
392 	struct net_device *netdev;
393 	int ref_count;
394 	bool mac_offloaded;
395 	u8 offloaded_mac_addr[ETH_ALEN];
396 };
397 
398 struct nfp_fl_key_ls {
399 	u32 key_layer_two;
400 	u8 key_layer;
401 	int key_size;
402 };
403 
404 struct nfp_fl_rule_metadata {
405 	u8 key_len;
406 	u8 mask_len;
407 	u8 act_len;
408 	u8 flags;
409 	__be32 host_ctx_id;
410 	__be64 host_cookie __packed;
411 	__be64 flow_version __packed;
412 	__be32 shortcut;
413 };
414 
415 struct nfp_fl_stats {
416 	u64 pkts;
417 	u64 bytes;
418 	u64 used;
419 };
420 
421 /**
422  * struct nfp_ipv6_addr_entry - cached IPv6 addresses
423  * @ipv6_addr:	IP address
424  * @ref_count:	number of rules currently using this IP
425  * @list:	list pointer
426  */
427 struct nfp_ipv6_addr_entry {
428 	struct in6_addr ipv6_addr;
429 	int ref_count;
430 	struct list_head list;
431 };
432 
433 struct nfp_fl_payload {
434 	struct nfp_fl_rule_metadata meta;
435 	unsigned long tc_flower_cookie;
436 	struct rhash_head fl_node;
437 	struct rcu_head rcu;
438 	__be32 nfp_tun_ipv4_addr;
439 	struct nfp_ipv6_addr_entry *nfp_tun_ipv6;
440 	struct net_device *ingress_dev;
441 	char *unmasked_data;
442 	char *mask_data;
443 	char *action_data;
444 	struct list_head linked_flows;
445 	bool in_hw;
446 	struct {
447 		struct nfp_predt_entry *predt;
448 		struct net_device *dev;
449 		__be16 vlan_tpid;
450 		__be16 vlan_tci;
451 		__be16 port_idx;
452 		u8 loc_mac[ETH_ALEN];
453 		u8 rem_mac[ETH_ALEN];
454 		bool is_ipv6;
455 	} pre_tun_rule;
456 };
457 
458 struct nfp_fl_payload_link {
459 	/* A link contains a pointer to a merge flow and an associated sub_flow.
460 	 * Each merge flow will feature in 2 links to its underlying sub_flows.
461 	 * A sub_flow will have at least 1 link to a merge flow or more if it
462 	 * has been used to create multiple merge flows.
463 	 *
464 	 * For a merge flow, 'linked_flows' in its nfp_fl_payload struct lists
465 	 * all links to sub_flows (sub_flow.flow) via merge.list.
466 	 * For a sub_flow, 'linked_flows' gives all links to merge flows it has
467 	 * formed (merge_flow.flow) via sub_flow.list.
468 	 */
469 	struct {
470 		struct list_head list;
471 		struct nfp_fl_payload *flow;
472 	} merge_flow, sub_flow;
473 };
474 
475 extern const struct rhashtable_params nfp_flower_table_params;
476 extern const struct rhashtable_params merge_table_params;
477 extern const struct rhashtable_params neigh_table_params;
478 
479 struct nfp_merge_info {
480 	u64 parent_ctx;
481 	struct rhash_head ht_node;
482 };
483 
484 struct nfp_fl_stats_frame {
485 	__be32 stats_con_id;
486 	__be32 pkt_count;
487 	__be64 byte_count;
488 	__be64 stats_cookie;
489 };
490 
491 struct nfp_meter_stats_entry {
492 	u64 pkts;
493 	u64 bytes;
494 	u64 drops;
495 };
496 
497 struct nfp_meter_entry {
498 	struct rhash_head ht_node;
499 	u32 meter_id;
500 	bool bps;
501 	u32 rate;
502 	u32 burst;
503 	u64 used;
504 	struct nfp_meter_stats {
505 		u64 update;
506 		struct nfp_meter_stats_entry curr;
507 		struct nfp_meter_stats_entry prev;
508 	} stats;
509 };
510 
511 enum nfp_meter_op {
512 	NFP_METER_ADD,
513 	NFP_METER_DEL,
514 };
515 
516 static inline bool
nfp_flower_internal_port_can_offload(struct nfp_app * app,struct net_device * netdev)517 nfp_flower_internal_port_can_offload(struct nfp_app *app,
518 				     struct net_device *netdev)
519 {
520 	struct nfp_flower_priv *app_priv = app->priv;
521 
522 	if (!(app_priv->flower_en_feats & NFP_FL_ENABLE_FLOW_MERGE))
523 		return false;
524 	if (!netdev->rtnl_link_ops)
525 		return false;
526 	if (!strcmp(netdev->rtnl_link_ops->kind, "openvswitch"))
527 		return true;
528 
529 	return false;
530 }
531 
532 /* The address of the merged flow acts as its cookie.
533  * Cookies supplied to us by TC flower are also addresses to allocated
534  * memory and thus this scheme should not generate any collisions.
535  */
nfp_flower_is_merge_flow(struct nfp_fl_payload * flow_pay)536 static inline bool nfp_flower_is_merge_flow(struct nfp_fl_payload *flow_pay)
537 {
538 	return flow_pay->tc_flower_cookie == (unsigned long)flow_pay;
539 }
540 
nfp_flower_is_supported_bridge(struct net_device * netdev)541 static inline bool nfp_flower_is_supported_bridge(struct net_device *netdev)
542 {
543 	return netif_is_ovs_master(netdev);
544 }
545 
546 int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count,
547 			     unsigned int host_ctx_split);
548 void nfp_flower_metadata_cleanup(struct nfp_app *app);
549 
550 int nfp_flower_setup_tc(struct nfp_app *app, struct net_device *netdev,
551 			enum tc_setup_type type, void *type_data);
552 int nfp_flower_merge_offloaded_flows(struct nfp_app *app,
553 				     struct nfp_fl_payload *sub_flow1,
554 				     struct nfp_fl_payload *sub_flow2);
555 void
556 nfp_flower_compile_meta(struct nfp_flower_meta_tci *ext,
557 			struct nfp_flower_meta_tci *msk, u8 key_type);
558 void
559 nfp_flower_compile_tci(struct nfp_flower_meta_tci *ext,
560 		       struct nfp_flower_meta_tci *msk,
561 		       struct flow_rule *rule);
562 void
563 nfp_flower_compile_ext_meta(struct nfp_flower_ext_meta *frame, u32 key_ext);
564 int
565 nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port,
566 			bool mask_version, enum nfp_flower_tun_type tun_type,
567 			struct netlink_ext_ack *extack);
568 void
569 nfp_flower_compile_mac(struct nfp_flower_mac_mpls *ext,
570 		       struct nfp_flower_mac_mpls *msk,
571 		       struct flow_rule *rule);
572 int
573 nfp_flower_compile_mpls(struct nfp_flower_mac_mpls *ext,
574 			struct nfp_flower_mac_mpls *msk,
575 			struct flow_rule *rule,
576 			struct netlink_ext_ack *extack);
577 void
578 nfp_flower_compile_tport(struct nfp_flower_tp_ports *ext,
579 			 struct nfp_flower_tp_ports *msk,
580 			 struct flow_rule *rule);
581 void
582 nfp_flower_compile_vlan(struct nfp_flower_vlan *ext,
583 			struct nfp_flower_vlan *msk,
584 			struct flow_rule *rule);
585 void
586 nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *ext,
587 			struct nfp_flower_ipv4 *msk, struct flow_rule *rule);
588 void
589 nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *ext,
590 			struct nfp_flower_ipv6 *msk, struct flow_rule *rule);
591 void
592 nfp_flower_compile_geneve_opt(u8 *ext, u8 *msk, struct flow_rule *rule);
593 void
594 nfp_flower_compile_ipv4_gre_tun(struct nfp_flower_ipv4_gre_tun *ext,
595 				struct nfp_flower_ipv4_gre_tun *msk,
596 				struct flow_rule *rule);
597 void
598 nfp_flower_compile_ipv4_udp_tun(struct nfp_flower_ipv4_udp_tun *ext,
599 				struct nfp_flower_ipv4_udp_tun *msk,
600 				struct flow_rule *rule);
601 void
602 nfp_flower_compile_ipv6_udp_tun(struct nfp_flower_ipv6_udp_tun *ext,
603 				struct nfp_flower_ipv6_udp_tun *msk,
604 				struct flow_rule *rule);
605 void
606 nfp_flower_compile_ipv6_gre_tun(struct nfp_flower_ipv6_gre_tun *ext,
607 				struct nfp_flower_ipv6_gre_tun *msk,
608 				struct flow_rule *rule);
609 int nfp_flower_compile_flow_match(struct nfp_app *app,
610 				  struct flow_rule *rule,
611 				  struct nfp_fl_key_ls *key_ls,
612 				  struct net_device *netdev,
613 				  struct nfp_fl_payload *nfp_flow,
614 				  enum nfp_flower_tun_type tun_type,
615 				  struct netlink_ext_ack *extack);
616 int nfp_flower_compile_action(struct nfp_app *app,
617 			      struct flow_rule *rule,
618 			      struct net_device *netdev,
619 			      struct nfp_fl_payload *nfp_flow,
620 			      struct netlink_ext_ack *extack);
621 int nfp_compile_flow_metadata(struct nfp_app *app, u32 cookie,
622 			      struct nfp_fl_payload *nfp_flow,
623 			      struct net_device *netdev,
624 			      struct netlink_ext_ack *extack);
625 void __nfp_modify_flow_metadata(struct nfp_flower_priv *priv,
626 				struct nfp_fl_payload *nfp_flow);
627 int nfp_modify_flow_metadata(struct nfp_app *app,
628 			     struct nfp_fl_payload *nfp_flow);
629 
630 struct nfp_fl_payload *
631 nfp_flower_search_fl_table(struct nfp_app *app, unsigned long tc_flower_cookie,
632 			   struct net_device *netdev);
633 struct nfp_fl_payload *
634 nfp_flower_get_fl_payload_from_ctx(struct nfp_app *app, u32 ctx_id);
635 struct nfp_fl_payload *
636 nfp_flower_remove_fl_table(struct nfp_app *app, unsigned long tc_flower_cookie);
637 
638 void nfp_flower_rx_flow_stats(struct nfp_app *app, struct sk_buff *skb);
639 
640 int nfp_tunnel_config_start(struct nfp_app *app);
641 void nfp_tunnel_config_stop(struct nfp_app *app);
642 int nfp_tunnel_mac_event_handler(struct nfp_app *app,
643 				 struct net_device *netdev,
644 				 unsigned long event, void *ptr);
645 void nfp_tunnel_del_ipv4_off(struct nfp_app *app, __be32 ipv4);
646 void nfp_tunnel_add_ipv4_off(struct nfp_app *app, __be32 ipv4);
647 void
648 nfp_tunnel_put_ipv6_off(struct nfp_app *app, struct nfp_ipv6_addr_entry *entry);
649 struct nfp_ipv6_addr_entry *
650 nfp_tunnel_add_ipv6_off(struct nfp_app *app, struct in6_addr *ipv6);
651 void nfp_tunnel_request_route_v4(struct nfp_app *app, struct sk_buff *skb);
652 void nfp_tunnel_request_route_v6(struct nfp_app *app, struct sk_buff *skb);
653 void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb);
654 void nfp_tunnel_keep_alive_v6(struct nfp_app *app, struct sk_buff *skb);
655 void nfp_flower_lag_init(struct nfp_fl_lag *lag);
656 void nfp_flower_lag_cleanup(struct nfp_fl_lag *lag);
657 int nfp_flower_lag_reset(struct nfp_fl_lag *lag);
658 int nfp_flower_lag_netdev_event(struct nfp_flower_priv *priv,
659 				struct net_device *netdev,
660 				unsigned long event, void *ptr);
661 bool nfp_flower_lag_unprocessed_msg(struct nfp_app *app, struct sk_buff *skb);
662 int nfp_flower_lag_populate_pre_action(struct nfp_app *app,
663 				       struct net_device *master,
664 				       struct nfp_fl_pre_lag *pre_act,
665 				       struct netlink_ext_ack *extack);
666 int nfp_flower_lag_get_output_id(struct nfp_app *app,
667 				 struct net_device *master);
668 void nfp_flower_lag_get_info_from_netdev(struct nfp_app *app,
669 					 struct net_device *netdev,
670 					 struct nfp_tun_neigh_lag *lag);
671 void nfp_flower_qos_init(struct nfp_app *app);
672 void nfp_flower_qos_cleanup(struct nfp_app *app);
673 int nfp_flower_setup_qos_offload(struct nfp_app *app, struct net_device *netdev,
674 				 struct tc_cls_matchall_offload *flow);
675 void nfp_flower_stats_rlim_reply(struct nfp_app *app, struct sk_buff *skb);
676 int nfp_flower_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch, void *cb_priv,
677 				enum tc_setup_type type, void *type_data,
678 				void *data,
679 				void (*cleanup)(struct flow_block_cb *block_cb));
680 void nfp_flower_setup_indr_tc_release(void *cb_priv);
681 
682 void
683 __nfp_flower_non_repr_priv_get(struct nfp_flower_non_repr_priv *non_repr_priv);
684 struct nfp_flower_non_repr_priv *
685 nfp_flower_non_repr_priv_get(struct nfp_app *app, struct net_device *netdev);
686 void
687 __nfp_flower_non_repr_priv_put(struct nfp_flower_non_repr_priv *non_repr_priv);
688 void
689 nfp_flower_non_repr_priv_put(struct nfp_app *app, struct net_device *netdev);
690 u32 nfp_flower_get_port_id_from_netdev(struct nfp_app *app,
691 				       struct net_device *netdev);
692 void nfp_tun_link_and_update_nn_entries(struct nfp_app *app,
693 					struct nfp_predt_entry *predt);
694 void nfp_tun_unlink_and_update_nn_entries(struct nfp_app *app,
695 					  struct nfp_predt_entry *predt);
696 int nfp_flower_xmit_pre_tun_flow(struct nfp_app *app,
697 				 struct nfp_fl_payload *flow);
698 int nfp_flower_xmit_pre_tun_del_flow(struct nfp_app *app,
699 				     struct nfp_fl_payload *flow);
700 
701 struct nfp_fl_payload *
702 nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer);
703 int nfp_flower_calculate_key_layers(struct nfp_app *app,
704 				    struct net_device *netdev,
705 				    struct nfp_fl_key_ls *ret_key_ls,
706 				    struct flow_rule *flow,
707 				    enum nfp_flower_tun_type *tun_type,
708 				    struct netlink_ext_ack *extack);
709 void
710 nfp_flower_del_linked_merge_flows(struct nfp_app *app,
711 				  struct nfp_fl_payload *sub_flow);
712 int
713 nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow,
714 		     u8 mtype);
715 void
716 nfp_flower_update_merge_stats(struct nfp_app *app,
717 			      struct nfp_fl_payload *sub_flow);
718 
719 int nfp_setup_tc_act_offload(struct nfp_app *app,
720 			     struct flow_offload_action *fl_act);
721 int nfp_init_meter_table(struct nfp_app *app);
722 void nfp_flower_stats_meter_request_all(struct nfp_flower_priv *fl_priv);
723 void nfp_act_stats_reply(struct nfp_app *app, void *pmsg);
724 int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress,
725 				  bool pps, u32 id, u32 rate, u32 burst);
726 int nfp_flower_setup_meter_entry(struct nfp_app *app,
727 				 const struct flow_action_entry *action,
728 				 enum nfp_meter_op op,
729 				 u32 meter_id);
730 struct nfp_meter_entry *
731 nfp_flower_search_meter_entry(struct nfp_app *app, u32 meter_id);
732 #endif
733