All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes
@ 2021-01-30 13:59 Kurt Kanzenbach
  2021-01-30 13:59 ` [PATCH net-next 1/2] net: dsa: hellcreek: Report VLAN table occupancy Kurt Kanzenbach
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Kurt Kanzenbach @ 2021-01-30 13:59 UTC (permalink / raw
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean
  Cc: David S. Miller, Jakub Kicinski, netdev, Kurt Kanzenbach

Hi,

Florian, Andrew and Vladimir suggested at some point to use devlink for
reporting tables, features and debugging counters instead of using debugfs and
printk.

So, start by reporting the VLAN and FDB table sizes.

Thanks,
Kurt

Kurt Kanzenbach (2):
  net: dsa: hellcreek: Report VLAN table occupancy
  net: dsa: hellcreek: Report FDB table occupancy

 drivers/net/dsa/hirschmann/hellcreek.c | 99 ++++++++++++++++++++++++--
 drivers/net/dsa/hirschmann/hellcreek.h |  6 ++
 2 files changed, 101 insertions(+), 4 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next 1/2] net: dsa: hellcreek: Report VLAN table occupancy
  2021-01-30 13:59 [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes Kurt Kanzenbach
@ 2021-01-30 13:59 ` Kurt Kanzenbach
  2021-01-31 21:31   ` Florian Fainelli
  2021-01-30 13:59 ` [PATCH net-next 2/2] net: dsa: hellcreek: Report FDB " Kurt Kanzenbach
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Kurt Kanzenbach @ 2021-01-30 13:59 UTC (permalink / raw
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean
  Cc: David S. Miller, Jakub Kicinski, netdev, Kurt Kanzenbach

The VLAN membership configuration is cached in software already. So, it can be
reported via devlink. Add support for it:

|root@tsn:~# devlink resource show platform/ff240000.switch
|platform/ff240000.switch:
|  name VLAN size 4096 occ 4 unit entry dpipe_tables none

Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
---
 drivers/net/dsa/hirschmann/hellcreek.c | 59 ++++++++++++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek.h |  5 +++
 2 files changed, 64 insertions(+)

diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c
index 4cc51fb37e67..0ba0f6e81305 100644
--- a/drivers/net/dsa/hirschmann/hellcreek.c
+++ b/drivers/net/dsa/hirschmann/hellcreek.c
@@ -1000,6 +1000,51 @@ static int hellcreek_setup_fdb(struct hellcreek *hellcreek)
 	return ret;
 }
 
+static u64 hellcreek_devlink_vlan_table_get(void *priv)
+{
+	struct hellcreek *hellcreek = priv;
+	u64 count = 0;
+	int i;
+
+	mutex_lock(&hellcreek->reg_lock);
+	for (i = 0; i < VLAN_N_VID; ++i)
+		if (hellcreek->vidmbrcfg[i])
+			count++;
+	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 hellcreek *hellcreek = ds->priv;
+	int err;
+
+	devlink_resource_size_params_init(&size_params, VLAN_N_VID,
+					  VLAN_N_VID,
+					  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);
+	if (err)
+		goto out;
+
+	dsa_devlink_resource_occ_get_register(ds,
+					      HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE,
+					      hellcreek_devlink_vlan_table_get,
+					      hellcreek);
+
+	return 0;
+
+out:
+	dsa_devlink_resources_unregister(ds);
+
+	return err;
+}
+
 static int hellcreek_setup(struct dsa_switch *ds)
 {
 	struct hellcreek *hellcreek = ds->priv;
@@ -1053,9 +1098,22 @@ static int hellcreek_setup(struct dsa_switch *ds)
 		return ret;
 	}
 
+	/* Register devlink resources with DSA */
+	ret = hellcreek_setup_devlink_resources(ds);
+	if (ret) {
+		dev_err(hellcreek->dev,
+			"Failed to setup devlink resources!\n");
+		return ret;
+	}
+
 	return 0;
 }
 
+static void hellcreek_teardown(struct dsa_switch *ds)
+{
+	dsa_devlink_resources_unregister(ds);
+}
+
 static void hellcreek_phylink_validate(struct dsa_switch *ds, int port,
 				       unsigned long *supported,
 				       struct phylink_link_state *state)
@@ -1447,6 +1505,7 @@ static const struct dsa_switch_ops hellcreek_ds_ops = {
 	.port_vlan_del	     = hellcreek_vlan_del,
 	.port_vlan_filtering = hellcreek_vlan_filtering,
 	.setup		     = hellcreek_setup,
+	.teardown	     = hellcreek_teardown,
 };
 
 static int hellcreek_probe(struct platform_device *pdev)
