Lines Matching refs:reporter
5837 devlink_health_reporter_priv(struct devlink_health_reporter *reporter) in devlink_health_reporter_priv() argument
5839 return reporter->priv; in devlink_health_reporter_priv()
5848 struct devlink_health_reporter *reporter; in __devlink_health_reporter_find_by_name() local
5851 list_for_each_entry(reporter, reporter_list, list) in __devlink_health_reporter_find_by_name()
5852 if (!strcmp(reporter->ops->name, reporter_name)) in __devlink_health_reporter_find_by_name()
5853 return reporter; in __devlink_health_reporter_find_by_name()
5880 struct devlink_health_reporter *reporter; in __devlink_health_reporter_create() local
5885 reporter = kzalloc(sizeof(*reporter), GFP_KERNEL); in __devlink_health_reporter_create()
5886 if (!reporter) in __devlink_health_reporter_create()
5889 reporter->priv = priv; in __devlink_health_reporter_create()
5890 reporter->ops = ops; in __devlink_health_reporter_create()
5891 reporter->devlink = devlink; in __devlink_health_reporter_create()
5892 reporter->graceful_period = graceful_period; in __devlink_health_reporter_create()
5893 reporter->auto_recover = !!ops->recover; in __devlink_health_reporter_create()
5894 reporter->auto_dump = !!ops->dump; in __devlink_health_reporter_create()
5895 mutex_init(&reporter->dump_lock); in __devlink_health_reporter_create()
5896 refcount_set(&reporter->refcount, 1); in __devlink_health_reporter_create()
5897 return reporter; in __devlink_health_reporter_create()
5914 struct devlink_health_reporter *reporter; in devlink_port_health_reporter_create() local
5919 reporter = ERR_PTR(-EEXIST); in devlink_port_health_reporter_create()
5923 reporter = __devlink_health_reporter_create(port->devlink, ops, in devlink_port_health_reporter_create()
5925 if (IS_ERR(reporter)) in devlink_port_health_reporter_create()
5928 reporter->devlink_port = port; in devlink_port_health_reporter_create()
5929 list_add_tail(&reporter->list, &port->reporter_list); in devlink_port_health_reporter_create()
5932 return reporter; in devlink_port_health_reporter_create()
5949 struct devlink_health_reporter *reporter; in devlink_health_reporter_create() local
5953 reporter = ERR_PTR(-EEXIST); in devlink_health_reporter_create()
5957 reporter = __devlink_health_reporter_create(devlink, ops, in devlink_health_reporter_create()
5959 if (IS_ERR(reporter)) in devlink_health_reporter_create()
5962 list_add_tail(&reporter->list, &devlink->reporter_list); in devlink_health_reporter_create()
5965 return reporter; in devlink_health_reporter_create()
5970 devlink_health_reporter_free(struct devlink_health_reporter *reporter) in devlink_health_reporter_free() argument
5972 mutex_destroy(&reporter->dump_lock); in devlink_health_reporter_free()
5973 if (reporter->dump_fmsg) in devlink_health_reporter_free()
5974 devlink_fmsg_free(reporter->dump_fmsg); in devlink_health_reporter_free()
5975 kfree(reporter); in devlink_health_reporter_free()
5979 devlink_health_reporter_put(struct devlink_health_reporter *reporter) in devlink_health_reporter_put() argument
5981 if (refcount_dec_and_test(&reporter->refcount)) in devlink_health_reporter_put()
5982 devlink_health_reporter_free(reporter); in devlink_health_reporter_put()
5986 __devlink_health_reporter_destroy(struct devlink_health_reporter *reporter) in __devlink_health_reporter_destroy() argument
5988 list_del(&reporter->list); in __devlink_health_reporter_destroy()
5989 devlink_health_reporter_put(reporter); in __devlink_health_reporter_destroy()
5998 devlink_health_reporter_destroy(struct devlink_health_reporter *reporter) in devlink_health_reporter_destroy() argument
6000 struct mutex *lock = &reporter->devlink->reporters_lock; in devlink_health_reporter_destroy()
6003 __devlink_health_reporter_destroy(reporter); in devlink_health_reporter_destroy()
6014 devlink_port_health_reporter_destroy(struct devlink_health_reporter *reporter) in devlink_port_health_reporter_destroy() argument
6016 struct mutex *lock = &reporter->devlink_port->reporters_lock; in devlink_port_health_reporter_destroy()
6019 __devlink_health_reporter_destroy(reporter); in devlink_port_health_reporter_destroy()
6027 struct devlink_health_reporter *reporter, in devlink_nl_health_reporter_fill() argument
6041 if (reporter->devlink_port) { in devlink_nl_health_reporter_fill()
6042 if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX, reporter->devlink_port->index)) in devlink_nl_health_reporter_fill()
6050 reporter->ops->name)) in devlink_nl_health_reporter_fill()
6053 reporter->health_state)) in devlink_nl_health_reporter_fill()
6056 reporter->error_count, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
6059 reporter->recovery_count, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
6061 if (reporter->ops->recover && in devlink_nl_health_reporter_fill()
6063 reporter->graceful_period, in devlink_nl_health_reporter_fill()
6066 if (reporter->ops->recover && in devlink_nl_health_reporter_fill()
6068 reporter->auto_recover)) in devlink_nl_health_reporter_fill()
6070 if (reporter->dump_fmsg && in devlink_nl_health_reporter_fill()
6072 jiffies_to_msecs(reporter->dump_ts), in devlink_nl_health_reporter_fill()
6075 if (reporter->dump_fmsg && in devlink_nl_health_reporter_fill()
6077 reporter->dump_real_ts, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
6079 if (reporter->ops->dump && in devlink_nl_health_reporter_fill()
6081 reporter->auto_dump)) in devlink_nl_health_reporter_fill()
6095 static void devlink_recover_notify(struct devlink_health_reporter *reporter, in devlink_recover_notify() argument
6107 err = devlink_nl_health_reporter_fill(msg, reporter->devlink, in devlink_recover_notify()
6108 reporter, cmd, 0, 0, 0); in devlink_recover_notify()
6115 devlink_net(reporter->devlink), in devlink_recover_notify()
6120 devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter) in devlink_health_reporter_recovery_done() argument
6122 reporter->recovery_count++; in devlink_health_reporter_recovery_done()
6123 reporter->last_recovery_ts = jiffies; in devlink_health_reporter_recovery_done()
6128 devlink_health_reporter_recover(struct devlink_health_reporter *reporter, in devlink_health_reporter_recover() argument
6133 if (reporter->health_state == DEVLINK_HEALTH_REPORTER_STATE_HEALTHY) in devlink_health_reporter_recover()
6136 if (!reporter->ops->recover) in devlink_health_reporter_recover()
6139 err = reporter->ops->recover(reporter, priv_ctx, extack); in devlink_health_reporter_recover()
6143 devlink_health_reporter_recovery_done(reporter); in devlink_health_reporter_recover()
6144 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_HEALTHY; in devlink_health_reporter_recover()
6145 devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER); in devlink_health_reporter_recover()
6151 devlink_health_dump_clear(struct devlink_health_reporter *reporter) in devlink_health_dump_clear() argument
6153 if (!reporter->dump_fmsg) in devlink_health_dump_clear()
6155 devlink_fmsg_free(reporter->dump_fmsg); in devlink_health_dump_clear()
6156 reporter->dump_fmsg = NULL; in devlink_health_dump_clear()
6159 static int devlink_health_do_dump(struct devlink_health_reporter *reporter, in devlink_health_do_dump() argument
6165 if (!reporter->ops->dump) in devlink_health_do_dump()
6168 if (reporter->dump_fmsg) in devlink_health_do_dump()
6171 reporter->dump_fmsg = devlink_fmsg_alloc(); in devlink_health_do_dump()
6172 if (!reporter->dump_fmsg) { in devlink_health_do_dump()
6177 err = devlink_fmsg_obj_nest_start(reporter->dump_fmsg); in devlink_health_do_dump()
6181 err = reporter->ops->dump(reporter, reporter->dump_fmsg, in devlink_health_do_dump()
6186 err = devlink_fmsg_obj_nest_end(reporter->dump_fmsg); in devlink_health_do_dump()
6190 reporter->dump_ts = jiffies; in devlink_health_do_dump()
6191 reporter->dump_real_ts = ktime_get_real_ns(); in devlink_health_do_dump()
6196 devlink_health_dump_clear(reporter); in devlink_health_do_dump()
6200 int devlink_health_report(struct devlink_health_reporter *reporter, in devlink_health_report() argument
6204 struct devlink *devlink = reporter->devlink; in devlink_health_report()
6209 trace_devlink_health_report(devlink, reporter->ops->name, msg); in devlink_health_report()
6210 reporter->error_count++; in devlink_health_report()
6211 prev_health_state = reporter->health_state; in devlink_health_report()
6212 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_ERROR; in devlink_health_report()
6213 devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER); in devlink_health_report()
6216 recover_ts_threshold = reporter->last_recovery_ts + in devlink_health_report()
6217 msecs_to_jiffies(reporter->graceful_period); in devlink_health_report()
6218 if (reporter->auto_recover && in devlink_health_report()
6220 (reporter->last_recovery_ts && reporter->recovery_count && in devlink_health_report()
6223 reporter->ops->name, in devlink_health_report()
6224 reporter->health_state, in devlink_health_report()
6226 reporter->last_recovery_ts); in devlink_health_report()
6230 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_ERROR; in devlink_health_report()
6232 if (reporter->auto_dump) { in devlink_health_report()
6233 mutex_lock(&reporter->dump_lock); in devlink_health_report()
6235 devlink_health_do_dump(reporter, priv_ctx, NULL); in devlink_health_report()
6236 mutex_unlock(&reporter->dump_lock); in devlink_health_report()
6239 if (reporter->auto_recover) in devlink_health_report()
6240 return devlink_health_reporter_recover(reporter, in devlink_health_report()
6251 struct devlink_health_reporter *reporter; in devlink_health_reporter_get_from_attrs() local
6262 reporter = devlink_health_reporter_find_by_name(devlink, reporter_name); in devlink_health_reporter_get_from_attrs()
6263 if (reporter) in devlink_health_reporter_get_from_attrs()
6264 refcount_inc(&reporter->refcount); in devlink_health_reporter_get_from_attrs()
6268 reporter = devlink_port_health_reporter_find_by_name(devlink_port, reporter_name); in devlink_health_reporter_get_from_attrs()
6269 if (reporter) in devlink_health_reporter_get_from_attrs()
6270 refcount_inc(&reporter->refcount); in devlink_health_reporter_get_from_attrs()
6274 return reporter; in devlink_health_reporter_get_from_attrs()
6288 struct devlink_health_reporter *reporter; in devlink_health_reporter_get_from_cb() local
6297 reporter = devlink_health_reporter_get_from_attrs(devlink, attrs); in devlink_health_reporter_get_from_cb()
6299 return reporter; in devlink_health_reporter_get_from_cb()
6306 devlink_health_reporter_state_update(struct devlink_health_reporter *reporter, in devlink_health_reporter_state_update() argument
6313 if (reporter->health_state == state) in devlink_health_reporter_state_update()
6316 reporter->health_state = state; in devlink_health_reporter_state_update()
6317 trace_devlink_health_reporter_state_update(reporter->devlink, in devlink_health_reporter_state_update()
6318 reporter->ops->name, state); in devlink_health_reporter_state_update()
6319 devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER); in devlink_health_reporter_state_update()
6327 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_get_doit() local
6331 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_get_doit()
6332 if (!reporter) in devlink_nl_cmd_health_reporter_get_doit()
6341 err = devlink_nl_health_reporter_fill(msg, devlink, reporter, in devlink_nl_cmd_health_reporter_get_doit()
6352 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_get_doit()
6360 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_get_dumpit() local
6372 list_for_each_entry(reporter, &devlink->reporter_list, in devlink_nl_cmd_health_reporter_get_dumpit()
6379 reporter, in devlink_nl_cmd_health_reporter_get_dumpit()
6399 list_for_each_entry(reporter, &port->reporter_list, list) { in devlink_nl_cmd_health_reporter_get_dumpit()
6404 err = devlink_nl_health_reporter_fill(msg, devlink, reporter, in devlink_nl_cmd_health_reporter_get_dumpit()
6432 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_set_doit() local
6435 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_set_doit()
6436 if (!reporter) in devlink_nl_cmd_health_reporter_set_doit()
6439 if (!reporter->ops->recover && in devlink_nl_cmd_health_reporter_set_doit()
6445 if (!reporter->ops->dump && in devlink_nl_cmd_health_reporter_set_doit()
6452 reporter->graceful_period = in devlink_nl_cmd_health_reporter_set_doit()
6456 reporter->auto_recover = in devlink_nl_cmd_health_reporter_set_doit()
6460 reporter->auto_dump = in devlink_nl_cmd_health_reporter_set_doit()
6463 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_set_doit()
6466 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_set_doit()
6474 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_recover_doit() local
6477 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_recover_doit()
6478 if (!reporter) in devlink_nl_cmd_health_reporter_recover_doit()
6481 err = devlink_health_reporter_recover(reporter, NULL, info->extack); in devlink_nl_cmd_health_reporter_recover_doit()
6483 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_recover_doit()
6491 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_diagnose_doit() local
6495 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_diagnose_doit()
6496 if (!reporter) in devlink_nl_cmd_health_reporter_diagnose_doit()
6499 if (!reporter->ops->diagnose) { in devlink_nl_cmd_health_reporter_diagnose_doit()
6500 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
6506 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
6514 err = reporter->ops->diagnose(reporter, fmsg, info->extack); in devlink_nl_cmd_health_reporter_diagnose_doit()
6527 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
6535 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_dump_get_dumpit() local
6539 reporter = devlink_health_reporter_get_from_cb(cb); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6540 if (!reporter) in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6543 if (!reporter->ops->dump) { in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6547 mutex_lock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6549 err = devlink_health_do_dump(reporter, NULL, cb->extack); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6552 cb->args[1] = reporter->dump_ts; in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6554 if (!reporter->dump_fmsg || cb->args[1] != reporter->dump_ts) { in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6560 err = devlink_fmsg_dumpit(reporter->dump_fmsg, skb, cb, in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6563 mutex_unlock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6565 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
6574 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_dump_clear_doit() local
6576 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_dump_clear_doit()
6577 if (!reporter) in devlink_nl_cmd_health_reporter_dump_clear_doit()
6580 if (!reporter->ops->dump) { in devlink_nl_cmd_health_reporter_dump_clear_doit()
6581 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
6585 mutex_lock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_clear_doit()
6586 devlink_health_dump_clear(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
6587 mutex_unlock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_clear_doit()
6588 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
6596 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_test_doit() local
6599 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_test_doit()
6600 if (!reporter) in devlink_nl_cmd_health_reporter_test_doit()
6603 if (!reporter->ops->test) { in devlink_nl_cmd_health_reporter_test_doit()
6604 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_test_doit()
6608 err = reporter->ops->test(reporter, info->extack); in devlink_nl_cmd_health_reporter_test_doit()
6610 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_test_doit()