hv_lp_event.h 5.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2
/*
 * Copyright (C) 2001  Mike Corrigan IBM Corporation
3
 *
L
Linus Torvalds 已提交
4 5 6 7
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
8
 *
L
Linus Torvalds 已提交
9 10 11 12
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
13
 *
L
Linus Torvalds 已提交
14 15 16 17 18
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */

19 20
/* This file contains the class for HV events in the system. */

21 22
#ifndef _ASM_POWERPC_ISERIES_HV_LP_EVENT_H
#define _ASM_POWERPC_ISERIES_HV_LP_EVENT_H
L
Linus Torvalds 已提交
23 24 25

#include <asm/types.h>
#include <asm/ptrace.h>
26
#include <asm/iseries/hv_types.h>
27
#include <asm/iseries/hv_call_event.h>
L
Linus Torvalds 已提交
28

29 30 31 32 33 34
/*
 * HvLpEvent is the structure for Lp Event messages passed between
 * partitions through PLIC.
 */

struct HvLpEvent {
35
	u8	flags;			/* Event flags		      x00-x00 */
36 37 38 39 40 41 42 43
	u8	xType;			/* Type of message	      x01-x01 */
	u16	xSubtype;		/* Subtype for event	      x02-x03 */
	u8	xSourceLp;		/* Source LP		      x04-x04 */
	u8	xTargetLp;		/* Target LP		      x05-x05 */
	u8	xSizeMinus1;		/* Size of Derived class - 1  x06-x06 */
	u8	xRc;			/* RC for Ack flows	      x07-x07 */
	u16	xSourceInstanceId;	/* Source sides instance id   x08-x09 */
	u16	xTargetInstanceId;	/* Target sides instance id   x0A-x0B */
L
Linus Torvalds 已提交
44
	union {
45 46 47
		u32	xSubtypeData;	/* Data usable by the subtype x0C-x0F */
		u16	xSubtypeDataShort[2];	/* Data as 2 shorts */
		u8	xSubtypeDataChar[4];	/* Data as 4 chars */
L
Linus Torvalds 已提交
48 49
	} x;

50
	u64	xCorrelationToken;	/* Unique value for source/type x10-x17 */
L
Linus Torvalds 已提交
51 52
};

O
Olaf Hering 已提交
53
typedef void (*LpEventHandler)(struct HvLpEvent *);
L
Linus Torvalds 已提交
54

55 56 57
/* Register a handler for an event type - returns 0 on success */
extern int HvLpEvent_registerHandler(HvLpEvent_Type eventType,
		LpEventHandler hdlr);
L
Linus Torvalds 已提交
58

59 60 61 62 63 64 65 66 67 68
/*
 * Unregister a handler for an event type
 *
 * This call will sleep until the handler being removed is guaranteed to
 * be no longer executing on any CPU. Do not call with locks held.
 *
 *  returns 0 on success
 *  Unregister will fail if there are any paths open for the type
 */
extern int HvLpEvent_unregisterHandler(HvLpEvent_Type eventType);
L
Linus Torvalds 已提交
69

70 71 72 73 74 75 76 77
/*
 * Open an Lp Event Path for an event type
 * returns 0 on success
 * openPath will fail if there is no handler registered for the event type.
 * The lpIndex specified is the partition index for the target partition
 * (for VirtualIo, VirtualLan and SessionMgr) other types specify zero)
 */
extern int HvLpEvent_openPath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
L
Linus Torvalds 已提交
78

79 80
/*
 * Close an Lp Event Path for a type and partition
81
 * returns 0 on success
82 83
 */
extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
L
Linus Torvalds 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118

#define HvLpEvent_Type_Hypervisor 0
#define HvLpEvent_Type_MachineFac 1
#define HvLpEvent_Type_SessionMgr 2
#define HvLpEvent_Type_SpdIo      3
#define HvLpEvent_Type_VirtualBus 4
#define HvLpEvent_Type_PciIo      5
#define HvLpEvent_Type_RioIo      6
#define HvLpEvent_Type_VirtualLan 7
#define HvLpEvent_Type_VirtualIo  8
#define HvLpEvent_Type_NumTypes   9

#define HvLpEvent_Rc_Good 0
#define HvLpEvent_Rc_BufferNotAvailable 1
#define HvLpEvent_Rc_Cancelled 2
#define HvLpEvent_Rc_GenericError 3
#define HvLpEvent_Rc_InvalidAddress 4
#define HvLpEvent_Rc_InvalidPartition 5
#define HvLpEvent_Rc_InvalidSize 6
#define HvLpEvent_Rc_InvalidSubtype 7
#define HvLpEvent_Rc_InvalidSubtypeData 8
#define HvLpEvent_Rc_InvalidType 9
#define HvLpEvent_Rc_PartitionDead 10
#define HvLpEvent_Rc_PathClosed 11
#define HvLpEvent_Rc_SubtypeError 12

#define HvLpEvent_Function_Ack 0
#define HvLpEvent_Function_Int 1

#define HvLpEvent_AckInd_NoAck 0
#define HvLpEvent_AckInd_DoAck 1

#define HvLpEvent_AckType_ImmediateAck 0
#define HvLpEvent_AckType_DeferredAck 1

119 120 121 122 123
#define HV_LP_EVENT_INT			0x01
#define HV_LP_EVENT_DO_ACK		0x02
#define HV_LP_EVENT_DEFERRED_ACK	0x04
#define HV_LP_EVENT_VALID		0x80

L
Linus Torvalds 已提交
124 125 126 127 128 129 130 131 132 133 134 135 136
#define HvLpDma_Direction_LocalToRemote 0
#define HvLpDma_Direction_RemoteToLocal 1

#define HvLpDma_AddressType_TceIndex 0
#define HvLpDma_AddressType_RealAddress 1

#define HvLpDma_Rc_Good 0
#define HvLpDma_Rc_Error 1
#define HvLpDma_Rc_PartitionDead 2
#define HvLpDma_Rc_PathClosed 3
#define HvLpDma_Rc_InvalidAddress 4
#define HvLpDma_Rc_InvalidLength 5

137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
static inline int hvlpevent_is_valid(struct HvLpEvent *h)
{
	return h->flags & HV_LP_EVENT_VALID;
}

static inline void hvlpevent_invalidate(struct HvLpEvent *h)
{
	h->flags &= ~ HV_LP_EVENT_VALID;
}

static inline int hvlpevent_is_int(struct HvLpEvent *h)
{
	return h->flags & HV_LP_EVENT_INT;
}

static inline int hvlpevent_is_ack(struct HvLpEvent *h)
{
	return !hvlpevent_is_int(h);
}

static inline int hvlpevent_need_ack(struct HvLpEvent *h)
{
	return h->flags & HV_LP_EVENT_DO_ACK;
}

162
#endif /* _ASM_POWERPC_ISERIES_HV_LP_EVENT_H */