📄 rioroute.c
字号:
return 0; } HostP->Mapping[UnitId].Flags |= BEEN_HERE; for ( link=0; link < LINKS_PER_UNIT; link++ ) { /* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d check link (%c)\n", UnitId,'A'+link)); */ if ( RIOCheck( HostP, HostP->Mapping[UnitId].Topology[link].Unit ) ) { /* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d is connected to something that knows the host via link (%c)\n", UnitId,link+'A')); */ HostP->Mapping[UnitId].Flags &= ~BEEN_HERE; return 1; } } HostP->Mapping[UnitId].Flags &= ~BEEN_HERE; /* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d DOESNT KNOW THE HOST!\n", UnitId)); */ return 0;}/*** Returns the type of unit (host, 16/8 port RTA)*/uintGetUnitType(Uniq)uint Uniq;{ switch ( (Uniq >> 28) & 0xf) { case RIO_AT: case RIO_MCA: case RIO_EISA: case RIO_PCI: rio_dprintk (RIO_DEBUG_ROUTE, "Unit type: Host\n"); return(TYPE_HOST); case RIO_RTA_16: rio_dprintk (RIO_DEBUG_ROUTE, "Unit type: 16 port RTA\n"); return(TYPE_RTA16); case RIO_RTA: rio_dprintk (RIO_DEBUG_ROUTE, "Unit type: 8 port RTA\n"); return(TYPE_RTA8); default : rio_dprintk (RIO_DEBUG_ROUTE, "Unit type: Unrecognised\n"); return(99); }}intRIOSetChange(p)struct rio_info * p;{ if ( p->RIOQuickCheck != NOT_CHANGED ) return(0); p->RIOQuickCheck = CHANGED; if ( p->RIOSignalProcess ) { rio_dprintk (RIO_DEBUG_ROUTE, "Send SIG-HUP"); /* psignal( RIOSignalProcess, SIGHUP ); */ } return(0);}static voidRIOConCon(p, HostP, FromId, FromLink, ToId, ToLink, Change)struct rio_info * p;struct Host *HostP;uint FromId;uint FromLink;uint ToId;uint ToLink;int Change; { char *FromName; char *FromType; char *ToName; char *ToType; unsigned int tp;/*** 15.10.1998 ARG - ESIL 0759** (Part) fix for port being trashed when opened whilst RTA "disconnected"**** What's this doing in here anyway ?** It was causing the port to be 'unmapped' if opened whilst RTA "disconnected"**** 09.12.1998 ARG - ESIL 0776 - part fix** Okay, We've found out what this was all about now !** Someone had botched this to use RIOHalted to indicated the number of RTAs** 'disconnected'. The value in RIOHalted was then being used in the** 'RIO_QUICK_CHECK' ioctl. A none zero value indicating that a least one RTA** is 'disconnected'. The change was put in to satisfy a customer's needs.** Having taken this bit of code out 'RIO_QUICK_CHECK' now no longer works for** the customer.** if (Change == CONNECT) { if (p->RIOHalted) p->RIOHalted --; } else { p->RIOHalted ++; }**** So - we need to implement it slightly differently - a new member of the** rio_info struct - RIORtaDisCons (RIO RTA connections) keeps track of RTA** connections and disconnections. */ if (Change == CONNECT) { if (p->RIORtaDisCons) p->RIORtaDisCons--; } else { p->RIORtaDisCons++; } if ( p->RIOPrintDisabled == DONT_PRINT ) return; if ( FromId > ToId ) { tp = FromId; FromId = ToId; ToId = tp; tp = FromLink; FromLink = ToLink; ToLink = tp; } FromName = FromId ? HostP->Mapping[FromId-1].Name : HostP->Name; FromType = FromId ? "RTA" : "HOST"; ToName = ToId ? HostP->Mapping[ToId-1].Name : HostP->Name; ToType = ToId ? "RTA" : "HOST"; rio_dprintk (RIO_DEBUG_ROUTE, "Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A'+FromLink, ToType, ToName, 'A'+ToLink, (Change==CONNECT) ? "established" : "disconnected"); cprintf("Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A'+FromLink, ToType, ToName, 'A'+ToLink, (Change==CONNECT) ? "established" : "disconnected");}/*** RIORemoveFromSavedTable :**** Delete and RTA entry from the saved table given to us** by the configuration program.*/static intRIORemoveFromSavedTable(struct rio_info *p, struct Map *pMap){ int entry; /* ** We loop for all entries even after finding an entry and ** zeroing it because we may have two entries to delete if ** it's a 16 port RTA. */ for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) { bzero((caddr_t)&p->RIOSavedTable[entry], sizeof(struct Map)); } } return 0;}/*** RIOCheckDisconnected :**** Scan the unit links to and return zero if the unit is completely** disconnected.*/static intRIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit){ int link; rio_dprintk (RIO_DEBUG_ROUTE, "RIOFreeDisconnect unit %d\n", unit); /* ** If the slot is tentative and does not belong to the ** second half of a 16 port RTA then scan to see if ** is disconnected. */ for (link = 0; link < LINKS_PER_UNIT; link++) { if (HostP->Mapping[unit].Topology[link].Unit != ROUTE_DISCONNECT) break; } /* ** If not all links are disconnected then we can forget about it. */ if (link < LINKS_PER_UNIT) return 1;#ifdef NEED_TO_FIX_THIS /* Ok so all the links are disconnected. But we may have only just ** made this slot tentative and not yet received a topology update. ** Lets check how long ago we made it tentative. */ rio_dprintk (RIO_DEBUG_ROUTE, "Just about to check LBOLT on entry %d\n", unit); if (drv_getparm(LBOLT, (ulong_t *) ¤t_time)) rio_dprintk (RIO_DEBUG_ROUTE, "drv_getparm(LBOLT,....) Failed.\n"); elapse_time = current_time - TentTime[unit]; rio_dprintk (RIO_DEBUG_ROUTE, "elapse %d = current %d - tent %d (%d usec)\n", elapse_time, current_time, TentTime[unit], drv_hztousec(elapse_time)); if (drv_hztousec(elapse_time) < WAIT_TO_FINISH) { rio_dprintk (RIO_DEBUG_ROUTE, "Skipping slot %d, not timed out yet %d\n", unit, drv_hztousec(elapse_time)); return 1; }#endif /* ** We have found an usable slot. ** If it is half of a 16 port RTA then delete the other half. */ if (HostP->Mapping[unit].ID2 != 0) { int nOther = (HostP->Mapping[unit].ID2) -1; rio_dprintk (RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther); bzero((caddr_t)&HostP->Mapping[nOther], sizeof(struct Map)); } RIORemoveFromSavedTable(p, &HostP->Mapping[unit]); return 0;}/*** RIOFindFreeID :**** This function scans the given host table for either one** or two free unit ID's.*/intRIOFindFreeID(struct rio_info *p, struct Host *HostP, uint *pID1, uint *pID2){ int unit,tempID; /* ** Initialise the ID's to MAX_RUP. ** We do this to make the loop for setting the ID's as simple as ** possible. */ *pID1 = MAX_RUP; if (pID2 != NULL) *pID2 = MAX_RUP; /* ** Scan all entries of the host mapping table for free slots. ** We scan for free slots first and then if that is not successful ** we start all over again looking for tentative slots we can re-use. */ for (unit = 0; unit < MAX_RUP; unit++) { rio_dprintk (RIO_DEBUG_ROUTE, "Scanning unit %d\n",unit); /* ** If the flags are zero then the slot is empty. */ if (HostP->Mapping[unit].Flags == 0) { rio_dprintk (RIO_DEBUG_ROUTE, " This slot is empty.\n"); /* ** If we haven't allocated the first ID then do it now. */ if (*pID1 == MAX_RUP) { rio_dprintk (RIO_DEBUG_ROUTE, "Make tentative entry for first unit %d\n", unit); *pID1 = unit; /* ** If the second ID is not needed then we can return ** now. */ if (pID2 == NULL) return 0; } else { /* ** Allocate the second slot and return. */ rio_dprintk (RIO_DEBUG_ROUTE, "Make tentative entry for second unit %d\n", unit); *pID2 = unit; return 0; } } } /* ** If we manage to come out of the free slot loop then we ** need to start all over again looking for tentative slots ** that we can re-use. */ rio_dprintk (RIO_DEBUG_ROUTE, "Starting to scan for tentative slots\n"); for (unit = 0; unit < MAX_RUP; unit++) { if (((HostP->Mapping[unit].Flags & SLOT_TENTATIVE) || (HostP->Mapping[unit].Flags == 0)) && ! (HostP->Mapping[unit].Flags & RTA16_SECOND_SLOT )) { rio_dprintk (RIO_DEBUG_ROUTE, " Slot %d looks promising.\n",unit); if(unit == *pID1) { rio_dprintk (RIO_DEBUG_ROUTE, " No it isn't, its the 1st half\n"); continue; } /* ** Slot is Tentative or Empty, but not a tentative second ** slot of a 16 porter. ** Attempt to free up this slot (and its parnter if ** it is a 16 port slot. The second slot will become ** empty after a call to RIOFreeDisconnected so thats why ** we look for empty slots above as well). */ if (HostP->Mapping[unit].Flags != 0) if (RIOFreeDisconnected(p, HostP, unit) != 0) continue; /* ** If we haven't allocated the first ID then do it now. */ if (*pID1 == MAX_RUP) { rio_dprintk (RIO_DEBUG_ROUTE, "Grab tentative entry for first unit %d\n", unit); *pID1 = unit; /* ** Clear out this slot now that we intend to use it. */ bzero(&HostP->Mapping[unit], sizeof(struct Map)); /* ** If the second ID is not needed then we can return ** now. */ if (pID2 == NULL) return 0; } else { /* ** Allocate the second slot and return. */ rio_dprintk (RIO_DEBUG_ROUTE, "Grab tentative/empty entry for second unit %d\n", unit); *pID2 = unit; /* ** Clear out this slot now that we intend to use it. */ bzero(&HostP->Mapping[unit], sizeof(struct Map)); /* At this point under the right(wrong?) conditions ** we may have a first unit ID being higher than the ** second unit ID. This is a bad idea if we are about ** to fill the slots with a 16 port RTA. ** Better check and swap them over. */ if (*pID1 > *pID2) { rio_dprintk (RIO_DEBUG_ROUTE, "Swapping IDS %d %d\n", *pID1, *pID2); tempID = *pID1; *pID1 = *pID2; *pID2 = tempID; } return 0; } } } /* ** If we manage to get to the end of the second loop then we ** can give up and return a failure. */ return 1;}/*** The link switch scenario.**** Rta Wun (A) is connected to Tuw (A).** The tables are all up to date, and the system is OK.**** If Wun (A) is now moved to Wun (B) before Wun (A) can** become disconnected, then the follow happens:**** Tuw (A) spots the change of unit:link at the other end** of its link and Tuw sends a topology packet reflecting** the change: Tuw (A) now disconnected from Wun (A), and** this is closely followed by a packet indicating that ** Tuw (A) is now connected to Wun (B).**** Wun (B) will spot that it has now become connected, and** Wun will send a topology packet, which indicates that** both Wun (A) and Wun (B) is connected to Tuw (A).**** Eventually Wun (A) realises that it is now disconnected** and Wun will send out a topology packet indicating that** Wun (A) is now disconnected.*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -