From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Ivan Malov <ivan.malov@oktetlabs.ru>
Subject: [PATCH 6/6] net/sfc: add support for MCDI proxy
Date: Thu, 2 Mar 2017 15:46:48 +0000 [thread overview]
Message-ID: <1488469608-2252-7-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1488469608-2252-1-git-send-email-arybchenko@solarflare.com>
From: Ivan Malov <ivan.malov@oktetlabs.ru>
The patch is to add support for MCDI proxy which comes in
useful, particularly, while running over VF: few commands
will normally fail with EPERM, but in some cases the host
driver (i.e. running over the corresponding PF, typically,
within a hypervisor) may set itself as a proxy to conduct
authorization for the commands coming from VFs; these are
forwarded to the corresponding access control application
which may decline or approve authorization by replying to
the requests; all in all, the guest driver has to process
the replies forwarded back by the firmware MC in order to
give up gracefully (by setting return code which could be
understood by 'libefx') or re-issue the original commands
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
drivers/net/sfc/efsys.h | 2 +-
drivers/net/sfc/sfc.h | 2 ++
drivers/net/sfc/sfc_mcdi.c | 74 ++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h
index 60829be..d52552b 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/net/sfc/efsys.h
@@ -177,7 +177,7 @@ prefetch_read_once(const volatile void *addr)
/* MCDI is required for SFN7xxx and SFN8xx */
#define EFSYS_OPT_MCDI 1
#define EFSYS_OPT_MCDI_LOGGING 1
-#define EFSYS_OPT_MCDI_PROXY_AUTH 0
+#define EFSYS_OPT_MCDI_PROXY_AUTH 1
#define EFSYS_OPT_MAC_STATS 1
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 204a054..5c633c8 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -125,6 +125,8 @@ struct sfc_mcdi {
enum sfc_mcdi_state state;
efx_mcdi_transport_t transport;
bool logging;
+ uint32_t proxy_handle;
+ efx_rc_t proxy_result;
};
struct sfc_intr {
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 3bed2e0..43dbf13 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -36,6 +36,7 @@
#include "sfc.h"
#include "sfc_log.h"
#include "sfc_kvargs.h"
+#include "sfc_ev.h"
#define SFC_MCDI_POLL_INTERVAL_MIN_US 10 /* 10us in 1us units */
#define SFC_MCDI_POLL_INTERVAL_MAX_US (US_PER_S / 10) /* 100ms in 1us units */
@@ -49,8 +50,22 @@ sfc_mcdi_timeout(struct sfc_adapter *sa)
sfc_panic(sa, "MCDI timeout handling is not implemented\n");
}
+static inline boolean_t
+sfc_mcdi_proxy_event_available(struct sfc_adapter *sa)
+{
+ struct sfc_mcdi *mcdi = &sa->mcdi;
+
+ mcdi->proxy_handle = 0;
+ mcdi->proxy_result = ETIMEDOUT;
+ sfc_ev_mgmt_qpoll(sa);
+ if (mcdi->proxy_result != ETIMEDOUT)
+ return B_TRUE;
+
+ return B_FALSE;
+}
+
static void
-sfc_mcdi_poll(struct sfc_adapter *sa)
+sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
{
efx_nic_t *enp;
unsigned int delay_total;
@@ -62,13 +77,20 @@ sfc_mcdi_poll(struct sfc_adapter *sa)
enp = sa->nic;
do {
- if (efx_mcdi_request_poll(enp))
+ boolean_t poll_completed;
+
+ poll_completed = (proxy) ? sfc_mcdi_proxy_event_available(sa) :
+ efx_mcdi_request_poll(enp);
+ if (poll_completed)
return;
if (delay_total > SFC_MCDI_WATCHDOG_INTERVAL_US) {
- aborted = efx_mcdi_request_abort(enp);
- SFC_ASSERT(aborted);
- sfc_mcdi_timeout(sa);
+ if (!proxy) {
+ aborted = efx_mcdi_request_abort(enp);
+ SFC_ASSERT(aborted);
+ sfc_mcdi_timeout(sa);
+ }
+
return;
}
@@ -90,13 +112,42 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
{
struct sfc_adapter *sa = (struct sfc_adapter *)arg;
struct sfc_mcdi *mcdi = &sa->mcdi;
+ uint32_t proxy_handle;
rte_spinlock_lock(&mcdi->lock);
SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
- sfc_mcdi_poll(sa);
+ sfc_mcdi_poll(sa, B_FALSE);
+
+ if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) {
+ /*
+ * Authorization is required for the MCDI request;
+ * wait for an MCDI proxy response event to bring
+ * a non-zero proxy handle (should be the same as
+ * the value obtained above) and operation status
+ */
+ sfc_mcdi_poll(sa, B_TRUE);
+
+ if ((mcdi->proxy_handle != 0) &&
+ (mcdi->proxy_handle != proxy_handle)) {
+ sfc_err(sa, "Unexpected MCDI proxy event");
+ emrp->emr_rc = EFAULT;
+ } else if (mcdi->proxy_result == 0) {
+ /*
+ * Authorization succeeded; re-issue the original
+ * request and poll for an ordinary MCDI response
+ */
+ efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
+ sfc_mcdi_poll(sa, B_FALSE);
+ } else {
+ emrp->emr_rc = mcdi->proxy_result;
+ sfc_err(sa, "MCDI proxy authorization failed "
+ "(handle=%08x, result=%d)",
+ proxy_handle, mcdi->proxy_result);
+ }
+ }
rte_spinlock_unlock(&mcdi->lock);
}
@@ -185,6 +236,16 @@ sfc_mcdi_logger(void *arg, efx_log_msg_t type,
}
}
+static void
+sfc_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
+{
+ struct sfc_adapter *sa = (struct sfc_adapter *)arg;
+ struct sfc_mcdi *mcdi = &sa->mcdi;
+
+ mcdi->proxy_handle = handle;
+ mcdi->proxy_result = result;
+}
+
int
sfc_mcdi_init(struct sfc_adapter *sa)
{
@@ -222,6 +283,7 @@ sfc_mcdi_init(struct sfc_adapter *sa)
emtp->emt_ev_cpl = sfc_mcdi_ev_cpl;
emtp->emt_exception = sfc_mcdi_exception;
emtp->emt_logger = sfc_mcdi_logger;
+ emtp->emt_ev_proxy_response = sfc_mcdi_ev_proxy_response;
sfc_log_init(sa, "init MCDI");
rc = efx_mcdi_init(sa->nic, emtp);
--
2.9.3
next prev parent reply other threads:[~2017-03-02 15:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-02 15:46 [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-02 15:46 ` [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
2017-03-06 10:10 ` Ferruh Yigit
2017-03-06 14:00 ` Andrew Rybchenko
2017-03-02 15:46 ` [PATCH 2/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
2017-03-02 15:46 ` [PATCH 3/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
2017-03-02 15:46 ` [PATCH 4/6] net/sfc: port HW stats must work if periodic DMA is absent Andrew Rybchenko
2017-03-02 15:46 ` [PATCH 5/6] net/sfc: port must not fail to start if Rx mode is rejected Andrew Rybchenko
2017-03-06 10:24 ` Ferruh Yigit
2017-03-02 15:46 ` Andrew Rybchenko [this message]
2017-03-09 17:22 ` [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-09 17:22 ` [PATCH v2 1/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
2017-03-09 17:22 ` [PATCH v2 2/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
2017-03-09 17:23 ` [PATCH v2 3/6] net/sfc: poll MAC stats if periodic DMA is not supported Andrew Rybchenko
2017-03-09 17:23 ` [PATCH v2 4/6] net/sfc: avoid failure on port start if Rx mode is rejected Andrew Rybchenko
2017-03-09 17:23 ` [PATCH v2 5/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
2017-03-15 11:13 ` Ferruh Yigit
2017-03-09 17:23 ` [PATCH v2 6/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
2017-03-15 11:11 ` [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Ferruh Yigit
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=1488469608-2252-7-git-send-email-arybchenko@solarflare.com \
--to=arybchenko@solarflare.com \
--cc=dev@dpdk.org \
--cc=ivan.malov@oktetlabs.ru \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.