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 | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 7 | PLDM_SUPPORTED_TYPES = ['base', 'platform', 'bios'] |
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'} |
| 14 | PLDM_TYPE_OEM = {'VALUE': '3F', 'STRING': 'oem'} |
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 | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 20 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 21 | # PLDM base related variables. |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 22 | PLDM_BASE_CMD = { |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 23 | 'GET_TID': '02', |
| 24 | 'GET_PLDM_VERSION': '03', |
| 25 | 'GET_PLDM_TYPES': '04', |
| 26 | 'GET_PLDM_COMMANDS': '05'} |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 27 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 28 | # Response lengths are inclusive of completion code. |
| 29 | GET_TID_RESP_BYTES = 2 |
| 30 | GET_PLDM_VERSION_RESP_BYTES = 10 |
| 31 | GET_PLDM_TYPES_RESP_BYTES = 9 |
| 32 | GET_PLDM_COMMANDS_RESP_BYTES = 33 |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 33 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 34 | # PLDM bios related variables. |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 35 | PLDM_BIOS_CMD = { |
| 36 | 'GET_BIOS_TABLE': '01', |
| 37 | 'SET_BIOS_ATTRIBUTE_CURRENT_VALUE': '07', |
| 38 | 'GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE': '08', |
| 39 | 'GET_DATE_TIME': '0c'} |
| 40 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 41 | PLDM_BIOS_TABLE_TYPES = { |
| 42 | 'STRING_TABLE': '00', |
| 43 | 'ATTRIBUTE_TABLE': '01', |
| 44 | 'ATTRIBUTE_VAL_TABLE': '02'} |
| 45 | |
| 46 | TRANSFER_OPERATION_FLAG = { |
| 47 | 'GETNEXTPART': '00', |
| 48 | 'GETFIRSTPART': '01'} |
| 49 | |
| 50 | TRANSFER_RESP_FLAG = { |
| 51 | 'PLDM_START': '01', |
| 52 | 'PLDM_MIDDLE': '02', |
| 53 | 'PLDM_END': '04', |
| 54 | 'PLDM_START_AND_END': '05'} |
| 55 | |
| 56 | # PLDM platform related variables. |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 57 | PLDM_PLATFORM_CMD = { |
| 58 | 'SET_STATE_EFFECTER_STATES': '39', |
| 59 | 'GET_PDR': '51'} |
| 60 | |
| 61 | PLDM_PDR_TYPES = { |
| 62 | 'STATE_EFFECTER_PDR': '11'} |
| 63 | |
| 64 | # PLDM OEM related variables. |
| 65 | PLDM_FILEIO_CMD = { |
| 66 | 'GET_FILE_TABLE': '1', |
| 67 | 'READ_FILE': '4', |
| 68 | 'WRITE_FILE': '5', |
| 69 | 'READ_FILE_INTO_MEMORY': '6', |
| 70 | 'WRITE_FILE_FROM_MEMORY': '7'} |
| 71 | |
| 72 | PLDM_FILEIO_COMPLETION_CODES = { |
| 73 | 'INVALID_FILE_HANDLE': '80', |
| 74 | 'DATA_OUT_OF_RANGE': '81', |
| 75 | 'INVALID_READ_LENGTH': '82', |
| 76 | 'INVALID_WRITE_LENGTH': '83', |
| 77 | 'FILE_TABLE_UNAVAILABLE': '84', |
| 78 | 'INVALID_FILE_TABLE_TYPE': '85'} |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 79 | |
| 80 | # PLDM FRU related variables. |
| 81 | PLDM_FRU_CMD = { |
| 82 | 'PLDM_GET_FRU_RECORD_TABLE_METADATA': '01', |
| 83 | 'PLDM_GET_FRU_RECORD_TABLE': '02'} |
| 84 | |
| 85 | # PLDM command format. |
| 86 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 87 | ''' |
| 88 | e.g. : GetPLDMVersion usage |
| 89 | |
| 90 | pldmtool base GetPLDMVersion -t <pldm_type> |
| 91 | |
| 92 | pldm supported types |
| 93 | |
| 94 | base->0,platform->2,bios->3,fru->4 |
| 95 | |
| 96 | ''' |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 97 | CMD_GETPLDMVERSION = 'base GetPLDMVersion -t %s' |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 98 | |
| 99 | ''' |
| 100 | e.g. : PLDM raw command usage |
| 101 | |
| 102 | pldmtool raw -d 0x80 0x00 0x03 0x00 0x00 0x00 0x00 0x01 0x00 |
| 103 | |
| 104 | pldm raw -d 0x<header> 0x<pldm_type> 0x<pldm_cmd_type> 0x<payload_data> |
| 105 | ''' |
| 106 | |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 107 | CMD_PLDMTOOL_RAW = 'raw -d 0x80' + '0x%s' + ' ' + '0x%s' |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 108 | |
| 109 | |
| 110 | # PLDM command payload data. |
| 111 | |
| 112 | PAYLOAD_GetPLDMVersion = \ |
| 113 | ' 0x00 0x00 0x00 0x00 0x%s 0x%s' # %(TransferOperationFlag, PLDMType) |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 114 | |
| 115 | |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 116 | ''' |
| 117 | e.g. : SetDateTime usage |
| 118 | |
| 119 | pldmtool bios SetDateTime -d <YYYYMMDDHHMMSS> |
| 120 | |
| 121 | ''' |
| 122 | CMD_SETDATETIME = 'bios SetDateTime -d %s' |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 123 | |
| 124 | |
| 125 | CMD_GETPDR = 'platform GetPDR -d %s' |
| 126 | |
| 127 | ''' |
| 128 | e.g. : SetStateEffecterStates usage |
| 129 | |
| 130 | pldmtool platform GetPDR -d <effecterID, requestSet, effecterState> |
| 131 | |
| 132 | pldmtool platform SetStateEffecterStates -d 1 1 1 |
| 133 | |
| 134 | ''' |
| 135 | |
| 136 | CMD_SETSTATEEFFECTERSTATES = 'platform SetStateEffecterStates -d %s' |
| 137 | |
| 138 | # GetPDR parsed response message for record handle. |
| 139 | # Dictionary value array holds the expected output for record handle 1, 2. |
| 140 | # e.g. : 'nextrecordhandle': ['0', '2'] |
| 141 | # |
| 142 | # Note : |
| 143 | # Record handle - 0 is default & has same behaviour as record handle 1 |
| 144 | # Only record handle 0, 1, 2 are supported as of now. |
| 145 | |
| 146 | RESPONSE_DICT_GETPDR = { |
| 147 | 'nextrecordhandle': ['0', '2'], |
| 148 | 'responsecount': ['29', '30'], |
| 149 | 'recordhandle': ['1', '2'], |
| 150 | 'pdrheaderversion': ['1'], |
| 151 | 'pdrtype': ['11'], |
| 152 | 'recordchangenumber': ['0'], |
| 153 | 'datalength': ['19', '20'], |
| 154 | 'pldmterminushandle': ['0'], |
| 155 | 'effecterid': ['1', '2'], |
| 156 | 'entitytype': ['33', '45'], |
| 157 | 'entityinstancenumber': ['0'], |
| 158 | 'containerid': ['0'], |
| 159 | 'effectersemanticid': ['0'], |
| 160 | 'effecterinit': ['0'], |
| 161 | 'effecterdescriptionpdr': ['false'], |
| 162 | 'compositeeffectercount': ['1'], |
| 163 | 'statesetid': ['196', '260'], |
| 164 | 'possiblestatessize': ['1', '2'], |
| 165 | 'possiblestates': ['6', '0']} |
| 166 | |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 167 | RESPONSE_DICT_GETBIOSTABLE_STRTABLE = { |
| 168 | 'biosstringhandle': ['BIOSString'], |
| 169 | '0': ['Allowed'], |
| 170 | '1': ['Disabled'], |
| 171 | '2': ['Enabled'], |
| 172 | '3': ['Not Allowed'], |
| 173 | '4': ['Perm'], |
| 174 | '5': ['Temp'], |
| 175 | '6': ['pvm-fw-boot-side'], |
| 176 | '7': ['pvm-inband-code-update'], |
| 177 | '8': ['pvm-os-boot-side'], |
| 178 | '9': ['pvm-pcie-error-inject'], |
| 179 | '10': ['pvm-surveillance'], |
| 180 | '11': ['pvm-system-name'], |
| 181 | '12': ['vmi-if-count']} |