From patchwork Thu May 14 13:25:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 186720 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp1404451ilb; Thu, 14 May 2020 06:30:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkRlt/EFPW2EO3RjzPqq+xBhsqXt7TXVP+cBsdXt5WEFBgqBUuxo5Zuk+OpmA753hdlDZ4 X-Received: by 2002:a1c:6182:: with SMTP id v124mr8525907wmb.30.1589463025577; Thu, 14 May 2020 06:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589463025; cv=none; d=google.com; s=arc-20160816; b=ISxTkVadErIGPVEB29wgmrPseF4oE57fmHEA9SoS2QoYGVBPBp26kyw0vCei76i6M5 a+UlVJhB8avOVHEhzqcBwlYEjYUdPNyLrCrx0ds+B+ymiwX6maJaR+1j+qSU9xbdXNyf vqw0p0AAeVC0I1VYMc+XB9iQZMXwYFTW35O8p5eOwzIoaXvSNhrAKLyCDhn6vEvXPYz2 DIuriUKap3TUPUg/74POVZdcTFNcFyYxy5cRhNEHGiPN46jrp+vvfOTlBB0nWSb+2fML na/ONkrT25ZiTl9fmxWC6YpPQTctQR09o6l31XKLMEv+MO2FcQv/Ky1z3cvCRcb9ZKsf Wysw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=Z4ri5buR9leOmKtc/SizxHp/Qqck3G6nDT+LH9uTOi8=; b=BEb8Ghq8AOr7xxAWLzqrPwgZ3UEO5r52xBBOpL5jIQJHRM9i3bOlXSqW4FHh47cBMX 8zSlttXyblXApjDE1zBkW+pcKoxmEnn+WpacmNPAJTmbilfOdCEyQ0edYbCJS5ZhHwRF 9PSAbwhQcN5u1QMvMhNwOzRiDChL8joqO52hOyTi58QKDNR+XZwcqeZD+YID/q+xSjJF hiq0D0mjt9zyBzGWvU7nOH+MewKYrDhogKIYXlkzjCniIDSjiPMTlbRGnm5gE4KCr9pd 2AI/FtyRgZDGRm2Jp1VJGsLWOafEdj+b2ozwzb68uVgN1WFoND/Nodsfg8IodX2RrkA+ RWlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id a17si13559740wme.111.2020.05.14.06.30.25; Thu, 14 May 2020 06:30:25 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E3E561D718; Thu, 14 May 2020 15:28:26 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id B3DDA1D948 for ; Thu, 14 May 2020 15:28:08 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 97FA11A1550; Thu, 14 May 2020 15:28:08 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 71A3A1A15EB; Thu, 14 May 2020 15:28:06 +0200 (CEST) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 53C84402E0; Thu, 14 May 2020 21:28:03 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org, david.marchand@redhat.com, mdr@ashroe.eu Cc: Hemant Agrawal Date: Thu, 14 May 2020 18:55:32 +0530 Message-Id: <20200514132533.13752-13-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200514132533.13752-1-hemant.agrawal@nxp.com> References: <20200513132745.9006-1-hemant.agrawal@nxp.com> <20200514132533.13752-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v4 12/13] bus/fslmc: share mcp ptr as function across libs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Currently rte_mcp_ptr_list is being shared as a variable across libs. This is only used in control path. This patch change it to a exported function based access. Signed-off-by: Hemant Agrawal --- drivers/bus/fslmc/fslmc_vfio.c | 15 ++++++++++++--- drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c | 2 +- drivers/bus/fslmc/portal/dpaa2_hw_dpci.c | 2 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 2 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 7 ++++--- drivers/bus/fslmc/rte_bus_fslmc_version.map | 2 +- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 2 +- drivers/event/dpaa2/dpaa2_hw_dpcon.c | 2 +- drivers/net/dpaa2/dpaa2_ethdev.c | 2 +- drivers/net/dpaa2/dpaa2_mux.c | 2 +- drivers/net/dpaa2/dpaa2_ptp.c | 2 +- drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 2 +- 12 files changed, 26 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 970969d2bf..efe2c43d37 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -51,6 +51,15 @@ static int fslmc_iommu_type; static uint32_t *msi_intr_vaddr; void *(*rte_mcp_ptr_list); +void * +dpaa2_get_mcp_ptr(int portal_idx) +{ + if (rte_mcp_ptr_list) + return rte_mcp_ptr_list[portal_idx]; + else + return NULL; +} + static struct rte_dpaa2_object_list dpaa2_obj_list = TAILQ_HEAD_INITIALIZER(dpaa2_obj_list); @@ -734,7 +743,7 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev) struct fsl_mc_io dpmng = {0}; struct mc_version mc_ver_info = {0}; - rte_mcp_ptr_list = malloc(sizeof(void *) * 1); + rte_mcp_ptr_list = malloc(sizeof(void *) * (MC_PORTAL_INDEX + 1)); if (!rte_mcp_ptr_list) { DPAA2_BUS_ERR("Unable to allocate MC portal memory"); ret = -ENOMEM; @@ -762,7 +771,7 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev) * required. */ if (rte_eal_process_type() == RTE_PROC_SECONDARY) { - rte_mcp_ptr_list[0] = (void *)v_addr; + rte_mcp_ptr_list[MC_PORTAL_INDEX] = (void *)v_addr; return 0; } @@ -782,7 +791,7 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev) ret = -1; goto cleanup; } - rte_mcp_ptr_list[0] = (void *)v_addr; + rte_mcp_ptr_list[MC_PORTAL_INDEX] = (void *)v_addr; free(dev_name); return 0; diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c index db49d637f5..79b148f20b 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c @@ -56,7 +56,7 @@ dpaa2_create_dpbp_device(int vdev_fd __rte_unused, } /* Open the dpbp object */ - dpbp_node->dpbp.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX]; + dpbp_node->dpbp.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX); ret = dpbp_open(&dpbp_node->dpbp, CMD_PRI_LOW, dpbp_id, &dpbp_node->token); if (ret) { diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c index 5ad0374df9..d393ce6186 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c @@ -50,7 +50,7 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused, } /* Open the dpci object */ - dpci_node->dpci.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX]; + dpci_node->dpci.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX); ret = dpci_open(&dpci_node->dpci, CMD_PRI_LOW, dpci_id, &dpci_node->token); if (ret) { diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c index 739ce434ba..21c535f2fb 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c @@ -416,7 +416,7 @@ dpaa2_create_dpio_device(int vdev_fd, dpio_dev->hw_id = object_id; rte_atomic16_init(&dpio_dev->ref_count); /* Using single portal for all devices */ - dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX]; + dpio_dev->mc_portal = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX); if (!check_lcore_cpuset) { check_lcore_cpuset = 1; diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h index 33b191f823..194b99c583 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h @@ -198,9 +198,6 @@ struct dpaa2_dpcon_dev { uint8_t channel_index; }; -/*! Global MCP list */ -extern void *(*rte_mcp_ptr_list); - /* Refer to Table 7-3 in SEC BG */ struct qbman_fle { uint32_t addr_lo; @@ -441,4 +438,8 @@ struct dpaa2_dpci_dev *rte_dpaa2_alloc_dpci_dev(void); __rte_internal void rte_dpaa2_free_dpci_dev(struct dpaa2_dpci_dev *dpci); +/* Global MCP pointer */ +__rte_internal +void *dpaa2_get_mcp_ptr(int portal_idx); + #endif diff --git a/drivers/bus/fslmc/rte_bus_fslmc_version.map b/drivers/bus/fslmc/rte_bus_fslmc_version.map index 04e61156c3..53e3ce6f99 100644 --- a/drivers/bus/fslmc/rte_bus_fslmc_version.map +++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map @@ -11,6 +11,7 @@ INTERNAL { dpaa2_free_dpbp_dev; dpaa2_free_dq_storage; dpaa2_free_eq_descriptors; + dpaa2_get_mcp_ptr; dpaa2_io_portal; dpaa2_svr_family; dpaa2_virt_mode; @@ -101,7 +102,6 @@ INTERNAL { rte_fslmc_get_device_count; rte_fslmc_object_register; rte_global_active_dqs_list; - rte_mcp_ptr_list; local: *; }; diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index fe34e644cc..5d63644934 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -3788,7 +3788,7 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev) "Error in allocating the memory for dpsec object"); return -ENOMEM; } - dpseci->regs = rte_mcp_ptr_list[0]; + dpseci->regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX); retcode = dpseci_open(dpseci, CMD_PRI_LOW, hw_id, &token); if (retcode != 0) { diff --git a/drivers/event/dpaa2/dpaa2_hw_dpcon.c b/drivers/event/dpaa2/dpaa2_hw_dpcon.c index d64e588aa8..200b71640b 100644 --- a/drivers/event/dpaa2/dpaa2_hw_dpcon.c +++ b/drivers/event/dpaa2/dpaa2_hw_dpcon.c @@ -48,7 +48,7 @@ rte_dpaa2_create_dpcon_device(int dev_fd __rte_unused, } /* Open the dpcon object */ - dpcon_node->dpcon.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX]; + dpcon_node->dpcon.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX); ret = dpcon_open(&dpcon_node->dpcon, CMD_PRI_LOW, dpcon_id, &dpcon_node->token); if (ret) { diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 1bab3b064c..2f031ec5c1 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -2343,7 +2343,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) DPAA2_PMD_ERR("Memory allocation failed for dpni device"); return -1; } - dpni_dev->regs = rte_mcp_ptr_list[0]; + dpni_dev->regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX); eth_dev->process_private = (void *)dpni_dev; /* For secondary processes, the primary has done all the work */ diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c index 9ac8806faf..f8366e839e 100644 --- a/drivers/net/dpaa2/dpaa2_mux.c +++ b/drivers/net/dpaa2/dpaa2_mux.c @@ -224,7 +224,7 @@ dpaa2_create_dpdmux_device(int vdev_fd __rte_unused, } /* Open the dpdmux object */ - dpdmux_dev->dpdmux.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX]; + dpdmux_dev->dpdmux.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX); ret = dpdmux_open(&dpdmux_dev->dpdmux, CMD_PRI_LOW, dpdmux_id, &dpdmux_dev->token); if (ret) { diff --git a/drivers/net/dpaa2/dpaa2_ptp.c b/drivers/net/dpaa2/dpaa2_ptp.c index 316912fe3e..f58eedb314 100644 --- a/drivers/net/dpaa2/dpaa2_ptp.c +++ b/drivers/net/dpaa2/dpaa2_ptp.c @@ -147,7 +147,7 @@ dpaa2_create_dprtc_device(int vdev_fd __rte_unused, } /* Open the dprtc object */ - dprtc_dev->dprtc.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX]; + dprtc_dev->dprtc.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX); ret = dprtc_open(&dprtc_dev->dprtc, CMD_PRI_LOW, dprtc_id, &dprtc_dev->token); if (ret) { diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c index d5202d6522..1be1b6ddf0 100644 --- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c +++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c @@ -1315,7 +1315,7 @@ dpaa2_dpdmai_dev_init(struct rte_rawdev *rawdev, int dpdmai_id) /* Open DPDMAI device */ dpdmai_dev->dpdmai_id = dpdmai_id; - dpdmai_dev->dpdmai.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX]; + dpdmai_dev->dpdmai.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX); ret = dpdmai_open(&dpdmai_dev->dpdmai, CMD_PRI_LOW, dpdmai_dev->dpdmai_id, &dpdmai_dev->token); if (ret) {