170e14187SSridevi Ramesh#!/usr/bin/python 270e14187SSridevi Ramesh 370e14187SSridevi Rameshr""" 470e14187SSridevi RameshContains PLDM-related constants. 570e14187SSridevi Ramesh""" 670e14187SSridevi Ramesh 71495bc4fSSridevi RameshPLDM_SUPPORTED_TYPES = ['base', 'platform', 'bios'] 84d488571SRahul Maheshwari 9c4e1cbacSSridevi Ramesh# PLDM types. 10c4e1cbacSSridevi RameshPLDM_TYPE_BASE = {'VALUE': '00', 'STRING': 'base'} 11c4e1cbacSSridevi RameshPLDM_TYPE_PLATFORM = {'VALUE': '02', 'STRING': 'platform'} 12c4e1cbacSSridevi RameshPLDM_TYPE_BIOS = {'VALUE': '03', 'STRING': 'bios'} 13c4e1cbacSSridevi RameshPLDM_TYPE_FRU = {'VALUE': '04', 'STRING': 'fru'} 14c4e1cbacSSridevi RameshPLDM_TYPE_OEM = {'VALUE': '3F', 'STRING': 'oem'} 1570e14187SSridevi Ramesh 16c4e1cbacSSridevi RameshVERSION_BASE = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} 17ec753aa1SSridevi RameshVERSION_PLATFORM = {'VALUE': ['f1', 'f2', 'f0', '00'], 'STRING': '1.2.0'} 18c4e1cbacSSridevi RameshVERSION_BIOS = {'VALUE': ['f1', 'f1', 'f1', '00'], 'STRING': '1.0.0'} 19c4e1cbacSSridevi RameshVERSION_FRU = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} 2070e14187SSridevi Ramesh 21c4e1cbacSSridevi Ramesh# PLDM base related variables. 2270e14187SSridevi RameshPLDM_BASE_CMD = { 23c4e1cbacSSridevi Ramesh 'GET_TID': '02', 24c4e1cbacSSridevi Ramesh 'GET_PLDM_VERSION': '03', 25c4e1cbacSSridevi Ramesh 'GET_PLDM_TYPES': '04', 26c4e1cbacSSridevi Ramesh 'GET_PLDM_COMMANDS': '05'} 2770e14187SSridevi Ramesh 28c4e1cbacSSridevi Ramesh# Response lengths are inclusive of completion code. 29c4e1cbacSSridevi RameshGET_TID_RESP_BYTES = 2 30c4e1cbacSSridevi RameshGET_PLDM_VERSION_RESP_BYTES = 10 31c4e1cbacSSridevi RameshGET_PLDM_TYPES_RESP_BYTES = 9 32c4e1cbacSSridevi RameshGET_PLDM_COMMANDS_RESP_BYTES = 33 3370e14187SSridevi Ramesh 34c4e1cbacSSridevi Ramesh# PLDM bios related variables. 3570e14187SSridevi RameshPLDM_BIOS_CMD = { 3670e14187SSridevi Ramesh 'GET_BIOS_TABLE': '01', 3770e14187SSridevi Ramesh 'SET_BIOS_ATTRIBUTE_CURRENT_VALUE': '07', 3870e14187SSridevi Ramesh 'GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE': '08', 3970e14187SSridevi Ramesh 'GET_DATE_TIME': '0c'} 4070e14187SSridevi Ramesh 41c4e1cbacSSridevi RameshPLDM_BIOS_TABLE_TYPES = { 42c4e1cbacSSridevi Ramesh 'STRING_TABLE': '00', 43c4e1cbacSSridevi Ramesh 'ATTRIBUTE_TABLE': '01', 44c4e1cbacSSridevi Ramesh 'ATTRIBUTE_VAL_TABLE': '02'} 45c4e1cbacSSridevi Ramesh 46c4e1cbacSSridevi RameshTRANSFER_OPERATION_FLAG = { 47c4e1cbacSSridevi Ramesh 'GETNEXTPART': '00', 48c4e1cbacSSridevi Ramesh 'GETFIRSTPART': '01'} 49c4e1cbacSSridevi Ramesh 50c4e1cbacSSridevi RameshTRANSFER_RESP_FLAG = { 51c4e1cbacSSridevi Ramesh 'PLDM_START': '01', 52c4e1cbacSSridevi Ramesh 'PLDM_MIDDLE': '02', 53c4e1cbacSSridevi Ramesh 'PLDM_END': '04', 54c4e1cbacSSridevi Ramesh 'PLDM_START_AND_END': '05'} 55c4e1cbacSSridevi Ramesh 56c4e1cbacSSridevi Ramesh# PLDM platform related variables. 5770e14187SSridevi RameshPLDM_PLATFORM_CMD = { 5870e14187SSridevi Ramesh 'SET_STATE_EFFECTER_STATES': '39', 5970e14187SSridevi Ramesh 'GET_PDR': '51'} 6070e14187SSridevi Ramesh 6170e14187SSridevi RameshPLDM_PDR_TYPES = { 6270e14187SSridevi Ramesh 'STATE_EFFECTER_PDR': '11'} 6370e14187SSridevi Ramesh 6470e14187SSridevi Ramesh# PLDM OEM related variables. 6570e14187SSridevi RameshPLDM_FILEIO_CMD = { 6670e14187SSridevi Ramesh 'GET_FILE_TABLE': '1', 6770e14187SSridevi Ramesh 'READ_FILE': '4', 6870e14187SSridevi Ramesh 'WRITE_FILE': '5', 6970e14187SSridevi Ramesh 'READ_FILE_INTO_MEMORY': '6', 7070e14187SSridevi Ramesh 'WRITE_FILE_FROM_MEMORY': '7'} 7170e14187SSridevi Ramesh 7270e14187SSridevi RameshPLDM_FILEIO_COMPLETION_CODES = { 7370e14187SSridevi Ramesh 'INVALID_FILE_HANDLE': '80', 7470e14187SSridevi Ramesh 'DATA_OUT_OF_RANGE': '81', 7570e14187SSridevi Ramesh 'INVALID_READ_LENGTH': '82', 7670e14187SSridevi Ramesh 'INVALID_WRITE_LENGTH': '83', 7770e14187SSridevi Ramesh 'FILE_TABLE_UNAVAILABLE': '84', 7870e14187SSridevi Ramesh 'INVALID_FILE_TABLE_TYPE': '85'} 79c4e1cbacSSridevi Ramesh 80c4e1cbacSSridevi Ramesh# PLDM FRU related variables. 81c4e1cbacSSridevi RameshPLDM_FRU_CMD = { 82c4e1cbacSSridevi Ramesh 'PLDM_GET_FRU_RECORD_TABLE_METADATA': '01', 83c4e1cbacSSridevi Ramesh 'PLDM_GET_FRU_RECORD_TABLE': '02'} 84c4e1cbacSSridevi Ramesh 85c4e1cbacSSridevi Ramesh# PLDM command format. 86c4e1cbacSSridevi Ramesh 87c4e1cbacSSridevi Ramesh''' 88c4e1cbacSSridevi Rameshe.g. : GetPLDMVersion usage 89c4e1cbacSSridevi Ramesh 90c4e1cbacSSridevi Rameshpldmtool base GetPLDMVersion -t <pldm_type> 91c4e1cbacSSridevi Ramesh 92c4e1cbacSSridevi Rameshpldm supported types 93c4e1cbacSSridevi Ramesh 94c4e1cbacSSridevi Rameshbase->0,platform->2,bios->3,fru->4 95c4e1cbacSSridevi Ramesh 96c4e1cbacSSridevi Ramesh''' 974d488571SRahul MaheshwariCMD_GETPLDMVERSION = 'base GetPLDMVersion -t %s' 98c4e1cbacSSridevi Ramesh 99c4e1cbacSSridevi Ramesh''' 100c4e1cbacSSridevi Rameshe.g. : PLDM raw command usage 101c4e1cbacSSridevi Ramesh 102c4e1cbacSSridevi Rameshpldmtool raw -d 0x80 0x00 0x03 0x00 0x00 0x00 0x00 0x01 0x00 103c4e1cbacSSridevi Ramesh 104c4e1cbacSSridevi Rameshpldm raw -d 0x<header> 0x<pldm_type> 0x<pldm_cmd_type> 0x<payload_data> 105c4e1cbacSSridevi Ramesh''' 106c4e1cbacSSridevi Ramesh 1074d488571SRahul MaheshwariCMD_PLDMTOOL_RAW = 'raw -d 0x80' + '0x%s' + ' ' + '0x%s' 108c4e1cbacSSridevi Ramesh 109c4e1cbacSSridevi Ramesh 110c4e1cbacSSridevi Ramesh# PLDM command payload data. 111c4e1cbacSSridevi Ramesh 112c4e1cbacSSridevi RameshPAYLOAD_GetPLDMVersion = \ 113c4e1cbacSSridevi Ramesh ' 0x00 0x00 0x00 0x00 0x%s 0x%s' # %(TransferOperationFlag, PLDMType) 1144d488571SRahul Maheshwari 1154d488571SRahul Maheshwari 1161495bc4fSSridevi Ramesh''' 1171495bc4fSSridevi Rameshe.g. : SetDateTime usage 1181495bc4fSSridevi Ramesh 1191495bc4fSSridevi Rameshpldmtool bios SetDateTime -d <YYYYMMDDHHMMSS> 1201495bc4fSSridevi Ramesh 1211495bc4fSSridevi Ramesh''' 1221495bc4fSSridevi RameshCMD_SETDATETIME = 'bios SetDateTime -d %s' 123fe52e405SSridevi Ramesh 124fe52e405SSridevi Ramesh 125fe52e405SSridevi RameshCMD_GETPDR = 'platform GetPDR -d %s' 126fe52e405SSridevi Ramesh 127fe52e405SSridevi Ramesh''' 128fe52e405SSridevi Rameshe.g. : SetStateEffecterStates usage 129fe52e405SSridevi Ramesh 130*ca3223a6SSridevi Rameshpldmtool platform GetPDR -i <effter_handle> -c <count> -d <effecterID, effecterState> 131fe52e405SSridevi Ramesh 132*ca3223a6SSridevi Rameshpldmtool platform SetStateEffecterStates -i 1 -c 1 -d 1 1 133fe52e405SSridevi Ramesh''' 134fe52e405SSridevi Ramesh 135*ca3223a6SSridevi RameshCMD_SETSTATEEFFECTERSTATES = 'platform SetStateEffecterStates -i %s -c %s -d %s' 136fe52e405SSridevi Ramesh 137fe52e405SSridevi Ramesh# GetPDR parsed response message for record handle. 138fe52e405SSridevi Ramesh# Dictionary value array holds the expected output for record handle 1, 2. 139fe52e405SSridevi Ramesh# e.g. : 'nextrecordhandle': ['0', '2'] 140fe52e405SSridevi Ramesh# 141fe52e405SSridevi Ramesh# Note : 142fe52e405SSridevi Ramesh# Record handle - 0 is default & has same behaviour as record handle 1 143fe52e405SSridevi Ramesh# Only record handle 0, 1, 2 are supported as of now. 144fe52e405SSridevi Ramesh 145fe52e405SSridevi RameshRESPONSE_DICT_GETPDR = { 146fe52e405SSridevi Ramesh 'nextrecordhandle': ['0', '2'], 147fe52e405SSridevi Ramesh 'responsecount': ['29', '30'], 148fe52e405SSridevi Ramesh 'recordhandle': ['1', '2'], 149fe52e405SSridevi Ramesh 'pdrheaderversion': ['1'], 150fe52e405SSridevi Ramesh 'pdrtype': ['11'], 151fe52e405SSridevi Ramesh 'recordchangenumber': ['0'], 152fe52e405SSridevi Ramesh 'datalength': ['19', '20'], 153fe52e405SSridevi Ramesh 'pldmterminushandle': ['0'], 154fe52e405SSridevi Ramesh 'effecterid': ['1', '2'], 155fe52e405SSridevi Ramesh 'entitytype': ['33', '45'], 156fe52e405SSridevi Ramesh 'entityinstancenumber': ['0'], 157fe52e405SSridevi Ramesh 'containerid': ['0'], 158fe52e405SSridevi Ramesh 'effectersemanticid': ['0'], 159fe52e405SSridevi Ramesh 'effecterinit': ['0'], 160fe52e405SSridevi Ramesh 'effecterdescriptionpdr': ['false'], 161fe52e405SSridevi Ramesh 'compositeeffectercount': ['1'], 162fe52e405SSridevi Ramesh 'statesetid': ['196', '260'], 163fe52e405SSridevi Ramesh 'possiblestatessize': ['1', '2'], 164fe52e405SSridevi Ramesh 'possiblestates': ['6', '0']} 165fe52e405SSridevi Ramesh 166fe52e405SSridevi RameshRESPONSE_DICT_GETBIOSTABLE_STRTABLE = { 167fe52e405SSridevi Ramesh 'biosstringhandle': ['BIOSString'], 168fe52e405SSridevi Ramesh '0': ['Allowed'], 169fe52e405SSridevi Ramesh '1': ['Disabled'], 170fe52e405SSridevi Ramesh '2': ['Enabled'], 171fe52e405SSridevi Ramesh '3': ['Not Allowed'], 172fe52e405SSridevi Ramesh '4': ['Perm'], 173fe52e405SSridevi Ramesh '5': ['Temp'], 174fe52e405SSridevi Ramesh '6': ['pvm-fw-boot-side'], 175fe52e405SSridevi Ramesh '7': ['pvm-inband-code-update'], 176fe52e405SSridevi Ramesh '8': ['pvm-os-boot-side'], 177fe52e405SSridevi Ramesh '9': ['pvm-pcie-error-inject'], 178fe52e405SSridevi Ramesh '10': ['pvm-surveillance'], 179fe52e405SSridevi Ramesh '11': ['pvm-system-name'], 180fe52e405SSridevi Ramesh '12': ['vmi-if-count']} 181