From patchwork Tue Mar 26 12:01:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 161208 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp5124134jan; Tue, 26 Mar 2019 05:02:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVbUVhLUbi/D5F9G/9XJj74RSBeL3bZvNqRdKwaSUGjiVxIGT9MD2pL8B204LeBfXfmo/G X-Received: by 2002:a17:906:7857:: with SMTP id p23mr17303590ejm.55.1553601726375; Tue, 26 Mar 2019 05:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553601726; cv=none; d=google.com; s=arc-20160816; b=jt27dDmAtIsf1PMl2IrhvTfka4cSIIWGN1b5wxcohlBQ5MPax7jN8zXBw/6Y3RNGfY lGgPjc6p6kqvLR1sZkjAPWT11rISmKHdbELjO2TCaWXXNUDWRoo/Kk9BATFeIOGXANsq lPd55w0v3rbaxwk7mmqx4Nv9skBTO4UVsEXQJcqKHguy9lzcZKUHqJWz/0ApGXBGyEsb 6KQoUpIfABdSYJ4mjloxVuVkIsfscC+9vf5Rf3L9sjPoVrThk9S5ZjS+ulXNJwTQeo0N 1BY7w2bGpTYTzrmFFlyR+NX6Idz0MdQfireg3MuG16YoNQk1aGY+9Kxe0eK8SqJfoW+D d2cA== 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:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic:cc :to:from:dkim-signature; bh=XMq2OyDW0RvoLmGAarAT/F7TA04WlwjYpjxrRvCZuS0=; b=YXVLeZ7lPbZnvggvLgnk+Qo3/kqeNQOVftv56tDcqcXia2z22f3UBWWgVktEnqjs1L bUX4psI8tV7mrlOXV7Pc7mCZQlLCQWb26Q51cz0m48tvPD1qfdtqT6Hsk18bD1HQQbzA UqE2uptpQRcZq47AmlEU49m/pQlhzuHMFS0MmCGYEEl1O2SxV8/2Qvx1uW5ooRgJIJH+ c6FVAYD+ab3E0PL8wAZq7wwgdRPvKmqCy3uebTr0KVyRsInHg5qIDCjfuPXrIFc45UIR 2vCSoIDkP/Qcd50940M4KTAKGpXir+SiW/EMvYJ0MZDSWUQ+wPRGI7p0WdlDYJbNLUL2 16vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nxp.com header.s=selector1 header.b="yAo/JhG+"; 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 q12si2324242edd.11.2019.03.26.05.02.06; Tue, 26 Mar 2019 05:02:06 -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; dkim=fail header.i=@nxp.com header.s=selector1 header.b="yAo/JhG+"; 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 9FBD349E0; Tue, 26 Mar 2019 13:01:53 +0100 (CET) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20059.outbound.protection.outlook.com [40.107.2.59]) by dpdk.org (Postfix) with ESMTP id 2CCB1324D for ; Tue, 26 Mar 2019 13:01:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XMq2OyDW0RvoLmGAarAT/F7TA04WlwjYpjxrRvCZuS0=; b=yAo/JhG+xiiPGzGRHOdo5B8oR7e4xqqJzcWqn6vRy3RppirqyEl0rvJDXplJl++mJ0T7DUQowlGciiTK/R+xTq/olkiBi5ixnFALnbwGVAnMRWuy6T/yHzp+05qlxReeJDx+70yi/rfSo+1E/3tUtfy9D3seavHKKPId8uv36Dw= Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com (10.168.65.19) by VI1PR0401MB2366.eurprd04.prod.outlook.com (10.169.134.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.18; Tue, 26 Mar 2019 12:01:47 +0000 Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::18e3:39b6:c61d:3f18]) by VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::18e3:39b6:c61d:3f18%12]) with mapi id 15.20.1730.019; Tue, 26 Mar 2019 12:01:47 +0000 From: Hemant Agrawal To: "dev@dpdk.org" CC: "ferruh.yigit@intel.com" , Shreyansh Jain Thread-Topic: [PATCH 3/4] bus/dpaa: delay fman device list to bus probe Thread-Index: AQHU48uvL9QkZNq0Ykqkn9/jDazJrw== Date: Tue, 26 Mar 2019 12:01:46 +0000 Message-ID: <20190326115952.26278-3-hemant.agrawal@nxp.com> References: <20190326115952.26278-1-hemant.agrawal@nxp.com> In-Reply-To: <20190326115952.26278-1-hemant.agrawal@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [92.120.1.72] x-mailer: git-send-email 2.17.1 x-clientproxiedby: BM1PR01CA0157.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:68::27) To VI1PR0401MB2541.eurprd04.prod.outlook.com (2603:10a6:800:56::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=hemant.agrawal@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3a6df033-c453-4028-420c-08d6b1e2d232 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR0401MB2366; x-ms-traffictypediagnostic: VI1PR0401MB2366: x-microsoft-antispam-prvs: x-forefront-prvs: 09888BC01D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(366004)(136003)(346002)(39860400002)(376002)(199004)(189003)(71190400001)(86362001)(256004)(44832011)(6916009)(26005)(5660300002)(81156014)(2351001)(2501003)(1076003)(66066001)(2906002)(6116002)(3846002)(14454004)(486006)(6506007)(1730700003)(71200400001)(316002)(14444005)(105586002)(478600001)(97736004)(8676002)(186003)(6512007)(7736002)(106356001)(8936002)(52116002)(81166006)(25786009)(50226002)(99286004)(6436002)(5640700003)(11346002)(446003)(2616005)(305945005)(68736007)(386003)(4326008)(102836004)(476003)(36756003)(76176011)(6486002)(54906003)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2366; H:VI1PR0401MB2541.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: sDecqblEzfo15QvknpcHOVEpmYwD6+lu7Mme8YyF/+bUmXidgLkXGAjiMdKUne9DRFnExiHeKo98Ccpqs7K4pIK8bTPquhxjrDRXvBePdxKKF7/39pMX4A69sgnfgSLKK89wkhstAg3OZWqaeofHOWNai53Zy3z3J2kO54VIp+6MwxVLy6du/qfoOjD4PYoBIPCciTlEDy445WRVlkJKhnHGHKLZaDvFZZ+B7pUV6MiCHxRu17ewKINo2u5E89VmFkgC9FIEv+KdnsSqH7SWl5qrpQpjy1ot5gaSQ9fgS/dsg2njA8rKRwUWkXk53XmhxHomlRYpnVkOJPD6BJGQ8IHucrKCHziYKFl1VzcqlL8NOoEw+urxtpwGIfuGh7TgYlIdskJjmHw3ipZx4gC2YAF9M2t2STgsZVAI34LjnvE= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a6df033-c453-4028-420c-08d6b1e2d232 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Mar 2019 12:01:47.0151 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2366 Subject: [dpdk-dev] [PATCH 3/4] bus/dpaa: delay fman device list to bus probe 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" The fman device list need to be accessed across processes. The hw device structures should be allocated with rte_calloc instead of calloc. The rte_calloc is not available at the time of bus scan, so better prepare the device list at probe. Signed-off-by: Hemant Agrawal --- drivers/bus/dpaa/base/fman/fman.c | 11 +-- drivers/bus/dpaa/base/fman/netcfg_layer.c | 6 +- drivers/bus/dpaa/dpaa_bus.c | 83 +++++++++++++---------- drivers/bus/dpaa/rte_dpaa_bus.h | 1 + drivers/net/dpaa/dpaa_ethdev.c | 2 +- 5 files changed, 60 insertions(+), 43 deletions(-) -- 2.17.1 diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index 06762e0f4..8fa9b8cae 100644 --- a/drivers/bus/dpaa/base/fman/fman.c +++ b/drivers/bus/dpaa/base/fman/fman.c @@ -12,6 +12,7 @@ /* This header declares the driver interface we implement */ #include #include +#include #include #include @@ -177,7 +178,7 @@ fman_if_init(const struct device_node *dpa_node) mprop = "fsl,fman-mac"; /* Allocate an object for this network interface */ - __if = malloc(sizeof(*__if)); + __if = rte_malloc(NULL, sizeof(*__if), RTE_CACHE_LINE_SIZE); if (!__if) { FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*__if)); goto err; @@ -433,7 +434,7 @@ fman_if_init(const struct device_node *dpa_node) uint64_t bpool_host[6] = {0}; const char *pname; /* Allocate an object for the pool */ - bpool = malloc(sizeof(*bpool)); + bpool = rte_malloc(NULL, sizeof(*bpool), RTE_CACHE_LINE_SIZE); if (!bpool) { FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*bpool)); goto err; @@ -443,7 +444,7 @@ fman_if_init(const struct device_node *dpa_node) if (!pool_node) { FMAN_ERR(-ENXIO, "%s: bad fsl,bman-buffer-pools\n", dname); - free(bpool); + rte_free(bpool); goto err; } pname = pool_node->full_name; @@ -451,7 +452,7 @@ fman_if_init(const struct device_node *dpa_node) prop = of_get_property(pool_node, "fsl,bpid", &proplen); if (!prop) { FMAN_ERR(-EINVAL, "%s: no fsl,bpid\n", pname); - free(bpool); + rte_free(bpool); goto err; } assert(proplen == sizeof(*prop)); @@ -574,7 +575,7 @@ fman_finish(void) -errno, strerror(errno)); printf("Tearing down %s\n", __if->node_path); list_del(&__if->__if.node); - free(__if); + rte_free(__if); } close(fman_ccsr_map_fd); diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c index 6b5224203..bf8c77265 100644 --- a/drivers/bus/dpaa/base/fman/netcfg_layer.c +++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c @@ -114,7 +114,7 @@ netcfg_acquire(void) size = sizeof(*netcfg) + (num_ports * sizeof(struct fm_eth_port_cfg)); - netcfg = calloc(1, size); + netcfg = rte_calloc(NULL, 1, size, 0); if (unlikely(netcfg == NULL)) { DPAA_BUS_LOG(ERR, "Unable to allocat mem for netcfg"); goto error; @@ -141,7 +141,7 @@ netcfg_acquire(void) error: if (netcfg) { - free(netcfg); + rte_free(netcfg); netcfg = NULL; } @@ -151,7 +151,7 @@ netcfg_acquire(void) void netcfg_release(struct netcfg_info *cfg_ptr) { - free(cfg_ptr); + rte_free(cfg_ptr); /* Close socket for shared interfaces */ if (skfd >= 0) { close(skfd); diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index c7da96f8d..ac20eccd5 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -442,40 +442,8 @@ rte_dpaa_bus_scan(void) RTE_LOG(DEBUG, EAL, "DPAA Bus not present. Skipping.\n"); return 0; } - - /* Load the device-tree driver */ - ret = of_init(); - if (ret) { - DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret); - return -1; - } - - /* Get the interface configurations from device-tree */ - dpaa_netcfg = netcfg_acquire(); - if (!dpaa_netcfg) { - DPAA_BUS_LOG(ERR, "netcfg_acquire failed"); - return -EINVAL; - } - - RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n"); - - if (!dpaa_netcfg->num_ethports) { - DPAA_BUS_LOG(INFO, "no network interfaces available"); - /* This is not an error */ - return 0; - } - -#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER - dump_netcfg(dpaa_netcfg); -#endif - - DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d", - dpaa_netcfg->num_ethports); - ret = dpaa_create_device_list(); - if (ret) { - DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret); - return ret; - } + /* detected DPAA devices */ + rte_dpaa_bus.detected = 1; /* create the key, supplying a function that'll be invoked * when a portal affined thread will be deleted. @@ -533,6 +501,47 @@ rte_dpaa_device_match(struct rte_dpaa_driver *drv, return -1; } +static int +rte_dpaa_bus_dev_build(void) +{ + int ret; + + /* Load the device-tree driver */ + ret = of_init(); + if (ret) { + DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret); + return -1; + } + + /* Get the interface configurations from device-tree */ + dpaa_netcfg = netcfg_acquire(); + if (!dpaa_netcfg) { + DPAA_BUS_LOG(ERR, "netcfg_acquire failed"); + return -EINVAL; + } + + RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n"); + + if (!dpaa_netcfg->num_ethports) { + DPAA_BUS_LOG(INFO, "no network interfaces available"); + /* This is not an error */ + return 0; + } + +#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER + dump_netcfg(dpaa_netcfg); +#endif + + DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d", + dpaa_netcfg->num_ethports); + ret = dpaa_create_device_list(); + if (ret) { + DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret); + return ret; + } + return 0; +} + static int rte_dpaa_bus_probe(void) { @@ -544,6 +553,12 @@ rte_dpaa_bus_probe(void) int probe_all = rte_dpaa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST; /* If DPAA bus is not present nothing needs to be done */ + if (!rte_dpaa_bus.detected) + return 0; + + rte_dpaa_bus_dev_build(); + + /* If no device present on DPAA bus nothing needs to be done */ if (TAILQ_EMPTY(&rte_dpaa_bus.device_list)) return 0; diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index 1d580a000..72fbbfce7 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -54,6 +54,7 @@ struct rte_dpaa_bus { struct rte_dpaa_device_list device_list; struct rte_dpaa_driver_list driver_list; int device_count; + int detected; }; struct dpaa_device_id { diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index d124169c5..b1fac8fa7 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1354,7 +1354,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) /* reset bpool list, initialize bpool dynamically */ list_for_each_entry_safe(bp, tmp_bp, &cfg->fman_if->bpool_list, node) { list_del(&bp->node); - free(bp); + rte_free(bp); } /* Populate ethdev structure */