1/******************************************************************************
2 *
3 * Name:	skrlmt.h
4 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5 * Version:	$Revision: 1.1.1.1 $
6 * Date:	$Date: 2008/10/15 03:26:44 $
7 * Purpose:	Header file for Redundant Link ManagemenT.
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 *	(C)Copyright 1998-2001 SysKonnect GmbH.
14 *
15 *	This program is free software; you can redistribute it and/or modify
16 *	it under the terms of the GNU General Public License as published by
17 *	the Free Software Foundation; either version 2 of the License, or
18 *	(at your option) any later version.
19 *
20 *	The information in this file is provided "AS IS" without warranty.
21 *
22 ******************************************************************************/
23
24/******************************************************************************
25 *
26 * History:
27 *
28 *	$Log: skrlmt.h,v $
29 *	Revision 1.1.1.1  2008/10/15 03:26:44  james26_jang
30 *	Initial.
31 *
32 *	Revision 1.1.1.1  2008/07/21 09:15:07  james26_jang
33 *	New UI, New QoS, New wireless driver(4.151.10.29), ipmonitor.
34 *
35 *	Revision 1.1  2008/07/17 12:43:35  james26_jang
36 *	*** empty log message ***
37 *
38 *	Revision 1.1.1.1  2007/02/15 12:11:35  jiahao
39 *	initial update
40 *
41 *	Revision 1.1.1.1  2007/01/25 12:51:56  jiahao_jhou
42 *
43 *
44 *	Revision 1.1.1.1  2003/02/03 22:37:48  mhuang
45 *	LINUX_2_4 branch snapshot from linux-mips.org CVS
46 *
47 *	Revision 1.32  2001/02/14 14:06:31  rassmann
48 *	Editorial changes.
49 *
50 *	Revision 1.31  2001/02/05 14:25:26  rassmann
51 *	Prepared RLMT for transparent operation.
52 *
53 *	Revision 1.30  2001/01/22 13:41:39  rassmann
54 *	Supporting two nets on dual-port adapters.
55 *
56 *	Revision 1.29  2000/11/17 08:58:00  rassmann
57 *	Moved CheckSwitch from SK_RLMT_PACKET_RECEIVED to SK_RLMT_TIM event.
58 *
59 *	Revision 1.28  2000/11/09 12:24:34  rassmann
60 *	Editorial changes.
61 *
62 *	Revision 1.27  1999/11/22 13:59:56  cgoos
63 *	Changed license header to GPL.
64 *
65 *	Revision 1.26  1999/10/04 14:01:19  rassmann
66 *	Corrected reaction to reception of BPDU frames (#10441).
67 *
68 *	Revision 1.25  1999/07/20 12:53:39  rassmann
69 *	Fixed documentation errors for lookahead macros.
70 *
71 *	Revision 1.24  1999/05/28 11:15:56  rassmann
72 *	Changed behaviour to reflect Design Spec v1.2.
73 *	Controlling Link LED(s).
74 *	Introduced RLMT Packet Version field in RLMT Packet.
75 *	Newstyle lookahead macros (checking meta-information before looking at
76 *	  the packet).
77 *
78 *	Revision 1.23  1999/01/28 12:50:42  rassmann
79 *	Not using broadcast time stamps in CheckLinkState mode.
80 *
81 *	Revision 1.22  1999/01/27 14:13:04  rassmann
82 *	Monitoring broadcast traffic.
83 *	Switching more reliably and not too early if switch is
84 *	 configured for spanning tree.
85 *
86 *	Revision 1.21  1998/12/08 13:11:25  rassmann
87 *	Stopping SegTimer at RlmtStop.
88 *
89 *	Revision 1.20  1998/11/24 12:37:33  rassmann
90 *	Implemented segmentation check.
91 *
92 *	Revision 1.19  1998/11/17 13:43:06  rassmann
93 *	Handling (logical) tx failure.
94 *	Sending packet on logical address after PORT_SWITCH.
95 *
96 *	Revision 1.18  1998/11/13 16:56:56  rassmann
97 *	Added macro version of SkRlmtLookaheadPacket.
98 *
99 *	Revision 1.17  1998/11/06 18:06:05  rassmann
100 *	Corrected timing when RLMT checks fail.
101 *	Clearing tx counter earlier in periodical checks.
102 *
103 *	Revision 1.16  1998/11/03 13:53:50  rassmann
104 *	RLMT should switch now (at least in mode 3).
105 *
106 *	Revision 1.15  1998/10/22 11:39:52  rassmann
107 *	Corrected signed/unsigned mismatches.
108 *	Corrected receive list handling and address recognition.
109 *
110 *	Revision 1.14  1998/10/15 15:16:36  rassmann
111 *	Finished Spanning Tree checking.
112 *	Checked with lint.
113 *
114 *	Revision 1.13  1998/09/24 19:16:08  rassmann
115 *	Code cleanup.
116 *	Introduced Timer for PORT_DOWN due to no RX.
117 *
118 *	Revision 1.12  1998/09/16 11:09:52  rassmann
119 *	Syntax corrections.
120 *
121 *	Revision 1.11  1998/09/15 11:28:50  rassmann
122 *	Syntax corrections.
123 *
124 *	Revision 1.10  1998/09/14 17:07:38  rassmann
125 *	Added code for port checking via LAN.
126 *	Changed Mbuf definition.
127 *
128 *	Revision 1.9  1998/09/07 11:14:15  rassmann
129 *	Syntax corrections.
130 *
131 *	Revision 1.8  1998/09/07 09:06:08  rassmann
132 *	Syntax corrections.
133 *
134 *	Revision 1.7  1998/09/04 19:41:34  rassmann
135 *	Syntax corrections.
136 *	Started entering code for checking local links.
137 *
138 *	Revision 1.6  1998/09/04 12:14:28  rassmann
139 *	Interface cleanup.
140 *
141 *	Revision 1.5  1998/09/02 16:55:29  rassmann
142 *	Updated to reflect new DRV/HWAC/RLMT interface.
143 *
144 *	Revision 1.4  1998/09/02 07:26:02  afischer
145 *	typedef for SK_RLMT_PORT
146 *
147 *	Revision 1.3  1998/08/27 14:29:03  rassmann
148 *	Code cleanup.
149 *
150 *	Revision 1.2  1998/08/27 14:26:25  rassmann
151 *	Updated interface.
152 *
153 *	Revision 1.1  1998/08/21 08:29:10  rassmann
154 *	First public version.
155 *
156 ******************************************************************************/
157
158/******************************************************************************
159 *
160 * Description:
161 *
162 * This is the header file for Redundant Link ManagemenT.
163 *
164 * Include File Hierarchy:
165 *
166 *	"skdrv1st.h"
167 *	...
168 *	"sktypes.h"
169 *	"skqueue.h"
170 *	"skaddr.h"
171 *	"skrlmt.h"
172 *	...
173 *	"skdrv2nd.h"
174 *
175 ******************************************************************************/
176
177#ifndef __INC_SKRLMT_H
178#define __INC_SKRLMT_H
179
180#ifdef __cplusplus
181#error C++ is not yet supported.
182extern "C" {
183#endif	/* cplusplus */
184
185/* defines ********************************************************************/
186
187#define	SK_RLMT_NET_DOWN_TEMP	1	/* NET_DOWN due to last port down. */
188#define	SK_RLMT_NET_DOWN_FINAL	2	/* NET_DOWN due to RLMT_STOP. */
189
190/* ----- Default queue sizes - must be multiples of 8 KB ----- */
191
192/* Less than 8 KB free in RX queue => pause frames. */
193#define SK_RLMT_STANDBY_QRXSIZE	128	/* Size of rx standby queue in KB. */
194#define SK_RLMT_STANDBY_QXASIZE	32	/* Size of async standby queue in KB. */
195#define SK_RLMT_STANDBY_QXSSIZE	0	/* Size of sync standby queue in KB. */
196
197#define SK_RLMT_MAX_TX_BUF_SIZE	60	/* Maximum RLMT transmit size. */
198
199/* ----- PORT states ----- */
200
201#define SK_RLMT_PS_INIT			0	/* Port state: Init. */
202#define SK_RLMT_PS_LINK_DOWN	1	/* Port state: Link down. */
203#define SK_RLMT_PS_DOWN			2	/* Port state: Port down. */
204#define SK_RLMT_PS_GOING_UP		3	/* Port state: Going up. */
205#define SK_RLMT_PS_UP			4	/* Port state: Up. */
206
207/* ----- RLMT states ----- */
208
209#define SK_RLMT_RS_INIT			0	/* RLMT state: Init. */
210#define SK_RLMT_RS_NET_DOWN		1	/* RLMT state: Net down. */
211#define SK_RLMT_RS_NET_UP		2	/* RLMT state: Net up. */
212
213/* ----- PORT events ----- */
214
215#define SK_RLMT_LINK_UP			1001	/* Link came up. */
216#define SK_RLMT_LINK_DOWN		1002	/* Link went down. */
217#define SK_RLMT_PORT_ADDR		1003	/* Port address changed. */
218
219/* ----- RLMT events ----- */
220
221#define SK_RLMT_START			2001	/* Start RLMT. */
222#define SK_RLMT_STOP			2002	/* Stop RLMT. */
223#define SK_RLMT_PACKET_RECEIVED	2003	/* Packet was received for RLMT. */
224#define SK_RLMT_STATS_CLEAR		2004	/* Clear statistics. */
225#define SK_RLMT_STATS_UPDATE	2005	/* Update statistics. */
226#define SK_RLMT_PREFPORT_CHANGE	2006	/* Change preferred port. */
227#define SK_RLMT_MODE_CHANGE		2007	/* New RlmtMode. */
228#define SK_RLMT_SET_NETS		2008	/* Number of Nets (1 or 2). */
229
230/* ----- RLMT mode bits ----- */
231
232/*
233 * CAUTION:	These defines are private to RLMT.
234 *			Please use the RLMT mode defines below.
235 */
236
237#define SK_RLMT_CHECK_LINK		  1		/* Check Link. */
238#define SK_RLMT_CHECK_LOC_LINK	  2		/* Check other link on same adapter. */
239#define SK_RLMT_CHECK_SEG		  4		/* Check segmentation. */
240
241#ifndef RLMT_CHECK_REMOTE
242#define SK_RLMT_CHECK_OTHERS	SK_RLMT_CHECK_LOC_LINK
243#else	/* RLMT_CHECK_REMOTE */
244#define SK_RLMT_CHECK_REM_LINK	  8		/* Check link(s) on other adapter(s). */
245#define SK_RLMT_MAX_REMOTE_PORTS_CHECKED	3
246#define SK_RLMT_CHECK_OTHERS	\
247		(SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK)
248#endif	/* RLMT_CHECK_REMOTE */
249
250#ifndef SK_RLMT_ENABLE_TRANSPARENT
251#define SK_RLMT_TRANSPARENT		  0		/* RLMT transparent - inactive. */
252#else	/* SK_RLMT_ENABLE_TRANSPARENT */
253#define SK_RLMT_TRANSPARENT		128		/* RLMT transparent. */
254#endif	/* SK_RLMT_ENABLE_TRANSPARENT */
255
256/* ----- RLMT modes ----- */
257
258/* Check Link State. */
259#define SK_RLMT_MODE_CLS	(SK_RLMT_CHECK_LINK)
260
261/* Check Local Ports: check other links on the same adapter. */
262#define SK_RLMT_MODE_CLP	(SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK)
263
264/* Check Local Ports and Segmentation Status. */
265#define SK_RLMT_MODE_CLPSS	\
266		(SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_SEG)
267
268#ifdef RLMT_CHECK_REMOTE
269/* Check Local and Remote Ports: check links (local or remote). */
270	Name of define TBD!
271#define SK_RLMT_MODE_CRP	\
272		(SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK)
273
274/* Check Local and Remote Ports and Segmentation Status. */
275	Name of define TBD!
276#define SK_RLMT_MODE_CRPSS	\
277		(SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | \
278		SK_RLMT_CHECK_REM_LINK | SK_RLMT_CHECK_SEG)
279#endif	/* RLMT_CHECK_REMOTE */
280
281/* ----- RLMT lookahead result bits ----- */
282
283#define SK_RLMT_RX_RLMT			1	/* Give packet to RLMT. */
284#define SK_RLMT_RX_PROTOCOL		2	/* Give packet to protocol. */
285
286/* Macros */
287
288
289#define SK_RLMT_PRE_LOOKAHEAD(pAC,PortNum,PktLen,IsBc,pOffset,pNumBytes) { \
290	SK_AC	*_pAC; \
291	SK_U32	_PortNum; \
292	_pAC = (pAC); \
293	_PortNum = (SK_U32)(PortNum); \
294	/* _pAC->Rlmt.Port[_PortNum].PacketsRx++; */ \
295	_pAC->Rlmt.Port[_PortNum].PacketsPerTimeSlot++; \
296	if ((_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_TRANSPARENT) != 0) { \
297		*(pNumBytes) = 0; \
298	} \
299	else if (IsBc) { \
300		if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode != SK_RLMT_MODE_CLS) { \
301			*(pNumBytes) = 6; \
302			*(pOffset) = 6; \
303		} \
304		else { \
305			*(pNumBytes) = 0; \
306		} \
307	} \
308	else { \
309		if ((PktLen) > SK_RLMT_MAX_TX_BUF_SIZE) { \
310			/* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
311			*(pNumBytes) = 0; \
312		} \
313		else { \
314			*(pNumBytes) = 6; \
315			*(pOffset) = 0; \
316		} \
317	} \
318}
319
320
321#define SK_RLMT_LOOKAHEAD(pAC,PortNum,pLaPacket,IsBc,IsMc,pForRlmt) { \
322	SK_AC	*_pAC; \
323	SK_U32	_PortNum; \
324	SK_U8	*_pLaPacket; \
325	_pAC = (pAC); \
326	_PortNum = (SK_U32)(PortNum); \
327	_pLaPacket = (SK_U8 *)(pLaPacket); \
328	if (IsBc) {\
329		if (!SK_ADDR_EQUAL(_pLaPacket, _pAC->Addr.Net[_pAC->Rlmt.Port[ \
330			_PortNum].Net->NetNumber].CurrentMacAddress.a)) { \
331			_pAC->Rlmt.Port[_PortNum].BcTimeStamp = SkOsGetTime(_pAC); \
332			_pAC->Rlmt.CheckSwitch = SK_TRUE; \
333		} \
334		/* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
335		*(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
336	} \
337	else if (IsMc) { \
338		if (SK_ADDR_EQUAL(_pLaPacket, BridgeMcAddr.a)) { \
339			_pAC->Rlmt.Port[_PortNum].BpduPacketsPerTimeSlot++; \
340			if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_CHECK_SEG) { \
341				*(pForRlmt) = SK_RLMT_RX_RLMT | SK_RLMT_RX_PROTOCOL; \
342			} \
343			else { \
344				*(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
345			} \
346		} \
347		else if (SK_ADDR_EQUAL(_pLaPacket, SkRlmtMcAddr.a)) { \
348			*(pForRlmt) = SK_RLMT_RX_RLMT; \
349		} \
350		else { \
351			/* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
352			*(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
353		} \
354	} \
355	else { \
356		if (SK_ADDR_EQUAL( \
357			_pLaPacket, \
358			_pAC->Addr.Port[_PortNum].CurrentMacAddress.a)) { \
359			*(pForRlmt) = SK_RLMT_RX_RLMT; \
360		} \
361		else { \
362			/* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
363			*(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
364		} \
365	} \
366}
367
368#ifdef SK_RLMT_FAST_LOOKAHEAD
369Error: SK_RLMT_FAST_LOOKAHEAD no longer used. Use new macros for lookahead.
370#endif	/* SK_RLMT_FAST_LOOKAHEAD */
371#ifdef SK_RLMT_SLOW_LOOKAHEAD
372Error: SK_RLMT_SLOW_LOOKAHEAD no longer used. Use new macros for lookahead.
373#endif	/* SK_RLMT_SLOW_LOOKAHEAD */
374
375/* typedefs *******************************************************************/
376
377#ifdef SK_RLMT_MBUF_PRIVATE
378typedef struct s_RlmtMbuf {
379	some content
380} SK_RLMT_MBUF;
381#endif	/* SK_RLMT_MBUF_PRIVATE */
382
383
384#ifdef SK_LA_INFO
385typedef struct s_Rlmt_PacketInfo {
386	unsigned	PacketLength;			/* Length of packet. */
387	unsigned	PacketType;				/* Directed/Multicast/Broadcast. */
388} SK_RLMT_PINFO;
389#endif	/* SK_LA_INFO */
390
391
392typedef struct s_RootId {
393	SK_U8		Id[8];					/* Root Bridge Id. */
394} SK_RLMT_ROOT_ID;
395
396
397typedef struct s_port {
398	SK_MAC_ADDR	CheckAddr;
399	SK_BOOL		SuspectTx;
400} SK_PORT_CHECK;
401
402
403typedef struct s_RlmtNet SK_RLMT_NET;
404
405
406typedef struct s_RlmtPort {
407
408/* ----- Public part (read-only) ----- */
409
410	SK_U8			PortState;				/* Current state of this port. */
411
412	/* For PNMI */
413	SK_BOOL			LinkDown;
414	SK_BOOL			PortDown;
415	SK_U8			Align01;
416
417	SK_U32			PortNumber;				/* Number of port on adapter. */
418	SK_RLMT_NET *	Net;					/* Net port belongs to. */
419
420	SK_U64			TxHelloCts;
421	SK_U64			RxHelloCts;
422	SK_U64			TxSpHelloReqCts;
423	SK_U64			RxSpHelloCts;
424
425/* ----- Private part ----- */
426
427/*	SK_U64			PacketsRx; */				/* Total packets received. */
428	SK_U32			PacketsPerTimeSlot;		/* Packets rxed between TOs. */
429/*	SK_U32			DataPacketsPerTimeSlot; */	/* Data packets ... */
430	SK_U32			BpduPacketsPerTimeSlot;	/* BPDU packets rxed in TS. */
431	SK_U64			BcTimeStamp;			/* Time of last BC receive. */
432	SK_U64			GuTimeStamp;			/* Time of entering GOING_UP. */
433
434	SK_TIMER		UpTimer;				/* Timer struct Link/Port up. */
435	SK_TIMER		DownRxTimer;			/* Timer struct down rx. */
436	SK_TIMER		DownTxTimer;			/* Timer struct down tx. */
437
438	SK_U32			CheckingState;			/* Checking State. */
439
440	SK_ADDR_PORT *	AddrPort;
441
442	SK_U8			Random[4];				/* Random value. */
443	unsigned		PortsChecked;			/* #ports checked. */
444	unsigned		PortsSuspect;			/* #ports checked that are s. */
445	SK_PORT_CHECK	PortCheck[1];
446/*	SK_PORT_CHECK	PortCheck[SK_MAX_MACS - 1]; */
447
448	SK_BOOL			PortStarted;			/* Port is started. */
449	SK_BOOL			PortNoRx;				/* NoRx for >= 1 time slot. */
450	SK_BOOL			RootIdSet;
451	SK_RLMT_ROOT_ID	Root;					/* Root Bridge Id. */
452} SK_RLMT_PORT;
453
454
455struct s_RlmtNet {
456
457/* ----- Public part (read-only) ----- */
458
459	SK_U32			NetNumber;			/* Number of net. */
460
461	SK_RLMT_PORT *	Port[SK_MAX_MACS];	/* Ports that belong to this net. */
462	SK_U32			NumPorts;			/* Number of ports. */
463	SK_U32			PrefPort;			/* Preferred port. */
464
465	/* For PNMI */
466
467	SK_U32			RlmtMode;			/* Check ... */
468	SK_U32			ActivePort;			/* Active port. */
469	SK_U32			Preference;		/* 0xFFFFFFFF: Automatic. */
470
471	SK_U8			RlmtState;			/* Current RLMT state. */
472
473/* ----- Private part ----- */
474	SK_BOOL			RootIdSet;
475	SK_U16			Align01;
476
477	int				LinksUp;			/* #Links up. */
478	int				PortsUp;			/* #Ports up. */
479	SK_U32			TimeoutValue;		/* RLMT timeout value. */
480
481	SK_U32			CheckingState;		/* Checking State. */
482	SK_RLMT_ROOT_ID	Root;				/* Root Bridge Id. */
483
484	SK_TIMER		LocTimer;			/* Timer struct. */
485	SK_TIMER		SegTimer;			/* Timer struct. */
486};
487
488
489typedef struct s_Rlmt {
490
491/* ----- Public part (read-only) ----- */
492
493	SK_U32			NumNets;			/* Number of nets. */
494	SK_U32			NetsStarted;		/* Number of nets started. */
495	SK_RLMT_NET		Net[SK_MAX_NETS];	/* Array of available nets. */
496	SK_RLMT_PORT	Port[SK_MAX_MACS];	/* Array of available ports. */
497
498/* ----- Private part ----- */
499	SK_BOOL			CheckSwitch;
500	SK_U8			Align01;
501	SK_U16			Align02;
502
503} SK_RLMT;
504
505
506extern	SK_MAC_ADDR	BridgeMcAddr;
507extern	SK_MAC_ADDR	SkRlmtMcAddr;
508
509/* function prototypes ********************************************************/
510
511
512#ifndef SK_KR_PROTO
513
514/* Functions provided by SkRlmt */
515
516/* ANSI/C++ compliant function prototypes */
517
518extern	void	SkRlmtInit(
519	SK_AC	*pAC,
520	SK_IOC	IoC,
521	int		Level);
522
523extern	int	SkRlmtEvent(
524	SK_AC		*pAC,
525	SK_IOC		IoC,
526	SK_U32		Event,
527	SK_EVPARA	Para);
528
529#else	/* defined(SK_KR_PROTO) */
530
531/* Non-ANSI/C++ compliant function prototypes */
532
533#error KR-style function prototypes are not yet provided.
534
535#endif	/* defined(SK_KR_PROTO)) */
536
537
538#ifdef __cplusplus
539}
540#endif	/* __cplusplus */
541
542#endif	/* __INC_SKRLMT_H */
543