xref: /openbmc/openbmc-test-automation/lib/ras/host_utils.robot (revision e7dc4478003c8a01d25291f1df061a061645ca0f)
1*** Settings ***
2Documentation       This module is for OS checkstop opertions.
3Resource            ../../lib/rest_client.robot
4Resource            ../../lib/utils.robot
5Variables           ../../lib/ras/variables.py
6Library             ../../lib/bmc_ssh_utils.py
7Library             OperatingSystem
8
9*** Keywords ***
10
11Getscom Operations On OS
12    [Documentation]  Executes getscom command on OS with the given
13    ...              input command.
14    [Arguments]      ${input_cmd}
15    # Description of arguments:
16    # input_cmd      -l|--list-chips
17    #                -c|--chip <chip-id> <addr>
18
19    ${output}  ${stderr}  ${rc}=  OS Execute Command  getscom ${input_cmd}
20    Should Be Empty  ${stderr}
21    [Return]  ${output}
22
23Gard Operations On OS
24    [Documentation]  Executes opal-gard command on OS with the given
25    ...              input command.
26    [Arguments]      ${input_cmd}
27    # Description of arguments:
28    # input_cmd      list/clear all/show <gard_record_id>
29
30    ${output}  ${stderr}  ${rc}=  OS Execute Command  opal-gard ${input_cmd}
31    Should Be Empty  ${stderr}
32    [Return]  ${output}
33
34Putscom Operations On OS
35    [Documentation]  Executes putscom command on OS with the given
36    ...              input arguments.
37    [Arguments]      ${proc_chip_id}  ${fru}  ${address}
38    # Description of arguments:
39    # proc_chip_id        Processor ID (e.g '0', '8').
40    # fru            FRU value (e.g. 2011400).
41    # address        Chip address (e.g 4000000000000000).
42
43    ${cmd}=  Catenate  putscom -c 0x${proc_chip_id} 0x${fru} 0x${address}
44    Start Command  ${cmd}
45
46Get ProcChipId From OS
47    [Documentation]  Get processor chip ID values based on the input.
48    [Arguments]      ${chip_type}
49    # Description of arguments:
50    # chip_type      The chip type (Processor/Centaur).
51
52    ${cmd}=  Catenate  -l | grep -i ${chip_type} | cut -c1-8
53    ${proc_chip_id}=  Getscom Operations On OS  ${cmd}
54    # Example output:
55    # 00000008
56    # 00000000
57    [Return]  ${proc_chip_id}
58
59Get Core IDs From OS
60    [Documentation]  Get Core IDs corresponding to the input processor chip ID.
61    [Arguments]      ${proc_chip_id}
62    # Description of argument(s):
63    # proc_chip_id        Processor ID (e.g '0', '8').
64
65    ${cmd}=  Catenate  set -o pipefail ; ${probe_cpu_file_path}
66    ...    | grep -i 'CHIP ID: ${proc_chip_id}' | cut -c21-22
67    ${output}  ${stderr}  ${rc}=  OS Execute Command  ${cmd}
68    Should Be Empty  ${stderr}
69    ${core_ids}=  Split String  ${output}
70    # Example output:
71    # ['2', '3', '4', '5', '6']
72    [Return]  ${core_ids}
73
74FIR Address Translation Through HOST
75    [Documentation]  Do FIR address translation through host for given FIR,
76    ...              core value & target type.
77    [Arguments]  ${fir}  ${core_id}  ${target_type}
78    # Description of argument(s):
79    # fir          FIR (Fault isolation register) value (e.g. 2011400).
80    # core_id      Core ID (e.g. 9).
81    # target_type  Target type (e.g. 'EQ', 'EX', 'C').
82
83    ${cmd}=  Catenate  set -o pipefail ; ${addr_translation_file_path} ${fir}
84    ...  ${core_id} | grep -i ${target_type}
85    ${output}  ${stderr}  ${rc}=  OS Execute Command  ${cmd}
86    Should Be Empty  ${stderr}
87    ${translated_addr}=  Split String  ${output}  :${SPACE}0x
88    # Example output:
89    # 0x10010c00
90    [Return]  ${translated_addr[1]}
91
92
93Inject Error Through HOST
94    [Documentation]  Inject checkstop on processor through HOST.
95    ...              Test sequence:
96    ...              1. Boot To HOST
97    ...              2. Clear any existing gard records
98    ...              3. Inject Error on processor/centaur
99    [Arguments]      ${fir}  ${chip_address}  ${threshold_limit}
100    # Description of argument(s):
101    # fir                 FIR (Fault isolation register) value (e.g. 2011400).
102    # chip_address        chip address (e.g 2000000000000000).
103    # threshold_limit     Threshold limit (e.g 1, 5, 32).
104
105    Delete Error Logs
106    Login To OS Host
107    Gard Operations On OS  clear all
108
109    # Fetch processor chip IDs.
110    ${chip_ids}=  Get ProcChipId From OS  Processor
111    ${proc_ids}=  Split String  ${chip_ids}
112    ${proc_id}=  Get From List  ${proc_ids}  1
113
114    ${threshold_limit}=  Convert To Integer  ${threshold_limit}
115    :FOR  ${i}  IN RANGE  ${threshold_limit}
116    \  Run Keyword  Putscom Operations On OS  ${proc_id}  ${fir}  ${chip_address}
117    # Adding delay after each error injection.
118    \  Sleep  10s
119    # Adding delay to get error log after error injection.
120    Sleep  120s
121
122
123Code Update Unrecoverable Error Inject
124    [Documentation]  Inject UE MCACALFIR checkstop on processor through
125    ...   host during PNOR code update.
126
127    Inject Error Through HOST  05010800  4000000000000000  1
128