dot_command.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * IBM ASM Service Processor Device Driver
  4. *
  5. * Copyright (C) IBM Corporation, 2004
  6. *
  7. * Author: Max Asböck <amax@us.ibm.com>
  8. */
  9. #ifndef __DOT_COMMAND_H__
  10. #define __DOT_COMMAND_H__
  11. /*
  12. * dot commands are the protocol used to communicate with the service
  13. * processor.
  14. * They consist of header, a command of variable length and data of
  15. * variable length.
  16. */
  17. /* dot command types */
  18. #define sp_write 0
  19. #define sp_write_next 1
  20. #define sp_read 2
  21. #define sp_read_next 3
  22. #define sp_command_response 4
  23. #define sp_event 5
  24. #define sp_heartbeat 6
  25. #pragma pack(1)
  26. struct dot_command_header {
  27. u8 type;
  28. u8 command_size;
  29. u16 data_size;
  30. u8 status;
  31. u8 reserved;
  32. };
  33. #pragma pack()
  34. static inline size_t get_dot_command_size(void *buffer)
  35. {
  36. struct dot_command_header *cmd = (struct dot_command_header *)buffer;
  37. return sizeof(struct dot_command_header) + cmd->command_size + cmd->data_size;
  38. }
  39. static inline unsigned int get_dot_command_timeout(void *buffer)
  40. {
  41. struct dot_command_header *header = (struct dot_command_header *)buffer;
  42. unsigned char *cmd = buffer + sizeof(struct dot_command_header);
  43. /* dot commands 6.3.1, 7.1 and 8.x need a longer timeout */
  44. if (header->command_size == 3) {
  45. if ((cmd[0] == 6) && (cmd[1] == 3) && (cmd[2] == 1))
  46. return IBMASM_CMD_TIMEOUT_EXTRA;
  47. } else if (header->command_size == 2) {
  48. if ((cmd[0] == 7) && (cmd[1] == 1))
  49. return IBMASM_CMD_TIMEOUT_EXTRA;
  50. if (cmd[0] == 8)
  51. return IBMASM_CMD_TIMEOUT_EXTRA;
  52. }
  53. return IBMASM_CMD_TIMEOUT_NORMAL;
  54. }
  55. #endif /* __DOT_COMMAND_H__ */