.. | .. |
---|
1 | | -/* |
---|
2 | | - * Copyright (C) 2015-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) 2015-2018 Netronome Systems, Inc. */ |
---|
33 | 3 | |
---|
34 | 4 | #include <linux/bitfield.h> |
---|
35 | 5 | #include <linux/netdevice.h> |
---|
.. | .. |
---|
75 | 45 | { |
---|
76 | 46 | struct nfp_flower_cmsg_mac_repr *msg; |
---|
77 | 47 | struct sk_buff *skb; |
---|
78 | | - unsigned int size; |
---|
79 | 48 | |
---|
80 | | - size = sizeof(*msg) + num_ports * sizeof(msg->ports[0]); |
---|
81 | | - skb = nfp_flower_cmsg_alloc(app, size, NFP_FLOWER_CMSG_TYPE_MAC_REPR, |
---|
82 | | - GFP_KERNEL); |
---|
| 49 | + skb = nfp_flower_cmsg_alloc(app, struct_size(msg, ports, num_ports), |
---|
| 50 | + NFP_FLOWER_CMSG_TYPE_MAC_REPR, GFP_KERNEL); |
---|
83 | 51 | if (!skb) |
---|
84 | 52 | return NULL; |
---|
85 | 53 | |
---|
.. | .. |
---|
191 | 159 | |
---|
192 | 160 | rtnl_lock(); |
---|
193 | 161 | rcu_read_lock(); |
---|
194 | | - netdev = nfp_app_repr_get(app, be32_to_cpu(msg->portnum)); |
---|
| 162 | + netdev = nfp_app_dev_get(app, be32_to_cpu(msg->portnum), NULL); |
---|
195 | 163 | rcu_read_unlock(); |
---|
196 | 164 | if (!netdev) { |
---|
197 | 165 | nfp_flower_cmsg_warn(app, "ctrl msg for unknown port 0x%08x\n", |
---|
.. | .. |
---|
224 | 192 | msg = nfp_flower_cmsg_get_data(skb); |
---|
225 | 193 | |
---|
226 | 194 | rcu_read_lock(); |
---|
227 | | - exists = !!nfp_app_repr_get(app, be32_to_cpu(msg->portnum)); |
---|
| 195 | + exists = !!nfp_app_dev_get(app, be32_to_cpu(msg->portnum), NULL); |
---|
228 | 196 | rcu_read_unlock(); |
---|
229 | 197 | if (!exists) { |
---|
230 | 198 | nfp_flower_cmsg_warn(app, "ctrl msg for unknown port 0x%08x\n", |
---|
.. | .. |
---|
233 | 201 | } |
---|
234 | 202 | |
---|
235 | 203 | atomic_inc(&priv->reify_replies); |
---|
236 | | - wake_up_interruptible(&priv->reify_wait_queue); |
---|
| 204 | + wake_up(&priv->reify_wait_queue); |
---|
| 205 | +} |
---|
| 206 | + |
---|
| 207 | +static void |
---|
| 208 | +nfp_flower_cmsg_merge_hint_rx(struct nfp_app *app, struct sk_buff *skb) |
---|
| 209 | +{ |
---|
| 210 | + unsigned int msg_len = nfp_flower_cmsg_get_data_len(skb); |
---|
| 211 | + struct nfp_flower_cmsg_merge_hint *msg; |
---|
| 212 | + struct nfp_fl_payload *sub_flows[2]; |
---|
| 213 | + int err, i, flow_cnt; |
---|
| 214 | + |
---|
| 215 | + msg = nfp_flower_cmsg_get_data(skb); |
---|
| 216 | + /* msg->count starts at 0 and always assumes at least 1 entry. */ |
---|
| 217 | + flow_cnt = msg->count + 1; |
---|
| 218 | + |
---|
| 219 | + if (msg_len < struct_size(msg, flow, flow_cnt)) { |
---|
| 220 | + nfp_flower_cmsg_warn(app, "Merge hint ctrl msg too short - %d bytes but expect %zd\n", |
---|
| 221 | + msg_len, struct_size(msg, flow, flow_cnt)); |
---|
| 222 | + return; |
---|
| 223 | + } |
---|
| 224 | + |
---|
| 225 | + if (flow_cnt != 2) { |
---|
| 226 | + nfp_flower_cmsg_warn(app, "Merge hint contains %d flows - two are expected\n", |
---|
| 227 | + flow_cnt); |
---|
| 228 | + return; |
---|
| 229 | + } |
---|
| 230 | + |
---|
| 231 | + rtnl_lock(); |
---|
| 232 | + for (i = 0; i < flow_cnt; i++) { |
---|
| 233 | + u32 ctx = be32_to_cpu(msg->flow[i].host_ctx); |
---|
| 234 | + |
---|
| 235 | + sub_flows[i] = nfp_flower_get_fl_payload_from_ctx(app, ctx); |
---|
| 236 | + if (!sub_flows[i]) { |
---|
| 237 | + nfp_flower_cmsg_warn(app, "Invalid flow in merge hint\n"); |
---|
| 238 | + goto err_rtnl_unlock; |
---|
| 239 | + } |
---|
| 240 | + } |
---|
| 241 | + |
---|
| 242 | + err = nfp_flower_merge_offloaded_flows(app, sub_flows[0], sub_flows[1]); |
---|
| 243 | + /* Only warn on memory fail. Hint veto will not break functionality. */ |
---|
| 244 | + if (err == -ENOMEM) |
---|
| 245 | + nfp_flower_cmsg_warn(app, "Flow merge memory fail.\n"); |
---|
| 246 | + |
---|
| 247 | +err_rtnl_unlock: |
---|
| 248 | + rtnl_unlock(); |
---|
237 | 249 | } |
---|
238 | 250 | |
---|
239 | 251 | static void |
---|
.. | .. |
---|
248 | 260 | |
---|
249 | 261 | type = cmsg_hdr->type; |
---|
250 | 262 | switch (type) { |
---|
251 | | - case NFP_FLOWER_CMSG_TYPE_PORT_REIFY: |
---|
252 | | - nfp_flower_cmsg_portreify_rx(app, skb); |
---|
253 | | - break; |
---|
254 | 263 | case NFP_FLOWER_CMSG_TYPE_PORT_MOD: |
---|
255 | 264 | nfp_flower_cmsg_portmod_rx(app, skb); |
---|
256 | 265 | break; |
---|
| 266 | + case NFP_FLOWER_CMSG_TYPE_MERGE_HINT: |
---|
| 267 | + if (app_priv->flower_en_feats & NFP_FL_ENABLE_FLOW_MERGE) { |
---|
| 268 | + nfp_flower_cmsg_merge_hint_rx(app, skb); |
---|
| 269 | + break; |
---|
| 270 | + } |
---|
| 271 | + goto err_default; |
---|
257 | 272 | case NFP_FLOWER_CMSG_TYPE_NO_NEIGH: |
---|
258 | | - nfp_tunnel_request_route(app, skb); |
---|
| 273 | + nfp_tunnel_request_route_v4(app, skb); |
---|
| 274 | + break; |
---|
| 275 | + case NFP_FLOWER_CMSG_TYPE_NO_NEIGH_V6: |
---|
| 276 | + nfp_tunnel_request_route_v6(app, skb); |
---|
259 | 277 | break; |
---|
260 | 278 | case NFP_FLOWER_CMSG_TYPE_ACTIVE_TUNS: |
---|
261 | 279 | nfp_tunnel_keep_alive(app, skb); |
---|
262 | 280 | break; |
---|
| 281 | + case NFP_FLOWER_CMSG_TYPE_ACTIVE_TUNS_V6: |
---|
| 282 | + nfp_tunnel_keep_alive_v6(app, skb); |
---|
| 283 | + break; |
---|
| 284 | + case NFP_FLOWER_CMSG_TYPE_QOS_STATS: |
---|
| 285 | + nfp_flower_stats_rlim_reply(app, skb); |
---|
| 286 | + break; |
---|
263 | 287 | case NFP_FLOWER_CMSG_TYPE_LAG_CONFIG: |
---|
264 | | - if (app_priv->flower_ext_feats & NFP_FL_FEATS_LAG) { |
---|
| 288 | + if (app_priv->flower_en_feats & NFP_FL_ENABLE_LAG) { |
---|
265 | 289 | skb_stored = nfp_flower_lag_unprocessed_msg(app, skb); |
---|
266 | 290 | break; |
---|
267 | 291 | } |
---|
268 | | - /* fall through */ |
---|
| 292 | + fallthrough; |
---|
269 | 293 | default: |
---|
| 294 | +err_default: |
---|
270 | 295 | nfp_flower_cmsg_warn(app, "Cannot handle invalid repr control type %u\n", |
---|
271 | 296 | type); |
---|
272 | 297 | goto out; |
---|
.. | .. |
---|
306 | 331 | struct nfp_flower_priv *priv = app->priv; |
---|
307 | 332 | struct sk_buff_head *skb_head; |
---|
308 | 333 | |
---|
309 | | - if (type == NFP_FLOWER_CMSG_TYPE_PORT_REIFY || |
---|
310 | | - type == NFP_FLOWER_CMSG_TYPE_PORT_MOD) |
---|
| 334 | + if (type == NFP_FLOWER_CMSG_TYPE_PORT_MOD) |
---|
311 | 335 | skb_head = &priv->cmsg_skbs_high; |
---|
312 | 336 | else |
---|
313 | 337 | skb_head = &priv->cmsg_skbs_low; |
---|
.. | .. |
---|
343 | 367 | nfp_flower_process_mtu_ack(app, skb)) { |
---|
344 | 368 | /* Handle MTU acks outside wq to prevent RTNL conflict. */ |
---|
345 | 369 | dev_consume_skb_any(skb); |
---|
346 | | - } else if (cmsg_hdr->type == NFP_FLOWER_CMSG_TYPE_TUN_NEIGH) { |
---|
| 370 | + } else if (cmsg_hdr->type == NFP_FLOWER_CMSG_TYPE_TUN_NEIGH || |
---|
| 371 | + cmsg_hdr->type == NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6) { |
---|
347 | 372 | /* Acks from the NFP that the route is added - ignore. */ |
---|
348 | 373 | dev_consume_skb_any(skb); |
---|
| 374 | + } else if (cmsg_hdr->type == NFP_FLOWER_CMSG_TYPE_PORT_REIFY) { |
---|
| 375 | + /* Handle REIFY acks outside wq to prevent RTNL conflict. */ |
---|
| 376 | + nfp_flower_cmsg_portreify_rx(app, skb); |
---|
| 377 | + dev_consume_skb_any(skb); |
---|
349 | 378 | } else { |
---|
350 | 379 | nfp_flower_queue_ctl_msg(app, skb, cmsg_hdr->type); |
---|
351 | 380 | } |
---|