diff options
Diffstat (limited to 'drivers/char/rio/rioroute.c')
-rw-r--r-- | drivers/char/rio/rioroute.c | 166 |
1 files changed, 71 insertions, 95 deletions
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c index f98888f52659..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"; #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" @@ -71,29 +68,25 @@ 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 *, 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); +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); /* ** Incoming on the ROUTE_RUP ** I wrote this while I was tired. Forgive me. */ -int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) +int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT * PacketP) { struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; struct PktCmd_M *PktReplyP; @@ -104,10 +97,10 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) int ThisLink, ThisLinkMin, ThisLinkMax; int port; int Mod, Mod1, Mod2; - ushort RtaType; - uint RtaUniq; - uint ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */ - uint OldUnit, NewUnit, OldLink, NewLink; + unsigned short RtaType; + unsigned int RtaUniq; + unsigned int ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */ + unsigned int OldUnit, NewUnit, OldLink, NewLink; char *MyType, *MyName; int Lies; unsigned long flags; @@ -115,7 +108,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) /* ** Is this unit telling us it's current link topology? */ - if (RBYTE(PktCmdP->Command) == ROUTE_TOPOLOGY) { + if (readb(&PktCmdP->Command) == ROUTE_TOPOLOGY) { MapP = HostP->Mapping; /* @@ -125,7 +118,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) ** from an RTA then we need to fill in the Mapping structure's ** Topology array for the unit. */ - if (Rup >= (ushort) MAX_RUP) { + if (Rup >= (unsigned short) MAX_RUP) { ThisUnit = HOST_ID; TopP = HostP->Topology; MyType = "Host"; @@ -151,11 +144,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) ** it won't lie about network interconnect, total disconnects ** and no-IDs. (or at least, it doesn't *matter* if it does) */ - if (RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) > (ushort) MAX_RUP) + if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (unsigned short) MAX_RUP) continue; for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) { - if ((RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) == RBYTE(PktCmdP->RouteTopology[NewLink].Unit)) && (RBYTE(PktCmdP->RouteTopology[ThisLink].Link) == RBYTE(PktCmdP->RouteTopology[NewLink].Link))) { + if ((readb(&PktCmdP->RouteTopology[ThisLink].Unit) == readb(&PktCmdP->RouteTopology[NewLink].Unit)) && (readb(&PktCmdP->RouteTopology[ThisLink].Link) == readb(&PktCmdP->RouteTopology[NewLink].Link))) { Lies++; } } @@ -164,11 +157,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 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", - 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; + 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; } /* @@ -184,8 +177,8 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) /* ** this is what it is now connected to */ - NewUnit = RBYTE(PktCmdP->RouteTopology[ThisLink].Unit); - NewLink = RBYTE(PktCmdP->RouteTopology[ThisLink].Link); + NewUnit = readb(&PktCmdP->RouteTopology[ThisLink].Unit); + NewLink = readb(&PktCmdP->RouteTopology[ThisLink].Link); if (OldUnit != NewUnit || OldLink != NewLink) { /* @@ -219,7 +212,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) if (NewUnit == ROUTE_INTERCONNECT) { if (!p->RIONoMessage) - cprintf("%s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink); + printk(KERN_DEBUG "rio: %s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink); } /* @@ -258,18 +251,18 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) RIOCheckIsolated(p, HostP, OldUnit); } } - return TRUE; + return 1; } /* ** The only other command we recognise is a route_request command */ - 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; + 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; } - RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + (RBYTE(PktCmdP->UniqNum[1]) << 8) + (RBYTE(PktCmdP->UniqNum[2]) << 16) + (RBYTE(PktCmdP->UniqNum[3]) << 24); + RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24); /* ** Determine if 8 or 16 port RTA @@ -278,7 +271,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq); - Mod = RBYTE(PktCmdP->ModuleTypes); + Mod = readb(&PktCmdP->ModuleTypes); Mod1 = LONYBLE(Mod); if (RtaType == TYPE_RTA16) { /* @@ -292,10 +285,6 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 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. */ @@ -320,7 +309,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) PktReplyP->Command = ROUTE_FOAD; HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); RIOQueueCmdBlk(HostP, Rup, CmdBlkP); - return TRUE; + return 1; } /* @@ -348,13 +337,13 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) { if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) { if (!p->RIONoMessage) - cprintf("RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name); + printk(KERN_DEBUG "rio: RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name); HostP->Mapping[ThisUnit].Flags |= MSG_DONE; } PktReplyP->Command = ROUTE_FOAD; HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); RIOQueueCmdBlk(HostP, Rup, CmdBlkP); - return TRUE; + return 1; } /* @@ -447,7 +436,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) /* ** Job done, get on with the interrupts! */ - return TRUE; + return 1; } } /* @@ -475,7 +464,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) if (!UnknownMesgDone) { if (!p->RIONoMessage) - cprintf("One or more unknown RTAs are being updated.\n"); + printk(KERN_DEBUG "rio: One or more unknown RTAs are being updated.\n"); UnknownMesgDone = 1; } @@ -491,28 +480,25 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) if (RtaType == TYPE_RTA16) { if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) { RIODefaultName(p, HostP, ThisUnit); - FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP); + rio_fill_host_slot(ThisUnit, ThisUnit2, RtaUniq, HostP); } } else { if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) { RIODefaultName(p, HostP, ThisUnit); - FillSlot(ThisUnit, 0, RtaUniq, HostP); + rio_fill_host_slot(ThisUnit, 0, RtaUniq, HostP); } } PktReplyP->Command = ROUTE_USED; HostP->Copy("RT_USED", PktReplyP->CommandText, 7); } RIOQueueCmdBlk(HostP, Rup, CmdBlkP); - return TRUE; + return 1; } -void RIOFixPhbs(p, HostP, unit) -struct rio_info *p; -struct Host *HostP; -uint unit; +void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit) { - ushort link, port; + unsigned short link, port; struct Port *PortP; unsigned long flags; int PortN = HostP->Mapping[unit].SysPort; @@ -520,19 +506,19 @@ uint unit; rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN); if (PortN != -1) { - ushort dest_unit = HostP->Mapping[unit].ID2; + unsigned short 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 = RWORD(PortP->PhbP->link); + link = readw(&PortP->PhbP->link); for (port = 0; port < PORTS_PER_RTA; port++, PortN++) { - ushort dest_port = port + 8; - WORD *TxPktP; - PKT *Pkt; + unsigned short dest_port = port + 8; + u16 *TxPktP; + struct PKT *Pkt; PortP = p->RIOPortp[PortN]; @@ -569,18 +555,18 @@ uint unit; ** card. This needs to be translated into a 32 bit pointer ** so it can be accessed from the driver. */ - Pkt = (PKT *) RIO_PTR(HostP->Caddr, RINDW(TxPktP)); + Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(TxPktP)); /* ** If the packet is used, reset it. */ - Pkt = (PKT *) ((uint) Pkt & ~PKT_IN_USE); - WBYTE(Pkt->dest_unit, dest_unit); - WBYTE(Pkt->dest_port, dest_port); + Pkt = (struct PKT *) ((unsigned long) Pkt & ~PKT_IN_USE); + writeb(dest_unit, &Pkt->dest_unit); + writeb(dest_port, &Pkt->dest_port); } - 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_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_spin_unlock_irqrestore(&PortP->portSem, flags); } @@ -590,9 +576,9 @@ uint unit; */ if (link > 3) return; - if (((unit * 8) + 7) > RWORD(HostP->LinkStrP[link].last_port)) { + if (((unit * 8) + 7) > readw(&HostP->LinkStrP[link].last_port)) { rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7); - WWORD(HostP->LinkStrP[link].last_port, (unit * 8) + 7); + writew((unit * 8) + 7, &HostP->LinkStrP[link].last_port); } } } @@ -603,10 +589,7 @@ uint 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(p, HostP, UnitId) -struct rio_info *p; -struct Host *HostP; -uint UnitId; +static int RIOCheckIsolated(struct rio_info *p, struct Host *HostP, unsigned int UnitId) { unsigned long flags; rio_spin_lock_irqsave(&HostP->HostLock, flags); @@ -628,12 +611,9 @@ uint UnitId; ** all the units attached to it. This will mean that the entire ** subnet will re-introduce itself. */ -static int RIOIsolate(p, HostP, UnitId) -struct rio_info *p; -struct Host *HostP; -uint UnitId; +static int RIOIsolate(struct rio_info *p, struct Host *HostP, unsigned int UnitId) { - uint link, unit; + unsigned int link, unit; UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */ @@ -658,9 +638,7 @@ uint UnitId; return 1; } -static int RIOCheck(HostP, UnitId) -struct Host *HostP; -uint UnitId; +static int RIOCheck(struct Host *HostP, unsigned int UnitId) { unsigned char link; @@ -714,8 +692,7 @@ uint UnitId; ** Returns the type of unit (host, 16/8 port RTA) */ -uint GetUnitType(Uniq) -uint Uniq; +unsigned int GetUnitType(unsigned int Uniq) { switch ((Uniq >> 28) & 0xf) { case RIO_AT: @@ -736,8 +713,7 @@ uint Uniq; } } -int RIOSetChange(p) -struct rio_info *p; +int RIOSetChange(struct rio_info *p) { if (p->RIOQuickCheck != NOT_CHANGED) return (0); @@ -751,14 +727,13 @@ struct rio_info *p; return (0); } -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; +static void RIOConCon(struct rio_info *p, + struct Host *HostP, + unsigned int FromId, + unsigned int FromLink, + unsigned int ToId, + unsigned int ToLink, + int Change) { char *FromName; char *FromType; @@ -818,7 +793,7 @@ int Change; 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"); + 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"); } /* @@ -838,7 +813,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) { - bzero((caddr_t) & p->RIOSavedTable[entry], sizeof(struct Map)); + memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map)); } } return 0; @@ -898,7 +873,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); - bzero((caddr_t) & HostP->Mapping[nOther], sizeof(struct Map)); + memset(&HostP->Mapping[nOther], 0, sizeof(struct Map)); } RIORemoveFromSavedTable(p, &HostP->Mapping[unit]); @@ -912,7 +887,8 @@ 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, uint * pID1, uint * pID2) + +int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, unsigned int * pID2) { int unit, tempID; @@ -997,7 +973,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pI /* ** Clear out this slot now that we intend to use it. */ - bzero(&HostP->Mapping[unit], sizeof(struct Map)); + memset(&HostP->Mapping[unit], 0, sizeof(struct Map)); /* ** If the second ID is not needed then we can return @@ -1015,7 +991,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pI /* ** Clear out this slot now that we intend to use it. */ - bzero(&HostP->Mapping[unit], sizeof(struct Map)); + memset(&HostP->Mapping[unit], 0, sizeof(struct Map)); /* At this point under the right(wrong?) conditions ** we may have a first unit ID being higher than the |