From patchwork Sat Sep 16 10:52:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 112796 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1616439qgf; Sat, 16 Sep 2017 03:56:25 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB9VTTfaa1SKCyCfICPVB6IGLiN1NpZLIncayXQ1IdVgvp9lMVEJ5SParvMQnow5pFnrCFf X-Received: by 10.28.25.129 with SMTP id 123mr4730907wmz.17.1505559385197; Sat, 16 Sep 2017 03:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505559385; cv=none; d=google.com; s=arc-20160816; b=Tsr+qdX6fDxA3Mga7C7BDNuxJjFzuVhuNM8CVrEGMuXj6r84vQWk2OzKiJjGgZTv32 wQzNTwBvWO1y2JLI0srbTGq174uki/ViS/9gomMj/kLZLcoUGqSAWIHafWln0DJYojRl ushGcmYdYa6zYROOfjI02chSyodTQ5vfQ7OXnEfeD+ihQbe0Euh3TQ6eAb0/pbGqhGJh cPB8oxrQQqK1P9u9Z9DTO/VlXY85SsVwY1UGy90yiACUbI/5gYuhAYVSgYPwH7pdGgMu bHHxQ6gWS5CnwOJ2FI435h13vfJpV+Nm9BbHeFQ1tmpkzROIbr55XMP+BQ1Z23GRZ0uo TLnQ== 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=6O3ffquaT2Y3Iy7J5XcVcaMyyTKxU/JvNBlGAFCPOB0=; b=DxvgxEBmbOaJhbkAFLgZLwVDSCXMFHlqjnv+PS4GRNu18UepNmU5taXawC1wI4k/a+ NTJux1KU4/hqIa1aOXhIJ6iXq4hKbXB5Biemhx5/lqBKW4E3/wPJLEjzGj3QQBaqP8wU Aqf6wwEy/x+UUEwYgxcsTQcxP8OMzQIglpI+4kYItbr6JSdbMaGqiZVFC4hmW2AhKOsz pzzxh68C9CD7Y5AIa1/wTnXhdjvC9Qe59lETcnnvQ6+GBS+NWgL+5AScmchCbkmVQxD6 /be3T1CF2VM/+v/ZhaXKqL5Mf2Dymr77iQ5ePDDUJo2lIrCOs/BowpXl74qzWOU1p1r4 dGVQ== 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 w77si2481937wmw.194.2017.09.16.03.56.24; Sat, 16 Sep 2017 03:56:25 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 822321B20F; Sat, 16 Sep 2017 12:53:45 +0200 (CEST) Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0066.outbound.protection.outlook.com [104.47.41.66]) by dpdk.org (Postfix) with ESMTP id EAEA41B1A6 for ; Sat, 16 Sep 2017 12:53:36 +0200 (CEST) Received: from CY4PR03CA0023.namprd03.prod.outlook.com (10.168.162.33) by CY4PR03MB2694.namprd03.prod.outlook.com (10.173.43.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Sat, 16 Sep 2017 10:53:35 +0000 Received: from BL2FFO11FD029.protection.gbl (2a01:111:f400:7c09::129) by CY4PR03CA0023.outlook.office365.com (2603:10b6:903:33::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11 via Frontend Transport; Sat, 16 Sep 2017 10:53:35 +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 BL2FFO11FD029.mail.protection.outlook.com (10.173.160.69) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.13.11 via Frontend Transport; Sat, 16 Sep 2017 10:53:34 +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 v8GAr6v1028328; Sat, 16 Sep 2017 03:53:32 -0700 From: Hemant Agrawal To: CC: , Date: Sat, 16 Sep 2017 16:22:28 +0530 Message-ID: <1505559161-29222-15-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505559161-29222-1-git-send-email-hemant.agrawal@nxp.com> References: <1504860327-18451-1-git-send-email-hemant.agrawal@nxp.com> <1505559161-29222-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131500328148101475; (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)(376002)(346002)(39860400002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(45074003)(199003)(189002)(85426001)(76176999)(316002)(50986999)(54906002)(6916009)(110136004)(97736004)(48376002)(105606002)(50466002)(53936002)(36756003)(4326008)(2351001)(104016004)(16586007)(106466001)(33646002)(47776003)(77096006)(2906002)(8656003)(6666003)(8676002)(5003940100001)(86362001)(81156014)(81166006)(305945005)(189998001)(5660300001)(356003)(8936002)(498600001)(68736007)(2950100002)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB2694; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD029; 1:nvRsUVOBMz4s4oCZrTlgt5hLu5pK//qp/tl6XLrS0yZ0G4tmQCGC/VpT5LD9HClC4dviio0TCyJ67FAK1+9cxj76UJvLxUHT7DWKU/ZDpb8oJAk+9nkinapKbMj4rS3J MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 293ea56a-7c03-464f-fcfa-08d4fcf12d7e 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:CY4PR03MB2694; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2694; 3:tccd8qqO/d+eT/qGYVl1szbmTQVimNXoS/ZMd9rVu/v2CKQkJQubo6nBh906W2//S5SpBgGqkHBE9SNdB3588BseBnxRjFw5h+3iQQqRBYlQPQMIIeEN9nZ6yK3cveA1/nzUOndSh6EpZyNp2K6/p+gteqQhOBhzoVawbo/vUgWglOn+h7JEEbDKleM0hMzDhr+Ay+gbGaXC/z9wqDuKfPa0/MMpPmYlzXl1ULHxdRz1iKLoAbwa3pxjptITh9bNUUlUqwSAG+0wfIk2KYmBGBCml+I9sn+EHpLe0el41tdtTeUiGzhfz13p1zXUJoM+gDonIEvXjuiqG0veT4OkaBl7+5Q0kY3zZ9OAqSA/hjI=; 25:bXJGqFKn6d05+nE7Lq+NpNaRvUyrEzO80emkkvUANNskFRBqLdXLcBev5eWhDyl1/diAn6a7SL2xIW2jbmCiSK9vcEUm1QSgFK+JNrZQss1khvwUt7LOfar6eS95BVxTACMaUJwHHX5MDDCM8RUUjYOsPkTiOsymLvWJ1HY6QNVh53RxqCMa/qa4dqjrnq0xbQk+s/Osl875naiaEamfrlTLfSPpK8vKBEzAlMyFs5MLmS+ruGO46GLlJMLQKDFJsoq8ed1ih349L16ZumYGxICqliKTJaHaLF836Iq4Wfv2dLQOodG1kljebos0zmLIbQb7+2dLhpnmo4NsnveQ3Q== X-MS-TrafficTypeDiagnostic: CY4PR03MB2694: X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2694; 31:5UZjdK/7nPxsIKHiJHD2EMQLjIzV48gulLox4iI2iP+Ax5MvUU9zY13u5P7flwLfwR3XqLcN9yGpcUStIw6ziVPkw3Nyk+Fk+VkS8fd0dUejcVmoCqb1leWgoA/YuxjDRXpuAiCNZstpLB0NHv15Q4S3elOItsZIKgd4tKE8jRyWGkOIGwgYoSLPJbVUkJ9oentWuxWoz3Qg0rRo/5nEUYJa55FASTU6Ij0SpOIv1O0=; 4:89XiCUS1V4ph+2Vh4y4PbVKNcST2uFMoN4IMxB2E/IcZueLs1DQW5Zjq2+eh2FylR+t8yiNfRdqU8N3if1eXIuEKetUy4j3GQbkIZk3on0usvj4QKeIWYRiAylfseTia2KFcIOIzrZhBRvd/owqCRdCQDHlorTyIdkZId019GNN9Qn6IcBYFc1uu3pernqwMzh362zEQhVlp2kioyf9k7gk0hCedNCVu9Kzzo9f00rbnvmvwR5qYLazO1rzg0KImhuQSg3h5pHw3kmhnLXrnu5FFrWbZRdswkrOwCLhllw/VOluKnRKnDWZyZsM6EnmgchRsMHjVMGseHlQyeNQmdA== 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)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6055026)(6096035)(20161123563025)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123556025)(20161123561025)(20161123559100)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR03MB2694; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR03MB2694; X-Forefront-PRVS: 0432A04947 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR03MB2694; 23:sFEb4L+ri7OuKq12Fo7VX7WNuinvdFmEC4ye0xGOC?= sCzMz4tjTZkkXamz75x+BCaFhGeTxMvDcr6WITJyVY8J3Dp7ChT2wGcyGuzKxVbzLgKmIg6VWsXGtncVTgdIabY7UZ2PFHB47mGCos6VsIaAHuV8/6doMmAR7DsSI1IjDmloRyQNZs0pKdXIP4qAtsPJzn1+KyTMvOm7RJiVAd3R5+qxCgWifYjXSiCH/b6aA39E9EwJtINGjDjEWnECe8tTaRn1UBd23YPG0EKquXWOVCynU7GUT8mAiidFR5aHP5luLzxH/EgQhqZctLc83T+07G97gJ/Gv6GL3zrblj2kxbQwVEmJfqPsethHOsEdS9qCWPEBOwzF7reF6VNlYmJS2ptUpP9EaFUgNdjCqgVU65ItPx/Q7y8EvioPbewEL6y8ot2NEblINEE3W3k7d6VmTmZN/8e6tX3xj9dOF7MHYScWGSUYGHL09zxCMcjrH2wyKwLNJdi6XmJLRMwecCTcQpvkSyh7BaX/hjH+jtnN/duQ5oQae/eCvKA2d2rn7xzXV4xsHcFQsy4rx2QOIqcwrIFbm9x0z38GRb2uBQBbq6yuHsLq3wLxIC5rVvG9vcuGPrrPswCFIFhnPqHeR17NmB9fC9WDJJFxMM7Dtlpu2Fo5THyuNksE0UUgNRXPUNa5cWNwDDtuyPEy9S0mhU/IthMCSI4r7sMVZW2Vh8+18jQYFYL8HpuBQ4hUSvgV5l8VLPdO6M47U8VhrP5PzGOIoOc4T/yuM/RVRVrjYUq3DqAKrwAQrdohNUWL9rh485seMf/NMlunqybFrKf6iCQ21zuag/B2ej8OyUS4hm53Xm1re5agXl6e4eMHS3ilyjcAH0d4wphrO8spTYkSdV65Uyb/sCC39KuUUbZ0+sYIDCMW5vN13/X7PTRFWdgdlLDk9orzrwRTon8nDdJes6+2TrsTW0LmXXzJlQEvSfcqA4RNoSGMQBJ7SEQSWHQ/0PiQqQ0z57ayOayJ6Irp9Y/k66IZZY+kOB9ptgD3r0/aReo+0ISqRKGJI9UVRINE90T4LK6iHOqJPLmTLUcm/3LQxn3gHLXpcEWpwOJr9JbH2PJ5+HfTqxGIX2BzQqN81PvoiP2jWjF5yoGR904zGtcRtieyil696R/aIIH57mRg6o8F0oD+AXU5zOFQGPWinaYKm7JEzxmyiGlMyR95R2W X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2694; 6:QJG+Gu5jKwLtl+6dzFJb9q28CyZG/EqNK27Uaa5LADwpT0fLId0dlErSjbG7fsxWGAQ3cP2j+cpCWE79Tcsbfv4G3+aJrUenRGRqvymZssiHrosKWkPGwMkJp+c/w/SHx2soKgp0ZmxgKWVDqNwpfxnqDmkmMbtTW5jwcvn6li//zibX4/HImeKIpR9lHrTAKh+L8jwKXeq/c81+bKRbHXVxmcKSLyMauJB+XwH6lgwSb1kbKI91xF1pcszjIDsDwK5cI65M0kiaqBq+5JTahrmQDaGg7Jo0DFJ5w+LXzS7qlgiV721x314KtUJsw09kdf3C0XRHh/kJbvAOw9tTWA==; 5:1+Ic5qHfjMLxteoFTwoyOeWVSuTJjN8wQaCiv5cInyVqKg0uI/S2gxn5P4xa64vq8AzK7LAGRpdubAH8k+jiRmQ3VB7hB/dlYmX8AEI/h834U0y9eBqbR+XuDLyXytOxIfOCzuxlcJDYKDbUK7TKWRIGUnFs/5FR8qy3AS837XM=; 24:wTN0wiM05Q+XsGSfpMJBgUIA+s60/51x2sHGZsLt6JaqzN1pryRqWQxTEBQ7q4A0EjSHwgCQvoXdlPA3GRGTjoL/qS9x0ynLTQKkVaBPwEU=; 7:pllb7Ax1fTo291ifDkEXaVF8QGpWgUjGpp86GBXKAxI0nutHrIWrzJI18QvQsVA/dbcU5xZVbtRDMnzTkouEekA0/TWeT+nqy2IT23JkZzUm6aqAf5VsBSesBEFXJG8oDgOIN5HVc0pwy11GoxUOfyk2GsSC6eQKDOmDsLPSWbkea2wlnr4pXJxW/9O6P+EjNRBYYv/Jnt3r8O3xga0YxZN7PVl9paAoeZ7daOoCBxI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2017 10:53:34.5137 (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: CY4PR03MB2694 Subject: [dpdk-dev] [PATCH v3 14/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..72c9e67 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 = 0, 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;