From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next 09/13] nfp: add devlink_eswitch_mode_set callback
Date: Mon, 21 May 2018 22:12:51 -0700 [thread overview]
Message-ID: <20180522051255.9438-10-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180522051255.9438-1-jakub.kicinski@netronome.com>
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: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
drivers/net/ethernet/netronome/nfp/nfp_app.h | 9 +++++++++
drivers/net/ethernet/netronome/nfp/nfp_devlink.c | 13 +++++++++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_app.h b/drivers/net/ethernet/netronome/nfp/nfp_app.h
index fdf2593ae151..23b99a4e05c2 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_app.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_app.h
@@ -97,6 +97,7 @@ extern const struct nfp_app_type app_abm;
* @bpf: BPF ndo offload-related calls
* @xdp_offload: offload an XDP program
* @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_disable: app-specific sriov clean-up
* @repr_get: get representor netdev
@@ -148,6 +149,7 @@ struct nfp_app_type {
void (*sriov_disable)(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);
};
@@ -372,6 +374,13 @@ static inline int nfp_app_eswitch_mode_get(struct nfp_app *app, u16 *mode)
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)
{
if (!app || !app->type->sriov_enable)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
index 73c7fcc820ac..71c2edd83031 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
@@ -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);
}
+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 = {
.port_split = nfp_devlink_port_split,
.port_unsplit = nfp_devlink_port_unsplit,
.sb_pool_get = nfp_devlink_sb_pool_get,
.sb_pool_set = nfp_devlink_sb_pool_set,
.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)
--
2.17.0
next prev parent reply other threads:[~2018-05-22 5:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-22 5:12 [PATCH net-next 00/13] nfp: abm: add basic support for advanced buffering NIC Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 01/13] nfp: move rtsym helpers to pf code Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 02/13] nfp: add support for per-PCI PF mailbox Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 03/13] nfp: add shared buffer configuration Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 04/13] nfp: core: allow 4-byte aligned accesses to Memory Units Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 05/13] nfp: abm: add initial active buffer management NIC skeleton Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 06/13] nfp: abm: create project-specific vNIC structure Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 07/13] nfp: add app pointer to port representors Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 08/13] devlink: don't take instance lock around eswitch mode set Jakub Kicinski
2018-05-22 8:41 ` Jiri Pirko
2018-05-22 5:12 ` Jakub Kicinski [this message]
2018-05-22 5:12 ` [PATCH net-next 10/13] nfp: abm: spawn port netdevs Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 11/13] nfp: abm: force Ethternet port up Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 12/13] nfp: use split in naming of PCIe PF ports Jakub Kicinski
2018-05-22 5:12 ` [PATCH net-next 13/13] nfp: assign vNIC id as phys_port_name of vNICs which are not ports Jakub Kicinski
2018-05-22 6:32 ` [PATCH net-next 00/13] nfp: abm: add basic support for advanced buffering NIC Or Gerlitz
2018-05-22 7:56 ` Jakub Kicinski
2018-05-22 14:50 ` Or Gerlitz
2018-05-22 19:14 ` Jakub Kicinski
2018-05-23 18:28 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180522051255.9438-10-jakub.kicinski@netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).