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 2E8DF45BB0; Wed, 23 Oct 2024 14:02:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E04742E47; Wed, 23 Oct 2024 14:00:28 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id 0C947402E6 for ; Wed, 23 Oct 2024 14:00:05 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E12E420259E; Wed, 23 Oct 2024 14:00:04 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id AF1FB2025A1; Wed, 23 Oct 2024 14:00:04 +0200 (CEST) Received: from lsv03379.swis.in-blr01.nxp.com (lsv03379.swis.in-blr01.nxp.com [92.120.147.188]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 30103183DC0B; Wed, 23 Oct 2024 20:00:04 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Jun Yang Subject: [v5 18/42] bus/fslmc: create dpaa2 device with it's object Date: Wed, 23 Oct 2024 17:29:31 +0530 Message-Id: <20241023115955.1207617-19-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241023115955.1207617-1-vanshika.shukla@nxp.com> References: <20241022191256.516818-1-vanshika.shukla@nxp.com> <20241023115955.1207617-1-vanshika.shukla@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP 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 From: Jun Yang Create dpaa2 device with object instead of object ID. Assign each dpaa2 object with it's container. Signed-off-by: Jun Yang --- drivers/bus/fslmc/bus_fslmc_driver.h | 39 ++++++++++++------------ drivers/bus/fslmc/fslmc_vfio.c | 3 +- drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c | 6 ++-- drivers/bus/fslmc/portal/dpaa2_hw_dpci.c | 8 ++--- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 6 ++-- drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 8 +++-- drivers/event/dpaa2/dpaa2_hw_dpcon.c | 8 ++--- drivers/net/dpaa2/dpaa2_mux.c | 6 ++-- drivers/net/dpaa2/dpaa2_ptp.c | 8 ++--- 9 files changed, 47 insertions(+), 45 deletions(-) diff --git a/drivers/bus/fslmc/bus_fslmc_driver.h b/drivers/bus/fslmc/bus_fslmc_driver.h index ba3774823b..777ab24c10 100644 --- a/drivers/bus/fslmc/bus_fslmc_driver.h +++ b/drivers/bus/fslmc/bus_fslmc_driver.h @@ -89,25 +89,6 @@ enum rte_dpaa2_dev_type { DPAA2_DEVTYPE_MAX, }; -TAILQ_HEAD(rte_dpaa2_object_list, rte_dpaa2_object); - -typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd, - struct vfio_device_info *obj_info, - int object_id); - -typedef void (*rte_dpaa2_obj_close_t)(int object_id); - -/** - * A structure describing a DPAA2 object. - */ -struct rte_dpaa2_object { - TAILQ_ENTRY(rte_dpaa2_object) next; /**< Next in list. */ - const char *name; /**< Name of Object. */ - enum rte_dpaa2_dev_type dev_type; /**< Type of device */ - rte_dpaa2_obj_create_t create; - rte_dpaa2_obj_close_t close; -}; - /** * A structure describing a DPAA2 device. */ @@ -123,6 +104,7 @@ struct rte_dpaa2_device { enum rte_dpaa2_dev_type dev_type; /**< Device Type */ uint16_t object_id; /**< DPAA2 Object ID */ enum rte_dpaa2_dev_type ep_dev_type; /**< Endpoint Device Type */ + struct dpaa2_dprc_dev *container; uint16_t ep_object_id; /**< Endpoint DPAA2 Object ID */ char ep_name[RTE_DEV_NAME_MAX_LEN]; struct rte_intr_handle *intr_handle; /**< Interrupt handle */ @@ -130,10 +112,29 @@ struct rte_dpaa2_device { char name[FSLMC_OBJECT_MAX_LEN]; /**< DPAA2 Object name*/ }; +typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd, + struct vfio_device_info *obj_info, + struct rte_dpaa2_device *dev); + +typedef void (*rte_dpaa2_obj_close_t)(int object_id); + typedef int (*rte_dpaa2_probe_t)(struct rte_dpaa2_driver *dpaa2_drv, struct rte_dpaa2_device *dpaa2_dev); typedef int (*rte_dpaa2_remove_t)(struct rte_dpaa2_device *dpaa2_dev); +TAILQ_HEAD(rte_dpaa2_object_list, rte_dpaa2_object); + +/** + * A structure describing a DPAA2 object. + */ +struct rte_dpaa2_object { + TAILQ_ENTRY(rte_dpaa2_object) next; /**< Next in list. */ + const char *name; /**< Name of Object. */ + enum rte_dpaa2_dev_type dev_type; /**< Type of device */ + rte_dpaa2_obj_create_t create; + rte_dpaa2_obj_close_t close; +}; + /** * A structure describing a DPAA2 driver. */ diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 9d913781ae..5b382d93e4 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -1458,8 +1458,7 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev) case DPAA2_DPRC: TAILQ_FOREACH(object, &dpaa2_obj_list, next) { if (dev->dev_type == object->dev_type) - object->create(dev_fd, &device_info, - dev->object_id); + object->create(dev_fd, &device_info, dev); else continue; } diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c index 85e4c16c03..0ca3b2b2e4 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c @@ -47,11 +47,11 @@ static struct dpaa2_dpbp_dev *get_dpbp_from_id(uint32_t dpbp_id) static int dpaa2_create_dpbp_device(int vdev_fd __rte_unused, - struct vfio_device_info *obj_info __rte_unused, - int dpbp_id) + struct vfio_device_info *obj_info __rte_unused, + struct rte_dpaa2_device *obj) { struct dpaa2_dpbp_dev *dpbp_node; - int ret; + int ret, dpbp_id = obj->object_id; static int register_once; /* Allocate DPAA2 dpbp handle */ diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c index 99f2147ccb..9d7108bfdc 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause * - * Copyright 2017,2020 NXP + * Copyright 2017, 2020, 2023 NXP * */ @@ -45,15 +45,15 @@ static struct dpaa2_dpci_dev *get_dpci_from_id(uint32_t dpci_id) static int rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused, - struct vfio_device_info *obj_info __rte_unused, - int dpci_id) + struct vfio_device_info *obj_info __rte_unused, + struct rte_dpaa2_device *obj) { struct dpaa2_dpci_dev *dpci_node; struct dpci_attr attr; struct dpci_rx_queue_cfg rx_queue_cfg; struct dpci_rx_queue_attr rx_attr; struct dpci_tx_queue_attr tx_attr; - int ret, i; + int ret, i, dpci_id = obj->object_id; /* Allocate DPAA2 dpci handle */ dpci_node = rte_malloc(NULL, sizeof(struct dpaa2_dpci_dev), 0); diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c index 954d59d123..67d4c83e8c 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c @@ -399,14 +399,14 @@ dpaa2_close_dpio_device(int object_id) static int dpaa2_create_dpio_device(int vdev_fd, - struct vfio_device_info *obj_info, - int object_id) + struct vfio_device_info *obj_info, + struct rte_dpaa2_device *obj) { struct dpaa2_dpio_dev *dpio_dev = NULL; struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)}; struct qbman_swp_desc p_des; struct dpio_attr attr; - int ret; + int ret, object_id = obj->object_id; if (obj_info->num_regions < NUM_DPIO_REGIONS) { DPAA2_BUS_ERR("Not sufficient number of DPIO regions"); diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c b/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c index 65e2d799c3..a057cb1309 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c @@ -23,13 +23,13 @@ static struct dprc_dev_list dprc_dev_list static int rte_dpaa2_create_dprc_device(int vdev_fd __rte_unused, - struct vfio_device_info *obj_info __rte_unused, - int dprc_id) + struct vfio_device_info *obj_info __rte_unused, + struct rte_dpaa2_device *obj) { struct dpaa2_dprc_dev *dprc_node; struct dprc_endpoint endpoint1, endpoint2; struct rte_dpaa2_device *dev, *dev_tmp; - int ret; + int ret, dprc_id = obj->object_id; /* Allocate DPAA2 dprc handle */ dprc_node = rte_malloc(NULL, sizeof(struct dpaa2_dprc_dev), 0); @@ -50,6 +50,8 @@ rte_dpaa2_create_dprc_device(int vdev_fd __rte_unused, } RTE_TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, dev_tmp) { + /** DPRC is always created before it's children are created.*/ + dev->container = dprc_node; if (dev->dev_type == DPAA2_ETH) { int link_state; diff --git a/drivers/event/dpaa2/dpaa2_hw_dpcon.c b/drivers/event/dpaa2/dpaa2_hw_dpcon.c index 64b0136e24..ea5b0d4b85 100644 --- a/drivers/event/dpaa2/dpaa2_hw_dpcon.c +++ b/drivers/event/dpaa2/dpaa2_hw_dpcon.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause * - * Copyright 2017,2020 NXP + * Copyright 2017, 2020, 2023 NXP * */ @@ -45,12 +45,12 @@ static struct dpaa2_dpcon_dev *get_dpcon_from_id(uint32_t dpcon_id) static int rte_dpaa2_create_dpcon_device(int dev_fd __rte_unused, - struct vfio_device_info *obj_info __rte_unused, - int dpcon_id) + struct vfio_device_info *obj_info __rte_unused, + struct rte_dpaa2_device *obj) { struct dpaa2_dpcon_dev *dpcon_node; struct dpcon_attr attr; - int ret; + int ret, dpcon_id = obj->object_id; /* Allocate DPAA2 dpcon handle */ dpcon_node = rte_malloc(NULL, sizeof(struct dpaa2_dpcon_dev), 0); diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c index 3693f4b62e..f4b8d481af 100644 --- a/drivers/net/dpaa2/dpaa2_mux.c +++ b/drivers/net/dpaa2/dpaa2_mux.c @@ -374,12 +374,12 @@ rte_pmd_dpaa2_mux_dump_counter(FILE *f, uint32_t dpdmux_id, int num_if) static int dpaa2_create_dpdmux_device(int vdev_fd __rte_unused, - struct vfio_device_info *obj_info __rte_unused, - int dpdmux_id) + struct vfio_device_info *obj_info __rte_unused, + struct rte_dpaa2_device *obj) { struct dpaa2_dpdmux_dev *dpdmux_dev; struct dpdmux_attr attr; - int ret; + int ret, dpdmux_id = obj->object_id; uint16_t maj_ver; uint16_t min_ver; uint8_t skip_reset_flags; diff --git a/drivers/net/dpaa2/dpaa2_ptp.c b/drivers/net/dpaa2/dpaa2_ptp.c index c08aa0f3bf..751e558c73 100644 --- a/drivers/net/dpaa2/dpaa2_ptp.c +++ b/drivers/net/dpaa2/dpaa2_ptp.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2019 NXP + * Copyright 2019, 2023 NXP */ #include @@ -134,11 +134,11 @@ int dpaa2_timesync_read_rx_timestamp(struct rte_eth_dev *dev, #if defined(RTE_LIBRTE_IEEE1588) static int dpaa2_create_dprtc_device(int vdev_fd __rte_unused, - struct vfio_device_info *obj_info __rte_unused, - int dprtc_id) + struct vfio_device_info *obj_info __rte_unused, + struct rte_dpaa2_device *obj) { struct dprtc_attr attr; - int ret; + int ret, dprtc_id = obj->object_id; PMD_INIT_FUNC_TRACE(); -- 2.25.1