1#!/usr/bin/env python3
2
3r"""
4IPMI raw commands table:
5
6   - Define IPMI interface index, commands and expected output.
7
8"""
9
10# The currently supported cipher list.
11# Refer:
12# openbmc/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipe
13# s-phosphor/ipmi/phosphor-ipmi-host/cipher_list.json
14valid_ciphers = ['17']
15unsupported_ciphers = ['1', '2', '15', '16']
16
17IPMI_RAW_CMD = {
18    # Interface name
19    'power_supply_redundancy':
20    {
21        # Command action type
22        'Get':
23        [
24            # raw command, expected output(s), comment
25            "0x04 0x2d 0x0b",
26            "00 00 01 00",
27            "Byte position 3rd LSB e.g. 01 indicates disabled",
28            "00 00 02 00",
29            "Byte position 3rd LSB e.g. 02 indicates enabled",
30            "00 40 02 00",
31            "40 is scanning enabled and 02 indicates redundancy enabled",
32        ],
33        'Enabled':
34        [
35            # raw command, expected output, comment
36            "0x04 0x30 0x0b 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00",
37            "none",
38            "Enabled nibble position 6th LSB e.g. 0x2",
39        ],
40        'Disabled':
41        [
42            # raw command, expected output, comment
43            "0x04 0x30 0x0b 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00",
44            "none",
45            "Enabled nibble position 6th LSB e.g. 0x1",
46        ],
47    },
48    'power_reading':
49    {
50        'Get':
51        [
52            # raw command, expected output(s), comment
53            "0x2c 0x02 0xdc 0x01 0x01 0x00",
54            "dc d5 00 d5 00 d5 00 d5 00 00 00 00 00 00 00 00 00 00",
55            "Byte position 2nd LSB e.g. d5 Instantaneous power readings",
56        ],
57    },
58    'conf_param':
59    {
60        'Enabled':
61        [
62            # raw command, expected output, comment
63            "0x2c 0x12 0xdc 0x02 0x00 0x01",
64            "dc",
65            "Enabled nibble position 6th LSB e.g. 0x01",
66        ],
67        'Disabled':
68        [
69            # raw command, expected output, comment
70            "0x2c 0x12 0xdc 0x02 0x00 0x00",
71            "dc",
72            "Disable nibble position 6th LSB e.g. 0x00",
73        ]
74    },
75    'SEL_entry':
76    {
77        'Reserve':
78        [
79            # raw command, expected output, comment
80            "0x0a 0x42",
81            "27 00",
82            "27 is Reservation ID, LSB, 00 Reservation ID, MSB ",
83        ],
84        'Get_SEL_Time':
85        [
86            # raw command
87            '0x0a 0x48',
88        ],
89        'Set_SEL_Time':
90        [
91            # raw command, expected output(s)
92            '0x0a 0x49',
93            'rsp=0xd5',
94            'not supported in present state',
95            'rsp=0xc7',
96            'Request data length invalid',
97        ],
98        'Clear_SEL':
99        [
100            # raw command, expected output(s)
101            "0x0a 0x47",
102            "0x43 0x4c 0x52 0xaa",
103            "sel clear",
104            "Clearing SEL",
105            "rsp=0xc5",
106            "Reservation cancelled or invalid",
107            "0x43 0x4c 0x52 0x00",
108        ],
109        'SEL_info':
110        [
111            # raw command
112            "0x0a 0x40"
113        ],
114        'Create_SEL':
115        [
116            # raw command
117            "0x0a 0x44 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x04",
118            "0x00 0xa0 0x04 0x07",
119        ],
120        'Get_SEL_Entry':
121        [
122            # raw command
123            "0x0a 0x43 0x00 0x00",
124            "0x00 0xff",
125        ],
126    },
127    'Self_Test_Results':
128    {
129        'Get':
130        [
131            # raw command, expected output(s), comment
132            "0x06 0x04",
133            "56 00",
134            "56h = Self Test function not implemented in this controller.",
135        ]
136    },
137    'Device GUID':
138    {
139        'Get':
140        [
141            # raw command, expected output(s), comment
142            "0x06 0x08",
143            "01 70 9b ae da 6f dd 9c b4 4c 36 be 66 c8 49 28",
144            "Get GUID bytes 1 through 16.",
145
146        ]
147    },
148    'LAN_Config_Params':
149    {
150        'Get':
151        [
152            # raw command, expected output, comment
153            "0x0c 0x02",
154            "11 02",
155            "11 is Parameter revision, 02 is Configuration parameter data e.g. Cipher Suite Entry count",
156        ],
157        'Set':
158        [
159            # raw command, expected output, error response
160            "0x0c 0x01",
161            "11 00",
162            "Unknown (0x82)",
163            "Invalid data field in request",
164        ],
165    },
166    'Payload':
167    {
168        'Get_Payload_Activation_Status':
169        [
170            # raw command, expected output(s), comment
171            "0x06 0x4a 0x01",
172            "01 00 00",
173            "1st byte is instance capacity, last two bytes is activation status of instances",
174        ],
175        'Activate_Payload':
176        [
177            # raw command, expected output(s), comment
178            "0x06 0x48 0x01 0x01 0xc6 0x00 0x00 0x00",
179            "00 00 00 00 ff 00 ff 00 6f 02 ff ff",
180            "Last two bits are payload vlan number, - FFFFh if VLAN addressing is not used",
181        ],
182        'Deactivate_Payload':
183        [
184            # raw command, expected output(s), comment
185            "0x06 0x49 0x01 0x01 0x00 0x00 0x00 0x00",
186            "",
187            "Line feed only",
188        ],
189        'Get_Payload_Instance_Info':
190        [
191            # raw command, expected output(s), comment
192            "0x06 0x4b 0x01 0x01",
193            "00 00 00 00 00 00 00 00 00 00 00 00",
194            "When the payload is activated, the first four bytes are the session ID,"
195            "otherwise it should be 00."
196        ]
197    },
198    'BIOS_POST_Code':
199    {
200        'Get':
201        [
202            # raw command, expected output, comment
203            "0x30 0xe9",
204            "",
205            "Response bytes will vary in length depending on state of system",
206            "0x89",
207            "error response byte when host is powered off"
208        ]
209    },
210    'Device ID':
211    {
212        'Get':
213        [
214            # raw command, error response, error code
215            "0x06 0x01",
216            "Error: Unable to establish IPMI v2 / RMCP+ session",
217            "0xc7",
218        ]
219    },
220    'Cold Reset':
221    {
222        'reset':
223        [
224            # raw command
225            "0x06 0x02"
226        ]
227    },
228    'lan_parameters':
229    {
230        'get_ip':
231        [
232            # raw command
233            "0x0c 0x02 0x01 0x03 0 0"
234        ],
235        'get_ip_src':
236        [
237            # raw command
238            "0x0c 0x02 0x01 0x04 0 0"
239        ],
240        'get_dot1q':
241        [
242            # raw command
243            "0x0c 0x02 0x01 0x14 0 0"
244        ]
245    },
246    'SDR_Info':
247    {
248        'get':
249        [
250            # raw command
251            "0x04 0x20 1"
252        ]
253    },
254    'Chassis_status':
255    {
256        'get':
257        [
258            # raw command
259            "0x00 0x01"
260        ]
261    },
262    'SEL_Info':
263    {
264        'get':
265        [
266            # raw command
267            "0x0a 0x40"
268        ]
269    },
270    'Watchdog':
271    {
272        # Command action type
273        'Get':
274        [
275            # raw command, expected output(s), comment
276            "0x06 0x25",
277            "05 00 00 00 64 00",
278            "don't log bit enabled",
279            "85 00 00 00 64 00",
280            "don't log bit disabled",
281            "05 00 00 00 64 00",
282            "stop bit stop",
283            "45 00 00 00 64 00",
284            "stop bit resume",
285            "01 00 00 00 64 00",
286            "timer use FRB2",
287            "02 00 00 00 64 00",
288            "timer use POST",
289            "03 00 00 00 64 00",
290            "timer use OS",
291            "04 00 00 00 64 00",
292            "timer use SMS",
293            "05 00 00 00 64 00",
294            "timer use OEM",
295            "05 00 00 00 64 00",
296            "pre-timeout interrupt None",
297            "05 20 00 00 64 00",
298            "pre-timeout interrupt NMI",
299            "05 00 00 00 64 00",
300            "timeout action None",
301            "05 01 00 00 64 00",
302            "timeout action Reset",
303            "05 02 00 00 64 00",
304            "timeout action PowerDown",
305            "05 03 00 00 64 00",
306            "timeout action PowerCycle",
307            "01 00 00 02 00 00",
308            "timeout flag FRB2",
309            "02 00 00 04 00 00",
310            "timeout flag POST",
311            "03 00 00 08 00 00",
312            "timeout flag OS",
313            "04 00 00 10 00 00",
314            "timeout flag SMS",
315            "05 00 00 20 00 00",
316            "timeout flag OEM",
317            "05 00 00 00 30 35 30 35",
318            "Get should return 13.6 seconds",
319            "05 00 00 00 ff ff ff ff",
320            "Bit 6 not set when timer stopped",
321            "0x06 0x25 0x00",
322            "Get with one extra byte",
323        ],
324        'Set':
325        [
326            # raw command, expected output, comment
327            "0x06 0x24 0x05 0x00 0x00 0x00 0x64 0x00",
328            "none",
329            "don't log bit enabled",
330            "0x06 0x24 0x85 0x00 0x00 0x00 0x64 0x00",
331            "none",
332            "don't log bit disabled",
333            "0x06 0x24 0x05 0x00 0x00 0x00 0x64 0x00",
334            "none",
335            "stop bit stop",
336            "0x06 0x24 0x45 0x00 0x00 0x00 0x64 0x00",
337            "none",
338            "stop bit resume",
339            "0x06 0x24 0x01 0x00 0x00 0x00 0x64 0x00",
340            "none",
341            "timer use FRB2",
342            "0x06 0x24 0x02 0x00 0x00 0x00 0x64 0x00",
343            "none",
344            "timer use POST",
345            "0x06 0x24 0x03 0x00 0x00 0x00 0x64 0x00",
346            "none",
347            "timer use OS",
348            "0x06 0x24 0x04 0x00 0x00 0x00 0x64 0x00",
349            "none",
350            "timer use SMS",
351            "0x06 0x24 0x05 0x00 0x00 0x00 0x64 0x00",
352            "none",
353            "timer use OEM",
354            "0x06 0x24 0x05 0x00 0x00 0x00 0x64 0x00",
355            "none",
356            "pre-timeout interrupt None",
357            "0x06 0x24 0x05 0x20 0x00 0x00 0x64 0x00",
358            "none",
359            "pre-timeout interrupt NMI",
360            "0x06 0x24 0x05 0x00 0x00 0x00 0x64 0x00",
361            "none",
362            "timeout action None",
363            "0x06 0x24 0x05 0x01 0x00 0x00 0x64 0x00",
364            "none",
365            "timeout action Reset",
366            "0x06 0x24 0x05 0x02 0x00 0x00 0x64 0x00",
367            "none",
368            "timeout action PowerDown",
369            "0x06 0x24 0x05 0x03 0x00 0x00 0x64 0x00",
370            "none",
371            "timeout action PowerCycle",
372            "0x06 0x24 0x01 0x00 0x00 0x3e 0x00 0x00",
373            "none",
374            "timeout flag FRB2",
375            "0x06 0x24 0x02 0x00 0x00 0x3e 0x00 0x00",
376            "none",
377            "timeout flag POST",
378            "0x06 0x24 0x03 0x00 0x00 0x3e 0x00 0x00",
379            "none",
380            "timeout flag OS",
381            "0x06 0x24 0x04 0x00 0x00 0x3e 0x00 0x00",
382            "none",
383            "timeout flag SMS",
384            "0x06 0x24 0x05 0x00 0x00 0x3e 0x00 0x00",
385            "none",
386            "timeout flag OEM",
387            "0x06 0x24 0x01 0x02 0x00 0x00 0x20 0x00",
388            "none",
389            "Power down",
390            "0x06 0x24 0x01 0x01 0x00 0x00 0x20 0x00",
391            "none",
392            "Hard reset",
393            "0x06 0x24 0x01 0x03 0x00 0x00 0x20 0x00",
394            "none",
395            "Power cycle",
396            "0x06 0x24 0x01 0x00 0x00 0x00 0x20 0x00",
397            "none",
398            "No action",
399            "0x06 0x24 0x05 0x00 0x00 0x3e 0x30 0x35",
400            "none",
401            "Set for 13.6 seconds",
402            "0x06 0x24 0x05 0x00 0x07 0x00 0x50 0x00",
403            "none",
404            "Pre-timeout interval passes",
405            "0x06 0x24 0x05 0x00 0x04 0x00 0x0A 0x00",
406            "none",
407            "Pre-timeout interval fails",
408            "0x06 0x24 0x05 0x00 0x00 0x20 0xFF 0xFF",
409            "none",
410            "Bit 6 not set when timer stopped",
411            "0x06 0x24 0x05 0x00 0x08 0x00 0x64",
412            "none",
413            "Set with one less byte",
414            "0x06 0x24 0x05 0x00 0x08 0x00 0x64 0x00 0x00",
415            "none",
416            "Set with one extra byte",
417        ],
418        'Reset':
419        [
420            # raw command, expected output, comment
421            "0x06 0x22",
422            "none",
423            "Reset watchdog timer",
424            "0x06 0x22 0x00",
425            "none",
426            "Reset watchdog timer with extra byte",
427            "0x06 0x22",
428            "none",
429            "Reset watchdog timer without initialized watchdog",
430        ]
431    },
432    'SOL':
433    {
434        'Set_SOL':
435        [
436            # raw command, expected output(s), comment
437            'Invalid value',
438            'Valid values are serial, 9.6 19.2, 38.4, 57.6 and 115.2',
439        ]
440    },
441    'Get SDR':
442    {
443        'Get':
444        [
445            # Get SDR raw command without Reservation ID.
446            "0x0a 0x23 0x00 0x00 0x00 0x00 0x00 0xff",
447            # Netfunction and cmd.
448            "0x0a 0x23",
449            # Record ID offset and bytes to read.
450            "0x00 0x00 0x01 0x0f",
451            #  Raw command To Get SDR Partial without Reservation ID.
452            "0x0a 0x23 0x00 0x00 0x00 0x00 0x01 0x0f"
453        ],
454    },
455    'Get':
456    {
457        'POH_Counter':
458        [
459            # raw command, error response
460            '0x00 0x0f',
461            'Error: Unable to establish IPMI v2 / RMCP+ session'
462        ]
463    },
464    'Device_SDR':
465    {
466        'Get_Info':
467        [
468            # raw command, expected output(s), comment
469            "0x04 0x20 0x00",
470            "0x04 0x20 0x01",
471            "rsp=0xc7",
472            "Request data length invalid",
473            "rsp=0xd4",
474            "Insufficient privilege level",
475        ],
476        'Get':
477        [
478            # raw command, expected output(s), comment
479            "0x04 0x21",
480            "0x00 0x00 0x00 0xff",
481            "rsp=0xc7",
482            "Request data length invalid",
483        ],
484        'Reserve_Repository':
485        [
486            # raw command, expected output(s), comment
487            "0x04 0x22",
488            "rsp=0xc7",
489            "Request data length invalid",
490            "rsp=0xd4",
491            "Insufficient privilege level",
492            "Reservation cancelled or invalid",
493        ]
494    },
495    'System_Info':
496    {
497        'param0_Set_In_Progress':
498        {
499            'Get':
500            [
501                # raw command, expected output(s)
502                "0x06 0x59 0x00 0x00 0x00 0x00",
503                "Request data length invalid",
504            ],
505            'Set':
506            [
507                # raw command, expected output(s)
508                "0x06 0x58 0x00 0x00",
509                "Request data length invalid",
510                "Invalid data field in request",
511            ],
512        },
513        'param1_System_Firmware_Version':
514        {
515            'Get':
516            [
517                # raw command, expected output(s)
518                "0x06 0x59 0x00 0x01 0x00 0x00",
519                "Request data length invalid",
520            ],
521            'Set':
522            [
523                # raw command, expected output(s)
524                "0x06 0x58 0x01 0x00 0x00 0x0e",
525                "Invalid data field in request",
526            ],
527        },
528        'param2_System_Name':
529        {
530            'Get':
531            [
532                # raw command, expected output(s)
533                "0x06 0x59 0x00 0x02 0x00 0x00",
534                "Request data length invalid",
535            ],
536            'Set':
537            [
538                # raw command, expected output(s)
539                "0x06 0x58 0x02 0x00 0x00 0x0e",
540                "Invalid data field in request",
541            ],
542        },
543        'param3_Primary_Operating_System_Name':
544        {
545            'Get':
546            [
547                # raw command, expected output(s)
548                "0x06 0x59 0x00 0x03 0x00 0x00",
549                "Request data length invalid",
550            ],
551            'Set':
552            [
553                # raw command, expected output(s)
554                "0x06 0x58 0x03 0x00 0x00 0x0e",
555                "Invalid data field in request",
556            ],
557        },
558        'param4_Operating_System_Name':
559        {
560            'Get':
561            [
562                # raw command, expected output(s)
563                "0x06 0x59 0x00 0x04 0x00 0x00",
564                "Request data length invalid",
565            ],
566            'Set':
567            [
568                # raw command, expected output(s)
569                "0x06 0x58 0x04 0x00 0x00 0x0e",
570                "Invalid data field in request",
571            ],
572        },
573        'param5_Present_OS_Version_number':
574        {
575            'Get':
576            [
577                # raw command, expected output(s)
578                "0x06 0x59 0x00 0x05 0x00 0x00",
579                "Request data length invalid",
580            ],
581            'Set':
582            [
583                # raw command, expected output(s)
584                "0x06 0x58 0x05 0x00 0x00 0x0e",
585                "Invalid data field in request",
586            ]
587        }
588    }
589}
590