Commit 8486e83f authored by Kurt Kanzenbach's avatar Kurt Kanzenbach Committed by Jakub Kicinski

net: dsa: hellcreek: Report FDB table occupancy

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: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarKurt Kanzenbach <kurt@kmk-computers.de>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7f976d5c
...@@ -221,12 +221,11 @@ static void hellcreek_feature_detect(struct hellcreek *hellcreek) ...@@ -221,12 +221,11 @@ static void hellcreek_feature_detect(struct hellcreek *hellcreek)
features = hellcreek_read(hellcreek, HR_FEABITS0); 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) >> hellcreek->fdb_entries = ((features & HR_FEABITS0_FDBBINS_MASK) >>
HR_FEABITS0_FDBBINS_SHIFT) * 32; 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, 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) ...@@ -1015,20 +1014,48 @@ static u64 hellcreek_devlink_vlan_table_get(void *priv)
return count; 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) 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; struct hellcreek *hellcreek = ds->priv;
int err; 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, VLAN_N_VID,
1, DEVLINK_RESOURCE_UNIT_ENTRY); 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, err = dsa_devlink_resource_register(ds, "VLAN", VLAN_N_VID,
HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE, HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE,
DEVLINK_RESOURCE_ID_PARENT_TOP, 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) if (err)
goto out; goto out;
...@@ -1037,6 +1064,11 @@ static int hellcreek_setup_devlink_resources(struct dsa_switch *ds) ...@@ -1037,6 +1064,11 @@ static int hellcreek_setup_devlink_resources(struct dsa_switch *ds)
hellcreek_devlink_vlan_table_get, hellcreek_devlink_vlan_table_get,
hellcreek); hellcreek);
dsa_devlink_resource_occ_get_register(ds,
HELLCREEK_DEVLINK_PARAM_ID_FDB_TABLE,
hellcreek_devlink_fdb_table_get,
hellcreek);
return 0; return 0;
out: out:
......
...@@ -301,6 +301,7 @@ struct hellcreek { ...@@ -301,6 +301,7 @@ struct hellcreek {
/* Devlink resources */ /* Devlink resources */
enum hellcreek_devlink_resource_id { enum hellcreek_devlink_resource_id {
HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE, HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE,
HELLCREEK_DEVLINK_PARAM_ID_FDB_TABLE,
}; };
#endif /* _HELLCREEK_H_ */ #endif /* _HELLCREEK_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment