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 BF84CA0093; Tue, 19 May 2020 18:53:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 34D851D658; Tue, 19 May 2020 18:53:08 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id AEC091D63E for ; Tue, 19 May 2020 18:52:58 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id s20so135527plp.6 for ; Tue, 19 May 2020 09:52:58 -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=IXCsz0slMlqovZXBHfrssOLx7LrJjSSaUCqSPo6j3yM=; b=J7m77ooS1J/5z9kycSatC14flzs+sMth2oeFr3wZfTgxlxP0LzXTEGKqv0orb6zptb oP8RxtlccZO37qBi8OczXzT2G2/YfK9neFBsVv1ErB9n3/MTmKTuZFpiT2LLQpfSaLGu JF33bcD5j5K8RXzz1e7AfE8oOdKeTksifHWm2qvtak/JCXUnduE+SwwyDza+wyrHax27 nkzjayP9mv2c/6ddRUqtdms1YVo0ujBZ/EAldjhNs6CSfasSCfokmPmh4NodbS9RXQuu uYzFzpxV90C0frkU+Viaa6b8SJnmLXtpJc2doYKpDJ/rpJrdTmjDZy2j8pXaQKL5XtST VBZQ== 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=IXCsz0slMlqovZXBHfrssOLx7LrJjSSaUCqSPo6j3yM=; b=mSpRANPuWSmKBiP/RbP0hYpfEoeiExAfCfhur8EWqyBlCX8om/7ep6TeFCDuvBlNZn bKxlpS6bz1BSGMaZFids2iMt9Xou9ujm1w4s+C6+zCIzAlNuGHd1cICiAmk/1utUm2/Y uH1q+ixKAurE2ZqInwR2diPVyAQuZVMz0B5oqp4czVvlYPlX8/JyG8tGgvwu6Ua7jDUa 3wAtJQfD9QUztDxKxkg5LT3OubaoNVpGW9kSgEh/npqz7MpHNMmaMm1ax5Jlz9OwldCz /Xp8co3gDX+b4MokNkpt6Glihrwa3XwUlisSxN1nszFnw8bME0GDJMFE4MEztv0SAn1/ GSXw== X-Gm-Message-State: AOAM532yeesPyBbRU3WPu+0S10cEtpIquCIJyrvD7u/pNDjCAAuynxqf hxQZ11VL4jzjVcxNzLAFaNRmlfLDT1+QPA== X-Google-Smtp-Source: ABdhPJxt06B2Ru++7enkqRt3Ehdwgo4a0BdcFqJGOAQ6p4O8pzXSY0O72XuIBf8eKnf4+9jN8WRNvg== X-Received: by 2002:a17:902:9e0c:: with SMTP id d12mr419011plq.29.1589907177382; Tue, 19 May 2020 09:52:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:56 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:29 -0700 Message-Id: <20200519165230.23306-7-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 6/7] net/netvsc: process link change messages in alarm 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" 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 --- 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 #include #include +#include #include #include #include @@ -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