patch-2.4.23 linux-2.4.23/drivers/net/sk98lin/skrlmt.c

Next file: linux-2.4.23/drivers/net/sk98lin/sktimer.c
Previous file: linux-2.4.23/drivers/net/sk98lin/skqueue.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.22/drivers/net/sk98lin/skrlmt.c linux-2.4.23/drivers/net/sk98lin/skrlmt.c
@@ -2,15 +2,16 @@
  *
  * Name:	skrlmt.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.65 $
- * Date:	$Date: 2002/07/22 14:29:48 $
+ * Version:	$Revision: 1.69 $
+ * Date:	$Date: 2003/04/15 09:39:22 $
  * Purpose:	Manage links on SK-NET Adapters, esp. redundant ones.
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2001 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	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
@@ -26,6 +27,20 @@
  * History:
  *
  *	$Log: skrlmt.c,v $
+ *	Revision 1.69  2003/04/15 09:39:22  tschilli
+ *	Copyright messages changed.
+ *	"#error C++ is not yet supported." removed.
+ *	
+ *	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.
  *	
@@ -272,13 +287,12 @@
 
 #ifndef	lint
 static const char SysKonnectFileId[] =
-	"@(#) $Id: skrlmt.c,v 1.65 2002/07/22 14:29:48 rwahl Exp $ (C) SysKonnect.";
+	"@(#) $Id: skrlmt.c,v 1.69 2003/04/15 09:39:22 tschilli Exp $ (C) Marvell.";
 #endif	/* !defined(lint) */
 
 #define __SKRLMT_C
 
 #ifdef __cplusplus
-#error C++ is not yet supported.
 extern "C" {
 #endif	/* cplusplus */
 
@@ -578,6 +592,10 @@
 	SK_U32		i, j;
 	SK_U64		Random;
 	SK_EVPARA	Para;
+    SK_MAC_ADDR		VirtualMacAddress;
+    SK_MAC_ADDR		PhysicalAMacAddress;
+    SK_BOOL		VirtualMacAddressSet;
+    SK_BOOL		PhysicalAMacAddressSet;
 
 	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_INIT,
 		("RLMT Init level %d.\n", Level))
@@ -625,7 +643,7 @@
 		pAC->Rlmt.Net[0].NumPorts = pAC->GIni.GIMacsFound;
 
 		/* Initialize HW registers? */
-		if (pAC->GIni.GIMacsFound < 2) {
+		if (pAC->GIni.GIMacsFound == 1) {
 			Para.Para32[0] = SK_RLMT_MODE_CLS;
 			Para.Para32[1] = 0;
 			(void)SkRlmtEvent(pAC, IoC, SK_RLMT_MODE_CHANGE, Para);
@@ -661,6 +679,38 @@
 
 			(void)SkAddrMcUpdate(pAC, IoC, i);
 		}
+
+    	VirtualMacAddressSet = SK_FALSE;
+		/* Read virtual MAC address from Control Register File. */
+		for (j = 0; j < SK_MAC_ADDR_LEN; j++) {
+			
+            SK_IN8(IoC, B2_MAC_1 + j, &VirtualMacAddress.a[j]);
+            VirtualMacAddressSet |= VirtualMacAddress.a[j];
+		}
+    	
+        PhysicalAMacAddressSet = SK_FALSE;
+		/* Read physical MAC address for MAC A from Control Register File. */
+		for (j = 0; j < SK_MAC_ADDR_LEN; j++) {
+			
+            SK_IN8(IoC, B2_MAC_2 + j, &PhysicalAMacAddress.a[j]);
+            PhysicalAMacAddressSet |= PhysicalAMacAddress.a[j];
+		}
+
+        /* check if the two mac addresses contain reasonable values */
+        if (!VirtualMacAddressSet || !PhysicalAMacAddressSet) {
+
+            pAC->Rlmt.RlmtOff = SK_TRUE;
+        }
+
+        /* if the two mac addresses are equal switch off the RLMT_PRE_LOOKAHEAD
+           and the RLMT_LOOKAHEAD macros */
+        else if (SK_ADDR_EQUAL(PhysicalAMacAddress.a, VirtualMacAddress.a)) {
+
+            pAC->Rlmt.RlmtOff = SK_TRUE;
+        }
+		else {
+			pAC->Rlmt.RlmtOff = SK_FALSE;
+		}
 		break;
 
 	default:	/* error */
@@ -760,7 +810,7 @@
 	}
 #endif	/* DEBUG */
 
-	return;       
+	return;
 }	/* SkRlmtBuildCheckChain */
 
 
@@ -847,7 +897,7 @@
 		}
 	}
 
-	return (pMb);       
+	return (pMb);
 }	/* SkRlmtBuildPacket */
 
 
@@ -929,7 +979,7 @@
 		pAC->Rlmt.Port[PortNumber].TxSpHelloReqCts++;
 	}
 
-	return (pMb);       
+	return (pMb);
 }	/* SkRlmtBuildSpanningTreePacket */
 
 
@@ -996,8 +1046,8 @@
 			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_TX,
 				("SkRlmtSend: BPDU Packet on Port %u.\n", PortNumber))
 		}
-	}   
-	return;   
+	}
+	return;
 }	/* SkRlmtSend */
 
 
@@ -1337,7 +1387,7 @@
 					pRPort->Root.Id[0], pRPort->Root.Id[1],
 					pRPort->Root.Id[2], pRPort->Root.Id[3],
 					pRPort->Root.Id[4], pRPort->Root.Id[5],
