/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */12#ifndef _UAPI_ASM_X86_AMD_HSMP_H_3#define _UAPI_ASM_X86_AMD_HSMP_H_45#include <linux/types.h>67#pragma pack(4)89#define HSMP_MAX_MSG_LEN 81011/*12* HSMP Messages supported13*/14enum hsmp_message_ids {15HSMP_TEST = 1, /* 01h Increments input value by 1 */16HSMP_GET_SMU_VER, /* 02h SMU FW version */17HSMP_GET_PROTO_VER, /* 03h HSMP interface version */18HSMP_GET_SOCKET_POWER, /* 04h average package power consumption */19HSMP_SET_SOCKET_POWER_LIMIT, /* 05h Set the socket power limit */20HSMP_GET_SOCKET_POWER_LIMIT, /* 06h Get current socket power limit */21HSMP_GET_SOCKET_POWER_LIMIT_MAX,/* 07h Get maximum socket power value */22HSMP_SET_BOOST_LIMIT, /* 08h Set a core maximum frequency limit */23HSMP_SET_BOOST_LIMIT_SOCKET, /* 09h Set socket maximum frequency level */24HSMP_GET_BOOST_LIMIT, /* 0Ah Get current frequency limit */25HSMP_GET_PROC_HOT, /* 0Bh Get PROCHOT status */26HSMP_SET_XGMI_LINK_WIDTH, /* 0Ch Set max and min width of xGMI Link */27HSMP_SET_DF_PSTATE, /* 0Dh Alter APEnable/Disable messages behavior */28HSMP_SET_AUTO_DF_PSTATE, /* 0Eh Enable DF P-State Performance Boost algorithm */29HSMP_GET_FCLK_MCLK, /* 0Fh Get FCLK and MEMCLK for current socket */30HSMP_GET_CCLK_THROTTLE_LIMIT, /* 10h Get CCLK frequency limit in socket */31HSMP_GET_C0_PERCENT, /* 11h Get average C0 residency in socket */32HSMP_SET_NBIO_DPM_LEVEL, /* 12h Set max/min LCLK DPM Level for a given NBIO */33HSMP_GET_NBIO_DPM_LEVEL, /* 13h Get LCLK DPM level min and max for a given NBIO */34HSMP_GET_DDR_BANDWIDTH, /* 14h Get theoretical maximum and current DDR Bandwidth */35HSMP_GET_TEMP_MONITOR, /* 15h Get socket temperature */36HSMP_GET_DIMM_TEMP_RANGE, /* 16h Get per-DIMM temperature range and refresh rate */37HSMP_GET_DIMM_POWER, /* 17h Get per-DIMM power consumption */38HSMP_GET_DIMM_THERMAL, /* 18h Get per-DIMM thermal sensors */39HSMP_GET_SOCKET_FREQ_LIMIT, /* 19h Get current active frequency per socket */40HSMP_GET_CCLK_CORE_LIMIT, /* 1Ah Get CCLK frequency limit per core */41HSMP_GET_RAILS_SVI, /* 1Bh Get SVI-based Telemetry for all rails */42HSMP_GET_SOCKET_FMAX_FMIN, /* 1Ch Get Fmax and Fmin per socket */43HSMP_GET_IOLINK_BANDWITH, /* 1Dh Get current bandwidth on IO Link */44HSMP_GET_XGMI_BANDWITH, /* 1Eh Get current bandwidth on xGMI Link */45HSMP_SET_GMI3_WIDTH, /* 1Fh Set max and min GMI3 Link width */46HSMP_SET_PCI_RATE, /* 20h Control link rate on PCIe devices */47HSMP_SET_POWER_MODE, /* 21h Select power efficiency profile policy */48HSMP_SET_PSTATE_MAX_MIN, /* 22h Set the max and min DF P-State */49HSMP_GET_METRIC_TABLE_VER, /* 23h Get metrics table version */50HSMP_GET_METRIC_TABLE, /* 24h Get metrics table */51HSMP_GET_METRIC_TABLE_DRAM_ADDR,/* 25h Get metrics table dram address */52HSMP_SET_XGMI_PSTATE_RANGE, /* 26h Set xGMI P-state range */53HSMP_CPU_RAIL_ISO_FREQ_POLICY, /* 27h Get/Set Cpu Iso frequency policy */54HSMP_DFC_ENABLE_CTRL, /* 28h Enable/Disable DF C-state */55HSMP_GET_RAPL_UNITS = 0x30, /* 30h Get scaling factor for energy */56HSMP_GET_RAPL_CORE_COUNTER, /* 31h Get core energy counter value */57HSMP_GET_RAPL_PACKAGE_COUNTER, /* 32h Get package energy counter value */58HSMP_MSG_ID_MAX,59};6061struct hsmp_message {62__u32 msg_id; /* Message ID */63__u16 num_args; /* Number of input argument words in message */64__u16 response_sz; /* Number of expected output/response words */65__u32 args[HSMP_MAX_MSG_LEN]; /* argument/response buffer */66__u16 sock_ind; /* socket number */67};6869enum hsmp_msg_type {70HSMP_RSVD = -1,71HSMP_SET = 0,72HSMP_GET = 1,73HSMP_SET_GET = 2,74};7576enum hsmp_proto_versions {77HSMP_PROTO_VER2 = 2,78HSMP_PROTO_VER3,79HSMP_PROTO_VER4,80HSMP_PROTO_VER5,81HSMP_PROTO_VER6,82HSMP_PROTO_VER783};8485struct hsmp_msg_desc {86int num_args;87int response_sz;88enum hsmp_msg_type type;89};9091/*92* User may use these comments as reference, please find the93* supported list of messages and message definition in the94* HSMP chapter of respective family/model PPR.95*96* Not supported messages would return -ENOMSG.97*/98static const struct hsmp_msg_desc hsmp_msg_desc_table[]99__attribute__((unused)) = {100/* RESERVED */101{0, 0, HSMP_RSVD},102103/*104* HSMP_TEST, num_args = 1, response_sz = 1105* input: args[0] = xx106* output: args[0] = xx + 1107*/108{1, 1, HSMP_GET},109110/*111* HSMP_GET_SMU_VER, num_args = 0, response_sz = 1112* output: args[0] = smu fw ver113*/114{0, 1, HSMP_GET},115116/*117* HSMP_GET_PROTO_VER, num_args = 0, response_sz = 1118* output: args[0] = proto version119*/120{0, 1, HSMP_GET},121122/*123* HSMP_GET_SOCKET_POWER, num_args = 0, response_sz = 1124* output: args[0] = socket power in mWatts125*/126{0, 1, HSMP_GET},127128/*129* HSMP_SET_SOCKET_POWER_LIMIT, num_args = 1, response_sz = 0130* input: args[0] = power limit value in mWatts131*/132{1, 0, HSMP_SET},133134/*135* HSMP_GET_SOCKET_POWER_LIMIT, num_args = 0, response_sz = 1136* output: args[0] = socket power limit value in mWatts137*/138{0, 1, HSMP_GET},139140/*141* HSMP_GET_SOCKET_POWER_LIMIT_MAX, num_args = 0, response_sz = 1142* output: args[0] = maximuam socket power limit in mWatts143*/144{0, 1, HSMP_GET},145146/*147* HSMP_SET_BOOST_LIMIT, num_args = 1, response_sz = 0148* input: args[0] = apic id[31:16] + boost limit value in MHz[15:0]149*/150{1, 0, HSMP_SET},151152/*153* HSMP_SET_BOOST_LIMIT_SOCKET, num_args = 1, response_sz = 0154* input: args[0] = boost limit value in MHz155*/156{1, 0, HSMP_SET},157158/*159* HSMP_GET_BOOST_LIMIT, num_args = 1, response_sz = 1160* input: args[0] = apic id161* output: args[0] = boost limit value in MHz162*/163{1, 1, HSMP_GET},164165/*166* HSMP_GET_PROC_HOT, num_args = 0, response_sz = 1167* output: args[0] = proc hot status168*/169{0, 1, HSMP_GET},170171/*172* HSMP_SET_XGMI_LINK_WIDTH, num_args = 1, response_sz = 0173* input: args[0] = min link width[15:8] + max link width[7:0]174*/175{1, 0, HSMP_SET},176177/*178* HSMP_SET_DF_PSTATE, num_args = 1, response_sz = 0179* input: args[0] = df pstate[7:0]180*/181{1, 0, HSMP_SET},182183/* HSMP_SET_AUTO_DF_PSTATE, num_args = 0, response_sz = 0 */184{0, 0, HSMP_SET},185186/*187* HSMP_GET_FCLK_MCLK, num_args = 0, response_sz = 2188* output: args[0] = fclk in MHz, args[1] = mclk in MHz189*/190{0, 2, HSMP_GET},191192/*193* HSMP_GET_CCLK_THROTTLE_LIMIT, num_args = 0, response_sz = 1194* output: args[0] = core clock in MHz195*/196{0, 1, HSMP_GET},197198/*199* HSMP_GET_C0_PERCENT, num_args = 0, response_sz = 1200* output: args[0] = average c0 residency201*/202{0, 1, HSMP_GET},203204/*205* HSMP_SET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 0206* input: args[0] = nbioid[23:16] + max dpm level[15:8] + min dpm level[7:0]207*/208{1, 0, HSMP_SET},209210/*211* HSMP_GET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 1212* input: args[0] = nbioid[23:16]213* output: args[0] = max dpm level[15:8] + min dpm level[7:0]214*/215{1, 1, HSMP_GET},216217/*218* HSMP_GET_DDR_BANDWIDTH, num_args = 0, response_sz = 1219* output: args[0] = max bw in Gbps[31:20] + utilised bw in Gbps[19:8] +220* bw in percentage[7:0]221*/222{0, 1, HSMP_GET},223224/*225* HSMP_GET_TEMP_MONITOR, num_args = 0, response_sz = 1226* output: args[0] = temperature in degree celsius. [15:8] integer part +227* [7:5] fractional part228*/229{0, 1, HSMP_GET},230231/*232* HSMP_GET_DIMM_TEMP_RANGE, num_args = 1, response_sz = 1233* input: args[0] = DIMM address[7:0]234* output: args[0] = refresh rate[3] + temperature range[2:0]235*/236{1, 1, HSMP_GET},237238/*239* HSMP_GET_DIMM_POWER, num_args = 1, response_sz = 1240* input: args[0] = DIMM address[7:0]241* output: args[0] = DIMM power in mW[31:17] + update rate in ms[16:8] +242* DIMM address[7:0]243*/244{1, 1, HSMP_GET},245246/*247* HSMP_GET_DIMM_THERMAL, num_args = 1, response_sz = 1248* input: args[0] = DIMM address[7:0]249* output: args[0] = temperature in degree celsius[31:21] + update rate in ms[16:8] +250* DIMM address[7:0]251*/252{1, 1, HSMP_GET},253254/*255* HSMP_GET_SOCKET_FREQ_LIMIT, num_args = 0, response_sz = 1256* output: args[0] = frequency in MHz[31:16] + frequency source[15:0]257*/258{0, 1, HSMP_GET},259260/*261* HSMP_GET_CCLK_CORE_LIMIT, num_args = 1, response_sz = 1262* input: args[0] = apic id [31:0]263* output: args[0] = frequency in MHz[31:0]264*/265{1, 1, HSMP_GET},266267/*268* HSMP_GET_RAILS_SVI, num_args = 0, response_sz = 1269* output: args[0] = power in mW[31:0]270*/271{0, 1, HSMP_GET},272273/*274* HSMP_GET_SOCKET_FMAX_FMIN, num_args = 0, response_sz = 1275* output: args[0] = fmax in MHz[31:16] + fmin in MHz[15:0]276*/277{0, 1, HSMP_GET},278279/*280* HSMP_GET_IOLINK_BANDWITH, num_args = 1, response_sz = 1281* input: args[0] = link id[15:8] + bw type[2:0]282* output: args[0] = io bandwidth in Mbps[31:0]283*/284{1, 1, HSMP_GET},285286/*287* HSMP_GET_XGMI_BANDWITH, num_args = 1, response_sz = 1288* input: args[0] = link id[15:8] + bw type[2:0]289* output: args[0] = xgmi bandwidth in Mbps[31:0]290*/291{1, 1, HSMP_GET},292293/*294* HSMP_SET_GMI3_WIDTH, num_args = 1, response_sz = 0295* input: args[0] = min link width[15:8] + max link width[7:0]296*/297{1, 0, HSMP_SET},298299/*300* HSMP_SET_PCI_RATE, num_args = 1, response_sz = 1301* input: args[0] = link rate control value302* output: args[0] = previous link rate control value303*/304{1, 1, HSMP_SET},305306/*307* HSMP_SET_POWER_MODE, num_args = 1, response_sz = 0308* input: args[0] = power efficiency mode[2:0]309*/310{1, 1, HSMP_SET_GET},311312/*313* HSMP_SET_PSTATE_MAX_MIN, num_args = 1, response_sz = 0314* input: args[0] = min df pstate[15:8] + max df pstate[7:0]315*/316{1, 0, HSMP_SET},317318/*319* HSMP_GET_METRIC_TABLE_VER, num_args = 0, response_sz = 1320* output: args[0] = metrics table version321*/322{0, 1, HSMP_GET},323324/*325* HSMP_GET_METRIC_TABLE, num_args = 0, response_sz = 0326*/327{0, 0, HSMP_GET},328329/*330* HSMP_GET_METRIC_TABLE_DRAM_ADDR, num_args = 0, response_sz = 2331* output: args[0] = lower 32 bits of the address332* output: args[1] = upper 32 bits of the address333*/334{0, 2, HSMP_GET},335336/*337* HSMP_SET_XGMI_PSTATE_RANGE, num_args = 1, response_sz = 0338* input: args[0] = min xGMI p-state[15:8] + max xGMI p-state[7:0]339*/340{1, 0, HSMP_SET},341342/*343* HSMP_CPU_RAIL_ISO_FREQ_POLICY, num_args = 1, response_sz = 1344* input: args[0] = set/get policy[31] +345* disable/enable independent control[0]346* output: args[0] = current policy[0]347*/348{1, 1, HSMP_SET_GET},349350/*351* HSMP_DFC_ENABLE_CTRL, num_args = 1, response_sz = 1352* input: args[0] = set/get policy[31] + enable/disable DFC[0]353* output: args[0] = current policy[0]354*/355{1, 1, HSMP_SET_GET},356357/* RESERVED(0x29-0x2f) */358{0, 0, HSMP_RSVD},359{0, 0, HSMP_RSVD},360{0, 0, HSMP_RSVD},361{0, 0, HSMP_RSVD},362{0, 0, HSMP_RSVD},363{0, 0, HSMP_RSVD},364{0, 0, HSMP_RSVD},365366/*367* HSMP_GET_RAPL_UNITS, response_sz = 1368* output: args[0] = tu value[19:16] + esu value[12:8]369*/370{0, 1, HSMP_GET},371372/*373* HSMP_GET_RAPL_CORE_COUNTER, num_args = 1, response_sz = 1374* input: args[0] = apic id[15:0]375* output: args[0] = lower 32 bits of energy376* output: args[1] = upper 32 bits of energy377*/378{1, 2, HSMP_GET},379380/*381* HSMP_GET_RAPL_PACKAGE_COUNTER, num_args = 0, response_sz = 1382* output: args[0] = lower 32 bits of energy383* output: args[1] = upper 32 bits of energy384*/385{0, 2, HSMP_GET},386387};388389/* Metrics table (supported only with proto version 6) */390struct hsmp_metric_table {391__u32 accumulation_counter;392393/* TEMPERATURE */394__u32 max_socket_temperature;395__u32 max_vr_temperature;396__u32 max_hbm_temperature;397__u64 max_socket_temperature_acc;398__u64 max_vr_temperature_acc;399__u64 max_hbm_temperature_acc;400401/* POWER */402__u32 socket_power_limit;403__u32 max_socket_power_limit;404__u32 socket_power;405406/* ENERGY */407__u64 timestamp;408__u64 socket_energy_acc;409__u64 ccd_energy_acc;410__u64 xcd_energy_acc;411__u64 aid_energy_acc;412__u64 hbm_energy_acc;413414/* FREQUENCY */415__u32 cclk_frequency_limit;416__u32 gfxclk_frequency_limit;417__u32 fclk_frequency;418__u32 uclk_frequency;419__u32 socclk_frequency[4];420__u32 vclk_frequency[4];421__u32 dclk_frequency[4];422__u32 lclk_frequency[4];423__u64 gfxclk_frequency_acc[8];424__u64 cclk_frequency_acc[96];425426/* FREQUENCY RANGE */427__u32 max_cclk_frequency;428__u32 min_cclk_frequency;429__u32 max_gfxclk_frequency;430__u32 min_gfxclk_frequency;431__u32 fclk_frequency_table[4];432__u32 uclk_frequency_table[4];433__u32 socclk_frequency_table[4];434__u32 vclk_frequency_table[4];435__u32 dclk_frequency_table[4];436__u32 lclk_frequency_table[4];437__u32 max_lclk_dpm_range;438__u32 min_lclk_dpm_range;439440/* XGMI */441__u32 xgmi_width;442__u32 xgmi_bitrate;443__u64 xgmi_read_bandwidth_acc[8];444__u64 xgmi_write_bandwidth_acc[8];445446/* ACTIVITY */447__u32 socket_c0_residency;448__u32 socket_gfx_busy;449__u32 dram_bandwidth_utilization;450__u64 socket_c0_residency_acc;451__u64 socket_gfx_busy_acc;452__u64 dram_bandwidth_acc;453__u32 max_dram_bandwidth;454__u64 dram_bandwidth_utilization_acc;455__u64 pcie_bandwidth_acc[4];456457/* THROTTLERS */458__u32 prochot_residency_acc;459__u32 ppt_residency_acc;460__u32 socket_thm_residency_acc;461__u32 vr_thm_residency_acc;462__u32 hbm_thm_residency_acc;463__u32 spare;464465/* New items at the end to maintain driver compatibility */466__u32 gfxclk_frequency[8];467};468469/* Reset to default packing */470#pragma pack()471472/* Define unique ioctl command for hsmp msgs using generic _IOWR */473#define HSMP_BASE_IOCTL_NR 0xF8474#define HSMP_IOCTL_CMD _IOWR(HSMP_BASE_IOCTL_NR, 0, struct hsmp_message)475476#endif /*_ASM_X86_AMD_HSMP_H_*/477478479