From patchwork Fri Aug 25 10:49:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 111000 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp812961qge; Fri, 25 Aug 2017 03:54:07 -0700 (PDT) X-Received: by 10.223.135.157 with SMTP id b29mr5754305wrb.48.1503658447798; Fri, 25 Aug 2017 03:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503658447; cv=none; d=google.com; s=arc-20160816; b=O5FfQ7CSeJCU1B4JoEd7FrIBirS+AnM5mid4w+nTJqQyVwNZKPfpyHL0Hg3JFHlDas L/zQHwdwJ9oXnhKP8ZBiGyf78U69c219jWzJs7os8e9OBE2AdRsXbt9h3rzdI0DV006E /NDtGjXHxD6BPMkBrnIJJDuejuGZVfYJKhgiiFg3s3i6aQ9dtUwQ1TeJKwz56itBr/ZQ 7AZcXA6IMxkhcyn3XalO6ym9sDudqdeW4ypF3ox3at+NnfrkzdU9uGA8B5PA6bczxrCG +SK2gI3b6cv/bOZlMx/XhjOcQIWAd6XEnyyECThtm7Gyw+JNMlQIe1CuBttwnYSF3PMc zBCA== 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=30svvQ7P+Obj6tU92eboBpHKG5trvs7CvSEFt8J9a4U=; b=lYxFbNB9tCPgRW4fMnwFnJSIRAXr9Ifp4LDqWoM60kg/3DMs3QMPEe2pfZiSgra3i0 0YZnA+BqiCzFYRwTHuPqSUuS74vONxsfZcWceXvtccPcuZXtXh6rfeqIhLYzg0Uq71Hs RJvmiEDF2zcPko50R40uP4jh8fgkpg9KB+6qBiJmH91ruw5W2E9V90DiCtPEjsY63UG5 YszfTA2ojRgPdlMiPpAybCgFd5mPQymlTxJK4pH4WKyIe+SRCOPN70arG/zJtdL7OXc+ 1O13dcpzCsSzhOzxVaTB875u0J94PaCsDhCjt/dZHdcymWdN5pV8m79zxQFxIf0HQSCk lg6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 2001:4b98:dc0:41:216:3eff:fe72:dd13 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 ([2001:4b98:dc0:41:216:3eff:fe72:dd13]) by mx.google.com with ESMTP id i20si3990989wrc.405.2017.08.25.03.54.07; Fri, 25 Aug 2017 03:54:07 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 2001:4b98:dc0:41:216:3eff:fe72:dd13 as permitted sender) client-ip=2001:4b98:dc0:41:216:3eff:fe72:dd13; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 2001:4b98:dc0:41:216:3eff:fe72:dd13 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 [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 222BD9989; Fri, 25 Aug 2017 12:50:40 +0200 (CEST) Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0060.outbound.protection.outlook.com [104.47.41.60]) by dpdk.org (Postfix) with ESMTP id E52CF9155 for ; Fri, 25 Aug 2017 12:50:34 +0200 (CEST) Received: from DM5PR03CA0034.namprd03.prod.outlook.com (10.174.189.151) by CO2PR03MB2262.namprd03.prod.outlook.com (10.166.92.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Fri, 25 Aug 2017 10:50:33 +0000 Received: from BY2FFO11OLC003.protection.gbl (2a01:111:f400:7c0c::160) by DM5PR03CA0034.outlook.office365.com (2603:10b6:4:3b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9 via Frontend Transport; Fri, 25 Aug 2017 10:50:33 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.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 BY2FFO11OLC003.mail.protection.outlook.com (10.1.15.183) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1341.15 via Frontend Transport; Fri, 25 Aug 2017 10:50:33 +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 v7PAnw6L032070; Fri, 25 Aug 2017 03:50:31 -0700 From: Hemant Agrawal To: CC: , Date: Fri, 25 Aug 2017 16:19:33 +0530 Message-ID: <1503658183-4078-18-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> References: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131481318336305134; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39380400002)(39860400002)(2980300002)(1110001)(1109001)(339900001)(45074003)(199003)(189002)(86362001)(110136004)(8656003)(8936002)(50986999)(50226002)(76176999)(104016004)(68736007)(81156014)(8676002)(2906002)(81166006)(36756003)(53936002)(6916009)(47776003)(2950100002)(97736004)(77096006)(305945005)(85426001)(4326008)(50466002)(48376002)(626005)(356003)(498600001)(5660300001)(106466001)(54906002)(2351001)(105606002)(33646002)(189998001)(5003940100001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB2262; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC003; 1:d732GUNA7eeDITdejINYVCMjnUjs0f9JBn4B+JUz+S4a8JCJz4VH/8ebn1TCOauekEEA555EmBSHwqbqrON43b0tzjQgTGSYhK1HL8b5rWUyBMfE820YkbLaXFV/rXr4 MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e7c98b1a-629e-4742-b691-08d4eba71c7d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CO2PR03MB2262; X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2262; 3:8gdDArnA8BGgPedA5lri1nMrz2CMe0Hgam85C1s3pWP19VStUFDzw0cdEWIKLi2AcZDIEb+04bF50v5ZNeuDySOSczkRAtIQt2wv3w+vML9wMobb4TAmTR1sIOevp/KwyGBZSrnKMLAg1r1/CwpbwlQc+/GSNquVnKnYdcsKBx4wM0gPWUfWncDVKfx41pZIauEPx6V1U6mx6rhPA53pHvtHb3Dtnjz2F2sQuG6RkBJ7j3mTsO/EBemB5FPhubVgWBBuAffqC8pjrxGqLE+xQvZ3XNl6/ObKmyUqFdh4nVhmnyFdJt89vPSP2CCYWSjS4sg10XOD3JaBwS8GGz0BL3KflfvHk6BC0vJ1d7qHNEM=; 25:1tZXPXcPel0xPbRUnjFWoIgfple/r/vJSSR6f5N08trGl1a+A3KhWEbQGt80wIx88c1NP8r7WiQRaDpVscKjsCRe1+9zPu6fplGBMqmHbvy9rHTFcQVEmhRNwNxmjHU03M4MnO5jQzlmLCqf5InzZQBsqbNBVh1MY7UlXAj17vvdTwstjOWswe9NzeKAHG+NZFLG0Ikswkb8wq9J54IZbvRj1f4RsWlzWr659fgCyjgPD8DQNpyPYcCi3mR1GmIqo8t+Fuq31qwxTm0LSYWYa3O6PmQB8YXZPsFfornz9dRdA7ImTq2RG4IDI45/ofDHSjYChEonT02SBCWBTiEfgA== X-MS-TrafficTypeDiagnostic: CO2PR03MB2262: X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2262; 31:nUONYGKVlmfY+mB9gvTJbaOR0PPUp1dYtLFrI52ntXzbMFaTZD7ZAezYRFsB4wKDOZRzgloY6YQbf7bCV+gOUqJD2NotggV3bftdr8N5Bs8bQDvfl2LNWUy7pCCQ1ZY51byqu6fkm95jpV9dBrGMNNMO0ifbwFYmJqdlTHl08yodPuOy1xX8NXJO+Ibx+5hDwnIZ6x/Lt1gTXLUizIA4sfDaq7/UCjsKE3du+erbI0Q=; 4:eBo6sWlejyiVGMnmQwuYNya6enM5PYmN8skpG5jWBmP0U11M/++Tv13OGMbnz4q//mUMqwHHwXn6c5zJNh2wcThTl8tfnE5dXxcwmlm1qwC/5MEAFlKrhHqUAWZobT1lhOrFXO6nrjZX+hc9OWeFxdRBRNvT2/7Y3J/Pl/u8T88WwNUveAg59sE9AuiIb2yhuRVRR4FRDhBNjkyskmj21c6vU2DS3MnizoLND09dbZEfOUd/MKFYhRbXW46hHW0R5V70Mk3p+kb8Ll5lRegmd4wv1Frnd5d6fmFJlfStjgIXd14v02LZi8ROOsqks0eDQyq392mPXRiRsh4qiowWPg== X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(5005006)(13018025)(13016025)(8121501046)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6096035)(20161123559100)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123556025)(20161123561025)(20161123565025)(20161123563025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CO2PR03MB2262; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CO2PR03MB2262; X-Forefront-PRVS: 041032FF37 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR03MB2262; 23:DtOYCiFGcnjrLj4TVEDIqP3x8gZnPex8fpBmXO2Ua?= phHUYR4sESFmb4S4xlIUDIEHsug9LgNqjTl/n+swObPHxir9g/330toW7pVdQTM6BAEa9SRacMf/iM8cTRixUdbYhsGRAnUzhcs0KP1jXW4N1mT2aFe4W/aPeVnjh4SVDTbpWMMli6i9zLXDBOvqQbtmvJPGRAG2EV06pvBcI3aFjrFAacKq3RtgQxXjAt1+4RSwbRGPhc4n0flpHNYsMYTAOaqQzJ2gwhTvlenlApqxYGo4kAM+sdABG8szU5lzRYtgwEEFmxl04Bxr4sWjKYXNqdD9RqIwwCD3Fg4ZQlcsPI4XLGqvFRUKZL+FvM99Kl7mMX4vitXNKLC8Gg8Fd8aactw1hCG/TJXKHDzaZqAM1XgXmpHtNPty9yRPza/YetILX0HLT2pdsFgAXGmgKWE9ZgjZL73J5M+9dhEyel92s6dAPKsBaoZNfDiasOkdJS4LBX6KIeQvhfHTfw4y/Q9PP0WugVNT/vYBJBmrJr6d8jL7Ak2TMwjaFvmjiDnScTyijGVbKkK4KuMYGmc4T3J0f6FpFXZzS/h4vB2pgqfu2yi4eL4WIl7XazG8OwAS4mKLvQguf7hr6KYpZEG6CoU7SoCpAe7aCw6ij9x81OA73WOSElFot7OMYthAvs60GY0mo5ivMg9WEqOjB9rxEvj9F9DIT3e3epYE5F5E3MAnt7w7oe+4uAda69mADG7hCGVesjpcr58FVRrjHp/E9WeElbyUH4R7aStKkmdMgzzBDtj1biGuNuhTzycdGDtZeAIZDgmyvXsAnmXCe8IkP6BLZJIjjR1eFJqMjRzOHGzuTTdlxdR22ereZlullAJvJCqvcl9gyUSzMV1OSIAKu+HNSFKT5seasY9lGLBTczr0zZW4KdSdIYqXMXutKArcTrA6JAiUngrY6ttH83aFfPrNjHvK1qulya26ot7p3PGSuaDSPqEorwOXUT3u0uZX6eedxza2CaqO1WWWNS+w5gmZ1/YcQbEi6O6OVUBImqRw25+z3yTpPtdK2jQBNW/RGdVpJiz1STAACsnutTDoQMdAYFTDPAstmDlHAeMbcnttuhLUSlzTPekW8ztADCHsED6+DS/twPridu93IjT+ZZ0 X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2262; 6:XoRYRCL7/uFqcfpaf9ImcArAcxD+nMHt4WVbVdWQy2206xWgdKugBnuTizufYp22l4QGykE95v0BqsaSNI1O8dyjwX0qhtDIGS1I1blWpMZVmfNrc1/xhe+BAZzk+ppGF/VMd/7+Ua/3fo8zfFHFgY2tmfUpu41A5tAJcdoERBtEPqk8o+78vxgv61mrcVvVMj4h+nUX/8zafwtzh9BZaSFR3O7KlDsZ9XzQa57NqAJrjMlOBA5miMnXXOIh2L+QiDvR0mZzvKlMyXnrsbvsf8DcSmo/RUnCDInJ00HE1grRsdxG1JT9muNo6KY3DzWeV09VN5+2lSq8cGWjlwZXAA==; 5:XptsYQF7f6mATuh+9j22o4O6xIvayxVOVQWd0dby0R26n7NisA3e2bcUD3SUXj7hQBC/NuWmYTpPaMK5QaqJ/uwbcMCVbYH7FG/Q1He/KcPzKCpAnwNaOB8WoecH6pIacHDMyErqPfVQBoEYXYzgLg==; 24:i1FnNAZbrUaSFHh/Qp3euO56wZGkyMuB+sQmVU9+7neAjHbGYlr+V89YEvUjUIMVqcqljb/teBN+eETOcSyyhXH8xGWm0hgpzRa+7Au4HbQ=; 7:TkeXOdQtuJ5fvSHoZKbd2R+6UcgNMVc0w3qiFhvglQdr1EHC+zU1Tb5uPtj8dBQSdZdH+k36mXkwWhSeSs65tFl+Jf01oRd1YKTh0RIqThx1Qd5emO285KAnnnDCqGMwSYfemy+V9ipMjWNa32pWWSLFyFis/BzsXrOAFNsAJACO55P41/WOO7Mh3LtZar431YXhJ4CvxnA8zjWGwMYDNQOeTgBkHa+YDbA+Ghpby5g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 10:50:33.4277 (UTC) 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: CO2PR03MB2262 Subject: [dpdk-dev] [PATCH 17/27] net/dpaa2: add support for link status event 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" Signed-off-by: Hemant Agrawal --- doc/guides/nics/features/dpaa2.ini | 1 + drivers/net/dpaa2/dpaa2_ethdev.c | 123 +++++++++++++++++++ drivers/net/dpaa2/mc/dpni.c | 233 ++++++++++++++++++++++++++++++++++++ drivers/net/dpaa2/mc/fsl_dpni.h | 49 ++++++++ drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 50 ++++++++ 5 files changed, 456 insertions(+) -- 2.7.4 diff --git a/doc/guides/nics/features/dpaa2.ini b/doc/guides/nics/features/dpaa2.ini index 146e087..ba4321c 100644 --- a/doc/guides/nics/features/dpaa2.ini +++ b/doc/guides/nics/features/dpaa2.ini @@ -6,6 +6,7 @@ [Features] Speed capabilities = P Link status = Y +Link status event = Y Queue start/stop = Y Jumbo frame = Y MTU update = Y diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index d7950a5..49dc42b 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -54,6 +54,8 @@ static struct rte_dpaa2_driver rte_dpaa2_pmd; static int dpaa2_dev_uninit(struct rte_eth_dev *eth_dev); +static int dpaa2_dev_link_update(struct rte_eth_dev *dev, + int wait_to_complete); static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev); static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev); static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); @@ -344,6 +346,10 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev) return ret; } } + + /* update the current status */ + dpaa2_dev_link_update(dev, 0); + return 0; } @@ -556,9 +562,87 @@ dpaa2_supported_ptypes_get(struct rte_eth_dev *dev) return NULL; } +/** + * Dpaa2 link Interrupt handler + * + * @param param + * The address of parameter (struct rte_eth_dev *) regsitered before. + * + * @return + * void + */ +static void +dpaa2_interrupt_handler(void *param) +{ + struct rte_eth_dev *dev = param; + struct dpaa2_dev_priv *priv = dev->data->dev_private; + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; + int ret; + int irq_index = DPNI_IRQ_INDEX; + unsigned int status, clear = 0; + + PMD_INIT_FUNC_TRACE(); + + if (dpni == NULL) { + RTE_LOG(ERR, PMD, "dpni is NULL"); + return; + } + + ret = dpni_get_irq_status(dpni, CMD_PRI_LOW, priv->token, + irq_index, &status); + if (unlikely(ret)) { + RTE_LOG(ERR, PMD, "Can't get irq status (err %d)", ret); + clear = 0xffffffff; + goto out; + } + + if (status & DPNI_IRQ_EVENT_LINK_CHANGED) { + clear = DPNI_IRQ_EVENT_LINK_CHANGED; + dpaa2_dev_link_update(dev, 0); + /* calling all the apps registered for link status event */ + _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, + NULL, NULL); + } +out: + ret = dpni_clear_irq_status(dpni, CMD_PRI_LOW, priv->token, + irq_index, clear); + if (unlikely(ret)) + RTE_LOG(ERR, PMD, "Can't clear irq status (err %d)", ret); +} + +static int +dpaa2_eth_setup_irqs(struct rte_eth_dev *dev, int enable) +{ + int err = 0; + struct dpaa2_dev_priv *priv = dev->data->dev_private; + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; + int irq_index = DPNI_IRQ_INDEX; + unsigned int mask = DPNI_IRQ_EVENT_LINK_CHANGED; + + PMD_INIT_FUNC_TRACE(); + + err = dpni_set_irq_mask(dpni, CMD_PRI_LOW, priv->token, + irq_index, mask); + if (err < 0) { + PMD_INIT_LOG(ERR, "Error: dpni_set_irq_mask():%d (%s)", err, + strerror(-err)); + return err; + } + + err = dpni_set_irq_enable(dpni, CMD_PRI_LOW, priv->token, + irq_index, enable); + if (err < 0) + PMD_INIT_LOG(ERR, "Error: dpni_set_irq_enable():%d (%s)", err, + strerror(-err)); + + return err; +} + static int dpaa2_dev_start(struct rte_eth_dev *dev) { + struct rte_device *rdev = dev->device; + struct rte_dpaa2_device *dpaa2_dev; struct rte_eth_dev_data *data = dev->data; struct dpaa2_dev_priv *priv = data->dev_private; struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; @@ -568,6 +652,10 @@ dpaa2_dev_start(struct rte_eth_dev *dev) struct dpni_queue_id qid; struct dpaa2_queue *dpaa2_q; int ret, i; + struct rte_intr_handle *intr_handle; + + dpaa2_dev = container_of(rdev, struct rte_dpaa2_device, device); + intr_handle = &dpaa2_dev->intr_handle; PMD_INIT_FUNC_TRACE(); @@ -647,6 +735,24 @@ dpaa2_dev_start(struct rte_eth_dev *dev) if (priv->max_vlan_filters) dpaa2_vlan_offload_set(dev, ETH_VLAN_FILTER_MASK); + /* if the interrupts were configured on this devices*/ + if (intr_handle && (intr_handle->fd) && + (dev->data->dev_conf.intr_conf.lsc != 0)) { + /* Registering LSC interrupt handler */ + rte_intr_callback_register(intr_handle, + dpaa2_interrupt_handler, + (void *)dev); + + /* enable vfio intr/eventfd mapping + * Interrupt index 0 is required, so we can not use + * rte_intr_enable. + */ + rte_dpaa2_intr_enable(intr_handle, DPNI_IRQ_INDEX); + + /* enable dpni_irqs */ + dpaa2_eth_setup_irqs(dev, 1); + } + return 0; } @@ -661,9 +767,25 @@ dpaa2_dev_stop(struct rte_eth_dev *dev) struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; int ret; struct rte_eth_link link; + struct rte_intr_handle *intr_handle = dev->intr_handle; PMD_INIT_FUNC_TRACE(); + /* reset interrupt callback */ + if (intr_handle && (intr_handle->fd) && + (dev->data->dev_conf.intr_conf.lsc != 0)) { + /*disable dpni irqs */ + dpaa2_eth_setup_irqs(dev, 0); + + /* disable vfio intr before callback unregister */ + rte_dpaa2_intr_disable(intr_handle, DPNI_IRQ_INDEX); + + /* Unregistering LSC interrupt handler */ + rte_intr_callback_unregister(intr_handle, + dpaa2_interrupt_handler, + (void *)dev); + } + dpaa2_dev_set_link_down(dev); ret = dpni_disable(dpni, CMD_PRI_LOW, priv->token); @@ -1458,6 +1580,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) } eth_dev->dev_ops = &dpaa2_ethdev_ops; + eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx; eth_dev->tx_pkt_burst = dpaa2_dev_tx; diff --git a/drivers/net/dpaa2/mc/dpni.c b/drivers/net/dpaa2/mc/dpni.c index f95e669..6f671fe 100644 --- a/drivers/net/dpaa2/mc/dpni.c +++ b/drivers/net/dpaa2/mc/dpni.c @@ -351,6 +351,239 @@ int dpni_reset(struct fsl_mc_io *mc_io, } /** + * dpni_set_irq_enable() - Set overall interrupt state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @irq_index: The interrupt index to configure + * @en: Interrupt state: - enable = 1, disable = 0 + * + * Allows GPP software to control when interrupts are generated. + * Each interrupt can have up to 32 causes. The enable/disable control's the + * overall interrupt state. if the interrupt is disabled no causes will cause + * an interrupt. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_set_irq_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint8_t en) +{ + struct mc_command cmd = { 0 }; + struct dpni_cmd_set_irq_enable *cmd_params; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_ENABLE, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_set_irq_enable *)cmd.params; + dpni_set_field(cmd_params->enable, ENABLE, en); + cmd_params->irq_index = irq_index; + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** + * dpni_get_irq_enable() - Get overall interrupt state + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @irq_index: The interrupt index to configure + * @en: Returned interrupt state - enable = 1, disable = 0 + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_irq_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint8_t *en) +{ + struct mc_command cmd = { 0 }; + struct dpni_cmd_get_irq_enable *cmd_params; + struct dpni_rsp_get_irq_enable *rsp_params; + + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_ENABLE, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_get_irq_enable *)cmd.params; + cmd_params->irq_index = irq_index; + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + rsp_params = (struct dpni_rsp_get_irq_enable *)cmd.params; + *en = dpni_get_field(rsp_params->enabled, ENABLE); + + return 0; +} + +/** + * dpni_set_irq_mask() - Set interrupt mask. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @irq_index: The interrupt index to configure + * @mask: Event mask to trigger interrupt; + * each bit: + * 0 = ignore event + * 1 = consider event for asserting IRQ + * + * Every interrupt can have up to 32 causes and the interrupt model supports + * masking/unmasking each cause independently + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_set_irq_mask(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint32_t mask) +{ + struct mc_command cmd = { 0 }; + struct dpni_cmd_set_irq_mask *cmd_params; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_MASK, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_set_irq_mask *)cmd.params; + cmd_params->mask = cpu_to_le32(mask); + cmd_params->irq_index = irq_index; + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** + * dpni_get_irq_mask() - Get interrupt mask. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @irq_index: The interrupt index to configure + * @mask: Returned event mask to trigger interrupt + * + * Every interrupt can have up to 32 causes and the interrupt model supports + * masking/unmasking each cause independently + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_irq_mask(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint32_t *mask) +{ + struct mc_command cmd = { 0 }; + struct dpni_cmd_get_irq_mask *cmd_params; + struct dpni_rsp_get_irq_mask *rsp_params; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_MASK, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_get_irq_mask *)cmd.params; + cmd_params->irq_index = irq_index; + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + rsp_params = (struct dpni_rsp_get_irq_mask *)cmd.params; + *mask = le32_to_cpu(rsp_params->mask); + + return 0; +} + +/** + * dpni_get_irq_status() - Get the current status of any pending interrupts. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @irq_index: The interrupt index to configure + * @status: Returned interrupts status - one bit per cause: + * 0 = no interrupt pending + * 1 = interrupt pending + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_irq_status(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint32_t *status) +{ + struct mc_command cmd = { 0 }; + struct dpni_cmd_get_irq_status *cmd_params; + struct dpni_rsp_get_irq_status *rsp_params; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_STATUS, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_get_irq_status *)cmd.params; + cmd_params->status = cpu_to_le32(*status); + cmd_params->irq_index = irq_index; + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + rsp_params = (struct dpni_rsp_get_irq_status *)cmd.params; + *status = le32_to_cpu(rsp_params->status); + + return 0; +} + +/** + * dpni_clear_irq_status() - Clear a pending interrupt's status + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @irq_index: The interrupt index to configure + * @status: bits to clear (W1C) - one bit per cause: + * 0 = don't change + * 1 = clear status bit + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_clear_irq_status(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint32_t status) +{ + struct mc_command cmd = { 0 }; + struct dpni_cmd_clear_irq_status *cmd_params; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLEAR_IRQ_STATUS, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_clear_irq_status *)cmd.params; + cmd_params->irq_index = irq_index; + cmd_params->status = cpu_to_le32(status); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** * dpni_get_attributes() - Retrieve DPNI attributes. * @mc_io: Pointer to MC portal's I/O object * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' diff --git a/drivers/net/dpaa2/mc/fsl_dpni.h b/drivers/net/dpaa2/mc/fsl_dpni.h index 092d3b3..5227ea1 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni.h +++ b/drivers/net/dpaa2/mc/fsl_dpni.h @@ -247,6 +247,55 @@ int dpni_reset(struct fsl_mc_io *mc_io, uint16_t token); /** + * DPNI IRQ Index and Events + */ + +/** + * IRQ index + */ +#define DPNI_IRQ_INDEX 0 +/** + * IRQ event - indicates a change in link state + */ +#define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001 + +int dpni_set_irq_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint8_t en); + +int dpni_get_irq_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint8_t *en); + +int dpni_set_irq_mask(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint32_t mask); + +int dpni_get_irq_mask(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint32_t *mask); + +int dpni_get_irq_status(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint32_t *status); + +int dpni_clear_irq_status(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint32_t status); + +/** * struct dpni_attr - Structure representing DPNI attributes * @options: Any combination of the following options: * DPNI_OPT_TX_FRM_RELEASE diff --git a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h index 81226aa..1a48332 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h +++ b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h @@ -64,6 +64,13 @@ #define DPNI_CMDID_RESET DPNI_CMD(0x005) #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006) +#define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012) +#define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013) +#define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014) +#define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015) +#define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016) +#define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017) + #define DPNI_CMDID_SET_POOLS DPNI_CMD_V2(0x200) #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B) @@ -169,6 +176,49 @@ struct dpni_rsp_is_enabled { uint8_t enabled; }; +struct dpni_cmd_set_irq_enable { + uint8_t enable; + uint8_t pad[3]; + uint8_t irq_index; +}; + +struct dpni_cmd_get_irq_enable { + uint32_t pad; + uint8_t irq_index; +}; + +struct dpni_rsp_get_irq_enable { + uint8_t enabled; +}; + +struct dpni_cmd_set_irq_mask { + uint32_t mask; + uint8_t irq_index; +}; + +struct dpni_cmd_get_irq_mask { + uint32_t pad; + uint8_t irq_index; +}; + +struct dpni_rsp_get_irq_mask { + uint32_t mask; +}; + +struct dpni_cmd_get_irq_status { + uint32_t status; + uint8_t irq_index; +}; + +struct dpni_rsp_get_irq_status { + uint32_t status; +}; + +struct dpni_cmd_clear_irq_status { + uint32_t status; + uint8_t irq_index; +}; + struct dpni_rsp_get_attr { /* response word 0 */ uint32_t options;