drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c- Extension
.c- Size
- 21834 bytes
- Lines
- 783
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/types.hlinux/device.hlinux/sysfs.hlinux/thermal.hlinux/err.hlinux/sfp.hcore.hcore_env.h
Detected Declarations
struct mlxsw_cooling_statesstruct mlxsw_thermalstruct mlxsw_thermal_cooling_devicestruct mlxsw_thermal_modulestruct mlxsw_thermal_areastruct mlxsw_thermalfunction mlxsw_state_to_dutyfunction mlxsw_duty_to_statefunction mlxsw_get_cooling_device_idxfunction mlxsw_thermal_should_bindfunction mlxsw_thermal_get_tempfunction mlxsw_thermal_module_should_bindfunction mlxsw_thermal_module_temp_getfunction mlxsw_thermal_gearbox_temp_getfunction mlxsw_thermal_get_max_statefunction mlxsw_thermal_get_cur_statefunction mlxsw_thermal_set_cur_statefunction mlxsw_thermal_module_tz_initfunction mlxsw_thermal_module_tz_finifunction mlxsw_thermal_module_initfunction mlxsw_thermal_module_finifunction mlxsw_thermal_modules_initfunction mlxsw_thermal_modules_finifunction mlxsw_thermal_gearbox_tz_initfunction mlxsw_thermal_gearbox_tz_finifunction mlxsw_thermal_gearboxes_initfunction mlxsw_thermal_gearboxes_finifunction mlxsw_thermal_got_activefunction mlxsw_thermal_got_inactivefunction mlxsw_thermal_initfunction mlxsw_thermal_fini
Annotated Snippet
struct mlxsw_cooling_states {
int min_state;
int max_state;
};
static const struct thermal_trip default_thermal_trips[] = {
{ /* In range - 0-40% PWM */
.type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_ASIC_TEMP_NORM,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
{
/* In range - 40-100% PWM */
.type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_ASIC_TEMP_HIGH,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
{ /* Warning */
.type = THERMAL_TRIP_HOT,
.temperature = MLXSW_THERMAL_ASIC_TEMP_HOT,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
};
static const struct thermal_trip default_thermal_module_trips[] = {
{ /* In range - 0-40% PWM */
.type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_MODULE_TEMP_NORM,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
{
/* In range - 40-100% PWM */
.type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_MODULE_TEMP_HIGH,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
{ /* Warning */
.type = THERMAL_TRIP_HOT,
.temperature = MLXSW_THERMAL_MODULE_TEMP_HOT,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
};
static const struct mlxsw_cooling_states default_cooling_states[] = {
{
.min_state = 0,
.max_state = (4 * MLXSW_THERMAL_MAX_STATE) / 10,
},
{
.min_state = (4 * MLXSW_THERMAL_MAX_STATE) / 10,
.max_state = MLXSW_THERMAL_MAX_STATE,
},
{
.min_state = MLXSW_THERMAL_MAX_STATE,
.max_state = MLXSW_THERMAL_MAX_STATE,
},
};
#define MLXSW_THERMAL_NUM_TRIPS ARRAY_SIZE(default_thermal_trips)
struct mlxsw_thermal;
struct mlxsw_thermal_cooling_device {
struct mlxsw_thermal *thermal;
struct thermal_cooling_device *cdev;
unsigned int idx;
};
struct mlxsw_thermal_module {
struct mlxsw_thermal *parent;
struct thermal_zone_device *tzdev;
struct thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
struct mlxsw_cooling_states cooling_states[MLXSW_THERMAL_NUM_TRIPS];
int module; /* Module or gearbox number */
u8 slot_index;
};
struct mlxsw_thermal_area {
struct mlxsw_thermal_module *tz_module_arr;
u8 tz_module_num;
struct mlxsw_thermal_module *tz_gearbox_arr;
u8 tz_gearbox_num;
u8 slot_index;
bool active;
};
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/device.h`, `linux/sysfs.h`, `linux/thermal.h`, `linux/err.h`, `linux/sfp.h`, `core.h`.
- Detected declarations: `struct mlxsw_cooling_states`, `struct mlxsw_thermal`, `struct mlxsw_thermal_cooling_device`, `struct mlxsw_thermal_module`, `struct mlxsw_thermal_area`, `struct mlxsw_thermal`, `function mlxsw_state_to_duty`, `function mlxsw_duty_to_state`, `function mlxsw_get_cooling_device_idx`, `function mlxsw_thermal_should_bind`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.