X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fchar%2Frio%2Frioroute.c;fp=drivers%2Fchar%2Frio%2Frioroute.c;h=f98888f52659accc9961c18b92749dc590ead787;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=a99f3d9d7d652a1bfa63d142890de86448cbe991;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c index a99f3d9d7..f98888f52 100644 --- a/drivers/char/rio/rioroute.c +++ b/drivers/char/rio/rioroute.c @@ -50,12 +50,15 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3"; #include "linux_compat.h" #include "rio_linux.h" +#include "typdef.h" #include "pkt.h" #include "daemon.h" #include "rio.h" #include "riospace.h" +#include "top.h" #include "cmdpkt.h" #include "map.h" +#include "riotypes.h" #include "rup.h" #include "port.h" #include "riodrvr.h" @@ -68,27 +71,31 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3"; #include "unixrup.h" #include "board.h" #include "host.h" +#include "error.h" #include "phb.h" #include "link.h" #include "cmdblk.h" #include "route.h" +#include "control.h" #include "cirrus.h" #include "rioioctl.h" #include "param.h" +#include "list.h" +#include "sam.h" -static int RIOCheckIsolated(struct rio_info *, struct Host *, unsigned int); -static int RIOIsolate(struct rio_info *, struct Host *, unsigned int); -static int RIOCheck(struct Host *, unsigned int); -static void RIOConCon(struct rio_info *, struct Host *, unsigned int, unsigned int, unsigned int, unsigned int, int); +static int RIOCheckIsolated(struct rio_info *, struct Host *, uint); +static int RIOIsolate(struct rio_info *, struct Host *, uint); +static int RIOCheck(struct Host *, uint); +static void RIOConCon(struct rio_info *, struct Host *, uint, uint, uint, uint, int); /* ** Incoming on the ROUTE_RUP ** I wrote this while I was tired. Forgive me. */ -int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem * PacketP) +int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) { - struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data; + struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; struct PktCmd_M *PktReplyP; struct CmdBlk *CmdBlkP; struct Port *PortP; @@ -97,10 +104,10 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct int ThisLink, ThisLinkMin, ThisLinkMax; int port; int Mod, Mod1, Mod2; - unsigned short RtaType; - unsigned int RtaUniq; - unsigned int ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */ - unsigned int OldUnit, NewUnit, OldLink, NewLink; + ushort RtaType; + uint RtaUniq; + uint ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */ + uint OldUnit, NewUnit, OldLink, NewLink; char *MyType, *MyName; int Lies; unsigned long flags; @@ -108,7 +115,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct /* ** Is this unit telling us it's current link topology? */ - if (readb(&PktCmdP->Command) == ROUTE_TOPOLOGY) { + if (RBYTE(PktCmdP->Command) == ROUTE_TOPOLOGY) { MapP = HostP->Mapping; /* @@ -118,7 +125,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct ** from an RTA then we need to fill in the Mapping structure's ** Topology array for the unit. */ - if (Rup >= (unsigned short) MAX_RUP) { + if (Rup >= (ushort) MAX_RUP) { ThisUnit = HOST_ID; TopP = HostP->Topology; MyType = "Host"; @@ -144,11 +151,11 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct ** it won't lie about network interconnect, total disconnects ** and no-IDs. (or at least, it doesn't *matter* if it does) */ - if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (unsigned short) MAX_RUP) + if (RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) > (ushort) MAX_RUP) continue; for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) { - if ((readb(&PktCmdP->RouteTopology[ThisLink].Unit) == readb(&PktCmdP->RouteTopology[NewLink].Unit)) && (readb(&PktCmdP->RouteTopology[ThisLink].Link) == readb(&PktCmdP->RouteTopology[NewLink].Link))) { + if ((RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) == RBYTE(PktCmdP->RouteTopology[NewLink].Unit)) && (RBYTE(PktCmdP->RouteTopology[ThisLink].Link) == RBYTE(PktCmdP->RouteTopology[NewLink].Link))) { Lies++; } } @@ -157,11 +164,11 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct if (Lies) { rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies); rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n", - readb(&PktCmdP->RouteTopology[0].Unit), - 'A' + readb(&PktCmdP->RouteTopology[0].Link), - readb(&PktCmdP->RouteTopology[1].Unit), - '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)); - return 1; + RBYTE(PktCmdP->RouteTopology[0].Unit), + 'A' + RBYTE(PktCmdP->RouteTopology[0].Link), + RBYTE(PktCmdP->RouteTopology[1].Unit), + 'A' + RBYTE(PktCmdP->RouteTopology[1].Link), RBYTE(PktCmdP->RouteTopology[2].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[2].Link), RBYTE(PktCmdP->RouteTopology[3].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[3].Link)); + return TRUE; } /* @@ -177,8 +184,8 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct /* ** this is what it is now connected to */ - NewUnit = readb(&PktCmdP->RouteTopology[ThisLink].Unit); - NewLink = readb(&PktCmdP->RouteTopology[ThisLink].Link); + NewUnit = RBYTE(PktCmdP->RouteTopology[ThisLink].Unit); + NewLink = RBYTE(PktCmdP->RouteTopology[ThisLink].Link); if (OldUnit != NewUnit || OldLink != NewLink) { /* @@ -212,7 +219,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct if (NewUnit == ROUTE_INTERCONNECT) { if (!p->RIONoMessage) - printk(KERN_DEBUG "rio: %s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink); + cprintf("%s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink); } /* @@ -251,18 +258,18 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct RIOCheckIsolated(p, HostP, OldUnit); } } - return 1; + return TRUE; } /* ** The only other command we recognise is a route_request command */ - if (readb(&PktCmdP->Command) != ROUTE_REQUEST) { - rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %p ROUTE_RUP\n", readb(&PktCmdP->Command), Rup, HostP); - return 1; + if (RBYTE(PktCmdP->Command) != ROUTE_REQUEST) { + rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %d ROUTE_RUP\n", RBYTE(PktCmdP->Command), Rup, (int) HostP); + return TRUE; } - RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24); + RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + (RBYTE(PktCmdP->UniqNum[1]) << 8) + (RBYTE(PktCmdP->UniqNum[2]) << 16) + (RBYTE(PktCmdP->UniqNum[3]) << 24); /* ** Determine if 8 or 16 port RTA @@ -271,7 +278,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq); - Mod = readb(&PktCmdP->ModuleTypes); + Mod = RBYTE(PktCmdP->ModuleTypes); Mod1 = LONYBLE(Mod); if (RtaType == TYPE_RTA16) { /* @@ -285,6 +292,10 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct 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); } + if (RtaUniq == 0xffffffff) { + ShowPacket(DBG_SPECIAL, PacketP); + } + /* ** try to unhook a command block from the command free list. */ @@ -307,9 +318,9 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct if (!RIOBootOk(p, HostP, RtaUniq)) { rio_dprintk(RIO_DEBUG_ROUTE, "RTA %x tried to get an ID, but does not belong - FOAD it!\n", RtaUniq); PktReplyP->Command = ROUTE_FOAD; - memcpy(PktReplyP->CommandText, "RT_FOAD", 7); + HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); RIOQueueCmdBlk(HostP, Rup, CmdBlkP); - return 1; + return TRUE; } /* @@ -337,13 +348,13 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) { if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) { if (!p->RIONoMessage) - printk(KERN_DEBUG "rio: RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name); + cprintf("RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name); HostP->Mapping[ThisUnit].Flags |= MSG_DONE; } PktReplyP->Command = ROUTE_FOAD; - memcpy(PktReplyP->CommandText, "RT_FOAD", 7); + HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); RIOQueueCmdBlk(HostP, Rup, CmdBlkP); - return 1; + return TRUE; } /* @@ -367,7 +378,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PktReplyP->IDNum2 = ROUTE_NO_ID; rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated ID %d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum); } - memcpy(PktReplyP->CommandText, "RT_ALLOCAT", 10); + HostP->Copy("RT_ALLOCAT", PktReplyP->CommandText, 10); RIOQueueCmdBlk(HostP, Rup, CmdBlkP); @@ -436,7 +447,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct /* ** Job done, get on with the interrupts! */ - return 1; + return TRUE; } } /* @@ -464,12 +475,12 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct if (!UnknownMesgDone) { if (!p->RIONoMessage) - printk(KERN_DEBUG "rio: One or more unknown RTAs are being updated.\n"); + cprintf("One or more unknown RTAs are being updated.\n"); UnknownMesgDone = 1; } PktReplyP->Command = ROUTE_FOAD; - memcpy(PktReplyP->CommandText, "RT_FOAD", 7); + HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); } else { /* ** we did boot it (as an extra), and there may now be a table @@ -480,25 +491,28 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct if (RtaType == TYPE_RTA16) { if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) { RIODefaultName(p, HostP, ThisUnit); - rio_fill_host_slot(ThisUnit, ThisUnit2, RtaUniq, HostP); + FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP); } } else { if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) { RIODefaultName(p, HostP, ThisUnit); - rio_fill_host_slot(ThisUnit, 0, RtaUniq, HostP); + FillSlot(ThisUnit, 0, RtaUniq, HostP); } } PktReplyP->Command = ROUTE_USED; - memcpy(PktReplyP->CommandText, "RT_USED", 7); + HostP->Copy("RT_USED", PktReplyP->CommandText, 7); } RIOQueueCmdBlk(HostP, Rup, CmdBlkP); - return 1; + return TRUE; } -void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit) +void RIOFixPhbs(p, HostP, unit) +struct rio_info *p; +struct Host *HostP; +uint unit; { - unsigned short link, port; + ushort link, port; struct Port *PortP; unsigned long flags; int PortN = HostP->Mapping[unit].SysPort; @@ -506,19 +520,19 @@ void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit) rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN); if (PortN != -1) { - unsigned short dest_unit = HostP->Mapping[unit].ID2; + ushort dest_unit = HostP->Mapping[unit].ID2; /* ** Get the link number used for the 1st 8 phbs on this unit. */ PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort]; - link = readw(&PortP->PhbP->link); + link = RWORD(PortP->PhbP->link); for (port = 0; port < PORTS_PER_RTA; port++, PortN++) { - unsigned short dest_port = port + 8; - u16 __iomem *TxPktP; - struct PKT __iomem *Pkt; + ushort dest_port = port + 8; + WORD *TxPktP; + PKT *Pkt; PortP = p->RIOPortp[PortN]; @@ -555,18 +569,18 @@ void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit) ** card. This needs to be translated into a 32 bit pointer ** so it can be accessed from the driver. */ - Pkt = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(TxPktP)); + Pkt = (PKT *) RIO_PTR(HostP->Caddr, RINDW(TxPktP)); /* ** If the packet is used, reset it. */ - Pkt = (struct PKT __iomem *) ((unsigned long) Pkt & ~PKT_IN_USE); - writeb(dest_unit, &Pkt->dest_unit); - writeb(dest_port, &Pkt->dest_port); + Pkt = (PKT *) ((uint) Pkt & ~PKT_IN_USE); + WBYTE(Pkt->dest_unit, dest_unit); + WBYTE(Pkt->dest_port, dest_port); } - 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); - writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination); - writew(link, &PortP->PhbP->link); + rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", RWORD(PortP->PhbP->destination) & 0xff, (RWORD(PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port); + WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8)); + WWORD(PortP->PhbP->link, link); rio_spin_unlock_irqrestore(&PortP->portSem, flags); } @@ -576,9 +590,9 @@ void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit) */ if (link > 3) return; - if (((unit * 8) + 7) > readw(&HostP->LinkStrP[link].last_port)) { + if (((unit * 8) + 7) > RWORD(HostP->LinkStrP[link].last_port)) { rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7); - writew((unit * 8) + 7, &HostP->LinkStrP[link].last_port); + WWORD(HostP->LinkStrP[link].last_port, (unit * 8) + 7); } } } @@ -589,7 +603,10 @@ void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit) ** the world about it. This is done to ensure that the configurator ** only gets up-to-date information about what is going on. */ -static int RIOCheckIsolated(struct rio_info *p, struct Host *HostP, unsigned int UnitId) +static int RIOCheckIsolated(p, HostP, UnitId) +struct rio_info *p; +struct Host *HostP; +uint UnitId; { unsigned long flags; rio_spin_lock_irqsave(&HostP->HostLock, flags); @@ -611,9 +628,12 @@ static int RIOCheckIsolated(struct rio_info *p, struct Host *HostP, unsigned int ** all the units attached to it. This will mean that the entire ** subnet will re-introduce itself. */ -static int RIOIsolate(struct rio_info *p, struct Host *HostP, unsigned int UnitId) +static int RIOIsolate(p, HostP, UnitId) +struct rio_info *p; +struct Host *HostP; +uint UnitId; { - unsigned int link, unit; + uint link, unit; UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */ @@ -638,7 +658,9 @@ static int RIOIsolate(struct rio_info *p, struct Host *HostP, unsigned int UnitI return 1; } -static int RIOCheck(struct Host *HostP, unsigned int UnitId) +static int RIOCheck(HostP, UnitId) +struct Host *HostP; +uint UnitId; { unsigned char link; @@ -692,7 +714,8 @@ static int RIOCheck(struct Host *HostP, unsigned int UnitId) ** Returns the type of unit (host, 16/8 port RTA) */ -unsigned int GetUnitType(unsigned int Uniq) +uint GetUnitType(Uniq) +uint Uniq; { switch ((Uniq >> 28) & 0xf) { case RIO_AT: @@ -713,7 +736,8 @@ unsigned int GetUnitType(unsigned int Uniq) } } -int RIOSetChange(struct rio_info *p) +int RIOSetChange(p) +struct rio_info *p; { if (p->RIOQuickCheck != NOT_CHANGED) return (0); @@ -727,13 +751,14 @@ int RIOSetChange(struct rio_info *p) return (0); } -static void RIOConCon(struct rio_info *p, - struct Host *HostP, - unsigned int FromId, - unsigned int FromLink, - unsigned int ToId, - unsigned int ToLink, - int Change) +static void RIOConCon(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; @@ -793,7 +818,7 @@ static void RIOConCon(struct rio_info *p, 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"); - 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"); + cprintf("Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected"); } /* @@ -813,7 +838,7 @@ static int RIORemoveFromSavedTable(struct rio_info *p, struct Map *pMap) */ for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) { - memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map)); + bzero((caddr_t) & p->RIOSavedTable[entry], sizeof(struct Map)); } } return 0; @@ -873,7 +898,7 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit) int nOther = (HostP->Mapping[unit].ID2) - 1; rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther); - memset(&HostP->Mapping[nOther], 0, sizeof(struct Map)); + bzero((caddr_t) & HostP->Mapping[nOther], sizeof(struct Map)); } RIORemoveFromSavedTable(p, &HostP->Mapping[unit]); @@ -887,8 +912,7 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit) ** This function scans the given host table for either one ** or two free unit ID's. */ - -int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, unsigned int * pID2) +int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pID2) { int unit, tempID; @@ -973,7 +997,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, u /* ** Clear out this slot now that we intend to use it. */ - memset(&HostP->Mapping[unit], 0, sizeof(struct Map)); + bzero(&HostP->Mapping[unit], sizeof(struct Map)); /* ** If the second ID is not needed then we can return @@ -991,7 +1015,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, u /* ** Clear out this slot now that we intend to use it. */ - memset(&HostP->Mapping[unit], 0, sizeof(struct Map)); + 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