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