From patchwork Mon Sep 14 14:31:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangxiaoyun (Cloud)" X-Patchwork-Id: 77617 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 044FDA04C9; Mon, 14 Sep 2020 16:31:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1F289FFA; Mon, 14 Sep 2020 16:31:01 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id C59AB1C0CC; Mon, 14 Sep 2020 16:30:59 +0200 (CEST) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id BCE1F21C041EAF77A3E3; Mon, 14 Sep 2020 22:30:57 +0800 (CST) Received: from tester.localdomain (10.175.119.39) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 14 Sep 2020 22:30:48 +0800 From: Xiaoyun wang To: CC: , , , , , , , , , Xiaoyun wang Date: Mon, 14 Sep 2020 22:31:42 +0800 Message-ID: <46c2921994aada4b774bb4ad5cf20b47415134d4.1600093192.git.cloud.wangxiaoyun@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.175.119.39] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v1 1/5] net/hinic: fix return value of null not checked 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" If rte_zmalloc failed, pmd driver should also delete the ntuple filter or ethertype filter or normal and tcam filter that already added before. Fixes: d7964ce192e7 ("net/hinic: check memory allocations in flow creation") Cc: stable@dpdk.org Signed-off-by: Xiaoyun wang --- drivers/net/hinic/hinic_pmd_flow.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c index 70fd445..9888a87 100644 --- a/drivers/net/hinic/hinic_pmd_flow.c +++ b/drivers/net/hinic/hinic_pmd_flow.c @@ -694,6 +694,7 @@ static int hinic_ntuple_item_check_end(const struct rte_flow_item *item, item, "Not supported by ntuple filter"); return -rte_errno; } + return 0; } @@ -2981,6 +2982,8 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, sizeof(struct hinic_ntuple_filter_ele), 0); if (ntuple_filter_ptr == NULL) { PMD_DRV_LOG(ERR, "Failed to allocate ntuple_filter_ptr"); + (void)hinic_add_del_ntuple_filter(dev, + &ntuple_filter, FALSE); goto out; } rte_memcpy(&ntuple_filter_ptr->filter_info, @@ -3011,6 +3014,8 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, sizeof(struct hinic_ethertype_filter_ele), 0); if (ethertype_filter_ptr == NULL) { PMD_DRV_LOG(ERR, "Failed to allocate ethertype_filter_ptr"); + (void)hinic_add_del_ethertype_filter(dev, + ðertype_filter, FALSE); goto out; } rte_memcpy(ðertype_filter_ptr->filter_info, @@ -3034,11 +3039,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, actions, &fdir_rule, error); if (!ret) { if (fdir_rule.mode == HINIC_FDIR_MODE_NORMAL) { - ret = hinic_add_del_fdir_filter(dev, - &fdir_rule, TRUE); + ret = hinic_add_del_fdir_filter(dev, &fdir_rule, TRUE); } else if (fdir_rule.mode == HINIC_FDIR_MODE_TCAM) { - ret = hinic_add_del_tcam_fdir_filter(dev, - &fdir_rule, TRUE); + ret = hinic_add_del_tcam_fdir_filter(dev, &fdir_rule, + TRUE); } else { PMD_DRV_LOG(INFO, "flow fdir rule create failed, rule mode wrong"); goto out; @@ -3048,6 +3052,13 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, sizeof(struct hinic_fdir_rule_ele), 0); if (fdir_rule_ptr == NULL) { PMD_DRV_LOG(ERR, "Failed to allocate fdir_rule_ptr"); + if (fdir_rule.mode == HINIC_FDIR_MODE_NORMAL) + hinic_add_del_fdir_filter(dev, + &fdir_rule, FALSE); + else if (fdir_rule.mode == HINIC_FDIR_MODE_TCAM) + hinic_add_del_tcam_fdir_filter(dev, + &fdir_rule, FALSE); + goto out; } rte_memcpy(&fdir_rule_ptr->filter_info, &fdir_rule, From patchwork Mon Sep 14 14:31:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangxiaoyun (Cloud)" X-Patchwork-Id: 77618 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 EFC8FA04C7; Mon, 14 Sep 2020 16:31:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A91BC1C10D; Mon, 14 Sep 2020 16:31:04 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id E1AAB1C0C9; Mon, 14 Sep 2020 16:30:58 +0200 (CEST) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C0EA4C3F399918BCD798; Mon, 14 Sep 2020 22:30:57 +0800 (CST) Received: from tester.localdomain (10.175.119.39) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 14 Sep 2020 22:30:50 +0800 From: Xiaoyun wang To: CC: , , , , , , , , , Xiaoyun wang Date: Mon, 14 Sep 2020 22:31:43 +0800 Message-ID: <263a30d52f070480b98cd9ae4c36a95e86af7463.1600093192.git.cloud.wangxiaoyun@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.175.119.39] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v1 2/5] net/hinic: fix TCAM filter set failed 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" hinic supports two methods: linear table and tcam table, if tcam filter enables failed but linear table is ok, which also needs to enable filter, so for this scene, driver should not close fdir switch. Fixes: f4ca3fd54c4d ("net/hinic: create and destroy flow director filter") Cc: stable@dpdk.org Signed-off-by: Xiaoyun wang --- drivers/net/hinic/hinic_pmd_flow.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c index 9888a87..d71a42a 100644 --- a/drivers/net/hinic/hinic_pmd_flow.c +++ b/drivers/net/hinic/hinic_pmd_flow.c @@ -2809,8 +2809,12 @@ static int hinic_add_tcam_filter(struct rte_eth_dev *dev, rc = hinic_set_fdir_tcam_rule_filter(nic_dev->hwdev, true); if (rc && rc != HINIC_MGMT_CMD_UNSUPPORTED) { - (void)hinic_set_fdir_filter(nic_dev->hwdev, 0, 0, 0, - false); + /* + * hinic supports two methods: linear table and tcam + * table, if tcam filter enables failed but linear table + * is ok, which also needs to enable filter, so for this + * scene, driver should not close fdir switch. + */ (void)hinic_del_tcam_rule(nic_dev->hwdev, fdir_tcam_rule->index); return rc; From patchwork Mon Sep 14 14:31:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangxiaoyun (Cloud)" X-Patchwork-Id: 77619 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 5F22BA04C7; Mon, 14 Sep 2020 16:31:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F184E1C114; Mon, 14 Sep 2020 16:31:07 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id C05311C0D9; Mon, 14 Sep 2020 16:31:03 +0200 (CEST) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D1DC11813655B671AC8F; Mon, 14 Sep 2020 22:31:02 +0800 (CST) Received: from tester.localdomain (10.175.119.39) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 14 Sep 2020 22:30:52 +0800 From: Xiaoyun wang To: CC: , , , , , , , , , Xiaoyun wang Date: Mon, 14 Sep 2020 22:31:44 +0800 Message-ID: <7c33a4f34f078703137fc2a02b88ec02aabec1e0.1600093192.git.cloud.wangxiaoyun@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.175.119.39] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v1 3/5] net/hinic: fix Rx nombuf stats 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" rx_mbuf_alloc_failed value is not set to 0 when get stats from driver, which may cause this counter added every time when call this ops. Fixes: cb7b6606ebff ("net/hinic: add RSS stats and promiscuous ops") Cc: stable@dpdk.org Signed-off-by: Xiaoyun wang --- drivers/net/hinic/hinic_pmd_ethdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c index 67e6afc..b2c8a51 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.c +++ b/drivers/net/hinic/hinic_pmd_ethdev.c @@ -1320,6 +1320,8 @@ static int hinic_set_dev_promiscuous(struct hinic_nic_dev *nic_dev, bool enable) return err; } + dev->data->rx_mbuf_alloc_failed = 0; + /* rx queue stats */ q_num = (nic_dev->num_rq < RTE_ETHDEV_QUEUE_STAT_CNTRS) ? nic_dev->num_rq : RTE_ETHDEV_QUEUE_STAT_CNTRS; From patchwork Mon Sep 14 14:31:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangxiaoyun (Cloud)" X-Patchwork-Id: 77620 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 AB7F8A04C7; Mon, 14 Sep 2020 16:31:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A0E7F1C0CE; Mon, 14 Sep 2020 16:31:11 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id B25051BE98; Mon, 14 Sep 2020 16:31:03 +0200 (CEST) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id CDD1CF67B9AB339F1297; Mon, 14 Sep 2020 22:31:02 +0800 (CST) Received: from tester.localdomain (10.175.119.39) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 14 Sep 2020 22:30:55 +0800 From: Xiaoyun wang To: CC: , , , , , , , , , Xiaoyun wang Date: Mon, 14 Sep 2020 22:31:45 +0800 Message-ID: <4742db7f675112f5233bbc9e8a3e48fb1c90865d.1600093192.git.cloud.wangxiaoyun@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.175.119.39] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v1 4/5] net/hinic/base: get default cos from chip 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" Get default cos of pf driver from chip configuration file. Fixes: 6691acef0d3d ("net/hinic: support VF") Cc: stable@dpdk.org Signed-off-by: Xiaoyun wang --- drivers/net/hinic/base/hinic_pmd_cfg.c | 7 ++++-- drivers/net/hinic/base/hinic_pmd_cfg.h | 1 + drivers/net/hinic/hinic_pmd_ethdev.c | 39 ++++++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/drivers/net/hinic/base/hinic_pmd_cfg.c b/drivers/net/hinic/base/hinic_pmd_cfg.c index a0cc16d..837734f 100644 --- a/drivers/net/hinic/base/hinic_pmd_cfg.c +++ b/drivers/net/hinic/base/hinic_pmd_cfg.c @@ -112,6 +112,7 @@ static void hinic_parse_pub_res_cap(struct service_cap *cap, cap->host_id = dev_cap->host_id; cap->ep_id = dev_cap->ep_id; cap->max_cos_id = dev_cap->max_cos_id; + cap->valid_cos_bitmap = dev_cap->valid_cos_bitmap; cap->er_id = dev_cap->er_id; cap->port_id = dev_cap->port_id; @@ -134,9 +135,11 @@ static void hinic_parse_pub_res_cap(struct service_cap *cap, cap->host_oq_id_mask_val = dev_cap->host_oq_id_mask_val; PMD_DRV_LOG(INFO, "Get public resource capability:"); - PMD_DRV_LOG(INFO, "host_id: 0x%x, ep_id: 0x%x, intr_type: 0x%x, max_cos_id: 0x%x, er_id: 0x%x, port_id: 0x%x", + PMD_DRV_LOG(INFO, "host_id: 0x%x, ep_id: 0x%x, intr_type: 0x%x, " + "max_cos_id: 0x%x, cos_bitmap: 0x%x, er_id: 0x%x, port_id: 0x%x", cap->host_id, cap->ep_id, cap->intr_chip_en, - cap->max_cos_id, cap->er_id, cap->port_id); + cap->max_cos_id, cap->valid_cos_bitmap, cap->er_id, + cap->port_id); PMD_DRV_LOG(INFO, "host_total_function: 0x%x, host_oq_id_mask_val: 0x%x, max_vf: 0x%x", cap->host_total_function, cap->host_oq_id_mask_val, cap->max_vf); diff --git a/drivers/net/hinic/base/hinic_pmd_cfg.h b/drivers/net/hinic/base/hinic_pmd_cfg.h index 1741ca4..6e76e1d 100644 --- a/drivers/net/hinic/base/hinic_pmd_cfg.h +++ b/drivers/net/hinic/base/hinic_pmd_cfg.h @@ -54,6 +54,7 @@ struct service_cap { u8 ep_id; u8 intr_chip_en; u8 max_cos_id; /* PF/VF's max cos id */ + u8 valid_cos_bitmap; u8 er_id; /* PF/VF's ER */ u8 port_id; /* PF/VF's physical port */ u8 max_vf; /* max VF number that PF supported */ diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c index b2c8a51..6fd16e6 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.c +++ b/drivers/net/hinic/hinic_pmd_ethdev.c @@ -2583,26 +2583,53 @@ static int hinic_set_default_dcb_feature(struct hinic_nic_dev *nic_dev) up_pgid, up_bw, up_strict); } +static int hinic_pf_get_default_cos(struct hinic_hwdev *hwdev, u8 *cos_id) +{ + u8 default_cos = 0; + u8 valid_cos_bitmap; + u8 i; + + valid_cos_bitmap = hwdev->cfg_mgmt->svc_cap.valid_cos_bitmap; + if (!valid_cos_bitmap) { + PMD_DRV_LOG(ERR, "PF has none cos to support\n"); + return -EFAULT; + } + + for (i = 0; i < NR_MAX_COS; i++) { + if (valid_cos_bitmap & BIT(i)) + default_cos = i; /* Find max cos id as default cos */ + } + + *cos_id = default_cos; + + return 0; +} + static int hinic_init_default_cos(struct hinic_nic_dev *nic_dev) { u8 cos_id = 0; int err; if (!HINIC_IS_VF(nic_dev->hwdev)) { - nic_dev->default_cos = - (hinic_global_func_id(nic_dev->hwdev) + - DEFAULT_BASE_COS) % NR_MAX_COS; + err = hinic_pf_get_default_cos(nic_dev->hwdev, &cos_id); + if (err) { + PMD_DRV_LOG(ERR, "Get PF default cos failed, err: %d", + err); + return HINIC_ERROR; + } } else { err = hinic_vf_get_default_cos(nic_dev->hwdev, &cos_id); if (err) { PMD_DRV_LOG(ERR, "Get VF default cos failed, err: %d", - err); + err); return HINIC_ERROR; } - - nic_dev->default_cos = cos_id; } + nic_dev->default_cos = cos_id; + + PMD_DRV_LOG(INFO, "Default cos %d", nic_dev->default_cos); + return 0; } From patchwork Mon Sep 14 14:31:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangxiaoyun (Cloud)" X-Patchwork-Id: 77621 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 7D0BEA04C7; Mon, 14 Sep 2020 16:31:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9D0491C11D; Mon, 14 Sep 2020 16:31:13 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id C6CDB1C0CD; Mon, 14 Sep 2020 16:31:09 +0200 (CEST) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0670BDC1192C98481B36; Mon, 14 Sep 2020 22:31:08 +0800 (CST) Received: from tester.localdomain (10.175.119.39) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 14 Sep 2020 22:31:01 +0800 From: Xiaoyun wang To: CC: , , , , , , , , , Xiaoyun wang Date: Mon, 14 Sep 2020 22:31:46 +0800 Message-ID: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.175.119.39] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v1 5/5] net/hinic/base: fix clock definition with glibc version 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" Sync the repair of patch("fix compile error for old glibc caused by CLOCK_MONOTONIC_RAW") in the community. Fixes: efeed0894e9c ("net/hinic/base: avoid system time jump") Cc: stable@dpdk.org Signed-off-by: Xiaoyun wang --- drivers/net/hinic/base/hinic_compat.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/hinic/base/hinic_compat.h b/drivers/net/hinic/base/hinic_compat.h index 7036b03..6dd210e 100644 --- a/drivers/net/hinic/base/hinic_compat.h +++ b/drivers/net/hinic/base/hinic_compat.h @@ -166,11 +166,17 @@ static inline u32 readl(const volatile void *addr) #define spin_lock(spinlock_prt) rte_spinlock_lock(spinlock_prt) #define spin_unlock(spinlock_prt) rte_spinlock_unlock(spinlock_prt) +#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */ +#define CLOCK_TYPE CLOCK_MONOTONIC_RAW +#else +#define CLOCK_TYPE CLOCK_MONOTONIC +#endif + static inline unsigned long clock_gettime_ms(void) { struct timespec tv; - (void)clock_gettime(CLOCK_MONOTONIC, &tv); + (void)clock_gettime(CLOCK_TYPE, &tv); return (unsigned long)tv.tv_sec * 1000 + (unsigned long)tv.tv_nsec / 1000000;