From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E729142CBC for ; Thu, 15 Jun 2023 03:36:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E12FB42D77; Thu, 15 Jun 2023 03:36:05 +0200 (CEST) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mails.dpdk.org (Postfix) with ESMTP id 95AAA42D4B for ; Thu, 15 Jun 2023 03:36:04 +0200 (CEST) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-4f74cda5f1dso5247206e87.3 for ; Wed, 14 Jun 2023 18:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686792964; x=1689384964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sgga3J424LDdYlrrKbJCv/ZRrpRBNFpyFZ0mKpqu8vI=; b=FLmsO/Z6K5+4HORBJShYGLrwUNoanK1UV4pzl1LQg4J3GvHH/nDFA/pHYhKUCt1mBg PqODsTPoKv+udubuz+RpCJoQZl3LiN2UxXpoPow04SgOZ4RFxZGDUGRi4aNDQZwc4RI9 j1xxvHshjpkXqjohXXJ+irw3OGv+Af1UB2+Yd2WwPKDtiMKvN+iHuaa8Im8CtiuJDr62 rN3gZOuPrfFLyyoegZK/kMr2mSGmQ5AWNajDStbQDZHNUz5ri9M+uzOWXWcMXvvMX0ce I9weuleMI2tXq78kCGp7xfqy79358I5gcRKY704oWr0dDY9mC3TnIT6fdWqF1xrn4BTg /6xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686792964; x=1689384964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sgga3J424LDdYlrrKbJCv/ZRrpRBNFpyFZ0mKpqu8vI=; b=iwvLLUYbsc7yY21aovx9auThbOy25O3yAyedpimhAXaH6ovHKV/Xa67yU5S56fkZFe DmcJ92Esbb3rmFMCJxXU6fNk2clfIFodnVgCUQb4K3IWe0R7643ZhdifiAK6x6Nu1Vij QkWhfWJ7f7gEkGgcggdpnZZ003I5hh20H+Nbkuq1GSW4SnhaM6PsHdgTXgtoCHXPQAPx kaLXJJ4UOEE9XOkiYCAk4yDaOhgUVBQYBRq+QWtydg8pdX1XxrX31tt6amgALaiOJWEf bbCi9gocKTjJGNyxLrNR4IVo1/N94xA+XrYt8eLID/X5jtyvEf/C8AvAT0aHPNxI8Gbc KybA== X-Gm-Message-State: AC+VfDw3rcuUA+1AAOoR8ymjY5ykE+w9w6K9a17o44dyehjiI2X329tW GJJJc+99QnbWLHo9zPyJlRLVKgTFrbDP8ywB X-Google-Smtp-Source: ACHHUZ62iX3Kug1Li0JOYAfOUJuI3sj+aWtlw3SD895Dgnet+QhDR5XtFpyRB9gDaKj2+mY37p+fBQ== X-Received: by 2002:ac2:46ec:0:b0:4f3:a820:dd98 with SMTP id q12-20020ac246ec000000b004f3a820dd98mr9487053lfo.7.1686792964016; Wed, 14 Jun 2023 18:36:04 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id l16-20020a1c7910000000b003f8d770e935sm3928815wme.0.2023.06.14.18.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 18:36:03 -0700 (PDT) From: luca.boccassi@gmail.com To: Kaiwen Deng Cc: Qi Zhang , dpdk stable Subject: patch 'net/iavf: fix virtchnl command called in interrupt' has been queued to stable release 20.11.9 Date: Thu, 15 Jun 2023 02:32:55 +0100 Message-Id: <20230615013258.1439718-60-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615013258.1439718-1-luca.boccassi@gmail.com> References: <20230615013258.1439718-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 20.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/17/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/28122dd7602b701b055315e8692366f7394c3d6d Thanks. Luca Boccassi --- >From 28122dd7602b701b055315e8692366f7394c3d6d Mon Sep 17 00:00:00 2001 From: Kaiwen Deng Date: Thu, 8 Jun 2023 15:27:56 +0800 Subject: [PATCH] net/iavf: fix virtchnl command called in interrupt [ upstream commit 92a16af4504b67545e91286dfb0a332d58e68eec ] When iavf send virtchnl command in eal-intr-thread, there will be no response received from iavf_dev_virtchnl_handler for this command during block and wait. Because iavf_dev_virtchnl_handler is also registered in eal-intr-thread. This commit add to poll the response for virtchnl command when it is called by eal-intr-thread to fix this issue. Fixes: 22b123a36d07 ("net/avf: initialize PMD") Signed-off-by: Kaiwen Deng Acked-by: Qi Zhang --- drivers/net/iavf/iavf_ethdev.c | 5 ++- drivers/net/iavf/iavf_vchnl.c | 71 +++++++++++++++++++++++----------- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 746f6fc335..40f5693d28 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -2011,6 +2011,9 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) adapter->dev_data = eth_dev->data; adapter->stopped = 1; + if (iavf_dev_event_handler_init()) + return 0; + if (iavf_init_vf(eth_dev) != 0) { PMD_INIT_LOG(ERR, "Init vf failed"); return -1; @@ -2037,8 +2040,6 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.addr, ð_dev->data->mac_addrs[0]); - if (iavf_dev_event_handler_init()) - return 0; /* register callback func to eal lib */ rte_intr_callback_register(&pci_dev->intr_handle, diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index 4c6efaac3a..1a09acafb1 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -254,6 +254,7 @@ iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len, vf->link_speed = iavf_convert_link_speed(speed); } iavf_dev_link_update(vf->eth_dev, 0); + iavf_dev_event_post(vf->eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL, 0); PMD_DRV_LOG(INFO, "Link status update:%s", vf->link_up ? "up" : "down"); break; @@ -358,28 +359,48 @@ iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args) _clear_cmd(vf); break; default: - /* For other virtchnl ops in running time, - * wait for the cmd done flag. - */ - do { - if (vf->pend_cmd == VIRTCHNL_OP_UNKNOWN) - break; - iavf_msec_delay(ASQ_DELAY_MS); - /* If don't read msg or read sys event, continue */ - } while (i++ < MAX_TRY_TIMES); - - if (i >= MAX_TRY_TIMES) { - PMD_DRV_LOG(ERR, "No response for cmd %d", args->ops); + if (rte_thread_is_intr()) { + /* For virtchnl ops were executed in eal_intr_thread, + * need to poll the response. + */ + do { + result = iavf_read_msg_from_pf(adapter, args->out_size, + args->out_buffer); + if (result == IAVF_MSG_CMD) + break; + iavf_msec_delay(ASQ_DELAY_MS); + } while (i++ < MAX_TRY_TIMES); + if (i >= MAX_TRY_TIMES || + vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) { + err = -1; + PMD_DRV_LOG(ERR, "No response or return failure (%d)" + " for cmd %d", vf->cmd_retval, args->ops); + } _clear_cmd(vf); - err = -EIO; - } else if (vf->cmd_retval == - VIRTCHNL_STATUS_ERR_NOT_SUPPORTED) { - PMD_DRV_LOG(ERR, "Cmd %d not supported", args->ops); - err = -ENOTSUP; - } else if (vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) { - PMD_DRV_LOG(ERR, "Return failure %d for cmd %d", - vf->cmd_retval, args->ops); - err = -EINVAL; + } else { + /* For other virtchnl ops in running time, + * wait for the cmd done flag. + */ + do { + if (vf->pend_cmd == VIRTCHNL_OP_UNKNOWN) + break; + iavf_msec_delay(ASQ_DELAY_MS); + /* If don't read msg or read sys event, continue */ + } while (i++ < MAX_TRY_TIMES); + + if (i >= MAX_TRY_TIMES) { + PMD_DRV_LOG(ERR, "No response for cmd %d", args->ops); + _clear_cmd(vf); + err = -EIO; + } else if (vf->cmd_retval == + VIRTCHNL_STATUS_ERR_NOT_SUPPORTED) { + PMD_DRV_LOG(ERR, "Cmd %d not supported", args->ops); + err = -ENOTSUP; + } else if (vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) { + PMD_DRV_LOG(ERR, "Return failure %d for cmd %d", + vf->cmd_retval, args->ops); + err = -EINVAL; + } } break; } @@ -393,8 +414,14 @@ iavf_execute_vf_cmd_safe(struct iavf_adapter *adapter, { struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); int ret; + int is_intr_thread = rte_thread_is_intr(); - rte_spinlock_lock(&vf->aq_lock); + if (is_intr_thread) { + if (!rte_spinlock_trylock(&vf->aq_lock)) + return -EIO; + } else { + rte_spinlock_lock(&vf->aq_lock); + } ret = iavf_execute_vf_cmd(adapter, args); rte_spinlock_unlock(&vf->aq_lock); -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-06-15 01:56:37.713100577 +0100 +++ 0060-net-iavf-fix-virtchnl-command-called-in-interrupt.patch 2023-06-15 01:56:34.727544800 +0100 @@ -1 +1 @@ -From 92a16af4504b67545e91286dfb0a332d58e68eec Mon Sep 17 00:00:00 2001 +From 28122dd7602b701b055315e8692366f7394c3d6d Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 92a16af4504b67545e91286dfb0a332d58e68eec ] + @@ -15 +16,0 @@ -Cc: stable@dpdk.org @@ -25 +26 @@ -index 96004220a1..b72dbc8ceb 100644 +index 746f6fc335..40f5693d28 100644 @@ -28 +29 @@ -@@ -2647,6 +2647,9 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) +@@ -2011,6 +2011,9 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) @@ -33 +34 @@ -+ goto init_vf_err; ++ return 0; @@ -38 +39 @@ -@@ -2674,8 +2677,6 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) +@@ -2037,8 +2040,6 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) @@ -43 +44 @@ -- goto init_vf_err; +- return 0; @@ -45,2 +46,2 @@ - if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) { - /* register callback func to eal lib */ + /* register callback func to eal lib */ + rte_intr_callback_register(&pci_dev->intr_handle, @@ -48 +49 @@ -index 8874a08b24..07eb358824 100644 +index 4c6efaac3a..1a09acafb1 100644 @@ -51 +52 @@ -@@ -256,6 +256,7 @@ iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len, +@@ -254,6 +254,7 @@ iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len, @@ -56,4 +57,4 @@ - if (vf->link_up && !vf->vf_reset) { - iavf_dev_watchdog_disable(adapter); - } else { -@@ -374,28 +375,48 @@ iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args, + PMD_DRV_LOG(INFO, "Link status update:%s", + vf->link_up ? "up" : "down"); + break; +@@ -358,28 +359,48 @@ iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args) @@ -129 +130 @@ -@@ -409,8 +430,14 @@ iavf_execute_vf_cmd_safe(struct iavf_adapter *adapter, +@@ -393,8 +414,14 @@ iavf_execute_vf_cmd_safe(struct iavf_adapter *adapter, @@ -142 +143 @@ - ret = iavf_execute_vf_cmd(adapter, args, async); + ret = iavf_execute_vf_cmd(adapter, args);