aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/rio/rioroute.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/rio/rioroute.c')
-rw-r--r--drivers/char/rio/rioroute.c110
1 files changed, 43 insertions, 67 deletions
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index 874ac7462388..357085337942 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -50,15 +50,12 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
50 50
51#include "linux_compat.h" 51#include "linux_compat.h"
52#include "rio_linux.h" 52#include "rio_linux.h"
53#include "typdef.h"
54#include "pkt.h" 53#include "pkt.h"
55#include "daemon.h" 54#include "daemon.h"
56#include "rio.h" 55#include "rio.h"
57#include "riospace.h" 56#include "riospace.h"
58#include "top.h"
59#include "cmdpkt.h" 57#include "cmdpkt.h"
60#include "map.h" 58#include "map.h"
61#include "riotypes.h"
62#include "rup.h" 59#include "rup.h"
63#include "port.h" 60#include "port.h"
64#include "riodrvr.h" 61#include "riodrvr.h"
@@ -71,29 +68,25 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
71#include "unixrup.h" 68#include "unixrup.h"
72#include "board.h" 69#include "board.h"
73#include "host.h" 70#include "host.h"
74#include "error.h"
75#include "phb.h" 71#include "phb.h"
76#include "link.h" 72#include "link.h"
77#include "cmdblk.h" 73#include "cmdblk.h"
78#include "route.h" 74#include "route.h"
79#include "control.h"
80#include "cirrus.h" 75#include "cirrus.h"
81#include "rioioctl.h" 76#include "rioioctl.h"
82#include "param.h" 77#include "param.h"
83#include "list.h"
84#include "sam.h"
85 78
86static int RIOCheckIsolated(struct rio_info *, struct Host *, uint); 79static int RIOCheckIsolated(struct rio_info *, struct Host *, unsigned int);
87static int RIOIsolate(struct rio_info *, struct Host *, uint); 80static int RIOIsolate(struct rio_info *, struct Host *, unsigned int);
88static int RIOCheck(struct Host *, uint); 81static int RIOCheck(struct Host *, unsigned int);
89static void RIOConCon(struct rio_info *, struct Host *, uint, uint, uint, uint, int); 82static void RIOConCon(struct rio_info *, struct Host *, unsigned int, unsigned int, unsigned int, unsigned int, int);
90 83
91 84
92/* 85/*
93** Incoming on the ROUTE_RUP 86** Incoming on the ROUTE_RUP
94** I wrote this while I was tired. Forgive me. 87** I wrote this while I was tired. Forgive me.
95*/ 88*/
96int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 89int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT * PacketP)
97{ 90{
98 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 91 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
99 struct PktCmd_M *PktReplyP; 92 struct PktCmd_M *PktReplyP;
@@ -104,10 +97,10 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
104 int ThisLink, ThisLinkMin, ThisLinkMax; 97 int ThisLink, ThisLinkMin, ThisLinkMax;
105 int port; 98 int port;
106 int Mod, Mod1, Mod2; 99 int Mod, Mod1, Mod2;
107 ushort RtaType; 100 unsigned short RtaType;
108 uint RtaUniq; 101 unsigned int RtaUniq;
109 uint ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */ 102 unsigned int ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */
110 uint OldUnit, NewUnit, OldLink, NewLink; 103 unsigned int OldUnit, NewUnit, OldLink, NewLink;
111 char *MyType, *MyName; 104 char *MyType, *MyName;
112 int Lies; 105 int Lies;
113 unsigned long flags; 106 unsigned long flags;
@@ -125,7 +118,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
125 ** from an RTA then we need to fill in the Mapping structure's 118 ** from an RTA then we need to fill in the Mapping structure's
126 ** Topology array for the unit. 119 ** Topology array for the unit.
127 */ 120 */
128 if (Rup >= (ushort) MAX_RUP) { 121 if (Rup >= (unsigned short) MAX_RUP) {
129 ThisUnit = HOST_ID; 122 ThisUnit = HOST_ID;
130 TopP = HostP->Topology; 123 TopP = HostP->Topology;
131 MyType = "Host"; 124 MyType = "Host";
@@ -151,7 +144,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
151 ** it won't lie about network interconnect, total disconnects 144 ** it won't lie about network interconnect, total disconnects
152 ** and no-IDs. (or at least, it doesn't *matter* if it does) 145 ** and no-IDs. (or at least, it doesn't *matter* if it does)
153 */ 146 */
154 if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (ushort) MAX_RUP) 147 if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (unsigned short) MAX_RUP)
155 continue; 148 continue;
156 149
157 for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) { 150 for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) {
@@ -168,7 +161,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
168 'A' + readb(&PktCmdP->RouteTopology[0].Link), 161 'A' + readb(&PktCmdP->RouteTopology[0].Link),
169 readb(&PktCmdP->RouteTopology[1].Unit), 162 readb(&PktCmdP->RouteTopology[1].Unit),
170 '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)); 163 '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));
171 return TRUE; 164 return 1;
172 } 165 }
173 166
174 /* 167 /*
@@ -258,7 +251,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
258 RIOCheckIsolated(p, HostP, OldUnit); 251 RIOCheckIsolated(p, HostP, OldUnit);
259 } 252 }
260 } 253 }
261 return TRUE; 254 return 1;
262 } 255 }
263 256
264 /* 257 /*
@@ -266,7 +259,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
266 */ 259 */
267 if (readb(&PktCmdP->Command) != ROUTE_REQUEST) { 260 if (readb(&PktCmdP->Command) != ROUTE_REQUEST) {
268 rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %p ROUTE_RUP\n", readb(&PktCmdP->Command), Rup, HostP); 261 rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %p ROUTE_RUP\n", readb(&PktCmdP->Command), Rup, HostP);
269 return TRUE; 262 return 1;
270 } 263 }
271 264
272 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24); 265 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
@@ -292,10 +285,6 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
292 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); 285 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);
293 } 286 }
294 287
295 if (RtaUniq == 0xffffffff) {
296 ShowPacket(DBG_SPECIAL, PacketP);
297 }
298
299 /* 288 /*
300 ** try to unhook a command block from the command free list. 289 ** try to unhook a command block from the command free list.
301 */ 290 */
@@ -320,7 +309,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
320 PktReplyP->Command = ROUTE_FOAD; 309 PktReplyP->Command = ROUTE_FOAD;
321 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 310 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
322 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 311 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
323 return TRUE; 312 return 1;
324 } 313 }
325 314
326 /* 315 /*
@@ -354,7 +343,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
354 PktReplyP->Command = ROUTE_FOAD; 343 PktReplyP->Command = ROUTE_FOAD;
355 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 344 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
356 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 345 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
357 return TRUE; 346 return 1;
358 } 347 }
359 348
360 /* 349 /*
@@ -447,7 +436,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
447 /* 436 /*
448 ** Job done, get on with the interrupts! 437 ** Job done, get on with the interrupts!
449 */ 438 */
450 return TRUE; 439 return 1;
451 } 440 }
452 } 441 }
453 /* 442 /*
@@ -491,28 +480,25 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
491 if (RtaType == TYPE_RTA16) { 480 if (RtaType == TYPE_RTA16) {
492 if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) { 481 if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) {
493 RIODefaultName(p, HostP, ThisUnit); 482 RIODefaultName(p, HostP, ThisUnit);
494 FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP); 483 rio_fill_host_slot(ThisUnit, ThisUnit2, RtaUniq, HostP);
495 } 484 }
496 } else { 485 } else {
497 if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) { 486 if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) {
498 RIODefaultName(p, HostP, ThisUnit); 487 RIODefaultName(p, HostP, ThisUnit);
499 FillSlot(ThisUnit, 0, RtaUniq, HostP); 488 rio_fill_host_slot(ThisUnit, 0, RtaUniq, HostP);
500 } 489 }
501 } 490 }
502 PktReplyP->Command = ROUTE_USED; 491 PktReplyP->Command = ROUTE_USED;
503 HostP->Copy("RT_USED", PktReplyP->CommandText, 7); 492 HostP->Copy("RT_USED", PktReplyP->CommandText, 7);
504 } 493 }
505 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 494 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
506 return TRUE; 495 return 1;
507} 496}
508 497
509 498
510void RIOFixPhbs(p, HostP, unit) 499void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit)
511struct rio_info *p;
512struct Host *HostP;
513uint unit;
514{ 500{
515 ushort link, port; 501 unsigned short link, port;
516 struct Port *PortP; 502 struct Port *PortP;
517 unsigned long flags; 503 unsigned long flags;
518 int PortN = HostP->Mapping[unit].SysPort; 504 int PortN = HostP->Mapping[unit].SysPort;
@@ -520,7 +506,7 @@ uint unit;
520 rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN); 506 rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN);
521 507
522 if (PortN != -1) { 508 if (PortN != -1) {
523 ushort dest_unit = HostP->Mapping[unit].ID2; 509 unsigned short dest_unit = HostP->Mapping[unit].ID2;
524 510
525 /* 511 /*
526 ** Get the link number used for the 1st 8 phbs on this unit. 512 ** Get the link number used for the 1st 8 phbs on this unit.
@@ -530,9 +516,9 @@ uint unit;
530 link = readw(&PortP->PhbP->link); 516 link = readw(&PortP->PhbP->link);
531 517
532 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) { 518 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) {
533 ushort dest_port = port + 8; 519 unsigned short dest_port = port + 8;
534 WORD *TxPktP; 520 u16 *TxPktP;
535 PKT *Pkt; 521 struct PKT *Pkt;
536 522
537 PortP = p->RIOPortp[PortN]; 523 PortP = p->RIOPortp[PortN];
538 524
@@ -569,12 +555,12 @@ uint unit;
569 ** card. This needs to be translated into a 32 bit pointer 555 ** card. This needs to be translated into a 32 bit pointer
570 ** so it can be accessed from the driver. 556 ** so it can be accessed from the driver.
571 */ 557 */
572 Pkt = (PKT *) RIO_PTR(HostP->Caddr, readw(TxPktP)); 558 Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(TxPktP));
573 559
574 /* 560 /*
575 ** If the packet is used, reset it. 561 ** If the packet is used, reset it.
576 */ 562 */
577 Pkt = (PKT *) ((unsigned long) Pkt & ~PKT_IN_USE); 563 Pkt = (struct PKT *) ((unsigned long) Pkt & ~PKT_IN_USE);
578 writeb(dest_unit, &Pkt->dest_unit); 564 writeb(dest_unit, &Pkt->dest_unit);
579 writeb(dest_port, &Pkt->dest_port); 565 writeb(dest_port, &Pkt->dest_port);
580 } 566 }
@@ -603,10 +589,7 @@ uint unit;
603** the world about it. This is done to ensure that the configurator 589** the world about it. This is done to ensure that the configurator
604** only gets up-to-date information about what is going on. 590** only gets up-to-date information about what is going on.
605*/ 591*/
606static int RIOCheckIsolated(p, HostP, UnitId) 592static int RIOCheckIsolated(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
607struct rio_info *p;
608struct Host *HostP;
609uint UnitId;
610{ 593{
611 unsigned long flags; 594 unsigned long flags;
612 rio_spin_lock_irqsave(&HostP->HostLock, flags); 595 rio_spin_lock_irqsave(&HostP->HostLock, flags);
@@ -628,12 +611,9 @@ uint UnitId;
628** all the units attached to it. This will mean that the entire 611** all the units attached to it. This will mean that the entire
629** subnet will re-introduce itself. 612** subnet will re-introduce itself.
630*/ 613*/
631static int RIOIsolate(p, HostP, UnitId) 614static int RIOIsolate(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
632struct rio_info *p;
633struct Host *HostP;
634uint UnitId;
635{ 615{
636 uint link, unit; 616 unsigned int link, unit;
637 617
638 UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */ 618 UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */
639 619
@@ -658,9 +638,7 @@ uint UnitId;
658 return 1; 638 return 1;
659} 639}
660 640
661static int RIOCheck(HostP, UnitId) 641static int RIOCheck(struct Host *HostP, unsigned int UnitId)
662struct Host *HostP;
663uint UnitId;
664{ 642{
665 unsigned char link; 643 unsigned char link;
666 644
@@ -714,8 +692,7 @@ uint UnitId;
714** Returns the type of unit (host, 16/8 port RTA) 692** Returns the type of unit (host, 16/8 port RTA)
715*/ 693*/
716 694
717uint GetUnitType(Uniq) 695unsigned int GetUnitType(unsigned int Uniq)
718uint Uniq;
719{ 696{
720 switch ((Uniq >> 28) & 0xf) { 697 switch ((Uniq >> 28) & 0xf) {
721 case RIO_AT: 698 case RIO_AT:
@@ -736,8 +713,7 @@ uint Uniq;
736 } 713 }
737} 714}
738 715
739int RIOSetChange(p) 716int RIOSetChange(struct rio_info *p)
740struct rio_info *p;
741{ 717{
742 if (p->RIOQuickCheck != NOT_CHANGED) 718 if (p->RIOQuickCheck != NOT_CHANGED)
743 return (0); 719 return (0);
@@ -751,14 +727,13 @@ struct rio_info *p;
751 return (0); 727 return (0);
752} 728}
753 729
754static void RIOConCon(p, HostP, FromId, FromLink, ToId, ToLink, Change) 730static void RIOConCon(struct rio_info *p,
755struct rio_info *p; 731 struct Host *HostP,
756struct Host *HostP; 732 unsigned int FromId,
757uint FromId; 733 unsigned int FromLink,
758uint FromLink; 734 unsigned int ToId,
759uint ToId; 735 unsigned int ToLink,
760uint ToLink; 736 int Change)
761int Change;
762{ 737{
763 char *FromName; 738 char *FromName;
764 char *FromType; 739 char *FromType;
@@ -912,7 +887,8 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
912** This function scans the given host table for either one 887** This function scans the given host table for either one
913** or two free unit ID's. 888** or two free unit ID's.
914*/ 889*/
915int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pID2) 890
891int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, unsigned int * pID2)
916{ 892{
917 int unit, tempID; 893 int unit, tempID;
918 894