⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skrlmt.c

📁 u-boot 源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** * * Name:	skrlmt.c * Project:	GEnesis, PCI Gigabit Ethernet Adapter * Version:	$Revision: 1.68 $ * Date:	$Date: 2003/01/31 15:26:56 $ * Purpose:	Manage links on SK-NET Adapters, esp. redundant ones. * ******************************************************************************//****************************************************************************** * *	(C)Copyright 1998-2001 SysKonnect GmbH. * *	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. * *	The information in this file is provided "AS IS" without warranty. * ******************************************************************************//****************************************************************************** * * History: * *	$Log: skrlmt.c,v $ *	Revision 1.68  2003/01/31 15:26:56  rschmidt *	Added init for local variables in RlmtInit(). * *	Revision 1.67  2003/01/31 14:12:41  mkunz *	single port adapter runs now with two identical MAC addresses * *	Revision 1.66  2002/09/23 15:14:19  rwahl *	- Reset broadcast timestamp on link down. *	- Editorial corrections. * *	Revision 1.65  2002/07/22 14:29:48  rwahl *	- Removed BRK statement from debug check. * *	Revision 1.64  2001/11/28 19:36:14  rwahl *	- RLMT Packets sent to an invalid MAC address in CLP/CLPSS mode *	  (#10650). *	- Reworked fix for port switching in CLS mode (#10639) *	 (no dependency to RLMT module). *	- Enabled dbg output for entry/exit of event functions. *	- Editorial changes. * *	Revision 1.63  2001/10/26 07:53:18  afischer *	Port switching bug in `check local link` mode * *	Revision 1.62  2001/07/03 12:16:30  mkunz *	New Flag ChgBcPrio (Change priority of last broadcast received) * *	Revision 1.61  2001/03/14 12:52:08  rassmann *	Fixed reporting of active port up/down to PNMI. * *	Revision 1.60  2001/02/21 16:02:25  gklug *	fix: when RLMT starts set Active Port for PNMI * *	Revision 1.59  2001/02/16 14:38:19  rassmann *	Initializing some pointers earlier in the init phase. *	Rx Mbufs are freed if the net which they belong to is stopped. * *	Revision 1.58  2001/02/14 14:06:31  rassmann *	Editorial changes. * *	Revision 1.57  2001/02/05 14:25:26  rassmann *	Prepared RLMT for transparent operation. * *	Revision 1.56  2001/01/30 10:29:09  rassmann *	Not checking switching befor RlmtStart. *	Editorial changes. * *	Revision 1.55  2001/01/22 13:41:38  rassmann *	Supporting two nets on dual-port adapters. * *	Revision 1.54  2000/11/30 13:25:07  rassmann *	Setting SK_TICK_INCR to 1 by default. * *	Revision 1.53  2000/11/30 10:48:07  cgoos *	Changed definition of SK_RLMT_BC_DELTA. * *	Revision 1.52  2000/11/27 12:50:03  rassmann *	Checking ports after receiving broadcasts. * *	Revision 1.51  2000/11/17 08:58:00  rassmann *	Moved CheckSwitch from SK_RLMT_PACKET_RECEIVED to SK_RLMT_TIM event. * *	Revision 1.50  2000/11/09 12:24:34  rassmann *	Indicating that segmentation check is not running anymore after *	  SkRlmtCheckSeg(). *	Restarting segmentation timer after segmentation log. *	Editorial changes. * *	Revision 1.49  1999/11/22 13:38:02  cgoos *	Changed license header to GPL. *	Added initialization to some variables to avoid compiler warnings. * *	Revision 1.48  1999/10/04 14:01:17  rassmann *	Corrected reaction to reception of BPDU frames (#10441). * *	Revision 1.47  1999/07/20 12:53:36  rassmann *	Fixed documentation errors for lookahead macros. * *	Revision 1.46  1999/05/28 13:29:16  rassmann *	Replaced C++-style comment. * *	Revision 1.45  1999/05/28 13:28:08  rassmann *	Corrected syntax error (xxx). * *	Revision 1.44  1999/05/28 11:15:54  rassmann *	Changed behaviour to reflect Design Spec v1.2. *	Controlling Link LED(s). *	Introduced RLMT Packet Version field in RLMT Packet. *	Newstyle lookahead macros (checking meta-information before looking at *	  the packet). * *	Revision 1.43  1999/01/28 13:12:43  rassmann *	Corrected Lookahead (bug introduced in previous Rev.). * *	Revision 1.42  1999/01/28 12:50:41  rassmann *	Not using broadcast time stamps in CheckLinkState mode. * *	Revision 1.41  1999/01/27 14:13:02  rassmann *	Monitoring broadcast traffic. *	Switching more reliably and not too early if switch is *	 configured for spanning tree. * *	Revision 1.40  1999/01/22 13:17:30  rassmann *	Informing PNMI of NET_UP. *	Clearing RLMT multicast addresses before setting them for the first time. *	Reporting segmentation earlier, setting a "quiet time" *	 after a report. * *	Revision 1.39  1998/12/10 15:29:53  rassmann *	Corrected SuspectStatus in SkRlmtBuildCheckChain(). *	Corrected CHECK_SEG mode. * *	Revision 1.38  1998/12/08 13:11:23  rassmann *	Stopping SegTimer at RlmtStop. * *	Revision 1.37  1998/12/07 16:51:42  rassmann *	Corrected comments. * *	Revision 1.36  1998/12/04 10:58:56  rassmann *	Setting next pointer to NULL when receiving. * *	Revision 1.35  1998/12/03 16:12:42  rassmann *	Ignoring/correcting illegal PrefPort values. * *	Revision 1.34  1998/12/01 11:45:35  rassmann *	Code cleanup. * *	Revision 1.33  1998/12/01 10:29:32  rassmann *	Starting standby ports before getting the net up. *	Checking if a port is started when the link comes up. * *	Revision 1.32  1998/11/30 16:19:50  rassmann *	New default for PortNoRx. * *	Revision 1.31  1998/11/27 19:17:13  rassmann *	Corrected handling of LINK_DOWN coming shortly after LINK_UP. * *	Revision 1.30  1998/11/24 12:37:31  rassmann *	Implemented segmentation check. * *	Revision 1.29  1998/11/18 13:04:32  rassmann *	Secured PortUpTimer event. *	Waiting longer before starting standby port(s). * *	Revision 1.28  1998/11/17 13:43:04  rassmann *	Handling (logical) tx failure. *	Sending packet on logical address after PORT_SWITCH. * *	Revision 1.27  1998/11/13 17:09:50  rassmann *	Secured some events against being called in wrong state. * *	Revision 1.26  1998/11/13 16:56:54  rassmann *	Added macro version of SkRlmtLookaheadPacket. * *	Revision 1.25  1998/11/06 18:06:04  rassmann *	Corrected timing when RLMT checks fail. *	Clearing tx counter earlier in periodical checks. * *	Revision 1.24  1998/11/05 10:37:27  rassmann *	Checking destination address in Lookahead. * *	Revision 1.23  1998/11/03 13:53:49  rassmann *	RLMT should switch now (at least in mode 3). * *	Revision 1.22  1998/10/29 14:34:49  rassmann *	Clearing SK_RLMT struct at startup. *	Initializing PortsUp during SK_RLMT_START. * *	Revision 1.21  1998/10/28 11:30:17  rassmann *	Default mode is now SK_RLMT_CHECK_LOC_LINK. * *	Revision 1.20  1998/10/26 16:02:03  rassmann *	Ignoring LINK_DOWN for links that are down. * *	Revision 1.19  1998/10/22 15:54:01  rassmann *	Corrected EtherLen. *	Starting Link Check when second port comes up. * *	Revision 1.18  1998/10/22 11:39:50  rassmann *	Corrected signed/unsigned mismatches. *	Corrected receive list handling and address recognition. * *	Revision 1.17  1998/10/19 17:01:20  rassmann *	More detailed checking of received packets. * *	Revision 1.16  1998/10/15 15:16:34  rassmann *	Finished Spanning Tree checking. *	Checked with lint. * *	Revision 1.15  1998/09/24 19:16:07  rassmann *	Code cleanup. *	Introduced Timer for PORT_DOWN due to no RX. * *	Revision 1.14  1998/09/18 20:27:14  rassmann *	Added address override. * *	Revision 1.13  1998/09/16 11:31:48  rassmann *	Including skdrv1st.h again. :( * *	Revision 1.12  1998/09/16 11:09:50  rassmann *	Syntax corrections. * *	Revision 1.11  1998/09/15 12:32:03  rassmann *	Syntax correction. * *	Revision 1.10  1998/09/15 11:28:49  rassmann *	Syntax corrections. * *	Revision 1.9  1998/09/14 17:07:37  rassmann *	Added code for port checking via LAN. *	Changed Mbuf definition. * *	Revision 1.8  1998/09/07 11:14:14  rassmann *	Syntax corrections. * *	Revision 1.7  1998/09/07 09:06:07  rassmann *	Syntax corrections. * *	Revision 1.6  1998/09/04 19:41:33  rassmann *	Syntax corrections. *	Started entering code for checking local links. * *	Revision 1.5  1998/09/04 12:14:27  rassmann *	Interface cleanup. * *	Revision 1.4  1998/09/02 16:55:28  rassmann *	Updated to reflect new DRV/HWAC/RLMT interface. * *	Revision 1.3  1998/08/27 14:29:03  rassmann *	Code cleanup. * *	Revision 1.2  1998/08/27 14:26:24  rassmann *	Updated interface. * *	Revision 1.1  1998/08/21 08:26:49  rassmann *	First public version. * ******************************************************************************//****************************************************************************** * * Description: * * This module contains code for Link ManagemenT (LMT) of SK-NET Adapters. * It is mainly intended for adapters with more than one link. * For such adapters, this module realizes Redundant Link ManagemenT (RLMT). * * Include File Hierarchy: * *	"skdrv1st.h" *	"skdrv2nd.h" * ******************************************************************************/#include <config.h>#ifdef CONFIG_SK98#ifndef	lintstatic const char SysKonnectFileId[] =	"@(#) $Id: skrlmt.c,v 1.68 2003/01/31 15:26:56 rschmidt Exp $ (C) SysKonnect.";#endif	/* !defined(lint) */#define __SKRLMT_C#ifdef __cplusplus#error C++ is not yet supported.extern "C" {#endif	/* cplusplus */#include "h/skdrv1st.h"#include "h/skdrv2nd.h"/* defines ********************************************************************/#ifndef SK_HWAC_LINK_LED#define SK_HWAC_LINK_LED(a,b,c,d)#endif	/* !defined(SK_HWAC_LINK_LED) */#ifndef DEBUG#define RLMT_STATIC	static#else	/* DEBUG */#define RLMT_STATIC#ifndef SK_LITTLE_ENDIAN/* First 32 bits */#define OFFS_LO32	1/* Second 32 bits */#define OFFS_HI32	0#else	/* SK_LITTLE_ENDIAN *//* First 32 bits */#define OFFS_LO32	0/* Second 32 bits */#define OFFS_HI32	1#endif	/* SK_LITTLE_ENDIAN */#endif	/* DEBUG *//* ----- Private timeout values ----- */#define SK_RLMT_MIN_TO_VAL			   125000	/* 1/8 sec. */#define SK_RLMT_DEF_TO_VAL			  1000000	/* 1 sec. */#define SK_RLMT_PORTDOWN_TIM_VAL	   900000	/* another 0.9 sec. */#define SK_RLMT_PORTSTART_TIM_VAL	   100000	/* 0.1 sec. */#define SK_RLMT_PORTUP_TIM_VAL		  2500000	/* 2.5 sec. */#define SK_RLMT_SEG_TO_VAL			900000000	/* 15 min. *//* Assume tick counter increment is 1 - may be set OS-dependent. */#ifndef SK_TICK_INCR#define SK_TICK_INCR	SK_CONSTU64(1)#endif	/* !defined(SK_TICK_INCR) *//* * Amount that a time stamp must be later to be recognized as "substantially * later". This is about 1/128 sec, but above 1 tick counter increment. */#define SK_RLMT_BC_DELTA		(1 + ((SK_TICKS_PER_SEC >> 7) > SK_TICK_INCR ? \									(SK_TICKS_PER_SEC >> 7) : SK_TICK_INCR))/* ----- Private RLMT defaults ----- */#define SK_RLMT_DEF_PREF_PORT	0					/* "Lower" port. */#define SK_RLMT_DEF_MODE 		SK_RLMT_CHECK_LINK	/* Default RLMT Mode. *//* ----- Private RLMT checking states ----- */#define SK_RLMT_RCS_SEG			1		/* RLMT Check State: check seg. */#define SK_RLMT_RCS_START_SEG	2		/* RLMT Check State: start check seg. */#define SK_RLMT_RCS_SEND_SEG	4		/* RLMT Check State: send BPDU packet */#define SK_RLMT_RCS_REPORT_SEG	8		/* RLMT Check State: report seg. *//* ----- Private PORT checking states ----- */#define SK_RLMT_PCS_TX			1		/* Port Check State: check tx. */#define SK_RLMT_PCS_RX			2		/* Port Check State: check rx. *//* ----- Private PORT events ----- *//* Note: Update simulation when changing these. */#define SK_RLMT_PORTSTART_TIM	1100	/* Port start timeout. */#define SK_RLMT_PORTUP_TIM		1101	/* Port can now go up. */#define SK_RLMT_PORTDOWN_RX_TIM	1102	/* Port did not receive once ... */#define SK_RLMT_PORTDOWN		1103	/* Port went down. */#define SK_RLMT_PORTDOWN_TX_TIM	1104	/* Partner did not receive ... *//* ----- Private RLMT events ----- *//* Note: Update simulation when changing these. */#define SK_RLMT_TIM				2100	/* RLMT timeout. */#define SK_RLMT_SEG_TIM			2101	/* RLMT segmentation check timeout. */#define TO_SHORTEN(tim)	((tim) / 2)/* Error numbers and messages. */#define SKERR_RLMT_E001		(SK_ERRBASE_RLMT + 0)#define SKERR_RLMT_E001_MSG	"No Packet."#define SKERR_RLMT_E002		(SKERR_RLMT_E001 + 1)#define SKERR_RLMT_E002_MSG	"Short Packet."#define SKERR_RLMT_E003		(SKERR_RLMT_E002 + 1)#define SKERR_RLMT_E003_MSG	"Unknown RLMT event."#define SKERR_RLMT_E004		(SKERR_RLMT_E003 + 1)#define SKERR_RLMT_E004_MSG	"PortsUp incorrect."#define SKERR_RLMT_E005		(SKERR_RLMT_E004 + 1)#define SKERR_RLMT_E005_MSG	\ "Net seems to be segmented (different root bridges are reported on the ports)."#define SKERR_RLMT_E006		(SKERR_RLMT_E005 + 1)#define SKERR_RLMT_E006_MSG	"Duplicate MAC Address detected."#define SKERR_RLMT_E007		(SKERR_RLMT_E006 + 1)#define SKERR_RLMT_E007_MSG	"LinksUp incorrect."#define SKERR_RLMT_E008		(SKERR_RLMT_E007 + 1)#define SKERR_RLMT_E008_MSG	"Port not started but link came up."#define SKERR_RLMT_E009		(SKERR_RLMT_E008 + 1)#define SKERR_RLMT_E009_MSG	"Corrected illegal setting of Preferred Port."#define SKERR_RLMT_E010		(SKERR_RLMT_E009 + 1)#define SKERR_RLMT_E010_MSG	"Ignored illegal Preferred Port."/* LLC field values. */#define LLC_COMMAND_RESPONSE_BIT		1#define LLC_TEST_COMMAND				0xE3#define LLC_UI							0x03/* RLMT Packet fields. */#define	SK_RLMT_DSAP					0#define	SK_RLMT_SSAP					0#define SK_RLMT_CTRL					(LLC_TEST_COMMAND)#define SK_RLMT_INDICATOR0				0x53	/* S */#define SK_RLMT_INDICATOR1				0x4B	/* K */#define SK_RLMT_INDICATOR2				0x2D	/* - */#define SK_RLMT_INDICATOR3				0x52	/* R */#define SK_RLMT_INDICATOR4				0x4C	/* L */#define SK_RLMT_INDICATOR5				0x4D	/* M */#define SK_RLMT_INDICATOR6				0x54	/* T */#define SK_RLMT_PACKET_VERSION			0/* RLMT SPT Flag values. */#define	SK_RLMT_SPT_FLAG_CHANGE			0x01#define	SK_RLMT_SPT_FLAG_CHANGE_ACK		0x80/* RLMT SPT Packet fields. */#define	SK_RLMT_SPT_DSAP				0x42#define	SK_RLMT_SPT_SSAP				0x42#define SK_RLMT_SPT_CTRL				(LLC_UI)#define	SK_RLMT_SPT_PROTOCOL_ID0		0x00#define	SK_RLMT_SPT_PROTOCOL_ID1		0x00#define	SK_RLMT_SPT_PROTOCOL_VERSION_ID	0x00#define	SK_RLMT_SPT_BPDU_TYPE			0x00#define	SK_RLMT_SPT_FLAGS				0x00	/* ?? */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -