From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23CF54595A; Wed, 11 Sep 2024 04:08:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 01C7A42F4F; Wed, 11 Sep 2024 04:08:16 +0200 (CEST) Received: from lf-1-19.ptr.blmpb.com (lf-1-19.ptr.blmpb.com [103.149.242.19]) by mails.dpdk.org (Postfix) with ESMTP id EFB4F402DE for ; Wed, 11 Sep 2024 04:08:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1726020481; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=V2WUDsjII+ZNpkG22zwzcxG7uuU2wIpYEsYHNmDOYjg=; b=HAsHFS6yJEKVv+q3dJeZLFmAcA808Ql/jXMmkbLXfIhJS1GG6GVu6w8lgTO3VdVmndtyH9 KBqpniPqzL7PBzYNR5PdhpCHosHCPC4IHXfcJLocoHEZTE3+j9JF6HKcGeLCN9WeuoewTs 84YWR1m1serOG2oH23FgHubMHJQWfVP4TLyywkXn/G9LWpcasnQhnTE0L3lvAFTipzo7GR 4GkjWbEYNexjv+qvlPDC8PuiYWsW6ZXSZqQZkKDd6kYQur45mZUEbJRoxJU7NoB3e9kCb5 mFDLS13A8RFH18f4YdGtpD2s1w93AxsS1ZxkJ5BjZIjPJEKBlqMmxFe5i7ehgg== To: Date: Wed, 11 Sep 2024 10:07:27 +0800 Message-Id: <20240911020740.3950704-7-wanry@yunsilicon.com> Mime-Version: 1.0 X-Lms-Return-Path: From: "WanRenyong" Content-Type: text/plain; charset=UTF-8 Subject: [PATCH v2 06/19] net/xsc: initialize hardware information X-Original-From: WanRenyong Received: from ubuntu-liun.yunsilicon.com ([58.34.192.114]) by smtp.feishu.cn with ESMTPS; Wed, 11 Sep 2024 10:07:59 +0800 X-Mailer: git-send-email 2.25.1 Cc: , , "WanRenyong" Content-Transfer-Encoding: 7bit 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 Getting hardware information is done by ioctl command, which contains the information of xsc device, as well as the common information of the NIC board. Signed-off-by: WanRenyong --- drivers/net/xsc/xsc_dev.c | 63 +++++++++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_dev.h | 32 ++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/drivers/net/xsc/xsc_dev.c b/drivers/net/xsc/xsc_dev.c index 9673049628..1eb68ac95d 100644 --- a/drivers/net/xsc/xsc_dev.c +++ b/drivers/net/xsc/xsc_dev.c @@ -18,10 +18,64 @@ #include "xsc_defs.h" #include "xsc_dev.h" #include "xsc_utils.h" +#include "xsc_ctrl.h" #define XSC_DEV_DEF_FLOW_MODE XSC_FLOW_MODE_NULL #define XSC_DEV_CTRL_FILE_FMT "/dev/yunsilicon/port_ctrl_" PCI_PRI_FMT +static int xsc_hwinfo_init(struct xsc_dev *dev) +{ + struct { + struct xsc_ioctl_data_tl tl; + struct xsc_ioctl_get_hwinfo hwinfo; + } data; + struct xsc_ioctl_get_hwinfo *info = &data.hwinfo; + int data_len; + int ret; + + PMD_INIT_FUNC_TRACE(); + + data_len = sizeof(data); + data.tl.opmod = XSC_IOCTL_OP_GET_LOCAL; + ret = xsc_ioctl(dev, XSC_IOCTL_DRV_GET, XSC_IOCTL_GET_HW_INFO, &data, data_len, + &data, data_len); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to get hardware info"); + return ret; + } + + dev->hwinfo.valid = 1; + dev->hwinfo.pcie_no = info->pcie_no; + dev->hwinfo.func_id = info->func_id; + dev->hwinfo.pcie_host = info->pcie_host; + dev->hwinfo.mac_phy_port = info->mac_phy_port; + dev->hwinfo.funcid_to_logic_port_off = info->funcid_to_logic_port_off; + dev->hwinfo.lag_id = info->lag_id; + dev->hwinfo.raw_qp_id_base = info->raw_qp_id_base; + dev->hwinfo.raw_rss_qp_id_base = info->raw_rss_qp_id_base; + dev->hwinfo.pf0_vf_funcid_base = info->pf0_vf_funcid_base; + dev->hwinfo.pf0_vf_funcid_top = info->pf0_vf_funcid_top; + dev->hwinfo.pf1_vf_funcid_base = info->pf1_vf_funcid_base; + dev->hwinfo.pf1_vf_funcid_top = info->pf1_vf_funcid_top; + dev->hwinfo.pcie0_pf_funcid_base = info->pcie0_pf_funcid_base; + dev->hwinfo.pcie0_pf_funcid_top = info->pcie0_pf_funcid_top; + dev->hwinfo.pcie1_pf_funcid_base = info->pcie1_pf_funcid_base; + dev->hwinfo.pcie1_pf_funcid_top = info->pcie1_pf_funcid_top; + dev->hwinfo.lag_port_start = info->lag_port_start; + dev->hwinfo.raw_tpe_qp_num = info->raw_tpe_qp_num; + dev->hwinfo.send_seg_num = info->send_seg_num; + dev->hwinfo.recv_seg_num = info->recv_seg_num; + dev->hwinfo.on_chip_tbl_vld = info->on_chip_tbl_vld; + dev->hwinfo.dma_rw_tbl_vld = info->dma_rw_tbl_vld; + dev->hwinfo.pct_compress_vld = info->pct_compress_vld; + dev->hwinfo.chip_version = info->chip_version; + dev->hwinfo.hca_core_clock = info->hca_core_clock; + dev->hwinfo.mac_bit = info->mac_bit; + dev->hwinfo.esw_mode = info->esw_mode; + + return 0; +} + static void xsc_dev_args_parse(struct xsc_dev *dev, struct rte_devargs *devargs) { @@ -142,11 +196,20 @@ xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **dev) goto dev_open_fail; } + ret = xsc_hwinfo_init(d); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to initialize hardware info"); + goto hwinfo_init_fail; + return ret; + } + d->pci_dev = pci_dev; *dev = d; return 0; +hwinfo_init_fail: + xsc_dev_close(d); dev_open_fail: rte_free(d); return ret; diff --git a/drivers/net/xsc/xsc_dev.h b/drivers/net/xsc/xsc_dev.h index ce9dd65400..5f0e911b42 100644 --- a/drivers/net/xsc/xsc_dev.h +++ b/drivers/net/xsc/xsc_dev.h @@ -11,6 +11,37 @@ #define XSC_NIC_MODE_ARG "nic_mode" #define XSC_FLOW_MODE_ARG "flow_mode" +struct xsc_hwinfo { + uint8_t valid; /* 1: current phy info is valid, 0 : invalid */ + uint32_t pcie_no; /* pcie number , 0 or 1 */ + uint32_t func_id; /* pf glb func id */ + uint32_t pcie_host; /* host pcie number */ + uint32_t mac_phy_port; /* mac port */ + uint32_t funcid_to_logic_port_off; /* port func id offset */ + uint16_t lag_id; + uint16_t raw_qp_id_base; + uint16_t raw_rss_qp_id_base; + uint16_t pf0_vf_funcid_base; + uint16_t pf0_vf_funcid_top; + uint16_t pf1_vf_funcid_base; + uint16_t pf1_vf_funcid_top; + uint16_t pcie0_pf_funcid_base; + uint16_t pcie0_pf_funcid_top; + uint16_t pcie1_pf_funcid_base; + uint16_t pcie1_pf_funcid_top; + uint16_t lag_port_start; + uint16_t raw_tpe_qp_num; + int send_seg_num; + int recv_seg_num; + uint8_t on_chip_tbl_vld; + uint8_t dma_rw_tbl_vld; + uint8_t pct_compress_vld; + uint32_t chip_version; + uint32_t hca_core_clock; + uint8_t mac_bit; + uint8_t esw_mode; +}; + struct xsc_devargs { int nic_mode; int flow_mode; @@ -20,6 +51,7 @@ struct xsc_devargs { struct xsc_dev { struct rte_pci_device *pci_dev; struct xsc_devargs devargs; + struct xsc_hwinfo hwinfo; struct ibv_context *ibv_ctx; struct ibv_pd *ibv_pd; char ibv_name[IBV_SYSFS_NAME_MAX]; -- 2.25.1