Commit 9daee04a authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

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: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3fcece12
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#ifndef _NFP_APP_H #ifndef _NFP_APP_H
#define _NFP_APP_H 1 #define _NFP_APP_H 1
#include <net/devlink.h>
struct bpf_prog; struct bpf_prog;
struct net_device; struct net_device;
struct pci_dev; struct pci_dev;
...@@ -70,6 +72,7 @@ extern const struct nfp_app_type app_bpf; ...@@ -70,6 +72,7 @@ extern const struct nfp_app_type app_bpf;
* @setup_tc: setup TC ndo * @setup_tc: setup TC ndo
* @tc_busy: TC HW offload busy (rules loaded) * @tc_busy: TC HW offload busy (rules loaded)
* @xdp_offload: offload an XDP program * @xdp_offload: offload an XDP program
* @eswitch_mode_get: get SR-IOV eswitch mode
*/ */
struct nfp_app_type { struct nfp_app_type {
enum nfp_app_id id; enum nfp_app_id id;
...@@ -95,6 +98,8 @@ struct nfp_app_type { ...@@ -95,6 +98,8 @@ struct nfp_app_type {
bool (*tc_busy)(struct nfp_app *app, struct nfp_net *nn); bool (*tc_busy)(struct nfp_app *app, struct nfp_net *nn);
int (*xdp_offload)(struct nfp_app *app, struct nfp_net *nn, int (*xdp_offload)(struct nfp_app *app, struct nfp_net *nn,
struct bpf_prog *prog); struct bpf_prog *prog);
enum devlink_eswitch_mode (*eswitch_mode_get)(struct nfp_app *app);
}; };
/** /**
...@@ -216,6 +221,16 @@ static inline void nfp_app_ctrl_rx(struct nfp_app *app, struct sk_buff *skb) ...@@ -216,6 +221,16 @@ static inline void nfp_app_ctrl_rx(struct nfp_app *app, struct sk_buff *skb)
app->type->ctrl_msg_rx(app, skb); app->type->ctrl_msg_rx(app, skb);
} }
static inline int nfp_app_eswitch_mode_get(struct nfp_app *app, u16 *mode)
{
if (!app->type->eswitch_mode_get)
return -EOPNOTSUPP;
*mode = app->type->eswitch_mode_get(app);
return 0;
}
const char *nfp_app_mip_name(struct nfp_app *app); const char *nfp_app_mip_name(struct nfp_app *app);
struct sk_buff *nfp_app_ctrl_msg_alloc(struct nfp_app *app, unsigned int size); struct sk_buff *nfp_app_ctrl_msg_alloc(struct nfp_app *app, unsigned int size);
......
...@@ -149,9 +149,27 @@ nfp_devlink_port_unsplit(struct devlink *devlink, unsigned int port_index) ...@@ -149,9 +149,27 @@ nfp_devlink_port_unsplit(struct devlink *devlink, unsigned int port_index)
return ret; return ret;
} }
static int nfp_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
{
struct nfp_pf *pf = devlink_priv(devlink);
int ret;
mutex_lock(&pf->lock);
if (!pf->app) {
ret = -EBUSY;
goto out;
}
ret = nfp_app_eswitch_mode_get(pf->app, mode);
out:
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,
.eswitch_mode_get = nfp_devlink_eswitch_mode_get,
}; };
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