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 #pragma pack(1)
0011 struct i2o_header {
0012     u8  version;
0013     u8  message_flags;
0014     u16 message_size;
0015     u8  target;
0016     u8  initiator_and_target;
0017     u8  initiator;
0018     u8  function;
0019     u32 initiator_context;
0020 };
0021 #pragma pack()
0022 
0023 #define I2O_HEADER_TEMPLATE \
0024       { .version              = 0x01, \
0025     .message_flags        = 0x00, \
0026     .function             = 0xFF, \
0027     .initiator            = 0x00, \
0028     .initiator_and_target = 0x40, \
0029     .target               = 0x00, \
0030     .initiator_context    = 0x0 }
0031 
0032 #define I2O_MESSAGE_SIZE    0x1000
0033 #define I2O_COMMAND_SIZE    (I2O_MESSAGE_SIZE - sizeof(struct i2o_header))
0034 
0035 #pragma pack(1)
0036 struct i2o_message {
0037     struct i2o_header   header;
0038     void            *data;
0039 };
0040 #pragma pack()
0041 
0042 static inline unsigned short outgoing_message_size(unsigned int data_size)
0043 {
0044     unsigned int size;
0045     unsigned short i2o_size;
0046 
0047     if (data_size > I2O_COMMAND_SIZE)
0048         data_size = I2O_COMMAND_SIZE;
0049 
0050     size = sizeof(struct i2o_header) + data_size;
0051 
0052     i2o_size = size / sizeof(u32);
0053 
0054     if (size % sizeof(u32))
0055            i2o_size++;
0056 
0057     return i2o_size;
0058 }
0059 
0060 static inline u32 incoming_data_size(struct i2o_message *i2o_message)
0061 {
0062     return (sizeof(u32) * i2o_message->header.message_size);
0063 }