DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH v3 6/7] net/netvsc: process link change messages in alarm
Date: Tue, 19 May 2020 09:52:29 -0700
Message-ID: <20200519165230.23306-7-stephen@networkplumber.org> (raw)
In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org>

The original code would deadlock itself if a link change event
happened with link state interrupt enabled. The problem is that
the link state changed message would be seen while reading
the host to guest ring (under lock) and then the driver would
send a query to the host to see the new link state. The response
would never be seen (stuck in a while loop) waiting for the
response.

The solution is to use the link change indication to trigger
a DPDK alarm. The alarm will happen in a different thread and
in that context it can send request for new link state and
also do interrupt callback. This is similar to how the bonding
driver is handling the same thing.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/netvsc/hn_rndis.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c
index 7947ca2331e2..6a850ce5f226 100644
--- a/drivers/net/netvsc/hn_rndis.c
+++ b/drivers/net/netvsc/hn_rndis.c
@@ -17,6 +17,7 @@
 #include <rte_memzone.h>
 #include <rte_malloc.h>
 #include <rte_atomic.h>
+#include <rte_alarm.h>
 #include <rte_branch_prediction.h>
 #include <rte_ether.h>
 #include <rte_common.h>
@@ -281,6 +282,15 @@ static int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan,
 				  &nvs_rndis, sizeof(nvs_rndis), 0U, NULL);
 }
 
+/*
+ * Alarm callback to process link changed notifications.
+ * Can not directly since link_status is discovered while reading ring
+ */
+static void hn_rndis_link_alarm(void *arg)
+{
+	_rte_eth_dev_callback_process(arg, RTE_ETH_EVENT_INTR_LSC, NULL);
+}
+
 void hn_rndis_link_status(struct rte_eth_dev *dev, const void *msg)
 {
 	const struct rndis_status_msg *indicate = msg;
@@ -298,11 +308,8 @@ void hn_rndis_link_status(struct rte_eth_dev *dev, const void *msg)
 	case RNDIS_STATUS_LINK_SPEED_CHANGE:
 	case RNDIS_STATUS_MEDIA_CONNECT:
 	case RNDIS_STATUS_MEDIA_DISCONNECT:
-		if (dev->data->dev_conf.intr_conf.lsc &&
-		    hn_dev_link_update(dev, 0) == 0)
-			_rte_eth_dev_callback_process(dev,
-						      RTE_ETH_EVENT_INTR_LSC,
-						      NULL);
+		if (dev->data->dev_conf.intr_conf.lsc)
+			rte_eal_alarm_set(10, hn_rndis_link_alarm, dev);
 		break;
 	default:
 		PMD_DRV_LOG(NOTICE, "unknown RNDIS indication: %#x",
@@ -1101,6 +1108,10 @@ hn_rndis_attach(struct hn_data *hv)
 void
 hn_rndis_detach(struct hn_data *hv)
 {
+	struct rte_eth_dev *dev = &rte_eth_devices[hv->port_id];
+
+	rte_eal_alarm_cancel(hn_rndis_link_alarm, dev);
+
 	/* Halt the RNDIS. */
 	hn_rndis_halt(hv);
 }
-- 
2.26.2


  parent reply	other threads:[~2020-05-19 16:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 19:27 [dpdk-dev] [PATCH 0/4] net/netvsc: diagnostic enhancements Stephen Hemminger
2020-05-06 19:27 ` [dpdk-dev] [PATCH 1/4] net/netvsc: support per-queue info requests Stephen Hemminger
2020-05-06 19:27 ` [dpdk-dev] [PATCH 2/4] net/netvsc: implement rx/tx descriptor status functions Stephen Hemminger
2020-05-06 19:27 ` [dpdk-dev] [PATCH 3/4] net/netvsc: change tx/rx error handling Stephen Hemminger
2020-05-06 19:27 ` [dpdk-dev] [PATCH 4/4] bus/vmbus: improve debug output Stephen Hemminger
2020-05-06 19:52 ` [dpdk-dev] [PATCH v2 0/4] net/netvsc: diagnostic enhancements Stephen Hemminger
2020-05-06 19:52   ` [dpdk-dev] [PATCH v2 1/4] net/netvsc: support per-queue info requests Stephen Hemminger
2020-05-06 19:52   ` [dpdk-dev] [PATCH v2 2/4] net/netvsc: implement rx/tx descriptor status functions Stephen Hemminger
2020-05-07 15:27     ` Ferruh Yigit
2020-05-06 19:52   ` [dpdk-dev] [PATCH v2 3/4] net/netvsc: change tx/rx error handling Stephen Hemminger
2020-05-07 15:29     ` Ferruh Yigit
2020-05-06 19:52   ` [dpdk-dev] [PATCH v2 4/4] bus/vmbus: improve debug output Stephen Hemminger
2020-05-19 16:52 ` [dpdk-dev] [PATCH v3 0/7] net/netvsc: VF bug fix and diagnostic support Stephen Hemminger
2020-05-19 16:52   ` [dpdk-dev] [PATCH v3 1/7] net/netvsc: support per-queue info requests Stephen Hemminger
2020-05-19 16:52   ` [dpdk-dev] [PATCH v3 2/7] net/netvsc: implement rx/tx descriptor status functions Stephen Hemminger
2020-05-27 18:14     ` Ferruh Yigit
2020-05-27 21:00       ` Stephen Hemminger
2020-05-19 16:52   ` [dpdk-dev] [PATCH v3 3/7] net/netvsc: change tx/rx logging Stephen Hemminger
2020-05-19 16:52   ` [dpdk-dev] [PATCH v3 4/7] net/netvsc: fix warning when VF is removed Stephen Hemminger
2020-05-19 16:52   ` [dpdk-dev] [PATCH v3 5/7] net/netvsc: don't query VF link state Stephen Hemminger
2020-05-19 16:52   ` Stephen Hemminger [this message]
2020-05-19 16:52   ` [dpdk-dev] [PATCH v3 7/7] net/netvsc: do not spin forever waiting for reply Stephen Hemminger
2020-05-27 18:16   ` [dpdk-dev] [PATCH v3 0/7] net/netvsc: VF bug fix and diagnostic support 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=20200519165230.23306-7-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --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