From patchwork Fri Sep 8 08:45:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 112039 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp1246714ybm; Fri, 8 Sep 2017 01:49:54 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5Na/GpX8QusfJq6KzK+3PbOfJPW6cs5dkphGlWjJYjnuAv9xx0ST2Ep3qmHkomMJB5Yxh9 X-Received: by 10.223.157.3 with SMTP id k3mr1386773wre.122.1504860594481; Fri, 08 Sep 2017 01:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504860594; cv=none; d=google.com; s=arc-20160816; b=Lr9sfuWLGKEKZd3TjsDsSAZdwBezUNsbv/v4cW01C+SC0JbzYXyCXRuy5S23/1kMmD u6XdD0Dw5uYeR96QVzoYm4PH0wSnDQEGU4MacJzs51dMXdy6kamZ6NkO6Z04F02dCCpZ RHUN8r98ppXagFrBCrdXCX6oOWf0ghRoUeUhdSvPp2xlS5TmuHyIakMxCiZzeVPiKvAq AxQUxWrv9K8LtQiEV7n3CckdkVkZgPHah2NE7butMRUQWVkqNRegW75MkYNlOSOWn+x7 sN1OsNiTiiCz445SPn/qwbDIcEVMHBXLwkGpbh/ymRX7juc6k5xDiL8lQfL1UVPjwtSa Tc8g== 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=ika04PpCpY8no9D/7x17nkEl3J+YyQqwsHrPSNH5Efg3eq19FkmUt7bG0pcG2CCSs1 o0wV7OiWBz28swCsEOEkzhAVwnZmSdmCgAMm527ew67Wv8kXyp7nlw5qWbTkAr/fMJel gAhOIWFhjnz7UMzo9FwxWDFBt7RhZsZHEoKGsMndJ0Efh+qAtIXxruTJoYIkrQvQx4Pi OTvrr+znHpTMrh6Hd+dTXV8kqMd5/6K63kH7ShXt+5qKB22NKvEMCSJK4EJJnubGPVLn Bvi+FPaqaaQ7on7S7lCEy9RLLNjXTwwj1yUl761M8FEmNI9SeTbkeVzhcmu9oMHSaCI9 vLTA== 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 n5si1040864wmi.167.2017.09.08.01.49.54; Fri, 08 Sep 2017 01:49:54 -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 [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 9BE7C19A29; Fri, 8 Sep 2017 10:46:28 +0200 (CEST) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0061.outbound.protection.outlook.com [104.47.37.61]) by dpdk.org (Postfix) with ESMTP id 7824F19A06 for ; Fri, 8 Sep 2017 10:46:25 +0200 (CEST) Received: from DM5PR03CA0034.namprd03.prod.outlook.com (2603:10b6:4:3b::23) by SN2PR03MB2269.namprd03.prod.outlook.com (2603:10b6:804:d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12; Fri, 8 Sep 2017 08:46:23 +0000 Received: from BL2FFO11FD040.protection.gbl (2a01:111:f400:7c09::130) 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.20.35.12 via Frontend Transport; Fri, 8 Sep 2017 08:46:23 +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 BL2FFO11FD040.mail.protection.outlook.com (10.173.161.136) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1385.11 via Frontend Transport; Fri, 8 Sep 2017 08:46:23 +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 v888jmon023063; Fri, 8 Sep 2017 01:46:21 -0700 From: Hemant Agrawal To: CC: , Date: Fri, 8 Sep 2017 14:15:14 +0530 Message-ID: <1504860327-18451-18-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504860327-18451-1-git-send-email-hemant.agrawal@nxp.com> References: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> <1504860327-18451-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131493339833220831; (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)(39860400002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(45074003)(86362001)(47776003)(5003940100001)(48376002)(50466002)(76176999)(5660300001)(36756003)(106466001)(50986999)(2351001)(33646002)(189998001)(6666003)(2950100002)(68736007)(81166006)(81156014)(105606002)(54906002)(8676002)(8936002)(50226002)(77096006)(4326008)(85426001)(356003)(2906002)(110136004)(305945005)(8656003)(498600001)(104016004)(53936002)(97736004)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2269; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD040; 1:F4CR9Qk2VIuwrCzGPBn9CF7xSdodb6SeIMKCZowcOYpZU+hTNTgd/BO9XJfGgggG2eGBzgYMYlrgMLnNF1xmfhoTKE9F2XUsbx8ip5gHEz+6A+c4wGLqazAYohURRb8s MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 90c79e33-ee6d-44a0-bedf-08d4f696158d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN2PR03MB2269; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2269; 3:drh8gOKvP3IGgFn6CnVDqBvwU9E8A4bVg33aTOXy+AN4bGq6XnLGe++rN1GgO59SssnEdQrshtVTDCXhOF7usl8k9Qfn1omHkul+pAWWrlFWBnoFX/yzyDOVJ6vlpxiqIH9o2kLbk+EWVvmbpKXKXZLPIMp+FUj4SDOgTj0HnKXYXqQhTCjTdO82c1sQRgaqmoovXuZQj7WKlIxM/Se/IQ9eMplvT+omh3AqXl4fls9osbQ/qAk1qPIX438Iy+t3fTKp13PaRA0EX9z4pVP/Vc8nrvpQwqoGYtjGAM2W9lDnpK1+HE4KzIHZg0BI8RYBaaUYP5F7hJ18FG4RN5lmmpcjUq0REUptE4juwRWbBYU=; 25:mheiwC/iz6bNJwB+gTPlYYJRbzpqbq1tgDBXhtdgDn7sxkxgVaNW35AmrREFcNPPRhgq8J26EACBPD5XIXvqwO14WUPzgK0LtDFmMHJVDwnTwULp0ZLqq1R7+RHinWqkkEn9BjxF10/9EqYYlbbCZnnIdodZBlSa0UGA5dXpfnngbUJnZGfabiMu5EOLdVctQMxrXO+uhfH6C319XEJ2QYTd3bTlZWCwICF0TKfd4N0FY2nf+FKXHPAPksyIp9+dveEkK7OPBpFVt3kJzBluimfUQ54iPWr8Vs+0ebTWtzFh80oX/1F9Y2ll/ng4/93tWZmViuDXSV3c7lqzzuFvqA== X-MS-TrafficTypeDiagnostic: SN2PR03MB2269: X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2269; 31:o9xM7OIVXmeCxA3an7dhgy/cmf3Rry0z+SOZweYweceGJluH8q6GEzq27rjPDH3+Jl0fNQvmP5vmbKSyVWH/Gyl0s3IH+sMZKBQE8wPu620G4Uew8klOMSivsI9/tim0O8vD8UqnXi0elT+YxtEPYIWWYBxHr3PI7xw2b4QVGU34i7zzdEdj8edSen9Uri5HTQvOnmfKcPfvmSgqIZiUVppZDQ/85AhebVxQopLWnNs=; 4:mcbBliN7CKYnV+HwxR2kqedkHD6567CcO99HWsp5fuP1kUhheqgplPjtRM4Ah1LKuPu4tozjr2Sfvi3C6PUbchids/xxkUGBzb8EmsHL/Y7JxfrZrnNNySSgDMsCGpH5kpr32WbT4b98uD9oSVMKR/7WG3iRPju0LYI3NFcZ7lNPGvSuhiXuTUPgm5wyisqV/MWb3XQ6GTjDrABz7Kc1hVRKBZudTe8B/wu2rwp8Kw68n50TCTyP+zaS76XWgCd2yOE0Rhl1kIjA7f0V0iHdDbclNEHZUP4M77uqi0dTJM9t8lhOGjtJR1Ccb4h9i2yr4kReuSZ4lg1jqpEuyiI/Tw== 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)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6055026)(6096035)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123561025)(20161123559100)(20161123563025)(20161123556025)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN2PR03MB2269; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN2PR03MB2269; X-Forefront-PRVS: 04244E0DC5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB2269; 23:4Kr8R+BqATn2sQEJAlthK4Qa+CXEQZl7N8THXfL3h?= CrCUn9BOXaYTPsz56+/3IwebfGnezE1aLj+Ie6HvTqxYRx35mIvZTTjVZvKqdbYXpVAvP0BA3rkIzxJFDLjEHs3OsfVQG/osT+J9xcQHjJyLZZjyBTAo6Nk5ysPI05cK1eYY76v05sK2Kc+V0AFXT8jQUjRNYreREWs2RHkk/l/6URYD1y4QQ9vFvNkAELRcm89N2peoBcYYCI8HHdLOiz2GsTNdMfxuLTznG8zICi9ZVDsI48Vd6I5/hzePaOKL/QZ3DylNUgP7NRNvXM8gprzOhjV+qKqGj3WPxErH15LhMG8wsdMOSWAuvgYCdY+i4BoWA72oBAvACtsPYrjkOWmJo/vnMdhG1ruvKhKfXDJf8/75EJFO6F/UY5CnT5mbWRKA8IDSLoLOVxh1LSgr4gNxlbEM2fxVtaKbRC/QY3L0EQ0xhUPBZrux6luKauy80z6tYGHx9yMSgOEAA7hEdprzYoFX6MweJtiUdRObrIrG7cJ4KkSEficM84FW3ht0UwIFOcjLYr9TYt5tUzyMdg6yVWV1NjNugjMWoxYUQJuO65agRuvnL/MZKIe31YsLPHf7MDzIN/CqeDjsBlpO6qA16CjUA9aMjiqXPfsNxy7N5qFy1A4mMZrlFGaSD5SFbAfvnV1GNahATNPaAPyW6yWqT6//YxIJ6Q+ubHZa+2g62aQykiD8yTUf8hSzAeXTBN+noNzXUt25PtdfOOkYuOZT8mWxz0ViyrIcyL1McJa5P0r4+DV/Urruk1c58sAF0A+fr5SEHzFN/KXUK55sYY6W/uvq6u0cdsOjw8jd0cmq19s8MJlbszO/l6Dgon9OGIs1cye/6fjbNq4Idbq7ndD5MjDArhLM6uuFHn7CRgG66UOmd6s8QHI669TPiFBvTLN+NlYYpnMblPyuZxhKSn4pzONQDckMmoUmDKmlhpjk195suG+S+wMsTJxeP6DYGm2CHYFDQAjtmrd60czvowpj6te9OYufQmSHVGQrEjsWIPoMpvBM1Nogyoy4lTtBS3gMsD9/71ruhe+YBJg2XdmU7yTENelG7q3ZSTNJmLaW8TwMUqlR6w5yCQOrn0qWJs0QFFF3H3pjb04dfUxPTYJ X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2269; 6:4kLAm0eKSiluZSFvZYNdVs2Md8rHz0gD1rcnOyeXWHlTt9eKhPZVF8RLFMn9USBIRgG5Q1GHa1X7a84OO7bFji28ZoX4cGR31HBbO1PR7Us++M0t9F01cXXVJm+87BW66ZIjvLZe/aauu7b7FPcD0skuyfVO0UePpo63CpDTFqBNWxlGxl9pC2L4g/gVFPSP52lJskndcfJmts3Ig7WnLj6ievE69jTfwtMlkpXV+QCV34ImAtgxY9aVcRkY4hSr4YjuSHDL4hl02i+MfBtlHmOJ7pmiC1dOFYs7Zk77A7xpsIq7xdACPhGjX8SX7z6S48YYthm5oSbU4dTrZuMw+A==; 5:Gmz2lf88uvqWE8neNVY6/Ib4k5g8YFvTdSwgg2kaWodX0gHDTW3LdvYKkJ6vn8DVQzmDUn4dRi76yfmmIF3QM1d10l+QgjRvNK17ZfOYJWyTV8CM6GDe35l0fTYQ3th88SPX4I0xtlxpt99dqxYj7g==; 24:6oPxS0uJPnX9qB6qI2S+oZDT/tZ1NRotMVl9ZwfSbqli4dVSJv4qcDjjUCArwDN2pZ+GxiymZt/4b2lrnJnRtBZ4Z9BoRmOb8rwIrIPLhlA=; 7:PAcZXxgkbQxA1UepAwZt559yx+nPSSRmTRagVqyX4EWfclLuBWUi4rm02L/NJig5Jl4coM7JDZ1Y0UUKNOCxDaqWMkx76i/Ulc4u8DoDL4N4TtmYtLg54RREa1k+auNF6fEfu+gIsEeKOkPWfhXvpQc12csUXNlk9L0DPXZ3bYoaknDIXpCY72oxWjxNkEIwVzhzjaoHI8paiH7A/w2oWsy1Va8EnHZcpXGVR+uEnwA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2017 08:46:23.1504 (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: SN2PR03MB2269 Subject: [dpdk-dev] [PATCH v2 17/30] 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;