Lines Matching refs:reporter

7376 devlink_health_reporter_priv(struct devlink_health_reporter *reporter)  in devlink_health_reporter_priv()  argument
7378 return reporter->priv; in devlink_health_reporter_priv()
7387 struct devlink_health_reporter *reporter; in __devlink_health_reporter_find_by_name() local
7390 list_for_each_entry(reporter, reporter_list, list) in __devlink_health_reporter_find_by_name()
7391 if (!strcmp(reporter->ops->name, reporter_name)) in __devlink_health_reporter_find_by_name()
7392 return reporter; in __devlink_health_reporter_find_by_name()
7419 struct devlink_health_reporter *reporter; in __devlink_health_reporter_create() local
7424 reporter = kzalloc(sizeof(*reporter), GFP_KERNEL); in __devlink_health_reporter_create()
7425 if (!reporter) in __devlink_health_reporter_create()
7428 reporter->priv = priv; in __devlink_health_reporter_create()
7429 reporter->ops = ops; in __devlink_health_reporter_create()
7430 reporter->devlink = devlink; in __devlink_health_reporter_create()
7431 reporter->graceful_period = graceful_period; in __devlink_health_reporter_create()
7432 reporter->auto_recover = !!ops->recover; in __devlink_health_reporter_create()
7433 reporter->auto_dump = !!ops->dump; in __devlink_health_reporter_create()
7434 mutex_init(&reporter->dump_lock); in __devlink_health_reporter_create()
7435 refcount_set(&reporter->refcount, 1); in __devlink_health_reporter_create()
7436 return reporter; in __devlink_health_reporter_create()
7453 struct devlink_health_reporter *reporter; in devlink_port_health_reporter_create() local
7458 reporter = ERR_PTR(-EEXIST); in devlink_port_health_reporter_create()
7462 reporter = __devlink_health_reporter_create(port->devlink, ops, in devlink_port_health_reporter_create()
7464 if (IS_ERR(reporter)) in devlink_port_health_reporter_create()
7467 reporter->devlink_port = port; in devlink_port_health_reporter_create()
7468 list_add_tail(&reporter->list, &port->reporter_list); in devlink_port_health_reporter_create()
7471 return reporter; in devlink_port_health_reporter_create()
7488 struct devlink_health_reporter *reporter; in devlink_health_reporter_create() local
7492 reporter = ERR_PTR(-EEXIST); in devlink_health_reporter_create()
7496 reporter = __devlink_health_reporter_create(devlink, ops, in devlink_health_reporter_create()
7498 if (IS_ERR(reporter)) in devlink_health_reporter_create()
7501 list_add_tail(&reporter->list, &devlink->reporter_list); in devlink_health_reporter_create()
7504 return reporter; in devlink_health_reporter_create()
7509 devlink_health_reporter_free(struct devlink_health_reporter *reporter) in devlink_health_reporter_free() argument
7511 mutex_destroy(&reporter->dump_lock); in devlink_health_reporter_free()
7512 if (reporter->dump_fmsg) in devlink_health_reporter_free()
7513 devlink_fmsg_free(reporter->dump_fmsg); in devlink_health_reporter_free()
7514 kfree(reporter); in devlink_health_reporter_free()
7518 devlink_health_reporter_put(struct devlink_health_reporter *reporter) in devlink_health_reporter_put() argument
7520 if (refcount_dec_and_test(&reporter->refcount)) in devlink_health_reporter_put()
7521 devlink_health_reporter_free(reporter); in devlink_health_reporter_put()
7525 __devlink_health_reporter_destroy(struct devlink_health_reporter *reporter) in __devlink_health_reporter_destroy() argument
7527 list_del(&reporter->list); in __devlink_health_reporter_destroy()
7528 devlink_health_reporter_put(reporter); in __devlink_health_reporter_destroy()
7537 devlink_health_reporter_destroy(struct devlink_health_reporter *reporter) in devlink_health_reporter_destroy() argument
7539 struct mutex *lock = &reporter->devlink->reporters_lock; in devlink_health_reporter_destroy()
7542 __devlink_health_reporter_destroy(reporter); in devlink_health_reporter_destroy()
7553 devlink_port_health_reporter_destroy(struct devlink_health_reporter *reporter) in devlink_port_health_reporter_destroy() argument
7555 struct mutex *lock = &reporter->devlink_port->reporters_lock; in devlink_port_health_reporter_destroy()
7558 __devlink_health_reporter_destroy(reporter); in devlink_port_health_reporter_destroy()
7565 struct devlink_health_reporter *reporter, in devlink_nl_health_reporter_fill() argument
7569 struct devlink *devlink = reporter->devlink; in devlink_nl_health_reporter_fill()
7580 if (reporter->devlink_port) { in devlink_nl_health_reporter_fill()
7581 if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX, reporter->devlink_port->index)) in devlink_nl_health_reporter_fill()
7589 reporter->ops->name)) in devlink_nl_health_reporter_fill()
7592 reporter->health_state)) in devlink_nl_health_reporter_fill()
7595 reporter->error_count, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
7598 reporter->recovery_count, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
7600 if (reporter->ops->recover && in devlink_nl_health_reporter_fill()
7602 reporter->graceful_period, in devlink_nl_health_reporter_fill()
7605 if (reporter->ops->recover && in devlink_nl_health_reporter_fill()
7607 reporter->auto_recover)) in devlink_nl_health_reporter_fill()
7609 if (reporter->dump_fmsg && in devlink_nl_health_reporter_fill()
7611 jiffies_to_msecs(reporter->dump_ts), in devlink_nl_health_reporter_fill()
7614 if (reporter->dump_fmsg && in devlink_nl_health_reporter_fill()
7616 reporter->dump_real_ts, DEVLINK_ATTR_PAD)) in devlink_nl_health_reporter_fill()
7618 if (reporter->ops->dump && in devlink_nl_health_reporter_fill()
7620 reporter->auto_dump)) in devlink_nl_health_reporter_fill()
7634 static void devlink_recover_notify(struct devlink_health_reporter *reporter, in devlink_recover_notify() argument
7637 struct devlink *devlink = reporter->devlink; in devlink_recover_notify()
7648 err = devlink_nl_health_reporter_fill(msg, reporter, cmd, 0, 0, 0); in devlink_recover_notify()
7659 devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter) in devlink_health_reporter_recovery_done() argument
7661 reporter->recovery_count++; in devlink_health_reporter_recovery_done()
7662 reporter->last_recovery_ts = jiffies; in devlink_health_reporter_recovery_done()
7667 devlink_health_reporter_recover(struct devlink_health_reporter *reporter, in devlink_health_reporter_recover() argument
7672 if (reporter->health_state == DEVLINK_HEALTH_REPORTER_STATE_HEALTHY) in devlink_health_reporter_recover()
7675 if (!reporter->ops->recover) in devlink_health_reporter_recover()
7678 err = reporter->ops->recover(reporter, priv_ctx, extack); in devlink_health_reporter_recover()
7682 devlink_health_reporter_recovery_done(reporter); in devlink_health_reporter_recover()
7683 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_HEALTHY; in devlink_health_reporter_recover()
7684 devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER); in devlink_health_reporter_recover()
7690 devlink_health_dump_clear(struct devlink_health_reporter *reporter) in devlink_health_dump_clear() argument
7692 if (!reporter->dump_fmsg) in devlink_health_dump_clear()
7694 devlink_fmsg_free(reporter->dump_fmsg); in devlink_health_dump_clear()
7695 reporter->dump_fmsg = NULL; in devlink_health_dump_clear()
7698 static int devlink_health_do_dump(struct devlink_health_reporter *reporter, in devlink_health_do_dump() argument
7704 if (!reporter->ops->dump) in devlink_health_do_dump()
7707 if (reporter->dump_fmsg) in devlink_health_do_dump()
7710 reporter->dump_fmsg = devlink_fmsg_alloc(); in devlink_health_do_dump()
7711 if (!reporter->dump_fmsg) { in devlink_health_do_dump()
7716 err = devlink_fmsg_obj_nest_start(reporter->dump_fmsg); in devlink_health_do_dump()
7720 err = reporter->ops->dump(reporter, reporter->dump_fmsg, in devlink_health_do_dump()
7725 err = devlink_fmsg_obj_nest_end(reporter->dump_fmsg); in devlink_health_do_dump()
7729 reporter->dump_ts = jiffies; in devlink_health_do_dump()
7730 reporter->dump_real_ts = ktime_get_real_ns(); in devlink_health_do_dump()
7735 devlink_health_dump_clear(reporter); in devlink_health_do_dump()
7739 int devlink_health_report(struct devlink_health_reporter *reporter, in devlink_health_report() argument
7743 struct devlink *devlink = reporter->devlink; in devlink_health_report()
7749 trace_devlink_health_report(devlink, reporter->ops->name, msg); in devlink_health_report()
7750 reporter->error_count++; in devlink_health_report()
7751 prev_health_state = reporter->health_state; in devlink_health_report()
7752 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_ERROR; in devlink_health_report()
7753 devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER); in devlink_health_report()
7756 recover_ts_threshold = reporter->last_recovery_ts + in devlink_health_report()
7757 msecs_to_jiffies(reporter->graceful_period); in devlink_health_report()
7758 if (reporter->auto_recover && in devlink_health_report()
7760 (reporter->last_recovery_ts && reporter->recovery_count && in devlink_health_report()
7763 reporter->ops->name, in devlink_health_report()
7764 reporter->health_state, in devlink_health_report()
7766 reporter->last_recovery_ts); in devlink_health_report()
7770 reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_ERROR; in devlink_health_report()
7772 if (reporter->auto_dump) { in devlink_health_report()
7773 mutex_lock(&reporter->dump_lock); in devlink_health_report()
7775 devlink_health_do_dump(reporter, priv_ctx, NULL); in devlink_health_report()
7776 mutex_unlock(&reporter->dump_lock); in devlink_health_report()
7779 if (!reporter->auto_recover) in devlink_health_report()
7783 ret = devlink_health_reporter_recover(reporter, priv_ctx, NULL); in devlink_health_report()
7794 struct devlink_health_reporter *reporter; in devlink_health_reporter_get_from_attrs() local
7805 reporter = devlink_health_reporter_find_by_name(devlink, reporter_name); in devlink_health_reporter_get_from_attrs()
7806 if (reporter) in devlink_health_reporter_get_from_attrs()
7807 refcount_inc(&reporter->refcount); in devlink_health_reporter_get_from_attrs()
7811 reporter = devlink_port_health_reporter_find_by_name(devlink_port, reporter_name); in devlink_health_reporter_get_from_attrs()
7812 if (reporter) in devlink_health_reporter_get_from_attrs()
7813 refcount_inc(&reporter->refcount); in devlink_health_reporter_get_from_attrs()
7817 return reporter; in devlink_health_reporter_get_from_attrs()
7831 struct devlink_health_reporter *reporter; in devlink_health_reporter_get_from_cb() local
7839 reporter = devlink_health_reporter_get_from_attrs(devlink, attrs); in devlink_health_reporter_get_from_cb()
7841 return reporter; in devlink_health_reporter_get_from_cb()
7845 devlink_health_reporter_state_update(struct devlink_health_reporter *reporter, in devlink_health_reporter_state_update() argument
7852 if (reporter->health_state == state) in devlink_health_reporter_state_update()
7855 reporter->health_state = state; in devlink_health_reporter_state_update()
7856 trace_devlink_health_reporter_state_update(reporter->devlink, in devlink_health_reporter_state_update()
7857 reporter->ops->name, state); in devlink_health_reporter_state_update()
7858 devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER); in devlink_health_reporter_state_update()
7866 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_get_doit() local
7870 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_get_doit()
7871 if (!reporter) in devlink_nl_cmd_health_reporter_get_doit()
7880 err = devlink_nl_health_reporter_fill(msg, reporter, in devlink_nl_cmd_health_reporter_get_doit()
7891 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_get_doit()
7899 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_get_dumpit() local
7909 list_for_each_entry(reporter, &devlink->reporter_list, in devlink_nl_cmd_health_reporter_get_dumpit()
7916 msg, reporter, DEVLINK_CMD_HEALTH_REPORTER_GET, in devlink_nl_cmd_health_reporter_get_dumpit()
7934 list_for_each_entry(reporter, &port->reporter_list, list) { in devlink_nl_cmd_health_reporter_get_dumpit()
7940 msg, reporter, in devlink_nl_cmd_health_reporter_get_dumpit()
7967 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_set_doit() local
7970 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_set_doit()
7971 if (!reporter) in devlink_nl_cmd_health_reporter_set_doit()
7974 if (!reporter->ops->recover && in devlink_nl_cmd_health_reporter_set_doit()
7980 if (!reporter->ops->dump && in devlink_nl_cmd_health_reporter_set_doit()
7987 reporter->graceful_period = in devlink_nl_cmd_health_reporter_set_doit()
7991 reporter->auto_recover = in devlink_nl_cmd_health_reporter_set_doit()
7995 reporter->auto_dump = in devlink_nl_cmd_health_reporter_set_doit()
7998 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_set_doit()
8001 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_set_doit()
8009 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_recover_doit() local
8012 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_recover_doit()
8013 if (!reporter) in devlink_nl_cmd_health_reporter_recover_doit()
8016 err = devlink_health_reporter_recover(reporter, NULL, info->extack); in devlink_nl_cmd_health_reporter_recover_doit()
8018 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_recover_doit()
8026 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_diagnose_doit() local
8030 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_diagnose_doit()
8031 if (!reporter) in devlink_nl_cmd_health_reporter_diagnose_doit()
8034 if (!reporter->ops->diagnose) { in devlink_nl_cmd_health_reporter_diagnose_doit()
8035 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
8041 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
8049 err = reporter->ops->diagnose(reporter, fmsg, info->extack); in devlink_nl_cmd_health_reporter_diagnose_doit()
8062 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_diagnose_doit()
8070 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_dump_get_dumpit() local
8074 reporter = devlink_health_reporter_get_from_cb(cb); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8075 if (!reporter) in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8078 if (!reporter->ops->dump) { in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8082 mutex_lock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8084 err = devlink_health_do_dump(reporter, NULL, cb->extack); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8087 cb->args[1] = reporter->dump_ts; in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8089 if (!reporter->dump_fmsg || cb->args[1] != reporter->dump_ts) { in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8095 err = devlink_fmsg_dumpit(reporter->dump_fmsg, skb, cb, in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8098 mutex_unlock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8100 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_get_dumpit()
8109 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_dump_clear_doit() local
8111 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_dump_clear_doit()
8112 if (!reporter) in devlink_nl_cmd_health_reporter_dump_clear_doit()
8115 if (!reporter->ops->dump) { in devlink_nl_cmd_health_reporter_dump_clear_doit()
8116 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
8120 mutex_lock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_clear_doit()
8121 devlink_health_dump_clear(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
8122 mutex_unlock(&reporter->dump_lock); in devlink_nl_cmd_health_reporter_dump_clear_doit()
8123 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_dump_clear_doit()
8131 struct devlink_health_reporter *reporter; in devlink_nl_cmd_health_reporter_test_doit() local
8134 reporter = devlink_health_reporter_get_from_info(devlink, info); in devlink_nl_cmd_health_reporter_test_doit()
8135 if (!reporter) in devlink_nl_cmd_health_reporter_test_doit()
8138 if (!reporter->ops->test) { in devlink_nl_cmd_health_reporter_test_doit()
8139 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_test_doit()
8143 err = reporter->ops->test(reporter, info->extack); in devlink_nl_cmd_health_reporter_test_doit()
8145 devlink_health_reporter_put(reporter); in devlink_nl_cmd_health_reporter_test_doit()