Commit 4afa3af4 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: add devlink_eswitch_mode_set callback

Our previous apps all assumed to use only one eswitch mode (legacy
or switchdev) without the ability to change it.  ABM NIC will
want to support the switch so plumb devlink_eswitch_mode_set through.
The devlink_eswitch_mode_set is expected to spawn representors and
potentially devlink ports so it's called under big devlink lock and
pf->lock.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarDirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7ac1cc9a
...@@ -97,6 +97,7 @@ extern const struct nfp_app_type app_abm; ...@@ -97,6 +97,7 @@ extern const struct nfp_app_type app_abm;
* @bpf: BPF ndo offload-related calls * @bpf: BPF ndo offload-related calls
* @xdp_offload: offload an XDP program * @xdp_offload: offload an XDP program
* @eswitch_mode_get: get SR-IOV eswitch mode * @eswitch_mode_get: get SR-IOV eswitch mode
* @eswitch_mode_set: set SR-IOV eswitch mode (under pf->lock)
* @sriov_enable: app-specific sriov initialisation * @sriov_enable: app-specific sriov initialisation
* @sriov_disable: app-specific sriov clean-up * @sriov_disable: app-specific sriov clean-up
* @repr_get: get representor netdev * @repr_get: get representor netdev
...@@ -148,6 +149,7 @@ struct nfp_app_type { ...@@ -148,6 +149,7 @@ struct nfp_app_type {
void (*sriov_disable)(struct nfp_app *app); void (*sriov_disable)(struct nfp_app *app);
enum devlink_eswitch_mode (*eswitch_mode_get)(struct nfp_app *app); enum devlink_eswitch_mode (*eswitch_mode_get)(struct nfp_app *app);
int (*eswitch_mode_set)(struct nfp_app *app, u16 mode);
struct net_device *(*repr_get)(struct nfp_app *app, u32 id); struct net_device *(*repr_get)(struct nfp_app *app, u32 id);
}; };
...@@ -372,6 +374,13 @@ static inline int nfp_app_eswitch_mode_get(struct nfp_app *app, u16 *mode) ...@@ -372,6 +374,13 @@ static inline int nfp_app_eswitch_mode_get(struct nfp_app *app, u16 *mode)
return 0; return 0;
} }
static inline int nfp_app_eswitch_mode_set(struct nfp_app *app, u16 mode)
{
if (!app->type->eswitch_mode_set)
return -EOPNOTSUPP;
return app->type->eswitch_mode_set(app, mode);
}
static inline int nfp_app_sriov_enable(struct nfp_app *app, int num_vfs) static inline int nfp_app_sriov_enable(struct nfp_app *app, int num_vfs)
{ {
if (!app || !app->type->sriov_enable) if (!app || !app->type->sriov_enable)
......
...@@ -176,12 +176,25 @@ static int nfp_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode) ...@@ -176,12 +176,25 @@ static int nfp_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
return nfp_app_eswitch_mode_get(pf->app, mode); return nfp_app_eswitch_mode_get(pf->app, mode);
} }
static int nfp_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode)
{
struct nfp_pf *pf = devlink_priv(devlink);
int ret;
mutex_lock(&pf->lock);
ret = nfp_app_eswitch_mode_set(pf->app, mode);
mutex_unlock(&pf->lock);
return ret;
}
const struct devlink_ops nfp_devlink_ops = { const struct devlink_ops nfp_devlink_ops = {
.port_split = nfp_devlink_port_split, .port_split = nfp_devlink_port_split,
.port_unsplit = nfp_devlink_port_unsplit, .port_unsplit = nfp_devlink_port_unsplit,
.sb_pool_get = nfp_devlink_sb_pool_get, .sb_pool_get = nfp_devlink_sb_pool_get,
.sb_pool_set = nfp_devlink_sb_pool_set, .sb_pool_set = nfp_devlink_sb_pool_set,
.eswitch_mode_get = nfp_devlink_eswitch_mode_get, .eswitch_mode_get = nfp_devlink_eswitch_mode_get,
.eswitch_mode_set = nfp_devlink_eswitch_mode_set,
}; };
int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port) int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment