From patchwork Mon Jul 15 08:44:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 168979 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4104033ilk; Mon, 15 Jul 2019 01:46:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIqMbaT9Kydy/Vr8R3pD5Og9oIs1hZfV3j7tZvXRXhhj8Bpj7+XE9tt20FiwwQWymp07ut X-Received: by 2002:a17:906:4acc:: with SMTP id u12mr18936434ejt.41.1563180370701; Mon, 15 Jul 2019 01:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563180370; cv=none; d=google.com; s=arc-20160816; b=MFHQCjig5k58bgmSQLVkNcL84XV2ArYFw6fdyBFo35GWKzKJJG91m+yXxOad/NO+rb I0d1pPmkn4Q6vm6nyNOFfzjgJd9PMwTEA8kyhzmicx9QvXPF/B+nySx69Ab95+J71xP0 Avc3Sela5kzbN/rJ0z0Zn3wUDJo0vJc5y8fq7i0HPVe+ahSWLX3PRp/2R2aGP7E//VWA SkBII1FPFY5gtotG5VCPCWtoq1wKesRpN9YH98zbcOLwogHmlOWizjHRt/xvq7Ynk2V5 srnTW/3M5WIua9IbuWcmlT5REnLqYTXhPzxSX9xSJJWKmHdffYPRQ5sZH7Hak9GTEm6q QzzA== 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=RzCf3QRO6hqAmag7oq/NTxjrTOBaIRYAwV5TXtuJe37ir3ZaA2F+qJ3qJEMC1tMMmN 2vOpRDHUUbr2erDkcijgzCPovQ/XBJwmElpi3umuls0wVgKnfbyfyw95yswfCbzhq1tS qQoTF5y2chmy5FO9GKVVby/yCBFie/tRQlxrbiihpDrASjr6z3+DYQhui7w7cV/JF7T4 fAFRlcbJWWRDdGV6IMpd4PF0txHq+ojpi4652a/WH23i5K/WDzyixA2GPi0j+wmJ3UtL 0jeEMPIoBBaZb+NCIP6Bri4IL7u5heh5HdGHVAVoMa3LuCIW1auUZnF3z7LVbzmmpQzn utIg== 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 13si10026021edz.208.2019.07.15.01.46.10; Mon, 15 Jul 2019 01:46:10 -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 A8A0037B0; Mon, 15 Jul 2019 10:46:05 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 6A9BE3423 for ; Mon, 15 Jul 2019 10:46:02 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E6E8A2001A5; Mon, 15 Jul 2019 10:46:01 +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 9891520021C; Mon, 15 Jul 2019 10:45:59 +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 5691A402D5; Mon, 15 Jul 2019 16:45:56 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: thomas@monjalon.net, Shreyansh Jain Date: Mon, 15 Jul 2019 14:14:38 +0530 Message-Id: <20190715084442.14686-2-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190715084442.14686-1-hemant.agrawal@nxp.com> References: <20190627093343.5171-2-hemant.agrawal@nxp.com> <20190715084442.14686-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 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 Mon Jul 15 08:44: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: 168980 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4104184ilk; Mon, 15 Jul 2019 01:46:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqw23EXlo1ImkJBomGb24HD9IOwO8AiM/wykx4Py9KKz24SIw+hZOAvT3bRxnZhrxO/eGdcY X-Received: by 2002:a17:906:e91:: with SMTP id p17mr19552427ejf.217.1563180378539; Mon, 15 Jul 2019 01:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563180378; cv=none; d=google.com; s=arc-20160816; b=0CFK9ysgIjPmO8E2dp2T7l9SxHKNV6yu1Kt5GRpduTWNGo7HD9eNA/izX94WT0Gx21 tHr/EU4FNR/8jzu3gV314VFT8mQW/5pTFRIIlbVmeb9LX56DPkhz+qU0lhoBq+QNEokZ LpHyhHwGLfb8VXo6ky51HQv0BuQPWvweHm/Mft9fu5BIPhvQSx3GOl0orOntwoa6/iQi dMtc0KRVGnrAI5SsayV+TRjPGJvL7FYn+fejKfkPbWFNrgRpKX1aQB1hixSSZ1wFulL1 gWX1y/u3Qcsq+yH0fYsFJDIPRumiybBPALH15ejaZOE8/qjMMTNiabCGJkseKR/1KF18 +5cg== 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=AKCWIqWWuCTUrbyKqB0XdwbQJakDFaBIwsiBcyf6t6CSITq8Bzuw2RudnrZnD/bANf L1s04iuC3QA/9LuzoeRBTOMzuubXm1KOjmZkWHSYA4+AL/HNzm75cXiquKV8k7C8pPep im+xnwLQpe4RtSJn+OQbqjsB8L2qJcG1WBPXVGPjcXNM6vviwf3z1qjzCxRs5QJCTiFU Gzg1jnv6u/w/Ep1Cwh0R/GgDbWXY3QwKrVwTWc0C7LUpDOLIAfJa9PEqoz+hsYzAR3a1 8burP5puU2NDUglWCzzCfD65IXLZgfLAckfM/be6Uc8AoZYlrIfhAtfMvfZL0zJF+hLz xvXw== 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 e52si9720729ede.345.2019.07.15.01.46.18; Mon, 15 Jul 2019 01:46:18 -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 78FD81B957; Mon, 15 Jul 2019 10:46:08 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 0C1623423 for ; Mon, 15 Jul 2019 10:46:03 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 9A5E11A017C; Mon, 15 Jul 2019 10:46:02 +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 8C4931A0052; Mon, 15 Jul 2019 10:46:00 +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 4282D402D6; Mon, 15 Jul 2019 16:45:57 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: thomas@monjalon.net, Shreyansh Jain Date: Mon, 15 Jul 2019 14:14:39 +0530 Message-Id: <20190715084442.14686-3-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190715084442.14686-1-hemant.agrawal@nxp.com> References: <20190627093343.5171-2-hemant.agrawal@nxp.com> <20190715084442.14686-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 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 Mon Jul 15 08:44: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: 168981 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4104281ilk; Mon, 15 Jul 2019 01:46:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqytofD8f4xpk+1yK7aliey3qbX+n4Kh+SpW+xsiC0++NqYn0zalBgwNYjN3pTfcpvS5yrMZ X-Received: by 2002:aa7:da14:: with SMTP id r20mr21883786eds.65.1563180386254; Mon, 15 Jul 2019 01:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563180386; cv=none; d=google.com; s=arc-20160816; b=KHc6yOR67Sv0HdakEDPPG8XywoQ46nS1Ai95HTOPW8rYteEYRzj2Wh/B0ZFbE7vYGt iLmp6dWZiDkrqcMjRTwpzqs84anB7ubXBM8WdzW+OsiC3CVS7UVbhzCy+seZy+DfiTvb ESWyEfyYje3bNTVAO9xFPLiy/zYRNmdKocLZlVBySyS5QisH0dmRzyMfTVJxYQrWEv5T AP+CXO/ymZVjx2HQz6yU5BopjKzEdeLMVEOr1V3iVM4f2I+6uxFE4IjPmEtUX1NAOwKZ CKeKZch7p5ayM403YBZ3gqtMirG0YBOvbTIz0d9NtNDY4AaaEkKuafKJWZIZzmEeXk5/ PEqw== 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=waNWQuUVOkiv24Kl2ipmlZY9ltQNjA3kNBDPe8067Tg=; b=S8XsHQFPE/5F3YUNQ9Plv5rDZLk6ScQWZD9So1FjBmAX96eDfBBJ1Hvqqut2Q2AjvI q8ZKQ2kdHWbQdtUkNSvEHnEJAnlYJFcwhr6gkgGoMNZix/SByEUCruJMeMVFh9VLM/DH vs/wfLv3quBzMszzu3AvnSBTQFxvTlnYi9T2ADpu0oBHJqJrENMsWd8/FxOTf85DU8Ga Htd2g0jJ+OJHUN6e7J+cWzMyuTCwsVXgFhO6K39mr7u7jZKlek26XL98HAzJSWSFrQ5H Cj4yc75vXfy3vKqK5nbVdupW57DC0a0qXalSIDyi72vjT5W+ZKt+LZz+SjUrVU9cDFIB k+qg== 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 z31si10136833edz.165.2019.07.15.01.46.26; Mon, 15 Jul 2019 01:46:26 -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 16C3B1B993; Mon, 15 Jul 2019 10:46:10 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 1243D3772 for ; Mon, 15 Jul 2019 10:46:03 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id C31062001B5; Mon, 15 Jul 2019 10:46:03 +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 6BAA420000E; Mon, 15 Jul 2019 10:46: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 3459F402A8; Mon, 15 Jul 2019 16:45:58 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: thomas@monjalon.net, Shreyansh Jain Date: Mon, 15 Jul 2019 14:14:40 +0530 Message-Id: <20190715084442.14686-4-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190715084442.14686-1-hemant.agrawal@nxp.com> References: <20190627093343.5171-2-hemant.agrawal@nxp.com> <20190715084442.14686-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 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 44e4fa6e2..1383af4f1 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; @@ -819,10 +833,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 Mon Jul 15 08:44: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: 168982 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4104362ilk; Mon, 15 Jul 2019 01:46:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwk1TpKjpssyciLhHRHM4pTg16Pr/xz3BFhyDzbp+giVxNbJi3FcBewI3Ssm6m6n1hpAxau X-Received: by 2002:a50:95ae:: with SMTP id w43mr21880150eda.115.1563180392205; Mon, 15 Jul 2019 01:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563180392; cv=none; d=google.com; s=arc-20160816; b=yJJicY/R5UWxpcXn2mDK2N/eWUit5C1mQ15DtQyoMxeZMH0WrWdU+jDiYGIK0TYwL0 IQmu0Gs2uOhZxqvMPQu9qDiTYqk9xBl/zYqJmPoKOo32G21C0S/GhRXi1/DDTKuflcNf WJy179SwElKSIRF+Qr+bRdTl/5/jwzwFrpe6pSJ8AwT/N82tJ72/6KeNOzF5PK6nQXhz T3U7BahSI2d9ym3HzzmS38hJy0auE0HCQUnKheNij5uyVygj5/QGDWjsBd7EW8N63lBS gPx4PDDFgUtXzCfgrYuW0Vy7YGIbN00OB6MKbgzBCA+YtTt/vYYVBPWvPmsXKh1GR+A9 F46A== 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=JXJinjiSbmmCMDg6tU79r/UR6Y0Kw5p56Hu3r3R3b1I=; b=v0hJy5GePwQ1NgUKnS68n3KsqCnGaev47b82IO6EPhhQfdxLpTGYEHMJMRtXJxrjym d7ZoHdaapXlOy7SF2kyOpNsfM8/LDMMWnW9fz7MpP9D1wpp5opbwqwRecQZ3cSfed591 NX1HkQYcOoTKWbEPrvn6BRlzEGa9MRbbXG5HMS6NMtJtCYdogTUoxrDFBgKOgLUS6XeB rQQUW+R6krmBmlnXFMA6M6H2qQ7txxQHlxl+5wQLYlzyAH8Y/+sBF2rxYZNkMQJx/HYP 4Brac1ZhNK6Z6iJEQtafgYgWgXtejBK3BKFEpZT8m3VEaP2XFVmYq2xuXHWkrE+ziGp4 T+5A== 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 oq27si8338243ejb.277.2019.07.15.01.46.31; Mon, 15 Jul 2019 01:46: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 CF7D51B9C9; Mon, 15 Jul 2019 10:46:11 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 5A2873772 for ; Mon, 15 Jul 2019 10:46:05 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 1C3EB1A0169; Mon, 15 Jul 2019 10:46:05 +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 87E2F1A0192; Mon, 15 Jul 2019 10:46: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 182D4402E3; Mon, 15 Jul 2019 16:45:58 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: thomas@monjalon.net, Nipun Gupta Date: Mon, 15 Jul 2019 14:14:41 +0530 Message-Id: <20190715084442.14686-5-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190715084442.14686-1-hemant.agrawal@nxp.com> References: <20190627093343.5171-2-hemant.agrawal@nxp.com> <20190715084442.14686-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 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 c35dafedb..88f0a9968 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 Mon Jul 15 08:44: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: 168983 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4104518ilk; Mon, 15 Jul 2019 01:46:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwabJlRis/E62K0fYdDRC9n9f+mogjVWvDBTCnK5p6tx0wkcQa5gEU4l8fmeK2G6B1Z72ql X-Received: by 2002:aa7:c999:: with SMTP id c25mr21874265edt.134.1563180401996; Mon, 15 Jul 2019 01:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563180401; cv=none; d=google.com; s=arc-20160816; b=faHbYvJPYGZH8MNwX9L/vIvjmGOSLR06Fk7d8DLx0zRKrRhBGKPDm8AFd+VCyh39QL xUoxuc/E9Yoft6a8FMslHxkL7MPJQJ/Ul2auB+TZN9GtzQn6Mi0h94gNQQIgCELO5R1e aBdeWKOmEXpnPBcDSzsjXELtfANA2J3ZhJiKakFfb7ZbCHhomzvvG9b5ogShst4XdBoc gKUqHng+0p+Qvh7E42jmjkcPGmlyPGKJ5aeaziui18bi7TVOuX0r5XdmU++nBpwoa/Uo jmk+TLJ295t8ajhI68gTkHkX2bs2z+jkA1NR13Q2Oq4FeESAnSzhxlWECxZkEharg+uW IhXQ== 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=VS12UG0mJgm6RtWkbybirupZhXYI4UR5Ss2oqDLCwNU=; b=ixtprm3eHTZXHACjc76HDYFGYvMLuiw9+mohfW92aTZoN5CzZWhsa3oUK78VxX1N0d MlGCSQ2ECkBz83Ns+ZI9aKuhUL48Gsl+am9IsNk8w1xCNRKouTiA6WJwITGU4NnhsyHN 51ciuru7ddOQ7r/gvgBag2UokPMP47KXA17jjzOU8GuoOdkT9AHZtRYZIhMnz+Qov3YR u9ANS7LBWtjdnfEfHCY2uBB9YGebOjiZ5JERyUBWIXeYEI0q0TmHI2r+g9i9xAglKkjo Ta/V2Ic6tMOCJl2i4Cd2MYPLPVhb9xMwEAKsj4qVeQdHkr8iYBYDNVOsClPajl/KWBEE EdIg== 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 by8si9036927ejb.129.2019.07.15.01.46.41; Mon, 15 Jul 2019 01:46:41 -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 F03B31B9DF; Mon, 15 Jul 2019 10:46:13 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id BC9331B94F for ; Mon, 15 Jul 2019 10:46:05 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 9F1E920000E; Mon, 15 Jul 2019 10:46:05 +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 46D8E2001A6; Mon, 15 Jul 2019 10:46:03 +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 2D006402B5; Mon, 15 Jul 2019 16:46:00 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: thomas@monjalon.net, Sachin Saxena Date: Mon, 15 Jul 2019 14:14:42 +0530 Message-Id: <20190715084442.14686-6-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190715084442.14686-1-hemant.agrawal@nxp.com> References: <20190627093343.5171-2-hemant.agrawal@nxp.com> <20190715084442.14686-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 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 This patch help in adding a routine to help memory map the user provided memory via VFIO. Signed-off-by: Sachin Saxena --- drivers/bus/fslmc/fslmc_vfio.c | 39 +++++++++++++++++++++ drivers/bus/fslmc/fslmc_vfio.h | 5 ++- drivers/bus/fslmc/rte_bus_fslmc_version.map | 6 ++++ drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 13 +++++++ 4 files changed, 62 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 1383af4f1..247b2a4a1 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; } +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..4132f1fa4 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,8 @@ 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);