rioboot.c
来自「LINUX 2.6.17.4的源码」· C语言 代码 · 共 1,115 行 · 第 1/3 页
C
1,115 行
*/ RtaType = GetUnitType(RtaUniq); if (Rup >= (unsigned short) MAX_RUP) rio_dprintk(RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", HostP->Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A'); else rio_dprintk(RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n", HostP->Mapping[Rup].Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A'); rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq); if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) { rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n"); return 1; } /* ** If this RTA has just booted an RTA which doesn't belong to this ** system, or the system is in slave mode, do not attempt to create ** a new table entry for it. */ if (!RIOBootOk(p, HostP, RtaUniq)) { MyLink = readb(&PktCmdP->LinkNum); if (Rup < (unsigned short) MAX_RUP) { /* ** RtaUniq was clone booted (by this RTA). Instruct this RTA ** to hold off further attempts to boot on this link for 30 ** seconds. */ if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) { rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink); } } else /* ** RtaUniq was booted by this host. Set the booting link ** to hold off for 30 seconds to give another unit a ** chance to boot it. */ writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot); rio_dprintk(RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n", RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum); return 1; } /* ** Check for a SLOT_IN_USE entry for this RTA attached to the ** current host card in the driver table. ** ** If it exists, make a note that we have booted it. Other parts of ** the driver are interested in this information at a later date, ** in particular when the booting RTA asks for an ID for this unit, ** we must have set the BOOTED flag, and the NEWBOOT flag is used ** to force an open on any ports that where previously open on this ** unit. */ for (entry = 0; entry < MAX_RUP; entry++) { unsigned int sysport; if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) { HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT; if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) { if (sysport < p->RIOFirstPortsBooted) p->RIOFirstPortsBooted = sysport; if (sysport > p->RIOLastPortsBooted) p->RIOLastPortsBooted = sysport; /* ** For a 16 port RTA, check the second bank of 8 ports */ if (RtaType == TYPE_RTA16) { entry2 = HostP->Mapping[entry].ID2 - 1; HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT; sysport = HostP->Mapping[entry2].SysPort; if (sysport < p->RIOFirstPortsBooted) p->RIOFirstPortsBooted = sysport; if (sysport > p->RIOLastPortsBooted) p->RIOLastPortsBooted = sysport; } } if (RtaType == TYPE_RTA16) rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1); else rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1); return 1; } } rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n"); if (Rup >= (unsigned short) MAX_RUP) { /* ** It was a host that did the booting */ MyType = "Host"; MyName = HostP->Name; } else { /* ** It was an RTA that did the booting */ MyType = "RTA"; MyName = HostP->Mapping[Rup].Name; } MyLink = readb(&PktCmdP->LinkNum); /* ** There is no SLOT_IN_USE entry for this RTA attached to the current ** host card in the driver table. ** ** Check for a SLOT_TENTATIVE entry for this RTA attached to the ** current host card in the driver table. ** ** If we find one, then we re-use that slot. */ for (entry = 0; entry < MAX_RUP; entry++) { if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) { if (RtaType == TYPE_RTA16) { entry2 = HostP->Mapping[entry].ID2 - 1; if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq)) rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2); else continue; } else rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry); if (!p->RIONoMessage) printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A'); return 1; } } /* ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA ** attached to the current host card in the driver table. ** ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another ** host for this RTA in the driver table. ** ** For a SLOT_IN_USE entry on another host, we need to delete the RTA ** entry from the other host and add it to this host (using some of ** the functions from table.c which do this). ** For a SLOT_TENTATIVE entry on another host, we must cope with the ** following scenario: ** ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry ** in table) ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE ** entries) ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE) ** + Unplug RTA and plug back into host A. ** + Configure RTA on host A. We now have the same RTA configured ** with different ports on two different hosts. */ rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq); found = 0; Flag = 0; /* Convince the compiler this variable is initialized */ for (host = 0; !found && (host < p->RIONumHosts); host++) { for (rta = 0; rta < MAX_RUP; rta++) { if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) { Flag = p->RIOHosts[host].Mapping[rta].Flags; MapP = &p->RIOHosts[host].Mapping[rta]; if (RtaType == TYPE_RTA16) { MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1]; rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name); } else rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name); found = 1; break; } } } /* ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA ** attached to the current host card in the driver table. ** ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on ** another host for this RTA in the driver table... ** ** Check for a SLOT_IN_USE entry for this RTA in the config table. */ if (!MapP) { rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq); for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) { rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum); if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) { MapP = &p->RIOSavedTable[rta]; Flag = p->RIOSavedTable[rta].Flags; if (RtaType == TYPE_RTA16) { for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) { if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq) break; } MapP2 = &p->RIOSavedTable[entry2]; rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2); } else rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta); break; } } } /* ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA ** attached to the current host card in the driver table. ** ** We may have found a SLOT_IN_USE entry on another host for this ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry ** on another host for this RTA in the driver table. ** ** Check the driver table for room to fit this newly discovered RTA. ** RIOFindFreeID() first looks for free slots and if it does not ** find any free slots it will then attempt to oust any ** tentative entry in the table. */ EmptySlot = 1; if (RtaType == TYPE_RTA16) { if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) { RIODefaultName(p, HostP, entry); rio_fill_host_slot(entry, entry2, RtaUniq, HostP); EmptySlot = 0; } } else { if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) { RIODefaultName(p, HostP, entry); rio_fill_host_slot(entry, 0, RtaUniq, HostP); EmptySlot = 0; } } /* ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA ** attached to the current host card in the driver table. ** ** If we found a SLOT_IN_USE entry on another host for this ** RTA in the config or driver table, and there are enough free ** slots in the driver table, then we need to move it over and ** delete it from the other host. ** If we found a SLOT_TENTATIVE entry on another host for this ** RTA in the driver table, just delete the other host entry. */ if (EmptySlot == 0) { if (MapP) { if (Flag & SLOT_IN_USE) { rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n"); HostP->Mapping[entry].SysPort = MapP->SysPort; memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN); HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT; RIOReMapPorts(p, HostP, &HostP->Mapping[entry]); if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted) p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort; if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted) p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort; rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name); } else { rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n"); HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT; } if (RtaType == TYPE_RTA16) { if (Flag & SLOT_IN_USE) { HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT; HostP->Mapping[entry2].SysPort = MapP2->SysPort; /* ** Map second block of ttys for 16 port RTA */ RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]); if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted) p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort; if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted) p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort; rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name); } else HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT; memset(MapP2, 0, sizeof(struct Map)); } memset(MapP, 0, sizeof(struct Map)); if (!p->RIONoMessage) printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A'); } else if (!p->RIONoMessage) printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A'); RIOSetChange(p); return 1; } /* ** There is no room in the driver table to make an entry for the ** booted RTA. Keep a note of its Uniq Num in the overflow table, ** so we can ignore it's ID requests. */ if (!p->RIONoMessage) printk("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n", MyType, MyName, MyLink + 'A'); for (entry = 0; entry < HostP->NumExtraBooted; entry++) { if (HostP->ExtraUnits[entry] == RtaUniq) { /* ** already got it! */ return 1; } } /* ** If there is room, add the unit to the list of extras */ if (HostP->NumExtraBooted < MAX_EXTRA_UNITS) HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq; return 1;}/*** If the RTA or its host appears in the RIOBindTab[] structure then** we mustn't boot the RTA and should return 0.** This operation is slightly different from the other drivers for RIO** in that this is designed to work with the new utilities** not config.rio and is FAR SIMPLER.** We no longer support the RIOBootMode variable. It is all done from the** "boot/noboot" field in the rio.cf file.*/int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq){ int Entry; unsigned int HostUniq = HostP->UniqueNum; /* ** Search bindings table for RTA or its parent. ** If it exists, return 0, else 1. */ for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) { if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq)) return 0; } return 1;}/*** Make an empty slot tentative. If this is a 16 port RTA, make both** slots tentative, and the second one RTA_SECOND_SLOT as well.*/void rio_fill_host_slot(int entry, int entry2, unsigned int rta_uniq, struct Host *host){ int link; rio_dprintk(RIO_DEBUG_BOOT, "rio_fill_host_slot(%d, %d, 0x%x...)\n", entry, entry2, rta_uniq); host->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE); host->Mapping[entry].SysPort = NO_PORT; host->Mapping[entry].RtaUniqueNum = rta_uniq; host->Mapping[entry].HostUniqueNum = host->UniqueNum; host->Mapping[entry].ID = entry + 1; host->Mapping[entry].ID2 = 0; if (entry2) { host->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT); host->Mapping[entry2].SysPort = NO_PORT; host->Mapping[entry2].RtaUniqueNum = rta_uniq; host->Mapping[entry2].HostUniqueNum = host->UniqueNum; host->Mapping[entry2].Name[0] = '\0'; host->Mapping[entry2].ID = entry2 + 1; host->Mapping[entry2].ID2 = entry + 1; host->Mapping[entry].ID2 = entry2 + 1; } /* ** Must set these up, so that utilities show ** topology of 16 port RTAs correctly */ for (link = 0; link < LINKS_PER_UNIT; link++) { host->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT; host->Mapping[entry].Topology[link].Link = NO_LINK; if (entry2) { host->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT; host->Mapping[entry2].Topology[link].Link = NO_LINK; } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?