From patchwork Fri Oct 22 09:19:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 102646 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 0C046A0C43; Fri, 22 Oct 2021 11:22:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 60EC4411CC; Fri, 22 Oct 2021 11:22:10 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 23AEE41103 for ; Fri, 22 Oct 2021 11:21:59 +0200 (CEST) Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HbJdt5tNYzbnMx; Fri, 22 Oct 2021 17:17:22 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Fri, 22 Oct 2021 17:21:57 +0800 From: "Min Hu (Connor)" To: CC: , Date: Fri, 22 Oct 2021 17:19:59 +0800 Message-ID: <20211022092006.60959-9-humin29@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211022092006.60959-1-humin29@huawei.com> References: <20211022092006.60959-1-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 08/14] net/hns3: add hns3 HW ops structure to operate hardware 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 This patch adds hns3_hw_ops structure to operate hardware in PF and VF driver. Signed-off-by: Huisong Li Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 10 ++++++++++ drivers/net/hns3/hns3_ethdev.h | 13 +++++++++++++ drivers/net/hns3/hns3_ethdev_vf.c | 10 ++++++++++ 3 files changed, 33 insertions(+) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 02d4b11029..e1099f5df9 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -7436,6 +7436,15 @@ static const struct hns3_reset_ops hns3_reset_ops = { .start_service = hns3_start_service, }; +static void +hns3_init_hw_ops(struct hns3_hw *hw) +{ + hw->ops.add_mc_mac_addr = hns3_add_mc_mac_addr; + hw->ops.del_mc_mac_addr = hns3_remove_mc_mac_addr; + hw->ops.add_uc_mac_addr = hns3_add_uc_mac_addr; + hw->ops.del_uc_mac_addr = hns3_remove_uc_mac_addr; +} + static int hns3_dev_init(struct rte_eth_dev *eth_dev) { @@ -7488,6 +7497,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) goto err_init_reset; hw->reset.ops = &hns3_reset_ops; + hns3_init_hw_ops(hw); ret = hns3_init_pf(eth_dev); if (ret) { PMD_INIT_LOG(ERR, "Failed to init pf: %d", ret); diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 20999ce7ab..9d0a060720 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -428,6 +428,17 @@ struct hns3_reset_data { struct hns3_wait_data *wait_data; }; +struct hns3_hw_ops { + int (*add_mc_mac_addr)(struct hns3_hw *hw, + struct rte_ether_addr *mac_addr); + int (*del_mc_mac_addr)(struct hns3_hw *hw, + struct rte_ether_addr *mac_addr); + int (*add_uc_mac_addr)(struct hns3_hw *hw, + struct rte_ether_addr *mac_addr); + int (*del_uc_mac_addr)(struct hns3_hw *hw, + struct rte_ether_addr *mac_addr); +}; + #define HNS3_INTR_MAPPING_VEC_RSV_ONE 0 #define HNS3_INTR_MAPPING_VEC_ALL 1 @@ -638,6 +649,8 @@ struct hns3_hw { struct hns3_rss_filter_list flow_rss_list; /* flow RSS rule list */ struct hns3_flow_mem_list flow_list; + struct hns3_hw_ops ops; + /* * PMD setup and configuration is not thread safe. Since it is not * performance sensitive, it is better to guarantee thread-safety diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index abb9211a09..b5c6a696f3 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2894,6 +2894,15 @@ static const struct hns3_reset_ops hns3vf_reset_ops = { .start_service = hns3vf_start_service, }; +static void +hns3vf_init_hw_ops(struct hns3_hw *hw) +{ + hw->ops.add_mc_mac_addr = hns3vf_add_mc_mac_addr; + hw->ops.del_mc_mac_addr = hns3vf_remove_mc_mac_addr; + hw->ops.add_uc_mac_addr = hns3vf_add_uc_mac_addr; + hw->ops.del_uc_mac_addr = hns3vf_remove_uc_mac_addr; +} + static int hns3vf_dev_init(struct rte_eth_dev *eth_dev) { @@ -2938,6 +2947,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) goto err_init_reset; hw->reset.ops = &hns3vf_reset_ops; + hns3vf_init_hw_ops(hw); ret = hns3vf_init_vf(eth_dev); if (ret) { PMD_INIT_LOG(ERR, "Failed to init vf: %d", ret);