Lines Matching refs:reporter
6665 devlink_health_reporter_priv(struct devlink_health_reporter *reporter) in devlink_health_reporter_priv() argument
6667 return reporter->priv; in devlink_health_reporter_priv()
6676 struct devlink_health_reporter *reporter; in __devlink_health_reporter_find_by_name() local
6679 list_for_each_entry(reporter, reporter_list, list) in __devlink_health_reporter_find_by_name()
6680 if (!strcmp(reporter->ops->name, reporter_name)) in __devlink_health_reporter_find_by_name()
6681 return reporter; in __devlink_health_reporter_find_by_name()
6708 struct devlink_health_reporter *reporter; in __devlink_health_reporter_create() local
6713 reporter = kzalloc(sizeof(*reporter), GFP_KERNEL); in __devlink_health_reporter_create()
6714 if (!reporter) in __devlink_health_reporter_create()
6717 reporter->priv = priv; in __devlink_health_reporter_create()
6718 reporter->ops = ops; in __devlink_health_reporter_create()
6719 reporter->devlink = devlink; in __devlink_health_reporter_create()
6720 reporter->graceful_period = graceful_period; in __devlink_health_reporter_create()
6721 reporter->auto_recover = !!ops->recover; in __devlink_health_reporter_create()
6722 reporter->auto_dump = !!ops->dump; in __devlink_health_reporter_create()
6723 mutex_init(&reporter->dump_lock); in __devlink_health_reporter_create()
6724 refcount_set(&reporter->refcount, 1); in __devlink_health_reporter_create()
6725 return reporter; in __devlink_health_reporter_create()
6742 struct devlink_health_reporter *reporter; in devlink_port_health_reporter_create() local
6747 reporter = ERR_PTR(-EEXIST); in devlink_port_health_reporter_create()
6751 reporter = __devlink_health_reporter_create(port->devlink, ops, in devlink_port_health_reporter_create()
6753 if (IS_ERR(reporter)) in devlink_port_health_reporter_create()
6756 reporter->devlink_port = port; in devlink_port_health_reporter_create()
6757 list_add_tail(&reporter->list, &port->reporter_list); in devlink_port_health_reporter_create()
6760 return reporter; in devlink_port_health_reporter_create()
6777 struct devlink_health_reporter *reporter; in devlink_health_reporter_create() local
6781 reporter = ERR_PTR(-EEXIST); in devlink_health_reporter_create()
6785 reporter = __devlink_health_reporter_create(devlink, ops, in devlink_health_reporter_create()
6787 if (IS_ERR(reporter)) in devlink_health_reporter_create()
6790 list_add_tail(&reporter->list, &devlink->reporter_list); in devlink_health_reporter_create()
6793 return reporter; in devlink_health_reporter_create()
6798 devlink_health_reporter_free(struct devlink_health_reporter *reporter) in devlink_health_reporter_free() argument
6800 mutex_destroy(&reporter->dump_lock); in devlink_health_reporter_free()
6801 if (reporter->dump_fmsg) in devlink_health_reporter_free()
6802 devlink_fmsg_free(reporter->dump_fmsg); in devlink_health_reporter_free()
6803 kfree(reporter); in devlink_health_reporter_free()
6807 devlink_health_reporter_put(struct devlink_health_reporter *reporter) in devlink_health_reporter_put() argument
6809 if (refcount_dec_and_test(&reporter->refcount)) in devlink_health_reporter_put()
6810 devlink_health_reporter_free(reporter); in devlink_health_reporter_put()
6814 __devlink_health_reporter_destroy(struct devlink_health_reporter *reporter) in __devlink_health_reporter_destroy() argument
6816 list_del(&reporter->list); in __devlink_health_reporter_destroy()
6817 devlink_health_reporter_put(reporter); in __devlink_health_reporter_destroy()
6826 devlink_health_reporter_destroy(struct devlink_health_reporter *reporter) in devlink_health_reporter_destroy() argument
6828 struct mutex *lock = &reporter->devlink->reporters_lock; in devlink_health_reporter_destroy()
6831 __devlink_health_reporter_destroy(reporter); in devlink_health_reporter_destroy()
6842 devlink_port_health_reporter_destroy(struct devlink_health_reporter *reporter) in devlink_port_health_reporter_destroy() argument
6844 struct mutex *lock = &reporter->devlink_port->reporters_lock; in devlink_port_health_reporter_destroy()
6847 __devlink_health_reporter_destroy(reporter); in devlink_port_health_reporter_destroy()
6854 struct devlink_health_reporter *reporter, in devlink_nl_health_reporter_fill() argument
6858 struct devlink *devlink = reporter->devlink; in devlink_nl_health_reporter_fill()
6869 if (reporter->devlink_port) { in devlink_nl_health_reporter_fill()
6870 if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX, reporter->devlink_port->index)) in devlink_nl_health_reporter_fill()
6878 reporter->ops->name)) in devlink_nl_health_reporter_fill()
6881 reporter->health_state)) in devlink_nl_health_reporter_fill()
6884 reporter->error_count, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
6887 reporter->recovery_count, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
6889 if (reporter->ops->recover && in devlink_nl_health_reporter_fill()
6891 reporter->graceful_period, in devlink_nl_health_reporter_fill()
6894 if (reporter->ops->recover && in devlink_nl_health_reporter_fill()
6896 reporter->auto_recover)) in devlink_nl_health_reporter_fill()
6898 if (reporter->dump_fmsg && in devlink_nl_health_reporter_fill()
6900 jiffies_to_msecs(reporter->dump_ts), in devlink_nl_health_reporter_fill()
6903 if (reporter->dump_fmsg && in devlink_nl_health_reporter_fill()
6905 reporter->dump_real_ts, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
6907 if (reporter->ops->dump && in devlink_nl_health_reporter_fill()
6909 reporter->auto_dump)) in devlink_nl_health_reporter_fill()
6923 static void devlink_recover_notify(struct devlink_health_reporter *reporter, in devlink_recover_notify() argument
6935 err = devlink_nl_health_reporter_fill(msg, reporter, cmd, 0, 0, 0); in devlink_recover_notify()
6942 devlink_net(reporter->devlink), in devlink_recover_notify()
6947 devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter) in devlink_health_reporter_recovery_done() argument
6949 reporter->recovery_count++; in devlink_health_reporter_recovery_done()
6950 reporter->last_recovery_ts = jiffies; in devlink_health_reporter_recovery_done()
6955 devlink_health_reporter_recover(struct devlink_health_reporter *reporter, in devlink_health_reporter_recover() argument
6960 if (reporter->health_state == DEVLINK_HEALTH_REPORTER_STATE_HEALTHY) in devlink_health_reporter_recover()
6963 if (!reporter->ops->recover) in devlink_health_reporter_recover()
6966 err = reporter->ops->recover(reporter, priv_ctx, extack); in devlink_health_reporter_recover()
6970 devlink_health_reporter_recovery_done(reporter); in devlink_health_reporter_recover()
6971 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_HEALTHY; in devlink_health_reporter_recover()
6972 devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER); in devlink_health_reporter_recover()
6978 devlink_health_dump_clear(struct devlink_health_reporter *reporter) in devlink_health_dump_clear() argument
6980 if (!reporter->dump_fmsg) in devlink_health_dump_clear()
6982 devlink_fmsg_free(reporter->dump_fmsg); in devlink_health_dump_clear()
6983 reporter->dump_fmsg = NULL; in devlink_health_dump_clear()
6986 static int devlink_health_do_dump(struct devlink_health_reporter *reporter, in devlink_health_do_dump() argument
6992 if (!reporter->ops->dump) in devlink_health_do_dump()
6995 if (reporter->dump_fmsg) in devlink_health_do_dump()
6998 reporter->dump_fmsg = devlink_fmsg_alloc(); in devlink_health_do_dump()
6999 if (!reporter->dump_fmsg) { in devlink_health_do_dump()
7004 err = devlink_fmsg_obj_nest_start(reporter->dump_fmsg); in devlink_health_do_dump()
7008 err = reporter->ops->dump(reporter, reporter->dump_fmsg, in devlink_health_do_dump()
7013 err = devlink_fmsg_obj_nest_end(reporter->dump_fmsg); in devlink_health_do_dump()
7017 reporter->dump_ts = jiffies; in devlink_health_do_dump()
7018 reporter->dump_real_ts = ktime_get_real_ns(); in devlink_health_do_dump()
7023 devlink_health_dump_clear(reporter); in devlink_health_do_dump()
7027 int devlink_health_report(struct devlink_health_reporter *reporter, in devlink_health_report() argument
7031 struct devlink *devlink = reporter->devlink; in devlink_health_report()
7036 trace_devlink_health_report(devlink, reporter->ops->name, msg); in devlink_health_report()
7037 reporter->error_count++; in devlink_health_report()
7038 prev_health_state = reporter->health_state; in devlink_health_report()
7039 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_ERROR; in devlink_health_report()
7040 devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER); in devlink_health_report()
7043 recover_ts_threshold = reporter->last_recovery_ts + in devlink_health_report()
7044 msecs_to_jiffies(reporter->graceful_period); in devlink_health_report()
7045 if (reporter->auto_recover && in devlink_health_report()
7047 (reporter->last_recovery_ts && reporter->recovery_count && in devlink_health_report()
7050 reporter->ops->name, in devlink_health_report()
7051 reporter->health_state, in devlink_health_report()
7053 reporter->last_recovery_ts); in devlink_health_report()
7057 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_ERROR; in devlink_health_report()
7059 if (reporter->auto_dump) { in devlink_health_report()
7060 mutex_lock(&reporter->dump_lock); in devlink_health_report()
7062 devlink_health_do_dump(reporter, priv_ctx, NULL); in devlink_health_report()
7063 mutex_unlock(&reporter->dump_lock); in devlink_health_report()
7066 if (reporter->auto_recover) in devlink_health_report()
7067 return devlink_health_reporter_recover(reporter, in devlink_health_report()
7078 struct devlink_health_reporter *reporter; in devlink_health_reporter_get_from_attrs() local
7089 reporter = devlink_health_reporter_find_by_name(devlink, reporter_name); in devlink_health_reporter_get_from_attrs()
7090 if (reporter) in devlink_health_reporter_get_from_attrs()
7091 refcount_inc(&reporter->refcount); in devlink_health_reporter_get_from_attrs()
7095 reporter = devlink_port_health_reporter_find_by_name(devlink_port, reporter_name); in devlink_health_reporter_get_from_attrs()
7096 if (reporter) in devlink_health_reporter_get_from_attrs()
7097 refcount_inc(&reporter->refcount); in devlink_health_reporter_get_from_attrs()
7101 return reporter; in devlink_health_reporter_get_from_attrs()
7115 struct devlink_health_reporter *reporter; in devlink_health_reporter_get_from_cb() local
7124 reporter = devlink_health_reporter_get_from_attrs(devlink, attrs); in devlink_health_reporter_get_from_cb()
7127 return reporter; in devlink_health_reporter_get_from_cb()
7134 devlink_health_reporter_state_update(struct devlink_health_reporter *reporter, in devlink_health_reporter_state_update() argument
7141 if (reporter->health_state == state) in devlink_health_reporter_state_update()
7144 reporter->health_state = state; in devlink_health_reporter_state_update()
7145 trace_devlink_health_reporter_state_update(reporter->devlink, in devlink_health_reporter_state_update()
7146 reporter->ops->name, state); in devlink_health_reporter_state_update()
7147 devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER); in devlink_health_reporter_state_update()
7155 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_get_doit() local
7159 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_get_doit()
7160 if (!reporter) in devlink_nl_cmd_health_reporter_get_doit()
7169 err = devlink_nl_health_reporter_fill(msg, reporter, in devlink_nl_cmd_health_reporter_get_doit()
7180 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_get_doit()
7188 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_get_dumpit() local
7205 list_for_each_entry(reporter, &devlink->reporter_list, in devlink_nl_cmd_health_reporter_get_dumpit()
7212 msg, reporter, DEVLINK_CMD_HEALTH_REPORTER_GET, in devlink_nl_cmd_health_reporter_get_dumpit()
7237 list_for_each_entry(reporter, &port->reporter_list, list) { in devlink_nl_cmd_health_reporter_get_dumpit()
7243 msg, reporter, in devlink_nl_cmd_health_reporter_get_dumpit()
7273 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_set_doit() local
7276 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_set_doit()
7277 if (!reporter) in devlink_nl_cmd_health_reporter_set_doit()
7280 if (!reporter->ops->recover && in devlink_nl_cmd_health_reporter_set_doit()
7286 if (!reporter->ops->dump && in devlink_nl_cmd_health_reporter_set_doit()
7293 reporter->graceful_period = in devlink_nl_cmd_health_reporter_set_doit()
7297 reporter->auto_recover = in devlink_nl_cmd_health_reporter_set_doit()
7301 reporter->auto_dump = in devlink_nl_cmd_health_reporter_set_doit()
7304 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_set_doit()
7307 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_set_doit()
7315 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_recover_doit() local
7318 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_recover_doit()
7319 if (!reporter) in devlink_nl_cmd_health_reporter_recover_doit()
7322 err = devlink_health_reporter_recover(reporter, NULL, info->extack); in devlink_nl_cmd_health_reporter_recover_doit()
7324 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_recover_doit()
7332 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_diagnose_doit() local
7336 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_diagnose_doit()
7337 if (!reporter) in devlink_nl_cmd_health_reporter_diagnose_doit()
7340 if (!reporter->ops->diagnose) { in devlink_nl_cmd_health_reporter_diagnose_doit()
7341 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
7347 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
7355 err = reporter->ops->diagnose(reporter, fmsg, info->extack); in devlink_nl_cmd_health_reporter_diagnose_doit()
7368 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
7376 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_dump_get_dumpit() local
7380 reporter = devlink_health_reporter_get_from_cb(cb); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7381 if (!reporter) in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7384 if (!reporter->ops->dump) { in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7388 mutex_lock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7390 err = devlink_health_do_dump(reporter, NULL, cb->extack); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7393 cb->args[1] = reporter->dump_ts; in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7395 if (!reporter->dump_fmsg || cb->args[1] != reporter->dump_ts) { in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7401 err = devlink_fmsg_dumpit(reporter->dump_fmsg, skb, cb, in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7404 mutex_unlock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7406 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
7415 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_dump_clear_doit() local
7417 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_dump_clear_doit()
7418 if (!reporter) in devlink_nl_cmd_health_reporter_dump_clear_doit()
7421 if (!reporter->ops->dump) { in devlink_nl_cmd_health_reporter_dump_clear_doit()
7422 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
7426 mutex_lock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_clear_doit()
7427 devlink_health_dump_clear(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
7428 mutex_unlock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_clear_doit()
7429 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
7437 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_test_doit() local
7440 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_test_doit()
7441 if (!reporter) in devlink_nl_cmd_health_reporter_test_doit()
7444 if (!reporter->ops->test) { in devlink_nl_cmd_health_reporter_test_doit()
7445 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_test_doit()
7449 err = reporter->ops->test(reporter, info->extack); in devlink_nl_cmd_health_reporter_test_doit()
7451 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_test_doit()