Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * IBM ASM Service Processor Device Driver
0004  *
0005  * Copyright (C) IBM Corporation, 2004
0006  *
0007  * Author: Max Asböck <amax@us.ibm.com>
0008  */
0009 
0010 #ifndef __DOT_COMMAND_H__
0011 #define __DOT_COMMAND_H__
0012 
0013 /*
0014  * dot commands are the protocol used to communicate with the service
0015  * processor.
0016  * They consist of header, a command of variable length and data of
0017  * variable length.
0018  */
0019 
0020 /* dot command types */
0021 #define sp_write        0
0022 #define sp_write_next       1
0023 #define sp_read         2
0024 #define sp_read_next        3
0025 #define sp_command_response 4
0026 #define sp_event        5
0027 #define sp_heartbeat        6
0028 
0029 #pragma pack(1)
0030 struct dot_command_header {
0031     u8  type;
0032     u8  command_size;
0033     u16 data_size;
0034     u8  status;
0035     u8  reserved;
0036 };
0037 #pragma pack()
0038 
0039 static inline size_t get_dot_command_size(void *buffer)
0040 {
0041     struct dot_command_header *cmd = (struct dot_command_header *)buffer;
0042     return sizeof(struct dot_command_header) + cmd->command_size + cmd->data_size;
0043 }
0044 
0045 static inline unsigned int get_dot_command_timeout(void *buffer)
0046 {
0047     struct dot_command_header *header = (struct dot_command_header *)buffer;
0048     unsigned char *cmd = buffer + sizeof(struct dot_command_header);
0049 
0050     /* dot commands 6.3.1, 7.1 and 8.x need a longer timeout */
0051 
0052     if (header->command_size == 3) {
0053         if ((cmd[0] == 6) && (cmd[1] == 3) && (cmd[2] == 1))
0054             return IBMASM_CMD_TIMEOUT_EXTRA;
0055     } else if (header->command_size == 2) {
0056         if ((cmd[0] == 7) && (cmd[1] == 1))
0057             return IBMASM_CMD_TIMEOUT_EXTRA;
0058         if (cmd[0] == 8)
0059             return IBMASM_CMD_TIMEOUT_EXTRA;
0060     }
0061     return IBMASM_CMD_TIMEOUT_NORMAL;
0062 }
0063 
0064 #endif /* __DOT_COMMAND_H__ */