From: Simon Horman <simon.horman@netronome.com>
To: David Miller <davem@davemloft.net>,
Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
Or Gerlitz <gerlitz.or@gmail.com>,
Simon Horman <simon.horman@netronome.com>
Subject: [PATCH net-next v2 02/12] nfp: devlink add support for getting eswitch mode
Date: Tue, 20 Jun 2017 23:36:10 +0200 [thread overview]
Message-ID: <1497994580-6271-3-git-send-email-simon.horman@netronome.com> (raw)
In-Reply-To: <1497994580-6271-1-git-send-email-simon.horman@netronome.com>
From: Jakub Kicinski <jakub.kicinski@netronome.com>
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 <jakub.kicinski@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
drivers/net/ethernet/netronome/nfp/nfp_app.h | 15 +++++++++++++++
drivers/net/ethernet/netronome/nfp/nfp_devlink.c | 18 ++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_app.h b/drivers/net/ethernet/netronome/nfp/nfp_app.h
index f5e373fa8c3b..0fee14ffa081 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_app.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_app.h
@@ -34,6 +34,8 @@
#ifndef _NFP_APP_H
#define _NFP_APP_H 1
+#include <net/devlink.h>
+
struct bpf_prog;
struct net_device;
struct pci_dev;
@@ -70,6 +72,7 @@ extern const struct nfp_app_type app_bpf;
* @setup_tc: setup TC ndo
* @tc_busy: TC HW offload busy (rules loaded)
* @xdp_offload: offload an XDP program
+ * @eswitch_mode_get: get SR-IOV eswitch mode
*/
struct nfp_app_type {
enum nfp_app_id id;
@@ -95,6 +98,8 @@ struct nfp_app_type {
bool (*tc_busy)(struct nfp_app *app, struct nfp_net *nn);
int (*xdp_offload)(struct nfp_app *app, struct nfp_net *nn,
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)
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);
struct sk_buff *nfp_app_ctrl_msg_alloc(struct nfp_app *app, unsigned int size);
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
index 2609a0f28e81..6c9f29c2e975 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
@@ -149,9 +149,27 @@ nfp_devlink_port_unsplit(struct devlink *devlink, unsigned int port_index)
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 = {
.port_split = nfp_devlink_port_split,
.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)
--
2.1.4
next prev parent reply other threads:[~2017-06-20 21:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 21:36 [PATCH net-next v2 00/12] nfp: add flower app with representors Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 01/12] net: store port/representator id in metadata_dst Simon Horman
2017-06-20 21:36 ` Simon Horman [this message]
2017-06-20 21:36 ` [PATCH net-next v2 03/12] nfp: move physical port init into a helper Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 04/12] nfp: map mac_stats and vf_cfg BARs Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 05/12] nfp: general representor implementation Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 06/12] nfp: add stats and xmit helpers for representors Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 07/12] nfp: app callbacks for SRIOV Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 08/12] nfp: provide nfp_port to of nfp_net_get_mac_addr() Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 09/12] nfp: add support for tx/rx with metadata portid Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 10/12] nfp: add support for control messages for flower app Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 11/12] nfp: add " Simon Horman
2017-06-21 9:04 ` Or Gerlitz
2017-06-21 9:59 ` Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 12/12] nfp: add VF and PF representors to " Simon Horman
2017-06-22 14:50 ` Or Gerlitz
2017-06-22 19:08 ` Simon Horman
2017-06-21 19:40 ` [PATCH net-next v2 00/12] nfp: add flower app with representors David Miller
2017-06-22 14:54 ` Or Gerlitz
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=1497994580-6271-3-git-send-email-simon.horman@netronome.com \
--to=simon.horman@netronome.com \
--cc=davem@davemloft.net \
--cc=gerlitz.or@gmail.com \
--cc=jakub.kicinski@netronome.com \
--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).