Skip to content

Commit b03f13c

Browse files
Jiri Pirkokuba-moo
authored andcommitted
devlink: extend health reporter dump selector by port index
Introduce a possibility for devlink object to expose attributes it supports for selection of dumped objects. Use this by health reporter to indicate it supports port index based selection of dump objects. Implement this selection mechanism in devlink_nl_cmd_health_reporter_get_dump_one() Example: $ devlink health pci/0000:08:00.0: reporter fw state healthy error 0 recover 0 auto_dump true reporter fw_fatal state healthy error 0 recover 0 grace_period 60000 auto_recover true auto_dump true reporter vnic state healthy error 0 recover 0 pci/0000:08:00.0/32768: reporter vnic state healthy error 0 recover 0 pci/0000:08:00.0/32769: reporter vnic state healthy error 0 recover 0 pci/0000:08:00.0/32770: reporter vnic state healthy error 0 recover 0 pci/0000:08:00.1: reporter fw state healthy error 0 recover 0 auto_dump true reporter fw_fatal state healthy error 0 recover 0 grace_period 60000 auto_recover true auto_dump true reporter vnic state healthy error 0 recover 0 pci/0000:08:00.1/98304: reporter vnic state healthy error 0 recover 0 pci/0000:08:00.1/98305: reporter vnic state healthy error 0 recover 0 pci/0000:08:00.1/98306: reporter vnic state healthy error 0 recover 0 $ devlink health show pci/0000:08:00.0 pci/0000:08:00.0: reporter fw state healthy error 0 recover 0 auto_dump true reporter fw_fatal state healthy error 0 recover 0 grace_period 60000 auto_recover true auto_dump true reporter vnic state healthy error 0 recover 0 pci/0000:08:00.0/32768: reporter vnic state healthy error 0 recover 0 pci/0000:08:00.0/32769: reporter vnic state healthy error 0 recover 0 pci/0000:08:00.0/32770: reporter vnic state healthy error 0 recover 0 $ devlink health show pci/0000:08:00.0/32768 pci/0000:08:00.0/32768: reporter vnic state healthy error 0 recover 0 The last command is possible because of this patch. Signed-off-by: Jiri Pirko <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3449333 commit b03f13c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

net/devlink/health.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,23 @@ static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
390390
int flags)
391391
{
392392
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
393+
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
393394
struct devlink_health_reporter *reporter;
395+
unsigned long port_index_end = ULONG_MAX;
396+
struct nlattr **attrs = info->attrs;
397+
unsigned long port_index_start = 0;
394398
struct devlink_port *port;
395399
unsigned long port_index;
396400
int idx = 0;
397401
int err;
398402

403+
if (attrs && attrs[DEVLINK_ATTR_PORT_INDEX]) {
404+
port_index_start = nla_get_u32(attrs[DEVLINK_ATTR_PORT_INDEX]);
405+
port_index_end = port_index_start;
406+
flags |= NLM_F_DUMP_FILTERED;
407+
goto per_port_dump;
408+
}
409+
399410
list_for_each_entry(reporter, &devlink->reporter_list, list) {
400411
if (idx < state->idx) {
401412
idx++;
@@ -412,7 +423,9 @@ static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
412423
}
413424
idx++;
414425
}
415-
xa_for_each(&devlink->ports, port_index, port) {
426+
per_port_dump:
427+
xa_for_each_range(&devlink->ports, port_index, port,
428+
port_index_start, port_index_end) {
416429
list_for_each_entry(reporter, &port->reporter_list, list) {
417430
if (idx < state->idx) {
418431
idx++;

0 commit comments

Comments
 (0)