.. | .. |
---|
1 | | -/* |
---|
2 | | - * Copyright (C) 2017 Netronome Systems, Inc. |
---|
3 | | - * |
---|
4 | | - * This software is dual licensed under the GNU General License Version 2, |
---|
5 | | - * June 1991 as shown in the file COPYING in the top-level directory of this |
---|
6 | | - * source tree or the BSD 2-Clause License provided below. You have the |
---|
7 | | - * option to license this software under the complete terms of either license. |
---|
8 | | - * |
---|
9 | | - * The BSD 2-Clause License: |
---|
10 | | - * |
---|
11 | | - * Redistribution and use in source and binary forms, with or |
---|
12 | | - * without modification, are permitted provided that the following |
---|
13 | | - * conditions are met: |
---|
14 | | - * |
---|
15 | | - * 1. Redistributions of source code must retain the above |
---|
16 | | - * copyright notice, this list of conditions and the following |
---|
17 | | - * disclaimer. |
---|
18 | | - * |
---|
19 | | - * 2. Redistributions in binary form must reproduce the above |
---|
20 | | - * copyright notice, this list of conditions and the following |
---|
21 | | - * disclaimer in the documentation and/or other materials |
---|
22 | | - * provided with the distribution. |
---|
23 | | - * |
---|
24 | | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
---|
25 | | - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
26 | | - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
---|
27 | | - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
---|
28 | | - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
---|
29 | | - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
---|
30 | | - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
---|
31 | | - * SOFTWARE. |
---|
32 | | - */ |
---|
| 1 | +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ |
---|
| 2 | +/* Copyright (C) 2017-2018 Netronome Systems, Inc. */ |
---|
33 | 3 | |
---|
34 | 4 | #ifndef __NFP_FLOWER_H__ |
---|
35 | 5 | #define __NFP_FLOWER_H__ 1 |
---|
36 | 6 | |
---|
37 | 7 | #include "cmsg.h" |
---|
| 8 | +#include "../nfp_net.h" |
---|
38 | 9 | |
---|
39 | 10 | #include <linux/circ_buf.h> |
---|
40 | 11 | #include <linux/hashtable.h> |
---|
| 12 | +#include <linux/rhashtable.h> |
---|
41 | 13 | #include <linux/time64.h> |
---|
42 | 14 | #include <linux/types.h> |
---|
43 | 15 | #include <net/pkt_cls.h> |
---|
.. | .. |
---|
49 | 21 | struct net_device; |
---|
50 | 22 | struct nfp_app; |
---|
51 | 23 | |
---|
52 | | -#define NFP_FL_STATS_CTX_DONT_CARE cpu_to_be32(0xffffffff) |
---|
53 | | -#define NFP_FL_STATS_ENTRY_RS BIT(20) |
---|
54 | | -#define NFP_FL_STATS_ELEM_RS 4 |
---|
55 | | -#define NFP_FL_REPEATED_HASH_MAX BIT(17) |
---|
56 | | -#define NFP_FLOWER_HASH_BITS 19 |
---|
| 24 | +#define NFP_FL_STAT_ID_MU_NUM GENMASK(31, 22) |
---|
| 25 | +#define NFP_FL_STAT_ID_STAT GENMASK(21, 0) |
---|
| 26 | + |
---|
| 27 | +#define NFP_FL_STATS_ELEM_RS sizeof_field(struct nfp_fl_stats_id, \ |
---|
| 28 | + init_unalloc) |
---|
57 | 29 | #define NFP_FLOWER_MASK_ENTRY_RS 256 |
---|
58 | 30 | #define NFP_FLOWER_MASK_ELEMENT_RS 1 |
---|
59 | 31 | #define NFP_FLOWER_MASK_HASH_BITS 10 |
---|
| 32 | + |
---|
| 33 | +#define NFP_FLOWER_KEY_MAX_LW 32 |
---|
60 | 34 | |
---|
61 | 35 | #define NFP_FL_META_FLAG_MANAGE_MASK BIT(7) |
---|
62 | 36 | |
---|
63 | 37 | #define NFP_FL_MASK_REUSE_TIME_NS 40000 |
---|
64 | 38 | #define NFP_FL_MASK_ID_LOCATION 1 |
---|
65 | 39 | |
---|
66 | | -#define NFP_FL_VXLAN_PORT 4789 |
---|
67 | | -#define NFP_FL_GENEVE_PORT 6081 |
---|
68 | | - |
---|
69 | 40 | /* Extra features bitmap. */ |
---|
70 | 41 | #define NFP_FL_FEATS_GENEVE BIT(0) |
---|
71 | 42 | #define NFP_FL_NBI_MTU_SETTING BIT(1) |
---|
72 | 43 | #define NFP_FL_FEATS_GENEVE_OPT BIT(2) |
---|
73 | 44 | #define NFP_FL_FEATS_VLAN_PCP BIT(3) |
---|
74 | | -#define NFP_FL_FEATS_LAG BIT(31) |
---|
| 45 | +#define NFP_FL_FEATS_VF_RLIM BIT(4) |
---|
| 46 | +#define NFP_FL_FEATS_FLOW_MOD BIT(5) |
---|
| 47 | +#define NFP_FL_FEATS_PRE_TUN_RULES BIT(6) |
---|
| 48 | +#define NFP_FL_FEATS_IPV6_TUN BIT(7) |
---|
| 49 | +#define NFP_FL_FEATS_VLAN_QINQ BIT(8) |
---|
| 50 | +#define NFP_FL_FEATS_HOST_ACK BIT(31) |
---|
| 51 | + |
---|
| 52 | +#define NFP_FL_ENABLE_FLOW_MERGE BIT(0) |
---|
| 53 | +#define NFP_FL_ENABLE_LAG BIT(1) |
---|
| 54 | + |
---|
| 55 | +#define NFP_FL_FEATS_HOST \ |
---|
| 56 | + (NFP_FL_FEATS_GENEVE | \ |
---|
| 57 | + NFP_FL_NBI_MTU_SETTING | \ |
---|
| 58 | + NFP_FL_FEATS_GENEVE_OPT | \ |
---|
| 59 | + NFP_FL_FEATS_VLAN_PCP | \ |
---|
| 60 | + NFP_FL_FEATS_VF_RLIM | \ |
---|
| 61 | + NFP_FL_FEATS_FLOW_MOD | \ |
---|
| 62 | + NFP_FL_FEATS_PRE_TUN_RULES | \ |
---|
| 63 | + NFP_FL_FEATS_IPV6_TUN | \ |
---|
| 64 | + NFP_FL_FEATS_VLAN_QINQ) |
---|
75 | 65 | |
---|
76 | 66 | struct nfp_fl_mask_id { |
---|
77 | 67 | struct circ_buf mask_id_free_list; |
---|
.. | .. |
---|
83 | 73 | struct circ_buf free_list; |
---|
84 | 74 | u32 init_unalloc; |
---|
85 | 75 | u8 repeated_em_count; |
---|
| 76 | +}; |
---|
| 77 | + |
---|
| 78 | +/** |
---|
| 79 | + * struct nfp_fl_tunnel_offloads - priv data for tunnel offloads |
---|
| 80 | + * @offloaded_macs: Hashtable of the offloaded MAC addresses |
---|
| 81 | + * @ipv4_off_list: List of IPv4 addresses to offload |
---|
| 82 | + * @ipv6_off_list: List of IPv6 addresses to offload |
---|
| 83 | + * @neigh_off_list_v4: List of IPv4 neighbour offloads |
---|
| 84 | + * @neigh_off_list_v6: List of IPv6 neighbour offloads |
---|
| 85 | + * @ipv4_off_lock: Lock for the IPv4 address list |
---|
| 86 | + * @ipv6_off_lock: Lock for the IPv6 address list |
---|
| 87 | + * @neigh_off_lock_v4: Lock for the IPv4 neighbour address list |
---|
| 88 | + * @neigh_off_lock_v6: Lock for the IPv6 neighbour address list |
---|
| 89 | + * @mac_off_ids: IDA to manage id assignment for offloaded MACs |
---|
| 90 | + * @neigh_nb: Notifier to monitor neighbour state |
---|
| 91 | + */ |
---|
| 92 | +struct nfp_fl_tunnel_offloads { |
---|
| 93 | + struct rhashtable offloaded_macs; |
---|
| 94 | + struct list_head ipv4_off_list; |
---|
| 95 | + struct list_head ipv6_off_list; |
---|
| 96 | + struct list_head neigh_off_list_v4; |
---|
| 97 | + struct list_head neigh_off_list_v6; |
---|
| 98 | + struct mutex ipv4_off_lock; |
---|
| 99 | + struct mutex ipv6_off_lock; |
---|
| 100 | + spinlock_t neigh_off_lock_v4; |
---|
| 101 | + spinlock_t neigh_off_lock_v6; |
---|
| 102 | + struct ida mac_off_ids; |
---|
| 103 | + struct notifier_block neigh_nb; |
---|
86 | 104 | }; |
---|
87 | 105 | |
---|
88 | 106 | /** |
---|
.. | .. |
---|
103 | 121 | |
---|
104 | 122 | /** |
---|
105 | 123 | * struct nfp_fl_lag - Flower APP priv data for link aggregation |
---|
106 | | - * @lag_nb: Notifier to track master/slave events |
---|
107 | 124 | * @work: Work queue for writing configs to the HW |
---|
108 | 125 | * @lock: Lock to protect lag_group_list |
---|
109 | 126 | * @group_list: List of all master/slave groups offloaded |
---|
.. | .. |
---|
116 | 133 | * retransmission |
---|
117 | 134 | */ |
---|
118 | 135 | struct nfp_fl_lag { |
---|
119 | | - struct notifier_block lag_nb; |
---|
120 | 136 | struct delayed_work work; |
---|
121 | 137 | struct mutex lock; |
---|
122 | 138 | struct list_head group_list; |
---|
.. | .. |
---|
129 | 145 | }; |
---|
130 | 146 | |
---|
131 | 147 | /** |
---|
| 148 | + * struct nfp_fl_internal_ports - Flower APP priv data for additional ports |
---|
| 149 | + * @port_ids: Assignment of ids to any additional ports |
---|
| 150 | + * @lock: Lock for extra ports list |
---|
| 151 | + */ |
---|
| 152 | +struct nfp_fl_internal_ports { |
---|
| 153 | + struct idr port_ids; |
---|
| 154 | + spinlock_t lock; |
---|
| 155 | +}; |
---|
| 156 | + |
---|
| 157 | +/** |
---|
132 | 158 | * struct nfp_flower_priv - Flower APP per-vNIC priv data |
---|
133 | 159 | * @app: Back pointer to app |
---|
134 | 160 | * @nn: Pointer to vNIC |
---|
135 | 161 | * @mask_id_seed: Seed used for mask hash table |
---|
136 | 162 | * @flower_version: HW version of flower |
---|
137 | 163 | * @flower_ext_feats: Bitmap of extra features the HW supports |
---|
| 164 | + * @flower_en_feats: Bitmap of features enabled by HW |
---|
138 | 165 | * @stats_ids: List of free stats ids |
---|
139 | 166 | * @mask_ids: List of free mask ids |
---|
140 | 167 | * @mask_table: Hash table used to store masks |
---|
| 168 | + * @stats_ring_size: Maximum number of allowed stats ids |
---|
141 | 169 | * @flow_table: Hash table used to store flower rules |
---|
| 170 | + * @stats: Stored stats updates for flower rules |
---|
| 171 | + * @stats_lock: Lock for flower rule stats updates |
---|
| 172 | + * @stats_ctx_table: Hash table to map stats contexts to its flow rule |
---|
142 | 173 | * @cmsg_work: Workqueue for control messages processing |
---|
143 | 174 | * @cmsg_skbs_high: List of higher priority skbs for control message |
---|
144 | 175 | * processing |
---|
145 | 176 | * @cmsg_skbs_low: List of lower priority skbs for control message |
---|
146 | 177 | * processing |
---|
147 | | - * @nfp_mac_off_list: List of MAC addresses to offload |
---|
148 | | - * @nfp_mac_index_list: List of unique 8-bit indexes for non NFP netdevs |
---|
149 | | - * @nfp_ipv4_off_list: List of IPv4 addresses to offload |
---|
150 | | - * @nfp_neigh_off_list: List of neighbour offloads |
---|
151 | | - * @nfp_mac_off_lock: Lock for the MAC address list |
---|
152 | | - * @nfp_mac_index_lock: Lock for the MAC index list |
---|
153 | | - * @nfp_ipv4_off_lock: Lock for the IPv4 address list |
---|
154 | | - * @nfp_neigh_off_lock: Lock for the neighbour address list |
---|
155 | | - * @nfp_mac_off_ids: IDA to manage id assignment for offloaded macs |
---|
156 | | - * @nfp_mac_off_count: Number of MACs in address list |
---|
157 | | - * @nfp_tun_mac_nb: Notifier to monitor link state |
---|
158 | | - * @nfp_tun_neigh_nb: Notifier to monitor neighbour state |
---|
| 178 | + * @tun: Tunnel offload data |
---|
159 | 179 | * @reify_replies: atomically stores the number of replies received |
---|
160 | 180 | * from firmware for repr reify |
---|
161 | 181 | * @reify_wait_queue: wait queue for repr reify response counting |
---|
162 | 182 | * @mtu_conf: Configuration of repr MTU value |
---|
163 | 183 | * @nfp_lag: Link aggregation data block |
---|
| 184 | + * @indr_block_cb_priv: List of priv data passed to indirect block cbs |
---|
| 185 | + * @non_repr_priv: List of offloaded non-repr ports and their priv data |
---|
| 186 | + * @active_mem_unit: Current active memory unit for flower rules |
---|
| 187 | + * @total_mem_units: Total number of available memory units for flower rules |
---|
| 188 | + * @internal_ports: Internal port ids used in offloaded rules |
---|
| 189 | + * @qos_stats_work: Workqueue for qos stats processing |
---|
| 190 | + * @qos_rate_limiters: Current active qos rate limiters |
---|
| 191 | + * @qos_stats_lock: Lock on qos stats updates |
---|
| 192 | + * @pre_tun_rule_cnt: Number of pre-tunnel rules offloaded |
---|
| 193 | + * @merge_table: Hash table to store merged flows |
---|
164 | 194 | */ |
---|
165 | 195 | struct nfp_flower_priv { |
---|
166 | 196 | struct nfp_app *app; |
---|
.. | .. |
---|
168 | 198 | u32 mask_id_seed; |
---|
169 | 199 | u64 flower_version; |
---|
170 | 200 | u64 flower_ext_feats; |
---|
| 201 | + u8 flower_en_feats; |
---|
171 | 202 | struct nfp_fl_stats_id stats_ids; |
---|
172 | 203 | struct nfp_fl_mask_id mask_ids; |
---|
173 | 204 | DECLARE_HASHTABLE(mask_table, NFP_FLOWER_MASK_HASH_BITS); |
---|
174 | | - DECLARE_HASHTABLE(flow_table, NFP_FLOWER_HASH_BITS); |
---|
| 205 | + u32 stats_ring_size; |
---|
| 206 | + struct rhashtable flow_table; |
---|
| 207 | + struct nfp_fl_stats *stats; |
---|
| 208 | + spinlock_t stats_lock; /* lock stats */ |
---|
| 209 | + struct rhashtable stats_ctx_table; |
---|
175 | 210 | struct work_struct cmsg_work; |
---|
176 | 211 | struct sk_buff_head cmsg_skbs_high; |
---|
177 | 212 | struct sk_buff_head cmsg_skbs_low; |
---|
178 | | - struct list_head nfp_mac_off_list; |
---|
179 | | - struct list_head nfp_mac_index_list; |
---|
180 | | - struct list_head nfp_ipv4_off_list; |
---|
181 | | - struct list_head nfp_neigh_off_list; |
---|
182 | | - struct mutex nfp_mac_off_lock; |
---|
183 | | - struct mutex nfp_mac_index_lock; |
---|
184 | | - struct mutex nfp_ipv4_off_lock; |
---|
185 | | - spinlock_t nfp_neigh_off_lock; |
---|
186 | | - struct ida nfp_mac_off_ids; |
---|
187 | | - int nfp_mac_off_count; |
---|
188 | | - struct notifier_block nfp_tun_mac_nb; |
---|
189 | | - struct notifier_block nfp_tun_neigh_nb; |
---|
| 213 | + struct nfp_fl_tunnel_offloads tun; |
---|
190 | 214 | atomic_t reify_replies; |
---|
191 | 215 | wait_queue_head_t reify_wait_queue; |
---|
192 | 216 | struct nfp_mtu_conf mtu_conf; |
---|
193 | 217 | struct nfp_fl_lag nfp_lag; |
---|
| 218 | + struct list_head indr_block_cb_priv; |
---|
| 219 | + struct list_head non_repr_priv; |
---|
| 220 | + unsigned int active_mem_unit; |
---|
| 221 | + unsigned int total_mem_units; |
---|
| 222 | + struct nfp_fl_internal_ports internal_ports; |
---|
| 223 | + struct delayed_work qos_stats_work; |
---|
| 224 | + unsigned int qos_rate_limiters; |
---|
| 225 | + spinlock_t qos_stats_lock; /* Protect the qos stats */ |
---|
| 226 | + int pre_tun_rule_cnt; |
---|
| 227 | + struct rhashtable merge_table; |
---|
| 228 | +}; |
---|
| 229 | + |
---|
| 230 | +/** |
---|
| 231 | + * struct nfp_fl_qos - Flower APP priv data for quality of service |
---|
| 232 | + * @netdev_port_id: NFP port number of repr with qos info |
---|
| 233 | + * @curr_stats: Currently stored stats updates for qos info |
---|
| 234 | + * @prev_stats: Previously stored updates for qos info |
---|
| 235 | + * @last_update: Stored time when last stats were updated |
---|
| 236 | + */ |
---|
| 237 | +struct nfp_fl_qos { |
---|
| 238 | + u32 netdev_port_id; |
---|
| 239 | + struct nfp_stat_pair curr_stats; |
---|
| 240 | + struct nfp_stat_pair prev_stats; |
---|
| 241 | + u64 last_update; |
---|
194 | 242 | }; |
---|
195 | 243 | |
---|
196 | 244 | /** |
---|
197 | 245 | * struct nfp_flower_repr_priv - Flower APP per-repr priv data |
---|
| 246 | + * @nfp_repr: Back pointer to nfp_repr |
---|
198 | 247 | * @lag_port_flags: Extended port flags to record lag state of repr |
---|
| 248 | + * @mac_offloaded: Flag indicating a MAC address is offloaded for repr |
---|
| 249 | + * @offloaded_mac_addr: MAC address that has been offloaded for repr |
---|
| 250 | + * @block_shared: Flag indicating if offload applies to shared blocks |
---|
| 251 | + * @mac_list: List entry of reprs that share the same offloaded MAC |
---|
| 252 | + * @qos_table: Stored info on filters implementing qos |
---|
| 253 | + * @on_bridge: Indicates if the repr is attached to a bridge |
---|
199 | 254 | */ |
---|
200 | 255 | struct nfp_flower_repr_priv { |
---|
| 256 | + struct nfp_repr *nfp_repr; |
---|
201 | 257 | unsigned long lag_port_flags; |
---|
| 258 | + bool mac_offloaded; |
---|
| 259 | + u8 offloaded_mac_addr[ETH_ALEN]; |
---|
| 260 | + bool block_shared; |
---|
| 261 | + struct list_head mac_list; |
---|
| 262 | + struct nfp_fl_qos qos_table; |
---|
| 263 | + bool on_bridge; |
---|
| 264 | +}; |
---|
| 265 | + |
---|
| 266 | +/** |
---|
| 267 | + * struct nfp_flower_non_repr_priv - Priv data for non-repr offloaded ports |
---|
| 268 | + * @list: List entry of offloaded reprs |
---|
| 269 | + * @netdev: Pointer to non-repr net_device |
---|
| 270 | + * @ref_count: Number of references held for this priv data |
---|
| 271 | + * @mac_offloaded: Flag indicating a MAC address is offloaded for device |
---|
| 272 | + * @offloaded_mac_addr: MAC address that has been offloaded for dev |
---|
| 273 | + */ |
---|
| 274 | +struct nfp_flower_non_repr_priv { |
---|
| 275 | + struct list_head list; |
---|
| 276 | + struct net_device *netdev; |
---|
| 277 | + int ref_count; |
---|
| 278 | + bool mac_offloaded; |
---|
| 279 | + u8 offloaded_mac_addr[ETH_ALEN]; |
---|
202 | 280 | }; |
---|
203 | 281 | |
---|
204 | 282 | struct nfp_fl_key_ls { |
---|
.. | .. |
---|
224 | 302 | u64 used; |
---|
225 | 303 | }; |
---|
226 | 304 | |
---|
| 305 | +/** |
---|
| 306 | + * struct nfp_ipv6_addr_entry - cached IPv6 addresses |
---|
| 307 | + * @ipv6_addr: IP address |
---|
| 308 | + * @ref_count: number of rules currently using this IP |
---|
| 309 | + * @list: list pointer |
---|
| 310 | + */ |
---|
| 311 | +struct nfp_ipv6_addr_entry { |
---|
| 312 | + struct in6_addr ipv6_addr; |
---|
| 313 | + int ref_count; |
---|
| 314 | + struct list_head list; |
---|
| 315 | +}; |
---|
| 316 | + |
---|
227 | 317 | struct nfp_fl_payload { |
---|
228 | 318 | struct nfp_fl_rule_metadata meta; |
---|
229 | 319 | unsigned long tc_flower_cookie; |
---|
230 | | - struct hlist_node link; |
---|
| 320 | + struct rhash_head fl_node; |
---|
231 | 321 | struct rcu_head rcu; |
---|
232 | | - spinlock_t lock; /* lock stats */ |
---|
233 | | - struct nfp_fl_stats stats; |
---|
234 | 322 | __be32 nfp_tun_ipv4_addr; |
---|
| 323 | + struct nfp_ipv6_addr_entry *nfp_tun_ipv6; |
---|
235 | 324 | struct net_device *ingress_dev; |
---|
236 | 325 | char *unmasked_data; |
---|
237 | 326 | char *mask_data; |
---|
238 | 327 | char *action_data; |
---|
239 | | - bool ingress_offload; |
---|
| 328 | + struct list_head linked_flows; |
---|
| 329 | + bool in_hw; |
---|
| 330 | + struct { |
---|
| 331 | + struct net_device *dev; |
---|
| 332 | + __be16 vlan_tci; |
---|
| 333 | + __be16 port_idx; |
---|
| 334 | + } pre_tun_rule; |
---|
| 335 | +}; |
---|
| 336 | + |
---|
| 337 | +struct nfp_fl_payload_link { |
---|
| 338 | + /* A link contains a pointer to a merge flow and an associated sub_flow. |
---|
| 339 | + * Each merge flow will feature in 2 links to its underlying sub_flows. |
---|
| 340 | + * A sub_flow will have at least 1 link to a merge flow or more if it |
---|
| 341 | + * has been used to create multiple merge flows. |
---|
| 342 | + * |
---|
| 343 | + * For a merge flow, 'linked_flows' in its nfp_fl_payload struct lists |
---|
| 344 | + * all links to sub_flows (sub_flow.flow) via merge.list. |
---|
| 345 | + * For a sub_flow, 'linked_flows' gives all links to merge flows it has |
---|
| 346 | + * formed (merge_flow.flow) via sub_flow.list. |
---|
| 347 | + */ |
---|
| 348 | + struct { |
---|
| 349 | + struct list_head list; |
---|
| 350 | + struct nfp_fl_payload *flow; |
---|
| 351 | + } merge_flow, sub_flow; |
---|
| 352 | +}; |
---|
| 353 | + |
---|
| 354 | +extern const struct rhashtable_params nfp_flower_table_params; |
---|
| 355 | +extern const struct rhashtable_params merge_table_params; |
---|
| 356 | + |
---|
| 357 | +struct nfp_merge_info { |
---|
| 358 | + u64 parent_ctx; |
---|
| 359 | + struct rhash_head ht_node; |
---|
240 | 360 | }; |
---|
241 | 361 | |
---|
242 | 362 | struct nfp_fl_stats_frame { |
---|
.. | .. |
---|
246 | 366 | __be64 stats_cookie; |
---|
247 | 367 | }; |
---|
248 | 368 | |
---|
249 | | -int nfp_flower_metadata_init(struct nfp_app *app); |
---|
| 369 | +static inline bool |
---|
| 370 | +nfp_flower_internal_port_can_offload(struct nfp_app *app, |
---|
| 371 | + struct net_device *netdev) |
---|
| 372 | +{ |
---|
| 373 | + struct nfp_flower_priv *app_priv = app->priv; |
---|
| 374 | + |
---|
| 375 | + if (!(app_priv->flower_en_feats & NFP_FL_ENABLE_FLOW_MERGE)) |
---|
| 376 | + return false; |
---|
| 377 | + if (!netdev->rtnl_link_ops) |
---|
| 378 | + return false; |
---|
| 379 | + if (!strcmp(netdev->rtnl_link_ops->kind, "openvswitch")) |
---|
| 380 | + return true; |
---|
| 381 | + |
---|
| 382 | + return false; |
---|
| 383 | +} |
---|
| 384 | + |
---|
| 385 | +/* The address of the merged flow acts as its cookie. |
---|
| 386 | + * Cookies supplied to us by TC flower are also addresses to allocated |
---|
| 387 | + * memory and thus this scheme should not generate any collisions. |
---|
| 388 | + */ |
---|
| 389 | +static inline bool nfp_flower_is_merge_flow(struct nfp_fl_payload *flow_pay) |
---|
| 390 | +{ |
---|
| 391 | + return flow_pay->tc_flower_cookie == (unsigned long)flow_pay; |
---|
| 392 | +} |
---|
| 393 | + |
---|
| 394 | +static inline bool nfp_flower_is_supported_bridge(struct net_device *netdev) |
---|
| 395 | +{ |
---|
| 396 | + return netif_is_ovs_master(netdev); |
---|
| 397 | +} |
---|
| 398 | + |
---|
| 399 | +int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, |
---|
| 400 | + unsigned int host_ctx_split); |
---|
250 | 401 | void nfp_flower_metadata_cleanup(struct nfp_app *app); |
---|
251 | 402 | |
---|
252 | 403 | int nfp_flower_setup_tc(struct nfp_app *app, struct net_device *netdev, |
---|
253 | 404 | enum tc_setup_type type, void *type_data); |
---|
254 | | -int nfp_flower_compile_flow_match(struct tc_cls_flower_offload *flow, |
---|
| 405 | +int nfp_flower_merge_offloaded_flows(struct nfp_app *app, |
---|
| 406 | + struct nfp_fl_payload *sub_flow1, |
---|
| 407 | + struct nfp_fl_payload *sub_flow2); |
---|
| 408 | +int nfp_flower_compile_flow_match(struct nfp_app *app, |
---|
| 409 | + struct flow_cls_offload *flow, |
---|
255 | 410 | struct nfp_fl_key_ls *key_ls, |
---|
256 | 411 | struct net_device *netdev, |
---|
257 | 412 | struct nfp_fl_payload *nfp_flow, |
---|
258 | | - enum nfp_flower_tun_type tun_type); |
---|
| 413 | + enum nfp_flower_tun_type tun_type, |
---|
| 414 | + struct netlink_ext_ack *extack); |
---|
259 | 415 | int nfp_flower_compile_action(struct nfp_app *app, |
---|
260 | | - struct tc_cls_flower_offload *flow, |
---|
| 416 | + struct flow_cls_offload *flow, |
---|
261 | 417 | struct net_device *netdev, |
---|
262 | | - struct nfp_fl_payload *nfp_flow); |
---|
263 | | -int nfp_compile_flow_metadata(struct nfp_app *app, |
---|
264 | | - struct tc_cls_flower_offload *flow, |
---|
265 | 418 | struct nfp_fl_payload *nfp_flow, |
---|
266 | | - struct net_device *netdev); |
---|
| 419 | + struct netlink_ext_ack *extack); |
---|
| 420 | +int nfp_compile_flow_metadata(struct nfp_app *app, |
---|
| 421 | + struct flow_cls_offload *flow, |
---|
| 422 | + struct nfp_fl_payload *nfp_flow, |
---|
| 423 | + struct net_device *netdev, |
---|
| 424 | + struct netlink_ext_ack *extack); |
---|
| 425 | +void __nfp_modify_flow_metadata(struct nfp_flower_priv *priv, |
---|
| 426 | + struct nfp_fl_payload *nfp_flow); |
---|
267 | 427 | int nfp_modify_flow_metadata(struct nfp_app *app, |
---|
268 | 428 | struct nfp_fl_payload *nfp_flow); |
---|
269 | 429 | |
---|
270 | 430 | struct nfp_fl_payload * |
---|
271 | 431 | nfp_flower_search_fl_table(struct nfp_app *app, unsigned long tc_flower_cookie, |
---|
272 | | - struct net_device *netdev, __be32 host_ctx); |
---|
| 432 | + struct net_device *netdev); |
---|
| 433 | +struct nfp_fl_payload * |
---|
| 434 | +nfp_flower_get_fl_payload_from_ctx(struct nfp_app *app, u32 ctx_id); |
---|
273 | 435 | struct nfp_fl_payload * |
---|
274 | 436 | nfp_flower_remove_fl_table(struct nfp_app *app, unsigned long tc_flower_cookie); |
---|
275 | 437 | |
---|
.. | .. |
---|
277 | 439 | |
---|
278 | 440 | int nfp_tunnel_config_start(struct nfp_app *app); |
---|
279 | 441 | void nfp_tunnel_config_stop(struct nfp_app *app); |
---|
280 | | -void nfp_tunnel_write_macs(struct nfp_app *app); |
---|
| 442 | +int nfp_tunnel_mac_event_handler(struct nfp_app *app, |
---|
| 443 | + struct net_device *netdev, |
---|
| 444 | + unsigned long event, void *ptr); |
---|
281 | 445 | void nfp_tunnel_del_ipv4_off(struct nfp_app *app, __be32 ipv4); |
---|
282 | 446 | void nfp_tunnel_add_ipv4_off(struct nfp_app *app, __be32 ipv4); |
---|
283 | | -void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb); |
---|
| 447 | +void |
---|
| 448 | +nfp_tunnel_put_ipv6_off(struct nfp_app *app, struct nfp_ipv6_addr_entry *entry); |
---|
| 449 | +struct nfp_ipv6_addr_entry * |
---|
| 450 | +nfp_tunnel_add_ipv6_off(struct nfp_app *app, struct in6_addr *ipv6); |
---|
| 451 | +void nfp_tunnel_request_route_v4(struct nfp_app *app, struct sk_buff *skb); |
---|
| 452 | +void nfp_tunnel_request_route_v6(struct nfp_app *app, struct sk_buff *skb); |
---|
284 | 453 | void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb); |
---|
285 | | -int nfp_flower_setup_tc_egress_cb(enum tc_setup_type type, void *type_data, |
---|
286 | | - void *cb_priv); |
---|
| 454 | +void nfp_tunnel_keep_alive_v6(struct nfp_app *app, struct sk_buff *skb); |
---|
287 | 455 | void nfp_flower_lag_init(struct nfp_fl_lag *lag); |
---|
288 | 456 | void nfp_flower_lag_cleanup(struct nfp_fl_lag *lag); |
---|
289 | 457 | int nfp_flower_lag_reset(struct nfp_fl_lag *lag); |
---|
| 458 | +int nfp_flower_lag_netdev_event(struct nfp_flower_priv *priv, |
---|
| 459 | + struct net_device *netdev, |
---|
| 460 | + unsigned long event, void *ptr); |
---|
290 | 461 | bool nfp_flower_lag_unprocessed_msg(struct nfp_app *app, struct sk_buff *skb); |
---|
291 | 462 | int nfp_flower_lag_populate_pre_action(struct nfp_app *app, |
---|
292 | 463 | struct net_device *master, |
---|
293 | | - struct nfp_fl_pre_lag *pre_act); |
---|
| 464 | + struct nfp_fl_pre_lag *pre_act, |
---|
| 465 | + struct netlink_ext_ack *extack); |
---|
294 | 466 | int nfp_flower_lag_get_output_id(struct nfp_app *app, |
---|
295 | 467 | struct net_device *master); |
---|
| 468 | +void nfp_flower_qos_init(struct nfp_app *app); |
---|
| 469 | +void nfp_flower_qos_cleanup(struct nfp_app *app); |
---|
| 470 | +int nfp_flower_setup_qos_offload(struct nfp_app *app, struct net_device *netdev, |
---|
| 471 | + struct tc_cls_matchall_offload *flow); |
---|
| 472 | +void nfp_flower_stats_rlim_reply(struct nfp_app *app, struct sk_buff *skb); |
---|
| 473 | +int nfp_flower_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch, void *cb_priv, |
---|
| 474 | + enum tc_setup_type type, void *type_data, |
---|
| 475 | + void *data, |
---|
| 476 | + void (*cleanup)(struct flow_block_cb *block_cb)); |
---|
| 477 | +void nfp_flower_setup_indr_tc_release(void *cb_priv); |
---|
296 | 478 | |
---|
| 479 | +void |
---|
| 480 | +__nfp_flower_non_repr_priv_get(struct nfp_flower_non_repr_priv *non_repr_priv); |
---|
| 481 | +struct nfp_flower_non_repr_priv * |
---|
| 482 | +nfp_flower_non_repr_priv_get(struct nfp_app *app, struct net_device *netdev); |
---|
| 483 | +void |
---|
| 484 | +__nfp_flower_non_repr_priv_put(struct nfp_flower_non_repr_priv *non_repr_priv); |
---|
| 485 | +void |
---|
| 486 | +nfp_flower_non_repr_priv_put(struct nfp_app *app, struct net_device *netdev); |
---|
| 487 | +u32 nfp_flower_get_port_id_from_netdev(struct nfp_app *app, |
---|
| 488 | + struct net_device *netdev); |
---|
| 489 | +int nfp_flower_xmit_pre_tun_flow(struct nfp_app *app, |
---|
| 490 | + struct nfp_fl_payload *flow); |
---|
| 491 | +int nfp_flower_xmit_pre_tun_del_flow(struct nfp_app *app, |
---|
| 492 | + struct nfp_fl_payload *flow); |
---|
297 | 493 | #endif |
---|