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 C9171459C6; Wed, 18 Sep 2024 09:53:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BB9E142F53; Wed, 18 Sep 2024 09:51:27 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 4235742EAE for ; Wed, 18 Sep 2024 09:51:06 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 26D921A13B8; Wed, 18 Sep 2024 09:51:06 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E1B851A13B5; Wed, 18 Sep 2024 09:51:05 +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 6231B183C481; Wed, 18 Sep 2024 15:51:05 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Jun Yang Subject: [v2 18/43] bus/fslmc: create dpaa2 device with it's object Date: Wed, 18 Sep 2024 13:20:31 +0530 Message-Id: <20240918075056.1838654-19-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240918075056.1838654-1-vanshika.shukla@nxp.com> References: <20240913055959.3246917-1-vanshika.shukla@nxp.com> <20240918075056.1838654-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 11eebd560c..462bf2113e 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 733423faa0..9a1e53f2ee 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -1469,8 +1469,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 d7de2bca05..03c2c82f66 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 b52a8c8ba5..346092a6b4 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c @@ -391,14 +391,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 53020e9302..4390be9789 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