1*** Settings *** 2Documentation Utility for error injection scenarios through HOST & BMC. 3Resource ../../lib/rest_client.robot 4Resource ../../lib/utils.robot 5Variables ../../lib/ras/variables.py 6Library ../../lib/bmc_ssh_utils.py 7Library ../../lib/gen_print.py 8Library ../../lib/gen_robot_print.py 9 10Library OperatingSystem 11 12*** Keywords *** 13 14Getscom Operations On OS 15 [Documentation] Executes getscom command on OS with the given 16 ... input command. 17 [Arguments] ${input_cmd} 18 # Description of arguments: 19 # input_cmd -l|--list-chips 20 # -c|--chip <chip-id> <addr> 21 22 ${output} ${stderr} ${rc}= OS Execute Command getscom ${input_cmd} 23 [Return] ${output} 24 25Gard Operations On OS 26 [Documentation] Executes opal-gard command on OS with the given 27 ... input command. 28 [Arguments] ${input_cmd} 29 # Description of arguments: 30 # input_cmd list/clear all/show <gard_record_id> 31 32 ${output} ${stderr} ${rc}= OS Execute Command opal-gard ${input_cmd} 33 [Return] ${output} 34 35Putscom Operations On OS 36 [Documentation] Executes putscom command on OS with the given 37 ... input arguments. 38 [Arguments] ${proc_chip_id} ${fru} ${address} 39 # Description of arguments: 40 # proc_chip_id Processor ID (e.g '0', '8'). 41 # fru FRU value (e.g. 2011400). 42 # address Chip address (e.g 4000000000000000). 43 44 ${cmd}= Catenate putscom -c 0x${proc_chip_id} 0x${fru} 0x${address} 45 Start Command ${cmd} 46 47Get ProcChipId From OS 48 [Documentation] Get processor chip ID values based on the input. 49 [Arguments] ${chip_type} ${master_proc_chip} 50 # Description of arguments: 51 # chip_type The chip type (Processor/Centaur). 52 # master_proc_chip Processor chip type ('True' or 'False'). 53 54 ${cmd}= Catenate -l | grep -i ${chip_type} | cut -c1-8 55 ${proc_chip_id}= Getscom Operations On OS ${cmd} 56 # Example output: 57 # getscom -l | grep processor | cut -c1-8 58 # 00000008 - False 59 # 00000000 - True 60 61 ${proc_ids}= Split String ${proc_chip_id} 62 ${proc_id}= Run Keyword If '${master_proc_chip}' == 'True' 63 \ ... Get From List ${proc_ids} 1 64 \ ... ELSE Get From List ${proc_ids} 0 65 66 # Example output: 67 # 00000008 68 [Return] ${proc_id} 69 70Get Core IDs From OS 71 [Documentation] Get Core IDs corresponding to the input processor chip ID. 72 [Arguments] ${proc_chip_id} 73 # Description of argument(s): 74 # proc_chip_id Processor ID (e.g '0', '8'). 75 76 ${cmd}= Catenate set -o pipefail ; ${probe_cpu_file_path} 77 ... | grep -i 'CHIP ID: ${proc_chip_id}' | cut -c21-22 78 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} 79 ${core_ids}= Split String ${output} 80 # Example output: 81 # ['2', '3', '4', '5', '6'] 82 [Return] ${core_ids} 83 84FIR Address Translation Through HOST 85 [Documentation] Do FIR address translation through host for given FIR, 86 ... core value & target type. 87 [Arguments] ${fir} ${core_id} ${target_type} 88 # Description of argument(s): 89 # fir FIR (Fault isolation register) value (e.g. 2011400). 90 # core_id Core ID (e.g. 9). 91 # target_type Target type (e.g. 'EQ', 'EX', 'C'). 92 93 ${cmd}= Catenate set -o pipefail ; ${addr_translation_file_path} ${fir} 94 ... ${core_id} | grep -i ${target_type} 95 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} 96 ${translated_addr}= Split String ${output} :${SPACE}0x 97 # Example output: 98 # 0x10010c00 99 [Return] ${translated_addr[1]} 100 101Inject Error Through HOST 102 [Documentation] Inject checkstop on multiple targets like 103 ... CPU/CME/OCC/NPU/CAPP/MCA etc through HOST. 104 ... Test sequence: 105 ... 1. Boot To HOST 106 ... 2. Clear any existing gard records 107 ... 3. Inject Error on processor/centaur 108 [Arguments] ${fir} ${chip_address} ${threshold_limit} 109 ... ${master_proc_chip}=True 110 # Description of argument(s): 111 # fir FIR (Fault isolation register) value (e.g. 2011400). 112 # chip_address chip address (e.g 2000000000000000). 113 # threshold_limit Threshold limit (e.g 1, 5, 32). 114 # master_proc_chip Processor chip type (True' or 'False'). 115 116 Delete Error Logs 117 Login To OS Host 118 Set Auto Reboot 1 119 Gard Operations On OS clear all 120 121 # Fetch processor chip IDs. 122 ${proc_chip_id}= Get ProcChipId From OS Processor ${master_proc_chip} 123 124 ${threshold_limit}= Convert To Integer ${threshold_limit} 125 :FOR ${count} IN RANGE ${threshold_limit} 126 \ Run Keyword Putscom Operations On OS ${proc_chip_id} ${fir} 127 ... ${chip_address} 128 # Adding delay after each error injection. 129 \ Sleep 10s 130 # Adding delay to get error log after error injection. 131 Sleep 120s 132 133Code Update Unrecoverable Error Inject 134 [Documentation] Inject UE MCACALFIR checkstop on processor through 135 ... host during PNOR code update. 136 137 Inject Error Through HOST 05010800 4000000000000000 1 138 139Disable CPU States Through HOST 140 [Documentation] Disable CPU states through host. 141 142 # Fetch number of states present for cpu0. 143 ${cmd}= Catenate ls /sys/devices/system/cpu/cpu0/cpuidle|grep state|wc -l 144 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} 145 ${no_of_states}= Convert To Integer ${output} 146 147 # Disable state for all cpus. 148 :FOR ${count} IN RANGE ${no_of_states} 149 \ ${cmd}= Catenate SEPARATOR= for file_path in /sys/devices/system/cpu/ 150 ... cpu*/cpuidle/state${i}/disable; do echo 1 > $file_path; done 151 \ ${output} ${stderr} ${rc}= Run Keyword OS Execute Command ${cmd} 152 153Is Opal-PRD Service Enabled 154 [Documentation] Check if Opal-PRD service is running & return either 155 ... 'enabled' or 'disabled'. 156 157 ${cmd}= Catenate systemctl list-unit-files | grep opal-prd 158 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} 159 ${opal_prd_state}= Split String ${output} 160 161 # Example output from prior command: 162 # opal-prd.service enabled 163 [Return] ${opal_prd_state[1]} 164 165Enable Opal-PRD Service On HOST 166 [Documentation] Enable Opal-PRD service on host. 167 168 OS Execute Command service opal-prd start 169 ${opal_prd_state}= Is Opal-PRD Service Enabled 170 Should Contain ${opal_prd_state} enabled 171 172BMC Putscom 173 [Documentation] Executes putscom command through BMC. 174 175 [Arguments] ${proc_chip_id} ${fru} ${chip_address} 176 177 # Description of argument(s): 178 # proc_chip_id Processor ID (e.g '0', '8'). 179 # fru FRU (field replaceable unit) (e.g. '2011400'). 180 # chip_address Chip address (e.g. '4000000000000000'). 181 182 ${cmd}= Catenate pdbg -d p9w -p${proc_chip_id} putscom 0x${fru} 0x${chip_address} 183 184 BMC Execute Command ${cmd} 185 186Inject Error Through BMC 187 [Documentation] Inject checkstop on multiple targets like 188 ... CPU/CME/OCC/NPU/CAPP/MCA etc through BMC. 189 ... Test sequence: 190 ... 1. Boot To HOST. 191 ... 2. Clear any existing gard records. 192 ... 3. Inject Error on processor/centaur. 193 [Arguments] ${fir} ${chip_address} ${threshold_limit} 194 ... ${master_proc_chip}=True 195 # Description of argument(s): 196 # fir FIR (Fault isolation register) value (e.g. '2011400'). 197 # chip_address Chip address (e.g. '2000000000000000'). 198 # threshold_limit Recoverable error threshold limit (e.g. '1', '5', '32'). 199 200 Delete Error Logs 201 Login To OS Host 202 Set Auto Reboot 1 203 204 Gard Operations On OS clear all 205 206 ${threshold_limit}= Convert To Integer ${threshold_limit} 207 :FOR ${count} IN RANGE ${threshold_limit} 208 \ BMC Putscom 0 ${fir} 209 ... ${chip_address} 210 # Adding delay after each error injection. 211 \ Sleep 10s 212 # Adding delay to get error log after error injection. 213 Sleep 120s 214