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 A2920A0565; Tue, 17 Mar 2020 15:46:26 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB8FB1C02D; Tue, 17 Mar 2020 15:46:04 +0100 (CET) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id 3F14C25D9 for ; Tue, 17 Mar 2020 15:46:01 +0100 (CET) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 1805EB70697939C29ACE; Tue, 17 Mar 2020 22:45:59 +0800 (CST) Received: from tester.localdomain (10.175.119.39) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Tue, 17 Mar 2020 22:45:52 +0800 From: Xiaoyun wang To: CC: , , , , , , , , Xiaoyun wang Date: Tue, 17 Mar 2020 23:01:13 +0800 Message-ID: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.119.39] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v2 3/7] net/hinic/base: optimize doorbell area initialization 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 maximum doorbell area is inited from hardware param, and not uses const macro param. Signed-off-by: Xiaoyun wang --- drivers/net/hinic/base/hinic_pmd_hwif.c | 23 +++++++++++++++++------ drivers/net/hinic/base/hinic_pmd_hwif.h | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/hinic/base/hinic_pmd_hwif.c b/drivers/net/hinic/base/hinic_pmd_hwif.c index 8a01fbc..0fced5b 100644 --- a/drivers/net/hinic/base/hinic_pmd_hwif.c +++ b/drivers/net/hinic/base/hinic_pmd_hwif.c @@ -183,17 +183,19 @@ static void set_ppf(struct hinic_hwif *hwif) attr->func_type = TYPE_PPF; } -static void init_db_area_idx(struct hinic_free_db_area *free_db_area) +static void init_db_area_idx(struct hinic_hwif *hwif) { + struct hinic_free_db_area *free_db_area = &hwif->free_db_area; + u32 db_max_areas = hwif->db_max_areas; u32 i; - for (i = 0; i < HINIC_DB_MAX_AREAS; i++) + for (i = 0; i < db_max_areas; i++) free_db_area->db_idx[i] = i; free_db_area->alloc_pos = 0; free_db_area->return_pos = 0; - free_db_area->num_free = HINIC_DB_MAX_AREAS; + free_db_area->num_free = db_max_areas; spin_lock_init(&free_db_area->idx_lock); } @@ -214,7 +216,7 @@ static int get_db_idx(struct hinic_hwif *hwif, u32 *idx) free_db_area->num_free--; pos = free_db_area->alloc_pos++; - pos &= HINIC_DB_MAX_AREAS - 1; + pos &= (hwif->db_max_areas - 1); pg_idx = free_db_area->db_idx[pos]; @@ -235,7 +237,7 @@ static void free_db_idx(struct hinic_hwif *hwif, u32 idx) spin_lock(&free_db_area->idx_lock); pos = free_db_area->return_pos++; - pos &= HINIC_DB_MAX_AREAS - 1; + pos &= (hwif->db_max_areas - 1); free_db_area->db_idx[pos] = idx; @@ -391,8 +393,13 @@ static int hinic_init_hwif(struct hinic_hwdev *hwdev, void *cfg_reg_base, void *db_base, __rte_unused void *dwqe_mapping) { struct hinic_hwif *hwif; + struct rte_pci_device *pci_dev; + u64 db_bar_len; int err; + pci_dev = (struct rte_pci_device *)(hwdev->pcidev_hdl); + db_bar_len = pci_dev->mem_resource[HINIC_DB_MEM_BAR].len; + hwif = hwdev->hwif; hwif->cfg_regs_base = (u8 __iomem *)cfg_reg_base; @@ -400,7 +407,11 @@ static int hinic_init_hwif(struct hinic_hwdev *hwdev, void *cfg_reg_base, hwif->db_base_phy = db_base_phy; hwif->db_base = (u8 __iomem *)db_base; - init_db_area_idx(&hwif->free_db_area); + hwif->db_max_areas = db_bar_len / HINIC_DB_PAGE_SIZE; + if (hwif->db_max_areas > HINIC_DB_MAX_AREAS) + hwif->db_max_areas = HINIC_DB_MAX_AREAS; + + init_db_area_idx(hwif); get_hwif_attr(hwif); diff --git a/drivers/net/hinic/base/hinic_pmd_hwif.h b/drivers/net/hinic/base/hinic_pmd_hwif.h index 6752587..de99507 100644 --- a/drivers/net/hinic/base/hinic_pmd_hwif.h +++ b/drivers/net/hinic/base/hinic_pmd_hwif.h @@ -73,6 +73,7 @@ struct hinic_hwif { u8 __iomem *intr_regs_base; u64 db_base_phy; u8 __iomem *db_base; + u64 db_max_areas; struct hinic_free_db_area free_db_area; struct hinic_func_attr attr; }; -- 1.8.3.1