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 EE67BA034D for ; Mon, 17 Aug 2020 11:26:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E532C1C123; Mon, 17 Aug 2020 11:26:19 +0200 (CEST) Received: from mail.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id E84C11C12F for ; Mon, 17 Aug 2020 11:26:17 +0200 (CEST) Received: from localhost.localdomain (120.133.139.157) by INCCAS001.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Mon, 17 Aug 2020 17:25:43 +0800 From: "Wei Hu (Xavier)" To: CC: Date: Mon, 17 Aug 2020 17:25:19 +0800 Message-ID: <20200817092532.59530-12-huwei013@chinasoftinc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200817092532.59530-1-huwei013@chinasoftinc.com> References: <20200817092532.59530-1-huwei013@chinasoftinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [120.133.139.157] Subject: [dpdk-stable] [PATCH 11/24] net/hns3: get PCI revision ID X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: "Wei Hu (Xavier)" [ upstream commit 837740cfa37a4641b6e3fc2d92c6572fe3c9911f ] The hns3 network engine is built-in multiple SoCs, such as kunpeng 920, kunpeng 930, etc. The PCI revision id is 0x21 in kunpeng 920, and the PCI revision id is 0x30 in kunpeng 930. This patch gets PCI revision to identify different version of hardware network engine. Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 12 ++++++++++++ drivers/net/hns3/hns3_ethdev.h | 5 +++++ drivers/net/hns3/hns3_ethdev_vf.c | 13 +++++++++++++ 3 files changed, 30 insertions(+) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 0bad55030..fcd47ef9a 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5392,9 +5392,21 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) struct hns3_adapter *hns = eth_dev->data->dev_private; struct hns3_hw *hw = &hns->hw; uint16_t device_id = pci_dev->id.device_id; + uint8_t revision; int ret; PMD_INIT_FUNC_TRACE(); + + /* Get PCI revision id */ + ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, + HNS3_PCI_REVISION_ID); + if (ret != HNS3_PCI_REVISION_ID_LEN) { + PMD_INIT_LOG(ERR, "Failed to read pci revision id, ret = %d", + ret); + return -EIO; + } + hw->revision = revision; + eth_dev->process_private = (struct hns3_process_private *) rte_zmalloc_socket("hns3_filter_list", sizeof(struct hns3_process_private), diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index df06ba3b0..ba06ed103 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -26,6 +26,10 @@ #define HNS3_DEV_ID_100G_VF 0xA22E #define HNS3_DEV_ID_100G_RDMA_PFC_VF 0xA22F +/* PCI Config offsets */ +#define HNS3_PCI_REVISION_ID 0x08 +#define HNS3_PCI_REVISION_ID_LEN 1 + #define HNS3_UC_MACADDR_NUM 128 #define HNS3_VF_UC_MACADDR_NUM 48 #define HNS3_MC_MACADDR_NUM 128 @@ -351,6 +355,7 @@ struct hns3_reset_data { struct hns3_hw { struct rte_eth_dev_data *data; void *io_base; + uint8_t revision; /* PCI revision, low byte of class word */ struct hns3_cmq cmq; struct hns3_mbx_resp_status mbx_resp; /* mailbox response */ struct hns3_mbx_arq_ring arq; /* mailbox async rx queue */ diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index d503d5011..99e09ec45 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2392,12 +2392,25 @@ static const struct hns3_reset_ops hns3vf_reset_ops = { static int hns3vf_dev_init(struct rte_eth_dev *eth_dev) { + struct rte_device *dev = eth_dev->device; + struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev); struct hns3_adapter *hns = eth_dev->data->dev_private; struct hns3_hw *hw = &hns->hw; + uint8_t revision; int ret; PMD_INIT_FUNC_TRACE(); + /* Get PCI revision id */ + ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, + HNS3_PCI_REVISION_ID); + if (ret != HNS3_PCI_REVISION_ID_LEN) { + PMD_INIT_LOG(ERR, "Failed to read pci revision id, ret = %d", + ret); + return -EIO; + } + hw->revision = revision; + eth_dev->process_private = (struct hns3_process_private *) rte_zmalloc_socket("hns3_filter_list", sizeof(struct hns3_process_private), -- 2.27.0