DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 03/14] net/sfc: handle MC reboot event
Date: Sun, 24 Dec 2017 10:46:33 +0000	[thread overview]
Message-ID: <1514112404-13398-4-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1514112404-13398-1-git-send-email-arybchenko@solarflare.com>

Implement handling of the MC reboot event received on management
event queue or detected by MCDI processing.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
---
 drivers/net/sfc/sfc.c      | 62 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/sfc/sfc.h      |  4 +++
 drivers/net/sfc/sfc_mcdi.c |  2 +-
 3 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 49d7e93..0dcfdd8 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 
 #include <rte_errno.h>
+#include <rte_alarm.h>
 
 #include "efx.h"
 
@@ -389,6 +390,58 @@ sfc_stop(struct sfc_adapter *sa)
 	sfc_log_init(sa, "done");
 }
 
+static int
+sfc_restart(struct sfc_adapter *sa)
+{
+	int rc;
+
+	SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+	if (sa->state != SFC_ADAPTER_STARTED)
+		return EINVAL;
+
+	sfc_stop(sa);
+
+	rc = sfc_start(sa);
+	if (rc != 0)
+		sfc_err(sa, "restart failed");
+
+	return rc;
+}
+
+static void
+sfc_restart_if_required(void *arg)
+{
+	struct sfc_adapter *sa = arg;
+
+	/* If restart is scheduled, clear the flag and do it */
+	if (rte_atomic32_cmpset((volatile uint32_t *)&sa->restart_required,
+				1, 0)) {
+		sfc_adapter_lock(sa);
+		if (sa->state == SFC_ADAPTER_STARTED)
+			(void)sfc_restart(sa);
+		sfc_adapter_unlock(sa);
+	}
+}
+
+void
+sfc_schedule_restart(struct sfc_adapter *sa)
+{
+	int rc;
+
+	/* Schedule restart alarm if it is not scheduled yet */
+	if (!rte_atomic32_test_and_set(&sa->restart_required))
+		return;
+
+	rc = rte_eal_alarm_set(1, sfc_restart_if_required, sa);
+	if (rc == -ENOTSUP)
+		sfc_warn(sa, "alarms are not supported, restart is pending");
+	else if (rc != 0)
+		sfc_err(sa, "cannot arm restart alarm (rc=%d)", rc);
+	else
+		sfc_info(sa, "restart scheduled");
+}
+
 int
 sfc_configure(struct sfc_adapter *sa)
 {
@@ -679,6 +732,7 @@ sfc_probe(struct sfc_adapter *sa)
 	SFC_ASSERT(sfc_adapter_is_locked(sa));
 
 	sa->socket_id = rte_socket_id();
+	rte_atomic32_init(&sa->restart_required);
 
 	sfc_log_init(sa, "init mem bar");
 	rc = sfc_mem_bar_init(sa);
@@ -743,6 +797,14 @@ sfc_unprobe(struct sfc_adapter *sa)
 
 	sfc_mcdi_fini(sa);
 
+	/*
+	 * Make sure there is no pending alarm to restart since we are
+	 * going to free device private which is passed as the callback
+	 * opaque data. A new alarm cannot be scheduled since MCDI is
+	 * shut down.
+	 */
+	rte_eal_alarm_cancel(sfc_restart_if_required, sa);
+
 	sfc_log_init(sa, "destroy nic");
 	sa->nic = NULL;
 	efx_nic_destroy(enp);
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index ef980a4..77882eb 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -39,6 +39,7 @@
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
+#include <rte_atomic.h>
 
 #include "efx.h"
 
@@ -197,6 +198,7 @@ struct sfc_adapter {
 	efx_family_t			family;
 	efx_nic_t			*nic;
 	rte_spinlock_t			nic_lock;
+	rte_atomic32_t			restart_required;
 
 	struct sfc_mcdi			mcdi;
 	struct sfc_intr			intr;
@@ -329,6 +331,8 @@ void sfc_detach(struct sfc_adapter *sa);
 int sfc_start(struct sfc_adapter *sa);
 void sfc_stop(struct sfc_adapter *sa);
 
+void sfc_schedule_restart(struct sfc_adapter *sa);
+
 int sfc_mcdi_init(struct sfc_adapter *sa);
 void sfc_mcdi_fini(struct sfc_adapter *sa);
 
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 0faad3e..f4763ab 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -176,7 +176,7 @@ sfc_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
 	    (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN");
 
-	sfc_panic(sa, "MCDI exceptions handling is not implemented\n");
+	sfc_schedule_restart(sa);
 }
 
 #define SFC_MCDI_LOG_BUF_SIZE	128
-- 
2.7.4

  parent reply	other threads:[~2017-12-24 10:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-24 10:46 [dpdk-dev] [PATCH 00/14] net/sfc: support NVGRE, VXLAN and GENEVE tunnels Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 01/14] net/sfc: fix label name to be consistent Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 02/14] net/sfc: do not hold management event queue lock while MCDI Andrew Rybchenko
2017-12-24 10:46 ` Andrew Rybchenko [this message]
2017-12-24 10:46 ` [dpdk-dev] [PATCH 04/14] net/sfc: retry port start to handle MC reboot in the middle Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 05/14] net/sfc/base: control RxQ scatter using flag instead of type Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 06/14] net/sfc/base: add function to create packed stream RxQ Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 07/14] net/sfc/base: allow to request inner classes for Rx packets Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 08/14] net/sfc/base: add API to control UDP tunnel ports Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 09/14] net/sfc: support UDP tunnel ports configuration Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 10/14] net/sfc: fix incorrect bitwise ORing of L3/L4 packet types Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 11/14] net/sfc: support VXLAN and NVGRE packet types classification Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 12/14] net/sfc: correct Rx checksum offloads for tunnel packets Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 13/14] net/sfc: support inner checksum offload on transmit Andrew Rybchenko
2017-12-24 10:46 ` [dpdk-dev] [PATCH 14/14] doc: add net/sfc tunnels support to release features Andrew Rybchenko
2018-01-09 17:31 ` [dpdk-dev] [PATCH 00/14] net/sfc: support NVGRE, VXLAN and GENEVE tunnels 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=1514112404-13398-4-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
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).