From patchwork Wed Mar 31 10:01:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90227 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 094D5A034F; Wed, 31 Mar 2021 12:02:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D779140EB2; Wed, 31 Mar 2021 12:01:37 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id D4EA7140E4C for ; Wed, 31 Mar 2021 12:01:26 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt227bz9v4k for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:18 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:35 +0800 Message-ID: <1617184904-55349-2-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 01/10] net/hns3: fix some function names for copper media type X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Huisong Li PHY is a common concept for the copper and optical media type interface. There are some inappropriate function names for copper ports, which needs to be adjusted. Fixes: 2e4859f3b362 ("net/hns3: support PF device with copper PHYs") Signed-off-by: Huisong Li Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 9c71808..953e8a1 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -4547,7 +4547,7 @@ hns3_update_fiber_link_info(struct hns3_hw *hw) } static void -hns3_parse_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac) +hns3_parse_copper_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac) { struct hns3_phy_params_bd0_cmd *req; @@ -4565,7 +4565,7 @@ hns3_parse_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac) } static int -hns3_get_phy_params(struct hns3_hw *hw, struct hns3_mac *mac) +hns3_get_copper_phy_params(struct hns3_hw *hw, struct hns3_mac *mac) { struct hns3_cmd_desc desc[HNS3_PHY_PARAM_CFG_BD_NUM]; uint16_t i; @@ -4584,20 +4584,20 @@ hns3_get_phy_params(struct hns3_hw *hw, struct hns3_mac *mac) return ret; } - hns3_parse_phy_params(desc, mac); + hns3_parse_copper_phy_params(desc, mac); return 0; } static int -hns3_update_phy_link_info(struct hns3_hw *hw) +hns3_update_copper_link_info(struct hns3_hw *hw) { struct hns3_mac *mac = &hw->mac; struct hns3_mac mac_info; int ret; memset(&mac_info, 0, sizeof(struct hns3_mac)); - ret = hns3_get_phy_params(hw, &mac_info); + ret = hns3_get_copper_phy_params(hw, &mac_info); if (ret) return ret; @@ -4626,7 +4626,7 @@ hns3_update_link_info(struct rte_eth_dev *eth_dev) int ret = 0; if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) - ret = hns3_update_phy_link_info(hw); + ret = hns3_update_copper_link_info(hw); else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) ret = hns3_update_fiber_link_info(hw); From patchwork Wed Mar 31 10:01:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90229 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B6BFBA034F; Wed, 31 Mar 2021 12:02:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 84CA6140EBA; Wed, 31 Mar 2021 12:01:39 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id D43F5140E4B for ; Wed, 31 Mar 2021 12:01:26 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt1XPHz9v4b for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:18 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:36 +0800 Message-ID: <1617184904-55349-3-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 02/10] net/hns3: fix set default MAC addr fail in bonding of VF X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Chengwen Feng When start testpmd with two hns3 VFs(0000:bd:01.0, 0000:bd:01.7), and then execute the following commands: testpmd> create bonded device 1 0 testpmd> set bonding mac_addr 2 3c:12:34:56:78:9a testpmd> add bonding slave 0 2 testpmd> add bonding slave 1 2 testpmd> set portmask 0x4 testpmd> port start 2 It will occurs the following error in a low probability: 0000:bd:01.0 hns3_get_mbx_resp(): VF could not get mbx(3,0) head(16) tail(15) lost(1) from PF in_irq:0 0000:bd:01.0 hns3vf_set_default_mac_addr(): Failed to set mac addr(3C:**:**:**:78:9A) for vf: -62 mac_address_slaves_update(1541) - Failed to update port Id 0 MAC address The problem replay: 1. the 'port start 2' command will start slave ports and then set slave mac address, the function call flow: bond_ethdev_start -> mac_address_slaves_update. 2. there are also a monitor task which running in intr thread will check slave ports link status and update slave ports mac address, the function call flow: bond_ethdev_slave_link_status_change_monitor -> bond_ethdev_lsc_event_callback -> mac_address_slaves_update. 3. because the above step1&2 running on different threads, they may both call drivers ops mac_addr_set which is hns3vf_set_default_mac_addr. 4. hns3vf_set_default_mac_addr will first acquire hw.lock and then send mailbox to PF and wait PF's response message. Note: the PF's response is an independent message which will received in hw.cmq.crq, the receiving operation can only performed in intr thread. 5. so if the step1 operation hold the hw.lock and try get response message, and step2 operation try acquire the hw.lock and so it can't process the response message, this will lead to step1 fail. The solution: 1. make all threads could process the mailbox response message, which protected by the hw.cmq.crq.lock. 2. use the following rules to avoid deadlock: 2.1. ensure use the correct locking sequence: hw.lock > hw.mbx_resp.lock > hw.cmq.crq.lock. 2.2. make sure don't acquire such as hw.lock & hw.mbx_resp.lock again when process mailbox response message. Fixes: 463e748964f5 ("net/hns3: support mailbox") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.h | 1 - drivers/net/hns3/hns3_ethdev_vf.c | 3 --- drivers/net/hns3/hns3_mbx.c | 51 +++++++++++---------------------------- 3 files changed, 14 insertions(+), 41 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index ac255a3..b11457b 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -439,7 +439,6 @@ struct hns3_hw { struct hns3_cmq cmq; struct hns3_mbx_resp_status mbx_resp; /* mailbox response */ struct hns3_mbx_arq_ring arq; /* mailbox async rx queue */ - pthread_t irq_thread_id; struct hns3_mac mac; unsigned int secondary_cnt; /* Number of secondary processes init'd. */ struct hns3_tqp_stats tqp_stats; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 6c3ddcc..f70106d 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1109,9 +1109,6 @@ hns3vf_interrupt_handler(void *param) enum hns3vf_evt_cause event_cause; uint32_t clearval; - if (hw->irq_thread_id == 0) - hw->irq_thread_id = pthread_self(); - /* Disable interrupt */ hns3vf_disable_irq0(hw); diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index 61d1584..ad0b4e6 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -40,36 +40,14 @@ hns3_resp_to_errno(uint16_t resp_code) return -EIO; } -static void -hns3_poll_all_sync_msg(void) -{ - struct rte_eth_dev *eth_dev; - struct hns3_adapter *adapter; - const char *name; - uint16_t port_id; - - RTE_ETH_FOREACH_DEV(port_id) { - eth_dev = &rte_eth_devices[port_id]; - name = eth_dev->device->driver->name; - if (strcmp(name, "net_hns3") && strcmp(name, "net_hns3_vf")) - continue; - adapter = eth_dev->data->dev_private; - if (!adapter || adapter->hw.adapter_state == HNS3_NIC_CLOSED) - continue; - /* Synchronous msg, the mbx_resp.req_msg_data is non-zero */ - if (adapter->hw.mbx_resp.req_msg_data) - hns3_dev_handle_mbx_msg(&adapter->hw); - } -} - static int hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, uint8_t *resp_data, uint16_t resp_len) { #define HNS3_MAX_RETRY_MS 500 +#define HNS3_WAIT_RESP_US 100 struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); struct hns3_mbx_resp_status *mbx_resp; - bool in_irq = false; uint64_t now; uint64_t end; @@ -96,26 +74,19 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, return -EIO; } - /* - * The mbox response is running on the interrupt thread. - * Sending mbox in the interrupt thread cannot wait for the - * response, so polling the mbox response on the irq thread. - */ - if (pthread_equal(hw->irq_thread_id, pthread_self())) { - in_irq = true; - hns3_poll_all_sync_msg(); - } else { - rte_delay_ms(HNS3_POLL_RESPONE_MS); - } + hns3_dev_handle_mbx_msg(hw); + rte_delay_us(HNS3_WAIT_RESP_US); + now = get_timeofday_ms(); } hw->mbx_resp.req_msg_data = 0; if (now >= end) { hw->mbx_resp.lost++; hns3_err(hw, - "VF could not get mbx(%u,%u) head(%u) tail(%u) lost(%u) from PF in_irq:%d", + "VF could not get mbx(%u,%u) head(%u) tail(%u) " + "lost(%u) from PF", code0, code1, hw->mbx_resp.head, hw->mbx_resp.tail, - hw->mbx_resp.lost, in_irq); + hw->mbx_resp.lost); return -ETIME; } rte_io_rmb(); @@ -368,9 +339,13 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) uint8_t *temp; int i; + rte_spinlock_lock(&hw->cmq.crq.lock); + while (!hns3_cmd_crq_empty(hw)) { - if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) + if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { + rte_spinlock_unlock(&hw->cmq.crq.lock); return; + } desc = &crq->desc[crq->next_to_use]; req = (struct hns3_mbx_pf_to_vf_cmd *)desc->data; @@ -441,4 +416,6 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) /* Write back CMDQ_RQ header pointer, IMP need this pointer */ hns3_write_dev(hw, HNS3_CMDQ_RX_HEAD_REG, crq->next_to_use); + + rte_spinlock_unlock(&hw->cmq.crq.lock); } From patchwork Wed Mar 31 10:01:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90226 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AA4D7A034F; Wed, 31 Mar 2021 12:02:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0714B140EA6; Wed, 31 Mar 2021 12:01:36 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id D13DA140E4A for ; Wed, 31 Mar 2021 12:01:26 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt2ngFz9v4t for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:18 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:37 +0800 Message-ID: <1617184904-55349-4-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 03/10] net/hns3: fix the FLR miss detection X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Hongbo Zheng When FLR occurs, the head pointer register of the command queue will be cleared, resulting in abnormal detection of the head pointer register of the command queue. At present, FLR is detected in this way, and the reset recovery process is executed. However, when FLR occurs, the header pointer register of the command queue is not necessarily abnormal. For example, when the driver runs normally, the value of the header pointer register of the command queue may also be 0, which will lead to the miss detection of FLR. Therefore, the judgment that whether the base address register of command queue is 0 is added to ensure that FLR not miss detection. Fixes: 2790c6464725 ("net/hns3: support device reset") Cc: stable@dpdk.org Signed-off-by: Hongbo Zheng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_cmd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c index 03f8048..f0c4a7f 100644 --- a/drivers/net/hns3/hns3_cmd.c +++ b/drivers/net/hns3/hns3_cmd.c @@ -195,12 +195,14 @@ hns3_cmd_csq_clean(struct hns3_hw *hw) { struct hns3_cmq_ring *csq = &hw->cmq.csq; uint32_t head; + uint32_t addr; int clean; head = hns3_read_dev(hw, HNS3_CMDQ_TX_HEAD_REG); - if (!is_valid_csq_clean_head(csq, head)) { - hns3_err(hw, "wrong cmd head (%u, %u-%u)", head, - csq->next_to_use, csq->next_to_clean); + addr = hns3_read_dev(hw, HNS3_CMDQ_TX_ADDR_L_REG); + if (!is_valid_csq_clean_head(csq, head) || addr == 0) { + hns3_err(hw, "wrong cmd addr(%0x) head (%u, %u-%u)", addr, head, + csq->next_to_use, csq->next_to_clean); if (rte_eal_process_type() == RTE_PROC_PRIMARY) { __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); From patchwork Wed Mar 31 10:01:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90220 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0C426A034F; Wed, 31 Mar 2021 12:01:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E2E22140E50; Wed, 31 Mar 2021 12:01:26 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id 959A7140E42 for ; Wed, 31 Mar 2021 12:01:25 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt2C5Qz9v4p for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:19 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:38 +0800 Message-ID: <1617184904-55349-5-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 04/10] net/hns3: fix lack of rollback after setting PVID failed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Chengchang Tang Currently, three hardware operations are involved in setting the PVID. If any operation fails, a failure will be returned. And there may be residual hardware configurations because no rollback is performed. This patch adds rollback operation for setting PVID to avoid residual hardware configuration after the PVID fails to be configured. Fixes: 411d23b9eafb ("net/hns3: support VLAN") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 953e8a1..005e8bf 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -964,7 +964,7 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) { struct hns3_hw *hw = &hns->hw; uint16_t port_base_vlan_state; - int ret; + int ret, err; if (on == 0 && pvid != hw->port_base_vlan_cfg.pvid) { if (hw->port_base_vlan_cfg.pvid != HNS3_INVALID_PVID) @@ -987,7 +987,7 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) if (ret) { hns3_err(hw, "failed to config rx vlan strip for pvid, " "ret = %d", ret); - return ret; + goto pvid_vlan_strip_fail; } if (pvid == HNS3_INVALID_PVID) @@ -996,13 +996,27 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) if (ret) { hns3_err(hw, "failed to update vlan filter entries, ret = %d", ret); - return ret; + goto vlan_filter_set_fail; } out: hw->port_base_vlan_cfg.state = port_base_vlan_state; hw->port_base_vlan_cfg.pvid = on ? pvid : HNS3_INVALID_PVID; return ret; + +vlan_filter_set_fail: + err = hns3_en_pvid_strip(hns, hw->port_base_vlan_cfg.state == + HNS3_PORT_BASE_VLAN_ENABLE); + if (err) + hns3_err(hw, "fail to rollback pvid strip, ret = %d", err); + +pvid_vlan_strip_fail: + err = hns3_vlan_txvlan_cfg(hns, hw->port_base_vlan_cfg.state, + hw->port_base_vlan_cfg.pvid); + if (err) + hns3_err(hw, "fail to rollback txvlan status, ret = %d", err); + + return ret; } static int From patchwork Wed Mar 31 10:01:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90224 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C1B0A034F; Wed, 31 Mar 2021 12:01:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E5AD140E95; Wed, 31 Mar 2021 12:01:31 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id DA34E140E4E for ; Wed, 31 Mar 2021 12:01:25 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt1tF2z9v4h for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:19 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:39 +0800 Message-ID: <1617184904-55349-6-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 05/10] net/hns3: fix flow control exception X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Huisong Li In multi-TC scenarios, MAC pause is not supported. Otherwise, only TC0 can trigger pause frames, and other TCs cannot trigger pause frames. In this case, flow control does not meet the expectation. Fixes: 62e3ccc2b94c ("net/hns3: support flow control") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 005e8bf..2bb0c43 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5500,6 +5500,11 @@ hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) return -EOPNOTSUPP; } + if (hw->num_tc > 1) { + hns3_err(hw, "in multi-TC scenarios, MAC pause is not supported."); + return -EOPNOTSUPP; + } + hns3_get_fc_mode(hw, fc_conf->mode); if (hw->requested_mode == hw->current_mode && pf->pause_time == fc_conf->pause_time) From patchwork Wed Mar 31 10:01:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90230 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DB021A034F; Wed, 31 Mar 2021 12:02:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD633140EC5; Wed, 31 Mar 2021 12:01:40 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id ED66E140E53 for ; Wed, 31 Mar 2021 12:01:26 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt120tz9v02 for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:19 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:40 +0800 Message-ID: <1617184904-55349-7-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 06/10] net/hns3: fix flow counter not cleared when create X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Chengwen Feng User could create flow rules with specified counter by the action of RTE_FLOW_ACTION_TYPE_COUNT, but the counter may retain the original value when create. This patch fix the bug by read the counter when creating the rule because the counter is read-clear. Fixes: fcba820d9b9e ("net/hns3: support flow director") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_flow.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index 0c4e911..84ab819 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -158,7 +158,10 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id, { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_pf *pf = &hns->pf; + struct hns3_hw *hw = &hns->hw; struct hns3_flow_counter *cnt; + uint64_t value; + int ret; cnt = hns3_counter_lookup(dev, id); if (cnt) { @@ -171,6 +174,13 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id, return 0; } + /* Clear the counter by read ops because the counter is read-clear */ + ret = hns3_get_count(hw, id, &value); + if (ret) + return rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Clear counter failed!"); + cnt = rte_zmalloc("hns3 counter", sizeof(*cnt), 0); if (cnt == NULL) return rte_flow_error_set(error, ENOMEM, From patchwork Wed Mar 31 10:01:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90225 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1BB41A034F; Wed, 31 Mar 2021 12:01:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BFED3140EA2; Wed, 31 Mar 2021 12:01:34 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id A43E0140E42 for ; Wed, 31 Mar 2021 12:01:26 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt2yLHz9v4x for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:19 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:41 +0800 Message-ID: <1617184904-55349-8-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 07/10] net/hns3: fix VF mailbox head field wrong update X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Chengwen Feng Currently, the VF mailbox synchronization communication is based on three fields: head/tail/lost, when head equals tail plus lost, it means the response is received successfully. The head field indicates the number of requests that are successfully sent. If the request sending fails, it should not be updated. This patch fix the above bug by roll back updates when the sending fails. Fixes: 463e748964f57 ("net/hns3: support mailbox") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_mbx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index ad0b4e6..3ba65f1 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -142,6 +142,7 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, hw->mbx_resp.head++; ret = hns3_cmd_send(hw, &desc, 1); if (ret) { + hw->mbx_resp.head--; rte_spinlock_unlock(&hw->mbx_resp.lock); hns3_err(hw, "VF failed(=%d) to send mbx message to PF", ret); From patchwork Wed Mar 31 10:01:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90222 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 10047A034F; Wed, 31 Mar 2021 12:01:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25FBD140E7A; Wed, 31 Mar 2021 12:01:29 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id CE997140E4B for ; Wed, 31 Mar 2021 12:01:25 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt1DbQz9v21 for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:20 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:42 +0800 Message-ID: <1617184904-55349-9-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 08/10] net/hns3: support get device version when dump register X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Chengwen Feng Support get device version which is equal to the firmware version when dump register. Fixes: 936eda25e8da ("net/hns3: support dump register") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_regs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c index 4022bb9..cfcd080 100644 --- a/drivers/net/hns3/hns3_regs.c +++ b/drivers/net/hns3/hns3_regs.c @@ -504,6 +504,8 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) if (regs->length && regs->length != length) return -ENOTSUP; + regs->version = hw->fw_version; + /* fetching per-PF registers values from PF PCIe register space */ data += hns3_direct_access_regs(hw, data); From patchwork Wed Mar 31 10:01:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90221 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2544EA034F; Wed, 31 Mar 2021 12:01:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E54E5140E52; Wed, 31 Mar 2021 12:01:27 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id A8315140E4A for ; Wed, 31 Mar 2021 12:01:25 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt1NPPz9v3b for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:20 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:43 +0800 Message-ID: <1617184904-55349-10-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 09/10] net/hns3: delete redundant blank line X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Hongbo Zheng Delete redundant blank line in "hns3vf_check_event_cause" to solve the static warning. Fixes: a5475d61fa34 ("net/hns3: support VF") Signed-off-by: Hongbo Zheng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev_vf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index f70106d..5513db7 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1064,7 +1064,6 @@ hns3vf_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) /* Fetch the events from their corresponding regs */ cmdq_stat_reg = hns3_read_dev(hw, HNS3_VECTOR0_CMDQ_STAT_REG); - if (BIT(HNS3_VECTOR0_RST_INT_B) & cmdq_stat_reg) { rst_ing_reg = hns3_read_dev(hw, HNS3_FUN_RST_ING); hns3_warn(hw, "resetting reg: 0x%x", rst_ing_reg); From patchwork Wed Mar 31 10:01:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 90228 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8CA64A034F; Wed, 31 Mar 2021 12:02:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5FB8E140EAC; Wed, 31 Mar 2021 12:01:38 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id E73D6140E52 for ; Wed, 31 Mar 2021 12:01:26 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt1kMmz9v4d for ; Wed, 31 Mar 2021 17:59:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 18:01:20 +0800 From: "Min Hu (Connor)" To: CC: Date: Wed, 31 Mar 2021 18:01:44 +0800 Message-ID: <1617184904-55349-11-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com> References: <1617184904-55349-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 10/10] net/hns3: fix code style static warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Hongbo Zheng Add one space before the left brace to solve the static warning. Fixes: 4311f7372881 ("net/hns3: support query Rx descriptor status") Signed-off-by: Hongbo Zheng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index ce5d852..80f7007 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -4438,7 +4438,7 @@ hns3_dev_rx_descriptor_status(void *rx_queue, uint16_t offset) if (offset >= rxq->nb_rx_desc - rxq->rx_free_hold) return RTE_ETH_RX_DESC_UNAVAIL; } else if (dev->rx_pkt_burst == hns3_recv_pkts_vec || - dev->rx_pkt_burst == hns3_recv_pkts_vec_sve){ + dev->rx_pkt_burst == hns3_recv_pkts_vec_sve) { if (offset >= rxq->nb_rx_desc - rxq->rx_rearm_nb) return RTE_ETH_RX_DESC_UNAVAIL; } else {