Lines Matching refs:reporter
4629 devlink_health_reporter_priv(struct devlink_health_reporter *reporter) in devlink_health_reporter_priv() argument
4631 return reporter->priv; in devlink_health_reporter_priv()
4639 struct devlink_health_reporter *reporter; in devlink_health_reporter_find_by_name() local
4642 list_for_each_entry(reporter, &devlink->reporter_list, list) in devlink_health_reporter_find_by_name()
4643 if (!strcmp(reporter->ops->name, reporter_name)) in devlink_health_reporter_find_by_name()
4644 return reporter; in devlink_health_reporter_find_by_name()
4663 struct devlink_health_reporter *reporter; in devlink_health_reporter_create() local
4667 reporter = ERR_PTR(-EEXIST); in devlink_health_reporter_create()
4673 reporter = ERR_PTR(-EINVAL); in devlink_health_reporter_create()
4677 reporter = kzalloc(sizeof(*reporter), GFP_KERNEL); in devlink_health_reporter_create()
4678 if (!reporter) { in devlink_health_reporter_create()
4679 reporter = ERR_PTR(-ENOMEM); in devlink_health_reporter_create()
4683 reporter->priv = priv; in devlink_health_reporter_create()
4684 reporter->ops = ops; in devlink_health_reporter_create()
4685 reporter->devlink = devlink; in devlink_health_reporter_create()
4686 reporter->graceful_period = graceful_period; in devlink_health_reporter_create()
4687 reporter->auto_recover = auto_recover; in devlink_health_reporter_create()
4688 mutex_init(&reporter->dump_lock); in devlink_health_reporter_create()
4689 refcount_set(&reporter->refcount, 1); in devlink_health_reporter_create()
4690 list_add_tail(&reporter->list, &devlink->reporter_list); in devlink_health_reporter_create()
4693 return reporter; in devlink_health_reporter_create()
4703 devlink_health_reporter_destroy(struct devlink_health_reporter *reporter) in devlink_health_reporter_destroy() argument
4705 mutex_lock(&reporter->devlink->reporters_lock); in devlink_health_reporter_destroy()
4706 list_del(&reporter->list); in devlink_health_reporter_destroy()
4707 mutex_unlock(&reporter->devlink->reporters_lock); in devlink_health_reporter_destroy()
4708 while (refcount_read(&reporter->refcount) > 1) in devlink_health_reporter_destroy()
4710 mutex_destroy(&reporter->dump_lock); in devlink_health_reporter_destroy()
4711 if (reporter->dump_fmsg) in devlink_health_reporter_destroy()
4712 devlink_fmsg_free(reporter->dump_fmsg); in devlink_health_reporter_destroy()
4713 kfree(reporter); in devlink_health_reporter_destroy()
4718 devlink_health_reporter_state_update(struct devlink_health_reporter *reporter, in devlink_health_reporter_state_update() argument
4725 if (reporter->health_state == state) in devlink_health_reporter_state_update()
4728 reporter->health_state = state; in devlink_health_reporter_state_update()
4729 trace_devlink_health_reporter_state_update(reporter->devlink, in devlink_health_reporter_state_update()
4730 reporter->ops->name, state); in devlink_health_reporter_state_update()
4735 devlink_health_reporter_recover(struct devlink_health_reporter *reporter, in devlink_health_reporter_recover() argument
4740 if (!reporter->ops->recover) in devlink_health_reporter_recover()
4743 err = reporter->ops->recover(reporter, priv_ctx); in devlink_health_reporter_recover()
4747 reporter->recovery_count++; in devlink_health_reporter_recover()
4748 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_HEALTHY; in devlink_health_reporter_recover()
4749 reporter->last_recovery_ts = jiffies; in devlink_health_reporter_recover()
4755 devlink_health_dump_clear(struct devlink_health_reporter *reporter) in devlink_health_dump_clear() argument
4757 if (!reporter->dump_fmsg) in devlink_health_dump_clear()
4759 devlink_fmsg_free(reporter->dump_fmsg); in devlink_health_dump_clear()
4760 reporter->dump_fmsg = NULL; in devlink_health_dump_clear()
4763 static int devlink_health_do_dump(struct devlink_health_reporter *reporter, in devlink_health_do_dump() argument
4768 if (!reporter->ops->dump) in devlink_health_do_dump()
4771 if (reporter->dump_fmsg) in devlink_health_do_dump()
4774 reporter->dump_fmsg = devlink_fmsg_alloc(); in devlink_health_do_dump()
4775 if (!reporter->dump_fmsg) { in devlink_health_do_dump()
4780 err = devlink_fmsg_obj_nest_start(reporter->dump_fmsg); in devlink_health_do_dump()
4784 err = reporter->ops->dump(reporter, reporter->dump_fmsg, in devlink_health_do_dump()
4789 err = devlink_fmsg_obj_nest_end(reporter->dump_fmsg); in devlink_health_do_dump()
4793 reporter->dump_ts = jiffies; in devlink_health_do_dump()
4794 reporter->dump_real_ts = ktime_get_real_ns(); in devlink_health_do_dump()
4799 devlink_health_dump_clear(reporter); in devlink_health_do_dump()
4803 int devlink_health_report(struct devlink_health_reporter *reporter, in devlink_health_report() argument
4807 struct devlink *devlink = reporter->devlink; in devlink_health_report()
4811 trace_devlink_health_report(devlink, reporter->ops->name, msg); in devlink_health_report()
4812 reporter->error_count++; in devlink_health_report()
4813 prev_health_state = reporter->health_state; in devlink_health_report()
4814 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_ERROR; in devlink_health_report()
4817 if (reporter->auto_recover && in devlink_health_report()
4819 jiffies - reporter->last_recovery_ts < in devlink_health_report()
4820 msecs_to_jiffies(reporter->graceful_period))) { in devlink_health_report()
4822 reporter->ops->name, in devlink_health_report()
4823 reporter->health_state, in devlink_health_report()
4825 reporter->last_recovery_ts); in devlink_health_report()
4829 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_ERROR; in devlink_health_report()
4831 mutex_lock(&reporter->dump_lock); in devlink_health_report()
4833 devlink_health_do_dump(reporter, priv_ctx); in devlink_health_report()
4834 mutex_unlock(&reporter->dump_lock); in devlink_health_report()
4836 if (reporter->auto_recover) in devlink_health_report()
4837 return devlink_health_reporter_recover(reporter, priv_ctx); in devlink_health_report()
4847 struct devlink_health_reporter *reporter; in devlink_health_reporter_get_from_attrs() local
4855 reporter = devlink_health_reporter_find_by_name(devlink, reporter_name); in devlink_health_reporter_get_from_attrs()
4856 if (reporter) in devlink_health_reporter_get_from_attrs()
4857 refcount_inc(&reporter->refcount); in devlink_health_reporter_get_from_attrs()
4859 return reporter; in devlink_health_reporter_get_from_attrs()
4872 struct devlink_health_reporter *reporter; in devlink_health_reporter_get_from_cb() local
4893 reporter = devlink_health_reporter_get_from_attrs(devlink, attrs); in devlink_health_reporter_get_from_cb()
4896 return reporter; in devlink_health_reporter_get_from_cb()
4905 devlink_health_reporter_put(struct devlink_health_reporter *reporter) in devlink_health_reporter_put() argument
4907 refcount_dec(&reporter->refcount); in devlink_health_reporter_put()
4913 struct devlink_health_reporter *reporter, in devlink_nl_health_reporter_fill() argument
4932 reporter->ops->name)) in devlink_nl_health_reporter_fill()
4935 reporter->health_state)) in devlink_nl_health_reporter_fill()
4938 reporter->error_count, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
4941 reporter->recovery_count, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
4943 if (reporter->ops->recover && in devlink_nl_health_reporter_fill()
4945 reporter->graceful_period, in devlink_nl_health_reporter_fill()
4948 if (reporter->ops->recover && in devlink_nl_health_reporter_fill()
4950 reporter->auto_recover)) in devlink_nl_health_reporter_fill()
4952 if (reporter->dump_fmsg && in devlink_nl_health_reporter_fill()
4954 jiffies_to_msecs(reporter->dump_ts), in devlink_nl_health_reporter_fill()
4957 if (reporter->dump_fmsg && in devlink_nl_health_reporter_fill()
4959 reporter->dump_real_ts, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
4977 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_get_doit() local
4981 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_get_doit()
4982 if (!reporter) in devlink_nl_cmd_health_reporter_get_doit()
4991 err = devlink_nl_health_reporter_fill(msg, devlink, reporter, in devlink_nl_cmd_health_reporter_get_doit()
5002 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_get_doit()
5010 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_get_dumpit() local
5021 list_for_each_entry(reporter, &devlink->reporter_list, in devlink_nl_cmd_health_reporter_get_dumpit()
5028 reporter, in devlink_nl_cmd_health_reporter_get_dumpit()
5053 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_set_doit() local
5056 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_set_doit()
5057 if (!reporter) in devlink_nl_cmd_health_reporter_set_doit()
5060 if (!reporter->ops->recover && in devlink_nl_cmd_health_reporter_set_doit()
5068 reporter->graceful_period = in devlink_nl_cmd_health_reporter_set_doit()
5072 reporter->auto_recover = in devlink_nl_cmd_health_reporter_set_doit()
5075 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_set_doit()
5078 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_set_doit()
5086 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_recover_doit() local
5089 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_recover_doit()
5090 if (!reporter) in devlink_nl_cmd_health_reporter_recover_doit()
5093 err = devlink_health_reporter_recover(reporter, NULL); in devlink_nl_cmd_health_reporter_recover_doit()
5095 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_recover_doit()
5103 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_diagnose_doit() local
5107 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_diagnose_doit()
5108 if (!reporter) in devlink_nl_cmd_health_reporter_diagnose_doit()
5111 if (!reporter->ops->diagnose) { in devlink_nl_cmd_health_reporter_diagnose_doit()
5112 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
5118 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
5126 err = reporter->ops->diagnose(reporter, fmsg); in devlink_nl_cmd_health_reporter_diagnose_doit()
5139 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
5147 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_dump_get_dumpit() local
5151 reporter = devlink_health_reporter_get_from_cb(cb); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5152 if (!reporter) in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5155 if (!reporter->ops->dump) { in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5159 mutex_lock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5161 err = devlink_health_do_dump(reporter, NULL); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5164 cb->args[1] = reporter->dump_ts; in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5166 if (!reporter->dump_fmsg || cb->args[1] != reporter->dump_ts) { in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5172 err = devlink_fmsg_dumpit(reporter->dump_fmsg, skb, cb, in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5175 mutex_unlock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5177 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
5186 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_dump_clear_doit() local
5188 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_dump_clear_doit()
5189 if (!reporter) in devlink_nl_cmd_health_reporter_dump_clear_doit()
5192 if (!reporter->ops->dump) { in devlink_nl_cmd_health_reporter_dump_clear_doit()
5193 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
5197 mutex_lock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_clear_doit()
5198 devlink_health_dump_clear(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
5199 mutex_unlock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_clear_doit()
5200 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()