i2o.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #pragma pack(1)
  10. struct i2o_header {
  11. u8 version;
  12. u8 message_flags;
  13. u16 message_size;
  14. u8 target;
  15. u8 initiator_and_target;
  16. u8 initiator;
  17. u8 function;
  18. u32 initiator_context;
  19. };
  20. #pragma pack()
  21. #define I2O_HEADER_TEMPLATE \
  22. { .version = 0x01, \
  23. .message_flags = 0x00, \
  24. .function = 0xFF, \
  25. .initiator = 0x00, \
  26. .initiator_and_target = 0x40, \
  27. .target = 0x00, \
  28. .initiator_context = 0x0 }
  29. #define I2O_MESSAGE_SIZE 0x1000
  30. #define I2O_COMMAND_SIZE (I2O_MESSAGE_SIZE - sizeof(struct i2o_header))
  31. #pragma pack(1)
  32. struct i2o_message {
  33. struct i2o_header header;
  34. void *data;
  35. };
  36. #pragma pack()
  37. static inline unsigned short outgoing_message_size(unsigned int data_size)
  38. {
  39. unsigned int size;
  40. unsigned short i2o_size;
  41. if (data_size > I2O_COMMAND_SIZE)
  42. data_size = I2O_COMMAND_SIZE;
  43. size = sizeof(struct i2o_header) + data_size;
  44. i2o_size = size / sizeof(u32);
  45. if (size % sizeof(u32))
  46. i2o_size++;
  47. return i2o_size;
  48. }
  49. static inline u32 incoming_data_size(struct i2o_message *i2o_message)
  50. {
  51. return (sizeof(u32) * i2o_message->header.message_size);
  52. }