blob: 6ce2ce1e26909a0bc80bf84c772d6cc5338c4b77 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2001 Mike Corrigan IBM Corporation
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07003 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07008 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070013 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070019/* This file contains the class for HV events in the system. */
20
Kelly Dalyecb3ca272005-11-02 15:53:01 +110021#ifndef _ASM_POWERPC_ISERIES_HV_LP_EVENT_H
22#define _ASM_POWERPC_ISERIES_HV_LP_EVENT_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24#include <asm/types.h>
25#include <asm/ptrace.h>
Kelly Daly1ec65d72005-11-02 13:46:07 +110026#include <asm/iseries/hv_types.h>
Kelly Dalyc0a8d052005-11-02 11:11:11 +110027#include <asm/iseries/hv_call_event.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070029/*
30 * HvLpEvent is the structure for Lp Event messages passed between
31 * partitions through PLIC.
32 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070034struct HvLpEvent {
Stephen Rothwell677f8c02006-01-12 13:47:43 +110035 u8 flags; /* Event flags x00-x00 */
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070036 u8 xType; /* Type of message x01-x01 */
37 u16 xSubtype; /* Subtype for event x02-x03 */
38 u8 xSourceLp; /* Source LP x04-x04 */
39 u8 xTargetLp; /* Target LP x05-x05 */
40 u8 xSizeMinus1; /* Size of Derived class - 1 x06-x06 */
41 u8 xRc; /* RC for Ack flows x07-x07 */
42 u16 xSourceInstanceId; /* Source sides instance id x08-x09 */
43 u16 xTargetInstanceId; /* Target sides instance id x0A-x0B */
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 union {
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070045 u32 xSubtypeData; /* Data usable by the subtype x0C-x0F */
46 u16 xSubtypeDataShort[2]; /* Data as 2 shorts */
47 u8 xSubtypeDataChar[4]; /* Data as 4 chars */
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 } x;
49
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070050 u64 xCorrelationToken; /* Unique value for source/type x10-x17 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051};
52
Olaf Hering35a84c22006-10-07 22:08:26 +100053typedef void (*LpEventHandler)(struct HvLpEvent *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070055/* Register a handler for an event type - returns 0 on success */
56extern int HvLpEvent_registerHandler(HvLpEvent_Type eventType,
57 LpEventHandler hdlr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070059/*
60 * Unregister a handler for an event type
61 *
62 * This call will sleep until the handler being removed is guaranteed to
63 * be no longer executing on any CPU. Do not call with locks held.
64 *
65 * returns 0 on success
66 * Unregister will fail if there are any paths open for the type
67 */
68extern int HvLpEvent_unregisterHandler(HvLpEvent_Type eventType);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070070/*
71 * Open an Lp Event Path for an event type
72 * returns 0 on success
73 * openPath will fail if there is no handler registered for the event type.
74 * The lpIndex specified is the partition index for the target partition
75 * (for VirtualIo, VirtualLan and SessionMgr) other types specify zero)
76 */
77extern int HvLpEvent_openPath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070079/*
80 * Close an Lp Event Path for a type and partition
81 * returns 0 on sucess
82 */
83extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85#define HvLpEvent_Type_Hypervisor 0
86#define HvLpEvent_Type_MachineFac 1
87#define HvLpEvent_Type_SessionMgr 2
88#define HvLpEvent_Type_SpdIo 3
89#define HvLpEvent_Type_VirtualBus 4
90#define HvLpEvent_Type_PciIo 5
91#define HvLpEvent_Type_RioIo 6
92#define HvLpEvent_Type_VirtualLan 7
93#define HvLpEvent_Type_VirtualIo 8
94#define HvLpEvent_Type_NumTypes 9
95
96#define HvLpEvent_Rc_Good 0
97#define HvLpEvent_Rc_BufferNotAvailable 1
98#define HvLpEvent_Rc_Cancelled 2
99#define HvLpEvent_Rc_GenericError 3
100#define HvLpEvent_Rc_InvalidAddress 4
101#define HvLpEvent_Rc_InvalidPartition 5
102#define HvLpEvent_Rc_InvalidSize 6
103#define HvLpEvent_Rc_InvalidSubtype 7
104#define HvLpEvent_Rc_InvalidSubtypeData 8
105#define HvLpEvent_Rc_InvalidType 9
106#define HvLpEvent_Rc_PartitionDead 10
107#define HvLpEvent_Rc_PathClosed 11
108#define HvLpEvent_Rc_SubtypeError 12
109
110#define HvLpEvent_Function_Ack 0
111#define HvLpEvent_Function_Int 1
112
113#define HvLpEvent_AckInd_NoAck 0
114#define HvLpEvent_AckInd_DoAck 1
115
116#define HvLpEvent_AckType_ImmediateAck 0
117#define HvLpEvent_AckType_DeferredAck 1
118
Stephen Rothwell677f8c02006-01-12 13:47:43 +1100119#define HV_LP_EVENT_INT 0x01
120#define HV_LP_EVENT_DO_ACK 0x02
121#define HV_LP_EVENT_DEFERRED_ACK 0x04
122#define HV_LP_EVENT_VALID 0x80
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124#define HvLpDma_Direction_LocalToRemote 0
125#define HvLpDma_Direction_RemoteToLocal 1
126
127#define HvLpDma_AddressType_TceIndex 0
128#define HvLpDma_AddressType_RealAddress 1
129
130#define HvLpDma_Rc_Good 0
131#define HvLpDma_Rc_Error 1
132#define HvLpDma_Rc_PartitionDead 2
133#define HvLpDma_Rc_PathClosed 3
134#define HvLpDma_Rc_InvalidAddress 4
135#define HvLpDma_Rc_InvalidLength 5
136
Stephen Rothwell677f8c02006-01-12 13:47:43 +1100137static inline int hvlpevent_is_valid(struct HvLpEvent *h)
138{
139 return h->flags & HV_LP_EVENT_VALID;
140}
141
142static inline void hvlpevent_invalidate(struct HvLpEvent *h)
143{
144 h->flags &= ~ HV_LP_EVENT_VALID;
145}
146
147static inline int hvlpevent_is_int(struct HvLpEvent *h)
148{
149 return h->flags & HV_LP_EVENT_INT;
150}
151
152static inline int hvlpevent_is_ack(struct HvLpEvent *h)
153{
154 return !hvlpevent_is_int(h);
155}
156
157static inline int hvlpevent_need_ack(struct HvLpEvent *h)
158{
159 return h->flags & HV_LP_EVENT_DO_ACK;
160}
161
Kelly Dalyecb3ca272005-11-02 15:53:01 +1100162#endif /* _ASM_POWERPC_ISERIES_HV_LP_EVENT_H */