-					pRPort->Root.Id[6], pRPort->Root.Id[7]))      
+					pRPort->Root.Id[6], pRPort->Root.Id[7]))
 		}
 
 		SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
@@ -1500,10 +1550,10 @@
 			SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
 		}
 
-		NewTimeout = SK_RLMT_DEF_TO_VAL;              
+		NewTimeout = SK_RLMT_DEF_TO_VAL;
 	}
 
-	return (NewTimeout);       
+	return (NewTimeout);
 }	/* SkRlmtCheckPort */
 
 
@@ -1537,13 +1587,14 @@
 	
 	/* Select port with the latest TimeStamp. */
 	for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
-#ifdef DEBUG
+
 		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
-			("TimeStamp Port %d: %08x %08x.\n",
+			("TimeStamp Port %d (Down: %d, NoRx: %d): %08x %08x.\n",
 				i,
+   				pAC->Rlmt.Port[i].PortDown, pAC->Rlmt.Port[i].PortNoRx,
 				*((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_HI32),
 				*((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_LO32)))
-#endif	/* DEBUG */
+
 		if (!pAC->Rlmt.Port[i].PortDown && !pAC->Rlmt.Port[i].PortNoRx) {
 			if (!PortFound || pAC->Rlmt.Port[i].BcTimeStamp > BcTimeStamp) {
 				BcTimeStamp = pAC->Rlmt.Port[i].BcTimeStamp;
@@ -1568,10 +1619,9 @@
 				pAC->Rlmt.Port[i].BcTimeStamp +
 				 SK_RLMT_BC_DELTA > BcTimeStamp)) {
 				PortFound = SK_FALSE;
-#ifdef DEBUG
+				
 				SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
 					("Port %d received a broadcast at a similar time.\n", i))
-#endif	/* DEBUG */
 				break;
 			}
 		}
@@ -1580,8 +1630,8 @@
 #ifdef DEBUG
 	if (PortFound) {
 		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
-			("SK_RLMT_CHECK_SWITCH found Port %d receiving the substantially "
-			 "latest broadcast (%d).\n",
+			("SK_RLMT_SELECT_BCRX found Port %d receiving the substantially "
+			 "latest broadcast (%u).\n",
 				*pSelect,
 				BcTimeStamp - pAC->Rlmt.Port[1 - *pSelect].BcTimeStamp))
 	}
@@ -1631,7 +1681,7 @@
 			}
 			PortFound = SK_TRUE;
 			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
-				("SK_RLMT_CHECK_SWITCH found Port %d up and not check RX.\n",
+				("SK_RLMT_SELECT_NOTSUSPECT found Port %d up and not check RX.\n",
 					*pSelect))
 			break;
 		}
@@ -1681,7 +1731,7 @@
 			}
 			PortFound = SK_TRUE;
 			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
-				("SK_RLMT_CHECK_SWITCH found Port %d up.\n", *pSelect))
+				("SK_RLMT_SELECT_UP found Port %d up.\n", *pSelect))
 			break;
 		}
 	}
@@ -1742,7 +1792,7 @@
 	}
 
 	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
-		("SK_RLMT_CHECK_SWITCH found Port %d going up.\n", *pSelect))
+		("SK_RLMT_SELECT_GOINGUP found Port %d going up.\n", *pSelect))
 	return (SK_TRUE);
 }	/* SkRlmtSelectGoingUp */
 
@@ -1788,7 +1838,7 @@
 			}
 			PortFound = SK_TRUE;
 			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
-				("SK_RLMT_CHECK_SWITCH found Port %d down.\n", *pSelect))
+				("SK_RLMT_SELECT_DOWN found Port %d down.\n", *pSelect))
 			break;
 		}
 	}
@@ -2426,6 +2476,7 @@
 	pRPort->PacketsPerTimeSlot = 0;
 	/* pRPort->DataPacketsPerTimeSlot = 0; */
 	pRPort->BpduPacketsPerTimeSlot = 0;
+	pRPort->BcTimeStamp = 0;
 
 	/*
 	 * RA;:;: To be checked:
@@ -2696,7 +2747,7 @@
 	}
 
 	/* Stop RLMT timers. */
-	SkTimerStop(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].LocTimer); 
+	SkTimerStop(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].LocTimer);
 	SkTimerStop(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].SegTimer);
 
 	/* Stop net. */
@@ -2896,7 +2947,7 @@
 		}
 	}
 #endif	/* xDEBUG */
-				   
+				
 	SkRlmtCheckSeg(pAC, IoC, Para.Para32[0]);
 
 	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
@@ -3284,7 +3335,7 @@
 
 	Para.Para32[0] |= SK_RLMT_CHECK_LINK;
 
-	if (pAC->Rlmt.Net[Para.Para32[1]].NumPorts < 2 &&
+	if ((pAC->Rlmt.Net[Para.Para32[1]].NumPorts == 1) &&
 		Para.Para32[0] != SK_RLMT_MODE_CLS) {
 		pAC->Rlmt.Net[Para.Para32[1]].RlmtMode = SK_RLMT_MODE_CLS;
 		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
@@ -3447,7 +3498,7 @@
 		break;
 	}	/* switch() */
 
-	return (0);       
+	return (0);
 }	/* SkRlmtEvent */
 
 #ifdef __cplusplus

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)