|
26 | 26 | #include <trace/events/devlink.h> |
27 | 27 |
|
28 | 28 | #include "core.h" |
| 29 | +#include "core_env.h" |
29 | 30 | #include "item.h" |
30 | 31 | #include "cmd.h" |
31 | 32 | #include "port.h" |
@@ -87,6 +88,8 @@ struct mlxsw_core { |
87 | 88 | struct { |
88 | 89 | struct devlink_health_reporter *fw_fatal; |
89 | 90 | } health; |
| 91 | + struct mlxsw_env *env; |
| 92 | + bool is_initialized; /* Denotes if core was already initialized. */ |
90 | 93 | unsigned long driver_priv[]; |
91 | 94 | /* driver_priv has to be always the last item */ |
92 | 95 | }; |
@@ -133,6 +136,11 @@ bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core) |
133 | 136 | } |
134 | 137 | EXPORT_SYMBOL(mlxsw_core_res_query_enabled); |
135 | 138 |
|
| 139 | +bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core) |
| 140 | +{ |
| 141 | + return mlxsw_core->driver->temp_warn_enabled; |
| 142 | +} |
| 143 | + |
136 | 144 | bool |
137 | 145 | mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev, |
138 | 146 | const struct mlxsw_fw_rev *req_rev) |
@@ -1943,13 +1951,20 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, |
1943 | 1951 | if (err) |
1944 | 1952 | goto err_thermal_init; |
1945 | 1953 |
|
| 1954 | + err = mlxsw_env_init(mlxsw_core, &mlxsw_core->env); |
| 1955 | + if (err) |
| 1956 | + goto err_env_init; |
| 1957 | + |
| 1958 | + mlxsw_core->is_initialized = true; |
1946 | 1959 | devlink_params_publish(devlink); |
1947 | 1960 |
|
1948 | 1961 | if (!reload) |
1949 | 1962 | devlink_reload_enable(devlink); |
1950 | 1963 |
|
1951 | 1964 | return 0; |
1952 | 1965 |
|
| 1966 | +err_env_init: |
| 1967 | + mlxsw_thermal_fini(mlxsw_core->thermal); |
1953 | 1968 | err_thermal_init: |
1954 | 1969 | mlxsw_hwmon_fini(mlxsw_core->hwmon); |
1955 | 1970 | err_hwmon_init: |
@@ -2026,6 +2041,8 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, |
2026 | 2041 | } |
2027 | 2042 |
|
2028 | 2043 | devlink_params_unpublish(devlink); |
| 2044 | + mlxsw_core->is_initialized = false; |
| 2045 | + mlxsw_env_fini(mlxsw_core->env); |
2029 | 2046 | mlxsw_thermal_fini(mlxsw_core->thermal); |
2030 | 2047 | mlxsw_hwmon_fini(mlxsw_core->hwmon); |
2031 | 2048 | if (mlxsw_core->driver->fini) |
@@ -2829,6 +2846,16 @@ mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core, |
2829 | 2846 | } |
2830 | 2847 | EXPORT_SYMBOL(mlxsw_core_port_devlink_port_get); |
2831 | 2848 |
|
| 2849 | +struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core) |
| 2850 | +{ |
| 2851 | + return mlxsw_core->env; |
| 2852 | +} |
| 2853 | + |
| 2854 | +bool mlxsw_core_is_initialized(const struct mlxsw_core *mlxsw_core) |
| 2855 | +{ |
| 2856 | + return mlxsw_core->is_initialized; |
| 2857 | +} |
| 2858 | + |
2832 | 2859 | int mlxsw_core_module_max_width(struct mlxsw_core *mlxsw_core, u8 module) |
2833 | 2860 | { |
2834 | 2861 | enum mlxsw_reg_pmtm_module_type module_type; |
|
0 commit comments