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