• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * @nfp_fl_lock:	Lock to protect the flow offload operation
285  */
286 struct nfp_flower_priv {
287 	struct nfp_app *app;
288 	struct nfp_net *nn;
289 	u32 mask_id_seed;
290 	u64 flower_version;
291 	u64 flower_ext_feats;
292 	u8 flower_en_feats;
293 	struct nfp_fl_stats_id stats_ids;
294 	struct nfp_fl_mask_id mask_ids;
295 	DECLARE_HASHTABLE(mask_table, NFP_FLOWER_MASK_HASH_BITS);
296 	u32 stats_ring_size;
297 	struct rhashtable flow_table;
298 	struct nfp_fl_stats *stats;
299 	spinlock_t stats_lock; /* lock stats */
300 	struct rhashtable stats_ctx_table;
301 	struct work_struct cmsg_work;
302 	struct sk_buff_head cmsg_skbs_high;
303 	struct sk_buff_head cmsg_skbs_low;
304 	struct nfp_fl_tunnel_offloads tun;
305 	atomic_t reify_replies;
306 	wait_queue_head_t reify_wait_queue;
307 	struct nfp_mtu_conf mtu_conf;
308 	struct nfp_fl_lag nfp_lag;
309 	struct list_head indr_block_cb_priv;
310 	struct list_head non_repr_priv;
311 	unsigned int active_mem_unit;
312 	unsigned int total_mem_units;
313 	struct nfp_fl_internal_ports internal_ports;
314 	struct delayed_work qos_stats_work;
315 	unsigned int qos_rate_limiters;
316 	spinlock_t qos_stats_lock; /* Protect the qos stats */
317 	struct mutex meter_stats_lock; /* Protect the meter stats */
318 	struct rhashtable meter_table;
319 	int pre_tun_rule_cnt;
320 	struct rhashtable merge_table;
321 	struct rhashtable ct_zone_table;
322 	struct nfp_fl_ct_zone_entry *ct_zone_wc;
323 	struct rhashtable ct_map_table;
324 	struct list_head predt_list;
325 	struct rhashtable neigh_table;
326 	spinlock_t predt_lock; /* Lock to serialise predt/neigh table updates */
327 	struct mutex nfp_fl_lock; /* Protect the flow operation */
328 };
329 
330 /**
331  * struct nfp_fl_qos - Flower APP priv data for quality of service
332  * @netdev_port_id:	NFP port number of repr with qos info
333  * @curr_stats:		Currently stored stats updates for qos info
334  * @prev_stats:		Previously stored updates for qos info
335  * @last_update:	Stored time when last stats were updated
336  */
337 struct nfp_fl_qos {
338 	u32 netdev_port_id;
339 	struct nfp_stat_pair curr_stats;
340 	struct nfp_stat_pair prev_stats;
341 	u64 last_update;
342 };
343 
344 /**
345  * struct nfp_flower_repr_priv - Flower APP per-repr priv data
346  * @nfp_repr:		Back pointer to nfp_repr
347  * @lag_port_flags:	Extended port flags to record lag state of repr
348  * @mac_offloaded:	Flag indicating a MAC address is offloaded for repr
349  * @offloaded_mac_addr:	MAC address that has been offloaded for repr
350  * @block_shared:	Flag indicating if offload applies to shared blocks
351  * @mac_list:		List entry of reprs that share the same offloaded MAC
352  * @qos_table:		Stored info on filters implementing qos
353  * @on_bridge:		Indicates if the repr is attached to a bridge
354  */
355 struct nfp_flower_repr_priv {
356 	struct nfp_repr *nfp_repr;
357 	unsigned long lag_port_flags;
358 	bool mac_offloaded;
359 	u8 offloaded_mac_addr[ETH_ALEN];
360 	bool block_shared;
361 	struct list_head mac_list;
362 	struct nfp_fl_qos qos_table;
363 	bool on_bridge;
364 };
365 
366 /**
367  * struct nfp_flower_non_repr_priv - Priv data for non-repr offloaded ports
368  * @list:		List entry of offloaded reprs
369  * @netdev:		Pointer to non-repr net_device
370  * @ref_count:		Number of references held for this priv data
371  * @mac_offloaded:	Flag indicating a MAC address is offloaded for device
372  * @offloaded_mac_addr:	MAC address that has been offloaded for dev
373  */
374 struct nfp_flower_non_repr_priv {
375 	struct list_head list;
376 	struct net_device *netdev;
377 	int ref_count;
378 	bool mac_offloaded;
379 	u8 offloaded_mac_addr[ETH_ALEN];
380 };
381 
382 struct nfp_fl_key_ls {
383 	u32 key_layer_two;
384 	u8 key_layer;
385 	int key_size;
386 };
387 
388 struct nfp_fl_rule_metadata {
389 	u8 key_len;
390 	u8 mask_len;
391 	u8 act_len;
392 	u8 flags;
393 	__be32 host_ctx_id;
394 	__be64 host_cookie __packed;
395 	__be64 flow_version __packed;
396 	__be32 shortcut;
397 };
398 
399 struct nfp_fl_stats {
400 	u64 pkts;
401 	u64 bytes;
402 	u64 used;
403 };
404 
405 /**
406  * struct nfp_ipv6_addr_entry - cached IPv6 addresses
407  * @ipv6_addr:	IP address
408  * @ref_count:	number of rules currently using this IP
409  * @list:	list pointer
410  */
411 struct nfp_ipv6_addr_entry {
412 	struct in6_addr ipv6_addr;
413 	int ref_count;
414 	struct list_head list;
415 };
416 
417 struct nfp_fl_payload {
418 	struct nfp_fl_rule_metadata meta;
419 	unsigned long tc_flower_cookie;
420 	struct rhash_head fl_node;
421 	struct rcu_head rcu;
422 	__be32 nfp_tun_ipv4_addr;
423 	struct nfp_ipv6_addr_entry *nfp_tun_ipv6;
424 	struct net_device *ingress_dev;
425 	char *unmasked_data;
426 	char *mask_data;
427 	char *action_data;
428 	struct list_head linked_flows;
429 	bool in_hw;
430 	struct {
431 		struct nfp_predt_entry *predt;
432 		struct net_device *dev;
433 		__be16 vlan_tpid;
434 		__be16 vlan_tci;
435 		__be16 port_idx;
436 		u8 loc_mac[ETH_ALEN];
437 		u8 rem_mac[ETH_ALEN];
438 		bool is_ipv6;
439 	} pre_tun_rule;
440 };
441 
442 struct nfp_fl_payload_link {
443 	/* A link contains a pointer to a merge flow and an associated sub_flow.
444 	 * Each merge flow will feature in 2 links to its underlying sub_flows.
445 	 * A sub_flow will have at least 1 link to a merge flow or more if it
446 	 * has been used to create multiple merge flows.
447 	 *
448 	 * For a merge flow, 'linked_flows' in its nfp_fl_payload struct lists
449 	 * all links to sub_flows (sub_flow.flow) via merge.list.
450 	 * For a sub_flow, 'linked_flows' gives all links to merge flows it has
451 	 * formed (merge_flow.flow) via sub_flow.list.
452 	 */
453 	struct {
454 		struct list_head list;
455 		struct nfp_fl_payload *flow;
456 	} merge_flow, sub_flow;
457 };
458 
459 extern const struct rhashtable_params nfp_flower_table_params;
460 extern const struct rhashtable_params merge_table_params;
461 extern const struct rhashtable_params neigh_table_params;
462 
463 struct nfp_merge_info {
464 	u64 parent_ctx;
465 	struct rhash_head ht_node;
466 };
467 
468 struct nfp_fl_stats_frame {
469 	__be32 stats_con_id;
470 	__be32 pkt_count;
471 	__be64 byte_count;
472 	__be64 stats_cookie;
473 };
474 
475 struct nfp_meter_stats_entry {
476 	u64 pkts;
477 	u64 bytes;
478 	u64 drops;
479 };
480 
481 struct nfp_meter_entry {
482 	struct rhash_head ht_node;
483 	u32 meter_id;
484 	bool bps;
485 	u32 rate;
486 	u32 burst;
487 	u64 used;
488 	struct nfp_meter_stats {
489 		u64 update;
490 		struct nfp_meter_stats_entry curr;
491 		struct nfp_meter_stats_entry prev;
492 	} stats;
493 };
494 
495 enum nfp_meter_op {
496 	NFP_METER_ADD,
497 	NFP_METER_DEL,
498 };
499 
500 static inline bool
nfp_flower_internal_port_can_offload(struct nfp_app * app,struct net_device * netdev)501 nfp_flower_internal_port_can_offload(struct nfp_app *app,
502 				     struct net_device *netdev)
503 {
504 	struct nfp_flower_priv *app_priv = app->priv;
505 
506 	if (!(app_priv->flower_en_feats & NFP_FL_ENABLE_FLOW_MERGE))
507 		return false;
508 	if (!netdev->rtnl_link_ops)
509 		return false;
510 	if (!strcmp(netdev->rtnl_link_ops->kind, "openvswitch"))
511 		return true;
512 
513 	return false;
514 }
515 
516 /* The address of the merged flow acts as its cookie.
517  * Cookies supplied to us by TC flower are also addresses to allocated
518  * memory and thus this scheme should not generate any collisions.
519  */
nfp_flower_is_merge_flow(struct nfp_fl_payload * flow_pay)520 static inline bool nfp_flower_is_merge_flow(struct nfp_fl_payload *flow_pay)
521 {
522 	return flow_pay->tc_flower_cookie == (unsigned long)flow_pay;
523 }
524 
nfp_flower_is_supported_bridge(struct net_device * netdev)525 static inline bool nfp_flower_is_supported_bridge(struct net_device *netdev)
526 {
527 	return netif_is_ovs_master(netdev);
528 }
529 
530 int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count,
531 			     unsigned int host_ctx_split);
532 void nfp_flower_metadata_cleanup(struct nfp_app *app);
533 
534 int nfp_flower_setup_tc(struct nfp_app *app, struct net_device *netdev,
535 			enum tc_setup_type type, void *type_data);
536 int nfp_flower_merge_offloaded_flows(struct nfp_app *app,
537 				     struct nfp_fl_payload *sub_flow1,
538 				     struct nfp_fl_payload *sub_flow2);
539 void
540 nfp_flower_compile_meta(struct nfp_flower_meta_tci *ext,
541 			struct nfp_flower_meta_tci *msk, u8 key_type);
542 void
543 nfp_flower_compile_tci(struct nfp_flower_meta_tci *ext,
544 		       struct nfp_flower_meta_tci *msk,
545 		       struct flow_rule *rule);
546 void
547 nfp_flower_compile_ext_meta(struct nfp_flower_ext_meta *frame, u32 key_ext);
548 int
549 nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port,
550 			bool mask_version, enum nfp_flower_tun_type tun_type,
551 			struct netlink_ext_ack *extack);
552 void
553 nfp_flower_compile_mac(struct nfp_flower_mac_mpls *ext,
554 		       struct nfp_flower_mac_mpls *msk,
555 		       struct flow_rule *rule);
556 int
557 nfp_flower_compile_mpls(struct nfp_flower_mac_mpls *ext,
558 			struct nfp_flower_mac_mpls *msk,
559 			struct flow_rule *rule,
560 			struct netlink_ext_ack *extack);
561 void
562 nfp_flower_compile_tport(struct nfp_flower_tp_ports *ext,
563 			 struct nfp_flower_tp_ports *msk,
564 			 struct flow_rule *rule);
565 void
566 nfp_flower_compile_vlan(struct nfp_flower_vlan *ext,
567 			struct nfp_flower_vlan *msk,
568 			struct flow_rule *rule);
569 void
570 nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *ext,
571 			struct nfp_flower_ipv4 *msk, struct flow_rule *rule);
572 void
573 nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *ext,
574 			struct nfp_flower_ipv6 *msk, struct flow_rule *rule);
575 void
576 nfp_flower_compile_geneve_opt(u8 *ext, u8 *msk, struct flow_rule *rule);
577 void
578 nfp_flower_compile_ipv4_gre_tun(struct nfp_flower_ipv4_gre_tun *ext,
579 				struct nfp_flower_ipv4_gre_tun *msk,
580 				struct flow_rule *rule);
581 void
582 nfp_flower_compile_ipv4_udp_tun(struct nfp_flower_ipv4_udp_tun *ext,
583 				struct nfp_flower_ipv4_udp_tun *msk,
584 				struct flow_rule *rule);
585 void
586 nfp_flower_compile_ipv6_udp_tun(struct nfp_flower_ipv6_udp_tun *ext,
587 				struct nfp_flower_ipv6_udp_tun *msk,
588 				struct flow_rule *rule);
589 void
590 nfp_flower_compile_ipv6_gre_tun(struct nfp_flower_ipv6_gre_tun *ext,
591 				struct nfp_flower_ipv6_gre_tun *msk,
592 				struct flow_rule *rule);
593 int nfp_flower_compile_flow_match(struct nfp_app *app,
594 				  struct flow_rule *rule,
595 				  struct nfp_fl_key_ls *key_ls,
596 				  struct net_device *netdev,
597 				  struct nfp_fl_payload *nfp_flow,
598 				  enum nfp_flower_tun_type tun_type,
599 				  struct netlink_ext_ack *extack);
600 int nfp_flower_compile_action(struct nfp_app *app,
601 			      struct flow_rule *rule,
602 			      struct net_device *netdev,
603 			      struct nfp_fl_payload *nfp_flow,
604 			      struct netlink_ext_ack *extack);
605 int nfp_compile_flow_metadata(struct nfp_app *app, u32 cookie,
606 			      struct nfp_fl_payload *nfp_flow,
607 			      struct net_device *netdev,
608 			      struct netlink_ext_ack *extack);
609 void __nfp_modify_flow_metadata(struct nfp_flower_priv *priv,
610 				struct nfp_fl_payload *nfp_flow);
611 int nfp_modify_flow_metadata(struct nfp_app *app,
612 			     struct nfp_fl_payload *nfp_flow);
613 
614 struct nfp_fl_payload *
615 nfp_flower_search_fl_table(struct nfp_app *app, unsigned long tc_flower_cookie,
616 			   struct net_device *netdev);
617 struct nfp_fl_payload *
618 nfp_flower_get_fl_payload_from_ctx(struct nfp_app *app, u32 ctx_id);
619 struct nfp_fl_payload *
620 nfp_flower_remove_fl_table(struct nfp_app *app, unsigned long tc_flower_cookie);
621 
622 void nfp_flower_rx_flow_stats(struct nfp_app *app, struct sk_buff *skb);
623 
624 int nfp_tunnel_config_start(struct nfp_app *app);
625 void nfp_tunnel_config_stop(struct nfp_app *app);
626 int nfp_tunnel_mac_event_handler(struct nfp_app *app,
627 				 struct net_device *netdev,
628 				 unsigned long event, void *ptr);
629 void nfp_tunnel_del_ipv4_off(struct nfp_app *app, __be32 ipv4);
630 void nfp_tunnel_add_ipv4_off(struct nfp_app *app, __be32 ipv4);
631 void
632 nfp_tunnel_put_ipv6_off(struct nfp_app *app, struct nfp_ipv6_addr_entry *entry);
633 struct nfp_ipv6_addr_entry *
634 nfp_tunnel_add_ipv6_off(struct nfp_app *app, struct in6_addr *ipv6);
635 void nfp_tunnel_request_route_v4(struct nfp_app *app, struct sk_buff *skb);
636 void nfp_tunnel_request_route_v6(struct nfp_app *app, struct sk_buff *skb);
637 void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb);
638 void nfp_tunnel_keep_alive_v6(struct nfp_app *app, struct sk_buff *skb);
639 void nfp_flower_lag_init(struct nfp_fl_lag *lag);
640 void nfp_flower_lag_cleanup(struct nfp_fl_lag *lag);
641 int nfp_flower_lag_reset(struct nfp_fl_lag *lag);
642 int nfp_flower_lag_netdev_event(struct nfp_flower_priv *priv,
643 				struct net_device *netdev,
644 				unsigned long event, void *ptr);
645 bool nfp_flower_lag_unprocessed_msg(struct nfp_app *app, struct sk_buff *skb);
646 int nfp_flower_lag_populate_pre_action(struct nfp_app *app,
647 				       struct net_device *master,
648 				       struct nfp_fl_pre_lag *pre_act,
649 				       struct netlink_ext_ack *extack);
650 int nfp_flower_lag_get_output_id(struct nfp_app *app,
651 				 struct net_device *master);
652 void nfp_flower_qos_init(struct nfp_app *app);
653 void nfp_flower_qos_cleanup(struct nfp_app *app);
654 int nfp_flower_setup_qos_offload(struct nfp_app *app, struct net_device *netdev,
655 				 struct tc_cls_matchall_offload *flow);
656 void nfp_flower_stats_rlim_reply(struct nfp_app *app, struct sk_buff *skb);
657 int nfp_flower_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch, void *cb_priv,
658 				enum tc_setup_type type, void *type_data,
659 				void *data,
660 				void (*cleanup)(struct flow_block_cb *block_cb));
661 void nfp_flower_setup_indr_tc_release(void *cb_priv);
662 
663 void
664 __nfp_flower_non_repr_priv_get(struct nfp_flower_non_repr_priv *non_repr_priv);
665 struct nfp_flower_non_repr_priv *
666 nfp_flower_non_repr_priv_get(struct nfp_app *app, struct net_device *netdev);
667 void
668 __nfp_flower_non_repr_priv_put(struct nfp_flower_non_repr_priv *non_repr_priv);
669 void
670 nfp_flower_non_repr_priv_put(struct nfp_app *app, struct net_device *netdev);
671 u32 nfp_flower_get_port_id_from_netdev(struct nfp_app *app,
672 				       struct net_device *netdev);
673 void nfp_tun_link_and_update_nn_entries(struct nfp_app *app,
674 					struct nfp_predt_entry *predt);
675 void nfp_tun_unlink_and_update_nn_entries(struct nfp_app *app,
676 					  struct nfp_predt_entry *predt);
677 int nfp_flower_xmit_pre_tun_flow(struct nfp_app *app,
678 				 struct nfp_fl_payload *flow);
679 int nfp_flower_xmit_pre_tun_del_flow(struct nfp_app *app,
680 				     struct nfp_fl_payload *flow);
681 
682 struct nfp_fl_payload *
683 nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer);
684 int nfp_flower_calculate_key_layers(struct nfp_app *app,
685 				    struct net_device *netdev,
686 				    struct nfp_fl_key_ls *ret_key_ls,
687 				    struct flow_rule *flow,
688 				    enum nfp_flower_tun_type *tun_type,
689 				    struct netlink_ext_ack *extack);
690 void
691 nfp_flower_del_linked_merge_flows(struct nfp_app *app,
692 				  struct nfp_fl_payload *sub_flow);
693 int
694 nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow,
695 		     u8 mtype);
696 void
697 nfp_flower_update_merge_stats(struct nfp_app *app,
698 			      struct nfp_fl_payload *sub_flow);
699 
700 int nfp_setup_tc_act_offload(struct nfp_app *app,
701 			     struct flow_offload_action *fl_act);
702 int nfp_init_meter_table(struct nfp_app *app);
703 void nfp_flower_stats_meter_request_all(struct nfp_flower_priv *fl_priv);
704 void nfp_act_stats_reply(struct nfp_app *app, void *pmsg);
705 int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress,
706 				  bool pps, u32 id, u32 rate, u32 burst);
707 int nfp_flower_setup_meter_entry(struct nfp_app *app,
708 				 const struct flow_action_entry *action,
709 				 enum nfp_meter_op op,
710 				 u32 meter_id);
711 struct nfp_meter_entry *
712 nfp_flower_search_meter_entry(struct nfp_app *app, u32 meter_id);
713 #endif
714