DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 13/14] net/sfc: use MCDI control structure as libefx ops context
Date: Tue, 8 Sep 2020 10:14:34 +0100
Message-ID: <1599556475-27820-15-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com>

Now MCDI helpers interface is independent from network driver and
may be moved into common driver.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 47 +++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 28 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index fa9160f6d3..ff2bc14c5d 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -52,10 +52,8 @@
 	sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__)
 
 static void
-sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
+sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
-
 	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
 
 	mcdi->state = SFC_EFX_MCDI_DEAD;
@@ -64,10 +62,8 @@ sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 }
 
 static inline boolean_t
-sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
+sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
-
 	mcdi->proxy_handle = 0;
 	mcdi->proxy_result = ETIMEDOUT;
 	mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie);
@@ -78,9 +74,8 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
 }
 
 static void
-sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
+sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy)
 {
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	efx_nic_t *enp;
 	unsigned int delay_total;
 	unsigned int delay_us;
@@ -93,8 +88,9 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 	do {
 		boolean_t poll_completed;
 
-		poll_completed = (proxy) ? sfc_efx_mcdi_proxy_event_available(sa) :
-					   efx_mcdi_request_poll(enp);
+		poll_completed = (proxy) ?
+				sfc_efx_mcdi_proxy_event_available(mcdi) :
+				efx_mcdi_request_poll(enp);
 		if (poll_completed)
 			return;
 
@@ -102,7 +98,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 			if (!proxy) {
 				aborted = efx_mcdi_request_abort(enp);
 				SFC_ASSERT(aborted);
-				sfc_efx_mcdi_timeout(sa);
+				sfc_efx_mcdi_timeout(mcdi);
 			}
 
 			return;
@@ -125,8 +121,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 static void
 sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 	uint32_t proxy_handle;
 
 	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
@@ -139,7 +134,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-	sfc_efx_mcdi_poll(sa, B_FALSE);
+	sfc_efx_mcdi_poll(mcdi, B_FALSE);
 
 	if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) {
 		/*
@@ -148,7 +143,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 		 * a non-zero proxy handle (should be the same as
 		 * the value obtained above) and operation status
 		 */
-		sfc_efx_mcdi_poll(sa, B_TRUE);
+		sfc_efx_mcdi_poll(mcdi, B_TRUE);
 
 		if ((mcdi->proxy_handle != 0) &&
 		    (mcdi->proxy_handle != proxy_handle)) {
@@ -160,7 +155,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 			 * request and poll for an ordinary MCDI response
 			 */
 			efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-			sfc_efx_mcdi_poll(sa, B_FALSE);
+			sfc_efx_mcdi_poll(mcdi, B_FALSE);
 		} else {
 			emrp->emr_rc = mcdi->proxy_result;
 			sfc_efx_mcdi_err(mcdi,
@@ -175,10 +170,9 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 static void
 sfc_efx_mcdi_ev_cpl(void *arg)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi __rte_unused;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 
-	mcdi = &sa->mcdi;
+	RTE_SET_USED(mcdi);
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	/* MCDI is polled, completions are not expected */
@@ -188,8 +182,7 @@ sfc_efx_mcdi_ev_cpl(void *arg)
 static void
 sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi  = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 
 	sfc_efx_mcdi_warn(mcdi, "MC %s",
 	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
@@ -234,8 +227,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 		void *header, size_t header_size,
 		void *data, size_t data_size)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 	char buffer[SFC_MCDI_LOG_BUF_SIZE];
 	size_t pfxsize;
 	size_t start;
@@ -269,15 +261,14 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 static void
 sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 
 	mcdi->proxy_handle = handle;
 	mcdi->proxy_result = result;
 }
 
 static int
-sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
+sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
 		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic,
 		  const struct sfc_efx_mcdi_ops *ops, void *ops_cookie)
 {
@@ -308,7 +299,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 		goto fail_dma_alloc;
 
 	emtp = &mcdi->transport;
-	emtp->emt_context = sa;
+	emtp->emt_context = mcdi;
 	emtp->emt_dma_mem = &mcdi->mem;
 	emtp->emt_execute = sfc_efx_mcdi_execute;
 	emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl;
@@ -409,7 +400,7 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 				       SFC_LOGTYPE_MCDI_STR,
 				       RTE_LOG_NOTICE);
 
-	return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype,
+	return sfc_efx_mcdi_init(&sa->mcdi, logtype,
 				 sa->priv.shared->log_prefix, sa->nic,
 				 &sfc_mcdi_ops, sa);
 }
-- 
2.17.1


  parent reply	other threads:[~2020-09-08  9:16 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/iavf: downgrade error log Andrew Rybchenko
2020-09-08  9:26   ` Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/sfc: include header with debug helpers directly Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 02/14] net/sfc: introduce common driver library Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 03/14] net/sfc: add dedicated header file with MCDI interface Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 04/14] net/sfc: move MCDI helper interface to dedicated namespace Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 05/14] net/sfc: make MCDI logging helper macros local Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 06/14] net/sfc: start to make MCDI helpers interface shareable Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 07/14] net/sfc: use own logging helper macros Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 08/14] net/sfc: avoid usage of NIC pointer from adapter context Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 09/14] net/sfc: avoid panic in the case of MCDI timeout Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 10/14] net/sfc: add MCDI callbacks to allocate/free DMA memory Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 11/14] net/sfc: add MCDI callback to schedule restart Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 12/14] net/sfc: add MCDI callback to poll management event queue Andrew Rybchenko
2020-09-08  9:14 ` Andrew Rybchenko [this message]
2020-09-08  9:14 ` [dpdk-dev] [PATCH 14/14] net/sfc: move MCDI helpers to common driver Andrew Rybchenko
2020-09-09 14:32 ` [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Ferruh Yigit
2020-09-17  6:21   ` Andrew Rybchenko
2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 01/17] net/sfc/base: add missing extern storage-class specifiers Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 02/17] net/sfc/base: decorate libefx API functions Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 03/17] net/sfc/base: decorate libefx internal extern functions Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 04/17] net/sfc: include header with debug helpers directly Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 05/17] net/sfc: introduce common driver library Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 06/17] net/sfc: add dedicated header file with MCDI interface Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 07/17] net/sfc: move MCDI helper interface to dedicated namespace Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 08/17] net/sfc: make MCDI logging helper macros local Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 09/17] net/sfc: start to make MCDI helpers interface shareable Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 10/17] net/sfc: use own logging helper macros Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 11/17] net/sfc: avoid usage of NIC pointer from adapter context Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 12/17] net/sfc: avoid panic in the case of MCDI timeout Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 13/17] net/sfc: add MCDI callbacks to allocate/free DMA memory Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 14/17] net/sfc: add MCDI callback to schedule restart Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 15/17] net/sfc: add MCDI callback to poll management event queue Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 16/17] net/sfc: use MCDI control structure as libefx ops context Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 17/17] net/sfc: move MCDI helpers to common driver Andrew Rybchenko
2020-09-21 22:38   ` [dpdk-dev] [PATCH v2 00/17] net/sfc: factor out common driver library 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=1599556475-27820-15-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    /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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git