.. | .. |
---|
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_APP_H |
---|
35 | 5 | #define _NFP_APP_H 1 |
---|
.. | .. |
---|
39 | 9 | #include <trace/events/devlink.h> |
---|
40 | 10 | |
---|
41 | 11 | #include "nfp_net_repr.h" |
---|
| 12 | + |
---|
| 13 | +#define NFP_APP_CTRL_MTU_MAX U32_MAX |
---|
42 | 14 | |
---|
43 | 15 | struct bpf_prog; |
---|
44 | 16 | struct net_device; |
---|
.. | .. |
---|
97 | 69 | * @port_get_stats_strings: get strings for extra statistics |
---|
98 | 70 | * @start: start application logic |
---|
99 | 71 | * @stop: stop application logic |
---|
| 72 | + * @netdev_event: Netdevice notifier event |
---|
100 | 73 | * @ctrl_msg_rx: control message handler |
---|
101 | 74 | * @ctrl_msg_rx_raw: handler for control messages from data queues |
---|
102 | 75 | * @setup_tc: setup TC ndo |
---|
.. | .. |
---|
106 | 79 | * @eswitch_mode_set: set SR-IOV eswitch mode (under pf->lock) |
---|
107 | 80 | * @sriov_enable: app-specific sriov initialisation |
---|
108 | 81 | * @sriov_disable: app-specific sriov clean-up |
---|
109 | | - * @repr_get: get representor netdev |
---|
| 82 | + * @dev_get: get representor or internal port representing netdev |
---|
110 | 83 | */ |
---|
111 | 84 | struct nfp_app_type { |
---|
112 | 85 | enum nfp_app_id id; |
---|
.. | .. |
---|
150 | 123 | int (*start)(struct nfp_app *app); |
---|
151 | 124 | void (*stop)(struct nfp_app *app); |
---|
152 | 125 | |
---|
| 126 | + int (*netdev_event)(struct nfp_app *app, struct net_device *netdev, |
---|
| 127 | + unsigned long event, void *ptr); |
---|
| 128 | + |
---|
153 | 129 | void (*ctrl_msg_rx)(struct nfp_app *app, struct sk_buff *skb); |
---|
154 | 130 | void (*ctrl_msg_rx_raw)(struct nfp_app *app, const void *data, |
---|
155 | 131 | unsigned int len); |
---|
.. | .. |
---|
167 | 143 | |
---|
168 | 144 | enum devlink_eswitch_mode (*eswitch_mode_get)(struct nfp_app *app); |
---|
169 | 145 | int (*eswitch_mode_set)(struct nfp_app *app, u16 mode); |
---|
170 | | - struct net_device *(*repr_get)(struct nfp_app *app, u32 id); |
---|
| 146 | + struct net_device *(*dev_get)(struct nfp_app *app, u32 id, |
---|
| 147 | + bool *redir_egress); |
---|
171 | 148 | }; |
---|
172 | 149 | |
---|
173 | 150 | /** |
---|
.. | .. |
---|
178 | 155 | * @ctrl: pointer to ctrl vNIC struct |
---|
179 | 156 | * @reprs: array of pointers to representors |
---|
180 | 157 | * @type: pointer to const application ops and info |
---|
| 158 | + * @ctrl_mtu: MTU to set on the control vNIC (set in .init()) |
---|
| 159 | + * @netdev_nb: Netdevice notifier block |
---|
181 | 160 | * @priv: app-specific priv data |
---|
182 | 161 | */ |
---|
183 | 162 | struct nfp_app { |
---|
.. | .. |
---|
189 | 168 | struct nfp_reprs __rcu *reprs[NFP_REPR_TYPE_MAX + 1]; |
---|
190 | 169 | |
---|
191 | 170 | const struct nfp_app_type *type; |
---|
| 171 | + unsigned int ctrl_mtu; |
---|
| 172 | + |
---|
| 173 | + struct notifier_block netdev_nb; |
---|
| 174 | + |
---|
192 | 175 | void *priv; |
---|
193 | 176 | }; |
---|
194 | 177 | |
---|
| 178 | +void nfp_check_rhashtable_empty(void *ptr, void *arg); |
---|
195 | 179 | bool __nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb); |
---|
196 | 180 | bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb); |
---|
197 | 181 | |
---|
.. | .. |
---|
287 | 271 | if (!app || !app->type->repr_change_mtu) |
---|
288 | 272 | return 0; |
---|
289 | 273 | return app->type->repr_change_mtu(app, netdev, new_mtu); |
---|
290 | | -} |
---|
291 | | - |
---|
292 | | -static inline int nfp_app_start(struct nfp_app *app, struct nfp_net *ctrl) |
---|
293 | | -{ |
---|
294 | | - app->ctrl = ctrl; |
---|
295 | | - if (!app->type->start) |
---|
296 | | - return 0; |
---|
297 | | - return app->type->start(app); |
---|
298 | | -} |
---|
299 | | - |
---|
300 | | -static inline void nfp_app_stop(struct nfp_app *app) |
---|
301 | | -{ |
---|
302 | | - if (!app->type->stop) |
---|
303 | | - return; |
---|
304 | | - app->type->stop(app); |
---|
305 | 274 | } |
---|
306 | 275 | |
---|
307 | 276 | static inline const char *nfp_app_name(struct nfp_app *app) |
---|
.. | .. |
---|
429 | 398 | app->type->sriov_disable(app); |
---|
430 | 399 | } |
---|
431 | 400 | |
---|
432 | | -static inline struct net_device *nfp_app_repr_get(struct nfp_app *app, u32 id) |
---|
| 401 | +static inline |
---|
| 402 | +struct net_device *nfp_app_dev_get(struct nfp_app *app, u32 id, |
---|
| 403 | + bool *redir_egress) |
---|
433 | 404 | { |
---|
434 | | - if (unlikely(!app || !app->type->repr_get)) |
---|
| 405 | + if (unlikely(!app || !app->type->dev_get)) |
---|
435 | 406 | return NULL; |
---|
436 | 407 | |
---|
437 | | - return app->type->repr_get(app, id); |
---|
| 408 | + return app->type->dev_get(app, id, redir_egress); |
---|
438 | 409 | } |
---|
439 | 410 | |
---|
440 | 411 | struct nfp_app *nfp_app_from_netdev(struct net_device *netdev); |
---|
.. | .. |
---|
455 | 426 | |
---|
456 | 427 | struct nfp_app *nfp_app_alloc(struct nfp_pf *pf, enum nfp_app_id id); |
---|
457 | 428 | void nfp_app_free(struct nfp_app *app); |
---|
| 429 | +int nfp_app_start(struct nfp_app *app, struct nfp_net *ctrl); |
---|
| 430 | +void nfp_app_stop(struct nfp_app *app); |
---|
458 | 431 | |
---|
459 | 432 | /* Callbacks shared between apps */ |
---|
460 | 433 | |
---|
.. | .. |
---|
463 | 436 | int nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app, |
---|
464 | 437 | struct nfp_net *nn, unsigned int id); |
---|
465 | 438 | |
---|
| 439 | +struct devlink_port *nfp_devlink_get_devlink_port(struct net_device *netdev); |
---|
| 440 | + |
---|
466 | 441 | #endif |
---|