1 /*****************************************************************************
2  *
3  * Name:	skgepnm2.h
4  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5  * Purpose:	Defines for Private Network Management Interface
6  *
7  ****************************************************************************/
8 
9 /******************************************************************************
10  *
11  *	(C)Copyright 1998-2002 SysKonnect GmbH.
12  *	(C)Copyright 2002-2003 Marvell.
13  *
14  *	This program is free software; you can redistribute it and/or modify
15  *	it under the terms of the GNU General Public License as published by
16  *	the Free Software Foundation; either version 2 of the License, or
17  *	(at your option) any later version.
18  *
19  *	The information in this file is provided "AS IS" without warranty.
20  *
21  ******************************************************************************/
22 
23 #ifndef _SKGEPNM2_H_
24 #define _SKGEPNM2_H_
25 
26 /*
27  * General definitions
28  */
29 #define SK_PNMI_CHIPSET_XMAC	1	/* XMAC11800FP */
30 #define SK_PNMI_CHIPSET_YUKON	2	/* YUKON */
31 
32 #define	SK_PNMI_BUS_PCI		1	/* PCI bus*/
33 
34 /*
35  * Actions
36  */
37 #define SK_PNMI_ACT_IDLE		1
38 #define SK_PNMI_ACT_RESET		2
39 #define SK_PNMI_ACT_SELFTEST	3
40 #define SK_PNMI_ACT_RESETCNT	4
41 
42 /*
43  * VPD releated defines
44  */
45 
46 #define SK_PNMI_VPD_RW		1
47 #define SK_PNMI_VPD_RO		2
48 
49 #define SK_PNMI_VPD_OK			0
50 #define SK_PNMI_VPD_NOTFOUND	1
51 #define SK_PNMI_VPD_CUT			2
52 #define SK_PNMI_VPD_TIMEOUT		3
53 #define SK_PNMI_VPD_FULL		4
54 #define SK_PNMI_VPD_NOWRITE		5
55 #define SK_PNMI_VPD_FATAL		6
56 
57 #define SK_PNMI_VPD_IGNORE	0
58 #define SK_PNMI_VPD_CREATE	1
59 #define SK_PNMI_VPD_DELETE	2
60 
61 
62 /*
63  * RLMT related defines
64  */
65 #define SK_PNMI_DEF_RLMT_CHG_THRES	240	/* 4 changes per minute */
66 
67 
68 /*
69  * VCT internal status values
70  */
71 #define SK_PNMI_VCT_PENDING	32
72 #define SK_PNMI_VCT_TEST_DONE	64
73 #define SK_PNMI_VCT_LINK	128
74 
75 /*
76  * Internal table definitions
77  */
78 #define SK_PNMI_GET		0
79 #define SK_PNMI_PRESET	1
80 #define SK_PNMI_SET		2
81 
82 #define SK_PNMI_RO		0
83 #define SK_PNMI_RW		1
84 #define SK_PNMI_WO		2
85 
86 typedef struct s_OidTabEntry {
87 	SK_U32			Id;
88 	SK_U32			InstanceNo;
89 	unsigned int	StructSize;
90 	unsigned int	Offset;
91 	int				Access;
92 	int				(* Func)(SK_AC *pAc, SK_IOC pIo, int action,
93 							 SK_U32 Id, char* pBuf, unsigned int* pLen,
94 							 SK_U32 Instance, unsigned int TableIndex,
95 							 SK_U32 NetNumber);
96 	SK_U16			Param;
97 } SK_PNMI_TAB_ENTRY;
98 
99 
100 /*
101  * Trap lengths
102  */
103 #define SK_PNMI_TRAP_SIMPLE_LEN			17
104 #define SK_PNMI_TRAP_SENSOR_LEN_BASE	46
105 #define SK_PNMI_TRAP_RLMT_CHANGE_LEN	23
106 #define SK_PNMI_TRAP_RLMT_PORT_LEN		23
107 
108 /*
109  * Number of MAC types supported
110  */
111 #define SK_PNMI_MAC_TYPES	(SK_MAC_GMAC + 1)
112 
113 /*
114  * MAC statistic data list (overall set for MAC types used)
115  */
116 enum SK_MACSTATS {
117 	SK_PNMI_HTX				= 0,
118 	SK_PNMI_HTX_OCTET,
119 	SK_PNMI_HTX_OCTETHIGH 	= SK_PNMI_HTX_OCTET,
120 	SK_PNMI_HTX_OCTETLOW,
121 	SK_PNMI_HTX_BROADCAST,
122 	SK_PNMI_HTX_MULTICAST,
123 	SK_PNMI_HTX_UNICAST,
124 	SK_PNMI_HTX_BURST,
125 	SK_PNMI_HTX_PMACC,
126 	SK_PNMI_HTX_MACC,
127 	SK_PNMI_HTX_COL,
128 	SK_PNMI_HTX_SINGLE_COL,
129 	SK_PNMI_HTX_MULTI_COL,
130 	SK_PNMI_HTX_EXCESS_COL,
131 	SK_PNMI_HTX_LATE_COL,
132 	SK_PNMI_HTX_DEFFERAL,
133 	SK_PNMI_HTX_EXCESS_DEF,
134 	SK_PNMI_HTX_UNDERRUN,
135 	SK_PNMI_HTX_CARRIER,
136 	SK_PNMI_HTX_UTILUNDER,
137 	SK_PNMI_HTX_UTILOVER,
138 	SK_PNMI_HTX_64,
139 	SK_PNMI_HTX_127,
140 	SK_PNMI_HTX_255,
141 	SK_PNMI_HTX_511,
142 	SK_PNMI_HTX_1023,
143 	SK_PNMI_HTX_MAX,
144 	SK_PNMI_HTX_LONGFRAMES,
145 	SK_PNMI_HTX_SYNC,
146 	SK_PNMI_HTX_SYNC_OCTET,
147 	SK_PNMI_HTX_RESERVED,
148 
149 	SK_PNMI_HRX,
150 	SK_PNMI_HRX_OCTET,
151 	SK_PNMI_HRX_OCTETHIGH	= SK_PNMI_HRX_OCTET,
152 	SK_PNMI_HRX_OCTETLOW,
153 	SK_PNMI_HRX_BADOCTET,
154 	SK_PNMI_HRX_BADOCTETHIGH = SK_PNMI_HRX_BADOCTET,
155 	SK_PNMI_HRX_BADOCTETLOW,
156 	SK_PNMI_HRX_BROADCAST,
157 	SK_PNMI_HRX_MULTICAST,
158 	SK_PNMI_HRX_UNICAST,
159 	SK_PNMI_HRX_PMACC,
160 	SK_PNMI_HRX_MACC,
161 	SK_PNMI_HRX_PMACC_ERR,
162 	SK_PNMI_HRX_MACC_UNKWN,
163 	SK_PNMI_HRX_BURST,
164 	SK_PNMI_HRX_MISSED,
165 	SK_PNMI_HRX_FRAMING,
166 	SK_PNMI_HRX_UNDERSIZE,
167 	SK_PNMI_HRX_OVERFLOW,
168 	SK_PNMI_HRX_JABBER,
169 	SK_PNMI_HRX_CARRIER,
170 	SK_PNMI_HRX_IRLENGTH,
171 	SK_PNMI_HRX_SYMBOL,
172 	SK_PNMI_HRX_SHORTS,
173 	SK_PNMI_HRX_RUNT,
174 	SK_PNMI_HRX_TOO_LONG,
175 	SK_PNMI_HRX_FCS,
176 	SK_PNMI_HRX_CEXT,
177 	SK_PNMI_HRX_UTILUNDER,
178 	SK_PNMI_HRX_UTILOVER,
179 	SK_PNMI_HRX_64,
180 	SK_PNMI_HRX_127,
181 	SK_PNMI_HRX_255,
182 	SK_PNMI_HRX_511,
183 	SK_PNMI_HRX_1023,
184 	SK_PNMI_HRX_MAX,
185 	SK_PNMI_HRX_LONGFRAMES,
186 
187 	SK_PNMI_HRX_RESERVED,
188 
189 	SK_PNMI_MAX_IDX		/* NOTE: Ensure SK_PNMI_CNT_NO is set to this value */
190 };
191 
192 /*
193  * MAC specific data
194  */
195 typedef struct s_PnmiStatAddr {
196 	SK_U16		Reg;		/* MAC register containing the value */
197 	SK_BOOL		GetOffset;	/* TRUE: Offset managed by PNMI (call GetStatVal())*/
198 } SK_PNMI_STATADDR;
199 
200 
201 /*
202  * SK_PNMI_STRUCT_DATA copy offset evaluation macros
203  */
204 #define SK_PNMI_OFF(e)		((SK_U32)(SK_UPTR)&(((SK_PNMI_STRUCT_DATA *)0)->e))
205 #define SK_PNMI_MAI_OFF(e)	((SK_U32)(SK_UPTR)&(((SK_PNMI_STRUCT_DATA *)0)->e))
206 #define SK_PNMI_VPD_OFF(e)	((SK_U32)(SK_UPTR)&(((SK_PNMI_VPD *)0)->e))
207 #define SK_PNMI_SEN_OFF(e)	((SK_U32)(SK_UPTR)&(((SK_PNMI_SENSOR *)0)->e))
208 #define SK_PNMI_CHK_OFF(e)	((SK_U32)(SK_UPTR)&(((SK_PNMI_CHECKSUM *)0)->e))
209 #define SK_PNMI_STA_OFF(e)	((SK_U32)(SK_UPTR)&(((SK_PNMI_STAT *)0)->e))
210 #define SK_PNMI_CNF_OFF(e)	((SK_U32)(SK_UPTR)&(((SK_PNMI_CONF *)0)->e))
211 #define SK_PNMI_RLM_OFF(e)	((SK_U32)(SK_UPTR)&(((SK_PNMI_RLMT *)0)->e))
212 #define SK_PNMI_MON_OFF(e)	((SK_U32)(SK_UPTR)&(((SK_PNMI_RLMT_MONITOR *)0)->e))
213 #define SK_PNMI_TRP_OFF(e)	((SK_U32)(SK_UPTR)&(((SK_PNMI_TRAP *)0)->e))
214 
215 #define SK_PNMI_SET_STAT(b,s,o)	{SK_U32	Val32; char *pVal; \
216 					Val32 = (s); \
217 					pVal = (char *)(b) + ((SK_U32)(SK_UPTR) \
218 						&(((SK_PNMI_STRUCT_DATA *)0)-> \
219 						ReturnStatus.ErrorStatus)); \
220 					SK_PNMI_STORE_U32(pVal, Val32); \
221 					Val32 = (o); \
222 					pVal = (char *)(b) + ((SK_U32)(SK_UPTR) \
223 						&(((SK_PNMI_STRUCT_DATA *)0)-> \
224 						ReturnStatus.ErrorOffset)); \
225 					SK_PNMI_STORE_U32(pVal, Val32);}
226 
227 /*
228  * Time macros
229  */
230 #ifndef SK_PNMI_HUNDREDS_SEC
231 #if SK_TICKS_PER_SEC == 100
232 #define SK_PNMI_HUNDREDS_SEC(t)	(t)
233 #else
234 #define SK_PNMI_HUNDREDS_SEC(t)	(((t) * 100) / (SK_TICKS_PER_SEC))
235 #endif /* !SK_TICKS_PER_SEC */
236 #endif /* !SK_PNMI_HUNDREDS_SEC */
237 
238 /*
239  * Macros to work around alignment problems
240  */
241 #ifndef SK_PNMI_STORE_U16
242 #define SK_PNMI_STORE_U16(p,v)	{*(char *)(p) = *((char *)&(v)); \
243 					*((char *)(p) + 1) = \
244 						*(((char *)&(v)) + 1);}
245 #endif
246 
247 #ifndef SK_PNMI_STORE_U32
248 #define SK_PNMI_STORE_U32(p,v)	{*(char *)(p) = *((char *)&(v)); \
249 					*((char *)(p) + 1) = \
250 						*(((char *)&(v)) + 1); \
251 					*((char *)(p) + 2) = \
252 						*(((char *)&(v)) + 2); \
253 					*((char *)(p) + 3) = \
254 						*(((char *)&(v)) + 3);}
255 #endif
256 
257 #ifndef SK_PNMI_STORE_U64
258 #define SK_PNMI_STORE_U64(p,v)	{*(char *)(p) = *((char *)&(v)); \
259 					*((char *)(p) + 1) = \
260 						*(((char *)&(v)) + 1); \
261 					*((char *)(p) + 2) = \
262 						*(((char *)&(v)) + 2); \
263 					*((char *)(p) + 3) = \
264 						*(((char *)&(v)) + 3); \
265 					*((char *)(p) + 4) = \
266 						*(((char *)&(v)) + 4); \
267 					*((char *)(p) + 5) = \
268 						*(((char *)&(v)) + 5); \
269 					*((char *)(p) + 6) = \
270 						*(((char *)&(v)) + 6); \
271 					*((char *)(p) + 7) = \
272 						*(((char *)&(v)) + 7);}
273 #endif
274 
275 #ifndef SK_PNMI_READ_U16
276 #define SK_PNMI_READ_U16(p,v)	{*((char *)&(v)) = *(char *)(p); \
277 					*(((char *)&(v)) + 1) = \
278 						*((char *)(p) + 1);}
279 #endif
280 
281 #ifndef SK_PNMI_READ_U32
282 #define SK_PNMI_READ_U32(p,v)	{*((char *)&(v)) = *(char *)(p); \
283 					*(((char *)&(v)) + 1) = \
284 						*((char *)(p) + 1); \
285 					*(((char *)&(v)) + 2) = \
286 						*((char *)(p) + 2); \
287 					*(((char *)&(v)) + 3) = \
288 						*((char *)(p) + 3);}
289 #endif
290 
291 #ifndef SK_PNMI_READ_U64
292 #define SK_PNMI_READ_U64(p,v)	{*((char *)&(v)) = *(char *)(p); \
293 					*(((char *)&(v)) + 1) = \
294 						*((char *)(p) + 1); \
295 					*(((char *)&(v)) + 2) = \
296 						*((char *)(p) + 2); \
297 					*(((char *)&(v)) + 3) = \
298 						*((char *)(p) + 3); \
299 					*(((char *)&(v)) + 4) = \
300 						*((char *)(p) + 4); \
301 					*(((char *)&(v)) + 5) = \
302 						*((char *)(p) + 5); \
303 					*(((char *)&(v)) + 6) = \
304 						*((char *)(p) + 6); \
305 					*(((char *)&(v)) + 7) = \
306 						*((char *)(p) + 7);}
307 #endif
308 
309 /*
310  * Macros for Debug
311  */
312 #ifdef DEBUG
313 
314 #define SK_PNMI_CHECKFLAGS(vSt)	{if (pAC->Pnmi.MacUpdatedFlag > 0 || \
315 					pAC->Pnmi.RlmtUpdatedFlag > 0 || \
316 					pAC->Pnmi.SirqUpdatedFlag > 0) { \
317 						SK_DBG_MSG(pAC, \
318 						SK_DBGMOD_PNMI, \
319 						SK_DBGCAT_CTRL,	\
320 						("PNMI: ERR: %s MacUFlag=%d, RlmtUFlag=%d, SirqUFlag=%d\n", \
321 						vSt, \
322 						pAC->Pnmi.MacUpdatedFlag, \
323 						pAC->Pnmi.RlmtUpdatedFlag, \
324 						pAC->Pnmi.SirqUpdatedFlag))}}
325 
326 #else	/* !DEBUG */
327 
328 #define SK_PNMI_CHECKFLAGS(vSt)	/* Nothing */
329 
330 #endif	/* !DEBUG */
331 
332 #endif	/* _SKGEPNM2_H_ */
333