Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | r""" |
| 4 | Contains PLDM-related constants. |
| 5 | """ |
| 6 | |
Sridevi Ramesh | 92041a3 | 2020-04-22 02:29:31 -0500 | [diff] [blame] | 7 | PLDM_SUPPORTED_TYPES = ['base', 'platform', 'bios', 'fru', 'oem-ibm'] |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 8 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 9 | # PLDM types. |
| 10 | PLDM_TYPE_BASE = {'VALUE': '00', 'STRING': 'base'} |
| 11 | PLDM_TYPE_PLATFORM = {'VALUE': '02', 'STRING': 'platform'} |
| 12 | PLDM_TYPE_BIOS = {'VALUE': '03', 'STRING': 'bios'} |
| 13 | PLDM_TYPE_FRU = {'VALUE': '04', 'STRING': 'fru'} |
Sridevi Ramesh | 92041a3 | 2020-04-22 02:29:31 -0500 | [diff] [blame] | 14 | PLDM_TYPE_OEM = {'VALUE': '63', 'STRING': 'oem-ibm'} |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 15 | PLDM_SUPPORTED_TYPES = ['0(base)', '2(platform)', '3(bios)', '4(fru)', '63(oem-ibm)'] |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 16 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 17 | VERSION_BASE = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} |
Sridevi Ramesh | ec753aa | 2020-02-17 22:55:13 -0600 | [diff] [blame] | 18 | VERSION_PLATFORM = {'VALUE': ['f1', 'f2', 'f0', '00'], 'STRING': '1.2.0'} |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 19 | VERSION_BIOS = {'VALUE': ['f1', 'f1', 'f1', '00'], 'STRING': '1.0.0'} |
| 20 | VERSION_FRU = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} |
Sridevi Ramesh | 92041a3 | 2020-04-22 02:29:31 -0500 | [diff] [blame] | 21 | VERSION_OEM = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 22 | |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 23 | |
Sridevi Ramesh | 039bc76 | 2020-03-30 09:59:07 -0500 | [diff] [blame] | 24 | PLDM_BASE_CMDS = ['2(GetTID)', '3(GetPLDMVersion)', '4(GetPLDMTypes)', '5(GetPLDMCommands)'] |
| 25 | PLDM_PLATFORM_CMDS = ['57(SetStateEffecterStates)', '81(GetPDR)'] |
| 26 | PLDM_BIOS_CMDS = ['1(GetBIOSTable)', '7(SetBIOSAttributeCurrentValue)', |
| 27 | '8(GetBIOSAttributeCurrentValueByHandle)', '12(GetDateTime)', |
| 28 | '13(SetDateTime)'] |
Sridevi Ramesh | 3ca4f64 | 2020-07-14 01:15:30 -0500 | [diff] [blame] | 29 | PLDM_FRU_CMDS = ['1(GetFRURecordTableMetadata)', '2(GetFRURecordTable)', '4(GetFRURecordByOption)'] |
Sridevi Ramesh | 92041a3 | 2020-04-22 02:29:31 -0500 | [diff] [blame] | 30 | PLDM_OEM_CMDS = ['1(GetFileTable)', '4(ReadFile)', '5(WriteFile)', '6(ReadFileInToMemory)', |
| 31 | '7(WriteFileFromMemory)', '8(ReadFileByTypeIntoMemory)', |
| 32 | '9(WriteFileByTypeFromMemory)', '10(NewFileAvailable)', |
| 33 | '11(ReadFileByType)', '12(WriteFileByType)', '13(FileAck)', |
| 34 | '240(GetAlertStatus)'] |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 35 | |
| 36 | # PLDM command format. |
| 37 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 38 | ''' |
| 39 | e.g. : GetPLDMVersion usage |
| 40 | |
| 41 | pldmtool base GetPLDMVersion -t <pldm_type> |
| 42 | |
| 43 | pldm supported types |
| 44 | |
| 45 | base->0,platform->2,bios->3,fru->4 |
| 46 | |
| 47 | ''' |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 48 | CMD_GETPLDMVERSION = 'base GetPLDMVersion -t %s' |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 49 | |
| 50 | ''' |
| 51 | e.g. : PLDM raw command usage |
| 52 | |
| 53 | pldmtool raw -d 0x80 0x00 0x03 0x00 0x00 0x00 0x00 0x01 0x00 |
| 54 | |
| 55 | pldm raw -d 0x<header> 0x<pldm_type> 0x<pldm_cmd_type> 0x<payload_data> |
| 56 | ''' |
| 57 | |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 58 | CMD_PLDMTOOL_RAW = 'raw -d 0x80' + '0x%s' + ' ' + '0x%s' |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 59 | |
| 60 | |
| 61 | # PLDM command payload data. |
| 62 | |
| 63 | PAYLOAD_GetPLDMVersion = \ |
| 64 | ' 0x00 0x00 0x00 0x00 0x%s 0x%s' # %(TransferOperationFlag, PLDMType) |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 65 | |
| 66 | |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 67 | ''' |
| 68 | e.g. : SetDateTime usage |
| 69 | |
| 70 | pldmtool bios SetDateTime -d <YYYYMMDDHHMMSS> |
| 71 | |
| 72 | ''' |
| 73 | CMD_SETDATETIME = 'bios SetDateTime -d %s' |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 74 | |
| 75 | |
| 76 | CMD_GETPDR = 'platform GetPDR -d %s' |
| 77 | |
| 78 | ''' |
| 79 | e.g. : SetStateEffecterStates usage |
| 80 | |
Sridevi Ramesh | ca3223a | 2020-03-11 03:58:58 -0500 | [diff] [blame] | 81 | pldmtool platform GetPDR -i <effter_handle> -c <count> -d <effecterID, effecterState> |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 82 | |
Sridevi Ramesh | ca3223a | 2020-03-11 03:58:58 -0500 | [diff] [blame] | 83 | pldmtool platform SetStateEffecterStates -i 1 -c 1 -d 1 1 |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 84 | ''' |
| 85 | |
Sridevi Ramesh | ca3223a | 2020-03-11 03:58:58 -0500 | [diff] [blame] | 86 | CMD_SETSTATEEFFECTERSTATES = 'platform SetStateEffecterStates -i %s -c %s -d %s' |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 87 | |
| 88 | # GetPDR parsed response message for record handle. |
| 89 | # Dictionary value array holds the expected output for record handle 1, 2. |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 90 | # |
| 91 | # Note : |
| 92 | # Record handle - 0 is default & has same behaviour as record handle 1 |
| 93 | # Only record handle 0, 1, 2 are supported as of now. |
| 94 | |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 95 | RESPONSE_DICT_GETPDR_SETSTATEEFFECTER = { |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 96 | 'PDRHeaderVersion': [1], |
| 97 | 'PDRType': ['State Effecter PDR'], |
| 98 | 'recordChangeNumber': [0], |
| 99 | 'PLDMTerminusHandle': [0, 1, 2], |
Sridevi Ramesh | 88fc1ae | 2021-04-21 05:36:52 -0500 | [diff] [blame] | 100 | 'effecterID': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 101 | 'entityType': ['Virtual Machine Manager', 'System chassis (main enclosure)', |
Sridevi Ramesh | 88fc1ae | 2021-04-21 05:36:52 -0500 | [diff] [blame] | 102 | 'System Firmware', 'Processor Module', '32801(OEM)', |
| 103 | 'Management Controller', '24577(OEM)'], |
| 104 | 'entityInstanceNumber': [0, 1, 2, 3, 4], |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 105 | 'containerID': [0, 1], |
| 106 | 'effecterSemanticID': [0], |
| 107 | 'effecterInit': ['noInit'], |
| 108 | 'effecterDescriptionPDR': [False], |
Sridevi Ramesh | 297d41b | 2021-02-02 09:16:55 -0600 | [diff] [blame] | 109 | 'compositeEffecterCount': [1]} |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 110 | |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 111 | RESPONSE_DICT_GETPDR_FRURECORDSETIDENTIFIER = { |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 112 | 'PDRHeaderVersion': [1], |
| 113 | 'PDRType': ['FRU Record Set PDR'], |
| 114 | 'recordChangeNumber': [0], |
| 115 | 'dataLength': [10], |
| 116 | 'PLDMTerminusHandle': [0, 2], |
| 117 | 'entityType': ['System Board', 'Chassis front panel board (control panel)', |
Sridevi Ramesh | 072d5af | 2020-06-02 09:20:57 -0500 | [diff] [blame] | 118 | 'Management Controller', 'OEM', 'Power converter', |
Sridevi Ramesh | 88f2172 | 2020-04-16 05:54:02 -0500 | [diff] [blame] | 119 | 'System (logical)', 'System chassis (main enclosure)', |
Sridevi Ramesh | de91ec2 | 2020-05-14 05:02:03 -0500 | [diff] [blame] | 120 | 'Chassis front panel board (control panel)', |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 121 | 'Processor Module', 'Memory Module', 'Power Supply', |
Sridevi Ramesh | 420a3e2 | 2021-01-13 00:12:18 -0600 | [diff] [blame] | 122 | '24576(OEM)', '60(OEM)', 'Processor', '142(OEM)'], |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 123 | 'containerID': [0, 1, 2, 3]} |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 124 | |
| 125 | RESPONSE_DICT_GETPDR_PDRENTITYASSOCIATION = { |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 126 | 'PDRHeaderVersion': [1], |
| 127 | 'PDRType': ['Entity Association PDR'], |
| 128 | 'recordChangeNumber': [0], |
| 129 | 'containerID': [1, 2, 3], |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 130 | 'associationtype': ['Physical'], |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 131 | 'containerentityType': ['System Board', 'System (logical)', |
| 132 | 'System chassis (main enclosure)']} |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 133 | |
Sridevi Ramesh | dfc7fcb | 2020-07-23 03:03:57 -0500 | [diff] [blame] | 134 | RESPONSE_DICT_GETPDR_STATESENSORPDR = { |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 135 | 'entityType': ['Communication Channel', 'Connector', 'Processor Module', |
Sridevi Ramesh | 88fc1ae | 2021-04-21 05:36:52 -0500 | [diff] [blame] | 136 | '32774(OEM)', '57346(OEM)', '57347(OEM)', '32801(OEM)', |
| 137 | '91(OEM)', '5(OEM)', '24577(OEM)'], |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 138 | 'sensorInit': ['noInit'], |
Sridevi Ramesh | 297d41b | 2021-02-02 09:16:55 -0600 | [diff] [blame] | 139 | 'sensorAuxiliaryNamesPDR': [False]} |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 140 | |
| 141 | RESPONSE_DICT_GETPDR_TERMINUSLOCATORPDR = { |
| 142 | 'PDRHeaderVersion': [1], |
| 143 | 'PDRType': ['Terminus Locator PDR'], |
| 144 | 'recordChangeNumber': [0], |
| 145 | 'PLDMTerminusHandle': [1], |
| 146 | 'validity': ['valid'], |
| 147 | 'TID': [1, 208], |
| 148 | 'containerID': [0, 1], |
| 149 | 'terminusLocatorType': ['MCTP_EID'], |
| 150 | 'terminusLocatorValueSize': [1]} |
| 151 | |
| 152 | RESPONSE_DICT_GETPDR_NUMERICEFFECTERPDR = { |
| 153 | 'PDRHeaderVersion': [1], |
| 154 | 'PDRType': ['Numeric Effecter PDR'], |
| 155 | 'recordChangeNumber': [0], |
| 156 | 'PLDMTerminusHandle': [0, 1], |
| 157 | 'entityInstanceNumber': [0, 1], |
| 158 | 'containerID': [0], |
| 159 | 'effecterSemanticID': [0], |
| 160 | 'effecterInit': [0], |
| 161 | 'effecterAuxiliaryNames': [False], |
Sridevi Ramesh | 88fc1ae | 2021-04-21 05:36:52 -0500 | [diff] [blame] | 162 | 'baseUnit': [0, 72, 21], |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 163 | 'unitModifier': [0], |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 164 | 'baseOEMUnitHandle': [0], |
| 165 | 'auxUnit': [0], |
| 166 | 'auxUnitModifier': [0], |
| 167 | 'auxrateUnit': [0], |
| 168 | 'auxOEMUnitHandle': [0], |
| 169 | 'resolution': [1, 0], |
| 170 | 'offset': [0], |
| 171 | 'accuracy': [0], |
| 172 | 'plusTolerance': [0], |
| 173 | 'minusTolerance': [0], |
| 174 | 'stateTransitionInterval': [0], |
| 175 | 'TransitionInterval': [0], |
| 176 | 'minSettable': [0], |
| 177 | 'rangeFieldSupport': [0], |
| 178 | 'nominalValue': [0], |
| 179 | 'normalMax': [0], |
| 180 | 'normalMin': [0], |
| 181 | 'ratedMax': [0], |
| 182 | 'ratedMin': [0]} |
Sridevi Ramesh | dfc7fcb | 2020-07-23 03:03:57 -0500 | [diff] [blame] | 183 | |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 184 | PLDM_PDR_TYPES = { |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 185 | 'PLDM_STATE_EFFECTER_PDR': 'State Effecter PDR', |
| 186 | 'PLDM_PDR_FRU_RECORD_SET': 'FRU Record Set PDR', |
| 187 | 'PLDM_PDR_ENTITY_ASSOCIATION': 'Entity Association PDR', |
| 188 | 'PLDM_STATE_SENSOR_PDR': 'State Sensor PDR', |
| 189 | 'PLDM_NUMERIC_EFFECTER_PDR': 'Numeric Effecter PDR', |
| 190 | 'PLDM_TERMINUS_LOCATOR_PDR': 'Terminus Locator PDR', |
| 191 | 'PLDM_COMPACT_NUMERIC_SENSOR_PDR': '21'} |
Sridevi Ramesh | f60581b | 2020-04-07 05:11:12 -0500 | [diff] [blame] | 192 | |
| 193 | RESPONSE_LIST_GETBIOSTABLE_STRTABLE = [ |
| 194 | 'Allowed', 'Disabled', 'Enabled', 'IPv4DHCP', 'IPv4Static', 'Not Allowed', |
Sridevi Ramesh | 297d41b | 2021-02-02 09:16:55 -0600 | [diff] [blame] | 195 | 'Perm', 'Temp', 'pvm_fw_boot_side', 'pvm_inband_code_update', 'pvm_os_boot_side', |
| 196 | 'pvm_pcie_error_inject', 'pvm_surveillance', 'pvm_system_name', 'vmi_hostname', |
| 197 | 'vmi_if_count', 'vmi_if0_ipv4_ipaddr', 'vmi_if0_ipv4_method', |
| 198 | 'vmi_if0_ipv4_prefix_length', 'vmi_if1_ipv4_ipaddr', 'vmi_if1_ipv4_method', |
| 199 | 'vmi_if1_ipv4_prefix_length'] |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 200 | |
| 201 | |
| 202 | RESPONSE_LIST_GETBIOSTABLE_ATTRTABLE = [ |
Sridevi Ramesh | 297d41b | 2021-02-02 09:16:55 -0600 | [diff] [blame] | 203 | 'pvm_fw_boot_side', 'pvm_inband_code_update', 'pvm_os_boot_side', |
| 204 | 'pvm_pcie_error_inject', 'pvm_surveillance', 'pvm_system_name', 'vmi_hostname', |
| 205 | 'vmi_if_count', 'vmi_if0_ipv4_ipaddr', 'vmi_if0_ipv4_method', |
| 206 | 'vmi_if0_ipv4_prefix_length', 'vmi_if1_ipv4_ipaddr', 'vmi_if1_ipv4_method', |
| 207 | 'vmi_if1_ipv4_prefix_length'] |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 208 | |
| 209 | RESPONSE_LIST_GETBIOSTABLE_ATTRVALTABLE = [ |
| 210 | 'BIOSString', 'BIOSInteger', 'BIOSEnumeration'] |