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 | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 15 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 16 | VERSION_BASE = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} |
Sridevi Ramesh | ec753aa | 2020-02-17 22:55:13 -0600 | [diff] [blame] | 17 | VERSION_PLATFORM = {'VALUE': ['f1', 'f2', 'f0', '00'], 'STRING': '1.2.0'} |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 18 | VERSION_BIOS = {'VALUE': ['f1', 'f1', 'f1', '00'], 'STRING': '1.0.0'} |
| 19 | VERSION_FRU = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} |
Sridevi Ramesh | 92041a3 | 2020-04-22 02:29:31 -0500 | [diff] [blame] | 20 | VERSION_OEM = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 21 | |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 22 | |
Sridevi Ramesh | 039bc76 | 2020-03-30 09:59:07 -0500 | [diff] [blame] | 23 | PLDM_BASE_CMDS = ['2(GetTID)', '3(GetPLDMVersion)', '4(GetPLDMTypes)', '5(GetPLDMCommands)'] |
| 24 | PLDM_PLATFORM_CMDS = ['57(SetStateEffecterStates)', '81(GetPDR)'] |
| 25 | PLDM_BIOS_CMDS = ['1(GetBIOSTable)', '7(SetBIOSAttributeCurrentValue)', |
| 26 | '8(GetBIOSAttributeCurrentValueByHandle)', '12(GetDateTime)', |
| 27 | '13(SetDateTime)'] |
Sridevi Ramesh | 3ca4f64 | 2020-07-14 01:15:30 -0500 | [diff] [blame^] | 28 | PLDM_FRU_CMDS = ['1(GetFRURecordTableMetadata)', '2(GetFRURecordTable)', '4(GetFRURecordByOption)'] |
Sridevi Ramesh | 92041a3 | 2020-04-22 02:29:31 -0500 | [diff] [blame] | 29 | PLDM_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)'] |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 34 | |
| 35 | # PLDM command format. |
| 36 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 37 | ''' |
| 38 | e.g. : GetPLDMVersion usage |
| 39 | |
| 40 | pldmtool base GetPLDMVersion -t <pldm_type> |
| 41 | |
| 42 | pldm supported types |
| 43 | |
| 44 | base->0,platform->2,bios->3,fru->4 |
| 45 | |
| 46 | ''' |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 47 | CMD_GETPLDMVERSION = 'base GetPLDMVersion -t %s' |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 48 | |
| 49 | ''' |
| 50 | e.g. : PLDM raw command usage |
| 51 | |
| 52 | pldmtool raw -d 0x80 0x00 0x03 0x00 0x00 0x00 0x00 0x01 0x00 |
| 53 | |
| 54 | pldm raw -d 0x<header> 0x<pldm_type> 0x<pldm_cmd_type> 0x<payload_data> |
| 55 | ''' |
| 56 | |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 57 | CMD_PLDMTOOL_RAW = 'raw -d 0x80' + '0x%s' + ' ' + '0x%s' |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 58 | |
| 59 | |
| 60 | # PLDM command payload data. |
| 61 | |
| 62 | PAYLOAD_GetPLDMVersion = \ |
| 63 | ' 0x00 0x00 0x00 0x00 0x%s 0x%s' # %(TransferOperationFlag, PLDMType) |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 64 | |
| 65 | |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 66 | ''' |
| 67 | e.g. : SetDateTime usage |
| 68 | |
| 69 | pldmtool bios SetDateTime -d <YYYYMMDDHHMMSS> |
| 70 | |
| 71 | ''' |
| 72 | CMD_SETDATETIME = 'bios SetDateTime -d %s' |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 73 | |
| 74 | |
| 75 | CMD_GETPDR = 'platform GetPDR -d %s' |
| 76 | |
| 77 | ''' |
| 78 | e.g. : SetStateEffecterStates usage |
| 79 | |
Sridevi Ramesh | ca3223a | 2020-03-11 03:58:58 -0500 | [diff] [blame] | 80 | pldmtool platform GetPDR -i <effter_handle> -c <count> -d <effecterID, effecterState> |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 81 | |
Sridevi Ramesh | ca3223a | 2020-03-11 03:58:58 -0500 | [diff] [blame] | 82 | pldmtool platform SetStateEffecterStates -i 1 -c 1 -d 1 1 |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 83 | ''' |
| 84 | |
Sridevi Ramesh | ca3223a | 2020-03-11 03:58:58 -0500 | [diff] [blame] | 85 | CMD_SETSTATEEFFECTERSTATES = 'platform SetStateEffecterStates -i %s -c %s -d %s' |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 86 | |
| 87 | # GetPDR parsed response message for record handle. |
| 88 | # Dictionary value array holds the expected output for record handle 1, 2. |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 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 | |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 94 | RESPONSE_DICT_GETPDR_SETSTATEEFFECTER = { |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 95 | 'responsecount': ['29', '30'], |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 96 | 'pdrheaderversion': ['1'], |
| 97 | 'pdrtype': ['11'], |
| 98 | 'recordchangenumber': ['0'], |
| 99 | 'datalength': ['19', '20'], |
| 100 | 'pldmterminushandle': ['0'], |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 101 | 'effecterid': ['1', '2', '3'], |
| 102 | 'entitytype': ['33', '45', '31'], |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 103 | 'entityinstancenumber': ['0'], |
| 104 | 'containerid': ['0'], |
| 105 | 'effectersemanticid': ['0'], |
| 106 | 'effecterinit': ['0'], |
| 107 | 'effecterdescriptionpdr': ['false'], |
| 108 | 'compositeeffectercount': ['1'], |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 109 | 'statesetid': ['196', '260', '129'], |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 110 | 'possiblestatessize': ['1', '2'], |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 111 | 'possiblestates': ['6', '0', '64']} |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 112 | |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 113 | RESPONSE_DICT_GETPDR_FRURECORDSETIDENTIFIER = { |
| 114 | 'responsecount': ['20'], |
| 115 | 'pdrheaderversion': ['1'], |
| 116 | 'pdrtype': ['20'], |
| 117 | 'recordchangenumber': ['0'], |
| 118 | 'datalength': ['10'], |
Sridevi Ramesh | de91ec2 | 2020-05-14 05:02:03 -0500 | [diff] [blame] | 119 | 'pldmterminushandle': ['0', '2'], |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 120 | 'entitytype': ['System Board', 'Chassis front panel board (control panel)', |
Sridevi Ramesh | 072d5af | 2020-06-02 09:20:57 -0500 | [diff] [blame] | 121 | 'Management Controller', 'OEM', 'Power converter', |
Sridevi Ramesh | 88f2172 | 2020-04-16 05:54:02 -0500 | [diff] [blame] | 122 | 'System (logical)', 'System chassis (main enclosure)', |
Sridevi Ramesh | de91ec2 | 2020-05-14 05:02:03 -0500 | [diff] [blame] | 123 | 'Chassis front panel board (control panel)', |
| 124 | 'Processor Module', 'Memory Module'], |
Sridevi Ramesh | 88f2172 | 2020-04-16 05:54:02 -0500 | [diff] [blame] | 125 | 'containerid': ['0', '1', '2', '3']} |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 126 | |
| 127 | RESPONSE_DICT_GETPDR_PDRENTITYASSOCIATION = { |
| 128 | 'pdrheaderversion': ['1'], |
| 129 | 'pdrtype': ['15'], |
| 130 | 'recordchangenumber': ['0'], |
Sridevi Ramesh | 88f2172 | 2020-04-16 05:54:02 -0500 | [diff] [blame] | 131 | 'containerid': ['1', '2', '3'], |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 132 | 'associationtype': ['Physical'], |
Sridevi Ramesh | 88f2172 | 2020-04-16 05:54:02 -0500 | [diff] [blame] | 133 | 'containerentitytype': ['System Board', 'System (logical)', |
| 134 | 'System chassis (main enclosure)'] |
Sridevi Ramesh | 538d18d | 2020-03-30 11:45:42 -0500 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | PLDM_PDR_TYPES = { |
| 138 | 'PLDM_STATE_EFFECTER_PDR': '11', |
| 139 | 'PLDM_PDR_FRU_RECORD_SET': '20', |
Sridevi Ramesh | 072d5af | 2020-06-02 09:20:57 -0500 | [diff] [blame] | 140 | 'PLDM_PDR_ENTITY_ASSOCIATION': '15', |
| 141 | 'PLDM_STATE_SENSOR_PDR': '4', |
| 142 | 'PLDM_NUMERIC_EFFECTER_PDR': '9'} |
Sridevi Ramesh | f60581b | 2020-04-07 05:11:12 -0500 | [diff] [blame] | 143 | |
| 144 | RESPONSE_LIST_GETBIOSTABLE_STRTABLE = [ |
| 145 | 'Allowed', 'Disabled', 'Enabled', 'IPv4DHCP', 'IPv4Static', 'Not Allowed', |
| 146 | 'Perm', 'Temp', 'pvm-fw-boot-side', 'pvm-inband-code-update', 'pvm-os-boot-side', |
| 147 | 'pvm-pcie-error-inject', 'pvm-surveillance', 'pvm-system-name', 'vmi-hostname', |
| 148 | 'vmi-if-count', 'vmi-if0-ipv4-ipaddr', 'vmi-if0-ipv4-method', |
| 149 | 'vmi-if0-ipv4-prefix-length', 'vmi-if1-ipv4-ipaddr', 'vmi-if1-ipv4-method', |
| 150 | 'vmi-if1-ipv4-prefix-length', 'vmi-ipv4-gateway'] |