From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7D64DA0093; Tue, 19 May 2020 18:54:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C0A6D1D65B; Tue, 19 May 2020 18:53:10 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 7AB5C1D64D for ; Tue, 19 May 2020 18:53:00 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id u5so112244pgn.5 for ; Tue, 19 May 2020 09:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s49aFewguuWIhFIT8ZYKi3gpXOPufR4QcbD6gQzpcio=; b=QfHei33HQnB6e0UBFnHguSIa8a8Fz78GH1odtbinBqE6WGFsPBVyYGr36FagbykxcX RA/VShYY0ocgc7jZ3ha/blJ7TrZwJRyy+FrgKAg2wtGCMRPIru05XVDBQ3iD8bEwJ+Xj nsgOA3/Z2ri3mrkB12EBssQD8YQOos15Bb9vR77fTOfiffOw7qsfSfWHHvQRpxlMrS5d k+Wmjl5PSxBk1v3QZ+d4CUqb9yFSzOdmC1qNMx62zWzlFhsfIZjN9HE2wGXexWmqIKrQ RQUaN1WIeUd76d2YDqjXyUkbD1GPrmGIeeR+u1yA5loSLBI+ilZ+/rsgU2o7MNcqWIne KXlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s49aFewguuWIhFIT8ZYKi3gpXOPufR4QcbD6gQzpcio=; b=RnTOXwTtUrBOF1/2eT7M+NSumHeF9l2cm4wyR0mpbpyWRiwxJ0oEC/iqWts1G6nNa0 HSUKBTa7kyVkwMFYhpPKHVNLEAVBql9xe7+oW86M/GnwbRvAZSIz/nlst7VTPxL0lHJS OaNZHch2TUa50JPHIqHq6/AxOVTjT1ucGFeM87hC08sEO0CKkK1l89Cad0P8bser6JhE p39L1DK6bXrG5LVhWn6dqWuQCmYF5pmYERbZAm56aZWfsPlNfAkFVkrpxYlVNvTqwwQc cimtdJQWBLqAKW/jeuGXCbZBofTrImVh17Ra0pnK7nfOkB+T2kZv6AkxV6o3OaCBYv+e W7og== X-Gm-Message-State: AOAM5320s17d6LIG9iQOqnnizwJu+YFZ+s2/JMAA2c+8eUyFbx6WUAQk bAabRJQtflUe+LEAqaHmYl23wchk5WSyOA== X-Google-Smtp-Source: ABdhPJzTiNCNA2GYqFSOEbJlRceN0eBqBSc5RBHXIlTPbMdUEKL2FCqXWJ+l5DeD+dVgPTGai9nFYw== X-Received: by 2002:a63:f350:: with SMTP id t16mr120008pgj.33.1589907178930; Tue, 19 May 2020 09:52:58 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm107394pjm.46.2020.05.19.09.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:57 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:30 -0700 Message-Id: <20200519165230.23306-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org> References: <20200506192730.21613-1-stephen@networkplumber.org> <20200519165230.23306-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 7/7] net/netvsc: do not spin forever waiting for reply X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 #include #include +#include #include #include @@ -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