Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5092255img; Wed, 27 Mar 2019 01:47:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeXcNZc7eerRhv85ABrs0Z+w4QxbJcNZFWu+HW5U7/7TfzcX/ezPFRSE/vy/zg3NED4U5B X-Received: by 2002:a63:ff5a:: with SMTP id s26mr31023498pgk.96.1553676455138; Wed, 27 Mar 2019 01:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553676455; cv=none; d=google.com; s=arc-20160816; b=W8NCQYVVzToRb9KPqW2B7lnnBDkowxexrWNk27x5P4lIEqwMAAjsNaNC9Ps9OOVeC1 mMl28dOC9o59wB2iB0BPSaubgxrDreyzV6zOewDXCdM/JHLaPFpyTJAMCrwaPeoKwpfD MpLpWX/rMU9T7C92Cn+cbLB/rKbkvvaEXuoM5NZ+a/VE126xxKKUsM5EN+vI9vlG4/Uc EAdyy+6nCFQJprUgjMIpVEpuCXyfZXo8Y01fXWt9RgjJLXbRFOrb1/HNrtvwY0WB23Rp vcLKrybmfZ83y+Jm0+UyHOt8wDb6sGfh1uVvAXq3jdbDMjEFzv1+hQEL8+/ELIG1Wb5R qAdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rWviUg0tpDLhw1/Yf8GFzpAcFGgzT5mzvF4lfruuY/g=; b=qsrOpu+BFHONbYAdEwU4X7zhVwZGLKFSFlPtpUe6zpm+TFCXkJVIBqinJ9ywyMHCjD JxKX36rmU4/P+i4tudwWZ6+x7RTFFbgxXigd7AwKryAYwvCLJHbxRkuAJCbolAHg4Toz rJQlxEFQvdEhpJGewxRmeolIBKOj5cP5bMZ1pDeC3/fiWFLUzZKhqB1DIUQy5LX/1wGC sticnnjPZF4lrNuHoSgqxgWBCj7rOjubbXj8TxrcrExbdrQzKWgIjC5KoS+LlHU4otaU 2sYIJD/HZYNSYBbHV7spLr8uwXKMryWmvSbXyq7gplmkAy85VuiUhR12A7SCCq1HrMwZ 4VTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si18904214ply.361.2019.03.27.01.47.19; Wed, 27 Mar 2019 01:47:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732606AbfC0IqX (ORCPT + 99 others); Wed, 27 Mar 2019 04:46:23 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:45741 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732754AbfC0Io4 (ORCPT ); Wed, 27 Mar 2019 04:44:56 -0400 X-Originating-IP: 90.88.32.136 Received: from mc-bl-xps13.lan (aaubervilliers-681-1-91-136.w90-88.abo.wanadoo.fr [90.88.32.136]) (Authenticated sender: maxime.chevallier@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id BA9254000B; Wed, 27 Mar 2019 08:44:52 +0000 (UTC) From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Antoine Tenart , thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, miquel.raynal@bootlin.com, nadavh@marvell.com, stefanc@marvell.com, ymarkman@marvell.com, mw@semihalf.com, Russell King , linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 08/18] net: mvpp2: debugfs: Allow reading the flow table from debugfs Date: Wed, 27 Mar 2019 09:44:12 +0100 Message-Id: <20190327084422.4209-9-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190327084422.4209-1-maxime.chevallier@bootlin.com> References: <20190327084422.4209-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Classifier flow table is the central part of the PPv2 Classifier, since it describes all classification steps performed for each flow. It has 512 entries, shared between all ports, which are divided into sequences that are pointed-to by the decoding table. Being able to see which entries in the flow table were hit is a key point when implementing and debugging classification offload. This commit allows reading each flow table entry's hit count independently, with a clear-on-read behaviour. Signed-off-by: Maxime Chevallier --- .../ethernet/marvell/mvpp2/mvpp2_debugfs.c | 69 +++++++++++++++++-- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c index 5c2f84a2741e..4100d82eca75 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c @@ -23,6 +23,11 @@ struct mvpp2_dbgfs_flow_entry { struct mvpp2 *priv; }; +struct mvpp2_dbgfs_flow_tbl_entry { + int id; + struct mvpp2 *priv; +}; + struct mvpp2_dbgfs_port_flow_entry { struct mvpp2_port *port; struct mvpp2_dbgfs_flow_entry *dbg_fe; @@ -32,6 +37,9 @@ struct mvpp2_dbgfs_entries { /* Entries for Header Parser debug info */ struct mvpp2_dbgfs_prs_entry prs_entries[MVPP2_PRS_TCAM_SRAM_SIZE]; + /* Entries for Classifier Flow Table debug info */ + struct mvpp2_dbgfs_flow_tbl_entry flt_entries[MVPP2_CLS_FLOWS_TBL_SIZE]; + /* Entries for Classifier flows debug info */ struct mvpp2_dbgfs_flow_entry flow_entries[MVPP2_N_PRS_FLOWS]; @@ -41,10 +49,9 @@ struct mvpp2_dbgfs_entries { static int mvpp2_dbgfs_flow_flt_hits_show(struct seq_file *s, void *unused) { - struct mvpp2_dbgfs_flow_entry *entry = s->private; - int id = MVPP2_FLOW_C2_ENTRY(entry->flow); + struct mvpp2_dbgfs_flow_tbl_entry *entry = s->private; - u32 hits = mvpp2_cls_flow_hits(entry->priv, id); + u32 hits = mvpp2_cls_flow_hits(entry->priv, entry->id); seq_printf(s, "%u\n", hits); @@ -474,9 +481,6 @@ static int mvpp2_dbgfs_flow_entry_init(struct dentry *parent, entry->flow = flow; entry->priv = priv; - debugfs_create_file("flow_hits", 0444, flow_entry_dir, entry, - &mvpp2_dbgfs_flow_flt_hits_fops); - debugfs_create_file("dec_hits", 0444, flow_entry_dir, entry, &mvpp2_dbgfs_flow_dec_hits_fops); @@ -575,6 +579,55 @@ static int mvpp2_dbgfs_prs_init(struct dentry *parent, struct mvpp2 *priv) return 0; } +static int mvpp2_dbgfs_flow_tbl_entry_init(struct dentry *parent, + struct mvpp2 *priv, int id) +{ + struct mvpp2_dbgfs_flow_tbl_entry *entry; + struct dentry *flow_tbl_entry_dir; + char flow_tbl_entry_name[10]; + + if (id >= MVPP2_CLS_FLOWS_TBL_SIZE) + return -EINVAL; + + sprintf(flow_tbl_entry_name, "%03d", id); + + flow_tbl_entry_dir = debugfs_create_dir(flow_tbl_entry_name, parent); + if (!flow_tbl_entry_dir) + return -ENOMEM; + + entry = &priv->dbgfs_entries->flt_entries[id]; + + entry->id = id; + entry->priv = priv; + + debugfs_create_file("hits", 0444, flow_tbl_entry_dir, entry, + &mvpp2_dbgfs_flow_flt_hits_fops); + + return 0; +} + +static int mvpp2_dbgfs_cls_init(struct dentry *parent, struct mvpp2 *priv) +{ + struct dentry *cls_dir, *flow_tbl_dir; + int i, ret; + + cls_dir = debugfs_create_dir("classifier", parent); + if (!cls_dir) + return -ENOMEM; + + flow_tbl_dir = debugfs_create_dir("flow_table", cls_dir); + if (!flow_tbl_dir) + return -ENOMEM; + + for (i = 0; i < MVPP2_CLS_FLOWS_TBL_SIZE; i++) { + ret = mvpp2_dbgfs_flow_tbl_entry_init(flow_tbl_dir, priv, i); + if (ret) + return ret; + } + + return 0; +} + static int mvpp2_dbgfs_port_init(struct dentry *parent, struct mvpp2_port *port) { @@ -637,6 +690,10 @@ void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name) if (ret) goto err; + ret = mvpp2_dbgfs_cls_init(mvpp2_dir, priv); + if (ret) + goto err; + for (i = 0; i < priv->port_count; i++) { ret = mvpp2_dbgfs_port_init(mvpp2_dir, priv->port_list[i]); if (ret) -- 2.20.1