Skip to content

Commit 8486e83

Browse files
shifty91kuba-moo
authored andcommitted
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: Florian Fainelli <[email protected]> Signed-off-by: Kurt Kanzenbach <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7f976d5 commit 8486e83

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

drivers/net/dsa/hirschmann/hellcreek.c

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,11 @@ static void hellcreek_feature_detect(struct hellcreek *hellcreek)
221221

222222
features = hellcreek_read(hellcreek, HR_FEABITS0);
223223

224-
/* Currently we only detect the size of the FDB table */
224+
/* Only detect the size of the FDB table. The size and current
225+
* utilization can be queried via devlink.
226+
*/
225227
hellcreek->fdb_entries = ((features & HR_FEABITS0_FDBBINS_MASK) >>
226228
HR_FEABITS0_FDBBINS_SHIFT) * 32;
227-
228-
dev_info(hellcreek->dev, "Feature detect: FDB entries=%zu\n",
229-
hellcreek->fdb_entries);
230229
}
231230

232231
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)
10151014
return count;
10161015
}
10171016

1017+
static u64 hellcreek_devlink_fdb_table_get(void *priv)
1018+
{
1019+
struct hellcreek *hellcreek = priv;
1020+
u64 count = 0;
1021+
1022+
/* Reading this register has side effects. Synchronize against the other
1023+
* FDB operations.
1024+
*/
1025+
mutex_lock(&hellcreek->reg_lock);
1026+
count = hellcreek_read(hellcreek, HR_FDBMAX);
1027+
mutex_unlock(&hellcreek->reg_lock);
1028+
1029+
return count;
1030+
}
1031+
10181032
static int hellcreek_setup_devlink_resources(struct dsa_switch *ds)
10191033
{
1020-
struct devlink_resource_size_params size_params;
1034+
struct devlink_resource_size_params size_vlan_params;
1035+
struct devlink_resource_size_params size_fdb_params;
10211036
struct hellcreek *hellcreek = ds->priv;
10221037
int err;
10231038

1024-
devlink_resource_size_params_init(&size_params, VLAN_N_VID,
1039+
devlink_resource_size_params_init(&size_vlan_params, VLAN_N_VID,
10251040
VLAN_N_VID,
10261041
1, DEVLINK_RESOURCE_UNIT_ENTRY);
10271042

1043+
devlink_resource_size_params_init(&size_fdb_params,
1044+
hellcreek->fdb_entries,
1045+
hellcreek->fdb_entries,
1046+
1, DEVLINK_RESOURCE_UNIT_ENTRY);
1047+
10281048
err = dsa_devlink_resource_register(ds, "VLAN", VLAN_N_VID,
10291049
HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE,
10301050
DEVLINK_RESOURCE_ID_PARENT_TOP,
1031-
&size_params);
1051+
&size_vlan_params);
1052+
if (err)
1053+
goto out;
1054+
1055+
err = dsa_devlink_resource_register(ds, "FDB", hellcreek->fdb_entries,
1056+
HELLCREEK_DEVLINK_PARAM_ID_FDB_TABLE,
1057+
DEVLINK_RESOURCE_ID_PARENT_TOP,
1058+
&size_fdb_params);
10321059
if (err)
10331060
goto out;
10341061

@@ -1037,6 +1064,11 @@ static int hellcreek_setup_devlink_resources(struct dsa_switch *ds)
10371064
hellcreek_devlink_vlan_table_get,
10381065
hellcreek);
10391066

1067+
dsa_devlink_resource_occ_get_register(ds,
1068+
HELLCREEK_DEVLINK_PARAM_ID_FDB_TABLE,
1069+
hellcreek_devlink_fdb_table_get,
1070+
hellcreek);
1071+
10401072
return 0;
10411073

10421074
out:

drivers/net/dsa/hirschmann/hellcreek.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ struct hellcreek {
301301
/* Devlink resources */
302302
enum hellcreek_devlink_resource_id {
303303
HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE,
304+
HELLCREEK_DEVLINK_PARAM_ID_FDB_TABLE,
304305
};
305306

306307
#endif /* _HELLCREEK_H_ */

0 commit comments

Comments
 (0)