From patchwork Thu Oct 14 17:02:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12559009 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A216C433EF for ; Thu, 14 Oct 2021 17:03:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7757B61152 for ; Thu, 14 Oct 2021 17:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233023AbhJNRFN (ORCPT ); Thu, 14 Oct 2021 13:05:13 -0400 Received: from mail-eopbgr00044.outbound.protection.outlook.com ([40.107.0.44]:20865 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232160AbhJNRFM (ORCPT ); Thu, 14 Oct 2021 13:05:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VsD1IpG5rB1krveyg5FNcviirmc3VxYLaKOGzK+44M/IBKJxZGjDjdboxlE+htFFyuowYv97Ck/Cdxwqkr4dvgJcrVWPZk3Q54/aR4U3Mxk2WH963roJ+UoG+yEaWaf3BGlT8dkYcPkVgGdJxMJbOnHDSVLihZge0f+nuiI9p2rZPMw5HBf8BQ2k3L8a3TnJBh8NTVvca3QPxhIs75tm2pGNP8ppMX8AIBPZVHw6JQEwDxNcU/7vWiND+O5ScDNS81/GelaTt7q6TCXhT+tjoeEVITiUkLgDKloIei66XexAt1EbCHDUpTauVD7a27MPAQrVSLjYwM9v/oLWFrT/Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fix9iwjCIAMAcdBotycmKXXPc/JkaSXJzGoRioYI+B8=; b=M+OEab18iTIcN8H+UsIv500H4X8pPuStg5xs1DD9+gom83YBaQEG0tc5fEI+D4Azw/SdaQ3uMxhACcMWNsWJfYyjJMeExGh676I9yoDKTUP05m72ZM+jACtoJfEWMal4rl4vhAQkiP69YTUIZ9a4x+xTXI7Lmt4XveCeQ6uY9LZQIwyfDRq0TKlCK2uduAEKtdkSz+hNXI6lmfnu6h/WFzO9JhtS5dzMgqJWk+vbXK/h5k/QihwPcI0HtEjXCAg2x3eo9pi1GA69kmlgivRL354pgetVtRbzORZTD/Q1qrZ2xaOEOEe9O5xMlAeuy3aqUaDYz4ONC4/hvbxkayE4Fw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fix9iwjCIAMAcdBotycmKXXPc/JkaSXJzGoRioYI+B8=; b=cEd3TBw0sOx49wf1bklp3SqrhWknswsyl4SftL6Zw7Q+/idp7O5f1Qb7MQSN8Ccskejo1YqavrOgJ7qBOTYN2M8SiwVjGpYu8ZTLx10lCutsX9YNSg31IzmNkyw6F2G83rrOmSBb06V7M428IRf9ivwKoYveXF1pxpi0dUmPvrA= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) by AM0PR04MB5825.eurprd04.prod.outlook.com (2603:10a6:208:127::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Thu, 14 Oct 2021 17:02:58 +0000 Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726]) by AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726%8]) with mapi id 15.20.4587.030; Thu, 14 Oct 2021 17:02:58 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, netdev@vger.kernel.org, Ioana Ciornei Subject: [PATCH net-next 1/5] soc: fsl: dpio: extract the QBMAN clock frequency from the attributes Date: Thu, 14 Oct 2021 20:02:11 +0300 Message-Id: <20211014170215.132687-2-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211014170215.132687-1-ioana.ciornei@nxp.com> References: <20211014170215.132687-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) To AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) MIME-Version: 1.0 Received: from yoga-910.localhost (188.26.184.231) by AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Thu, 14 Oct 2021 17:02:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2011ef6c-91d3-4f81-2c95-08d98f3478e5 X-MS-TrafficTypeDiagnostic: AM0PR04MB5825: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lbDLn0GHd8SKWRvRwD2Fy1ihiMIioeW2EG7LStcEpFKlq9L4ESiGB6SYeN1qgVmuR3H6zbqaJ/OZ5NIXykHXTUokeGY+dGffjC8JBAn4zsMytCfYNyr621cnoJCeED6JbZYj6f2ixAgmxORV2W3Ceh7rPBD13PqeoWaQeMjUJeswY3R3LSjRYuD6dElFAN9JQEQNruMj8jUX4tVliYnGEoN4/htlDaaLHICkWXkEtVkxvuX3RpyZw0HTUubKhlKv6DeUPyjR3d1MUa7BJjrdnTpoQ+gZIXjrUmwwc5AWbBoUCSi2y9VGRjKK01cxM5z9JsuYeYsVaCxzEGVD/6bxgL4GjbfaUGInO+fGtNlrUSs4d/7YmOTthrWKy5jrIE/hkJj8aCaDscW7MXXQH2DTE6L7F1E7g6iIp7M4QNQLqKbLs+Ol7463pzs77ByF31aNWWNREN+7UA/lQqGdkBoaFeUgkY3uWF5BHGGOkyOSdhpMXzic6kBTrFYsm6E+ewoTtzFRlcg4H315LDDr8it0/nu81cmcVxSj8QCMeUjVny55H8TpLXOXqXco1npaFrSQfOhQLeHM8U9L2yV37MQ3csqqYV/D/Pp+EwsrWUOGwFphpkKXbe7mEkHvUaHBP+ZDF8KkE82pOBDFEjugFIOFlD7bwlLnK5o6ep213KTkUmPSie1XYBH78p/eGGakAKh1LwR3EtWNJc6zHk4F51gxug== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM4PR0401MB2308.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(508600001)(5660300002)(2616005)(956004)(1076003)(8936002)(6666004)(66476007)(186003)(316002)(36756003)(8676002)(4326008)(26005)(2906002)(6506007)(38350700002)(66556008)(52116002)(86362001)(44832011)(38100700002)(83380400001)(66946007)(6486002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vS1dA00qoAJOQh//4yY04OblGIunlWsK6wjDMFYMLPqI8wt6vRtOfznzydwW6/U7tVdfWmKP3WcbrRUAgS03f9ljpGVF7BUg7+jTEdgSyVpuGsTWobUjXst6uRTITiA+VijYmxF752+zOaLIxDmX/zOw9ztPk+Nja+JermqgePNdwKWxxEjJ3IycF5Ri+uEAEY9UdDtSej9YD8YcvJCh/izySwrs+Jxw9dLYTtTY/7PNmLaVzE5f8PKYKEgywfKkMQGQYoRI5/WHWZDJwQayqZX1r/bJ9GdxzJMr+5bbzNED0zl6ttBW5OX7DhThPv36vRJaFKxS/LOwEhBIuflaKWL/CeWASGqsKqBwlU1S+JDI9OCrijxkY5FGbD90BGn+G+qjhCkC/99EChHgpewuy+v1qdqAtZMGtQTrZkucFACbzzSU5efv64eWLfC0XQF6JqLQYFw+vZ0puW6j07F0GNHUY3ubsYh+Ack6e3CSgrAmzDPEOXWilsHcQPeTP45TKhqbHXOENQl13jN0eV6dgsu9C93/La4Y29ymZ24FGQm3TtEweHd/w81UocjyAo/K8qJVUldj2BtEl7r5oJ2DdL0ReeWVmTiUUaydnPtEjjRXF7DXlwMOZzJvklzksoHLR/KqJ+A4CGzl5d2ixnlvPO03rSZsPKIOfuEBiodOy45aKLNgpO8GtifmCYynhovaWOwZ+RQbjhnokkwQnFfd1BslSTGew8glCot7nmtzd9Gv2N0wvD1XUcHgsfUnPwmoSS1X+foSx88A+II6wcYHgCr8Baa+S+T5uIpnK8XYmle6j/QUYMNWJ2qeO+s+kozFeF3VCBHnrZY0T8JS0ZjrrEkWzmrXAGvo0aUp13ixdF3Wvs2t83xGXUMTZjtOZOHc6/84GEB9ojSi2BlvYd48GNEw3kFwDnPVNVWl+a8uldL6M2aK+ySn9UtGkrwKs4kJrVxc9xN2mkQsMiqDmDNFtxWXPetKuyZo7n0MkcXQ98+pLNX2v/pugPlIgMV+JFOldeWlgfal/XMEFb4B5ThsZ2xMn7207x0YEBa96hD/YqT8dRhjNPm8vbCQFaQgPTesVJt3mY9fmlsqG79ghmsTGis19lIdwt2BSmG1Ub6kIM0IC/8QLtfPrVQnVuCmknTArmP4xcxRD0ZHyulZ641an17yVpzGxXuJpsEfaIktmtOTUOlSZq6nDo5cQE9EYfvELZfltprtvVAgr5MJDz3yiqTs2EDQ1ex+V5gPjn0MmgRChjkojURdmtsgkhY0+cgCv8MQPwuc6XTELKBl8gc+N6QdgJnaPSU1EL7Qg4FPkLgciVzle9KfRcbRwVzDOJn9 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2011ef6c-91d3-4f81-2c95-08d98f3478e5 X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2308.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 17:02:58.0621 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: swvpDGiY8zVhsMJzhoQob6GJNWE9Dvdc4PqRqxMsQuvLUOkEfFUz7s6+9+NVMfUTjWk94GUHrotvOH4x/ECT7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5825 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Through the dpio_get_attributes() firmware call the dpio driver has access to the QBMAN clock frequency. Extend the structure which holds the firmware's response so that we can have access to this information. This will be needed in the next patches which also add support for interrupt coalescing which needs to be configured based on the frequency. Signed-off-by: Ioana Ciornei --- drivers/soc/fsl/dpio/dpio-cmd.h | 3 +++ drivers/soc/fsl/dpio/dpio-driver.c | 1 + drivers/soc/fsl/dpio/dpio-service.c | 1 + drivers/soc/fsl/dpio/dpio.c | 1 + drivers/soc/fsl/dpio/dpio.h | 2 ++ drivers/soc/fsl/dpio/qbman-portal.h | 1 + include/soc/fsl/dpaa2-io.h | 1 + 7 files changed, 10 insertions(+) diff --git a/drivers/soc/fsl/dpio/dpio-cmd.h b/drivers/soc/fsl/dpio/dpio-cmd.h index e13fd3ac1939..2fbcb78cdaaf 100644 --- a/drivers/soc/fsl/dpio/dpio-cmd.h +++ b/drivers/soc/fsl/dpio/dpio-cmd.h @@ -46,6 +46,9 @@ struct dpio_rsp_get_attr { __le64 qbman_portal_ci_addr; /* cmd word 3 */ __le32 qbman_version; + __le32 pad1; + /* cmd word 4 */ + __le32 clk; }; struct dpio_stashing_dest { diff --git a/drivers/soc/fsl/dpio/dpio-driver.c b/drivers/soc/fsl/dpio/dpio-driver.c index 7f397b4ad878..dd948889eeab 100644 --- a/drivers/soc/fsl/dpio/dpio-driver.c +++ b/drivers/soc/fsl/dpio/dpio-driver.c @@ -162,6 +162,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev) goto err_get_attr; } desc.qman_version = dpio_attrs.qbman_version; + desc.qman_clk = dpio_attrs.clk; err = dpio_enable(dpio_dev->mc_io, 0, dpio_dev->mc_handle); if (err) { diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c index 7351f3030550..2acbb96c5e45 100644 --- a/drivers/soc/fsl/dpio/dpio-service.c +++ b/drivers/soc/fsl/dpio/dpio-service.c @@ -127,6 +127,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, obj->dpio_desc = *desc; obj->swp_desc.cena_bar = obj->dpio_desc.regs_cena; obj->swp_desc.cinh_bar = obj->dpio_desc.regs_cinh; + obj->swp_desc.qman_clk = obj->dpio_desc.qman_clk; obj->swp_desc.qman_version = obj->dpio_desc.qman_version; obj->swp = qbman_swp_init(&obj->swp_desc); diff --git a/drivers/soc/fsl/dpio/dpio.c b/drivers/soc/fsl/dpio/dpio.c index af74c597a675..8ed606ffaac5 100644 --- a/drivers/soc/fsl/dpio/dpio.c +++ b/drivers/soc/fsl/dpio/dpio.c @@ -162,6 +162,7 @@ int dpio_get_attributes(struct fsl_mc_io *mc_io, attr->qbman_portal_ci_offset = le64_to_cpu(dpio_rsp->qbman_portal_ci_addr); attr->qbman_version = le32_to_cpu(dpio_rsp->qbman_version); + attr->clk = le32_to_cpu(dpio_rsp->clk); return 0; } diff --git a/drivers/soc/fsl/dpio/dpio.h b/drivers/soc/fsl/dpio/dpio.h index da06f7258098..7fda44f0d7f4 100644 --- a/drivers/soc/fsl/dpio/dpio.h +++ b/drivers/soc/fsl/dpio/dpio.h @@ -59,6 +59,7 @@ int dpio_disable(struct fsl_mc_io *mc_io, * @num_priorities: Number of priorities for the notification channel (1-8); * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' * @qbman_version: QBMAN version + * @clk: QBMAN clock frequency value in Hz */ struct dpio_attr { int id; @@ -68,6 +69,7 @@ struct dpio_attr { enum dpio_channel_mode channel_mode; u8 num_priorities; u32 qbman_version; + u32 clk; }; int dpio_get_attributes(struct fsl_mc_io *mc_io, diff --git a/drivers/soc/fsl/dpio/qbman-portal.h b/drivers/soc/fsl/dpio/qbman-portal.h index c7c2225b7d91..f058289416af 100644 --- a/drivers/soc/fsl/dpio/qbman-portal.h +++ b/drivers/soc/fsl/dpio/qbman-portal.h @@ -24,6 +24,7 @@ struct qbman_swp_desc { void *cena_bar; /* Cache-enabled portal base address */ void __iomem *cinh_bar; /* Cache-inhibited portal base address */ u32 qman_version; + u32 qman_clk; }; #define QBMAN_SWP_INTERRUPT_EQRI 0x01 diff --git a/include/soc/fsl/dpaa2-io.h b/include/soc/fsl/dpaa2-io.h index c9d849924f89..45de23daefb7 100644 --- a/include/soc/fsl/dpaa2-io.h +++ b/include/soc/fsl/dpaa2-io.h @@ -55,6 +55,7 @@ struct dpaa2_io_desc { void __iomem *regs_cinh; int dpio_id; u32 qman_version; + u32 qman_clk; }; struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, From patchwork Thu Oct 14 17:02:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12559007 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F526C433FE for ; Thu, 14 Oct 2021 17:03:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E226460EE9 for ; Thu, 14 Oct 2021 17:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233032AbhJNRFO (ORCPT ); Thu, 14 Oct 2021 13:05:14 -0400 Received: from mail-eopbgr00044.outbound.protection.outlook.com ([40.107.0.44]:20865 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231327AbhJNRFN (ORCPT ); Thu, 14 Oct 2021 13:05:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=chyLb7opFpvkcXDULdscR48ExxKoYN4Qi19LeRJD7kMS7vKJb8mgyTYUTmARptMdPvh54TRHUvDvQtmGuhnnXXn6VTLV7VUbArVuPpQFKHwBAUB83SRFVw46Y/SVXshkaMXDy4LiweAFPAa5wq4W37qHLQ7VHsQ29xkYfdyJCcYJ2czs3PN8S5ZuLE3gdIPXijf95AVqeuUFXTEw4aQG0iA+K2A2jtG9gzGSIqD09KGuRvHNClqSk1mbUcjplmRzpsbFB1kArFVc1Ox1Po2nroBVHuARZ4NNLwO+LIGan2WDAwek4F2RiJGf5gCE5BGMGaJ/i7NLKk+AztIXrMyPKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m8pUa1Q0zTsDChUZUAuWKYgMX1rNQHvsHhHy7kExR68=; b=Os2xlK4pO9gImUSllsxnJU53yN10gFt/nyT9NLakt9Pk7n+yyoJK+2Y7Ok/HB6TC50HYvA8kfYxNA5eFeIPo7WXpPzp3gfTZcABCwAI4DIpjIvaKYab3MYK575xwxBPSbvz6tk6IuV3Fb/66nDEklGmFTlkAT215KP7SLs5JZWtt0jLb9fHENoQXpgU6Ll/2LX1ClSB6sGYz+3IMC0NbAhtZO+d1F5+Ht1aEoMb1RP12bif7RasgVOflcG8+4KEkcJls6eGPC0bUzmviy3jPSvKprkPPxuGOF+rAISwZg1a1eDFYHAVZQvYPT7X2F7ckE8lhOpWNcVjO6LEi/j7cGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m8pUa1Q0zTsDChUZUAuWKYgMX1rNQHvsHhHy7kExR68=; b=RHC/rVvru/PCSUulXDeskjPQU06yv9EbZmSgLKHHYs2Cmc01hPDhYk2t5TA5Hr+l/7kJ+dxFs/NXYGPRt+qcsiOmsbLDvzvkzjLhp6L21nzzvg5LquYOG3QwH82zv50N/F8LXIM2Nt03g0N/jgeglQBaS5Ym8wiueW305s209KU= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) by AM0PR04MB5825.eurprd04.prod.outlook.com (2603:10a6:208:127::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Thu, 14 Oct 2021 17:02:59 +0000 Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726]) by AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726%8]) with mapi id 15.20.4587.030; Thu, 14 Oct 2021 17:02:59 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, netdev@vger.kernel.org, Ioana Ciornei Subject: [PATCH net-next 2/5] soc: fsl: dpio: add support for irq coalescing per software portal Date: Thu, 14 Oct 2021 20:02:12 +0300 Message-Id: <20211014170215.132687-3-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211014170215.132687-1-ioana.ciornei@nxp.com> References: <20211014170215.132687-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) To AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) MIME-Version: 1.0 Received: from yoga-910.localhost (188.26.184.231) by AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Thu, 14 Oct 2021 17:02:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 39aa587f-eb51-489c-462b-08d98f347982 X-MS-TrafficTypeDiagnostic: AM0PR04MB5825: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:179; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wEnopxi6RV3Zu4itJ+f1GcENoAhcwaCAa8d31ReMDaxyvl6GaXYjEVWANtlXknsIn8ZFst9ziDeQ/mpBLPD4KA0ivSZtSI4LQ5NIRUt5/9g6/SJ059qA8MaFB3+fSkibIhlGLmLWThtfE3ypibmNEfQ4m6S+s+A08gpip10AzPLdCUBRmgwGBcvekMicf16gCJKd82bCt0obArHzMzt2ce0xy3RZOXoT+6Ub7e2NyjlDVb/D3YBc0eMQHm3Bn+qNkkF/nVBJM34RCNP4Pt0VpwVswnhX3IyslbbdolpO/pTGrvdu95CIQ6TJNprTJYsQ750LE5jC1ZWNw6SLP2MVUAhs7Rnx0XrVR1zJS920HkCGxucIvCXuMU0PW3qmSwB3kRMzDaSsvfikRmd4qySeZVr4663qy7kquA/QfWFZx/ga9OAleqY2VtQgCF0AjtmogC61UswW7JyT+8WIELrPltr4vfa5mwZIPV5NA24P02Sd0O/gqv4lXzQmfXbZ7siYYVSuDcnqh8uvEfgexdYDu/bsijzGcN7Z5H5Ui0zEf8mOQaG0JwIoicr0Rt5eljxo7oir8M4oSrwFvJIWtJJAo6UZ6zas22Ac1Y72SE1x7s4g4FFCyuNveV9FgJnfuv0CvKKxIAme7YyWfKWYJvf7EMQWzqhYg51tQNMrsKI+/EexiL8bbS/DJcTSVee2LRU5cuK72hSV4Gsg9hWJe8bYXg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM4PR0401MB2308.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(508600001)(5660300002)(2616005)(956004)(1076003)(8936002)(6666004)(66476007)(186003)(316002)(36756003)(8676002)(4326008)(26005)(2906002)(6506007)(38350700002)(66556008)(52116002)(86362001)(44832011)(38100700002)(83380400001)(66946007)(6486002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lap5Z/PC3wdHe8ZX+cS9q5HIxX9ny5EELtPFfvv77W2KxmQWXD0v4pLus8uM6Cfumvkd05y5F2lxKXjOu5CsixOUpSgLpETvyvrAHkZWFE37lSsSWyg9fmfS8+ZCw/JUlnfW/CWFdgFoZkD3Mj5GzWivWuc3WwamykK8hX8vmZnW3crHaGNLDR0/0WACpa89Y6Ssv283jXwSITAn7NhI1zcV/6IR5/2Zdk8dPNRq37LRe2n1g1ud8c0ns4wyxY3TslsPLUmnJ+8KWMlNin+bFk1uSc+o8aMaFaDrnBqtK/e5rVyl0mlXx5PGd8DTGNoVVVn/3cKr1LpT3iN8qt6zXpVw+exed+d6244k35TdT6MJbehUaQ3YdViESbE7C6PUZUCOUt0oZ2cZmGhxKhjGrKp+QINlLMV5j6DOOfkQkbxJ/XZC3X8p66U/YyhRTiP+J99RSVlbhgIsGBv59wX4LncfoLsh6UGe80HQJXznQnSWei7rdhR4CQKZjhlkPuzkY5pmDGosfWka0dcChCwM/zIc8D6UE9ViL5uhoZi8lhKyNrAqVY9Kq5Wt+mrEusXh3xLuTLFmS5rfTxEHVZ2MszCc0mvuQfMAFyFhfjW8kT1JJqcdVe2lBQ9AyVzgu+Ets83ctIpe1Et+r/05e8dyhHBe6K9VQyUy1I42lV5wlnldzhDxQiEvGWvx0A+8GptrNFOEPpciHPrY4lvaHEyCwd56uuyCyt49R+nF97vgFsSP7yyzgeM4zNx3zTcroECT6Q+z7bg/I0wF1JAy2z/UnCAKmFDUalqY2M5wDDeR0+/bEvgMHnVtCzsg1/AecemOVbe8EhCFB9jpWW9/sxvQ6HLYhl4aceDg1T6uIXMdDWB1ZMJ1AaqG+CT3OKIlwzoP2gjmw36mWwxfT1JVTprHfdLJ+AIS38dN5kGRwtCn0azkHal1cnRQffZ3Z68ZPxV5rkR+IHmAoenr+4BAX0KMe79EvGoIvM4oh0ru+qDkDUPBrfWuN8LLMo91LMk3Kf/3IZzBxNqXK/iOwMw3BbwcWaTTgCzNkPADj8Ckz0tdjxYH0iOKe4qsKhKNX1wpOR8Hi60t4yMfX7KwuLwrYF58bQtVIlsIZICx84APXmhy9esWpZBCH5NrUaAFSbZywIC0kXYUT/SVoskIYj5Wrz5nYXZfaQZ743dJDrMiS5MoEPvUMjxCKZ6SPyrMkpM+Ex+xXjdEHalak+cpDK15YbfrlYjbafQ0FaixP9AwLkriS1665RsQe9WcvKZCl6REIG4VpycVjWGbXerW+x0rsM8tgnizyxlRAiPhpdBoz/5ENTDzmaenwkHV3m6DF0PEge6I X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39aa587f-eb51-489c-462b-08d98f347982 X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2308.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 17:02:59.1517 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gK77vIrqcb0xkBquONbP8p+s5oqYh2uBujnt+utP4JqFJes7a9IuLhqDZkGIiM1Kt38GeSMT9uCTBZf3hV7E8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5825 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In DPAA2 based SoCs, the IRQ coalesing support per software portal has 2 configurable parameters: - the IRQ timeout period (QBMAN_CINH_SWP_ITPR): how many 256 QBMAN cycles need to pass until a dequeue interrupt is asserted. - the IRQ threshold (QBMAN_CINH_SWP_DQRR_ITR): how many dequeue responses in the DQRR ring would generate an IRQ. Add support for setting up and querying these IRQ coalescing related parameters. Signed-off-by: Ioana Ciornei --- drivers/soc/fsl/dpio/dpio-service.c | 37 ++++++++++++++++++ drivers/soc/fsl/dpio/qbman-portal.c | 59 +++++++++++++++++++++++++++++ drivers/soc/fsl/dpio/qbman-portal.h | 11 ++++++ include/soc/fsl/dpaa2-io.h | 4 ++ 4 files changed, 111 insertions(+) diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c index 2acbb96c5e45..44fafed045ca 100644 --- a/drivers/soc/fsl/dpio/dpio-service.c +++ b/drivers/soc/fsl/dpio/dpio-service.c @@ -114,6 +114,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, struct device *dev) { struct dpaa2_io *obj = kmalloc(sizeof(*obj), GFP_KERNEL); + u32 qman_256_cycles_per_ns; if (!obj) return NULL; @@ -129,6 +130,13 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, obj->swp_desc.cinh_bar = obj->dpio_desc.regs_cinh; obj->swp_desc.qman_clk = obj->dpio_desc.qman_clk; obj->swp_desc.qman_version = obj->dpio_desc.qman_version; + + /* Compute how many 256 QBMAN cycles fit into one ns. This is because + * the interrupt timeout period register needs to be specified in QBMAN + * clock cycles in increments of 256. + */ + qman_256_cycles_per_ns = 256000 / (obj->swp_desc.qman_clk / 1000000); + obj->swp_desc.qman_256_cycles_per_ns = qman_256_cycles_per_ns; obj->swp = qbman_swp_init(&obj->swp_desc); if (!obj->swp) { @@ -780,3 +788,32 @@ int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid, u32 *num) return 0; } EXPORT_SYMBOL_GPL(dpaa2_io_query_bp_count); + +/** + * dpaa2_io_set_irq_coalescing() - Set new IRQ coalescing values + * @d: the given DPIO object + * @irq_holdoff: interrupt holdoff (timeout) period in us + * + * Return 0 for success, or negative error code on error. + */ +int dpaa2_io_set_irq_coalescing(struct dpaa2_io *d, u32 irq_holdoff) +{ + struct qbman_swp *swp = d->swp; + + return qbman_swp_set_irq_coalescing(swp, swp->dqrr.dqrr_size - 1, + irq_holdoff); +} +EXPORT_SYMBOL(dpaa2_io_set_irq_coalescing); + +/** + * dpaa2_io_get_irq_coalescing() - Get the current IRQ coalescing parameters + * @d: the given DPIO object + * @irq_holdoff: interrupt holdoff (timeout) period in us + */ +void dpaa2_io_get_irq_coalescing(struct dpaa2_io *d, u32 *irq_holdoff) +{ + struct qbman_swp *swp = d->swp; + + qbman_swp_get_irq_coalescing(swp, NULL, irq_holdoff); +} +EXPORT_SYMBOL(dpaa2_io_get_irq_coalescing); diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c index f13da4d7d1c5..d3c58df6240d 100644 --- a/drivers/soc/fsl/dpio/qbman-portal.c +++ b/drivers/soc/fsl/dpio/qbman-portal.c @@ -29,6 +29,7 @@ #define QBMAN_CINH_SWP_EQCR_AM_RT 0x980 #define QBMAN_CINH_SWP_RCR_AM_RT 0x9c0 #define QBMAN_CINH_SWP_DQPI 0xa00 +#define QBMAN_CINH_SWP_DQRR_ITR 0xa80 #define QBMAN_CINH_SWP_DCAP 0xac0 #define QBMAN_CINH_SWP_SDQCR 0xb00 #define QBMAN_CINH_SWP_EQCR_AM_RT2 0xb40 @@ -38,6 +39,7 @@ #define QBMAN_CINH_SWP_IER 0xe40 #define QBMAN_CINH_SWP_ISDR 0xe80 #define QBMAN_CINH_SWP_IIR 0xec0 +#define QBMAN_CINH_SWP_ITPR 0xf40 /* CENA register offsets */ #define QBMAN_CENA_SWP_EQCR(n) (0x000 + ((u32)(n) << 6)) @@ -355,6 +357,9 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d) & p->eqcr.pi_ci_mask; p->eqcr.available = p->eqcr.pi_ring_size; + /* Initialize the software portal with a irq timeout period of 0us */ + qbman_swp_set_irq_coalescing(p, p->dqrr.dqrr_size - 1, 0); + return p; } @@ -1796,3 +1801,57 @@ u32 qbman_bp_info_num_free_bufs(struct qbman_bp_query_rslt *a) { return le32_to_cpu(a->fill); } + +/** + * qbman_swp_set_irq_coalescing() - Set new IRQ coalescing values + * @p: the software portal object + * @irq_threshold: interrupt threshold + * @irq_holdoff: interrupt holdoff (timeout) period in us + * + * Return 0 for success, or negative error code on error. + */ +int qbman_swp_set_irq_coalescing(struct qbman_swp *p, u32 irq_threshold, + u32 irq_holdoff) +{ + u32 itp, max_holdoff; + + /* Convert irq_holdoff value from usecs to 256 QBMAN clock cycles + * increments. This depends to the QBMAN internal frequency. + */ + itp = (irq_holdoff * 1000) / p->desc->qman_256_cycles_per_ns; + if (itp < 0 || itp > 4096) { + max_holdoff = (p->desc->qman_256_cycles_per_ns * 4096) / 1000; + pr_err("irq_holdoff must be between 0..%dus\n", max_holdoff); + return -EINVAL; + } + + if (irq_threshold >= p->dqrr.dqrr_size || irq_threshold < 0) { + pr_err("irq_threshold must be between 0..%d\n", + p->dqrr.dqrr_size - 1); + return -EINVAL; + } + + p->irq_threshold = irq_threshold; + p->irq_holdoff = irq_holdoff; + + qbman_write_register(p, QBMAN_CINH_SWP_DQRR_ITR, irq_threshold); + qbman_write_register(p, QBMAN_CINH_SWP_ITPR, itp); + + return 0; +} + +/** + * qbman_swp_get_irq_coalescing() - Get the current IRQ coalescing parameters + * @p: the software portal object + * @irq_threshold: interrupt threshold (an IRQ is generated when there are more + * DQRR entries in the portal than the threshold) + * @irq_holdoff: interrupt holdoff (timeout) period in us + */ +void qbman_swp_get_irq_coalescing(struct qbman_swp *p, u32 *irq_threshold, + u32 *irq_holdoff) +{ + if (irq_threshold) + *irq_threshold = p->irq_threshold; + if (irq_holdoff) + *irq_holdoff = p->irq_holdoff; +} diff --git a/drivers/soc/fsl/dpio/qbman-portal.h b/drivers/soc/fsl/dpio/qbman-portal.h index f058289416af..4ea2dd950a2a 100644 --- a/drivers/soc/fsl/dpio/qbman-portal.h +++ b/drivers/soc/fsl/dpio/qbman-portal.h @@ -25,6 +25,7 @@ struct qbman_swp_desc { void __iomem *cinh_bar; /* Cache-inhibited portal base address */ u32 qman_version; u32 qman_clk; + u32 qman_256_cycles_per_ns; }; #define QBMAN_SWP_INTERRUPT_EQRI 0x01 @@ -157,6 +158,10 @@ struct qbman_swp { } eqcr; spinlock_t access_spinlock; + + /* Interrupt coalescing */ + u32 irq_threshold; + u32 irq_holdoff; }; /* Function pointers */ @@ -649,4 +654,10 @@ static inline const struct dpaa2_dq *qbman_swp_dqrr_next(struct qbman_swp *s) return qbman_swp_dqrr_next_ptr(s); } +int qbman_swp_set_irq_coalescing(struct qbman_swp *p, u32 irq_threshold, + u32 irq_holdoff); + +void qbman_swp_get_irq_coalescing(struct qbman_swp *p, u32 *irq_threshold, + u32 *irq_holdoff); + #endif /* __FSL_QBMAN_PORTAL_H */ diff --git a/include/soc/fsl/dpaa2-io.h b/include/soc/fsl/dpaa2-io.h index 45de23daefb7..31303ff32808 100644 --- a/include/soc/fsl/dpaa2-io.h +++ b/include/soc/fsl/dpaa2-io.h @@ -130,4 +130,8 @@ int dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid, u32 *fcnt, u32 *bcnt); int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid, u32 *num); + +int dpaa2_io_set_irq_coalescing(struct dpaa2_io *d, u32 irq_holdoff); +void dpaa2_io_get_irq_coalescing(struct dpaa2_io *d, u32 *irq_holdoff); + #endif /* __FSL_DPAA2_IO_H */ From patchwork Thu Oct 14 17:02:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12559011 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06076C433F5 for ; Thu, 14 Oct 2021 17:03:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFF4B60EE9 for ; Thu, 14 Oct 2021 17:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233061AbhJNRFP (ORCPT ); Thu, 14 Oct 2021 13:05:15 -0400 Received: from mail-eopbgr00044.outbound.protection.outlook.com ([40.107.0.44]:20865 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233025AbhJNRFN (ORCPT ); Thu, 14 Oct 2021 13:05:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LpUBQu+91eoBuXPwYfAYCowVVqfd4zJBMFFYf4x6kwtzq4rpZzQk/78uAxpeC/xrQPHx4SG6am6owGtBj3TnTt6tuuwrG1y2aYNqR9AeCnFp9vzGYbA/wMbmfAcRkbn9q67tAUdpEsbSpHlCo/T71TIH6cEQgFyv1mxOSUVHWidTINkCW7beyGal1FLGrff+287bwLREC3vQAxjQ7phAJR9ZFUu5we1+wPVFU0YkmjrVnACpy5IAxYFABPbC8Qnu7sLLqbNIM2aUxtflQmjYbh51E5g/JPQ+TvjSnVu2RHCMZmZhAguz4+qRvZxR2Ab0q9ScNRYHE/xtu+db3EWBtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ADUl24fy0VEkDTx0Ptz/Op4gkKH39MdHFZIQJRKE364=; b=AV3JoanttG4rQ+opjvJwsUxP9ULchQtMmYMGpHuLkNEASU87GsAmUBerbIIQmM/II3U9wbYS3n73TTQ+toldNbOOXUN+6Oh0ExImw3afQz8Ws57AlHig5MHNr07WrENi8vfkP/DqIbhqcunOO2Lx5bH2YS64Ta9hvsfPFXHBJ9mTjdfzsOc34BVTX4F5ke7uAPOpkxk9pD4u18RSrqcmsF1IkaxzhDL10fRbap9aLMOqEeOgHzr4ZDAlZ6YELJxd3pHjHAILCsmzs3YF1vU/qByOEV4gm3tw43JYnK2LuYlyTYezURvP18MdFo06qwsonCMf0qH6TyrPMgU6Rbrulg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ADUl24fy0VEkDTx0Ptz/Op4gkKH39MdHFZIQJRKE364=; b=bWZ/VWKTDMCXLS38n1TxYy6wBihfuRi3ikbjjeTHPMxnK07VfmqeUzqtcd5rutskSVNy66WqffUPDS89b1OtybZt9RyUk05zrl83wFgJyOcAEZLk+atqY3KKJE8W+MWp6IrShVSDuw8z1k33SRgrI+Wi/EDd3qm1iP0ziLKkCtY= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) by AM0PR04MB5825.eurprd04.prod.outlook.com (2603:10a6:208:127::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Thu, 14 Oct 2021 17:03:00 +0000 Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726]) by AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726%8]) with mapi id 15.20.4587.030; Thu, 14 Oct 2021 17:03:00 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, netdev@vger.kernel.org, Ioana Ciornei Subject: [PATCH net-next 3/5] net: dpaa2: add support for manual setup of IRQ coalesing Date: Thu, 14 Oct 2021 20:02:13 +0300 Message-Id: <20211014170215.132687-4-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211014170215.132687-1-ioana.ciornei@nxp.com> References: <20211014170215.132687-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) To AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) MIME-Version: 1.0 Received: from yoga-910.localhost (188.26.184.231) by AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Thu, 14 Oct 2021 17:02:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4949c38-99e8-4811-1b0e-08d98f347a09 X-MS-TrafficTypeDiagnostic: AM0PR04MB5825: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ykDG3Z8n+zOciiJH678pl10crClOahxFvZFPHnOz71WCv5AVKP7CSNYohUOlLnor45ssVdwhRDQ7wg+0mxtpeLSHDlaYjQW/0YLEyJiJZpZPNcBJwtZOrCSgGaT2TL42BNHjadG2V0u8xP15CoYMc2Jhk/lfB36GzzrDVeGviM1r+8MPlKC0htTzyFgtYnRBxincVRtu6ykW3csU4+OD+UYxkY309xLMFuk7JTbXxutdGQcfHEHY1mVg4tEtRq+cBeI6x5T9Dxt4Q25AX/cLMeAeZ5zrVZp8tpYPFo4Ylq3kCvGw+JOKlVC0VTyo1SzbtiAT8CDD0tq12UI6P+G2O9yVBy/YwIYZQw8SrZTpC+Pqib1SLhTKtanROeSHHE9+TTH4Ei5o4hxvTO4gjWIAc32vvww5GjHWvYd+mQbyVeYkfcjJCn2lknQQT0tsJ958gB07O7ysothJebi0RPDZaSieP9jF85MC/KgCkCVXpjs1D0hhmYN/KzELjh+mX1wpsgwn95+LtXHFNBluKMfKuJEw2w8mv1D6FcuTOED5253zYNw2RXeCplDseEZp6rYgengKFOi/klccC8tw0tkMfNd74wWSrqD5zhPcanGimE3KzBFMpYCeZKXlwmwyFKgONEG8R+1MAaK/W1NgU4Fg2plS1wl95BI9z7O2cxGqlya0ayeaQ65eht1ohYi+WmCQierr5oZcQ7eaJgl0HPllxw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM4PR0401MB2308.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(508600001)(5660300002)(2616005)(956004)(1076003)(8936002)(6666004)(66476007)(186003)(316002)(36756003)(8676002)(4326008)(26005)(2906002)(6506007)(38350700002)(66556008)(52116002)(86362001)(44832011)(38100700002)(83380400001)(66946007)(6486002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Llix/0pER7Unth9LyVFpxOno5MbRZ3r6vtdNhWWh5kjB8G7V9n42XZsXDuFtY9+Ztnogu0vZe/uXujRNLISFniOpvf/y78BZ7vDzND36hmJBKIEx4KUqaagkqkdnb4RSRCAs8rlxroOgFu5oJqlCxwwV/Pq1WYlQm6Bzj4Vy7nsld+LkgiHP3c7s9hyvIG5WbWGMFxom2NcXH/JVRLhQ5c27Kuw/OPGmJ5WqBgR3+gqhBq17m1TbPXb2gfX/ydJyeLllYne1diCv6cDJAZV6eADjfdntcOk7Tp+5YF/TCjHj2lmIOFZz+0l6q1HveIyMJey1yEZqT+98RvySM8cGDo14OXz9crezaCUZGJwx0MrIBJ9xxSJvGIU7vXZ//0X8okHgSxRqP4qK3jjbrrAV6RAYmwxyLsK7so/LDJPdUgeIc2Be3gE86PQlMaZ+UEOKm8xxsG2S+ZK5OvgUlRg2cUpMXeRkggsLtWCkPGsq0rTsoDJaOdVWvK6oEVNPYBM+KGZy7Vr1v23vg4AbvPpnoUdKAz1IHz/OU4kwUE038Hcu7HSY16RyNUkAE7Q6dJC8ZGMLF8j1ICMhysZGi8OmcUc2HAJ/n7uz4csJdlNF3aWJOH1AbiI7OVBUt4DyD9/jqkMjOIPLCEFhUT/YwhXHzEp8nodxwZNv+xdX+uhmOnrzam6TUDUGuRIH6fQn2a0tjjqtjn45xt/CT4GJLQg47wtFQ6BXbP5tD4gq4Knm5PfmP5xwK/dk9JUFehx41gximxhncGzcmCD5tqjIvfSysOfkXfyZVgzJD2qfa/D+ZUvLWt4+e627OgV36ujojQWeI0QguqrzGdeEzbVkEAn/EP2H8qlJ7wa8PKSh5tQnPGjbGaKbiQbwuJiE6E4cQFwmHPmQrNQfUJRgx+DtM05OqgFKrpGELAxtx61t0RKHaowm+hFGTSwtOOGi7emd9pFWG/DJ2AJam7dYNbIFAv+VP9weh/kbfwl62V2rJW27WQiD0W9TEo5kifq+E+jHkBdLREdYTaAozG4aPIS///At5Tf6tahfYnUcWi6/kS7gSLacMsFrujhO4KdlTt5gC1tqY0ifOWibryBTgTto4N9LOXi737yc4b+ul+FD2+9d0vRbspk3fAmpIXlNIhaqrcieoQwW/XxoHjUVfSQ0KiQg648B/AFbfnpp17yJrWpZRbiJQnq64wfOyUve8FrIzHfReOSp/rHabSnmQwmtMJxZ1Cf0dnDn4IJVSig5HoOILWQ/aoxZR0t4qgYkRuLt/NLq1ZrahhbwFc8kr/jJHRZjr9N4v8JSMFaVhbg5F8VnrYMvln50RWpiTQwIT1no1OhF X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4949c38-99e8-4811-1b0e-08d98f347a09 X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2308.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 17:02:59.9603 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8OaxDimbnwDgizm+izD1DesmPIglZyGNVa2XRo0/Knd3OYKsCSS1sPv9ZBqYenf+tUGsNFSHt+JVFpG77vtbOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5825 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use the newly exported dpio driver API to manually configure the IRQ coalescing parameters requested by the user. The .get_coalesce() and .set_coalesce() net_device callbacks are implemented and directly export or setup the rx-usecs on all the channels configured. Signed-off-by: Ioana Ciornei --- .../ethernet/freescale/dpaa2/dpaa2-ethtool.c | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c index 2da5f881f630..69a6860e11fa 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c @@ -820,7 +820,56 @@ static int dpaa2_eth_set_tunable(struct net_device *net_dev, return err; } +static int dpaa2_eth_get_coalesce(struct net_device *dev, + struct ethtool_coalesce *ic, + struct kernel_ethtool_coalesce *kernel_coal, + struct netlink_ext_ack *extack) +{ + struct dpaa2_eth_priv *priv = netdev_priv(dev); + struct dpaa2_io *dpio = priv->channel[0]->dpio; + + dpaa2_io_get_irq_coalescing(dpio, &ic->rx_coalesce_usecs); + + return 0; +} + +static int dpaa2_eth_set_coalesce(struct net_device *dev, + struct ethtool_coalesce *ic, + struct kernel_ethtool_coalesce *kernel_coal, + struct netlink_ext_ack *extack) +{ + struct dpaa2_eth_priv *priv = netdev_priv(dev); + struct dpaa2_io *dpio; + u32 prev_rx_usecs; + int i, j, err; + + /* Keep track of the previous value, just in case we fail */ + dpio = priv->channel[0]->dpio; + dpaa2_io_get_irq_coalescing(dpio, &prev_rx_usecs); + + /* Setup new value for rx coalescing */ + for (i = 0; i < priv->num_channels; i++) { + dpio = priv->channel[i]->dpio; + + err = dpaa2_io_set_irq_coalescing(dpio, ic->rx_coalesce_usecs); + if (err) + goto restore_rx_usecs; + } + + return 0; + +restore_rx_usecs: + for (j = 0; j < i; j++) { + dpio = priv->channel[j]->dpio; + + dpaa2_io_set_irq_coalescing(dpio, prev_rx_usecs); + } + + return err; +} + const struct ethtool_ops dpaa2_ethtool_ops = { + .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS, .get_drvinfo = dpaa2_eth_get_drvinfo, .nway_reset = dpaa2_eth_nway_reset, .get_link = ethtool_op_get_link, @@ -836,4 +885,6 @@ const struct ethtool_ops dpaa2_ethtool_ops = { .get_ts_info = dpaa2_eth_get_ts_info, .get_tunable = dpaa2_eth_get_tunable, .set_tunable = dpaa2_eth_set_tunable, + .get_coalesce = dpaa2_eth_get_coalesce, + .set_coalesce = dpaa2_eth_set_coalesce, }; From patchwork Thu Oct 14 17:02:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12559013 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8401C4332F for ; Thu, 14 Oct 2021 17:03:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C849F6109E for ; Thu, 14 Oct 2021 17:03:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233068AbhJNRFR (ORCPT ); Thu, 14 Oct 2021 13:05:17 -0400 Received: from mail-eopbgr00044.outbound.protection.outlook.com ([40.107.0.44]:20865 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231327AbhJNRFP (ORCPT ); Thu, 14 Oct 2021 13:05:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ba7QARNQLsrAWm3/yHLlNJkzq0av/9Lv4n5CPaKl0nStQKuqhXhfssq9Fx6F8Qod0VFULgHBo7WjLB9mzC8gxnyNeqEXEEabWlKRwk+YmGvPQHl0ZY7WTxV/9B9yJflrH/MOS/2zwoG6qZyDrKZl+BJ/R/rTpx9slLJwAeXzeJzdF4cUbS5UJ2gFjyqrFulx8EuF3HpSvoWb+1+wPjwvoe1++xWadLxcybTx8melUFMd6EzwO6/NCNFZrQ2w7/xVtJdEZ0J8QvNsbIJ3RomPu17WMLuBd9BayrQLA6tcEySSvTEEh99ENXhstK5WGlWCqJQNCJz1cHNwZnKP7t9LGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tD02XYiXEQj1av6QF9F5XF+1V5lt7LbSfkOHfJbIzU0=; b=bR336vWgdcpEBcwv89N1zyQJJAolaD9xYZ9mpBs+C8VCGvJ1Scve/7D/kfNM2Cz2YTgicRYoJly0HjrUwlCXam5o9c2+je/M7cTf859i/bdpDSgWhlFjpoRnKssuntQ0901zWGL58bTuag1AS8sRJt8S95V2Ri83Fp/Frmg51mv1P+09AnjqvlFDFT44XWWdaO6zTYiT10XMpUlvI8ftySmRQ8ej7AMSk+SWXiyJ0K5tWdhDN0Z7JyrK+BN/kzY8YbeGAdY2CpupPWQG2XCU6hFRYgwkLwpcdmTT+DPfMrOlY1GO5uHIvosnXWAyBqnXjofZ9zj4n2xnjp0MScmoXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tD02XYiXEQj1av6QF9F5XF+1V5lt7LbSfkOHfJbIzU0=; b=FG4qS2q4XFp4DDjHSNYNNJrtfaRcD9tEfMIQZ5hfRBsFqEoT/H0o97gktPeeLQd63tWQcP4zqXq1GlGm2u+knuyRAVXtNoTNedlCpFaEiLFgT8zLb/Tn2Joc/+j5C4CAtGKTlIlz8+23vLA0MRmvy+ZdqWulfKuDddUWGV92Nx4= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) by AM0PR04MB5825.eurprd04.prod.outlook.com (2603:10a6:208:127::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Thu, 14 Oct 2021 17:03:01 +0000 Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726]) by AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726%8]) with mapi id 15.20.4587.030; Thu, 14 Oct 2021 17:03:01 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, netdev@vger.kernel.org, Ioana Ciornei Subject: [PATCH net-next 4/5] soc: fsl: dpio: add Net DIM integration Date: Thu, 14 Oct 2021 20:02:14 +0300 Message-Id: <20211014170215.132687-5-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211014170215.132687-1-ioana.ciornei@nxp.com> References: <20211014170215.132687-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) To AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) MIME-Version: 1.0 Received: from yoga-910.localhost (188.26.184.231) by AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Thu, 14 Oct 2021 17:03:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fa6d3009-0051-4805-949f-08d98f347a95 X-MS-TrafficTypeDiagnostic: AM0PR04MB5825: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OlFh40AdkxvaE+bYc4/1cQvOsxJr14THHVrBxiQkaBG238MUChQ9U8bDZk57rxT956NMNGRNVjqjQbDrOs7LUGOMB/pBOeuVM6wG+BwIfuwxgoWQPEfiF9jRXvstp7Vs780uJx4xcUqrV4ZE40pe6IvEmPD4DBn+bNJ2GOzVvhJm2EDr7cNyeIi6ONHkAGv0G+ZjiGja3ArBh7rDeoQaVtqDXLLiumlqhsu5KxLc18wVw+N0vmPw2b3OWf6gYGXYA1J8o2407+bAK4d71ewSQvHskAD+mLOuAWebeW06wliwhRJdV4v0hB0RyJ3LunvzLGlisdsHQS+dGnghFf+21rghg3NknoPQMYoFEifcAc9rDn51DGBY4p3FeKVH+kDJt2J5Pz+w3XAE4Ce6DfCMhm4ovzOLPrMefk2bl3+gnRytR6A7n0MWJLAWIZ23liEjPbcu88r9n7P2cTEDd9xu0qeLUv2wvja5YvSzbPxDtx8GBBdtm8gFgUW3M8vCofLjgvvLR5yZOdD6bpfI0UKdKLKKtV0EwThTxeNhbDY0WrOz+aBLsy5bHE9LbygyS1lnOrVCvYlt8zVSU6eP2FyZkPi5U4+VGeSW0/P6b0loKyoDOdjiaZKD3GFDBsND4LzpUXM37g6j/40UioaSEP4fxcK8R2oJIVddECOiDuki3roZdHo89r41DQ9v54SYlYj+0VXc8s0rl0BB0T1l93jnFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM4PR0401MB2308.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(508600001)(5660300002)(2616005)(956004)(1076003)(8936002)(6666004)(66476007)(186003)(316002)(36756003)(8676002)(4326008)(26005)(2906002)(6506007)(38350700002)(66556008)(52116002)(86362001)(44832011)(38100700002)(83380400001)(66946007)(6486002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q6fEGbSB3Ct1VE6OtGueMkXwy0abstRu3vURWRYnuMHRcp5gTPGwBws5Z5H2xzSe6pVomv3o8fgWHB1FYI9w1fQCvdSrLp8yVXMFzYJMm2RdKjpIoS2pxbezhuLaNwFatEQauXOr7mm2I82QY8RYn2K+AAcqidgi3sxSGEkgKV4ccGJruL0y0U8UTI5kd3L7AHSMbinb+6DI1qX8X4NmwDcYqw8HahJOyLU94B/7n/w2C83NVn/c9D3Igb3YllDoX2keNB2OcIseu6Aczw6AzbHngDR8ieEaSeEAV/WaY2MwgJb2XLrV4Xm+kmYmC5dgp2VjJP6knwg6u0h6eUyFyIGo/7G0gRvQZMrT101l/twrG8desssnifq0MHBGXR8Heuak4NBXpY0Zz1tSZmfpRtOTEXxovi/C166btoDXnOrDr9fMsvfEOgMGQ4fILTTNg8IBEjMYZloKpF1Kf82OFleoGvTwb+E+NO/JEOG3EhX2k/+V0mDftWHO2+UbIwCkDAeJBbF35Ub660HQrx32ZBt14zhIKPsNkt4wMeFloY0urRkMe5jF5pSBBwLmAYgAltE7K9rHyDaOrFJVqthh+MHqU+IAD8v67lmQa3UFUApwghbzy4H7PIQV94gy+MjT+UHOxlzfwKp66fUMwAcowO8w++FwyhbtFVTpdtH5s1u2JRZfkFP7+Ak48B5CzD9o4Vv1r17t3ozKzKf1Kvirk8Cq6o6l7alT3RTMjtiOHfeprUQR+mjwt36c7iZzzH39ANAmmAsbx9wnuIaYmp3UZWlf8IKARNFV+7SpaQSOrEIEYoWCrBLPOj0iokcK6LVWVbDXJoDcovWv3uhCn42jWTThwRNDgOoAcjooYxcC7VumIRwE7C+Zx2EWaZhiyteTk8HqLv5hHwnYrT1o+zStqouRRU7o+t6CtqruiaQdFWWuHPooIKf1NZ3AYJFBWcI74hngjgl88f/ShkPQ6tmLcaJu4HcOhKc6EWlAun3+7QYeG71BBxnNaMZL3dCMr4I4TRKKq7r6aqprU1/UyRZgl59q8vl1Fxj8LbyArh+LDws/Hg4DO+7TDDwd0vQJNyekIiD4oyVDYsh49zy2uBenVDsoqBLEvadxm/Y5Cg7uALXDnodmJjuURE50zN0wBeJ239Ahvif8lDCIwjEr0B5uCE4U/+qxwbAwk+Jr+r7lfXPsIf0UcSGmiVA35ppIEX7LYYyJHU1AYpkQ3r5ee41IVBU/E/ey3DP/nGYFS7X6YeesenPVpV5f+eQSrfxVV2PBkj8tFQHI8Z7Ug/jiS593k8q67u3qZBcEJ+OEq9vQPJBLjKwkq19+r+xD34myxcXW X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa6d3009-0051-4805-949f-08d98f347a95 X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2308.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 17:03:00.9219 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OkNZmDv8jKF5zahG/WLLDHBNEGiC5tH8oLCNIx5BQ0fscylf7Mc9aIs5Vgb0CrWA2WKnh6OfI5wdjG0MKrCSlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5825 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use the generic dynamic interrupt moderation (dim) framework to implement adaptive interrupt coalescing on Rx. With the per-packet interrupt scheme, a high interrupt rate has been noted for moderate traffic flows leading to high CPU utilization. The dpio driver exports new functions to enable/disable adaptive IRQ coalescing on a DPIO object, to query the state or to update Net DIM with a new set of bytes and frames dequeued. Signed-off-by: Ioana Ciornei --- drivers/soc/fsl/Kconfig | 1 + drivers/soc/fsl/dpio/dpio-service.c | 79 +++++++++++++++++++++++++++++ drivers/soc/fsl/dpio/qbman-portal.h | 1 + include/soc/fsl/dpaa2-io.h | 5 +- 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index 4df32bc4c7a6..07d52cafbb31 100644 --- a/drivers/soc/fsl/Kconfig +++ b/drivers/soc/fsl/Kconfig @@ -24,6 +24,7 @@ config FSL_MC_DPIO tristate "QorIQ DPAA2 DPIO driver" depends on FSL_MC_BUS select SOC_BUS + select DIMLIB help Driver for the DPAA2 DPIO object. A DPIO provides queue and buffer management facilities for software to interact with diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c index 44fafed045ca..3fd0d0840287 100644 --- a/drivers/soc/fsl/dpio/dpio-service.c +++ b/drivers/soc/fsl/dpio/dpio-service.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "dpio.h" @@ -28,6 +29,14 @@ struct dpaa2_io { spinlock_t lock_notifications; struct list_head notifications; struct device *dev; + + /* Net DIM */ + struct dim rx_dim; + /* protect against concurrent Net DIM updates */ + spinlock_t dim_lock; + u16 event_ctr; + u64 bytes; + u64 frames; }; struct dpaa2_io_store { @@ -100,6 +109,17 @@ struct dpaa2_io *dpaa2_io_service_select(int cpu) } EXPORT_SYMBOL_GPL(dpaa2_io_service_select); +static void dpaa2_io_dim_work(struct work_struct *w) +{ + struct dim *dim = container_of(w, struct dim, work); + struct dim_cq_moder moder = + net_dim_get_rx_moderation(dim->mode, dim->profile_ix); + struct dpaa2_io *d = container_of(dim, struct dpaa2_io, rx_dim); + + dpaa2_io_set_irq_coalescing(d, moder.usec); + dim->state = DIM_START_MEASURE; +} + /** * dpaa2_io_create() - create a dpaa2_io object. * @desc: the dpaa2_io descriptor @@ -147,6 +167,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, INIT_LIST_HEAD(&obj->node); spin_lock_init(&obj->lock_mgmt_cmd); spin_lock_init(&obj->lock_notifications); + spin_lock_init(&obj->dim_lock); INIT_LIST_HEAD(&obj->notifications); /* For now only enable DQRR interrupts */ @@ -164,6 +185,12 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, obj->dev = dev; + memset(&obj->rx_dim, 0, sizeof(obj->rx_dim)); + INIT_WORK(&obj->rx_dim.work, dpaa2_io_dim_work); + obj->event_ctr = 0; + obj->bytes = 0; + obj->frames = 0; + return obj; } @@ -203,6 +230,8 @@ irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj) struct qbman_swp *swp; u32 status; + obj->event_ctr++; + swp = obj->swp; status = qbman_swp_interrupt_read_status(swp); if (!status) @@ -817,3 +846,53 @@ void dpaa2_io_get_irq_coalescing(struct dpaa2_io *d, u32 *irq_holdoff) qbman_swp_get_irq_coalescing(swp, NULL, irq_holdoff); } EXPORT_SYMBOL(dpaa2_io_get_irq_coalescing); + +/** + * dpaa2_io_set_adaptive_coalescing() - Enable/disable adaptive coalescing + * @d: the given DPIO object + * @use_adaptive_rx_coalesce: adaptive coalescing state + */ +void dpaa2_io_set_adaptive_coalescing(struct dpaa2_io *d, + int use_adaptive_rx_coalesce) +{ + d->swp->use_adaptive_rx_coalesce = use_adaptive_rx_coalesce; +} +EXPORT_SYMBOL(dpaa2_io_set_adaptive_coalescing); + +/** + * dpaa2_io_get_adaptive_coalescing() - Query adaptive coalescing state + * @d: the given DPIO object + * + * Return 1 when adaptive coalescing is enabled on the DPIO object and 0 + * otherwise. + */ +int dpaa2_io_get_adaptive_coalescing(struct dpaa2_io *d) +{ + return d->swp->use_adaptive_rx_coalesce; +} +EXPORT_SYMBOL(dpaa2_io_get_adaptive_coalescing); + +/** + * dpaa2_io_update_net_dim() - Update Net DIM + * @d: the given DPIO object + * @frames: how many frames have been dequeued by the user since the last call + * @bytes: how many bytes have been dequeued by the user since the last call + */ +void dpaa2_io_update_net_dim(struct dpaa2_io *d, __u64 frames, __u64 bytes) +{ + struct dim_sample dim_sample = {}; + + if (!d->swp->use_adaptive_rx_coalesce) + return; + + spin_lock(&d->dim_lock); + + d->bytes += bytes; + d->frames += frames; + + dim_update_sample(d->event_ctr, d->frames, d->bytes, &dim_sample); + net_dim(&d->rx_dim, dim_sample); + + spin_unlock(&d->dim_lock); +} +EXPORT_SYMBOL(dpaa2_io_update_net_dim); diff --git a/drivers/soc/fsl/dpio/qbman-portal.h b/drivers/soc/fsl/dpio/qbman-portal.h index 4ea2dd950a2a..b23883dd2725 100644 --- a/drivers/soc/fsl/dpio/qbman-portal.h +++ b/drivers/soc/fsl/dpio/qbman-portal.h @@ -162,6 +162,7 @@ struct qbman_swp { /* Interrupt coalescing */ u32 irq_threshold; u32 irq_holdoff; + int use_adaptive_rx_coalesce; }; /* Function pointers */ diff --git a/include/soc/fsl/dpaa2-io.h b/include/soc/fsl/dpaa2-io.h index 31303ff32808..0f20853be167 100644 --- a/include/soc/fsl/dpaa2-io.h +++ b/include/soc/fsl/dpaa2-io.h @@ -133,5 +133,8 @@ int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid, int dpaa2_io_set_irq_coalescing(struct dpaa2_io *d, u32 irq_holdoff); void dpaa2_io_get_irq_coalescing(struct dpaa2_io *d, u32 *irq_holdoff); - +void dpaa2_io_set_adaptive_coalescing(struct dpaa2_io *d, + int use_adaptive_rx_coalesce); +int dpaa2_io_get_adaptive_coalescing(struct dpaa2_io *d); +void dpaa2_io_update_net_dim(struct dpaa2_io *d, __u64 frames, __u64 bytes); #endif /* __FSL_DPAA2_IO_H */ From patchwork Thu Oct 14 17:02:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12559015 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDF6EC433F5 for ; Thu, 14 Oct 2021 17:03:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCA7A6109E for ; Thu, 14 Oct 2021 17:03:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233087AbhJNRFU (ORCPT ); Thu, 14 Oct 2021 13:05:20 -0400 Received: from mail-eopbgr00044.outbound.protection.outlook.com ([40.107.0.44]:20865 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233025AbhJNRFQ (ORCPT ); Thu, 14 Oct 2021 13:05:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QlWrmz3BMJ+83Q7oUHvp1LRdxeRHSxAXsbJ+QtgyxvkkV0mTIN/Qm9VfwZH5wqYlLqALu8PYFWipiDJ9w3nUNyxWXhKeMpw0LQx3SE3dh4KSqlzJnOcWz9GiNZKRrPekstzJ3EY4jXO2oaLGxRRo2wvqJOX9m7hHqMDhgeoLsTPbRItoL/FGof54v2uWuGDc06B0w5zCzc38KMqMkR6kfgrXu5w+m56OvFtnFL8yPSlukg+0uDHA/2m2fIZpNBSb9CVVzZv4Mls0aAjqo1qiysFApxMhcTiFcy47XdPQroWtHunU2y6x6aY6WdV0fxxLOQF7wv1Kuokc6IBlzXcFNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xO9H/PtdWRYzOjvfIswzxLjZeVAcdTaqV7EN6V/Y4QY=; b=cAKsdn1hEJWyVNwTw13yFGvn6XeRCZmJCGyUBsxMPm2sRXA3wIJeUZgj6HkwEr2li6cfaaJfkPAZNDLVcFN+TmZTwCWHdchSWfPswKapPt9eexFJRWc8bEFIVP/cLN1dInIWWBeg/gLUVWMe4rGcNK9I3z/US9/3NPJjlAb5vesvFSIG3rGJd5Gm//FoszEJ/WvGRlcTmWkvwurrs5t7WxXXdZhaKqf+W7T9KMfgM4PNpCO9GGngoqn7TN0UBd7Lktvng4gTrnVbynzCGc0wTPx0/d98IxvIDNAhHjJTbVWPpog0woRSRmcjdbdFT5JS0o7egu8YxjaVeE9Uoal/lw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xO9H/PtdWRYzOjvfIswzxLjZeVAcdTaqV7EN6V/Y4QY=; b=cJf9R7sLUH4eMCmyUC0BiDzypb3ba/nrlbyncl6pObSkZPwW4bo0qUWksjbfcZsDH0pZGGZnmR/Fwh5jKJehBpqRiGQZ+0EE9vyUtPzX4XPI6o+3CI+ygt4DG3u0zS+G3WMyTZ1Q+qxGtrcuRxOa6iCxX+NJPwhUiMc8nGIYuRY= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) by AM0PR04MB5825.eurprd04.prod.outlook.com (2603:10a6:208:127::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Thu, 14 Oct 2021 17:03:02 +0000 Received: from AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726]) by AM4PR0401MB2308.eurprd04.prod.outlook.com ([fe80::6476:5ddb:7bf2:e726%8]) with mapi id 15.20.4587.030; Thu, 14 Oct 2021 17:03:01 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, netdev@vger.kernel.org, Ioana Ciornei Subject: [PATCH net-next 5/5] net: dpaa2: add adaptive interrupt coalescing Date: Thu, 14 Oct 2021 20:02:15 +0300 Message-Id: <20211014170215.132687-6-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211014170215.132687-1-ioana.ciornei@nxp.com> References: <20211014170215.132687-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) To AM4PR0401MB2308.eurprd04.prod.outlook.com (2603:10a6:200:4f::13) MIME-Version: 1.0 Received: from yoga-910.localhost (188.26.184.231) by AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Thu, 14 Oct 2021 17:03:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a0e1d4e-eab3-484a-c8a2-08d98f347b26 X-MS-TrafficTypeDiagnostic: AM0PR04MB5825: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TSf7giV6MMhWW2vC8Vd8hw9528/0bv75a71Hr2gKln8+5xCYgGY+1DU9B1enf2z3iXRLwIWUdohMAIWHUTZ8qrYAiuriELdgpbFIyHziV334UR6HqHPFRxetvl+ERy1Npyfp9aMGk0UD/dBRkQxLemmWaT0kYZ5op581pfA9+bLETVbOkGAxao8QzxqTcVBPW/tud8WFCknINp45q7x5smgwJaviuTVt5nkd7aOtGCPAw+mweOeYmbCGX40JeKn7NmEHUHCO3HjgE/+LgDMFqmH5VBePy9VvN7q+q0X9XM7ZghAO7OkkM/HdOcGFbCB6dnt8iKU4QZhJO0E1UfVlcdU8ON+/B72I+zFNQfO/KO/o04/FVPEIRhPKaIRXSkmR2ji7TI/1TRVWuTGDJuKqi1Yn4CTpXPwv1m5uAMqxqBblpPSoSXcZgO8IYyUpKdeQtx0SvebVyafTLwx+08uZLJHZ3XiFLroOekzgY+UCrPkj+UeNQjm+XIUd9gQi9d1xAfqvgqVi6PDLaRNUbR1Wi7sxZh5LbM4kgSrdboVUYCflB/M0e9mk5plupRENocWjKQ5PHExNibnkDwI3vn6NVxEh1Fsj2hT5jvRRS4wsP/I4qkFA74SVIvalNZ4kM9DHBQEo/JSAR4Tk8MY8pPljfwUW6rUokQLRPRqzOZjexZXorp3j+IOKBEtiyvdB6uPpOiSggWTnKkfCf27jKfrYRw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM4PR0401MB2308.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(508600001)(5660300002)(2616005)(956004)(1076003)(8936002)(6666004)(66476007)(186003)(316002)(36756003)(8676002)(4326008)(26005)(2906002)(6506007)(38350700002)(66556008)(52116002)(86362001)(44832011)(38100700002)(83380400001)(66946007)(6486002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VzLLUSEzuOS8qOpgBtu51mAwRogH8CLs4/qwdOcJg6WavCH2igFO4nEH0cYgP5c7g0adNYGFaDgCtFKWBF21nT98Sjf2hJ6wqToy4kHx3snGTDoBdtOnkb/dVMNzpd3fV5GLV6nTmMQTO3ANzAwQqtXJQy/UQx6X/cn/NBFRze2oJBd33mB78jUcNa2d/lVFGEeSGN6uu7pRx6PDYfAsHfqNTEbJgumN1N3eVZAiY1h9StPxK2uSvRU4xnu6Mexm/VkuOwbOACpg8/3hpxl0GyWwuetiGUV5ifdylztyw1dfQCDG/aTPAU06VG4jmF9iv2oGiWYiHVHDM1BtQVVXiw20+tl6yQZNuvdAneE9U+Mja6YZuKR+YYqorjigsFQTMoOQp6u4+CGJrlX+dYQLZVUPTf7aklaAjZ/5GkI1J9a50jJHhAQ9zVvc3AtiuLVV24QBY6WK6hKQN5Zk/gSaYnpvNdW8PAPvu0VU4zEbnljNYxV76Rsw+K6qTCK0Q8H1jn13QAlaeG013UCgzRGNU6khWG1NejJ956AjrxQThG3GlhQpL5GTO0lE30NUpSWtamDfz2jQf5KwteyBR1sETEM0kdHSdX0sLvWztw+YDxvqgs3FRzHk+8vwUG30gfdFK6FocURz+lLHl/RosFYFmQl8yF+WsSxbBbXVICWUpBgVRIXv0tiwg7rvFcxnluMtQcJMrCvpVJMtwaKWlbEwlNYZW1ZdMc0LM9N46F0N9Bq51C0gzhoyH0Lyus/I8+fdc7TcTeLrKsX35vZICJIRRSZuXKCsOALfoZZu1tHHey0ZzuLnKv+QNexqfcRX0KgKdWH0hz3TFBgexUxsK8xgEum0bCAV8dmicgOFjUVWkAdDFTBXH+TPLvJ1PqTkj6paTZmlsVJLWCCgG19u1G6ObbeqtZAOUbWEcCcIqomfdupbgSvX9yzX/OTG6s9/H5Y3nI8yv+0xt35DnHxgRSoLmzKwqinFd2mDlTZhyM3Rcfr+0LrhpB4D2w5res/ODZh+0qtXif2UrKA62spvtICeFa/VdG9NrtX5HstFJ0XEnshGYay8khmu/PFtd3RdsccIbJH51EJ2lxPQTSoz2Wp7D8vN35Hq+QUk8ZTC9SGjTEZEsH4dUP2H/Ggg8ApRIUPNx9QLGnDBegKkdNrzZaHndm05qYPXIJYLnrfit4ETClphf2ENKOK54pIwRvti5PXdA3tjMA4zC3oV+oIJlfJy31Tf6+mjUxdxi7LE6miqFbGB8ErU7G/PeSNLeOU22iH9dWrs9K5gWXxhZgaNnvXAV1A+gFda8ezdRsvSJCUopGZLUerpiyOE82B+K7fINc0v X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a0e1d4e-eab3-484a-c8a2-08d98f347b26 X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2308.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 17:03:01.8835 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jjE9JApm/IBe5z9BG7LpXZ8FuRWWOKAMt03m56HpPipzEOltESVWY+j+mm22UfRSJXvHhdatzIDdYwq/mrRKwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5825 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add support for adaptive interrupt coalescing to the dpaa2-eth driver. First of all, ETHTOOL_COALESCE_USE_ADAPTIVE_RX is defined as a supported coalesce parameter and the requested state is configured through the dpio APIs added in the previous patch. Besides the ethtool API interaction, we keep track of how many bytes and frames are dequeued per CDAN (Channel Data Availability Notification) and update the Net DIM instance through the dpaa2_io_update_net_dim() API. Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 11 ++++++++++- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 2 ++ drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c | 9 ++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 34f189271ef2..714e961e7a77 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -533,6 +533,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, percpu_stats->rx_packets++; percpu_stats->rx_bytes += dpaa2_fd_get_len(fd); + ch->stats.bytes_per_cdan += dpaa2_fd_get_len(fd); list_add_tail(&skb->list, ch->rx_list); @@ -641,6 +642,7 @@ static int dpaa2_eth_consume_frames(struct dpaa2_eth_channel *ch, fq->stats.frames += cleaned; ch->stats.frames += cleaned; + ch->stats.frames_per_cdan += cleaned; /* A dequeue operation only pulls frames from a single queue * into the store. Return the frame queue as an out param. @@ -1264,7 +1266,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) /* Tx confirmation frame processing routine */ static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv, - struct dpaa2_eth_channel *ch __always_unused, + struct dpaa2_eth_channel *ch, const struct dpaa2_fd *fd, struct dpaa2_eth_fq *fq) { @@ -1279,6 +1281,7 @@ static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv, percpu_extras = this_cpu_ptr(priv->percpu_extras); percpu_extras->tx_conf_frames++; percpu_extras->tx_conf_bytes += fd_len; + ch->stats.bytes_per_cdan += fd_len; /* Check frame errors in the FD field */ fd_errors = dpaa2_fd_get_ctrl(fd) & DPAA2_FD_TX_ERR_MASK; @@ -1601,6 +1604,12 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int budget) } } while (store_cleaned); + /* Update NET DIM with the values for this CDAN */ + dpaa2_io_update_net_dim(ch->dpio, ch->stats.frames_per_cdan, + ch->stats.bytes_per_cdan); + ch->stats.frames_per_cdan = 0; + ch->stats.bytes_per_cdan = 0; + /* We didn't consume the entire budget, so finish napi and * re-enable data availability notifications */ diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index 628d2d45f045..2085844227fe 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -384,6 +384,8 @@ struct dpaa2_eth_ch_stats { __u64 xdp_redirect; /* Must be last, does not show up in ethtool stats */ __u64 frames; + __u64 frames_per_cdan; + __u64 bytes_per_cdan; }; /* Maximum number of queues associated with a DPNI */ diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c index 69a6860e11fa..adb8ce5306ee 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c @@ -829,6 +829,7 @@ static int dpaa2_eth_get_coalesce(struct net_device *dev, struct dpaa2_io *dpio = priv->channel[0]->dpio; dpaa2_io_get_irq_coalescing(dpio, &ic->rx_coalesce_usecs); + ic->use_adaptive_rx_coalesce = dpaa2_io_get_adaptive_coalescing(dpio); return 0; } @@ -840,17 +841,21 @@ static int dpaa2_eth_set_coalesce(struct net_device *dev, { struct dpaa2_eth_priv *priv = netdev_priv(dev); struct dpaa2_io *dpio; + int prev_adaptive; u32 prev_rx_usecs; int i, j, err; /* Keep track of the previous value, just in case we fail */ dpio = priv->channel[0]->dpio; dpaa2_io_get_irq_coalescing(dpio, &prev_rx_usecs); + prev_adaptive = dpaa2_io_get_adaptive_coalescing(dpio); /* Setup new value for rx coalescing */ for (i = 0; i < priv->num_channels; i++) { dpio = priv->channel[i]->dpio; + dpaa2_io_set_adaptive_coalescing(dpio, + ic->use_adaptive_rx_coalesce); err = dpaa2_io_set_irq_coalescing(dpio, ic->rx_coalesce_usecs); if (err) goto restore_rx_usecs; @@ -863,13 +868,15 @@ static int dpaa2_eth_set_coalesce(struct net_device *dev, dpio = priv->channel[j]->dpio; dpaa2_io_set_irq_coalescing(dpio, prev_rx_usecs); + dpaa2_io_set_adaptive_coalescing(dpio, prev_adaptive); } return err; } const struct ethtool_ops dpaa2_ethtool_ops = { - .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS, + .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS | + ETHTOOL_COALESCE_USE_ADAPTIVE_RX, .get_drvinfo = dpaa2_eth_get_drvinfo, .nway_reset = dpaa2_eth_nway_reset, .get_link = ethtool_op_get_link,