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