Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * IBM ASM Service Processor Device Driver |
| 4 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Copyright (C) IBM Corporation, 2004 |
| 6 | * |
Al Viro | d36b691 | 2011-12-29 17:09:01 -0500 | [diff] [blame] | 7 | * Author: Max Asböck <amax@us.ibm.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #pragma pack(1) |
| 11 | struct i2o_header { |
| 12 | u8 version; |
| 13 | u8 message_flags; |
| 14 | u16 message_size; |
Dmitry Torokhov | 3110dc7 | 2007-07-17 04:03:58 -0700 | [diff] [blame] | 15 | u8 target; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | u8 initiator_and_target; |
Dmitry Torokhov | 3110dc7 | 2007-07-17 04:03:58 -0700 | [diff] [blame] | 17 | u8 initiator; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | u8 function; |
| 19 | u32 initiator_context; |
| 20 | }; |
| 21 | #pragma pack() |
| 22 | |
| 23 | #define I2O_HEADER_TEMPLATE \ |
| 24 | { .version = 0x01, \ |
| 25 | .message_flags = 0x00, \ |
| 26 | .function = 0xFF, \ |
| 27 | .initiator = 0x00, \ |
| 28 | .initiator_and_target = 0x40, \ |
| 29 | .target = 0x00, \ |
| 30 | .initiator_context = 0x0 } |
| 31 | |
| 32 | #define I2O_MESSAGE_SIZE 0x1000 |
| 33 | #define I2O_COMMAND_SIZE (I2O_MESSAGE_SIZE - sizeof(struct i2o_header)) |
| 34 | |
| 35 | #pragma pack(1) |
| 36 | struct i2o_message { |
| 37 | struct i2o_header header; |
| 38 | void *data; |
| 39 | }; |
| 40 | #pragma pack() |
| 41 | |
| 42 | static inline unsigned short outgoing_message_size(unsigned int data_size) |
| 43 | { |
| 44 | unsigned int size; |
| 45 | unsigned short i2o_size; |
| 46 | |
| 47 | if (data_size > I2O_COMMAND_SIZE) |
| 48 | data_size = I2O_COMMAND_SIZE; |
| 49 | |
| 50 | size = sizeof(struct i2o_header) + data_size; |
| 51 | |
| 52 | i2o_size = size / sizeof(u32); |
Dmitry Torokhov | 3110dc7 | 2007-07-17 04:03:58 -0700 | [diff] [blame] | 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | if (size % sizeof(u32)) |
| 55 | i2o_size++; |
| 56 | |
| 57 | return i2o_size; |
Dmitry Torokhov | 3110dc7 | 2007-07-17 04:03:58 -0700 | [diff] [blame] | 58 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | static inline u32 incoming_data_size(struct i2o_message *i2o_message) |
| 61 | { |
| 62 | return (sizeof(u32) * i2o_message->header.message_size); |
| 63 | } |