From: Kurt Kanzenbach <kurt@kmk-computers.de>
To: Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Kurt Kanzenbach <kurt@kmk-computers.de>
Subject: [PATCH net-next 2/2] net: dsa: hellcreek: Report FDB table occupancy
Date: Sat, 30 Jan 2021 14:59:34 +0100 [thread overview]
Message-ID: <20210130135934.22870-3-kurt@kmk-computers.de> (raw)
In-Reply-To: <20210130135934.22870-1-kurt@kmk-computers.de>
Report the FDB table size and occupancy via devlink. The actual size depends on
the used Hellcreek version:
|root@tsn:~# devlink resource show platform/ff240000.switch
|platform/ff240000.switch:
| name VLAN size 4096 occ 2 unit entry dpipe_tables none
| name FDB size 256 occ 6 unit entry dpipe_tables none
Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
---
drivers/net/dsa/hirschmann/hellcreek.c | 46 ++++++++++++++++++++++----
drivers/net/dsa/hirschmann/hellcreek.h | 1 +
2 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c
index 0ba0f6e81305..f984ca75a71f 100644
--- a/drivers/net/dsa/hirschmann/hellcreek.c
+++ b/drivers/net/dsa/hirschmann/hellcreek.c
@@ -221,12 +221,11 @@ static void hellcreek_feature_detect(struct hellcreek *hellcreek)
features = hellcreek_read(hellcreek, HR_FEABITS0);
- /* Currently we only detect the size of the FDB table */
+ /* Only detect the size of the FDB table. The size and current
+ * utilization can be queried via devlink.
+ */
hellcreek->fdb_entries = ((features & HR_FEABITS0_FDBBINS_MASK) >>
HR_FEABITS0_FDBBINS_SHIFT) * 32;
-
- dev_info(hellcreek->dev, "Feature detect: FDB entries=%zu\n",
- hellcreek->fdb_entries);
}
static enum dsa_tag_protocol hellcreek_get_tag_protocol(struct dsa_switch *ds,
@@ -1015,20 +1014,48 @@ static u64 hellcreek_devlink_vlan_table_get(void *priv)
return count;
}
+static u64 hellcreek_devlink_fdb_table_get(void *priv)
+{
+ struct hellcreek *hellcreek = priv;
+ u64 count = 0;
+
+ /* Reading this register has side effects. Synchronize against the other
+ * FDB operations.
+ */
+ mutex_lock(&hellcreek->reg_lock);
+ count = hellcreek_read(hellcreek, HR_FDBMAX);
+ mutex_unlock(&hellcreek->reg_lock);
+
+ return count;
+}
+
static int hellcreek_setup_devlink_resources(struct dsa_switch *ds)
{
- struct devlink_resource_size_params size_params;
+ struct devlink_resource_size_params size_vlan_params;
+ struct devlink_resource_size_params size_fdb_params;
struct hellcreek *hellcreek = ds->priv;
int err;
- devlink_resource_size_params_init(&size_params, VLAN_N_VID,
+ devlink_resource_size_params_init(&size_vlan_params, VLAN_N_VID,
VLAN_N_VID,
1, DEVLINK_RESOURCE_UNIT_ENTRY);
+ devlink_resource_size_params_init(&size_fdb_params,
+ hellcreek->fdb_entries,
+ hellcreek->fdb_entries,
+ 1, DEVLINK_RESOURCE_UNIT_ENTRY);
+
err = dsa_devlink_resource_register(ds, "VLAN", VLAN_N_VID,
HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE,
DEVLINK_RESOURCE_ID_PARENT_TOP,
- &size_params);
+ &size_vlan_params);
+ if (err)
+ goto out;
+
+ err = dsa_devlink_resource_register(ds, "FDB", hellcreek->fdb_entries,
+ HELLCREEK_DEVLINK_PARAM_ID_FDB_TABLE,
+ DEVLINK_RESOURCE_ID_PARENT_TOP,
+ &size_fdb_params);
if (err)
goto out;
@@ -1037,6 +1064,11 @@ static int hellcreek_setup_devlink_resources(struct dsa_switch *ds)
hellcreek_devlink_vlan_table_get,
hellcreek);
+ dsa_devlink_resource_occ_get_register(ds,
+ HELLCREEK_DEVLINK_PARAM_ID_FDB_TABLE,
+ hellcreek_devlink_fdb_table_get,
+ hellcreek);
+
return 0;
out:
diff --git a/drivers/net/dsa/hirschmann/hellcreek.h b/drivers/net/dsa/hirschmann/hellcreek.h
index 11539916a6be..305e76dab34d 100644
--- a/drivers/net/dsa/hirschmann/hellcreek.h
+++ b/drivers/net/dsa/hirschmann/hellcreek.h
@@ -301,6 +301,7 @@ struct hellcreek {
/* Devlink resources */
enum hellcreek_devlink_resource_id {
HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE,
+ HELLCREEK_DEVLINK_PARAM_ID_FDB_TABLE,
};
#endif /* _HELLCREEK_H_ */
--
2.26.2
next prev parent reply other threads:[~2021-01-30 16:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-30 13:59 [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes Kurt Kanzenbach
2021-01-30 13:59 ` [PATCH net-next 1/2] net: dsa: hellcreek: Report VLAN table occupancy Kurt Kanzenbach
2021-01-31 21:31 ` Florian Fainelli
2021-01-30 13:59 ` Kurt Kanzenbach [this message]
2021-01-31 21:32 ` [PATCH net-next 2/2] net: dsa: hellcreek: Report FDB " Florian Fainelli
2021-01-31 21:28 ` [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes Vladimir Oltean
2021-02-01 16:56 ` Kurt Kanzenbach
2021-02-02 2:40 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210130135934.22870-3-kurt@kmk-computers.de \
--to=kurt@kmk-computers.de \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).