blob: 468fa84a3257f396da7d859060c6af936fbeb967 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * IBM ASM Service Processor Device Driver
4 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Copyright (C) IBM Corporation, 2004
6 *
Al Virod36b6912011-12-29 17:09:01 -05007 * Author: Max Asböck <amax@us.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
10#pragma pack(1)
11struct i2o_header {
12 u8 version;
13 u8 message_flags;
14 u16 message_size;
Dmitry Torokhov3110dc72007-07-17 04:03:58 -070015 u8 target;
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 u8 initiator_and_target;
Dmitry Torokhov3110dc72007-07-17 04:03:58 -070017 u8 initiator;
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 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)
36struct i2o_message {
37 struct i2o_header header;
38 void *data;
39};
40#pragma pack()
41
42static 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 Torokhov3110dc72007-07-17 04:03:58 -070053
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 if (size % sizeof(u32))
55 i2o_size++;
56
57 return i2o_size;
Dmitry Torokhov3110dc72007-07-17 04:03:58 -070058}
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60static inline u32 incoming_data_size(struct i2o_message *i2o_message)
61{
62 return (sizeof(u32) * i2o_message->header.message_size);
63}