added a lot of printk output to ease writing of emulator
[linux-2.4.21-pre4.git] / drivers / iseries / veth.h
1 /* File veth.h created by Kyle A. Lucke on Mon Aug  7 2000. */
2
3 /* Change Activity: */
4 /* End Change Activity */
5
6 #ifndef _VETH_H
7 #define _VETH_H
8
9 #ifndef _HVTYPES_H
10 #include <asm/iSeries/HvTypes.h>
11 #endif
12 #ifndef _HVLPEVENT_H
13 #include <asm/iSeries/HvLpEvent.h>
14 #endif
15 #include <linux/netdevice.h>
16
17 #define VethEventNumTypes (4)
18 #define VethEventTypeCap (0)
19 #define VethEventTypeFrames (1)
20 #define VethEventTypeMonitor (2)
21 #define VethEventTypeFramesAck (3)
22
23 #define VethMaxFramesMsgsAcked (20)
24 #define VethMaxFramesMsgs (0xFFFF)
25 #define VethMaxFramesPerMsg (6)
26 #define VethAckTimeoutUsec (1000000)
27
28 #define VETHSTACKTYPE(T) struct VethStack##T
29 #define VETHSTACK(T) \
30 VETHSTACKTYPE(T) \
31 { \
32 struct T *head; \
33 spinlock_t lock; \
34 }
35 #define VETHSTACKCTOR(s) do { (s)->head = NULL; spin_lock_init(&(s)->lock); } while(0)
36 #define VETHSTACKPUSH(s, p) \
37 do { \
38 unsigned long flags; \
39 spin_lock_irqsave(&(s)->lock,flags); \
40 (p)->next = (s)->head; \
41 (s)->head = (p); \
42 spin_unlock_irqrestore(&(s)->lock, flags); \
43 } while(0)
44
45 #define VETHSTACKPOP(s,p) \
46 do { \
47 unsigned long flags; \
48 spin_lock_irqsave(&(s)->lock,flags); \
49 (p) = (s)->head; \
50 if ((s)->head != NULL) \
51 { \
52 (s)->head = (s)->head->next; \
53 } \
54 spin_unlock_irqrestore(&(s)->lock, flags); \
55 } while(0)
56
57 #define VETHQUEUE(T) \
58 struct VethQueue##T \
59 { \
60 T *head; \
61 T *tail; \
62 spinlock_t lock; \
63 }
64 #define VETHQUEUECTOR(q) do { (q)->head = NULL; (q)->tail = NULL; spin_lock_init(&(q)->lock); } while(0)
65 #define VETHQUEUEENQ(q, p) \
66 do { \
67 unsigned long flags; \
68 spin_lock_irqsave(&(q)->lock,flags); \
69 (p)->next = NULL; \
70 if ((q)->head != NULL) \
71 { \
72 (q)->head->next = (p); \
73 (q)->head = (p); \
74 } \
75 else \
76 { \
77 (q)->tail = (q)->head = (p); \
78 } \
79 spin_unlock_irqrestore(&(q)->lock, flags); \
80 } while(0)
81
82 #define VETHQUEUEDEQ(q,p) \
83 do { \
84 unsigned long flags; \
85 spin_lock_irqsave(&(q)->lock,flags); \
86 (p) = (q)->tail; \
87 if ((p) != NULL) \
88 { \
89 (q)->tail = (p)->next; \
90 (p)->next = NULL; \
91 } \
92 if ((q)->tail == NULL) \
93 (q)->head = NULL; \
94 spin_unlock_irqrestore(&(q)->lock, flags); \
95 } while(0)
96
97 struct VethFramesData
98 {
99     u32 mAddress[6];
100     u16 mLength[6];
101     u32 mEofMask;
102 };
103
104 struct VethFramesAckData
105 {
106     u16 mToken[VethMaxFramesMsgsAcked];
107 };
108
109 struct VethCapData
110 {
111     union
112     {
113         struct Fields
114         {
115             u8 mVersion;
116             u8 mReserved1;
117             u16 mNumberBuffers;
118             u16 mThreshold;
119             u16 mReserved2;
120             u32 mTimer;
121             u32 mReserved3;
122             u64 mReserved4;
123             u64 mReserved5;
124             u64 mReserved6;
125         } mFields;
126         struct NoFields
127         {
128             u64 mReserved1;
129             u64 mReserved2;
130             u64 mReserved3;
131             u64 mReserved4;
132             u64 mReserved5;
133         } mNoFields;
134     } mUnionData;
135 };
136
137 struct VethFastPathData
138 {
139     u64 mData1;
140     u64 mData2;
141     u64 mData3;
142     u64 mData4;
143     u64 mData5;
144 };
145
146 struct VethLpEvent
147 {
148     struct HvLpEvent mBaseEvent;
149     union {                                             
150         struct VethFramesData mSendData;
151         struct VethCapData mCapabilitiesData;
152         struct VethFramesAckData mFramesAckData;
153         struct VethFastPathData mFastPathData;
154     } mDerivedData;
155
156 };
157
158 struct VethMsg
159 {
160     struct VethMsg *next;
161     union {
162         struct VethFramesData mSendData;
163         struct VethFastPathData mFpData;
164     } mEvent;
165     int mIndex;
166     unsigned long mInUse;
167     struct sk_buff *mSkb;
168 };
169
170
171 struct VethControlBlock
172 {
173     struct net_device   *mDev;
174     struct VethControlBlock *mNext;
175     HvLpVirtualLanIndex mVlanId;
176 };
177
178 struct VethLpConnection
179 {
180     u64 mEyecatcher;
181     HvLpIndex mRemoteLp;
182     HvLpInstanceId mSourceInst;
183     HvLpInstanceId mTargetInst;
184     u32 mNumMsgs;
185     struct VethMsg *mMsgs;
186     int mNumberRcvMsgs;
187     int mNumberLpAcksAlloced;
188     union
189     {
190         struct VethFramesAckData mAckData;
191         struct VethFastPathData mFpData;
192     } mEventData;
193     spinlock_t mAckGate;
194     u32 mNumAcks;
195     spinlock_t mStatusGate;
196     struct
197     {
198         u64 mOpen : 1;
199         u64 mCapMonAlloced : 1;
200         u64 mBaseMsgsAlloced : 1;
201         u64 mSentCap : 1;
202         u64 mCapAcked : 1;
203         u64 mGotCap : 1;
204         u64 mGotCapAcked : 1;
205         u64 mSentMonitor : 1;
206         u64 mPopulatedRings : 1;
207         u64 mReserved : 54;
208         u64 mFailed : 1;
209     } mConnectionStatus;
210     struct VethCapData mMyCap;
211     struct VethCapData mRemoteCap;
212     unsigned long mCapAckBhPending;
213     struct tq_struct mCapAckBhTq;
214     struct VethLpEvent mCapAckEvent;
215     unsigned long mCapBhPending;
216     struct tq_struct mCapBhTq;
217     struct VethLpEvent mCapEvent;
218     unsigned long mMonitorAckBhPending;
219     struct tq_struct mMonitorAckBhTq;
220     struct VethLpEvent mMonitorAckEvent;
221     unsigned long mAllocBhPending;
222     struct tq_struct mAllocBhTq;
223     int mNumberAllocated;
224     struct timer_list mAckTimer;
225     u32 mTimeout;
226     VETHSTACK(VethMsg) mMsgStack;
227 };
228 #define HVMAXARCHITECTEDVIRTUALLANS 16
229 struct VethPort
230 {
231     struct net_device *mDev;
232     struct net_device_stats mStats;
233     int mLock;
234     u64 mMyAddress;
235     int mPromiscuous;
236     int mAllMcast;
237     rwlock_t mMcastGate;
238     int mNumAddrs;
239     u64 mMcasts[12];
240 };
241
242 struct VethFabricMgr
243 {
244     u64 mEyecatcher;
245     HvLpIndex mThisLp;
246     struct VethLpConnection mConnection[HVMAXARCHITECTEDLPS];
247     spinlock_t mPortListGate;
248     u64 mNumPorts;
249     struct VethPort *mPorts[HVMAXARCHITECTEDVIRTUALLANS];
250 };
251
252 int proc_veth_dump_connection(char *page, char **start, off_t off, int count, int *eof, void *data);
253 int proc_veth_dump_port(char *page, char **start, off_t off, int count, int *eof, void *data);
254
255 #endif /* _VETH_H */