From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH v3 7/7] net/netvsc: do not spin forever waiting for reply
Date: Tue, 19 May 2020 09:52:30 -0700 [thread overview]
Message-ID: <20200519165230.23306-8-stephen@networkplumber.org> (raw)
In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org>
Because of bugs in driver or host a reply to a request might
never occur. Better to give an error than spin forever.
Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/netvsc/hn_rndis.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c
index 6a850ce5f226..d186ddeabda9 100644
--- a/drivers/net/netvsc/hn_rndis.c
+++ b/drivers/net/netvsc/hn_rndis.c
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
+#include <time.h>
#include <rte_ethdev_driver.h>
#include <rte_ethdev.h>
@@ -34,6 +35,9 @@
#include "hn_rndis.h"
#include "ndis.h"
+#define RNDIS_TIMEOUT_SEC 5
+#define RNDIS_DELAY_MS 10
+
#define HN_RNDIS_XFER_SIZE 0x4000
#define HN_NDIS_TXCSUM_CAP_IP4 \
@@ -354,7 +358,7 @@ void hn_rndis_receive_response(struct hn_data *hv,
rte_smp_wmb();
if (rte_atomic32_cmpset(&hv->rndis_pending, hdr->rid, 0) == 0) {
- PMD_DRV_LOG(ERR,
+ PMD_DRV_LOG(NOTICE,
"received id %#x pending id %#x",
hdr->rid, (uint32_t)hv->rndis_pending);
}
@@ -377,6 +381,11 @@ static int hn_rndis_exec1(struct hn_data *hv,
return -EIO;
}
+ if (rid == 0) {
+ PMD_DRV_LOG(ERR, "Invalid request id");
+ return -EINVAL;
+ }
+
if (comp != NULL &&
rte_atomic32_cmpset(&hv->rndis_pending, 0, rid) == 0) {
PMD_DRV_LOG(ERR,
@@ -391,9 +400,26 @@ static int hn_rndis_exec1(struct hn_data *hv,
}
if (comp) {
+ time_t start = time(NULL);
+
/* Poll primary channel until response received */
- while (hv->rndis_pending == rid)
+ while (hv->rndis_pending == rid) {
+ if (hv->closed)
+ return -ENETDOWN;
+
+ if (time(NULL) - start > RNDIS_TIMEOUT_SEC) {
+ PMD_DRV_LOG(ERR,
+ "RNDIS response timed out");
+
+ rte_atomic32_cmpset(&hv->rndis_pending, rid, 0);
+ return -ETIMEDOUT;
+ }
+
+ if (rte_vmbus_chan_rx_empty(hv->primary->chan))
+ rte_delay_ms(RNDIS_DELAY_MS);
+
hn_process_events(hv, 0, 1);
+ }
memcpy(comp, hv->rndis_resp, comp_len);
}
--
2.26.2
next prev parent reply other threads:[~2020-05-19 16:54 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 ` [dpdk-dev] [PATCH v3 6/7] net/netvsc: process link change messages in alarm Stephen Hemminger
2020-05-19 16:52 ` Stephen Hemminger [this message]
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-8-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
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).