From patchwork Tue Jan 9 13:22:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 123947 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4019974qgn; Tue, 9 Jan 2018 05:25:46 -0800 (PST) X-Google-Smtp-Source: ACJfBosaiPnRLljdIUDCkXnHGI1dHN5O4ANxwN3Jy8PfvNlsy5yb7hDON3JSTKekNZh6p2XQFvby X-Received: by 10.28.139.5 with SMTP id n5mr11515628wmd.23.1515504346811; Tue, 09 Jan 2018 05:25:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515504346; cv=none; d=google.com; s=arc-20160816; b=WRjJfVvV83oxv/JMuU0/aIhmvFRsmdmExvhldEtsvKLp6DDtbncVwEgiB8l/YNjYAp btNSXczXIWXgS8IsYpLlgcl2JJ69ShLwJlRz3a4+kgPSoXeBjXeEt3CuHmvzefVeSI92 yEsKMbNu8rnxR3BCGENVsM0Dbbb6tjz+M/BoMm1O+9TePZUOO+ql7vn5Q7Kj4c9hT6OE jpInmgK7CwMLd0vNfUhnx85zKai0NDNPMFEdUeUmAj8c9X26zpJzLdXA/UmlQ/4fczky pbpZYxbjw5AEtSAWv54kXxH8svdN7OdtWeF1bAO/+Xsn6rBQJGXc8piiybRTA4g7hJE7 yPnA== 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:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=V7rp6wNF3NNatQqorQnGLtza0gxG9pkOL7ZByVMe1CQ=; b=mEqIzUDl4+YpiUW6BI5hmmTEevW528xdHHff7JL2U89/HFnJDE7XiN88kyS8v5HpT6 LWKebjJ+tEopv20bd7lvL4F6cz3K5S74AhlQpHK1y8FR/FepJ6ThrEzUf3rs8GxJIRA9 pVygO+2RGZwLF1QuU8YXU0g5Uqmnrm7XFDI26kqssV4ywwOjBfpYBKZd+88NC3IK0EAP 4WWm7Va9LLQg6SNq7rss/5zHPXlQmCPrDcVBeVa5iTGQ89quzTpOAsNvNitVbnld1sol Q62eylLYesOtUnGXhR4RFQzy9V1Rhmbnutp3x6D9Br6Ya0HHawpftJ42pNWym1nLCaCZ 22DA== 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 f13si9453321wme.12.2018.01.09.05.25.46; Tue, 09 Jan 2018 05:25:46 -0800 (PST) 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 38B471B1DA; Tue, 9 Jan 2018 14:24:37 +0100 (CET) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0085.outbound.protection.outlook.com [104.47.42.85]) by dpdk.org (Postfix) with ESMTP id 7B21A1B1E4 for ; Tue, 9 Jan 2018 14:24:34 +0100 (CET) Received: from MWHPR03CA0038.namprd03.prod.outlook.com (10.174.173.155) by BN3PR03MB2354.namprd03.prod.outlook.com (10.166.74.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Tue, 9 Jan 2018 13:24:32 +0000 Received: from BN1BFFO11FD012.protection.gbl (2a01:111:f400:7c10::1:174) by MWHPR03CA0038.outlook.office365.com (2603:10b6:301:3b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.386.5 via Frontend Transport; Tue, 9 Jan 2018 13:24:31 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; NXP1.onmicrosoft.com; dkim=none (message not signed) header.d=none;NXP1.onmicrosoft.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD012.mail.protection.outlook.com (10.58.144.75) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Tue, 9 Jan 2018 13:24:00 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w09DOAVq017638; Tue, 9 Jan 2018 06:24:29 -0700 From: Hemant Agrawal To: CC: , Date: Tue, 9 Jan 2018 18:52:56 +0530 Message-ID: <1515504186-13587-9-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515504186-13587-1-git-send-email-hemant.agrawal@nxp.com> References: <1513166759-13466-1-git-send-email-hemant.agrawal@nxp.com> <1515504186-13587-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131599778411114696; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39380400002)(346002)(396003)(39860400002)(376002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(296002)(305945005)(68736007)(498600001)(4326008)(16586007)(8936002)(77096006)(316002)(356003)(50226002)(81166006)(59450400001)(86362001)(106466001)(81156014)(36756003)(105606002)(8676002)(47776003)(2351001)(104016004)(6666003)(2906002)(5660300001)(54906003)(53936002)(575784001)(8656006)(76176011)(2950100002)(50466002)(48376002)(6916009)(85426001)(97736004)(51416003)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2354; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD012; 1:Hax4T7MQstKLcl2wxTkbTRXzR1PY346GjXaEN3L8BobFvMqp+Y59h6GsR3GEKV8cHNK5TVxBlZLCerN9UbAc/6K7kzrtQQ+trdB0mJ6cSQyylWzzSPqzT0g6yEa24lao MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 182629dc-4301-440f-f0c8-08d557643f2d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307); SRVR:BN3PR03MB2354; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2354; 3:rn6tbIXUsYmdMrbRbH9YX+7iqzs1gZxlIBXOXHUijU4iha7eOIjvfeJAXlgBN15Y2P3Y25WvqH7CH21gmG0n4nAG876igVX0mGkDziKE+KjyR8SUHQ7xSoICJX9VI15ZJm+UJzeS0GaCUhLrPap7ErkjWrxyu9xGLUtYTCAbxVrD1G8M7oPQdsp99MyqI7Vu8fUU2xCDYTiAoLSAZOQeKxvsIrh91z5yuiaGgrcXzw1XKf4b+o7fRYhBltwuRtGsY/hMZxYz1wrCs/RpF/JNqolad3mAVfPQFAMI+g4sUSwB2lTF6YnuaE+Z706z/8Th1EbuNEPGtPr6YzKcuXHJli/J5Qe+50/mcnFQ+JhzPoc=; 25:yxP7eSHKXd9Vjlsp3Kq1Xmm0Xb475xMqK7vAdTWzMv+5kclCH/ztQsgjINHjGFF1arn4oL1V/+dtS/wQFgmUiwRsLsN1egHXJabJ/BxRcWBJ/Uzw/KdSP+PLpK15ELk72jfPUY6FBOeftp0YhWRMEerLOUnxj0TjPTuwnrSuepR/5RsdNezGQ8XZVCIhIxg599DiW3Pol3HmBGyu211kWK6vMmvOvxJGFhaiP2pQOZ74JjFwCEIuOn0PYQOxlyljSJdE395qC9OzXfyR39nDeL12jTWVVJY5CV0TFcYYfaDs0rk4o78vlqtd0kbsKi3Fhbjk8xIwqmR8s6zlx6b8iA== X-MS-TrafficTypeDiagnostic: BN3PR03MB2354: X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2354; 31:XxoGjeGQNa80CdRM97xWedmY6TH3563p0tVYTxcFZi657hxYaGCZNbKhcdc/bzppl6XwM6BztiFJExbV39MnfpixQbFowfYVndPiUJrZiRqQ1CbDDw54yjZhkLFbFc3GVHEEm6cJ6aqi4sVAmRk7vI8y0sKQGOVfTXxEqe50NZyhmjnbEGQAOBQ8FmZEJfqx+9pnKWMRJ8TKbXWMz71TL8ElBblDiI4HEjPp8XlhQcs=; 4:V4VT/sceaykbCSwLoiVAw1HXpz53xL2WHDymasPnAfFMBUGobiDIAw8rwmP/Cq0AMTh1/Yii54OPjdAuMAr4Ea6GMMYImIISf0kBjFQwC5S+N0AS9xPh7VjpSv4eOkiRid3JU8w8fdr0WErlWlU1wOndlWiVhw/Up93LRJrWYsfJiB6Pn1rryEq6o06sKxYAFjUMG7ceycULpFKfO7IF7v3PZbd6ssGx0cUurakZI0R1nzCK8obV4SyT2kRtF1eF3N/eYfDPNUtPqeGW45iBdA655LX49/2RfO3Xid3fPh0w/6qxwXkU9c/nvbTD1oq/yQx4w6h+7Afem9cD8H34/bhQaEMcE/inXviYzS+eJgkY0TYaF2cjL2UNfRINePsO X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(227817650892897)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231023)(944510075)(944921075)(946801075)(946901075)(6055026)(6096035)(20161123561025)(201703131430075)(201703131520075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123565025)(20161123563025)(20161123559100)(20161123556025)(201708071742011); SRVR:BN3PR03MB2354; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BN3PR03MB2354; X-Forefront-PRVS: 0547116B72 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB2354; 23:V1P7Z0kKv/pkGNeh0eKNkSw/XZ3iHnkWAt/lePNCx?= g3iFAdGIKA6kzo7YM2nOIKvdkIo84drjDevRe+PAwN+wF94lFEkBuTzDLjbZ2At5FTQoIwKgEHQiw6vAo2bBdgHVI7DyR7967Qlbas0pdQXu7ErjzkS+qo9uSLA6LITEC38Im87nroqItmYPPctsUO3AWlgMRzeAD6TFSQLAaOqIMa/JjcOOpa3GJLaZXGAmbl0RMu707GSzIEvkKmsl9oLz9JXsJ32TIJDT9gXs6JgVo+6Oh8tqvyF2tYMO4KnWGR3t2DBiULVT58ti4sWQzsZwiaZL2m4UZb08LBnEQbvvM0NjqJ23lKOUfG1Tx1ZZztsdzr0D27DyoDQM7bcDYPRPvK6/Ft8UvD4YuecuyrJT33QfBFpT7Wtbyut4YoC+6pOhBl7BCugyi40q352WFnI0PewnQa0LK99rCOpnO470a1FiMaZKzFm0qHNs6u1NqoF6q5uVfzS9ka01HOPmnAK1dy0MN82G4uB6ROfsMxnHRCZBZkuuDO3mcQxCzhhUyOAotXPSIbfKY7qm6OI/trKi0eAnm9+u1eE+FV577zfbuqTrblq79jD7opfe/3372PFKfj0dPLDJZocYe6/Jyn93yKr6zAGOMLNE4gNxoF3i7bPM6fOZSfgw0tpnwVn+fhFzxWk7BE9DTPpGJAWwfUZGN3TkLWFOJURNMcSZHtuP4affJnkOOdU2Ik9epEjYmf7QUWRSJK0x6YqxzPWBorDlPcP4zZAHGheVdP7tTxxR2/tYGNxigjbYl9KW73DPz7dEo6TmATTklGNZoslwJKBheQGZYKBaUxPHHlnYDvnAgLcRjxT3ZJ7BaCaXdksnqMPzuGsdxyENtvLbQICocVbZySMqMjC0pZUPSWuSEuDEsBXoZeV/toyA7yhmaECMntFymQzWL+evjxG6dd+DvcaQPqMbdnZRTolb9fXmn6xhJNe96rLb71v15FrJCfOxggSuYp9VWAkxUx+IPT2nRA8x5DOUSxucfly2r/O01n9yoUU+OMupcUpE5SGA18OV0ElFr3sVaE3KcY3xh0Pvy5IEecQBHX2Rb4oi4dQxlkAmKY0NkpEHmJlpgNyPyESIjR0mA7eSl9ccpoQjvc77gU9tWe9PY1pHwcJ8DaCN4Ur9A== X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2354; 6:dNKBzilk9LPunZSYff+Cpa2fxi6TfZxhB+aTACD6/VNiIHUhkHkuwztGF/ui6/39/9bb9TcrbmgNSEr7w6eEVMqIQk1dFIIagfP1zfTcfDtPGUnh+NbQolKuE6OoMajDUKhbemNg0FxawFY6qigI4bPm6R/fWgVK4Zfv1rcz3zfNfcRq+fh9mfzNbehLtgmWe0ZamQSAL/bRdIVtRHRGnspsxPHe+UHAjO2QHI6N1fG/zvk64w7B+gvLViKLYBBhzQl7bkkFLF7xv8qjpsoW1eB0XbgpmNQp1rYgndCpapavnMl+cVX0HGyNRfcxabGyZwQ2iSYlqC1rkh7ablwEaSzMBTXHesBT3Tc0/mX96Ls=; 5:5Fg8G/hQPR3n4TzcATcRQLfHx7FthoZMa8mbY4LHbVc+coZLuSsnJqpDc/dHhgZmde47WrwTAyMvOl/GODVCXs7SK916IY6tqVxzvpwSzrr29i8sP8favOfDP8bXaN/6uxcfTtxhbJXnPm2wtbT7aOmCuWB4/9Y9VxWSSxWRMq8=; 24:4SDDAmKyevrCVI4sYus79w3XjAK6d0bf4Qv2bT83iszqy+ZmlLDraZil5N3M9270KVm/LDvwS3iKAx0GSIeKZX5Pkg7pTrT7RqJhWvG/eVQ=; 7:+c8XIPfej8Juv66th29xfWNhsLGft3qGxMSafE/3BjYB1HypYeVn+QTueYRvipg7cmDkVPDg2hqBuJmNVZ1DUJCbJzaPAFm6HZ/5yFmgL+k5MEwOj/0iiYtdtaDdnD/0zQ9mIWAGVMWM2Tb5mElHxP8uo+Vf95EYy9I5M8V05DViQuSx6wRN0LbJOH+y3DLtT5wje9v/yxHTC+m8XDU2Bsvyyaw6M+WdSrOwkiNVV4O2ERgtN7cg2HZp0iOQPFNp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2018 13:24:00.9398 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 182629dc-4301-440f-f0c8-08d557643f2d X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB2354 Subject: [dpdk-dev] [PATCH v2 08/18] bus/dpaa: add support to create dynamic HW portal 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" HW portal is a processing context in DPAA. This patch allow creation of a queue specific HW portal context. Signed-off-by: Hemant Agrawal --- drivers/bus/dpaa/base/qbman/qman.c | 69 ++++++++++++-- drivers/bus/dpaa/base/qbman/qman_driver.c | 153 +++++++++++++++++++++++++----- drivers/bus/dpaa/base/qbman/qman_priv.h | 6 +- drivers/bus/dpaa/dpaa_bus.c | 31 +++++- drivers/bus/dpaa/include/fsl_qman.h | 25 ++--- drivers/bus/dpaa/include/fsl_usd.h | 4 + drivers/bus/dpaa/include/process.h | 11 ++- drivers/bus/dpaa/rte_bus_dpaa_version.map | 2 + drivers/bus/dpaa/rte_dpaa_bus.h | 4 + 9 files changed, 252 insertions(+), 53 deletions(-) -- 2.7.4 diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c index b6fd40b..d8fb25a 100644 --- a/drivers/bus/dpaa/base/qbman/qman.c +++ b/drivers/bus/dpaa/base/qbman/qman.c @@ -621,11 +621,52 @@ struct qman_portal *qman_create_portal( return NULL; } +#define MAX_GLOBAL_PORTALS 8 +static struct qman_portal global_portals[MAX_GLOBAL_PORTALS]; +static int global_portals_used[MAX_GLOBAL_PORTALS]; + +static struct qman_portal * +qman_alloc_global_portal(void) +{ + unsigned int i; + + for (i = 0; i < MAX_GLOBAL_PORTALS; i++) { + if (global_portals_used[i] == 0) { + global_portals_used[i] = 1; + return &global_portals[i]; + } + } + pr_err("No portal available (%x)\n", MAX_GLOBAL_PORTALS); + + return NULL; +} + +static int +qman_free_global_portal(struct qman_portal *portal) +{ + unsigned int i; + + for (i = 0; i < MAX_GLOBAL_PORTALS; i++) { + if (&global_portals[i] == portal) { + global_portals_used[i] = 0; + return 0; + } + } + return -1; +} + struct qman_portal *qman_create_affine_portal(const struct qm_portal_config *c, - const struct qman_cgrs *cgrs) + const struct qman_cgrs *cgrs, + int alloc) { struct qman_portal *res; - struct qman_portal *portal = get_affine_portal(); + struct qman_portal *portal; + + if (alloc) + portal = qman_alloc_global_portal(); + else + portal = get_affine_portal(); + /* A criteria for calling this function (from qman_driver.c) is that * we're already affine to the cpu and won't schedule onto another cpu. */ @@ -675,13 +716,18 @@ void qman_destroy_portal(struct qman_portal *qm) spin_lock_destroy(&qm->cgr_lock); } -const struct qm_portal_config *qman_destroy_affine_portal(void) +const struct qm_portal_config * +qman_destroy_affine_portal(struct qman_portal *qp) { /* We don't want to redirect if we're a slave, use "raw" */ - struct qman_portal *qm = get_affine_portal(); + struct qman_portal *qm; const struct qm_portal_config *pcfg; int cpu; + if (qp == NULL) + qm = get_affine_portal(); + else + qm = qp; pcfg = qm->config; cpu = pcfg->cpu; @@ -690,6 +736,9 @@ const struct qm_portal_config *qman_destroy_affine_portal(void) spin_lock(&affine_mask_lock); CPU_CLR(cpu, &affine_mask); spin_unlock(&affine_mask_lock); + + qman_free_global_portal(qm); + return pcfg; } @@ -1096,27 +1145,27 @@ void qman_start_dequeues(void) qm_dqrr_set_maxfill(&p->p, DQRR_MAXFILL); } -void qman_static_dequeue_add(u32 pools) +void qman_static_dequeue_add(u32 pools, struct qman_portal *qp) { - struct qman_portal *p = get_affine_portal(); + struct qman_portal *p = qp ? qp : get_affine_portal(); pools &= p->config->pools; p->sdqcr |= pools; qm_dqrr_sdqcr_set(&p->p, p->sdqcr); } -void qman_static_dequeue_del(u32 pools) +void qman_static_dequeue_del(u32 pools, struct qman_portal *qp) { - struct qman_portal *p = get_affine_portal(); + struct qman_portal *p = qp ? qp : get_affine_portal(); pools &= p->config->pools; p->sdqcr &= ~pools; qm_dqrr_sdqcr_set(&p->p, p->sdqcr); } -u32 qman_static_dequeue_get(void) +u32 qman_static_dequeue_get(struct qman_portal *qp) { - struct qman_portal *p = get_affine_portal(); + struct qman_portal *p = qp ? qp : get_affine_portal(); return p->sdqcr; } diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c index c17d15f..7cfa8ee 100644 --- a/drivers/bus/dpaa/base/qbman/qman_driver.c +++ b/drivers/bus/dpaa/base/qbman/qman_driver.c @@ -24,8 +24,8 @@ void *qman_ccsr_map; /* The qman clock frequency */ u32 qman_clk; -static __thread int fd = -1; -static __thread struct qm_portal_config pcfg; +static __thread int qmfd = -1; +static __thread struct qm_portal_config qpcfg; static __thread struct dpaa_ioctl_portal_map map = { .type = dpaa_portal_qman }; @@ -44,16 +44,16 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared) error(0, ret, "pthread_getaffinity_np()"); return ret; } - pcfg.cpu = -1; + qpcfg.cpu = -1; for (loop = 0; loop < CPU_SETSIZE; loop++) if (CPU_ISSET(loop, &cpuset)) { - if (pcfg.cpu != -1) { + if (qpcfg.cpu != -1) { pr_err("Thread is not affine to 1 cpu\n"); return -EINVAL; } - pcfg.cpu = loop; + qpcfg.cpu = loop; } - if (pcfg.cpu == -1) { + if (qpcfg.cpu == -1) { pr_err("Bug in getaffinity handling!\n"); return -EINVAL; } @@ -65,36 +65,36 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared) error(0, ret, "process_portal_map()"); return ret; } - pcfg.channel = map.channel; - pcfg.pools = map.pools; - pcfg.index = map.index; + qpcfg.channel = map.channel; + qpcfg.pools = map.pools; + qpcfg.index = map.index; /* Make the portal's cache-[enabled|inhibited] regions */ - pcfg.addr_virt[DPAA_PORTAL_CE] = map.addr.cena; - pcfg.addr_virt[DPAA_PORTAL_CI] = map.addr.cinh; + qpcfg.addr_virt[DPAA_PORTAL_CE] = map.addr.cena; + qpcfg.addr_virt[DPAA_PORTAL_CI] = map.addr.cinh; - fd = open(QMAN_PORTAL_IRQ_PATH, O_RDONLY); - if (fd == -1) { + qmfd = open(QMAN_PORTAL_IRQ_PATH, O_RDONLY); + if (qmfd == -1) { pr_err("QMan irq init failed\n"); process_portal_unmap(&map.addr); return -EBUSY; } - pcfg.is_shared = is_shared; - pcfg.node = NULL; - pcfg.irq = fd; + qpcfg.is_shared = is_shared; + qpcfg.node = NULL; + qpcfg.irq = qmfd; - portal = qman_create_affine_portal(&pcfg, NULL); + portal = qman_create_affine_portal(&qpcfg, NULL, 0); if (!portal) { pr_err("Qman portal initialisation failed (%d)\n", - pcfg.cpu); + qpcfg.cpu); process_portal_unmap(&map.addr); return -EBUSY; } irq_map.type = dpaa_portal_qman; irq_map.portal_cinh = map.addr.cinh; - process_portal_irq_map(fd, &irq_map); + process_portal_irq_map(qmfd, &irq_map); return 0; } @@ -103,10 +103,10 @@ static int fsl_qman_portal_finish(void) __maybe_unused const struct qm_portal_config *cfg; int ret; - process_portal_irq_unmap(fd); + process_portal_irq_unmap(qmfd); - cfg = qman_destroy_affine_portal(); - DPAA_BUG_ON(cfg != &pcfg); + cfg = qman_destroy_affine_portal(NULL); + DPAA_BUG_ON(cfg != &qpcfg); ret = process_portal_unmap(&map.addr); if (ret) error(0, ret, "process_portal_unmap()"); @@ -128,14 +128,119 @@ int qman_thread_finish(void) void qman_thread_irq(void) { - qbman_invoke_irq(pcfg.irq); + qbman_invoke_irq(qpcfg.irq); /* Now we need to uninhibit interrupts. This is the only code outside * the regular portal driver that manipulates any portal register, so * rather than breaking that encapsulation I am simply hard-coding the * offset to the inhibit register here. */ - out_be32(pcfg.addr_virt[DPAA_PORTAL_CI] + 0xe0c, 0); + out_be32(qpcfg.addr_virt[DPAA_PORTAL_CI] + 0xe0c, 0); +} + +struct qman_portal *fsl_qman_portal_create(void) +{ + cpu_set_t cpuset; + struct qman_portal *res; + + struct qm_portal_config *q_pcfg; + int loop, ret; + struct dpaa_ioctl_irq_map irq_map; + struct dpaa_ioctl_portal_map q_map = {0}; + int q_fd; + + q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0); + if (!q_pcfg) { + error(0, -1, "q_pcfg kzalloc failed"); + return NULL; + } + + /* Verify the thread's cpu-affinity */ + ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), + &cpuset); + if (ret) { + error(0, ret, "pthread_getaffinity_np()"); + return NULL; + } + + q_pcfg->cpu = -1; + for (loop = 0; loop < CPU_SETSIZE; loop++) + if (CPU_ISSET(loop, &cpuset)) { + if (q_pcfg->cpu != -1) { + pr_err("Thread is not affine to 1 cpu\n"); + return NULL; + } + q_pcfg->cpu = loop; + } + if (q_pcfg->cpu == -1) { + pr_err("Bug in getaffinity handling!\n"); + return NULL; + } + + /* Allocate and map a qman portal */ + q_map.type = dpaa_portal_qman; + q_map.index = QBMAN_ANY_PORTAL_IDX; + ret = process_portal_map(&q_map); + if (ret) { + error(0, ret, "process_portal_map()"); + return NULL; + } + q_pcfg->channel = q_map.channel; + q_pcfg->pools = q_map.pools; + q_pcfg->index = q_map.index; + + /* Make the portal's cache-[enabled|inhibited] regions */ + q_pcfg->addr_virt[DPAA_PORTAL_CE] = q_map.addr.cena; + q_pcfg->addr_virt[DPAA_PORTAL_CI] = q_map.addr.cinh; + + q_fd = open(QMAN_PORTAL_IRQ_PATH, O_RDONLY); + if (q_fd == -1) { + pr_err("QMan irq init failed\n"); + goto err1; + } + + q_pcfg->irq = q_fd; + + res = qman_create_affine_portal(q_pcfg, NULL, true); + if (!res) { + pr_err("Qman portal initialisation failed (%d)\n", + q_pcfg->cpu); + goto err2; + } + + irq_map.type = dpaa_portal_qman; + irq_map.portal_cinh = q_map.addr.cinh; + process_portal_irq_map(q_fd, &irq_map); + + return res; +err2: + close(q_fd); +err1: + process_portal_unmap(&q_map.addr); + return NULL; +} + +int fsl_qman_portal_destroy(struct qman_portal *qp) +{ + const struct qm_portal_config *cfg; + struct dpaa_portal_map addr; + int ret; + + cfg = qman_destroy_affine_portal(qp); + kfree(qp); + + process_portal_irq_unmap(cfg->irq); + + addr.cena = cfg->addr_virt[DPAA_PORTAL_CE]; + addr.cinh = cfg->addr_virt[DPAA_PORTAL_CI]; + + ret = process_portal_unmap(&addr); + if (ret) + pr_err("process_portal_unmap() (%d)\n", ret); + + kfree((void *)cfg); + + return ret; } int qman_global_init(void) diff --git a/drivers/bus/dpaa/base/qbman/qman_priv.h b/drivers/bus/dpaa/base/qbman/qman_priv.h index db0b310..9e4471e 100644 --- a/drivers/bus/dpaa/base/qbman/qman_priv.h +++ b/drivers/bus/dpaa/base/qbman/qman_priv.h @@ -146,8 +146,10 @@ int qm_get_wpm(int *wpm); struct qman_portal *qman_create_affine_portal( const struct qm_portal_config *config, - const struct qman_cgrs *cgrs); -const struct qm_portal_config *qman_destroy_affine_portal(void); + const struct qman_cgrs *cgrs, + int alloc); +const struct qm_portal_config * +qman_destroy_affine_portal(struct qman_portal *q); struct qm_portal_config *qm_get_unused_portal(void); struct qm_portal_config *qm_get_unused_portal_idx(uint32_t idx); diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index a7c05b3..329a125 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -264,8 +264,7 @@ _dpaa_portal_init(void *arg) * rte_dpaa_portal_init - Wrapper over _dpaa_portal_init with thread level check * XXX Complete this */ -int -rte_dpaa_portal_init(void *arg) +int rte_dpaa_portal_init(void *arg) { if (unlikely(!RTE_PER_LCORE(_dpaa_io))) return _dpaa_portal_init(arg); @@ -273,6 +272,34 @@ rte_dpaa_portal_init(void *arg) return 0; } +int +rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq) +{ + /* Affine above created portal with channel*/ + u32 sdqcr; + struct qman_portal *qp; + + if (unlikely(!RTE_PER_LCORE(_dpaa_io))) + _dpaa_portal_init(arg); + + /* Initialise qman specific portals */ + qp = fsl_qman_portal_create(); + if (!qp) { + DPAA_BUS_LOG(ERR, "Unable to alloc fq portal"); + return -1; + } + fq->qp = qp; + sdqcr = QM_SDQCR_CHANNELS_POOL_CONV(fq->ch_id); + qman_static_dequeue_add(sdqcr, qp); + + return 0; +} + +int rte_dpaa_portal_fq_close(struct qman_fq *fq) +{ + return fsl_qman_portal_destroy(fq->qp); +} + void dpaa_portal_finish(void *arg) { diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h index 5027230..fc00d8d 100644 --- a/drivers/bus/dpaa/include/fsl_qman.h +++ b/drivers/bus/dpaa/include/fsl_qman.h @@ -1190,21 +1190,24 @@ struct qman_fq_cb { struct qman_fq { /* Caller of qman_create_fq() provides these demux callbacks */ struct qman_fq_cb cb; - /* - * These are internal to the driver, don't touch. In particular, they - * may change, be removed, or extended (so you shouldn't rely on - * sizeof(qman_fq) being a constant). - */ - spinlock_t fqlock; - u32 fqid; + u32 fqid_le; + u16 ch_id; + u8 cgr_groupid; + u8 is_static; /* DPDK Interface */ void *dpaa_intf; + /* affined portal in case of static queue */ + struct qman_portal *qp; + volatile unsigned long flags; + enum qman_fq_state state; - int cgr_groupid; + u32 fqid; + spinlock_t fqlock; + struct rb_node node; #ifdef CONFIG_FSL_QMAN_FQ_LOOKUP u32 key; @@ -1383,7 +1386,7 @@ void qman_start_dequeues(void); * (SDQCR). The requested pools are limited to those the portal has dequeue * access to. */ -void qman_static_dequeue_add(u32 pools); +void qman_static_dequeue_add(u32 pools, struct qman_portal *qm); /** * qman_static_dequeue_del - Remove pool channels from the portal SDQCR @@ -1393,7 +1396,7 @@ void qman_static_dequeue_add(u32 pools); * register (SDQCR). The requested pools are limited to those the portal has * dequeue access to. */ -void qman_static_dequeue_del(u32 pools); +void qman_static_dequeue_del(u32 pools, struct qman_portal *qp); /** * qman_static_dequeue_get - return the portal's current SDQCR @@ -1402,7 +1405,7 @@ void qman_static_dequeue_del(u32 pools); * entire register is returned, so if only the currently-enabled pool channels * are desired, mask the return value with QM_SDQCR_CHANNELS_POOL_MASK. */ -u32 qman_static_dequeue_get(void); +u32 qman_static_dequeue_get(struct qman_portal *qp); /** * qman_dca - Perform a Discrete Consumption Acknowledgment diff --git a/drivers/bus/dpaa/include/fsl_usd.h b/drivers/bus/dpaa/include/fsl_usd.h index ada92f2..e183617 100644 --- a/drivers/bus/dpaa/include/fsl_usd.h +++ b/drivers/bus/dpaa/include/fsl_usd.h @@ -67,6 +67,10 @@ void bman_thread_irq(void); int qman_global_init(void); int bman_global_init(void); +/* Direct portal create and destroy */ +struct qman_portal *fsl_qman_portal_create(void); +int fsl_qman_portal_destroy(struct qman_portal *qp); + #ifdef __cplusplus } #endif diff --git a/drivers/bus/dpaa/include/process.h b/drivers/bus/dpaa/include/process.h index 079849b..d9ec94e 100644 --- a/drivers/bus/dpaa/include/process.h +++ b/drivers/bus/dpaa/include/process.h @@ -39,6 +39,11 @@ enum dpaa_portal_type { dpaa_portal_bman, }; +struct dpaa_portal_map { + void *cinh; + void *cena; +}; + struct dpaa_ioctl_portal_map { /* Input parameter, is a qman or bman portal required. */ enum dpaa_portal_type type; @@ -50,10 +55,8 @@ struct dpaa_ioctl_portal_map { /* Return value if the map succeeds, this gives the mapped * cache-inhibited (cinh) and cache-enabled (cena) addresses. */ - struct dpaa_portal_map { - void *cinh; - void *cena; - } addr; + struct dpaa_portal_map addr; + /* Qman-specific return values */ u16 channel; uint32_t pools; diff --git a/drivers/bus/dpaa/rte_bus_dpaa_version.map b/drivers/bus/dpaa/rte_bus_dpaa_version.map index f412362..4e3afda 100644 --- a/drivers/bus/dpaa/rte_bus_dpaa_version.map +++ b/drivers/bus/dpaa/rte_bus_dpaa_version.map @@ -74,6 +74,8 @@ DPDK_18.02 { qman_delete_cgr; qman_modify_cgr; qman_release_cgrid_range; + rte_dpaa_portal_fq_close; + rte_dpaa_portal_fq_init; local: *; } DPDK_17.11; diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index d9e8c84..f626066 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -136,6 +136,10 @@ void rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver); */ int rte_dpaa_portal_init(void *arg); +int rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq); + +int rte_dpaa_portal_fq_close(struct qman_fq *fq); + /** * Cleanup a DPAA Portal */