DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xiaoyun wang <cloud.wangxiaoyun@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <bluca@debian.org>,
	<luoxianjun@huawei.com>, <luoxingyu@huawei.com>,
	<zhouguoyang@huawei.com>, <xuanziyang2@huawei.com>,
	<shahar.belkar@huawei.com>, <yin.yinshi@huawei.com>,
	Xiaoyun wang <cloud.wangxiaoyun@huawei.com>
Subject: [dpdk-dev] [PATCH v2 3/7] net/hinic/base: optimize doorbell area initialization
Date: Tue, 17 Mar 2020 23:01:13 +0800	[thread overview]
Message-ID: <a93a09d801b0cde985352071d5b613a18725eaed.1584456756.git.cloud.wangxiaoyun@huawei.com> (raw)
In-Reply-To: <cover.1584456756.git.cloud.wangxiaoyun@huawei.com>

The maximum doorbell area is inited from hardware param, and not uses
const macro param.

Signed-off-by: Xiaoyun wang <cloud.wangxiaoyun@huawei.com>
---
 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


  parent reply	other threads:[~2020-03-17 14:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17 15:01 [dpdk-dev] [PATCH v2 0/7] Fix LRO issue and support Flow Control Xiaoyun wang
2020-03-17 15:01 ` [dpdk-dev] [PATCH v2 1/7] net/hinic: fix LRO problems Xiaoyun wang
2020-03-17 15:01 ` [dpdk-dev] [PATCH v2 2/7] net/hinic/base: fix hotupdate firmware problem Xiaoyun wang
2020-03-17 15:01 ` Xiaoyun wang [this message]
2020-03-17 15:01 ` [dpdk-dev] [PATCH v2 4/7] net/hinic: remove 40GE Mezz card id Xiaoyun wang
2020-03-17 15:01 ` [dpdk-dev] [PATCH v2 5/7] net/hinic: Add Fdir filter type Xiaoyun wang
2020-03-17 15:01 ` [dpdk-dev] [PATCH v2 6/7] net/hinic/base: Optimize log files Xiaoyun wang
2020-03-17 15:01 ` [dpdk-dev] [PATCH v2 7/7] net/hinic/base: Support Pause flow control Xiaoyun wang
2020-03-20 10:05 ` [dpdk-dev] [PATCH v2 0/7] Fix LRO issue and support Flow Control Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a93a09d801b0cde985352071d5b613a18725eaed.1584456756.git.cloud.wangxiaoyun@huawei.com \
    --to=cloud.wangxiaoyun@huawei.com \
    --cc=bluca@debian.org \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=luoxianjun@huawei.com \
    --cc=luoxingyu@huawei.com \
    --cc=shahar.belkar@huawei.com \
    --cc=xuanziyang2@huawei.com \
    --cc=yin.yinshi@huawei.com \
    --cc=zhouguoyang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).