brintos

brintos / linux-shallow public Read only

0
0
Text · 1.3 KiB · 468fa84 Raw
64 lines · c
1/* SPDX-License-Identifier: GPL-2.0-or-later */2/*3 * IBM ASM Service Processor Device Driver4 *5 * Copyright (C) IBM Corporation, 20046 *7 * Author: Max Asböck <amax@us.ibm.com>8 */9 10#pragma pack(1)11struct i2o_header {12	u8	version;13	u8	message_flags;14	u16	message_size;15	u8	target;16	u8	initiator_and_target;17	u8	initiator;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	0x100033#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);53 54	if (size % sizeof(u32))55	       i2o_size++;56 57	return i2o_size;58}59 60static inline u32 incoming_data_size(struct i2o_message *i2o_message)61{62	return (sizeof(u32) * i2o_message->header.message_size);63}64