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