From patchwork Thu Jun 27 09:33:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 167891 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2091868ilk; Thu, 27 Jun 2019 02:35:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxgpfXNm1TPh7qyCgA2McKbfyUK/IBx0Y4DakZ6afdrfGUV+YA3QdTLunXrg8CR1KjsTNk X-Received: by 2002:a1c:2302:: with SMTP id j2mr2433840wmj.174.1561628140324; Thu, 27 Jun 2019 02:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561628140; cv=none; d=google.com; s=arc-20160816; b=elEPE2QtuY7WBNhM0ZjVBVOjFJkMMFWeh0T0B7a5LJ80McasOReP3/q4nlaOOXnnyS SDhW+DJoz2U9PBmYdkBCXFlVsNJ24SqaBbUgr1h7sb2QMjUKo9SXDf9F/DYZBn2jsKJw pG/F7DoO9i0HMjkvN0ntui9lQnLhLOtXG5dpA4q7iOfFqoIa+sRgMz4pcXEc0z1ZLHXN xrw3Zt7Bw3jWGyWvQyYTzDgBtc0jpdVtwsXvZD0CWG5Xn0P1zZ7RwstEzWGexpo2sGDh iqqhfju9Zfgfl1KVWlnTjg8nyX6H5gGmFGXOSBY1q8+18XtZ0CkfvpYlWDO8l8nIBJ8f NHUw== 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=G6NNsa/+EZcKOVbOp6oeWdN938v0Ejiv+cgGrc7gwtw=; b=fMsn32gAgpU2SYjVAg7mDlXGp9OwGfpjGC7pL7zudtn6Ldf9YPY9na/UcMaig8FVa+ 6YXHkave9F/qSvcNZCtqL6LQmD/JyBh9K4VpIA5idb6yMD6UQ7UKwKI6g9K6Z67wczXh orGQxvDupvZWBO1tqPOqJ4+yhtZP+KJpg9FXuN3G0ewuTiO1gnNfbij1RhPz1XnMHbHO ziCcofcHqbFI7AmNiaBbrwL221y/cyNiUUobmvMaPyb5blLDI4eylfb3v9KEXAzvZVYO Fj0YZDvy/WPyMfZUXzrDddZyAuQ/RWBXuwW3W7fEXE1668UgrKyEtXgA7Ke8V3jh+3ik O3xA== 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 b2si1388408wrv.318.2019.06.27.02.35.40; Thu, 27 Jun 2019 02:35:40 -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 4B6702AA0; Thu, 27 Jun 2019 11:35:35 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id E9275DED for ; Thu, 27 Jun 2019 11:35:30 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CB2EE1A0C58; Thu, 27 Jun 2019 11:35:30 +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 DF7DC1A0A2D; Thu, 27 Jun 2019 11:35:28 +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 4FE1F4030E; Thu, 27 Jun 2019 17:35:26 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 27 Jun 2019 15:03:39 +0530 Message-Id: <20190627093343.5171-2-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627093343.5171-1-hemant.agrawal@nxp.com> References: <20190625104411.19565-1-hemant.agrawal@nxp.com> <20190627093343.5171-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 1/5] bus/fslmc: support device iteration 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 Recent (18.11+), devargs structure was changed and so was DPDK port usage in applications like OVS. Applications are now allowed to plug/unplug ports (eth) using APIs (hotplug) based on device arguments. This patch enables the plug/unplug function (which are dummy for FSLMC) and the iterator function for rte_dev_probe() and similar API support. Signed-off-by: Shreyansh Jain --- drivers/bus/fslmc/fslmc_bus.c | 132 +++++++++++++++++++++++++++++----- 1 file changed, 116 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index f6e66d22c..35103d224 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -230,34 +230,70 @@ rte_fslmc_parse(const char *name, void *addr) { uint16_t dev_id; char *t_ptr; + char *sep = NULL; + uint8_t sep_exists = 0; - /* 'name' is expected to contain name of device, for example, dpio.1, - * dpni.2, etc. + DPAA2_BUS_DEBUG("Parsing dev=(%s)", name); + + /* There are multiple ways this can be called, with bus:dev, name=dev + * or just dev. In all cases, the 'addr' is actually a string. + */ + sep = strchr(name, ':'); + if (!sep) { + /* check for '=' */ + sep = strchr(name, '='); + if (!sep) + sep_exists = 0; + else + sep_exists = 1; + } else + sep_exists = 1; + + /* Check if starting part if either of 'fslmc:' or 'name=', separator + * exists. */ - if (strncmp("dpni", name, 4) && - strncmp("dpseci", name, 6) && - strncmp("dpcon", name, 5) && - strncmp("dpbp", name, 4) && - strncmp("dpio", name, 4) && - strncmp("dpci", name, 4) && - strncmp("dpmcp", name, 5) && - strncmp("dpdmai", name, 6) && - strncmp("dpdmux", name, 6)) { - DPAA2_BUS_DEBUG("Unknown or unsupported device (%s)", name); + if (sep_exists) { + /* If either of "fslmc" or "name" are starting part */ + if (!strncmp(name, RTE_STR(FSLMC_BUS_NAME), + strlen(RTE_STR(FSLMC_BUS_NAME))) || + (!strncmp(name, "name", strlen("name")))) { + goto jump_out; + } else { + DPAA2_BUS_DEBUG("Invalid device for matching (%s).", + name); + goto err_out; + } + } else + sep = strdup(name); + +jump_out: + /* Validate device name */ + if (strncmp("dpni", sep, 4) && + strncmp("dpseci", sep, 6) && + strncmp("dpcon", sep, 5) && + strncmp("dpbp", sep, 4) && + strncmp("dpio", sep, 4) && + strncmp("dpci", sep, 4) && + strncmp("dpmcp", sep, 5) && + strncmp("dpdmai", sep, 6) && + strncmp("dpdmux", sep, 6)) { + DPAA2_BUS_DEBUG("Unknown or unsupported device (%s)", sep); goto err_out; } - t_ptr = strchr(name, '.'); + t_ptr = strchr(sep, '.'); if (!t_ptr || sscanf(t_ptr + 1, "%hu", &dev_id) != 1) { - DPAA2_BUS_ERR("Missing device id in device name (%s)", name); + DPAA2_BUS_ERR("Missing device id in device name (%s)", sep); goto err_out; } if (addr) - strcpy(addr, name); + strcpy(addr, sep); return 0; err_out: + if (sep) + free(sep); return -EINVAL; } @@ -430,6 +466,13 @@ rte_fslmc_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, const struct rte_dpaa2_device *dstart; struct rte_dpaa2_device *dev; + DPAA2_BUS_DEBUG("Finding a device named %s\n", (const char *)data); + + /* find_device is always called with an opaque object which should be + * passed along to the 'cmp' function iterating over all device obj + * on the bus. + */ + if (start != NULL) { dstart = RTE_DEV_TO_FSLMC_CONST(start); dev = TAILQ_NEXT(dstart, next); @@ -437,8 +480,11 @@ rte_fslmc_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, dev = TAILQ_FIRST(&rte_fslmc_bus.device_list); } while (dev != NULL) { - if (cmp(&dev->device, data) == 0) + if (cmp(&dev->device, data) == 0) { + DPAA2_BUS_DEBUG("Found device (%s)\n", + dev->device.name); return &dev->device; + } dev = TAILQ_NEXT(dev, next); } @@ -527,6 +573,57 @@ rte_dpaa2_get_iommu_class(void) return RTE_IOVA_PA; } +static int +fslmc_bus_plug(struct rte_device *dev __rte_unused) +{ + /* No operation is performed while plugging the device */ + return 0; +} + +static int +fslmc_bus_unplug(struct rte_device *dev __rte_unused) +{ + /* No operation is performed while unplugging the device */ + return 0; +} + +static void * +fslmc_bus_dev_iterate(const void *start, const char *str, + const struct rte_dev_iterator *it __rte_unused) +{ + const struct rte_dpaa2_device *dstart; + struct rte_dpaa2_device *dev; + char *dup, *dev_name = NULL; + + /* Expectation is that device would be name=device_name */ + if (strncmp(str, "name=", 5) != 0) { + DPAA2_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_FSLMC_CONST(start); + dev = TAILQ_NEXT(dstart, next); + } else { + dev = TAILQ_FIRST(&rte_fslmc_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; +} + struct rte_fslmc_bus rte_fslmc_bus = { .bus = { .scan = rte_fslmc_scan, @@ -534,6 +631,9 @@ struct rte_fslmc_bus rte_fslmc_bus = { .parse = rte_fslmc_parse, .find_device = rte_fslmc_find_device, .get_iommu_class = rte_dpaa2_get_iommu_class, + .plug = fslmc_bus_plug, + .unplug = fslmc_bus_unplug, + .dev_iterate = fslmc_bus_dev_iterate, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_fslmc_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_fslmc_bus.driver_list), From patchwork Thu Jun 27 09:33:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 167892 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2092216ilk; Thu, 27 Jun 2019 02:36:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeBOHDnLQvg28h4D+64QvxvsVPHXkxb9uIdfRkteq1BXN5t+KLZvKXTe8pWTPLDatjOt/A X-Received: by 2002:a5d:6a42:: with SMTP id t2mr2427351wrw.352.1561628162351; Thu, 27 Jun 2019 02:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561628162; cv=none; d=google.com; s=arc-20160816; b=veWnYZ65mDcgiD5sZioDqf+j/ZIOLD8FGNPvMq10H3kktmJBfFGDne5hb6Ac4bjlQL AOXISOQG3iHNNNACT/HyxQQ7k91mKMmv8Z54uYpDvUL77ySH/i1lC3jdjX+qmO2FgOPL LeS8NQgEAo51/bJ7McDKbso7I1KDxsSBAPesJj6ABhdLilrgLa9km6WhuiXzUpKBiww2 +JjUO4oklHn25oAFkD2nXLMwzt1TutDjxEwjjMilxm6z+xmqr6RgaroMASg7Io+abaw8 Pv+dzvX8mMNe8ayyya25OA67m9TwIhRtZDVtyj5qXm2ifrv12abqd2G4fF+ehvbERmKU 4sKw== 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=MdNFMkbPdKtAnYo4XqJxrwW5zEGMShy3AcW7my1p9/w=; b=DgbpVxjjnUPgQGXXZ+KtlvM+mmaMY7VFeT8DWqJQQHIxKEz/lAhVu+lInJOIjGb9gL JFiHCMu1Y2wkg7/Lii0WZRxbkk6UuZQy2dIRNf35OAWVJQO0jjpQGdxdB11P6sqNGyCP S5jUNXH7JHztY5ZlerJhR3z9UsGrMFF5/JK8oozdxlfjYJd0nd97aUkdwX3DMZzYayDc RF7wv3BDc/w1CT5I94lqejQVwUwlX+H8SwoRLZ50vvhmJFTzfjORAyXdx43W46hPjHr0 8KM0bdT7Kw8FdhDbhJnzY09eSYc4kxtUvYOnQ9RUJOo96cqgkYrqNwVj502Ua8wfZtSk Qzwg== 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 f25si1491459wrc.305.2019.06.27.02.36.02; Thu, 27 Jun 2019 02:36:02 -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 57FF52BF2; Thu, 27 Jun 2019 11:35:40 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id CBAC625D9 for ; Thu, 27 Jun 2019 11:35:33 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 669CA200B9F; Thu, 27 Jun 2019 11:35:33 +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 B391D200748; Thu, 27 Jun 2019 11:35:31 +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 D62D64031E; Thu, 27 Jun 2019 17:35:26 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 27 Jun 2019 15:03:40 +0530 Message-Id: <20190627093343.5171-3-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627093343.5171-1-hemant.agrawal@nxp.com> References: <20190625104411.19565-1-hemant.agrawal@nxp.com> <20190627093343.5171-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 2/5] bus/fslmc: enhance error handling for dev parsing 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 In case an incorrect device is found, it was quiting further search rather than skipping it. Signed-off-by: Shreyansh Jain --- drivers/bus/fslmc/fslmc_bus.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index 35103d224..a2ed3bcc9 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -33,7 +33,7 @@ uint8_t dpaa2_virt_mode; uint32_t rte_fslmc_get_device_count(enum rte_dpaa2_dev_type device_type) { - if (device_type > DPAA2_DEVTYPE_MAX) + if (device_type >= DPAA2_DEVTYPE_MAX) return 0; return rte_fslmc_bus.device_count[device_type]; } @@ -135,10 +135,11 @@ static int scan_one_fslmc_device(char *dev_name) { char *dup_dev_name, *t_ptr; - struct rte_dpaa2_device *dev; + struct rte_dpaa2_device *dev = NULL; + int ret = -1; if (!dev_name) - return -1; + return ret; /* Ignore the Container name itself */ if (!strncmp("dprc", dev_name, 4)) @@ -168,7 +169,8 @@ scan_one_fslmc_device(char *dev_name) /* Parse the device name and ID */ t_ptr = strtok(dup_dev_name, "."); if (!t_ptr) { - DPAA2_BUS_ERR("Incorrect device name observed"); + DPAA2_BUS_ERR("Invalid device found: (%s)", dup_dev_name); + ret = -EINVAL; goto cleanup; } if (!strncmp("dpni", t_ptr, 4)) @@ -192,12 +194,10 @@ scan_one_fslmc_device(char *dev_name) else dev->dev_type = DPAA2_UNKNOWN; - /* Update the device found into the device_count table */ - rte_fslmc_bus.device_count[dev->dev_type]++; - t_ptr = strtok(NULL, "."); if (!t_ptr) { - DPAA2_BUS_ERR("Incorrect device string observed (null)"); + DPAA2_BUS_ERR("Skipping invalid device (%s)", dup_dev_name); + ret = 0; goto cleanup; } @@ -205,10 +205,14 @@ scan_one_fslmc_device(char *dev_name) dev->device.name = strdup(dev_name); if (!dev->device.name) { DPAA2_BUS_ERR("Unable to clone device name. Out of memory"); + ret = -ENOMEM; goto cleanup; } dev->device.devargs = fslmc_devargs_lookup(dev); + /* Update the device found into the device_count table */ + rte_fslmc_bus.device_count[dev->dev_type]++; + /* Add device in the fslmc device list */ insert_in_device_list(dev); @@ -222,7 +226,7 @@ scan_one_fslmc_device(char *dev_name) free(dup_dev_name); if (dev) free(dev); - return -1; + return ret; } static int @@ -353,7 +357,7 @@ rte_fslmc_scan(void) /* Remove all devices in the list */ cleanup_fslmc_device_list(); scan_fail: - DPAA2_BUS_DEBUG("FSLMC Bus Not Available. Skipping"); + DPAA2_BUS_DEBUG("FSLMC Bus Not Available. Skipping (%d)", ret); /* Irrespective of failure, scan only return success */ return 0; } From patchwork Thu Jun 27 09:33:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 167894 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2092585ilk; Thu, 27 Jun 2019 02:36:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRGt9RRFrR8ne9LN7TyZoohAF+X2N8sZtIEXpdsE8jDzjAY3kDcN3h4u7RApuc4omDlQnx X-Received: by 2002:adf:f64a:: with SMTP id x10mr2352552wrp.287.1561628183526; Thu, 27 Jun 2019 02:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561628183; cv=none; d=google.com; s=arc-20160816; b=CQNX2CmWFwY8uH91EkXUiUtzvwNiI1RLaYlzLQfn8lXa+ptdXCHKcuEy+5pq/7tnx/ B02ExGL99Mw3MY5mTjr9uAkWfN1tpX5YG3pFELK4WD3GmC33wd+LnhhoTkdrxiVcAuW3 V+pG28FjjZxo/F0EaAMtl+rf5L6heFqqVcy2Xm6rP8/EjcGzoLqv5inbsJbHt1ZYjYiJ RpY3JbTqLv0gaz0R4JdjRB3es8HlDSR7ijUViPh4M3UJw3j7Rh/V3C8zu57rkFe4bXBC 8CESj9MXO9NIh9aG6KkEnlZyvck8N1jmfXklWytsBJyMYAL8ZmAo5fYQdfC+6n8C9EII LNNg== 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=gscI7fz84Tl4lw/dFrndSGb1s1T9axUnRymFFpP9EPU=; b=seG05i7JaIgNE88GT2bEfTr1lpL4SuqFI5TcTqHzORrpvO5EzpONeVtcoUucoc7M+m Xz4572wNUTNdcRpK5ZeAcWMIEGBIE3L0UE7EcoeEru38wL8iABCO8lEmhCaLRbWUSWJu C3T/ikAB7TA8YGOnThN7CvT/XL2Lg+w60BP9j42Po6+ZgR8R1sNdSGhCfiS+Zzr69iEA Jg+RA1vTWAaA2ocAw6W5BZ1Kd60tBm9aXYBKRS+Tlf7C81Wz5xEs44ant6+Pp3Y6Qi8N 4sLVRyWTaaZyRgM2Sl5/OcA99rZ4uHfwO3Pegtjl/fiXLvd+NHNbeQwcyWS7Jwmlx+Pp Wigg== 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 w23si3283845wmi.95.2019.06.27.02.36.23; Thu, 27 Jun 2019 02:36: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 20CC6325F; Thu, 27 Jun 2019 11:35:45 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 73BDA2956 for ; Thu, 27 Jun 2019 11:35:34 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 46ACE1A0311; Thu, 27 Jun 2019 11:35:34 +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 516481A0C41; Thu, 27 Jun 2019 11:35:32 +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 67D564031F; Thu, 27 Jun 2019 17:35:27 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 27 Jun 2019 15:03:41 +0530 Message-Id: <20190627093343.5171-4-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627093343.5171-1-hemant.agrawal@nxp.com> References: <20190625104411.19565-1-hemant.agrawal@nxp.com> <20190627093343.5171-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 3/5] bus/fslmc: dynamic iommu mode detection 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 This patch adds following: 1. 'g_container' variable name is not right way to represent the FSLMC container. Renaming it to fslmc_container. 2. dynamic selection of IOMMU mode based on run environment Signed-off-by: Shreyansh Jain --- drivers/bus/fslmc/fslmc_vfio.c | 38 +++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 1aae56fa9..711780e74 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016-2018 NXP + * Copyright 2016-2019 NXP * */ @@ -49,7 +49,8 @@ static struct fslmc_vfio_group vfio_group; static struct fslmc_vfio_container vfio_container; static int container_device_fd; -static char *g_container; +static char *fslmc_container; +static int fslmc_iommu_type; static uint32_t *msi_intr_vaddr; void *(*rte_mcp_ptr_list); @@ -71,7 +72,7 @@ fslmc_get_container_group(int *groupid) int ret; char *container; - if (!g_container) { + if (!fslmc_container) { container = getenv("DPRC"); if (container == NULL) { DPAA2_BUS_DEBUG("DPAA2: DPRC not available"); @@ -83,23 +84,26 @@ fslmc_get_container_group(int *groupid) return -1; } - g_container = strdup(container); - if (!g_container) { + fslmc_container = strdup(container); + if (!fslmc_container) { DPAA2_BUS_ERR("Mem alloc failure; Container name"); return -ENOMEM; } } + fslmc_iommu_type = (rte_vfio_noiommu_is_enabled() == 1) ? + RTE_VFIO_NOIOMMU : VFIO_TYPE1_IOMMU; + /* get group number */ ret = rte_vfio_get_group_num(SYSFS_FSL_MC_DEVICES, - g_container, groupid); + fslmc_container, groupid); if (ret <= 0) { - DPAA2_BUS_ERR("Unable to find %s IOMMU group", g_container); + DPAA2_BUS_ERR("Unable to find %s IOMMU group", fslmc_container); return -1; } DPAA2_BUS_DEBUG("Container: %s has VFIO iommu group id = %d", - g_container, *groupid); + fslmc_container, *groupid); return 0; } @@ -132,7 +136,7 @@ vfio_connect_container(void) } /* Check whether support for SMMU type IOMMU present or not */ - if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) { + if (ioctl(fd, VFIO_CHECK_EXTENSION, fslmc_iommu_type)) { /* Connect group to container */ ret = ioctl(vfio_group.fd, VFIO_GROUP_SET_CONTAINER, &fd); if (ret) { @@ -141,7 +145,7 @@ vfio_connect_container(void) return -errno; } - ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU); + ret = ioctl(fd, VFIO_SET_IOMMU, fslmc_iommu_type); if (ret) { DPAA2_BUS_ERR("Failed to setup VFIO iommu"); close(fd); @@ -261,6 +265,11 @@ fslmc_map_dma(uint64_t vaddr, rte_iova_t iovaddr __rte_unused, size_t len) }; int ret; + if (fslmc_iommu_type == RTE_VFIO_NOIOMMU) { + DPAA2_BUS_DEBUG("Running in NOIOMMU mode"); + return 0; + } + dma_map.size = len; dma_map.vaddr = vaddr; @@ -300,6 +309,11 @@ fslmc_unmap_dma(uint64_t vaddr, uint64_t iovaddr __rte_unused, size_t len) }; int ret; + if (fslmc_iommu_type == RTE_VFIO_NOIOMMU) { + DPAA2_BUS_DEBUG("Running in NOIOMMU mode"); + return 0; + } + dma_unmap.size = len; dma_unmap.iova = vaddr; @@ -821,10 +835,10 @@ fslmc_vfio_setup_group(void) } /* Get Device information */ - ret = ioctl(vfio_group.fd, VFIO_GROUP_GET_DEVICE_FD, g_container); + ret = ioctl(vfio_group.fd, VFIO_GROUP_GET_DEVICE_FD, fslmc_container); if (ret < 0) { DPAA2_BUS_ERR("Error getting device %s fd from group %d", - g_container, vfio_group.groupid); + fslmc_container, vfio_group.groupid); close(vfio_group.fd); rte_vfio_clear_group(vfio_group.fd); return ret; From patchwork Thu Jun 27 09:33:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 167893 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2092421ilk; Thu, 27 Jun 2019 02:36:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzj+hif8LUJN9a9hDZ+LzprqpAnGnktc6yuIHYmKkyt3pPAOCnGvmVsLNtMYBxrK/p3NYsy X-Received: by 2002:a7b:cd9a:: with SMTP id y26mr2663205wmj.44.1561628172915; Thu, 27 Jun 2019 02:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561628172; cv=none; d=google.com; s=arc-20160816; b=mC6XF1gVWjm3u1Y7f5jrCEQ9aA4fOmiztTS+jmY5lG9X016+SYVtgipcB/w215o/jM OLQNl11GkwM460JNMWMtJ44dg3MhcvKw2yTNy17gwXh/qxpskKrpLC/pKSquyggeFvn+ r95J86A2JQ4qwOQj/uLihnG9c59eV39KytlnDPsgUUPv046VA21eL10SXC4gT2YQ7qrr hcU4fG5A9K52ns//OssbtOgp5bz4UdPYbuxwEmATknFlnLZUZs6ibogEb9dioyJXl0RW kgSej2mvj3qY/bpThSGasneIk+QGlnvtVXQGZdqA5kQQ3X/7uoMSpVN/GY1oyiykkwwY Fqzg== 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=J0FCDCDa1AE8RFH8dR6s1hi5rHyBjCidtLddQw3G8nA=; b=GQTroTsRNFa87CRZRU4PESZ43N7P6wBpxQ2io8YQJ5TThFi/axzxVDUaN5JyGy+Peh YlyDH8a3JkRRXy3JpBiiVI71RDDcB0SkCWKD0k4pvbH0mn3/f3wsNeFAn5x+D/jF5Z4y I4KUXdF8nvgU6s2mzL4k1m1gpCnBQUY5Miu58gxedDDsahFGKAUUV8Ar9hBRmWimrUi3 xE3YQmi8YWCAdB9q7cAKVpnhIDsOw+w89VHMqkcO55qQuxRVlCZpW3ozHMLXk5fZZIHp MuhOg0dL0tQ7nwVGQKKVzGraGgBNnpjQ890wfBLXYFta3gp5gtQw6UstFz+YeRexJvK2 ysDQ== 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 n14si1349285wrv.284.2019.06.27.02.36.12; Thu, 27 Jun 2019 02:36:12 -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 CFC962C4F; Thu, 27 Jun 2019 11:35:42 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 804A02AA0 for ; Thu, 27 Jun 2019 11:35:34 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 3F1D3200B9C; Thu, 27 Jun 2019 11:35:34 +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 50EF5200B9A; Thu, 27 Jun 2019 11:35:32 +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 ED9FE40320; Thu, 27 Jun 2019 17:35:27 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 27 Jun 2019 15:03:42 +0530 Message-Id: <20190627093343.5171-5-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627093343.5171-1-hemant.agrawal@nxp.com> References: <20190625104411.19565-1-hemant.agrawal@nxp.com> <20190627093343.5171-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 4/5] bus/fslmc: use cinh read for eqcr ci on ls1088 platform 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: Nipun Gupta LS1088 platform CENA operation are causing issues at high load. CINH (cache inhibited) mode is working fine with minor performance impact. This patch enables CINH mode selectively on LS1088 platform Signed-off-by: Nipun Gupta --- drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 2 - drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 5 - .../fslmc/qbman/include/fsl_qbman_portal.h | 9 + drivers/bus/fslmc/qbman/qbman_portal.c | 278 +++++++++++++++++- drivers/bus/fslmc/qbman/qbman_sys.h | 22 +- 5 files changed, 303 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h index 17e7e4fad..c68495eaf 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h @@ -28,8 +28,6 @@ RTE_DECLARE_PER_LCORE(struct dpaa2_io_portal_t, _dpaa2_io); #define DPAA2_PER_LCORE_ETHRX_DPIO RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev #define DPAA2_PER_LCORE_ETHRX_PORTAL DPAA2_PER_LCORE_ETHRX_DPIO->sw_portal -/* Variable to store DPAA2 platform type */ -extern uint32_t dpaa2_svr_family; /* Variable to store DPAA2 DQRR size */ extern uint8_t dpaa2_dqrr_size; /* Variable to store DPAA2 EQCR size */ diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h index 0cbde8a9b..92fc76211 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h @@ -23,11 +23,6 @@ #define lower_32_bits(x) ((uint32_t)(x)) #define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16)) -#define SVR_LS1080A 0x87030000 -#define SVR_LS2080A 0x87010000 -#define SVR_LS2088A 0x87090000 -#define SVR_LX2160A 0x87360000 - #ifndef VLAN_TAG_SIZE #define VLAN_TAG_SIZE 4 /** < Vlan Header Length */ #endif diff --git a/drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h b/drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h index 07b8a4372..107850d37 100644 --- a/drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +++ b/drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright (C) 2014 Freescale Semiconductor, Inc. + * Copyright 2015-2019 NXP * */ #ifndef _FSL_QBMAN_PORTAL_H @@ -8,6 +9,14 @@ #include +#define SVR_LS1080A 0x87030000 +#define SVR_LS2080A 0x87010000 +#define SVR_LS2088A 0x87090000 +#define SVR_LX2160A 0x87360000 + +/* Variable to store DPAA2 platform type */ +extern uint32_t dpaa2_svr_family; + /** * DOC - QBMan portal APIs to implement the following functions: * - Initialize and destroy Software portal object. diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c index 20da8b921..e6066ce35 100644 --- a/drivers/bus/fslmc/qbman/qbman_portal.c +++ b/drivers/bus/fslmc/qbman/qbman_portal.c @@ -76,6 +76,10 @@ qbman_swp_enqueue_ring_mode_direct(struct qbman_swp *s, const struct qbman_eq_desc *d, const struct qbman_fd *fd); static int +qbman_swp_enqueue_ring_mode_cinh_direct(struct qbman_swp *s, + const struct qbman_eq_desc *d, + const struct qbman_fd *fd); +static int qbman_swp_enqueue_ring_mode_mem_back(struct qbman_swp *s, const struct qbman_eq_desc *d, const struct qbman_fd *fd); @@ -87,6 +91,12 @@ qbman_swp_enqueue_multiple_direct(struct qbman_swp *s, uint32_t *flags, int num_frames); static int +qbman_swp_enqueue_multiple_cinh_direct(struct qbman_swp *s, + const struct qbman_eq_desc *d, + const struct qbman_fd *fd, + uint32_t *flags, + int num_frames); +static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s, const struct qbman_eq_desc *d, const struct qbman_fd *fd, @@ -99,7 +109,12 @@ qbman_swp_enqueue_multiple_fd_direct(struct qbman_swp *s, struct qbman_fd **fd, uint32_t *flags, int num_frames); - +static int +qbman_swp_enqueue_multiple_fd_cinh_direct(struct qbman_swp *s, + const struct qbman_eq_desc *d, + struct qbman_fd **fd, + uint32_t *flags, + int num_frames); static int qbman_swp_enqueue_multiple_fd_mem_back(struct qbman_swp *s, const struct qbman_eq_desc *d, @@ -113,6 +128,11 @@ qbman_swp_enqueue_multiple_desc_direct(struct qbman_swp *s, const struct qbman_fd *fd, int num_frames); static int +qbman_swp_enqueue_multiple_desc_cinh_direct(struct qbman_swp *s, + const struct qbman_eq_desc *d, + const struct qbman_fd *fd, + int num_frames); +static int qbman_swp_enqueue_multiple_desc_mem_back(struct qbman_swp *s, const struct qbman_eq_desc *d, const struct qbman_fd *fd, @@ -273,6 +293,17 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d) qbman_swp_release_ptr = qbman_swp_release_mem_back; } + if (dpaa2_svr_family == SVR_LS1080A) { + qbman_swp_enqueue_ring_mode_ptr = + qbman_swp_enqueue_ring_mode_cinh_direct; + qbman_swp_enqueue_multiple_ptr = + qbman_swp_enqueue_multiple_cinh_direct; + qbman_swp_enqueue_multiple_fd_ptr = + qbman_swp_enqueue_multiple_fd_cinh_direct; + qbman_swp_enqueue_multiple_desc_ptr = + qbman_swp_enqueue_multiple_desc_cinh_direct; + } + for (mask_size = p->eqcr.pi_ring_size; mask_size > 0; mask_size >>= 1) p->eqcr.pi_ci_mask = (p->eqcr.pi_ci_mask<<1) + 1; eqcr_pi = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI); @@ -700,6 +731,46 @@ static int qbman_swp_enqueue_ring_mode_direct(struct qbman_swp *s, return 0; } +static int qbman_swp_enqueue_ring_mode_cinh_direct( + struct qbman_swp *s, + const struct qbman_eq_desc *d, + const struct qbman_fd *fd) +{ + uint32_t *p; + const uint32_t *cl = qb_cl(d); + uint32_t eqcr_ci, full_mask, half_mask; + + half_mask = (s->eqcr.pi_ci_mask>>1); + full_mask = s->eqcr.pi_ci_mask; + if (!s->eqcr.available) { + eqcr_ci = s->eqcr.ci; + s->eqcr.ci = qbman_cinh_read(&s->sys, + QBMAN_CINH_SWP_EQCR_CI) & full_mask; + s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size, + eqcr_ci, s->eqcr.ci); + if (!s->eqcr.available) + return -EBUSY; + } + + p = qbman_cena_write_start_wo_shadow(&s->sys, + QBMAN_CENA_SWP_EQCR(s->eqcr.pi & half_mask)); + memcpy(&p[1], &cl[1], 28); + memcpy(&p[8], fd, sizeof(*fd)); + lwsync(); + + /* Set the verb byte, have to substitute in the valid-bit */ + p[0] = cl[0] | s->eqcr.pi_vb; + qbman_cena_write_complete_wo_shadow(&s->sys, + QBMAN_CENA_SWP_EQCR(s->eqcr.pi & half_mask)); + s->eqcr.pi++; + s->eqcr.pi &= full_mask; + s->eqcr.available--; + if (!(s->eqcr.pi & half_mask)) + s->eqcr.pi_vb ^= QB_VALID_BIT; + + return 0; +} + static int qbman_swp_enqueue_ring_mode_mem_back(struct qbman_swp *s, const struct qbman_eq_desc *d, const struct qbman_fd *fd) @@ -823,6 +894,76 @@ static int qbman_swp_enqueue_multiple_direct(struct qbman_swp *s, return num_enqueued; } +static int qbman_swp_enqueue_multiple_cinh_direct( + struct qbman_swp *s, + const struct qbman_eq_desc *d, + const struct qbman_fd *fd, + uint32_t *flags, + int num_frames) +{ + uint32_t *p = NULL; + const uint32_t *cl = qb_cl(d); + uint32_t eqcr_ci, eqcr_pi, half_mask, full_mask; + int i, num_enqueued = 0; + uint64_t addr_cena; + + half_mask = (s->eqcr.pi_ci_mask>>1); + full_mask = s->eqcr.pi_ci_mask; + if (!s->eqcr.available) { + eqcr_ci = s->eqcr.ci; + s->eqcr.ci = qbman_cinh_read(&s->sys, + QBMAN_CINH_SWP_EQCR_CI) & full_mask; + s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size, + eqcr_ci, s->eqcr.ci); + if (!s->eqcr.available) + return 0; + } + + eqcr_pi = s->eqcr.pi; + num_enqueued = (s->eqcr.available < num_frames) ? + s->eqcr.available : num_frames; + s->eqcr.available -= num_enqueued; + /* Fill in the EQCR ring */ + for (i = 0; i < num_enqueued; i++) { + p = qbman_cena_write_start_wo_shadow(&s->sys, + QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask)); + memcpy(&p[1], &cl[1], 28); + memcpy(&p[8], &fd[i], sizeof(*fd)); + eqcr_pi++; + } + + lwsync(); + + /* Set the verb byte, have to substitute in the valid-bit */ + eqcr_pi = s->eqcr.pi; + for (i = 0; i < num_enqueued; i++) { + p = qbman_cena_write_start_wo_shadow(&s->sys, + QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask)); + p[0] = cl[0] | s->eqcr.pi_vb; + if (flags && (flags[i] & QBMAN_ENQUEUE_FLAG_DCA)) { + struct qbman_eq_desc *d = (struct qbman_eq_desc *)p; + + d->eq.dca = (1 << QB_ENQUEUE_CMD_DCA_EN_SHIFT) | + ((flags[i]) & QBMAN_EQCR_DCA_IDXMASK); + } + eqcr_pi++; + if (!(eqcr_pi & half_mask)) + s->eqcr.pi_vb ^= QB_VALID_BIT; + } + + /* Flush all the cacheline without load/store in between */ + eqcr_pi = s->eqcr.pi; + addr_cena = (size_t)s->sys.addr_cena; + for (i = 0; i < num_enqueued; i++) { + dcbf(addr_cena + + QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask)); + eqcr_pi++; + } + s->eqcr.pi = eqcr_pi & full_mask; + + return num_enqueued; +} + static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s, const struct qbman_eq_desc *d, const struct qbman_fd *fd, @@ -954,6 +1095,76 @@ static int qbman_swp_enqueue_multiple_fd_direct(struct qbman_swp *s, return num_enqueued; } +static int qbman_swp_enqueue_multiple_fd_cinh_direct( + struct qbman_swp *s, + const struct qbman_eq_desc *d, + struct qbman_fd **fd, + uint32_t *flags, + int num_frames) +{ + uint32_t *p = NULL; + const uint32_t *cl = qb_cl(d); + uint32_t eqcr_ci, eqcr_pi, half_mask, full_mask; + int i, num_enqueued = 0; + uint64_t addr_cena; + + half_mask = (s->eqcr.pi_ci_mask>>1); + full_mask = s->eqcr.pi_ci_mask; + if (!s->eqcr.available) { + eqcr_ci = s->eqcr.ci; + s->eqcr.ci = qbman_cinh_read(&s->sys, + QBMAN_CINH_SWP_EQCR_CI) & full_mask; + s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size, + eqcr_ci, s->eqcr.ci); + if (!s->eqcr.available) + return 0; + } + + eqcr_pi = s->eqcr.pi; + num_enqueued = (s->eqcr.available < num_frames) ? + s->eqcr.available : num_frames; + s->eqcr.available -= num_enqueued; + /* Fill in the EQCR ring */ + for (i = 0; i < num_enqueued; i++) { + p = qbman_cena_write_start_wo_shadow(&s->sys, + QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask)); + memcpy(&p[1], &cl[1], 28); + memcpy(&p[8], fd[i], sizeof(struct qbman_fd)); + eqcr_pi++; + } + + lwsync(); + + /* Set the verb byte, have to substitute in the valid-bit */ + eqcr_pi = s->eqcr.pi; + for (i = 0; i < num_enqueued; i++) { + p = qbman_cena_write_start_wo_shadow(&s->sys, + QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask)); + p[0] = cl[0] | s->eqcr.pi_vb; + if (flags && (flags[i] & QBMAN_ENQUEUE_FLAG_DCA)) { + struct qbman_eq_desc *d = (struct qbman_eq_desc *)p; + + d->eq.dca = (1 << QB_ENQUEUE_CMD_DCA_EN_SHIFT) | + ((flags[i]) & QBMAN_EQCR_DCA_IDXMASK); + } + eqcr_pi++; + if (!(eqcr_pi & half_mask)) + s->eqcr.pi_vb ^= QB_VALID_BIT; + } + + /* Flush all the cacheline without load/store in between */ + eqcr_pi = s->eqcr.pi; + addr_cena = (size_t)s->sys.addr_cena; + for (i = 0; i < num_enqueued; i++) { + dcbf(addr_cena + + QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask)); + eqcr_pi++; + } + s->eqcr.pi = eqcr_pi & full_mask; + + return num_enqueued; +} + static int qbman_swp_enqueue_multiple_fd_mem_back(struct qbman_swp *s, const struct qbman_eq_desc *d, struct qbman_fd **fd, @@ -1087,6 +1298,71 @@ static int qbman_swp_enqueue_multiple_desc_direct(struct qbman_swp *s, return num_enqueued; } +static int qbman_swp_enqueue_multiple_desc_cinh_direct( + struct qbman_swp *s, + const struct qbman_eq_desc *d, + const struct qbman_fd *fd, + int num_frames) +{ + uint32_t *p; + const uint32_t *cl; + uint32_t eqcr_ci, eqcr_pi, half_mask, full_mask; + int i, num_enqueued = 0; + uint64_t addr_cena; + + half_mask = (s->eqcr.pi_ci_mask>>1); + full_mask = s->eqcr.pi_ci_mask; + if (!s->eqcr.available) { + eqcr_ci = s->eqcr.ci; + s->eqcr.ci = qbman_cinh_read(&s->sys, + QBMAN_CINH_SWP_EQCR_CI) & full_mask; + s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size, + eqcr_ci, s->eqcr.ci); + if (!s->eqcr.available) + return 0; + } + + eqcr_pi = s->eqcr.pi; + num_enqueued = (s->eqcr.available < num_frames) ? + s->eqcr.available : num_frames; + s->eqcr.available -= num_enqueued; + /* Fill in the EQCR ring */ + for (i = 0; i < num_enqueued; i++) { + p = qbman_cena_write_start_wo_shadow(&s->sys, + QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask)); + cl = qb_cl(&d[i]); + memcpy(&p[1], &cl[1], 28); + memcpy(&p[8], &fd[i], sizeof(*fd)); + eqcr_pi++; + } + + lwsync(); + + /* Set the verb byte, have to substitute in the valid-bit */ + eqcr_pi = s->eqcr.pi; + for (i = 0; i < num_enqueued; i++) { + p = qbman_cena_write_start_wo_shadow(&s->sys, + QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask)); + cl = qb_cl(&d[i]); + p[0] = cl[0] | s->eqcr.pi_vb; + eqcr_pi++; + if (!(eqcr_pi & half_mask)) + s->eqcr.pi_vb ^= QB_VALID_BIT; + } + + /* Flush all the cacheline without load/store in between */ + eqcr_pi = s->eqcr.pi; + addr_cena = (size_t)s->sys.addr_cena; + for (i = 0; i < num_enqueued; i++) { + dcbf(addr_cena + + QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask)); + eqcr_pi++; + } + s->eqcr.pi = eqcr_pi & full_mask; + + return num_enqueued; +} + static int qbman_swp_enqueue_multiple_desc_mem_back(struct qbman_swp *s, const struct qbman_eq_desc *d, const struct qbman_fd *fd, diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h index 71f7a6782..e59fcfd54 100644 --- a/drivers/bus/fslmc/qbman/qbman_sys.h +++ b/drivers/bus/fslmc/qbman/qbman_sys.h @@ -381,6 +381,14 @@ static inline uint32_t qbman_set_swp_cfg(uint8_t max_fill, uint8_t wn, #define QMAN_REV_5000 0x05000000 #define QMAN_REV_MASK 0xffff0000 +#define SVR_LS1080A 0x87030000 +#define SVR_LS2080A 0x87010000 +#define SVR_LS2088A 0x87090000 +#define SVR_LX2160A 0x87360000 + +/* Variable to store DPAA2 platform type */ +extern uint32_t dpaa2_svr_family; + static inline int qbman_swp_sys_init(struct qbman_swp_sys *s, const struct qbman_swp_desc *d, uint8_t dqrr_size) @@ -388,16 +396,17 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s, uint32_t reg; int i; int cena_region_size = 4*1024; - - if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000 - && (d->cena_access_mode == qman_cena_fastest_access)) - cena_region_size = 64*1024; + uint8_t est = 1; #ifdef RTE_ARCH_64 uint8_t wn = CENA_WRITE_ENABLE; #else uint8_t wn = CINH_WRITE_ENABLE; #endif + + if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000 + && (d->cena_access_mode == qman_cena_fastest_access)) + cena_region_size = 64*1024; s->addr_cena = d->cena_bar; s->addr_cinh = d->cinh_bar; s->idx = (uint32_t)d->idx; @@ -428,6 +437,9 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s, dccivac(s->addr_cena + i); } + if (dpaa2_svr_family == SVR_LS1080A) + est = 0; + if (s->eqcr_mode == qman_eqcr_vb_array) { reg = qbman_set_swp_cfg(dqrr_size, wn, 0, 3, 2, 3, 1, 1, 1, 1, 1, 1); @@ -438,7 +450,7 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s, 1, 3, 2, 0, 1, 1, 1, 1, 1, 1); else reg = qbman_set_swp_cfg(dqrr_size, wn, - 1, 3, 2, 2, 1, 1, 1, 1, 1, 1); + est, 3, 2, 2, 1, 1, 1, 1, 1, 1); } if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000 From patchwork Thu Jun 27 09:33:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 167895 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2092715ilk; Thu, 27 Jun 2019 02:36:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfrU/cKKb4VEl6UFFjMjWEquStBacx8FxDqUqSBv+fS4NM5QeQNQc72o7FXIdCgHny0QSY X-Received: by 2002:a50:b635:: with SMTP id b50mr2820898ede.293.1561628192886; Thu, 27 Jun 2019 02:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561628192; cv=none; d=google.com; s=arc-20160816; b=VAKzKQBE8BSga2ebPwUdw85aeWdPdRj1IYYnUB5BsrBxCr3aCoME6nwW3fef8jGMDc zkBRbiPPfa0QKpMNZ4k/U1nTiISyd4akoGY29GeaeBkmkNzdoOUiB1axobJXgVaTDl0B S+ptsiKY6OurujgrgUmWwhu0Iku73DK9qu9Ut8vn9RMaMmzkcpNxfo6Er0T4Kgd2Wjt7 XPHwg7mqil9zRwdbWCk9kxQFnEJHY9npljsugcNRenOLCse2GnS5GLIzNteRq1zuEoSs W3Jv3wWOrlo3OZRep1bC9flgR1CDnUfrhPsPjwEuxO84vuCd1oXm+0DPp9ABBpYCE4jN 9EPg== 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=idG7kRVk5HcF6ogsqrJ5dUFrK/oTpkmW5v3MpLDY4yU=; b=JhGSR7UaIZDO8ULVblVspLFLrEHwp9QoYkUc8D97kwuz40JKY0nfYj7+VxSYHAV4Xm NJVMcbz8elCbdgb1eFW/Is5V11452XBbX7RTchI32OXQemhlpCj7QV7E+UI8CZThi7av Bp+E40uzwJk+G7ScSxSk2Xg9WcK2CSCCNC0FuWBz+eaxhAweTY5878NNTAtTHJL+yKsS GYrT4zC67QHTkkuSuGvNdxlNnD7qRdZJbi1qMDCKeQWofpDHEpSBwNRPMOo5eaKSEMhR 5JVDuK/PadYoZKHIZQMlJ2ws7SgHnIMvDoE2AN8cteQ0eXS/yJ2nLxjUJm6VS2lr4jBU MEPw== 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 l41si1299966eda.255.2019.06.27.02.36.32; Thu, 27 Jun 2019 02:36:32 -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 729E737B0; Thu, 27 Jun 2019 11:35:47 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 2912025D9 for ; Thu, 27 Jun 2019 11:35:35 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D9855200748; Thu, 27 Jun 2019 11:35:34 +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 E41DC200268; Thu, 27 Jun 2019 11:35:32 +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 7FFEC40323; Thu, 27 Jun 2019 17:35:28 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 27 Jun 2019 15:03:43 +0530 Message-Id: <20190627093343.5171-6-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627093343.5171-1-hemant.agrawal@nxp.com> References: <20190625104411.19565-1-hemant.agrawal@nxp.com> <20190627093343.5171-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 5/5] mempool/dpaa2: vfio dmamap for user allocated memory 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: Sachin Saxena Signed-off-by: Sachin Saxena --- drivers/bus/fslmc/fslmc_vfio.c | 39 +++++++++++++++++++++ drivers/bus/fslmc/fslmc_vfio.h | 4 ++- drivers/bus/fslmc/rte_bus_fslmc_version.map | 6 ++++ drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 13 +++++++ 4 files changed, 61 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 711780e74..e44bd31b9 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -358,6 +358,45 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused, return ret; } +__rte_experimental +int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size) +{ + int ret; + struct fslmc_vfio_group *group; + struct vfio_iommu_type1_dma_map dma_map = { + .argsz = sizeof(struct vfio_iommu_type1_dma_map), + .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE, + }; + + if (fslmc_iommu_type == RTE_VFIO_NOIOMMU) { + DPAA2_BUS_DEBUG("Running in NOIOMMU mode"); + return 0; + } + + /* SET DMA MAP for IOMMU */ + group = &vfio_group; + if (!group->container) { + DPAA2_BUS_ERR("Container is not connected"); + return -1; + } + + dma_map.size = size; + dma_map.vaddr = vaddr; + dma_map.iova = iova; + + DPAA2_BUS_DEBUG("VFIO dmamap 0x%llx:0x%llx, size 0x%llx\n", + dma_map.vaddr, dma_map.iova, dma_map.size); + ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, + &dma_map); + if (ret) { + printf("Unable to map DMA address (errno = %d)\n", + errno); + return ret; + } + + return 0; +} + int rte_fslmc_vfio_dmamap(void) { int i = 0, ret; diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h index 9e2c4feef..e877255ea 100644 --- a/drivers/bus/fslmc/fslmc_vfio.h +++ b/drivers/bus/fslmc/fslmc_vfio.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016 NXP + * Copyright 2016,2019 NXP * */ @@ -50,5 +50,7 @@ int fslmc_vfio_process_group(void); char *fslmc_get_container(void); int fslmc_get_container_group(int *gropuid); int rte_fslmc_vfio_dmamap(void); +__rte_experimental +int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size); #endif /* _FSLMC_VFIO_H_ */ diff --git a/drivers/bus/fslmc/rte_bus_fslmc_version.map b/drivers/bus/fslmc/rte_bus_fslmc_version.map index e86007384..4da787236 100644 --- a/drivers/bus/fslmc/rte_bus_fslmc_version.map +++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map @@ -141,3 +141,9 @@ DPDK_19.05 { qbman_result_eqresp_set_rspid; qbman_swp_enqueue_multiple_fd; } DPDK_18.11; + +EXPERIMENTAL { + global: + + rte_fslmc_vfio_mem_dmamap; +}; diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c index da66577cc..f26c30b00 100644 --- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c +++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c @@ -23,6 +23,7 @@ #include #include "rte_dpaa2_mempool.h" +#include "fslmc_vfio.h" #include #include #include @@ -405,6 +406,18 @@ dpaa2_populate(struct rte_mempool *mp, unsigned int max_objs, void *vaddr, rte_iova_t paddr, size_t len, rte_mempool_populate_obj_cb_t *obj_cb, void *obj_cb_arg) { + struct rte_memseg_list *msl; + /* The memsegment list exists incase the memory is not external. + * So, DMA-Map is required only when memory is provided by user, + * i.e. External. + */ + msl = rte_mem_virt2memseg_list(vaddr); + + if (!msl) { + DPAA2_MEMPOOL_DEBUG("Memsegment is External.\n"); + rte_fslmc_vfio_mem_dmamap((size_t)vaddr, + (size_t)paddr, (size_t)len); + } /* Insert entry into the PA->VA Table */ dpaax_iova_table_update(paddr, vaddr, len);