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