Skip to content

Commit 9daee04

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: devlink add support for getting eswitch mode
Add app callback for reporting eswitch mode. Non-SRIOV apps should not implement this callback, nfp_app code will then respond with -EOPNOTSUPP. Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3fcece1 commit 9daee04

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

drivers/net/ethernet/netronome/nfp/nfp_app.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#ifndef _NFP_APP_H
3535
#define _NFP_APP_H 1
3636

37+
#include <net/devlink.h>
38+
3739
struct bpf_prog;
3840
struct net_device;
3941
struct pci_dev;
@@ -70,6 +72,7 @@ extern const struct nfp_app_type app_bpf;
7072
* @setup_tc: setup TC ndo
7173
* @tc_busy: TC HW offload busy (rules loaded)
7274
* @xdp_offload: offload an XDP program
75+
* @eswitch_mode_get: get SR-IOV eswitch mode
7376
*/
7477
struct nfp_app_type {
7578
enum nfp_app_id id;
@@ -95,6 +98,8 @@ struct nfp_app_type {
9598
bool (*tc_busy)(struct nfp_app *app, struct nfp_net *nn);
9699
int (*xdp_offload)(struct nfp_app *app, struct nfp_net *nn,
97100
struct bpf_prog *prog);
101+
102+
enum devlink_eswitch_mode (*eswitch_mode_get)(struct nfp_app *app);
98103
};
99104

100105
/**
@@ -216,6 +221,16 @@ static inline void nfp_app_ctrl_rx(struct nfp_app *app, struct sk_buff *skb)
216221
app->type->ctrl_msg_rx(app, skb);
217222
}
218223

224+
static inline int nfp_app_eswitch_mode_get(struct nfp_app *app, u16 *mode)
225+
{
226+
if (!app->type->eswitch_mode_get)
227+
return -EOPNOTSUPP;
228+
229+
*mode = app->type->eswitch_mode_get(app);
230+
231+
return 0;
232+
}
233+
219234
const char *nfp_app_mip_name(struct nfp_app *app);
220235
struct sk_buff *nfp_app_ctrl_msg_alloc(struct nfp_app *app, unsigned int size);
221236

drivers/net/ethernet/netronome/nfp/nfp_devlink.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,27 @@ nfp_devlink_port_unsplit(struct devlink *devlink, unsigned int port_index)
149149
return ret;
150150
}
151151

152+
static int nfp_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
153+
{
154+
struct nfp_pf *pf = devlink_priv(devlink);
155+
int ret;
156+
157+
mutex_lock(&pf->lock);
158+
if (!pf->app) {
159+
ret = -EBUSY;
160+
goto out;
161+
}
162+
ret = nfp_app_eswitch_mode_get(pf->app, mode);
163+
out:
164+
mutex_unlock(&pf->lock);
165+
166+
return ret;
167+
}
168+
152169
const struct devlink_ops nfp_devlink_ops = {
153170
.port_split = nfp_devlink_port_split,
154171
.port_unsplit = nfp_devlink_port_unsplit,
172+
.eswitch_mode_get = nfp_devlink_eswitch_mode_get,
155173
};
156174

157175
int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port)

0 commit comments

Comments
 (0)