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.

Dependency Surface

Detected Declarations

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

Implementation Notes