forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/netronome/nfp/nfp_app.h
....@@ -1,35 +1,5 @@
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. */
333
344 #ifndef _NFP_APP_H
355 #define _NFP_APP_H 1
....@@ -39,6 +9,8 @@
399 #include <trace/events/devlink.h>
4010
4111 #include "nfp_net_repr.h"
12
+
13
+#define NFP_APP_CTRL_MTU_MAX U32_MAX
4214
4315 struct bpf_prog;
4416 struct net_device;
....@@ -97,6 +69,7 @@
9769 * @port_get_stats_strings: get strings for extra statistics
9870 * @start: start application logic
9971 * @stop: stop application logic
72
+ * @netdev_event: Netdevice notifier event
10073 * @ctrl_msg_rx: control message handler
10174 * @ctrl_msg_rx_raw: handler for control messages from data queues
10275 * @setup_tc: setup TC ndo
....@@ -106,7 +79,7 @@
10679 * @eswitch_mode_set: set SR-IOV eswitch mode (under pf->lock)
10780 * @sriov_enable: app-specific sriov initialisation
10881 * @sriov_disable: app-specific sriov clean-up
109
- * @repr_get: get representor netdev
82
+ * @dev_get: get representor or internal port representing netdev
11083 */
11184 struct nfp_app_type {
11285 enum nfp_app_id id;
....@@ -150,6 +123,9 @@
150123 int (*start)(struct nfp_app *app);
151124 void (*stop)(struct nfp_app *app);
152125
126
+ int (*netdev_event)(struct nfp_app *app, struct net_device *netdev,
127
+ unsigned long event, void *ptr);
128
+
153129 void (*ctrl_msg_rx)(struct nfp_app *app, struct sk_buff *skb);
154130 void (*ctrl_msg_rx_raw)(struct nfp_app *app, const void *data,
155131 unsigned int len);
....@@ -167,7 +143,8 @@
167143
168144 enum devlink_eswitch_mode (*eswitch_mode_get)(struct nfp_app *app);
169145 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);
171148 };
172149
173150 /**
....@@ -178,6 +155,8 @@
178155 * @ctrl: pointer to ctrl vNIC struct
179156 * @reprs: array of pointers to representors
180157 * @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
181160 * @priv: app-specific priv data
182161 */
183162 struct nfp_app {
....@@ -189,9 +168,14 @@
189168 struct nfp_reprs __rcu *reprs[NFP_REPR_TYPE_MAX + 1];
190169
191170 const struct nfp_app_type *type;
171
+ unsigned int ctrl_mtu;
172
+
173
+ struct notifier_block netdev_nb;
174
+
192175 void *priv;
193176 };
194177
178
+void nfp_check_rhashtable_empty(void *ptr, void *arg);
195179 bool __nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
196180 bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
197181
....@@ -287,21 +271,6 @@
287271 if (!app || !app->type->repr_change_mtu)
288272 return 0;
289273 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);
305274 }
306275
307276 static inline const char *nfp_app_name(struct nfp_app *app)
....@@ -429,12 +398,14 @@
429398 app->type->sriov_disable(app);
430399 }
431400
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)
433404 {
434
- if (unlikely(!app || !app->type->repr_get))
405
+ if (unlikely(!app || !app->type->dev_get))
435406 return NULL;
436407
437
- return app->type->repr_get(app, id);
408
+ return app->type->dev_get(app, id, redir_egress);
438409 }
439410
440411 struct nfp_app *nfp_app_from_netdev(struct net_device *netdev);
....@@ -455,6 +426,8 @@
455426
456427 struct nfp_app *nfp_app_alloc(struct nfp_pf *pf, enum nfp_app_id id);
457428 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);
458431
459432 /* Callbacks shared between apps */
460433
....@@ -463,4 +436,6 @@
463436 int nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
464437 struct nfp_net *nn, unsigned int id);
465438
439
+struct devlink_port *nfp_devlink_get_devlink_port(struct net_device *netdev);
440
+
466441 #endif