From patchwork Tue Jun 25 10:40:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 167690 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp4826205ock; Tue, 25 Jun 2019 03:42:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUQ3b4OC/VlxRbtaImT861uG3VF5oO1gvx8fvTtpxaowgk3VcTW+yoOHPRg7l81OsD/F7O X-Received: by 2002:a50:b104:: with SMTP id k4mr142955790edd.75.1561459327089; Tue, 25 Jun 2019 03:42:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561459327; cv=none; d=google.com; s=arc-20160816; b=gAyc/H93SNwH9XrugeX/DOA284NWLihfej7m/W167Tx6wEBzCExs1xG32nl5zJjPa/ qPxs2lhS2YrflUkJuEWCKELT52vYenSIqFZf9T6wyJqj914tK4/CEnf1iUh8NUgqOqbZ tiS8CTGeAWhRwNtF0gqJZhmKo0JPHCuXA4UsroMr29hvtfhM2UbIAYMFLe565iYddPUt 5nG2OQcjHJDUxx0BSkmzFIcvg5aKWH8Zw7Vp64XKIB7LiGIiM6FezovpdqLoZBLC6Yqk PmXUUtejE39mbme1ZYMONrhdVv0yRqAE0WZaGxY7M6wx24XaYvGAXAYi2sdPqW8m2ULy rtXQ== 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:message-id:date:cc:to :from; bh=g13SpSJlW9eB+73659jHmRGIFY9CzjcaYbQbFumTf4Q=; b=CtPE57GPgqpYis53pKvqBqN9knCFv4fyc2KBkfLaHoCYHwH9c1gds/M4uN6wli4y5Z Jow9WgOh8dwEfxVacQXVRhXOFkZ1FwP2rVyuI4MLQQk3dv2fn7s8o75N4himPjE1t0EO FYAmFVOiKgLTwJrkgx6R6/gCg4tQTvjXoqvTL0C712e9P+WuP2mequokRWPCDiYDvSOm ZzcH9PlcjdPGcVitp50KOvD5tgeBLjSjnOUudL2tQRfZzhU8tahdTEVTJcnZ4zXEV+CM 2qimLgHqlNJgKGnO2sm7lfh+GuWuHxBeffrUWReTkptOenru9HpKGfYLOMc6FSUdYgzK ZKyQ== 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 x22si64095eju.379.2019.06.25.03.42.06; Tue, 25 Jun 2019 03:42:07 -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 3740F1B99B; Tue, 25 Jun 2019 12:42:05 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 249794F94 for ; Tue, 25 Jun 2019 12:42:04 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id A66311A07AE; Tue, 25 Jun 2019 12:42:03 +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 C0BB31A07B3; Tue, 25 Jun 2019 12:42:01 +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 470934028F; Tue, 25 Jun 2019 18:41:59 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 25 Jun 2019 16:10:17 +0530 Message-Id: <20190625104019.19287-1-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 1/3] bus/dpaa: add plug support and rework parse 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" From: Shreyansh Jain Parse and find_device have specific function - former is for parsing a string passed as argument, whereas the later is for iterating over all the devices in the bus and calling a callback/handler. They have been corrected with their right operations to support hotplugging/devargs plug/unplug calls. Support for plug/unplug too has been added. Signed-off-by: Shreyansh Jain Acked-by: Hemant Agrawal --- drivers/bus/dpaa/dpaa_bus.c | 126 ++++++++++++++++++++++++++------ drivers/bus/dpaa/rte_dpaa_bus.h | 3 + 2 files changed, 108 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index 08c822781..c2563cc26 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause * - * Copyright 2017 NXP + * Copyright 2017-2019 NXP * */ /* System headers */ @@ -389,19 +389,28 @@ rte_dpaa_bus_parse(const char *name, void *out_name) { int i, j; int max_fman = 2, max_macs = 16; - char *sep = strchr(name, ':'); + char *dup_name; + char *sep = NULL; - if (strncmp(name, RTE_STR(FSL_DPAA_BUS_NAME), - strlen(RTE_STR(FSL_DPAA_BUS_NAME)))) { - return -EINVAL; - } - - if (!sep) { - DPAA_BUS_ERR("Incorrect device name observed"); - return -EINVAL; - } - - sep = (char *) (sep + 1); + /* There are two ways of passing device name, with and without + * separator. "dpaa_bus:fm1-mac3" with separator, and "fm1-mac3" + * without separator. Both need to be handled. + * It is also possible that "name=fm1-mac3" is passed along. + */ + DPAA_BUS_DEBUG("Parse device name (%s)\n", name); + + /* Check for dpaa_bus:fm1-mac3 style */ + dup_name = strdup(name); + sep = strchr(dup_name, ':'); + if (!sep) + /* If not, check for name=fm1-mac3 style */ + sep = strchr(dup_name, '='); + + if (sep) + /* jump over the seprator */ + sep = (char *) (sep + 1); + else + sep = dup_name; for (i = 0; i < max_fman; i++) { for (j = 0; j < max_macs; j++) { @@ -410,6 +419,7 @@ rte_dpaa_bus_parse(const char *name, void *out_name) if (strcmp(fm_name, sep) == 0) { if (out_name) strcpy(out_name, sep); + free(dup_name); return 0; } } @@ -422,10 +432,12 @@ rte_dpaa_bus_parse(const char *name, void *out_name) if (strcmp(sec_name, sep) == 0) { if (out_name) strcpy(out_name, sep); + free(dup_name); return 0; } } + free(dup_name); return -EINVAL; } @@ -444,7 +456,10 @@ rte_dpaa_bus_scan(void) RTE_LOG(DEBUG, EAL, "DPAA Bus not present. Skipping.\n"); return 0; } - /* detected DPAA devices */ + + if (rte_dpaa_bus.detected) + return 0; + rte_dpaa_bus.detected = 1; /* create the key, supplying a function that'll be invoked @@ -553,12 +568,16 @@ rte_dpaa_bus_probe(void) FILE *svr_file = NULL; unsigned int svr_ver; int probe_all = rte_dpaa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST; + static int process_once; /* If DPAA bus is not present nothing needs to be done */ if (!rte_dpaa_bus.detected) return 0; - rte_dpaa_bus_dev_build(); + /* Device list creation is only done once */ + if (!process_once) + rte_dpaa_bus_dev_build(); + process_once = 1; /* If no device present on DPAA bus nothing needs to be done */ if (TAILQ_EMPTY(&rte_dpaa_bus.device_list)) @@ -618,17 +637,28 @@ rte_dpaa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, const void *data) { struct rte_dpaa_device *dev; + const struct rte_dpaa_device *dstart; - TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) { - if (start && &dev->device == start) { - start = NULL; /* starting point found */ - continue; - } + /* find_device is called with 'data' as an opaque object - just call + * cmp with this and each device object on bus. + */ + + if (start != NULL) { + dstart = RTE_DEV_TO_DPAA_CONST(start); + dev = TAILQ_NEXT(dstart, next); + } else { + dev = TAILQ_FIRST(&rte_dpaa_bus.device_list); + } - if (cmp(&dev->device, data) == 0) + while (dev != NULL) { + if (cmp(&dev->device, data) == 0) { + DPAA_BUS_DEBUG("Found dev=(%s)\n", dev->device.name); return &dev->device; + } + dev = TAILQ_NEXT(dev, next); } + DPAA_BUS_DEBUG("Unable to find any device\n"); return NULL; } @@ -645,6 +675,57 @@ rte_dpaa_get_iommu_class(void) return RTE_IOVA_PA; } +static int +dpaa_bus_plug(struct rte_device *dev __rte_unused) +{ + /* No operation is performed while plugging the device */ + return 0; +} + +static int +dpaa_bus_unplug(struct rte_device *dev __rte_unused) +{ + /* No operation is performed while unplugging the device */ + return 0; +} + +static void * +dpaa_bus_dev_iterate(const void *start, const char *str, + const struct rte_dev_iterator *it __rte_unused) +{ + const struct rte_dpaa_device *dstart; + struct rte_dpaa_device *dev; + char *dup, *dev_name = NULL; + + /* Expectation is that device would be name=device_name */ + if (strncmp(str, "name=", 5) != 0) { + DPAA_BUS_ERR("Invalid device string (%s)\n", str); + return NULL; + } + + /* Now that name=device_name format is available, split */ + dup = strdup(str); + dev_name = dup + strlen("name="); + + if (start != NULL) { + dstart = RTE_DEV_TO_DPAA_CONST(start); + dev = TAILQ_NEXT(dstart, next); + } else { + dev = TAILQ_FIRST(&rte_dpaa_bus.device_list); + } + + while (dev != NULL) { + if (strcmp(dev->device.name, dev_name) == 0) { + free(dup); + return &dev->device; + } + dev = TAILQ_NEXT(dev, next); + } + + free(dup); + return NULL; +} + static struct rte_dpaa_bus rte_dpaa_bus = { .bus = { .scan = rte_dpaa_bus_scan, @@ -652,6 +733,9 @@ static struct rte_dpaa_bus rte_dpaa_bus = { .parse = rte_dpaa_bus_parse, .find_device = rte_dpaa_find_device, .get_iommu_class = rte_dpaa_get_iommu_class, + .plug = dpaa_bus_plug, + .unplug = dpaa_bus_unplug, + .dev_iterate = dpaa_bus_dev_iterate, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.driver_list), diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index 72fbbfce7..554a56f2e 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -30,6 +30,9 @@ #define SVR_LS1046A_FAMILY 0x87070000 #define SVR_MASK 0xffff0000 +#define RTE_DEV_TO_DPAA_CONST(ptr) \ + container_of(ptr, const struct rte_dpaa_device, device) + extern unsigned int dpaa_svr_family; extern RTE_DEFINE_PER_LCORE(bool, dpaa_io); From patchwork Tue Jun 25 10:40:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 167691 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp4826349ock; Tue, 25 Jun 2019 03:42:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyn+80dQOXyAowpv0lx+FlmhfXJwSJDsYf7G2zo48tQc6lSImILmQ06i1bhEUIYGDHRaF/R X-Received: by 2002:a17:906:1845:: with SMTP id w5mr24472753eje.0.1561459336293; Tue, 25 Jun 2019 03:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561459336; cv=none; d=google.com; s=arc-20160816; b=k1wo59fA8VpVTXQOzC0Fh7I6PHRIk0YrqLn/c70o2sDxvqAdFoxiaOOgV6QT2Vk4hD jr3ezU/JumNqbOdXVvy4CASIcU30pnV7IS0KfRoX9lOPMaUbEpXnkQWGE5uw4Ta66emt M5VDiEDR83b3QZrVwdI0Oz/8Hno09+GJ24Zj6CHVw67r92P2HJz6V4F5fn3oqu6Otzq9 tZDAD0LCVfMCmySepS/JOZeVb9yY7V6WPu+vfQemfQpxQOwZ8+qttCWi/roRI48rRsUP lRar1olNypa8t9iSxvhIkvOXrx835041UNJLo7wtUlavJZpdeRo01qdR2Y8EHNMnsQGo zJIQ== 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=IklopaFvHg1obhiyPT/eGnhQL8EFWCJA+Nbe/k7ALsQ=; b=Y4aHPRcch6RqakGCvlesIjRoPbgh7LtAfaTdiJCBbQ/+Mfb2y3ULtoTYIM49qsZlCZ nlqmHmwApTGeg5c19hMiyi1NKad3GG2XFK/y1foJhpZPU759m7Red6ElALv2dHbgyp6F FRGGVVBu6mhECvZcmcgahci2Uhldyv8mnFIgCaj8gVHoo8oaZ6oKLHvmlPoHr5xPPqz/ l2qquhGLtXqptNxH5H6Zn5lH2lIJAg2N+rt8nzNi/7omeggWv/H8ShAlVCkCY+gu5syQ Q/vSo+g5kbD1yoHpathLMfW5O3C3RvPDjYkfgU3VOVE26dE0Aash/dQUtV9pJ7JCnZ/0 yosA== 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 z5si101847edp.114.2019.06.25.03.42.16; Tue, 25 Jun 2019 03:42:16 -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 9882B1B9E6; Tue, 25 Jun 2019 12:42:09 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 59BA8559A for ; Tue, 25 Jun 2019 12:42:04 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E38F11A07AF; Tue, 25 Jun 2019 12:42:03 +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 477A01A07B6; Tue, 25 Jun 2019 12:42:02 +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 C235E402FB; Tue, 25 Jun 2019 18:41:59 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 25 Jun 2019 16:10:18 +0530 Message-Id: <20190625104019.19287-2-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625104019.19287-1-hemant.agrawal@nxp.com> References: <20190625104019.19287-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 2/3] bus/dpaa: update dpaa mempool for secondary process 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" 1. need to use the bpool with rte_malloc instead of rte_free 2. Option to give portal to the seondary process thread. Signed-off-by: Radu Bulie Signed-off-by: Hemant Agrawal Tested-by: Akhil Goyal --- drivers/bus/dpaa/include/compat.h | 10 ++++++---- drivers/mempool/dpaa/dpaa_mempool.c | 11 ++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/bus/dpaa/include/compat.h b/drivers/bus/dpaa/include/compat.h index 86cecf67b..277ce6369 100644 --- a/drivers/bus/dpaa/include/compat.h +++ b/drivers/bus/dpaa/include/compat.h @@ -2,6 +2,7 @@ * * Copyright 2011 Freescale Semiconductor, Inc. * All rights reserved. + * Copyright 2019 NXP * */ @@ -40,6 +41,7 @@ #include #include #include +#include /* The following definitions are primarily to allow the single-source driver * interfaces to be included by arbitrary program code. Ie. for interfaces that @@ -339,12 +341,12 @@ static inline void copy_bytes(void *dest, const void *src, size_t sz) #endif /* Allocator stuff */ -#define kmalloc(sz, t) malloc(sz) -#define vmalloc(sz) malloc(sz) -#define kfree(p) { if (p) free(p); } +#define kmalloc(sz, t) rte_malloc(NULL, sz, 0) +#define vmalloc(sz) rte_malloc(NULL, sz, 0) +#define kfree(p) { if (p) rte_free(p); } static inline void *kzalloc(size_t sz, gfp_t __foo __rte_unused) { - void *ptr = malloc(sz); + void *ptr = rte_malloc(NULL, sz, 0); if (ptr) memset(ptr, 0, sz); diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c index 003081772..3551e6d10 100644 --- a/drivers/mempool/dpaa/dpaa_mempool.c +++ b/drivers/mempool/dpaa/dpaa_mempool.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause * - * Copyright 2017 NXP + * Copyright 2017,2019 NXP * */ @@ -51,6 +51,15 @@ dpaa_mbuf_create_pool(struct rte_mempool *mp) MEMPOOL_INIT_FUNC_TRACE(); + if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + ret = rte_dpaa_portal_init((void *)0); + if (ret) { + DPAA_MEMPOOL_ERR( + "rte_dpaa_portal_init failed with ret: %d", + ret); + return -1; + } + } bp = bman_new_pool(¶ms); if (!bp) { DPAA_MEMPOOL_ERR("bman_new_pool() failed"); From patchwork Tue Jun 25 10:40:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 167692 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp4826426ock; Tue, 25 Jun 2019 03:42:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0M2bppiVr2fdIuiVbDxnw5dqvR17iDytBzdWuvy3m6R0GZlDlxc79W7XuWOaDpzOKe5x3 X-Received: by 2002:a17:906:d7aa:: with SMTP id pk10mr72985656ejb.125.1561459343114; Tue, 25 Jun 2019 03:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561459343; cv=none; d=google.com; s=arc-20160816; b=lxKb7R+9F3NTL5wXeatPR5vpruTx6gVoOIyF1wodqPo3JQQUlbodSheD3bnzZpn9fk KpyPTCb+MFWEsuRPyMc9B3OAGq1a7im6fEZ+S3YKArDIv9uRUPL02RXxU9jYVkqiDg9w kOU6mFSPmUx4jgHXY9TX7KOedgpxTTekfBPENC5wS/cXg+jNo1BhcJCHo0jqB1c7AY7l DKauqYrij79XV9RBVwKP19pD7QnKscO+hIdzI0RomTVjMPIYzvK4LXhF5Oro02jFkDaV FXpLLpVHNhqV710UWZtBgc/X72nzSIzVErL9hq50bcCG34nIQrQXIgmMupHmDnfnVc9O hdqQ== 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=kMRsb63rJ8O15r8XrUHXxLEMIkx5FTTtoe7iRHm0VnE=; b=ARN7Up2xucJqw1h+lwFlDC3AiCDyYId99HQo3I09hrnjVXCVRmY8tU+gAk81sS6DzI n8hGpuYp1Sj6hD2sD7v+IOYNH0w8bo6Lu1aqbUsUrdQ+D1qDQRnyKD8/XHZcPCbKmQ3p sscS9Qj1f2XVh+bJJFDhsOIKegKwBRuhjT4b75DZVdx/YZ61FPgssuw1i1/UrXk/Roix FU/4bmUDBCSgoNcMrnz4kCECdTSy3HF3WIY4kzHch1PgCmucpOgOieE7B0EhiaoC0vDa r+q1RurIs9qzZfR8+l1lC+dCFCbCz49OUJRzm9Se1C9KbQSdcGpppsY94i4VkfT/sVCW jOZw== 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 d31si100793ede.441.2019.06.25.03.42.22; Tue, 25 Jun 2019 03:42:23 -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 008D61B9FC; Tue, 25 Jun 2019 12:42:14 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 31D29559A for ; Tue, 25 Jun 2019 12:42:05 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A2479200ED5; Tue, 25 Jun 2019 12:42:04 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id C26ED200EF5; Tue, 25 Jun 2019 12:42:02 +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 48D4D4030C; Tue, 25 Jun 2019 18:42:00 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 25 Jun 2019 16:10:19 +0530 Message-Id: <20190625104019.19287-3-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625104019.19287-1-hemant.agrawal@nxp.com> References: <20190625104019.19287-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 3/3] net/dpaa: support interface init for multi process 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" From: Akhil Goyal The existing code is enabling the Tx queues as per the number of lcore count, which is causing issue in case of secondary process running on different number of cores. This patch fixes the Tx queues to number of DPAA cores, which helps in using fixed number of Tx queues across processes access. Signed-off-by: Akhil Goyal Acked-by: Hemant Agrawal --- drivers/net/dpaa/dpaa_ethdev.c | 44 ++++++++++++++++++++-------------- drivers/net/dpaa/dpaa_ethdev.h | 1 + 2 files changed, 27 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 4b0027929..adc0bd5ac 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1214,7 +1214,7 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid) static int dpaa_dev_init(struct rte_eth_dev *eth_dev) { - int num_cores, num_rx_fqs, fqid; + int num_rx_fqs, fqid; int loop, ret = 0; int dev_id; struct rte_dpaa_device *dpaa_device; @@ -1319,23 +1319,22 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) dpaa_intf->nb_rx_queues = num_rx_fqs; /* Initialise Tx FQs.free_rx Have as many Tx FQ's as number of cores */ - num_cores = rte_lcore_count(); dpaa_intf->tx_queues = rte_zmalloc(NULL, sizeof(struct qman_fq) * - num_cores, MAX_CACHELINE); + MAX_DPAA_CORES, MAX_CACHELINE); if (!dpaa_intf->tx_queues) { DPAA_PMD_ERR("Failed to alloc mem for TX queues\n"); ret = -ENOMEM; goto free_rx; } - for (loop = 0; loop < num_cores; loop++) { + for (loop = 0; loop < MAX_DPAA_CORES; loop++) { ret = dpaa_tx_queue_init(&dpaa_intf->tx_queues[loop], fman_intf); if (ret) goto free_tx; dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf; } - dpaa_intf->nb_tx_queues = num_cores; + dpaa_intf->nb_tx_queues = MAX_DPAA_CORES; #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER dpaa_debug_queue_init(&dpaa_intf->debug_queues[ @@ -1484,7 +1483,7 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused, return 0; } - if (!is_global_init) { + if (!is_global_init && (rte_eal_process_type() == RTE_PROC_PRIMARY)) { /* One time load of Qman/Bman drivers */ ret = qman_global_init(); if (ret) { @@ -1530,20 +1529,29 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused, } } - eth_dev = rte_eth_dev_allocate(dpaa_dev->name); - if (eth_dev == NULL) - return -ENOMEM; + /* In case of secondary process, the device is already configured + * and no further action is required, except portal initialization + * and verifying secondary attachment to port name. + */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + eth_dev = rte_eth_dev_attach_secondary(dpaa_dev->name); + if (!eth_dev) + return -ENOMEM; + } else { + eth_dev = rte_eth_dev_allocate(dpaa_dev->name); + if (eth_dev == NULL) + return -ENOMEM; - eth_dev->data->dev_private = rte_zmalloc( - "ethdev private structure", - sizeof(struct dpaa_if), - RTE_CACHE_LINE_SIZE); - if (!eth_dev->data->dev_private) { - DPAA_PMD_ERR("Cannot allocate memzone for port data"); - rte_eth_dev_release_port(eth_dev); - return -ENOMEM; + eth_dev->data->dev_private = rte_zmalloc( + "ethdev private structure", + sizeof(struct dpaa_if), + RTE_CACHE_LINE_SIZE); + if (!eth_dev->data->dev_private) { + DPAA_PMD_ERR("Cannot allocate memzone for port data"); + rte_eth_dev_release_port(eth_dev); + return -ENOMEM; + } } - eth_dev->device = &dpaa_dev->device; dpaa_dev->eth_dev = eth_dev; diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h index e906a0bec..18bc7dfa8 100644 --- a/drivers/net/dpaa/dpaa_ethdev.h +++ b/drivers/net/dpaa/dpaa_ethdev.h @@ -18,6 +18,7 @@ #include #include +#define MAX_DPAA_CORES 4 #define DPAA_MBUF_HW_ANNOTATION 64 #define DPAA_FD_PTA_SIZE 64