1#!/usr/bin/python 2 3r""" 4Contains PLDM-related constants. 5""" 6 7PLDM_SUPPORTED_TYPES = ['base', 'platform', 'bios', 'fru', 'oem-ibm'] 8 9# PLDM types. 10PLDM_TYPE_BASE = {'VALUE': '00', 'STRING': 'base'} 11PLDM_TYPE_PLATFORM = {'VALUE': '02', 'STRING': 'platform'} 12PLDM_TYPE_BIOS = {'VALUE': '03', 'STRING': 'bios'} 13PLDM_TYPE_FRU = {'VALUE': '04', 'STRING': 'fru'} 14PLDM_TYPE_OEM = {'VALUE': '63', 'STRING': 'oem-ibm'} 15 16VERSION_BASE = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} 17VERSION_PLATFORM = {'VALUE': ['f1', 'f2', 'f0', '00'], 'STRING': '1.2.0'} 18VERSION_BIOS = {'VALUE': ['f1', 'f1', 'f1', '00'], 'STRING': '1.0.0'} 19VERSION_FRU = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} 20VERSION_OEM = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} 21 22 23PLDM_BASE_CMDS = ['2(GetTID)', '3(GetPLDMVersion)', '4(GetPLDMTypes)', '5(GetPLDMCommands)'] 24PLDM_PLATFORM_CMDS = ['57(SetStateEffecterStates)', '81(GetPDR)'] 25PLDM_BIOS_CMDS = ['1(GetBIOSTable)', '7(SetBIOSAttributeCurrentValue)', 26 '8(GetBIOSAttributeCurrentValueByHandle)', '12(GetDateTime)', 27 '13(SetDateTime)'] 28PLDM_FRU_CMDS = ['1(GetFRURecordTableMetadata)', '2(GetFRURecordTable)', '4(GetFRURecordByOption)'] 29PLDM_OEM_CMDS = ['1(GetFileTable)', '4(ReadFile)', '5(WriteFile)', '6(ReadFileInToMemory)', 30 '7(WriteFileFromMemory)', '8(ReadFileByTypeIntoMemory)', 31 '9(WriteFileByTypeFromMemory)', '10(NewFileAvailable)', 32 '11(ReadFileByType)', '12(WriteFileByType)', '13(FileAck)', 33 '240(GetAlertStatus)'] 34 35# PLDM command format. 36 37''' 38e.g. : GetPLDMVersion usage 39 40pldmtool base GetPLDMVersion -t <pldm_type> 41 42pldm supported types 43 44base->0,platform->2,bios->3,fru->4 45 46''' 47CMD_GETPLDMVERSION = 'base GetPLDMVersion -t %s' 48 49''' 50e.g. : PLDM raw command usage 51 52pldmtool raw -d 0x80 0x00 0x03 0x00 0x00 0x00 0x00 0x01 0x00 53 54pldm raw -d 0x<header> 0x<pldm_type> 0x<pldm_cmd_type> 0x<payload_data> 55''' 56 57CMD_PLDMTOOL_RAW = 'raw -d 0x80' + '0x%s' + ' ' + '0x%s' 58 59 60# PLDM command payload data. 61 62PAYLOAD_GetPLDMVersion = \ 63 ' 0x00 0x00 0x00 0x00 0x%s 0x%s' # %(TransferOperationFlag, PLDMType) 64 65 66''' 67e.g. : SetDateTime usage 68 69pldmtool bios SetDateTime -d <YYYYMMDDHHMMSS> 70 71''' 72CMD_SETDATETIME = 'bios SetDateTime -d %s' 73 74 75CMD_GETPDR = 'platform GetPDR -d %s' 76 77''' 78e.g. : SetStateEffecterStates usage 79 80pldmtool platform GetPDR -i <effter_handle> -c <count> -d <effecterID, effecterState> 81 82pldmtool platform SetStateEffecterStates -i 1 -c 1 -d 1 1 83''' 84 85CMD_SETSTATEEFFECTERSTATES = 'platform SetStateEffecterStates -i %s -c %s -d %s' 86 87# GetPDR parsed response message for record handle. 88# Dictionary value array holds the expected output for record handle 1, 2. 89# 90# Note : 91# Record handle - 0 is default & has same behaviour as record handle 1 92# Only record handle 0, 1, 2 are supported as of now. 93 94RESPONSE_DICT_GETPDR_SETSTATEEFFECTER = { 95 'responsecount': ['29', '30'], 96 'pdrheaderversion': ['1'], 97 'pdrtype': ['State Effecter PDR(11)'], 98 'recordchangenumber': ['0'], 99 'datalength': ['19', '20'], 100 'pldmterminushandle': ['0'], 101 'effecterid': ['1', '2', '3'], 102 'entitytype': ['33', '45', '31'], 103 'entityinstancenumber': ['0'], 104 'containerid': ['0'], 105 'effectersemanticid': ['0'], 106 'effecterinit': ['0'], 107 'effecterdescriptionpdr': ['false'], 108 'compositeeffectercount': ['1'], 109 'statesetid': ['Boot Progress(196)', 110 'System Power State(260)', 'Software Termination Status(129)'], 111 'possiblestatessize': ['1', '2'], 112 'possiblestates': ['6', '0', '64']} 113 114RESPONSE_DICT_GETPDR_FRURECORDSETIDENTIFIER = { 115 'responsecount': ['20'], 116 'pdrheaderversion': ['1'], 117 'pdrtype': ['FRU Record Set PDR(20)'], 118 'recordchangenumber': ['0'], 119 'datalength': ['10'], 120 'pldmterminushandle': ['0', '2'], 121 'entitytype': ['System Board', 'Chassis front panel board (control panel)', 122 'Management Controller', 'OEM', 'Power converter', 123 'System (logical)', 'System chassis (main enclosure)', 124 'Chassis front panel board (control panel)', 125 'Processor Module', 'Memory Module', 'Power Supply'], 126 'containerid': ['0', '1', '2', '3']} 127 128RESPONSE_DICT_GETPDR_PDRENTITYASSOCIATION = { 129 'pdrheaderversion': ['1'], 130 'pdrtype': ['Entity Association PDR(15)'], 131 'recordchangenumber': ['0'], 132 'containerid': ['1', '2', '3'], 133 'associationtype': ['Physical'], 134 'containerentitytype': ['System Board', 'System (logical)', 135 'System chassis (main enclosure)'] 136} 137 138RESPONSE_DICT_GETPDR_STATESENSORPDR = { 139 'entitytype': ['Communication Channel', 'Connector'], 140 'sensorinit': ['noInit'], 141 'sensorauxiliarynamespdr': ['false'], 142 'statesetid': ['Availability(2)', 'Configuration State(15)'] 143} 144 145PLDM_PDR_TYPES = { 146 'PLDM_STATE_EFFECTER_PDR': 'State Effecter PDR(11)', 147 'PLDM_PDR_FRU_RECORD_SET': 'FRU Record Set PDR(20)', 148 'PLDM_PDR_ENTITY_ASSOCIATION': 'Entity Association PDR(15)', 149 'PLDM_STATE_SENSOR_PDR': 'State Sensor PDR(4)', 150 'PLDM_NUMERIC_EFFECTER_PDR': 'Numeric Effecter PDR(9)', 151 'PLDM_TERMINUS_LOCATOR_PDR': 'Terminus Locator PDR(1)'} 152 153RESPONSE_LIST_GETBIOSTABLE_STRTABLE = [ 154 'Allowed', 'Disabled', 'Enabled', 'IPv4DHCP', 'IPv4Static', 'Not Allowed', 155 'Perm', 'Temp', 'pvm-fw-boot-side', 'pvm-inband-code-update', 'pvm-os-boot-side', 156 'pvm-pcie-error-inject', 'pvm-surveillance', 'pvm-system-name', 'vmi-hostname', 157 'vmi-if-count', 'vmi-if0-ipv4-ipaddr', 'vmi-if0-ipv4-method', 158 'vmi-if0-ipv4-prefix-length', 'vmi-if1-ipv4-ipaddr', 'vmi-if1-ipv4-method', 159 'vmi-if1-ipv4-prefix-length', 'vmi-ipv4-gateway'] 160