From patchwork Wed Dec 13 12:05:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 121747 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5384141qgn; Wed, 13 Dec 2017 04:08:46 -0800 (PST) X-Google-Smtp-Source: ACJfBos06cGswzjkh7XXlzMaszhvDWatXzKhv03j192cjIpvzQFBafE9gJM29omh5b8nQt0Y5Pme X-Received: by 10.223.199.70 with SMTP id b6mr2251757wrh.25.1513166926063; Wed, 13 Dec 2017 04:08:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513166926; cv=none; d=google.com; s=arc-20160816; b=eTegUk7huoMWu8pkKfLAJsw6nQ0cpHWF/zrKvp0qJ8avd57+uZa4df0LvNmKwmR6Q4 ZzsxUMy0o8072qWICR3IhohJdDQ74LHzZu/MG6mCY0N5dnWcbV7Zs5UAnNPzTtsJOqCw BI/jfm/n5UWjjKqiQem7OfntB8dMfepbjVrLz2LvOhxovFmWn5TDqGX0wMOjVepTljMw JquBPUCZB6aOzNCS4JN2bnR1VVhCyAToITbm6bYbqS1LL6H6z6lqVeVGcxDSdB2Wd663 yt0xe6pQO/dVRnHXBZymIRmy57cAN/hpYHisCciN4hoc28sjeTu+iRk8UQdHFaf89civ WJzw== 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=mlOvF94rf8MjlqGmKX2ah08VIwnBT1lQ30jcnxpcP/E=; b=nXvCynjsBZyzWiiOPhygHK54mmmEkmNEbzaLztwPSq/HrY/V7Eko0NJp+dvNGGeOZ2 ces9ePY0krbOZPs9ZFVc/lWl0l8gtnu28U9XwGdpObPVY1ivdSIA7qdF0eKcv/M8304H zr4HDWQrV+YcGWUCjqlt8/REAJcNUvRYQlD1oopxyBp3N3l5mA6/PxWnX/qg708Vezsz G4dGGmV7kesy08di0f/3yGZdRjpi1wWkZTY06Doo1dbVGXWj6MLdnAQxJqQoeZql5uca 1e/De74d+Y66FgkBWzcjnsgEkSxeilTzeFWhemARidxn9hCsaWp873oTHekeZ15Xcqma Glhw== 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 q14si1284955wrd.153.2017.12.13.04.08.45; Wed, 13 Dec 2017 04:08: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 435E21B1A0; Wed, 13 Dec 2017 13:07:19 +0100 (CET) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0061.outbound.protection.outlook.com [104.47.42.61]) by dpdk.org (Postfix) with ESMTP id ABCF71B195 for ; Wed, 13 Dec 2017 13:07:15 +0100 (CET) Received: from BN3PR03CA0098.namprd03.prod.outlook.com (10.174.66.16) by DM5PR03MB2697.namprd03.prod.outlook.com (10.168.197.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Wed, 13 Dec 2017 12:07:14 +0000 Received: from BL2FFO11FD005.protection.gbl (2a01:111:f400:7c09::123) by BN3PR03CA0098.outlook.office365.com (2603:10b6:400:4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.302.9 via Frontend Transport; Wed, 13 Dec 2017 12:07:13 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; intel.com; dkim=none (message not signed) header.d=none; intel.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 BL2FFO11FD005.mail.protection.outlook.com (10.173.161.1) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.282.5 via Frontend Transport; Wed, 13 Dec 2017 12:07:06 +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 vBDC6t9T008652; Wed, 13 Dec 2017 05:07:11 -0700 From: Hemant Agrawal To: CC: Date: Wed, 13 Dec 2017 17:35:50 +0530 Message-ID: <1513166759-13466-10-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513166759-13466-1-git-send-email-hemant.agrawal@nxp.com> References: <1513166759-13466-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131576404264597916; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(336005)(376002)(346002)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(3190300001)(189003)(199004)(86362001)(2906002)(81166006)(305945005)(356003)(5660300001)(36756003)(498600001)(81156014)(6666003)(76176011)(316002)(6916009)(16586007)(2950100002)(8676002)(4326008)(105606002)(2351001)(68736007)(51416003)(575784001)(8936002)(106466001)(50226002)(77096006)(50466002)(85426001)(59450400001)(104016004)(97736004)(48376002)(47776003)(53936002)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2697; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD005; 1:RDw0QLowUKF4SiFXdVKIq3BsIfNiIz5LFl1XkNz2HaSjznyWzMFtvdjcbPpdXMDYsn1aVIknGuJq3vb3z0Qb36zGABQk32R5B2NzIkBYjj8CzQZfmfr4Duo+5xwxzr0g MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b3efe9df-2fe0-4e1a-583b-08d542220778 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307); SRVR:DM5PR03MB2697; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2697; 3:eeR2FL6UzgVr9l+5EzVW6cHguhtOx5K4nuQLKVmeavXbGvNIKPSFb58jkpHwJspE6j3O8lFbv72EHugCCEqgWeg8X8UaR2MvR7L+72d/dEuEAtiRabllm/6c4P6egCIrHclZtz7xKdcrGBB4ANf80tHFp8euQ+81mk9V6uJbkIscF3oDT5y1RX/uuArN8qhbGl0gTYmux3PLNNyj0o0HMF50LCQUf+rpFnldMfZt50GOb9JX8k9g7829hFYdbW/CijvSuZbUsxlpp+NLeXQfHvNijDFGs1aOHtcIEB6DXyofxobMgkrEpNk9TBz76wu09nAMY+LH5mjmmD/8W/EqOYU+dQ/Vy72AhHAv8Tc2Mx0=; 25:LYKb4O+R9vnaetSKc214ASIGR3bRciwekq0IYCmp6fSmP6Fp2oa7rCdb/I0lXWyqUwtD9aPGi2Q+jjzbVC88Ub6fPjS6tMFmZ2cFEJMRLkEIXLkpkpr+7cFuy8mdkmOTcsCh2gOhaoB+uUts6bP6EhXBKWeKA/H8XWmBqz2pHO1UJtQ2cfYj/VFlU5Ao2Bu4Mq1z/YcCYrRX498/VXjROH9xbACjU8fcqpjmx9kM/MDmDLXNNTSXRJRgZXr3Vtg0KFVC4HSaznhIgVdvmqJvtJFKvoAYfC6qM32xu4bOK1smMbNS2I31ysJhKWzZ72WDEgqm0JcLF1nRLZwK49IjRVDeiSj+S99dkNcLJRcJmow= X-MS-TrafficTypeDiagnostic: DM5PR03MB2697: X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2697; 31:X3esc9sOJmmUJsQi1Rr+vtrbI2DOLU9pKj0qCUO/KSgoaaaNwPkSjBIercJtZyH4z86F140wWzkDVb+YYpK0EpRXoEv5hi10mvTKXlREizatJqFCDQ198irOFzLztMLdM7iGV9JAbGKM+GdLZesBUk0N5PXKrrXXTN4JvKEhHXwSyq1ev2jVDlOC1HFemAKRKlI+2JaRm7qWQVh4oEv3W0zjAXYzOzo/5l0dUfqnHSY=; 4:w25WI2izxj4k0HBa0hvLJczXJSb8XBWcsz29n3LPVRCiddauE49eDTsQIacfV9KDcuzhvQnZ0BTJ1Gwig6Gz/oEtTzhoZKWW5EcSlRF9h/0i1tDlwj1JsQvM2H+E2yes6rjbvQFhuU/41/WXzbzmxNJiPZAql9O0GC5bGGDxyr09MJT34KiwFYUYmp8j5kD6j4SvTnc61JHQoBKzqHNgXCCEUmVbRglCMem6OTxfhBiq2KJVjf0pJ4w322K+k5Z+hhWZqM1NBmwF5c2hxpgdCmo+doIuK+EqtZzdcY0eYG6sH9edTShBDump3Z97E/qX0ZtqseHRCHK9u15+w9xLSvQMGO5gIzn3R3oQAUOpo+F2hX9rX2YOLJ8W8sllvNVB 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)(3002001)(10201501046)(3231023)(93006095)(93001095)(6055026)(6096035)(20161123561025)(20161123565025)(20161123559100)(20161123556025)(20161123563025)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(201708071742011); SRVR:DM5PR03MB2697; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:DM5PR03MB2697; X-Forefront-PRVS: 052017CAF1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2697; 23:7/I+jhL1Lt/F1sb1GZGR2cUW8KA//MNG5L+yh3WEk?= VAbXrtupr/J6va4W7WafoQ/XET7vliDhTn2RZdeLTyWa27Zccv5p52t2qNQulWODOiGGfB+nU2VdAdSe2dtlO+niTxU3SewTkKnwNiWeqlnrbEa/gFnnu3x4Rbehicul5Lq/nO2xeKTfxKA7mye/JXf5JQsW8Uf5borZV04Tl0N1yBD9oQVDGODwZoN83iDfHynoBukOIXXtAwVUJsfBzEWSpM57rzx6uBSBjojxu3Mc760WGzu/ff/1sc++IgjkRxYMHspgB4sTD4LF8IAE0pr9xbiCV1E1ztv3BWlXT82//d7/bR/XwRxolBOBamNEeBjOr/s0mjla2UAspRKWLRdmp7orWN4qR7/F0qEoA+lUSMlR91QFaFyMECFBJGJRKjLfWvr9zQUoozOBbKDBZa92GIFc89XjAbzJPlJDxlv1IPvpKuv45OtZ+CcI9luibd5/8oTxRWGBbqKpYcGuRKVHMjhbIgQjYA5GsG+04xPHlhPdzlOM4jI8RVLwZ5w7V45B1QxjGEWCliuEc9GARGh80WCeNCuhMugWWywaYWly/SO03qIGzoFh9X6Wh4sPbL32TJM0VrKz1+WFD/YF9r3J3d9N3yrvJOT0RMt4HmxvrnV8Vmv5mB41nI6sHqMfm0oEX1sMSrD5djXe/pjf054YsT8yZh1oD6vIjoKgOi03OmbmzawUt/5lEBKOFJ4klsu2AsRJBWbes3twRrAY3rRmvR5slBGYotcukhqzyxoc1v1Pze1FSO3PPtkSwhPvrAWNp2KjjX+dqpjpHj4MV/693NaahbYSX1CYnjbozQRSBCJ+MPgMs1JwrWbXMzlLevjKZ+iSInFe8swLXHaw26uvpLopiPUYkp/lvW1ltYhDN5pIFYWSGPDyQcaBIOeJdAKtlLsO2iQ2Lyul84DB4vz93+2X/ZLPDyC/eZ51PERFJVlOKl9z8/CRX1H0oRLovIL9ZpT87E/TUgVkws+xxq5uCrFeToTYCnAfgWH+gcAYH8IDaDfGos06GMaa2aQ2d26rt5byQ01AUZnu3MhoZEH9mqqL2CQHeiTdvSA/C0avwkri91lZJd5BGED+Vc+nmw= X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2697; 6:xuOpqQFLEmUZh2A8DPj4HWM3EB6JDFqIbF157zBGPGnkZFN9kOb8rBmvlW6B/S0VJBed+35VsfpM7Y+y3lxdJ1Wr3tRWwB/87Fj+ng39QbR32DAj4Bpdan2z5fK0ifNA407bjLtqTkePJc72IkF98AYEAAU5jjd3n/H1Hctsq7pKR4RJNmxc5qb4cMLkKms/jGucAp5w8EyUCu7rAPvs7SZtBj4fWquSeQCOOH6dneZjijETOmTi1gluCVtPMZB4eJaFH0St1Uez2Kbt0pTGFuo976OTy+mspkR7hD0JM1yWLLn719jRaJ4YfB9l28HAOn9r2vX3flvesM5nQSfdZMhQZIqSFlKdpyJ7TZi957k=; 5:TZomrGWtrCjPSPI3+PJMclyODsYwJwxPo24DVlZjL6LqxYx7B+LHeZx/1NbpfqNVvKpDFaUexaqzFJrfhVnlnawJA9ghE3qWThjOhIl4t8z5uw1c4yCOCyvb3aMEjeworSs8wK3e+DvIie2QqJ/TBNw2aQBA6nRbMX9jYaxI670=; 24:qEwU/mGrSoqNjmA5c9y8CtCX8DjrzdzOwfofLlvLXYAJaUQDzJbsfI0suvyXA1mOhvWZD19OWYKzIq/5f7wZKSwLzgP1bYF+qBckVkxAVsE=; 7:t1J0lB8JdeYJzTZpIduwSYAzt2+1+Hy3NWLZfnleTGolJJZSU1pLSKNEhOgsPm87AVpz2uKCPu365mdB6yTHofAd/7e82uBwBZZFYcGQiVgAMsC/YVpnaPeEquMCk/oO9wVbXL7pBMipIdmuOrPSc5KUh+gVAh65l99gGgSpS3o0mjKQsJDSYVvsg629gTaUxqnmX9WoORZl0EN0lQR/7I7liPAQiyJ5wYqxYByQrtPi9kqEHeE9sJPCHdYjYPwC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2017 12:07:06.2881 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3efe9df-2fe0-4e1a-583b-08d542220778 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: DM5PR03MB2697 Subject: [dpdk-dev] [PATCH 09/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 400d920..6ae4bb3 100644 --- a/drivers/bus/dpaa/base/qbman/qman.c +++ b/drivers/bus/dpaa/base/qbman/qman.c @@ -650,11 +650,52 @@ struct qman_portal *qman_create_portal( return NULL; } +#define MAX_GLOBAL_PORTLAS 8 +static struct qman_portal global_portals[MAX_GLOBAL_PORTLAS]; +static int global_portals_used[MAX_GLOBAL_PORTLAS]; + +static struct qman_portal * +qman_alloc_global_portal(void) +{ + unsigned int i; + + for (i = 0; i < MAX_GLOBAL_PORTLAS; 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_PORTLAS); + + return NULL; +} + +static int +qman_free_global_portal(struct qman_portal *portal) +{ + unsigned int i; + + for (i = 0; i < MAX_GLOBAL_PORTLAS; 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. */ @@ -704,13 +745,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; @@ -719,6 +765,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; } @@ -1125,27 +1174,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 7a68896..f5d4b37 100644 --- a/drivers/bus/dpaa/base/qbman/qman_driver.c +++ b/drivers/bus/dpaa/base/qbman/qman_driver.c @@ -57,8 +57,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 }; @@ -77,16 +77,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; } @@ -98,36 +98,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; } @@ -136,10 +136,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()"); @@ -161,14 +161,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 3e1d7f9..e78d90b 100644 --- a/drivers/bus/dpaa/base/qbman/qman_priv.h +++ b/drivers/bus/dpaa/base/qbman/qman_priv.h @@ -179,8 +179,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 f1bc62a..8d74643 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -290,8 +290,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); @@ -299,6 +298,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 ebcfa43..c5aef2d 100644 --- a/drivers/bus/dpaa/include/fsl_qman.h +++ b/drivers/bus/dpaa/include/fsl_qman.h @@ -1223,21 +1223,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; @@ -1416,7 +1419,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 @@ -1426,7 +1429,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 @@ -1435,7 +1438,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 a3243af..038a89d 100644 --- a/drivers/bus/dpaa/include/fsl_usd.h +++ b/drivers/bus/dpaa/include/fsl_usd.h @@ -100,6 +100,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 989ddcd..352e949 100644 --- a/drivers/bus/dpaa/include/process.h +++ b/drivers/bus/dpaa/include/process.h @@ -72,6 +72,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; @@ -83,10 +88,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 40caf72..b0f7d48 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -162,6 +162,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 */