From patchwork Fri May 22 09:21:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70514 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 13BD1A0093; Fri, 22 May 2020 11:22:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8CC561D95A; Fri, 22 May 2020 11:22:46 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id CEEE01D943 for ; Fri, 22 May 2020 11:22:40 +0200 (CEST) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 042DEF87D99B24E74E5B for ; Fri, 22 May 2020 17:22:39 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 22 May 2020 17:22:35 +0800 From: "Wei Hu (Xavier)" To: Date: Fri, 22 May 2020 17:21:14 +0800 Message-ID: <1590139278-11046-2-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> References: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 1/5] net/hns3: replace PF vport id zero with private macro 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" From: Chengchang Tang In hns3 PMD driver, the vport id 0 denote PF, and the vport id 1 denote the first VF device of the port. This patch adds two macros named HNS3_PF_FUNC_ID and HNS3_1ST_VF_FUNC_ID, and replaces this two numbers to improve code readability. Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 48 +++++++++++++++++++----------------------- drivers/net/hns3/hns3_ethdev.h | 3 +++ 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index a09ac08..06c4886 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -474,10 +474,9 @@ hns3_set_vlan_rx_offload_cfg(struct hns3_adapter *hns, /* * In current version VF is not supported when PF is driven by DPDK - * driver, the PF-related vf_id is 0, just need to configure parameters - * for vport_id 0. + * driver, just need to configure parameters for PF vport. */ - vport_id = 0; + vport_id = HNS3_PF_FUNC_ID; req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD; bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE); req->vf_bitmap[req->vf_offset] = bitmap; @@ -564,14 +563,16 @@ hns3_vlan_filter_init(struct hns3_adapter *hns) int ret; ret = hns3_set_vlan_filter_ctrl(hw, HNS3_FILTER_TYPE_VF, - HNS3_FILTER_FE_EGRESS, false, 0); + HNS3_FILTER_FE_EGRESS, false, + HNS3_PF_FUNC_ID); if (ret) { hns3_err(hw, "failed to init vf vlan filter, ret = %d", ret); return ret; } ret = hns3_set_vlan_filter_ctrl(hw, HNS3_FILTER_TYPE_PORT, - HNS3_FILTER_FE_INGRESS, false, 0); + HNS3_FILTER_FE_INGRESS, false, + HNS3_PF_FUNC_ID); if (ret) hns3_err(hw, "failed to init port vlan filter, ret = %d", ret); @@ -585,7 +586,8 @@ hns3_enable_vlan_filter(struct hns3_adapter *hns, bool enable) int ret; ret = hns3_set_vlan_filter_ctrl(hw, HNS3_FILTER_TYPE_PORT, - HNS3_FILTER_FE_INGRESS, enable, 0); + HNS3_FILTER_FE_INGRESS, enable, + HNS3_PF_FUNC_ID); if (ret) hns3_err(hw, "failed to %s port vlan filter, ret = %d", enable ? "enable" : "disable", ret); @@ -674,10 +676,9 @@ hns3_set_vlan_tx_offload_cfg(struct hns3_adapter *hns, /* * In current version VF is not supported when PF is driven by DPDK - * driver, the PF-related vf_id is 0, just need to configure parameters - * for vport_id 0. + * driver, just need to configure parameters for PF vport. */ - vport_id = 0; + vport_id = HNS3_PF_FUNC_ID; req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD; bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE); req->vf_bitmap[req->vf_offset] = bitmap; @@ -1425,10 +1426,9 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) /* * In current version VF is not supported when PF is driven by DPDK - * driver, the PF-related vf_id is 0, just need to configure parameters - * for vf_id 0. + * driver, just need to configure parameters for PF vport. */ - vf_id = 0; + vf_id = HNS3_PF_FUNC_ID; hns3_set_field(egress_port, HNS3_MAC_EPORT_VFID_M, HNS3_MAC_EPORT_VFID_S, vf_id); @@ -1781,10 +1781,9 @@ hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) /* * In current version VF is not supported when PF is driven by DPDK - * driver, the PF-related vf_id is 0, just need to configure parameters - * for vf_id 0. + * driver, just need to configure parameters for PF vport. */ - vf_id = 0; + vf_id = HNS3_PF_FUNC_ID; hns3_update_desc_vfid(desc, vf_id, false); ret = hns3_add_mac_vlan_tbl(hw, &req, desc); if (ret) { @@ -1824,10 +1823,9 @@ hns3_remove_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) /* * This mac addr exist, remove this handle's VFID for it. * In current version VF is not supported when PF is driven by - * DPDK driver, the PF-related vf_id is 0, just need to - * configure parameters for vf_id 0. + * DPDK driver, just need to configure parameters for PF vport. */ - vf_id = 0; + vf_id = HNS3_PF_FUNC_ID; hns3_update_desc_vfid(desc, vf_id, true); /* All the vfid is zero, so need to delete this entry */ @@ -2926,8 +2924,8 @@ hns3_map_tqp(struct hns3_hw *hw) */ tqp_id = 0; num = DIV_ROUND_UP(hw->total_tqps_num, HNS3_MAX_TQP_NUM_PER_FUNC); - for (func_id = 0; func_id < num; func_id++) { - is_pf = func_id == 0 ? true : false; + for (func_id = HNS3_PF_FUNC_ID; func_id < num; func_id++) { + is_pf = func_id == HNS3_PF_FUNC_ID ? true : false; for (i = 0; i < HNS3_MAX_TQP_NUM_PER_FUNC && tqp_id < tqps_num; i++) { ret = hns3_map_tqps_to_func(hw, func_id, tqp_id++, i, @@ -3819,10 +3817,9 @@ hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc) /* * In current version VF is not supported when PF is driven by DPDK - * driver, the PF-related vf_id is 0, just need to configure parameters - * for vf_id 0. + * driver, just need to configure parameters for PF vport. */ - vf_id = 0; + vf_id = HNS3_PF_FUNC_ID; hns3_promisc_param_init(¶m, en_uc_pmc, en_mc_pmc, en_bc_pmc, vf_id); return hns3_cmd_set_promisc_mode(hw, ¶m); @@ -3837,8 +3834,7 @@ hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw) uint16_t func_id; int ret; - /* func_id 0 is denoted PF, the VFs start from 1 */ - for (func_id = 1; func_id < pf->func_num; func_id++) { + for (func_id = HNS3_1ST_VF_FUNC_ID; func_id < pf->func_num; func_id++) { hns3_promisc_param_init(¶m, false, false, false, func_id); ret = hns3_cmd_set_promisc_mode(hw, ¶m); if (ret) @@ -5056,7 +5052,7 @@ hns3_prepare_reset(struct hns3_adapter *hns) switch (hw->reset.level) { case HNS3_FUNC_RESET: - ret = hns3_func_reset_cmd(hw, 0); + ret = hns3_func_reset_cmd(hw, HNS3_PF_FUNC_ID); if (ret) return ret; diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 06a1864..bc458cb 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -30,6 +30,9 @@ #define HNS3_PCI_REVISION_ID 0x08 #define HNS3_PCI_REVISION_ID_LEN 1 +#define HNS3_PF_FUNC_ID 0 +#define HNS3_1ST_VF_FUNC_ID 1 + #define HNS3_UC_MACADDR_NUM 128 #define HNS3_VF_UC_MACADDR_NUM 48 #define HNS3_MC_MACADDR_NUM 128 From patchwork Fri May 22 09:21:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70512 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 90CB0A0093; Fri, 22 May 2020 11:22:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6DB941D93F; Fri, 22 May 2020 11:22:43 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id C1D731D93B for ; Fri, 22 May 2020 11:22:40 +0200 (CEST) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0C2BE6B257951782B6FC for ; Fri, 22 May 2020 17:22:39 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 22 May 2020 17:22:35 +0800 From: "Wei Hu (Xavier)" To: Date: Fri, 22 May 2020 17:21:15 +0800 Message-ID: <1590139278-11046-3-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> References: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 2/5] net/hns3: fix promiscuous config not clear for PF on uninit 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" From: Chengchang Tang Currently, promiscuous mode configuration are not cleared during unintialziation based on hns3 PF device. The residual entries may cause unnecessary bandwidth usage. So, we need clear the PF's promisc mode status during the uninit. Fixes: a45fd0aa0ea1 ("net/hns3: fix Rx queue search with broadcast packet") Fixes: d51867db65c1 ("net/hns3: add initialization") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 53 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 06c4886..1c06b8f 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -3826,7 +3826,7 @@ hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc) } static int -hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw) +hns3_promisc_init(struct hns3_hw *hw) { struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); struct hns3_pf *pf = &hns->pf; @@ -3834,16 +3834,54 @@ hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw) uint16_t func_id; int ret; + ret = hns3_set_promisc_mode(hw, false, false); + if (ret) { + PMD_INIT_LOG(ERR, "failed to set promisc mode, ret = %d", ret); + return ret; + } + + /* + * In current version VFs are not supported when PF is driven by DPDK + * driver. After PF has been taken over by DPDK, the original VF will + * be invalid. So, there is a possibility of entry residues. It should + * clear VFs's promisc mode to avoid unnecessary bandwidth usage + * during init. + */ for (func_id = HNS3_1ST_VF_FUNC_ID; func_id < pf->func_num; func_id++) { hns3_promisc_param_init(¶m, false, false, false, func_id); ret = hns3_cmd_set_promisc_mode(hw, ¶m); - if (ret) + if (ret) { + PMD_INIT_LOG(ERR, "failed to clear vf:%d promisc mode," + " ret = %d", func_id, ret); return ret; + } } return 0; } +static void +hns3_promisc_uninit(struct hns3_hw *hw) +{ + struct hns3_promisc_param param; + uint16_t func_id; + int ret; + + func_id = HNS3_PF_FUNC_ID; + + /* + * In current version VFs are not supported when PF is driven by + * DPDK driver, and VFs' promisc mode status has been cleared during + * init and their status will not change. So just clear PF's promisc + * mode status during uninit. + */ + hns3_promisc_param_init(¶m, false, false, false, func_id); + ret = hns3_cmd_set_promisc_mode(hw, ¶m); + if (ret) + PMD_INIT_LOG(ERR, "failed to clear promisc status during" + " uninit, ret = %d", ret); +} + static int hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) { @@ -4186,15 +4224,9 @@ hns3_init_hardware(struct hns3_adapter *hns) goto err_mac_init; } - ret = hns3_set_promisc_mode(hw, false, false); - if (ret) { - PMD_INIT_LOG(ERR, "Failed to set promisc mode: %d", ret); - goto err_mac_init; - } - - ret = hns3_clear_all_vfs_promisc_mode(hw); + ret = hns3_promisc_init(hw); if (ret) { - PMD_INIT_LOG(ERR, "Failed to clear all vfs promisc mode: %d", + PMD_INIT_LOG(ERR, "Failed to init promisc: %d", ret); goto err_mac_init; } @@ -4353,6 +4385,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) hns3_enable_hw_error_intr(hns, false); hns3_rss_uninit(hns); + hns3_promisc_uninit(hw); hns3_fdir_filter_uninit(hns); hns3_uninit_umv_space(hw); hns3_pf_disable_irq0(hw); From patchwork Fri May 22 09:21:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70517 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 84A5BA0093; Fri, 22 May 2020 11:23:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 74D2B1D96E; Fri, 22 May 2020 11:22:50 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 4341E1D94F for ; Fri, 22 May 2020 11:22:44 +0200 (CEST) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1473ADFC0160A38CB0AE for ; Fri, 22 May 2020 17:22:39 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 22 May 2020 17:22:36 +0800 From: "Wei Hu (Xavier)" To: Date: Fri, 22 May 2020 17:21:16 +0800 Message-ID: <1590139278-11046-4-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> References: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 3/5] net/hns3: fix preparing sending packets less than 60 bytes 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" Currently, when running testpmd application based on hns3 network engine with csum fwd mode by "set fwd csum" command in the prompt line, sending 42 consecutive bytes of arp packets to network port with packets generator, But in fact hardware can't send the arp packets and the related logs as below: "Preparing packet burst to failed: Invalid argument" The hardware doesn't support transmit packets less than 60 bytes, and in the '.tx_pkt_burst' ops implementation function named hns3_xmit_pkts appending operation has been added for less than 60 bytes packets. So the interception needs to be removed in the '.tx_pkt_prepare' ops implementation function named hns3_prep_pkts. Fixes: de620754a109 ("net/hns3: fix sending packets less than 60 bytes") Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") Cc: stable@dpdk.org Signed-off-by: Wei Hu (Xavier) Signed-off-by: Hao Chen Signed-off-by: Chengchang Tang --- drivers/net/hns3/hns3_rxtx.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 8b3ced1..25ba3b8 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -2313,12 +2313,6 @@ hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, for (i = 0; i < nb_pkts; i++) { m = tx_pkts[i]; - /* check the size of packet */ - if (m->pkt_len < RTE_ETHER_MIN_LEN) { - rte_errno = EINVAL; - return i; - } - if (hns3_pkt_is_tso(m) && (hns3_pkt_need_linearized(m, m->nb_segs) || hns3_check_tso_pkt_valid(m))) { From patchwork Fri May 22 09:21:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70516 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BE611A0093; Fri, 22 May 2020 11:23:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 26BB91D967; Fri, 22 May 2020 11:22:49 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 7CF8C1D94B for ; Fri, 22 May 2020 11:22:43 +0200 (CEST) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F0D7E42640F473E62803 for ; Fri, 22 May 2020 17:22:38 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 22 May 2020 17:22:36 +0800 From: "Wei Hu (Xavier)" To: Date: Fri, 22 May 2020 17:21:17 +0800 Message-ID: <1590139278-11046-5-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> References: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 4/5] net/hns3: add RSS hash offload to port Rx configuration 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" From: Lijun Ou Rx offload flag `DEV_RX_OFFLOAD_RSS_HASH` which can be used to enable/disable PMDs write to `rte_mbuf::hash::rss`. The hns3 PMD driver already can notify the validity of `rte_mbuf::hash:rss` to the application by enabling `PKT_RX_RSS_HASH` flag in `rte_mbuf::ol_flags`. Fixes: 19a3ca4c99cf ("net/hns3: add start/stop and configure operations") Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 1 + drivers/net/hns3/hns3_ethdev_vf.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 1c06b8f..33d7c5c 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2312,6 +2312,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) /* When RSS is not configured, redirect the packet queue 0 */ if ((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG) { + conf->rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH; rss_conf = conf->rx_adv_conf.rss_conf; if (rss_conf.rss_key == NULL) { rss_conf.rss_key = rss_cfg->key; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 904562e..16d6012 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -784,6 +784,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) /* When RSS is not configured, redirect the packet queue 0 */ if ((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG) { + conf->rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH; rss_conf = conf->rx_adv_conf.rss_conf; if (rss_conf.rss_key == NULL) { rss_conf.rss_key = rss_cfg->key; From patchwork Fri May 22 09:21:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70515 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 72311A0093; Fri, 22 May 2020 11:23:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D87BA1D960; Fri, 22 May 2020 11:22:47 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 7DE951D94F for ; Fri, 22 May 2020 11:22:43 +0200 (CEST) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 08F805695E4D0BCD8991 for ; Fri, 22 May 2020 17:22:39 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 22 May 2020 17:22:36 +0800 From: "Wei Hu (Xavier)" To: Date: Fri, 22 May 2020 17:21:18 +0800 Message-ID: <1590139278-11046-6-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> References: <1590139278-11046-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 5/5] net/hns3: fix key length when configuring RSS 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" From: Lijun Ou When users set the length of rss hash key greater than the supported length by hardware, the pmd driver should intercept and can not configure the wrong key into the hardware. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_flow.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index aef301a..e3c2392 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1475,6 +1475,14 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } + if (rss_flow_conf.key_len && + rss_flow_conf.key_len > RTE_DIM(rss_info->key)) { + hns3_err(hw, + "input hash key(%u) greater than supported len(%lu)", + rss_flow_conf.key_len, RTE_DIM(rss_info->key)); + return -EINVAL; + } + /* Filter the unsupported flow types */ flow_types = rss_flow_conf.types & HNS3_ETH_RSS_SUPPORT; if (flow_types != rss_flow_conf.types)