rioroute.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. /*
  2. ** -----------------------------------------------------------------------------
  3. **
  4. ** Perle Specialix driver for Linux
  5. ** Ported from existing RIO Driver for SCO sources.
  6. *
  7. * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. **
  23. ** Module : rioroute.c
  24. ** SID : 1.3
  25. ** Last Modified : 11/6/98 10:33:46
  26. ** Retrieved : 11/6/98 10:33:50
  27. **
  28. ** ident @(#)rioroute.c 1.3
  29. **
  30. ** -----------------------------------------------------------------------------
  31. */
  32. #include <linux/module.h>
  33. #include <linux/errno.h>
  34. #include <asm/io.h>
  35. #include <asm/system.h>
  36. #include <asm/string.h>
  37. #include <asm/uaccess.h>
  38. #include <linux/termios.h>
  39. #include <linux/serial.h>
  40. #include <linux/generic_serial.h>
  41. #include "linux_compat.h"
  42. #include "rio_linux.h"
  43. #include "pkt.h"
  44. #include "daemon.h"
  45. #include "rio.h"
  46. #include "riospace.h"
  47. #include "cmdpkt.h"
  48. #include "map.h"
  49. #include "rup.h"
  50. #include "port.h"
  51. #include "riodrvr.h"
  52. #include "rioinfo.h"
  53. #include "func.h"
  54. #include "errors.h"
  55. #include "pci.h"
  56. #include "parmmap.h"
  57. #include "unixrup.h"
  58. #include "board.h"
  59. #include "host.h"
  60. #include "phb.h"
  61. #include "link.h"
  62. #include "cmdblk.h"
  63. #include "route.h"
  64. #include "cirrus.h"
  65. #include "rioioctl.h"
  66. #include "param.h"
  67. static int RIOCheckIsolated(struct rio_info *, struct Host *, unsigned int);
  68. static int RIOIsolate(struct rio_info *, struct Host *, unsigned int);
  69. static int RIOCheck(struct Host *, unsigned int);
  70. static void RIOConCon(struct rio_info *, struct Host *, unsigned int, unsigned int, unsigned int, unsigned int, int);
  71. /*
  72. ** Incoming on the ROUTE_RUP
  73. ** I wrote this while I was tired. Forgive me.
  74. */
  75. int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem * PacketP)
  76. {
  77. struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data;
  78. struct PktCmd_M *PktReplyP;
  79. struct CmdBlk *CmdBlkP;
  80. struct Port *PortP;
  81. struct Map *MapP;
  82. struct Top *TopP;
  83. int ThisLink, ThisLinkMin, ThisLinkMax;
  84. int port;
  85. int Mod, Mod1, Mod2;
  86. unsigned short RtaType;
  87. unsigned int RtaUniq;
  88. unsigned int ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */
  89. unsigned int OldUnit, NewUnit, OldLink, NewLink;
  90. char *MyType, *MyName;
  91. int Lies;
  92. unsigned long flags;
  93. /*
  94. ** Is this unit telling us it's current link topology?
  95. */
  96. if (readb(&PktCmdP->Command) == ROUTE_TOPOLOGY) {
  97. MapP = HostP->Mapping;
  98. /*
  99. ** The packet can be sent either by the host or by an RTA.
  100. ** If it comes from the host, then we need to fill in the
  101. ** Topology array in the host structure. If it came in
  102. ** from an RTA then we need to fill in the Mapping structure's
  103. ** Topology array for the unit.
  104. */
  105. if (Rup >= (unsigned short) MAX_RUP) {
  106. ThisUnit = HOST_ID;
  107. TopP = HostP->Topology;
  108. MyType = "Host";
  109. MyName = HostP->Name;
  110. ThisLinkMin = ThisLinkMax = Rup - MAX_RUP;
  111. } else {
  112. ThisUnit = Rup + 1;
  113. TopP = HostP->Mapping[Rup].Topology;
  114. MyType = "RTA";
  115. MyName = HostP->Mapping[Rup].Name;
  116. ThisLinkMin = 0;
  117. ThisLinkMax = LINKS_PER_UNIT - 1;
  118. }
  119. /*
  120. ** Lies will not be tolerated.
  121. ** If any pair of links claim to be connected to the same
  122. ** place, then ignore this packet completely.
  123. */
  124. Lies = 0;
  125. for (ThisLink = ThisLinkMin + 1; ThisLink <= ThisLinkMax; ThisLink++) {
  126. /*
  127. ** it won't lie about network interconnect, total disconnects
  128. ** and no-IDs. (or at least, it doesn't *matter* if it does)
  129. */
  130. if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (unsigned short) MAX_RUP)
  131. continue;
  132. for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) {
  133. if ((readb(&PktCmdP->RouteTopology[ThisLink].Unit) == readb(&PktCmdP->RouteTopology[NewLink].Unit)) && (readb(&PktCmdP->RouteTopology[ThisLink].Link) == readb(&PktCmdP->RouteTopology[NewLink].Link))) {
  134. Lies++;
  135. }
  136. }
  137. }
  138. if (Lies) {
  139. rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies);
  140. rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n",
  141. readb(&PktCmdP->RouteTopology[0].Unit),
  142. 'A' + readb(&PktCmdP->RouteTopology[0].Link),
  143. readb(&PktCmdP->RouteTopology[1].Unit),
  144. 'A' + readb(&PktCmdP->RouteTopology[1].Link), readb(&PktCmdP->RouteTopology[2].Unit), 'A' + readb(&PktCmdP->RouteTopology[2].Link), readb(&PktCmdP->RouteTopology[3].Unit), 'A' + readb(&PktCmdP->RouteTopology[3].Link));
  145. return 1;
  146. }
  147. /*
  148. ** now, process each link.
  149. */
  150. for (ThisLink = ThisLinkMin; ThisLink <= ThisLinkMax; ThisLink++) {
  151. /*
  152. ** this is what it was connected to
  153. */
  154. OldUnit = TopP[ThisLink].Unit;
  155. OldLink = TopP[ThisLink].Link;
  156. /*
  157. ** this is what it is now connected to
  158. */
  159. NewUnit = readb(&PktCmdP->RouteTopology[ThisLink].Unit);
  160. NewLink = readb(&PktCmdP->RouteTopology[ThisLink].Link);
  161. if (OldUnit != NewUnit || OldLink != NewLink) {
  162. /*
  163. ** something has changed!
  164. */
  165. if (NewUnit > MAX_RUP && NewUnit != ROUTE_DISCONNECT && NewUnit != ROUTE_NO_ID && NewUnit != ROUTE_INTERCONNECT) {
  166. rio_dprintk(RIO_DEBUG_ROUTE, "I have a link from %s %s to unit %d:%d - I don't like it.\n", MyType, MyName, NewUnit, NewLink);
  167. } else {
  168. /*
  169. ** put the new values in
  170. */
  171. TopP[ThisLink].Unit = NewUnit;
  172. TopP[ThisLink].Link = NewLink;
  173. RIOSetChange(p);
  174. if (OldUnit <= MAX_RUP) {
  175. /*
  176. ** If something has become bust, then re-enable them messages
  177. */
  178. if (!p->RIONoMessage)
  179. RIOConCon(p, HostP, ThisUnit, ThisLink, OldUnit, OldLink, DISCONNECT);
  180. }
  181. if ((NewUnit <= MAX_RUP) && !p->RIONoMessage)
  182. RIOConCon(p, HostP, ThisUnit, ThisLink, NewUnit, NewLink, CONNECT);
  183. if (NewUnit == ROUTE_NO_ID)
  184. rio_dprintk(RIO_DEBUG_ROUTE, "%s %s (%c) is connected to an unconfigured unit.\n", MyType, MyName, 'A' + ThisLink);
  185. if (NewUnit == ROUTE_INTERCONNECT) {
  186. if (!p->RIONoMessage)
  187. printk(KERN_DEBUG "rio: %s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink);
  188. }
  189. /*
  190. ** perform an update for 'the other end', so that these messages
  191. ** only appears once. Only disconnect the other end if it is pointing
  192. ** at us!
  193. */
  194. if (OldUnit == HOST_ID) {
  195. if (HostP->Topology[OldLink].Unit == ThisUnit && HostP->Topology[OldLink].Link == ThisLink) {
  196. rio_dprintk(RIO_DEBUG_ROUTE, "SETTING HOST (%c) TO DISCONNECTED!\n", OldLink + 'A');
  197. HostP->Topology[OldLink].Unit = ROUTE_DISCONNECT;
  198. HostP->Topology[OldLink].Link = NO_LINK;
  199. } else {
  200. rio_dprintk(RIO_DEBUG_ROUTE, "HOST(%c) WAS NOT CONNECTED TO %s (%c)!\n", OldLink + 'A', HostP->Mapping[ThisUnit - 1].Name, ThisLink + 'A');
  201. }
  202. } else if (OldUnit <= MAX_RUP) {
  203. if (HostP->Mapping[OldUnit - 1].Topology[OldLink].Unit == ThisUnit && HostP->Mapping[OldUnit - 1].Topology[OldLink].Link == ThisLink) {
  204. rio_dprintk(RIO_DEBUG_ROUTE, "SETTING RTA %s (%c) TO DISCONNECTED!\n", HostP->Mapping[OldUnit - 1].Name, OldLink + 'A');
  205. HostP->Mapping[OldUnit - 1].Topology[OldLink].Unit = ROUTE_DISCONNECT;
  206. HostP->Mapping[OldUnit - 1].Topology[OldLink].Link = NO_LINK;
  207. } else {
  208. rio_dprintk(RIO_DEBUG_ROUTE, "RTA %s (%c) WAS NOT CONNECTED TO %s (%c)\n", HostP->Mapping[OldUnit - 1].Name, OldLink + 'A', HostP->Mapping[ThisUnit - 1].Name, ThisLink + 'A');
  209. }
  210. }
  211. if (NewUnit == HOST_ID) {
  212. rio_dprintk(RIO_DEBUG_ROUTE, "MARKING HOST (%c) CONNECTED TO %s (%c)\n", NewLink + 'A', MyName, ThisLink + 'A');
  213. HostP->Topology[NewLink].Unit = ThisUnit;
  214. HostP->Topology[NewLink].Link = ThisLink;
  215. } else if (NewUnit <= MAX_RUP) {
  216. rio_dprintk(RIO_DEBUG_ROUTE, "MARKING RTA %s (%c) CONNECTED TO %s (%c)\n", HostP->Mapping[NewUnit - 1].Name, NewLink + 'A', MyName, ThisLink + 'A');
  217. HostP->Mapping[NewUnit - 1].Topology[NewLink].Unit = ThisUnit;
  218. HostP->Mapping[NewUnit - 1].Topology[NewLink].Link = ThisLink;
  219. }
  220. }
  221. RIOSetChange(p);
  222. RIOCheckIsolated(p, HostP, OldUnit);
  223. }
  224. }
  225. return 1;
  226. }
  227. /*
  228. ** The only other command we recognise is a route_request command
  229. */
  230. if (readb(&PktCmdP->Command) != ROUTE_REQUEST) {
  231. rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %p ROUTE_RUP\n", readb(&PktCmdP->Command), Rup, HostP);
  232. return 1;
  233. }
  234. RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
  235. /*
  236. ** Determine if 8 or 16 port RTA
  237. */
  238. RtaType = GetUnitType(RtaUniq);
  239. rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq);
  240. Mod = readb(&PktCmdP->ModuleTypes);
  241. Mod1 = LONYBLE(Mod);
  242. if (RtaType == TYPE_RTA16) {
  243. /*
  244. ** Only one ident is set for a 16 port RTA. To make compatible
  245. ** with 8 port, set 2nd ident in Mod2 to the same as Mod1.
  246. */
  247. Mod2 = Mod1;
  248. rio_dprintk(RIO_DEBUG_ROUTE, "Backplane type is %s (all ports)\n", p->RIOModuleTypes[Mod1].Name);
  249. } else {
  250. Mod2 = HINYBLE(Mod);
  251. rio_dprintk(RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n", p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name);
  252. }
  253. /*
  254. ** try to unhook a command block from the command free list.
  255. */
  256. if (!(CmdBlkP = RIOGetCmdBlk())) {
  257. rio_dprintk(RIO_DEBUG_ROUTE, "No command blocks to route RTA! come back later.\n");
  258. return 0;
  259. }
  260. /*
  261. ** Fill in the default info on the command block
  262. */
  263. CmdBlkP->Packet.dest_unit = Rup;
  264. CmdBlkP->Packet.dest_port = ROUTE_RUP;
  265. CmdBlkP->Packet.src_unit = HOST_ID;
  266. CmdBlkP->Packet.src_port = ROUTE_RUP;
  267. CmdBlkP->Packet.len = PKT_CMD_BIT | 1;
  268. CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
  269. PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
  270. if (!RIOBootOk(p, HostP, RtaUniq)) {
  271. rio_dprintk(RIO_DEBUG_ROUTE, "RTA %x tried to get an ID, but does not belong - FOAD it!\n", RtaUniq);
  272. PktReplyP->Command = ROUTE_FOAD;
  273. memcpy(PktReplyP->CommandText, "RT_FOAD", 7);
  274. RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
  275. return 1;
  276. }
  277. /*
  278. ** Check to see if the RTA is configured for this host
  279. */
  280. for (ThisUnit = 0; ThisUnit < MAX_RUP; ThisUnit++) {
  281. rio_dprintk(RIO_DEBUG_ROUTE, "Entry %d Flags=%s %s UniqueNum=0x%x\n",
  282. ThisUnit, HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE ? "Slot-In-Use" : "Not In Use", HostP->Mapping[ThisUnit].Flags & SLOT_TENTATIVE ? "Slot-Tentative" : "Not Tentative", HostP->Mapping[ThisUnit].RtaUniqueNum);
  283. /*
  284. ** We have an entry for it.
  285. */
  286. if ((HostP->Mapping[ThisUnit].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (HostP->Mapping[ThisUnit].RtaUniqueNum == RtaUniq)) {
  287. if (RtaType == TYPE_RTA16) {
  288. ThisUnit2 = HostP->Mapping[ThisUnit].ID2 - 1;
  289. rio_dprintk(RIO_DEBUG_ROUTE, "Found unit 0x%x at slots %d+%d\n", RtaUniq, ThisUnit, ThisUnit2);
  290. } else
  291. rio_dprintk(RIO_DEBUG_ROUTE, "Found unit 0x%x at slot %d\n", RtaUniq, ThisUnit);
  292. /*
  293. ** If we have no knowledge of booting it, then the host has
  294. ** been re-booted, and so we must kill the RTA, so that it
  295. ** will be booted again (potentially with new bins)
  296. ** and it will then re-ask for an ID, which we will service.
  297. */
  298. if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) {
  299. if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) {
  300. if (!p->RIONoMessage)
  301. printk(KERN_DEBUG "rio: RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name);
  302. HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
  303. }
  304. PktReplyP->Command = ROUTE_FOAD;
  305. memcpy(PktReplyP->CommandText, "RT_FOAD", 7);
  306. RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
  307. return 1;
  308. }
  309. /*
  310. ** Send the ID (entry) to this RTA. The ID number is implicit as
  311. ** the offset into the table. It is worth noting at this stage
  312. ** that offset zero in the table contains the entries for the
  313. ** RTA with ID 1!!!!
  314. */
  315. PktReplyP->Command = ROUTE_ALLOCATE;
  316. PktReplyP->IDNum = ThisUnit + 1;
  317. if (RtaType == TYPE_RTA16) {
  318. if (HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE)
  319. /*
  320. ** Adjust the phb and tx pkt dest_units for 2nd block of 8
  321. ** only if the RTA has ports associated (SLOT_IN_USE)
  322. */
  323. RIOFixPhbs(p, HostP, ThisUnit2);
  324. PktReplyP->IDNum2 = ThisUnit2 + 1;
  325. rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated IDs %d+%d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum, PktReplyP->IDNum2);
  326. } else {
  327. PktReplyP->IDNum2 = ROUTE_NO_ID;
  328. rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated ID %d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum);
  329. }
  330. memcpy(PktReplyP->CommandText, "RT_ALLOCAT", 10);
  331. RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
  332. /*
  333. ** If this is a freshly booted RTA, then we need to re-open
  334. ** the ports, if any where open, so that data may once more
  335. ** flow around the system!
  336. */
  337. if ((HostP->Mapping[ThisUnit].Flags & RTA_NEWBOOT) && (HostP->Mapping[ThisUnit].SysPort != NO_PORT)) {
  338. /*
  339. ** look at the ports associated with this beast and
  340. ** see if any where open. If they was, then re-open
  341. ** them, using the info from the tty flags.
  342. */
  343. for (port = 0; port < PORTS_PER_RTA; port++) {
  344. PortP = p->RIOPortp[port + HostP->Mapping[ThisUnit].SysPort];
  345. if (PortP->State & (RIO_MOPEN | RIO_LOPEN)) {
  346. rio_dprintk(RIO_DEBUG_ROUTE, "Re-opened this port\n");
  347. rio_spin_lock_irqsave(&PortP->portSem, flags);
  348. PortP->MagicFlags |= MAGIC_REBOOT;
  349. rio_spin_unlock_irqrestore(&PortP->portSem, flags);
  350. }
  351. }
  352. if (RtaType == TYPE_RTA16) {
  353. for (port = 0; port < PORTS_PER_RTA; port++) {
  354. PortP = p->RIOPortp[port + HostP->Mapping[ThisUnit2].SysPort];
  355. if (PortP->State & (RIO_MOPEN | RIO_LOPEN)) {
  356. rio_dprintk(RIO_DEBUG_ROUTE, "Re-opened this port\n");
  357. rio_spin_lock_irqsave(&PortP->portSem, flags);
  358. PortP->MagicFlags |= MAGIC_REBOOT;
  359. rio_spin_unlock_irqrestore(&PortP->portSem, flags);
  360. }
  361. }
  362. }
  363. }
  364. /*
  365. ** keep a copy of the module types!
  366. */
  367. HostP->UnixRups[ThisUnit].ModTypes = Mod;
  368. if (RtaType == TYPE_RTA16)
  369. HostP->UnixRups[ThisUnit2].ModTypes = Mod;
  370. /*
  371. ** If either of the modules on this unit is read-only or write-only
  372. ** or none-xprint, then we need to transfer that info over to the
  373. ** relevant ports.
  374. */
  375. if (HostP->Mapping[ThisUnit].SysPort != NO_PORT) {
  376. for (port = 0; port < PORTS_PER_MODULE; port++) {
  377. p->RIOPortp[port + HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
  378. p->RIOPortp[port + HostP->Mapping[ThisUnit].SysPort]->Config |= p->RIOModuleTypes[Mod1].Flags[port];
  379. p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
  380. p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
  381. }
  382. if (RtaType == TYPE_RTA16) {
  383. for (port = 0; port < PORTS_PER_MODULE; port++) {
  384. p->RIOPortp[port + HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
  385. p->RIOPortp[port + HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod1].Flags[port];
  386. p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
  387. p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
  388. }
  389. }
  390. }
  391. /*
  392. ** Job done, get on with the interrupts!
  393. */
  394. return 1;
  395. }
  396. }
  397. /*
  398. ** There is no table entry for this RTA at all.
  399. **
  400. ** Lets check to see if we actually booted this unit - if not,
  401. ** then we reset it and it will go round the loop of being booted
  402. ** we can then worry about trying to fit it into the table.
  403. */
  404. for (ThisUnit = 0; ThisUnit < HostP->NumExtraBooted; ThisUnit++)
  405. if (HostP->ExtraUnits[ThisUnit] == RtaUniq)
  406. break;
  407. if (ThisUnit == HostP->NumExtraBooted && ThisUnit != MAX_EXTRA_UNITS) {
  408. /*
  409. ** if the unit wasn't in the table, and the table wasn't full, then
  410. ** we reset the unit, because we didn't boot it.
  411. ** However, if the table is full, it could be that we did boot
  412. ** this unit, and so we won't reboot it, because it isn't really
  413. ** all that disasterous to keep the old bins in most cases. This
  414. ** is a rather tacky feature, but we are on the edge of reallity
  415. ** here, because the implication is that someone has connected
  416. ** 16+MAX_EXTRA_UNITS onto one host.
  417. */
  418. static int UnknownMesgDone = 0;
  419. if (!UnknownMesgDone) {
  420. if (!p->RIONoMessage)
  421. printk(KERN_DEBUG "rio: One or more unknown RTAs are being updated.\n");
  422. UnknownMesgDone = 1;
  423. }
  424. PktReplyP->Command = ROUTE_FOAD;
  425. memcpy(PktReplyP->CommandText, "RT_FOAD", 7);
  426. } else {
  427. /*
  428. ** we did boot it (as an extra), and there may now be a table
  429. ** slot free (because of a delete), so we will try to make
  430. ** a tentative entry for it, so that the configurator can see it
  431. ** and fill in the details for us.
  432. */
  433. if (RtaType == TYPE_RTA16) {
  434. if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) {
  435. RIODefaultName(p, HostP, ThisUnit);
  436. rio_fill_host_slot(ThisUnit, ThisUnit2, RtaUniq, HostP);
  437. }
  438. } else {
  439. if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) {
  440. RIODefaultName(p, HostP, ThisUnit);
  441. rio_fill_host_slot(ThisUnit, 0, RtaUniq, HostP);
  442. }
  443. }
  444. PktReplyP->Command = ROUTE_USED;
  445. memcpy(PktReplyP->CommandText, "RT_USED", 7);
  446. }
  447. RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
  448. return 1;
  449. }
  450. void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit)
  451. {
  452. unsigned short link, port;
  453. struct Port *PortP;
  454. unsigned long flags;
  455. int PortN = HostP->Mapping[unit].SysPort;
  456. rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN);
  457. if (PortN != -1) {
  458. unsigned short dest_unit = HostP->Mapping[unit].ID2;
  459. /*
  460. ** Get the link number used for the 1st 8 phbs on this unit.
  461. */
  462. PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort];
  463. link = readw(&PortP->PhbP->link);
  464. for (port = 0; port < PORTS_PER_RTA; port++, PortN++) {
  465. unsigned short dest_port = port + 8;
  466. u16 __iomem *TxPktP;
  467. struct PKT __iomem *Pkt;
  468. PortP = p->RIOPortp[PortN];
  469. rio_spin_lock_irqsave(&PortP->portSem, flags);
  470. /*
  471. ** If RTA is not powered on, the tx packets will be
  472. ** unset, so go no further.
  473. */
  474. if (!PortP->TxStart) {
  475. rio_dprintk(RIO_DEBUG_ROUTE, "Tx pkts not set up yet\n");
  476. rio_spin_unlock_irqrestore(&PortP->portSem, flags);
  477. break;
  478. }
  479. /*
  480. ** For the second slot of a 16 port RTA, the driver needs to
  481. ** sort out the phb to port mappings. The dest_unit for this
  482. ** group of 8 phbs is set to the dest_unit of the accompanying
  483. ** 8 port block. The dest_port of the second unit is set to
  484. ** be in the range 8-15 (i.e. 8 is added). Thus, for a 16 port
  485. ** RTA with IDs 5 and 6, traffic bound for port 6 of unit 6
  486. ** (being the second map ID) will be sent to dest_unit 5, port
  487. ** 14. When this RTA is deleted, dest_unit for ID 6 will be
  488. ** restored, and the dest_port will be reduced by 8.
  489. ** Transmit packets also have a destination field which needs
  490. ** adjusting in the same manner.
  491. ** Note that the unit/port bytes in 'dest' are swapped.
  492. ** We also need to adjust the phb and rup link numbers for the
  493. ** second block of 8 ttys.
  494. */
  495. for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
  496. /*
  497. ** *TxPktP is the pointer to the transmit packet on the host
  498. ** card. This needs to be translated into a 32 bit pointer
  499. ** so it can be accessed from the driver.
  500. */
  501. Pkt = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(TxPktP));
  502. /*
  503. ** If the packet is used, reset it.
  504. */
  505. Pkt = (struct PKT __iomem *) ((unsigned long) Pkt & ~PKT_IN_USE);
  506. writeb(dest_unit, &Pkt->dest_unit);
  507. writeb(dest_port, &Pkt->dest_port);
  508. }
  509. rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", readw(&PortP->PhbP->destination) & 0xff, (readw(&PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port);
  510. writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
  511. writew(link, &PortP->PhbP->link);
  512. rio_spin_unlock_irqrestore(&PortP->portSem, flags);
  513. }
  514. /*
  515. ** Now make sure the range of ports to be serviced includes
  516. ** the 2nd 8 on this 16 port RTA.
  517. */
  518. if (link > 3)
  519. return;
  520. if (((unit * 8) + 7) > readw(&HostP->LinkStrP[link].last_port)) {
  521. rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7);
  522. writew((unit * 8) + 7, &HostP->LinkStrP[link].last_port);
  523. }
  524. }
  525. }
  526. /*
  527. ** Check to see if the new disconnection has isolated this unit.
  528. ** If it has, then invalidate all its link information, and tell
  529. ** the world about it. This is done to ensure that the configurator
  530. ** only gets up-to-date information about what is going on.
  531. */
  532. static int RIOCheckIsolated(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
  533. {
  534. unsigned long flags;
  535. rio_spin_lock_irqsave(&HostP->HostLock, flags);
  536. if (RIOCheck(HostP, UnitId)) {
  537. rio_dprintk(RIO_DEBUG_ROUTE, "Unit %d is NOT isolated\n", UnitId);
  538. rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
  539. return (0);
  540. }
  541. RIOIsolate(p, HostP, UnitId);
  542. RIOSetChange(p);
  543. rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
  544. return 1;
  545. }
  546. /*
  547. ** Invalidate all the link interconnectivity of this unit, and of
  548. ** all the units attached to it. This will mean that the entire
  549. ** subnet will re-introduce itself.
  550. */
  551. static int RIOIsolate(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
  552. {
  553. unsigned int link, unit;
  554. UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */
  555. if (UnitId >= MAX_RUP) /* dontcha just lurv unsigned maths! */
  556. return (0);
  557. if (HostP->Mapping[UnitId].Flags & BEEN_HERE)
  558. return (0);
  559. HostP->Mapping[UnitId].Flags |= BEEN_HERE;
  560. if (p->RIOPrintDisabled == DO_PRINT)
  561. rio_dprintk(RIO_DEBUG_ROUTE, "RIOMesgIsolated %s", HostP->Mapping[UnitId].Name);
  562. for (link = 0; link < LINKS_PER_UNIT; link++) {
  563. unit = HostP->Mapping[UnitId].Topology[link].Unit;
  564. HostP->Mapping[UnitId].Topology[link].Unit = ROUTE_DISCONNECT;
  565. HostP->Mapping[UnitId].Topology[link].Link = NO_LINK;
  566. RIOIsolate(p, HostP, unit);
  567. }
  568. HostP->Mapping[UnitId].Flags &= ~BEEN_HERE;
  569. return 1;
  570. }
  571. static int RIOCheck(struct Host *HostP, unsigned int UnitId)
  572. {
  573. unsigned char link;
  574. /* rio_dprint(RIO_DEBUG_ROUTE, ("Check to see if unit %d has a route to the host\n",UnitId)); */
  575. rio_dprintk(RIO_DEBUG_ROUTE, "RIOCheck : UnitID = %d\n", UnitId);
  576. if (UnitId == HOST_ID) {
  577. /* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d is NOT isolated - it IS the host!\n", UnitId)); */
  578. return 1;
  579. }
  580. UnitId--;
  581. if (UnitId >= MAX_RUP) {
  582. /* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d - ignored.\n", UnitId)); */
  583. return 0;
  584. }
  585. for (link = 0; link < LINKS_PER_UNIT; link++) {
  586. if (HostP->Mapping[UnitId].Topology[link].Unit == HOST_ID) {
  587. /* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d is connected directly to host via link (%c).\n",
  588. UnitId, 'A'+link)); */
  589. return 1;
  590. }
  591. }
  592. if (HostP->Mapping[UnitId].Flags & BEEN_HERE) {
  593. /* rio_dprint(RIO_DEBUG_ROUTE, ("Been to Unit %d before - ignoring\n", UnitId)); */
  594. return 0;
  595. }
  596. HostP->Mapping[UnitId].Flags |= BEEN_HERE;
  597. for (link = 0; link < LINKS_PER_UNIT; link++) {
  598. /* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d check link (%c)\n", UnitId,'A'+link)); */
  599. if (RIOCheck(HostP, HostP->Mapping[UnitId].Topology[link].Unit)) {
  600. /* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d is connected to something that knows the host via link (%c)\n", UnitId,link+'A')); */
  601. HostP->Mapping[UnitId].Flags &= ~BEEN_HERE;
  602. return 1;
  603. }
  604. }
  605. HostP->Mapping[UnitId].Flags &= ~BEEN_HERE;
  606. /* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d DOESNT KNOW THE HOST!\n", UnitId)); */
  607. return 0;
  608. }
  609. /*
  610. ** Returns the type of unit (host, 16/8 port RTA)
  611. */
  612. unsigned int GetUnitType(unsigned int Uniq)
  613. {
  614. switch ((Uniq >> 28) & 0xf) {
  615. case RIO_AT:
  616. case RIO_MCA:
  617. case RIO_EISA:
  618. case RIO_PCI:
  619. rio_dprintk(RIO_DEBUG_ROUTE, "Unit type: Host\n");
  620. return (TYPE_HOST);
  621. case RIO_RTA_16:
  622. rio_dprintk(RIO_DEBUG_ROUTE, "Unit type: 16 port RTA\n");
  623. return (TYPE_RTA16);
  624. case RIO_RTA:
  625. rio_dprintk(RIO_DEBUG_ROUTE, "Unit type: 8 port RTA\n");
  626. return (TYPE_RTA8);
  627. default:
  628. rio_dprintk(RIO_DEBUG_ROUTE, "Unit type: Unrecognised\n");
  629. return (99);
  630. }
  631. }
  632. int RIOSetChange(struct rio_info *p)
  633. {
  634. if (p->RIOQuickCheck != NOT_CHANGED)
  635. return (0);
  636. p->RIOQuickCheck = CHANGED;
  637. if (p->RIOSignalProcess) {
  638. rio_dprintk(RIO_DEBUG_ROUTE, "Send SIG-HUP");
  639. /*
  640. psignal( RIOSignalProcess, SIGHUP );
  641. */
  642. }
  643. return (0);
  644. }
  645. static void RIOConCon(struct rio_info *p,
  646. struct Host *HostP,
  647. unsigned int FromId,
  648. unsigned int FromLink,
  649. unsigned int ToId,
  650. unsigned int ToLink,
  651. int Change)
  652. {
  653. char *FromName;
  654. char *FromType;
  655. char *ToName;
  656. char *ToType;
  657. unsigned int tp;
  658. /*
  659. ** 15.10.1998 ARG - ESIL 0759
  660. ** (Part) fix for port being trashed when opened whilst RTA "disconnected"
  661. **
  662. ** What's this doing in here anyway ?
  663. ** It was causing the port to be 'unmapped' if opened whilst RTA "disconnected"
  664. **
  665. ** 09.12.1998 ARG - ESIL 0776 - part fix
  666. ** Okay, We've found out what this was all about now !
  667. ** Someone had botched this to use RIOHalted to indicated the number of RTAs
  668. ** 'disconnected'. The value in RIOHalted was then being used in the
  669. ** 'RIO_QUICK_CHECK' ioctl. A none zero value indicating that a least one RTA
  670. ** is 'disconnected'. The change was put in to satisfy a customer's needs.
  671. ** Having taken this bit of code out 'RIO_QUICK_CHECK' now no longer works for
  672. ** the customer.
  673. **
  674. if (Change == CONNECT) {
  675. if (p->RIOHalted) p->RIOHalted --;
  676. }
  677. else {
  678. p->RIOHalted ++;
  679. }
  680. **
  681. ** So - we need to implement it slightly differently - a new member of the
  682. ** rio_info struct - RIORtaDisCons (RIO RTA connections) keeps track of RTA
  683. ** connections and disconnections.
  684. */
  685. if (Change == CONNECT) {
  686. if (p->RIORtaDisCons)
  687. p->RIORtaDisCons--;
  688. } else {
  689. p->RIORtaDisCons++;
  690. }
  691. if (p->RIOPrintDisabled == DONT_PRINT)
  692. return;
  693. if (FromId > ToId) {
  694. tp = FromId;
  695. FromId = ToId;
  696. ToId = tp;
  697. tp = FromLink;
  698. FromLink = ToLink;
  699. ToLink = tp;
  700. }
  701. FromName = FromId ? HostP->Mapping[FromId - 1].Name : HostP->Name;
  702. FromType = FromId ? "RTA" : "HOST";
  703. ToName = ToId ? HostP->Mapping[ToId - 1].Name : HostP->Name;
  704. ToType = ToId ? "RTA" : "HOST";
  705. 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");
  706. printk(KERN_DEBUG "rio: Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
  707. }
  708. /*
  709. ** RIORemoveFromSavedTable :
  710. **
  711. ** Delete and RTA entry from the saved table given to us
  712. ** by the configuration program.
  713. */
  714. static int RIORemoveFromSavedTable(struct rio_info *p, struct Map *pMap)
  715. {
  716. int entry;
  717. /*
  718. ** We loop for all entries even after finding an entry and
  719. ** zeroing it because we may have two entries to delete if
  720. ** it's a 16 port RTA.
  721. */
  722. for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
  723. if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) {
  724. memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
  725. }
  726. }
  727. return 0;
  728. }
  729. /*
  730. ** RIOCheckDisconnected :
  731. **
  732. ** Scan the unit links to and return zero if the unit is completely
  733. ** disconnected.
  734. */
  735. static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
  736. {
  737. int link;
  738. rio_dprintk(RIO_DEBUG_ROUTE, "RIOFreeDisconnect unit %d\n", unit);
  739. /*
  740. ** If the slot is tentative and does not belong to the
  741. ** second half of a 16 port RTA then scan to see if
  742. ** is disconnected.
  743. */
  744. for (link = 0; link < LINKS_PER_UNIT; link++) {
  745. if (HostP->Mapping[unit].Topology[link].Unit != ROUTE_DISCONNECT)
  746. break;
  747. }
  748. /*
  749. ** If not all links are disconnected then we can forget about it.
  750. */
  751. if (link < LINKS_PER_UNIT)
  752. return 1;
  753. #ifdef NEED_TO_FIX_THIS
  754. /* Ok so all the links are disconnected. But we may have only just
  755. ** made this slot tentative and not yet received a topology update.
  756. ** Lets check how long ago we made it tentative.
  757. */
  758. rio_dprintk(RIO_DEBUG_ROUTE, "Just about to check LBOLT on entry %d\n", unit);
  759. if (drv_getparm(LBOLT, (ulong_t *) & current_time))
  760. rio_dprintk(RIO_DEBUG_ROUTE, "drv_getparm(LBOLT,....) Failed.\n");
  761. elapse_time = current_time - TentTime[unit];
  762. rio_dprintk(RIO_DEBUG_ROUTE, "elapse %d = current %d - tent %d (%d usec)\n", elapse_time, current_time, TentTime[unit], drv_hztousec(elapse_time));
  763. if (drv_hztousec(elapse_time) < WAIT_TO_FINISH) {
  764. rio_dprintk(RIO_DEBUG_ROUTE, "Skipping slot %d, not timed out yet %d\n", unit, drv_hztousec(elapse_time));
  765. return 1;
  766. }
  767. #endif
  768. /*
  769. ** We have found an usable slot.
  770. ** If it is half of a 16 port RTA then delete the other half.
  771. */
  772. if (HostP->Mapping[unit].ID2 != 0) {
  773. int nOther = (HostP->Mapping[unit].ID2) - 1;
  774. rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther);
  775. memset(&HostP->Mapping[nOther], 0, sizeof(struct Map));
  776. }
  777. RIORemoveFromSavedTable(p, &HostP->Mapping[unit]);
  778. return 0;
  779. }
  780. /*
  781. ** RIOFindFreeID :
  782. **
  783. ** This function scans the given host table for either one
  784. ** or two free unit ID's.
  785. */
  786. int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, unsigned int * pID2)
  787. {
  788. int unit, tempID;
  789. /*
  790. ** Initialise the ID's to MAX_RUP.
  791. ** We do this to make the loop for setting the ID's as simple as
  792. ** possible.
  793. */
  794. *pID1 = MAX_RUP;
  795. if (pID2 != NULL)
  796. *pID2 = MAX_RUP;
  797. /*
  798. ** Scan all entries of the host mapping table for free slots.
  799. ** We scan for free slots first and then if that is not successful
  800. ** we start all over again looking for tentative slots we can re-use.
  801. */
  802. for (unit = 0; unit < MAX_RUP; unit++) {
  803. rio_dprintk(RIO_DEBUG_ROUTE, "Scanning unit %d\n", unit);
  804. /*
  805. ** If the flags are zero then the slot is empty.
  806. */
  807. if (HostP->Mapping[unit].Flags == 0) {
  808. rio_dprintk(RIO_DEBUG_ROUTE, " This slot is empty.\n");
  809. /*
  810. ** If we haven't allocated the first ID then do it now.
  811. */
  812. if (*pID1 == MAX_RUP) {
  813. rio_dprintk(RIO_DEBUG_ROUTE, "Make tentative entry for first unit %d\n", unit);
  814. *pID1 = unit;
  815. /*
  816. ** If the second ID is not needed then we can return
  817. ** now.
  818. */
  819. if (pID2 == NULL)
  820. return 0;
  821. } else {
  822. /*
  823. ** Allocate the second slot and return.
  824. */
  825. rio_dprintk(RIO_DEBUG_ROUTE, "Make tentative entry for second unit %d\n", unit);
  826. *pID2 = unit;
  827. return 0;
  828. }
  829. }
  830. }
  831. /*
  832. ** If we manage to come out of the free slot loop then we
  833. ** need to start all over again looking for tentative slots
  834. ** that we can re-use.
  835. */
  836. rio_dprintk(RIO_DEBUG_ROUTE, "Starting to scan for tentative slots\n");
  837. for (unit = 0; unit < MAX_RUP; unit++) {
  838. if (((HostP->Mapping[unit].Flags & SLOT_TENTATIVE) || (HostP->Mapping[unit].Flags == 0)) && !(HostP->Mapping[unit].Flags & RTA16_SECOND_SLOT)) {
  839. rio_dprintk(RIO_DEBUG_ROUTE, " Slot %d looks promising.\n", unit);
  840. if (unit == *pID1) {
  841. rio_dprintk(RIO_DEBUG_ROUTE, " No it isn't, its the 1st half\n");
  842. continue;
  843. }
  844. /*
  845. ** Slot is Tentative or Empty, but not a tentative second
  846. ** slot of a 16 porter.
  847. ** Attempt to free up this slot (and its parnter if
  848. ** it is a 16 port slot. The second slot will become
  849. ** empty after a call to RIOFreeDisconnected so thats why
  850. ** we look for empty slots above as well).
  851. */
  852. if (HostP->Mapping[unit].Flags != 0)
  853. if (RIOFreeDisconnected(p, HostP, unit) != 0)
  854. continue;
  855. /*
  856. ** If we haven't allocated the first ID then do it now.
  857. */
  858. if (*pID1 == MAX_RUP) {
  859. rio_dprintk(RIO_DEBUG_ROUTE, "Grab tentative entry for first unit %d\n", unit);
  860. *pID1 = unit;
  861. /*
  862. ** Clear out this slot now that we intend to use it.
  863. */
  864. memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
  865. /*
  866. ** If the second ID is not needed then we can return
  867. ** now.
  868. */
  869. if (pID2 == NULL)
  870. return 0;
  871. } else {
  872. /*
  873. ** Allocate the second slot and return.
  874. */
  875. rio_dprintk(RIO_DEBUG_ROUTE, "Grab tentative/empty entry for second unit %d\n", unit);
  876. *pID2 = unit;
  877. /*
  878. ** Clear out this slot now that we intend to use it.
  879. */
  880. memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
  881. /* At this point under the right(wrong?) conditions
  882. ** we may have a first unit ID being higher than the
  883. ** second unit ID. This is a bad idea if we are about
  884. ** to fill the slots with a 16 port RTA.
  885. ** Better check and swap them over.
  886. */
  887. if (*pID1 > *pID2) {
  888. rio_dprintk(RIO_DEBUG_ROUTE, "Swapping IDS %d %d\n", *pID1, *pID2);
  889. tempID = *pID1;
  890. *pID1 = *pID2;
  891. *pID2 = tempID;
  892. }
  893. return 0;
  894. }
  895. }
  896. }
  897. /*
  898. ** If we manage to get to the end of the second loop then we
  899. ** can give up and return a failure.
  900. */
  901. return 1;
  902. }
  903. /*
  904. ** The link switch scenario.
  905. **
  906. ** Rta Wun (A) is connected to Tuw (A).
  907. ** The tables are all up to date, and the system is OK.
  908. **
  909. ** If Wun (A) is now moved to Wun (B) before Wun (A) can
  910. ** become disconnected, then the follow happens:
  911. **
  912. ** Tuw (A) spots the change of unit:link at the other end
  913. ** of its link and Tuw sends a topology packet reflecting
  914. ** the change: Tuw (A) now disconnected from Wun (A), and
  915. ** this is closely followed by a packet indicating that
  916. ** Tuw (A) is now connected to Wun (B).
  917. **
  918. ** Wun (B) will spot that it has now become connected, and
  919. ** Wun will send a topology packet, which indicates that
  920. ** both Wun (A) and Wun (B) is connected to Tuw (A).
  921. **
  922. ** Eventually Wun (A) realises that it is now disconnected
  923. ** and Wun will send out a topology packet indicating that
  924. ** Wun (A) is now disconnected.
  925. */