From patchwork Wed Jan 16 09:57:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 1025717 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="jYq3fjnf"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43fjLw4vjzz9sBZ for ; Wed, 16 Jan 2019 20:58:00 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403995AbfAPJ56 (ORCPT ); Wed, 16 Jan 2019 04:57:58 -0500 Received: from mail-eopbgr150051.outbound.protection.outlook.com ([40.107.15.51]:48928 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2403964AbfAPJ5z (ORCPT ); Wed, 16 Jan 2019 04:57:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TI/URupZU31/8fPrc6fTHjr7HnRYOoID9StM6GzFfWo=; b=jYq3fjnfr2oeSelJQkyb2NOYtpbuJfapcDPqwsMxZS9oRQLuajhA1gOs3aJPoWHIFnZiiWxaPb4YWCVCDkOH6dp4cgEc4+E1CddYAba2k9+4G97Mr5mvFys3y/Vo9J2pUv6RcqOlNrMqkCO7TVU+wZY5LR2iiDKyWa10SjSHY5Y= Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com (10.172.255.18) by VI1PR0402MB3775.eurprd04.prod.outlook.com (52.134.15.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.19; Wed, 16 Jan 2019 09:57:52 +0000 Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::8c7b:7d91:36c7:1426]) by VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::8c7b:7d91:36c7:1426%7]) with mapi id 15.20.1537.018; Wed, 16 Jan 2019 09:57:52 +0000 From: Ioana Ciornei To: "davem@davemloft.net" CC: "netdev@vger.kernel.org" , Ioana Ciocoi Radulescu , Ioana Ciornei Subject: [PATCH net-next 1/2] dpaa2-eth: transform dpaa2_eth_queue_count into a macro Thread-Topic: [PATCH net-next 1/2] dpaa2-eth: transform dpaa2_eth_queue_count into a macro Thread-Index: AQHUrYHycsUb6dyUMUu2gNlSptHzgg== Date: Wed, 16 Jan 2019 09:57:52 +0000 Message-ID: <1547632637-22959-2-git-send-email-ioana.ciornei@nxp.com> References: <1547632637-22959-1-git-send-email-ioana.ciornei@nxp.com> In-Reply-To: <1547632637-22959-1-git-send-email-ioana.ciornei@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0202CA0013.eurprd02.prod.outlook.com (2603:10a6:803:14::26) To VI1PR0402MB2800.eurprd04.prod.outlook.com (2603:10a6:800:ad::18) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 1.9.1 x-originating-ip: [86.34.165.90] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0402MB3775; 6:RAA5gthaCZkR3xlZdrwMhbaii7LDjTNciclAwSPQobEpEKt+0LG+bFKnUof3/7aiyBBDn0R4Q5NY+VgbuzDkpWwcu27HxfEOjolXzAJkvpjwfMCZyW78cz2d/M01OkdmkzYZ2Yli6kPTMogN+OnfcsKKwSyCyGHCAPssO3SdWgViSY1/sHwvFj/KTYtFuFaUgIzh9uEBPTShBmv0yuR+2HaIcNbEJJE33n8K1PkD9tXHhATob8H4ZEK8SdyyWidKcckueuyoV+VTQeWy4Hh/gyJZgpyZO4nCpwsYLqJsm8jUOEGfhKksliqh8kJ53l2rHu2I7cQSk8aa21ZM9L3eWXgOpSeto2j2VqQTzeGFS6s1gM1uMv9GJNApY68ZThwDlqIZ2//yt7GPLcP+/kIuN+TEeKrnR3vDXz2Q6aTARP5eE43XXumVzBeppNtJgwxRxmK6zzIcaO1Ff2kxTeP3CA==; 5:4z9JcyfHfE37M3bbGVXmUeUZWn8zxCoMuZgGbXu1yHrK8VScWGBI60iYX+JOOp/hLVv65ZPGGCtXVCgtjLmxJcyRX5LZbxH6Lb9p4yiSy6yAE1qHyRHHLOk0lRD61qeyq5keePnP0vKhM313zvoYYOqGma4oGzFQiXTzRGJ38T+5sV68jNiIvoQLL28Ngjl7Y+rU508CsP594ugnzxp7oQ==; 7:lssAW35scUMf6iywg9gdWzW0uzulzyitgUKKoZKRDr4XeLC5ue6LeSJ6KnklVijl7kosP5HHufmQE5DXRK1QFGCFBVOlWSefrQ/vIUPu6MqMGY08TpkCD1TkzxXzlkQIQFeXqXsmjHIkdfp2kPrCrg== x-ms-office365-filtering-correlation-id: 7503f52f-3604-499e-6bf9-08d67b991471 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3775; x-ms-traffictypediagnostic: VI1PR0402MB3775: x-microsoft-antispam-prvs: x-forefront-prvs: 091949432C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(136003)(346002)(396003)(366004)(39860400002)(189003)(199004)(86362001)(99286004)(71200400001)(71190400001)(7736002)(478600001)(25786009)(4326008)(53936002)(36756003)(2501003)(97736004)(305945005)(14454004)(256004)(5660300001)(6916009)(6506007)(26005)(186003)(50226002)(44832011)(81166006)(102836004)(8936002)(6346003)(2906002)(386003)(68736007)(106356001)(486006)(2351001)(105586002)(1730700003)(316002)(81156014)(66066001)(54906003)(8676002)(6512007)(5640700003)(76176011)(52116002)(6486002)(11346002)(2616005)(476003)(446003)(6116002)(3846002)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3775; H:VI1PR0402MB2800.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ioana.ciornei@nxp.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: NFHF1cIHy3BPY3cUNPwcGeqUoR+NlQAB/Y6vJ/TwKCdWbgRW8QR7mEAXciIpIRug2plHif3aO4MwCS/KEtuDpCyWuOsn+EiBz6Wn6QSadUvbpmh6Gn8fYTe6HM9lv0AirBkE23DsLdxnuZXnXvLL3Hr3mQx0boJlBIpWugo74llL3NHwf5uIQ8DZFv6vSTMT5INyvgWWFPPyybCpZ8SY0qaKfAYipw1ULTMTS6B1ucKgRYHFzwuZmwa+cUoSl4v+enks3q+FfC4ljZJv0AJk6m4iN2ZoWwCXflNPuQJMl/RnI/eJ5JPm7fj19N9D5B76Q8/T/dBoyl2XErEE+kqB/u3ZMFCu9Uk6q1gp5wghdw93UkU867jCMDJxstXTvfMSb9VVl1HnDhy8etWO/IrGQcqUcF8jAFNX9v4LqlL6MKY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7503f52f-3604-499e-6bf9-08d67b991471 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jan 2019 09:57:52.1553 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3775 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Transform dpaa2_eth_queue_count into a macro to follow the the convention used by dpaa2_eth_fs_count and other functions. Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index 69c965d..308aae6 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -405,6 +405,10 @@ static inline int dpaa2_eth_cmp_dpni_ver(struct dpaa2_eth_priv *priv, #define dpaa2_eth_fs_count(priv) \ ((priv)->dpni_attrs.fs_entries) +/* We have exactly one {Rx, Tx conf} queue per channel */ +#define dpaa2_eth_queue_count(priv) \ + ((priv)->num_channels) + enum dpaa2_eth_rx_dist { DPAA2_ETH_RX_DIST_HASH, DPAA2_ETH_RX_DIST_CLS @@ -447,12 +451,6 @@ static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv) DPAA2_ETH_RX_HWA_SIZE; } -/* We have exactly one {Rx, Tx conf} queue per channel */ -static int dpaa2_eth_queue_count(struct dpaa2_eth_priv *priv) -{ - return priv->num_channels; -} - int dpaa2_eth_set_hash(struct net_device *net_dev, u64 flags); int dpaa2_eth_cls_key_size(void); int dpaa2_eth_cls_fld_off(int prot, int field); From patchwork Wed Jan 16 09:57:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 1025725 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="SNpxIkGV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43fjMq56pyz9sBZ for ; Wed, 16 Jan 2019 20:58:47 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404007AbfAPJ6C (ORCPT ); Wed, 16 Jan 2019 04:58:02 -0500 Received: from mail-eopbgr150042.outbound.protection.outlook.com ([40.107.15.42]:41760 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2403993AbfAPJ6A (ORCPT ); Wed, 16 Jan 2019 04:58:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MDjgh5OFgSwg15/4/ToRUmAFXi9HWPJXyQ3Neu06B5U=; b=SNpxIkGVhrXxDg8o5Z2luPqxn1vq5D+D1IZf/qi4yufh8oJ3wkPaxwflvTClFnqsgR6j++XT6ICZRS5tNt5SD+b2KqoYvbIUjq4N/0HEes/FPbCT07jnI3AGC+a2qISzzQSvEPjs810aZywpfFynmlewVbUfcWtzjSKR7Q73k3c= Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com (10.172.255.18) by VI1PR0402MB3775.eurprd04.prod.outlook.com (52.134.15.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.19; Wed, 16 Jan 2019 09:57:56 +0000 Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::8c7b:7d91:36c7:1426]) by VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::8c7b:7d91:36c7:1426%7]) with mapi id 15.20.1537.018; Wed, 16 Jan 2019 09:57:56 +0000 From: Ioana Ciornei To: "davem@davemloft.net" CC: "netdev@vger.kernel.org" , Ioana Ciocoi Radulescu , Ioana Ciornei Subject: [PATCH net-next 2/2] dpaa2-eth: add debugfs statistics Thread-Topic: [PATCH net-next 2/2] dpaa2-eth: add debugfs statistics Thread-Index: AQHUrYH0hKpEu7nyNEuewd8+4Bi0BQ== Date: Wed, 16 Jan 2019 09:57:56 +0000 Message-ID: <1547632637-22959-3-git-send-email-ioana.ciornei@nxp.com> References: <1547632637-22959-1-git-send-email-ioana.ciornei@nxp.com> In-Reply-To: <1547632637-22959-1-git-send-email-ioana.ciornei@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0202CA0013.eurprd02.prod.outlook.com (2603:10a6:803:14::26) To VI1PR0402MB2800.eurprd04.prod.outlook.com (2603:10a6:800:ad::18) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 1.9.1 x-originating-ip: [86.34.165.90] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0402MB3775; 6:cW2c5YB8lLMF+X2AjQrWYPLHkaQYlhIAOgEYOIs32FpxtFglT2PVGg78Deis+B76ZyTdQ6RBw/q3DWnjNiHgOSGohwct3XcNBi2aBEl+a0scuNeZ7TG9H1SuVeRMBNj1x4RSPYQVgUHR631EPVQL46lSdbq8f6Wm7kHbybG5Y8FmjnP+NE3yoOIJHzziIrP330vKtiON0qYNOzmCMghD5bQRsM4kENivjx/oBvgpKzAPOb5dr5YcdGUr7N95d5UdifUIyJlMIG8bYVCxd53cdmy0eGkLjw7+sTYJZURaCndxADhC9jQaexujtoT3bWLixr1CDSbpUicJEViZQvR0fi7+HH1VA9wv3D1GiDqZANySSbQEgHcO5xeRnuNNC23NTId4+7gPqVvr6ANQa3ZBexhp6z9+37FttUYKDPneJVcVAppmxyEjFTLNAIhdyXVYrk7IfAbDDiLv4gkbTMnCVA==; 5:Wp7wXRCf1NxtYPAgvWo7X1yW3friR8crspMlC1jut6EXVEvIjP3qbPh/AN67An3KvM1GhivRIBOhyGHlxyxgArgJ5DLy4SGLGZ7j/VgHVRImiHDgc4Y5fcapderT77X/9Ktn4X2wPxPck7kc54obaBA71qsjzdXC8C9n+Ks8bYYbxMjcz5X0wVCrubD3lMuDiPm662IEQPFDg8luWjHn/A==; 7:7ufsuJJTigw8Zx/9wnNpqsZD66LFcMDYlC4i6WQPsSKuWBFWhTtvBuXG5UTEW+H3jdKEJZfg73J2Z/5o1bwFvPbAfbSyXaPyW7r1zqMFsGqo5MtbMDY4W5gcxjW1zdLc7kPqlTRDNWUrM6ffaNT3wQ== x-ms-office365-filtering-correlation-id: 4e8d4c1f-16ae-4074-debe-08d67b99168d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3775; x-ms-traffictypediagnostic: VI1PR0402MB3775: x-microsoft-antispam-prvs: x-forefront-prvs: 091949432C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(136003)(346002)(396003)(366004)(39860400002)(189003)(199004)(86362001)(99286004)(71200400001)(71190400001)(7736002)(478600001)(25786009)(4326008)(53936002)(36756003)(2501003)(97736004)(305945005)(14454004)(256004)(14444005)(30864003)(5660300001)(6916009)(6506007)(26005)(186003)(50226002)(44832011)(81166006)(102836004)(8936002)(6346003)(2906002)(386003)(68736007)(106356001)(486006)(2351001)(105586002)(1730700003)(316002)(81156014)(66066001)(54906003)(8676002)(6512007)(5640700003)(76176011)(52116002)(6486002)(11346002)(2616005)(476003)(446003)(6116002)(3846002)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3775; H:VI1PR0402MB2800.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ioana.ciornei@nxp.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: kKiylm61ujcfwVvVg6BwQRdvbgrpCGojYpFnBcIVludj6uekKzHjlaPfi46otmQv4EJAshsLoZfDnssf8Rz2dxFWyQawUY7sinF9MN9T1sONeI+scJViGLrmNEFxoSL7UwN1d1bTMvueI8/08S++gcILOHz/IWfDbidBUHaC/TVAGkhgiPgCOHeMq+Ivh5CJwFmljsuUlKpY56y8aiFSWeyLDJ2iu2z3Jld9nzY4/GeU1fG+kj5jmjdxxY8gTeyoBvKJw3Z56YK+r3Mplo9T6k02bmd7501IPKE20Az1BOPHy0A1q/d9yMEM0qJitut3GchDC5lXmYBpwMQafO0LwQxBy+BjysxCXeMzzKuUsdKv1hfe8v33dsfA4RA/YTvpCALOQVFLHl84smp7yyZm5GC5RtZczeSzAizR+TH068o= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e8d4c1f-16ae-4074-debe-08d67b99168d X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jan 2019 09:57:55.6921 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3775 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Radulescu Export detailed driver counters through debugfs. Statistics already available in ethtool are presented in a structured manner. Includes per-core, per-FQ and per-channel statistics. Also transition from module_fsl_mc_driver to explicit module_init/exit in order to create the debugfs directory besides registering the driver. Signed-off-by: Ioana Radulescu Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/Makefile | 1 + .../ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c | 237 +++++++++++++++++++++ .../ethernet/freescale/dpaa2/dpaa2-eth-debugfs.h | 31 +++ drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 30 ++- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 4 + 5 files changed, 302 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.h diff --git a/drivers/net/ethernet/freescale/dpaa2/Makefile b/drivers/net/ethernet/freescale/dpaa2/Makefile index 2f424e0..d1e78cd 100644 --- a/drivers/net/ethernet/freescale/dpaa2/Makefile +++ b/drivers/net/ethernet/freescale/dpaa2/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_FSL_DPAA2_ETH) += fsl-dpaa2-eth.o obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += fsl-dpaa2-ptp.o fsl-dpaa2-eth-objs := dpaa2-eth.o dpaa2-ethtool.o dpni.o +fsl-dpaa2-eth-${CONFIG_DEBUG_FS} += dpaa2-eth-debugfs.o fsl-dpaa2-ptp-objs := dpaa2-ptp.o dprtc.o # Needed by the tracing framework diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c new file mode 100644 index 0000000..13be2bb --- /dev/null +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c @@ -0,0 +1,237 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) +/* Copyright 2015 Freescale Semiconductor Inc. + * Copyright 2018-2019 NXP + */ +#include +#include +#include "dpaa2-eth.h" +#include "dpaa2-eth-debugfs.h" + +#define DPAA2_ETH_DBG_ROOT "dpaa2-eth" + +static struct dentry *dpaa2_dbg_root; + +static int dpaa2_dbg_cpu_show(struct seq_file *file, void *offset) +{ + struct dpaa2_eth_priv *priv = (struct dpaa2_eth_priv *)file->private; + struct rtnl_link_stats64 *stats; + struct dpaa2_eth_drv_stats *extras; + int i; + + seq_printf(file, "Per-CPU stats for %s\n", priv->net_dev->name); + seq_printf(file, "%s%16s%16s%16s%16s%16s%16s%16s%16s%16s\n", + "CPU", "Rx", "Rx Err", "Rx SG", "Tx", "Tx Err", "Tx conf", + "Tx SG", "Tx realloc", "Enq busy"); + + for_each_online_cpu(i) { + stats = per_cpu_ptr(priv->percpu_stats, i); + extras = per_cpu_ptr(priv->percpu_extras, i); + seq_printf(file, "%3d%16llu%16llu%16llu%16llu%16llu%16llu%16llu%16llu%16llu\n", + i, + stats->rx_packets, + stats->rx_errors, + extras->rx_sg_frames, + stats->tx_packets, + stats->tx_errors, + extras->tx_conf_frames, + extras->tx_sg_frames, + extras->tx_reallocs, + extras->tx_portal_busy); + } + + return 0; +} + +static int dpaa2_dbg_cpu_open(struct inode *inode, struct file *file) +{ + int err; + struct dpaa2_eth_priv *priv = (struct dpaa2_eth_priv *)inode->i_private; + + err = single_open(file, dpaa2_dbg_cpu_show, priv); + if (err < 0) + netdev_err(priv->net_dev, "single_open() failed\n"); + + return err; +} + +static const struct file_operations dpaa2_dbg_cpu_ops = { + .open = dpaa2_dbg_cpu_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static char *fq_type_to_str(struct dpaa2_eth_fq *fq) +{ + switch (fq->type) { + case DPAA2_RX_FQ: + return "Rx"; + case DPAA2_TX_CONF_FQ: + return "Tx conf"; + default: + return "N/A"; + } +} + +static int dpaa2_dbg_fqs_show(struct seq_file *file, void *offset) +{ + struct dpaa2_eth_priv *priv = (struct dpaa2_eth_priv *)file->private; + struct dpaa2_eth_fq *fq; + u32 fcnt, bcnt; + int i, err; + + seq_printf(file, "FQ stats for %s:\n", priv->net_dev->name); + seq_printf(file, "%s%16s%16s%16s%16s\n", + "VFQID", "CPU", "Type", "Frames", "Pending frames"); + + for (i = 0; i < priv->num_fqs; i++) { + fq = &priv->fq[i]; + err = dpaa2_io_query_fq_count(NULL, fq->fqid, &fcnt, &bcnt); + if (err) + fcnt = 0; + + seq_printf(file, "%5d%16d%16s%16llu%16u\n", + fq->fqid, + fq->target_cpu, + fq_type_to_str(fq), + fq->stats.frames, + fcnt); + } + + return 0; +} + +static int dpaa2_dbg_fqs_open(struct inode *inode, struct file *file) +{ + int err; + struct dpaa2_eth_priv *priv = (struct dpaa2_eth_priv *)inode->i_private; + + err = single_open(file, dpaa2_dbg_fqs_show, priv); + if (err < 0) + netdev_err(priv->net_dev, "single_open() failed\n"); + + return err; +} + +static const struct file_operations dpaa2_dbg_fq_ops = { + .open = dpaa2_dbg_fqs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int dpaa2_dbg_ch_show(struct seq_file *file, void *offset) +{ + struct dpaa2_eth_priv *priv = (struct dpaa2_eth_priv *)file->private; + struct dpaa2_eth_channel *ch; + int i; + + seq_printf(file, "Channel stats for %s:\n", priv->net_dev->name); + seq_printf(file, "%s%16s%16s%16s%16s\n", + "CHID", "CPU", "Deq busy", "CDANs", "Buf count"); + + for (i = 0; i < priv->num_channels; i++) { + ch = priv->channel[i]; + seq_printf(file, "%4d%16d%16llu%16llu%16d\n", + ch->ch_id, + ch->nctx.desired_cpu, + ch->stats.dequeue_portal_busy, + ch->stats.cdan, + ch->buf_count); + } + + return 0; +} + +static int dpaa2_dbg_ch_open(struct inode *inode, struct file *file) +{ + int err; + struct dpaa2_eth_priv *priv = (struct dpaa2_eth_priv *)inode->i_private; + + err = single_open(file, dpaa2_dbg_ch_show, priv); + if (err < 0) + netdev_err(priv->net_dev, "single_open() failed\n"); + + return err; +} + +static const struct file_operations dpaa2_dbg_ch_ops = { + .open = dpaa2_dbg_ch_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +void dpaa2_dbg_add(struct dpaa2_eth_priv *priv) +{ + if (!dpaa2_dbg_root) + return; + + /* Create a directory for the interface */ + priv->dbg.dir = debugfs_create_dir(priv->net_dev->name, + dpaa2_dbg_root); + if (!priv->dbg.dir) { + netdev_err(priv->net_dev, "debugfs_create_dir() failed\n"); + return; + } + + /* per-cpu stats file */ + priv->dbg.cpu_stats = debugfs_create_file("cpu_stats", 0444, + priv->dbg.dir, priv, + &dpaa2_dbg_cpu_ops); + if (!priv->dbg.cpu_stats) { + netdev_err(priv->net_dev, "debugfs_create_file() failed\n"); + goto err_cpu_stats; + } + + /* per-fq stats file */ + priv->dbg.fq_stats = debugfs_create_file("fq_stats", 0444, + priv->dbg.dir, priv, + &dpaa2_dbg_fq_ops); + if (!priv->dbg.fq_stats) { + netdev_err(priv->net_dev, "debugfs_create_file() failed\n"); + goto err_fq_stats; + } + + /* per-fq stats file */ + priv->dbg.ch_stats = debugfs_create_file("ch_stats", 0444, + priv->dbg.dir, priv, + &dpaa2_dbg_ch_ops); + if (!priv->dbg.fq_stats) { + netdev_err(priv->net_dev, "debugfs_create_file() failed\n"); + goto err_ch_stats; + } + + return; + +err_ch_stats: + debugfs_remove(priv->dbg.fq_stats); +err_fq_stats: + debugfs_remove(priv->dbg.cpu_stats); +err_cpu_stats: + debugfs_remove(priv->dbg.dir); +} + +void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv) +{ + debugfs_remove(priv->dbg.fq_stats); + debugfs_remove(priv->dbg.ch_stats); + debugfs_remove(priv->dbg.cpu_stats); + debugfs_remove(priv->dbg.dir); +} + +void dpaa2_eth_dbg_init(void) +{ + dpaa2_dbg_root = debugfs_create_dir(DPAA2_ETH_DBG_ROOT, NULL); + if (!dpaa2_dbg_root) { + pr_err("DPAA2-ETH: debugfs create failed\n"); + return; + } + + pr_debug("DPAA2-ETH: debugfs created\n"); +} + +void __exit dpaa2_eth_dbg_exit(void) +{ + debugfs_remove(dpaa2_dbg_root); +} diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.h new file mode 100644 index 0000000..4f63de9 --- /dev/null +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ +/* Copyright 2015 Freescale Semiconductor Inc. + * Copyright 2018-2019 NXP + */ +#ifndef DPAA2_ETH_DEBUGFS_H +#define DPAA2_ETH_DEBUGFS_H + +#include + +struct dpaa2_eth_priv; + +struct dpaa2_debugfs { + struct dentry *dir; + struct dentry *fq_stats; + struct dentry *ch_stats; + struct dentry *cpu_stats; +}; + +#ifdef CONFIG_DEBUG_FS +void dpaa2_eth_dbg_init(void); +void dpaa2_eth_dbg_exit(void); +void dpaa2_dbg_add(struct dpaa2_eth_priv *priv); +void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv); +#else +static inline void dpaa2_eth_dbg_init(void) {} +static inline void dpaa2_eth_dbg_exit(void) {} +static inline void dpaa2_dbg_add(struct dpaa2_eth_priv *priv) {} +static inline void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv) {} +#endif /* CONFIG_DEBUG_FS */ + +#endif /* DPAA2_ETH_DEBUGFS_H */ diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 1ca9a18..bca211d 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -3083,6 +3083,10 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) goto err_netdev_reg; } +#ifdef CONFIG_DEBUG_FS + dpaa2_dbg_add(priv); +#endif + dev_info(dev, "Probed interface %s\n", net_dev->name); return 0; @@ -3126,6 +3130,9 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev) net_dev = dev_get_drvdata(dev); priv = netdev_priv(net_dev); +#ifdef CONFIG_DEBUG_FS + dpaa2_dbg_remove(priv); +#endif unregister_netdev(net_dev); if (priv->do_link_poll) @@ -3170,4 +3177,25 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev) .match_id_table = dpaa2_eth_match_id_table }; -module_fsl_mc_driver(dpaa2_eth_driver); +static int __init dpaa2_eth_driver_init(void) +{ + int err; + + dpaa2_eth_dbg_init(); + err = fsl_mc_driver_register(&dpaa2_eth_driver); + if (err) { + dpaa2_eth_dbg_exit(); + return err; + } + + return 0; +} + +static void __exit dpaa2_eth_driver_exit(void) +{ + dpaa2_eth_dbg_exit(); + fsl_mc_driver_unregister(&dpaa2_eth_driver); +} + +module_init(dpaa2_eth_driver_init); +module_exit(dpaa2_eth_driver_exit); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index 308aae6..31fe486 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -16,6 +16,7 @@ #include "dpni-cmd.h" #include "dpaa2-eth-trace.h" +#include "dpaa2-eth-debugfs.h" #define DPAA2_WRIOP_VERSION(x, y, z) ((x) << 10 | (y) << 5 | (z) << 0) @@ -365,6 +366,9 @@ struct dpaa2_eth_priv { struct dpaa2_eth_cls_rule *cls_rules; u8 rx_cls_enabled; struct bpf_prog *xdp_prog; +#ifdef CONFIG_DEBUG_FS + struct dpaa2_debugfs dbg; +#endif }; #define DPAA2_RXH_SUPPORTED (RXH_L2DA | RXH_VLAN | RXH_L3_PROTO \