diff --git a/drivers/net/dsa/hirschmann/hellcreek.h b/drivers/net/dsa/hirschmann/hellcreek.h
index 854639f87247..11539916a6be 100644
--- a/drivers/net/dsa/hirschmann/hellcreek.h
+++ b/drivers/net/dsa/hirschmann/hellcreek.h
@@ -298,4 +298,9 @@ struct hellcreek {
 #define dw_to_hellcreek_port(dw)				\
 	container_of(dw, struct hellcreek_port, schedule_work)
 
+/* Devlink resources */
+enum hellcreek_devlink_resource_id {
+	HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE,
+};
+
 #endif /* _HELLCREEK_H_ */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 2/2] net: dsa: hellcreek: Report FDB table occupancy
  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-30 13:59 ` Kurt Kanzenbach
  2021-01-31 21:32   ` Florian Fainelli
  2021-01-31 21:28 ` [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes Vladimir Oltean
  2021-02-02  2:40 ` patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Kurt Kanzenbach @ 2021-01-30 13:59 UTC (permalink / raw
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean
  Cc: David S. Miller, Jakub Kicinski, netdev, Kurt Kanzenbach

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes
  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-30 13:59 ` [PATCH net-next 2/2] net: dsa: hellcreek: Report FDB " Kurt Kanzenbach
@ 2021-01-31 21:28 ` Vladimir Oltean
  2021-02-01 16:56   ` Kurt Kanzenbach
  2021-02-02  2:40 ` patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Vladimir Oltean @ 2021-01-31 21:28 UTC (permalink / raw
  To: Kurt Kanzenbach
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
	Jakub Kicinski, netdev

On Sat, Jan 30, 2021 at 02:59:32PM +0100, Kurt Kanzenbach wrote:
> Florian, Andrew and Vladimir suggested at some point to use devlink for
> reporting tables, features and debugging counters instead of using debugfs and
> printk.
> 
> So, start by reporting the VLAN and FDB table sizes.

I don't remember having suggested that, but nonetheless it doesn't seem
like a bad idea.

By the way, your email landed in my spam folder, I just noticed the
patches by accident on patchwork.

Sorry, I am not competent enough in email headers to tell you the reason
why gmail flagged you.

	Why is this message in spam?
	It is in violation of Google's recommended email sender guidelines.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 1/2] net: dsa: hellcreek: Report VLAN table occupancy
  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
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2021-01-31 21:31 UTC (permalink / raw
  To: Kurt Kanzenbach, Andrew Lunn, Vivien Didelot, Vladimir Oltean
  Cc: David S. Miller, Jakub Kicinski, netdev



On 1/30/2021 5:59 AM, Kurt Kanzenbach wrote:
> The VLAN membership configuration is cached in software already. So, it can be
> reported via devlink. Add support for it:
> 
> |root@tsn:~# devlink resource show platform/ff240000.switch
> |platform/ff240000.switch:
> |  name VLAN size 4096 occ 4 unit entry dpipe_tables none
> 
> Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] net: dsa: hellcreek: Report FDB table occupancy
  2021-01-30 13:59 ` [PATCH net-next 2/2] net: dsa: hellcreek: Report FDB " Kurt Kanzenbach
@ 2021-01-31 21:32   ` Florian Fainelli
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2021-01-31 21:32 UTC (permalink / raw
  To: Kurt Kanzenbach, Andrew Lunn, Vivien Didelot, Vladimir Oltean
  Cc: David S. Miller, Jakub Kicinski, netdev



On 1/30/2021 5:59 AM, Kurt Kanzenbach wrote:
> 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>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes
  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
  0 siblings, 0 replies; 8+ messages in thread
From: Kurt Kanzenbach @ 2021-02-01 16:56 UTC (permalink / raw
  To: Vladimir Oltean
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
	Jakub Kicinski, netdev

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]

On Sun Jan 31 2021, Vladimir Oltean wrote:
> On Sat, Jan 30, 2021 at 02:59:32PM +0100, Kurt Kanzenbach wrote:
>> Florian, Andrew and Vladimir suggested at some point to use devlink for
>> reporting tables, features and debugging counters instead of using debugfs and
>> printk.
>> 
>> So, start by reporting the VLAN and FDB table sizes.
>
> I don't remember having suggested that, but nonetheless it doesn't seem
> like a bad idea.

If I remember correctly, you also mentioned to use devlink to dump the
databases via regions.

>
> By the way, your email landed in my spam folder, I just noticed the
> patches by accident on patchwork.
>
> Sorry, I am not competent enough in email headers to tell you the reason
> why gmail flagged you.
>
> 	Why is this message in spam?
> 	It is in violation of Google's recommended email sender guidelines.
>

Thanks. I'll look into my setup.

Thanks,
Kurt

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 865 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes
  2021-01-30 13:59 [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes Kurt Kanzenbach
                   ` (2 preceding siblings ...)
  2021-01-31 21:28 ` [PATCH net-next 0/2] net: dsa: hellcreek: Report tables sizes Vladimir Oltean
@ 2021-02-02  2:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-02-02  2:40 UTC (permalink / raw
  To: Kurt Kanzenbach
  Cc: andrew, vivien.didelot, f.fainelli, olteanv, davem, kuba, netdev

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Sat, 30 Jan 2021 14:59:32 +0100 you wrote:
> Hi,
> 
> Florian, Andrew and Vladimir suggested at some point to use devlink for
> reporting tables, features and debugging counters instead of using debugfs and
> printk.
> 
> So, start by reporting the VLAN and FDB table sizes.
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net: dsa: hellcreek: Report VLAN table occupancy
    https://git.kernel.org/netdev/net-next/c/7f976d5cf16d
  - [net-next,2/2] net: dsa: hellcreek: Report FDB table occupancy
    https://git.kernel.org/netdev/net-next/c/8486e83fe1d8

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-02-02  2:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH net-next 2/2] net: dsa: hellcreek: Report FDB " Kurt Kanzenbach
2021-01-31 21:32   ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.