/*
** -----------------------------------------------------------------------------
**
** Perle Specialix driver for Linux
** ported from the existing SCO driver source
**
*
* (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
** Module : riocmd.c
** SID : 1.2
** Last Modified : 11/6/98 10:33:41
** Retrieved : 11/6/98 10:33:49
**
** ident @(#)riocmd.c 1.2
**
** -----------------------------------------------------------------------------
*/
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/tty.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/string.h>
#include <asm/uaccess.h>
#include <linux/termios.h>
#include <linux/serial.h>
#include <linux/generic_serial.h>
#include "linux_compat.h"
#include "rio_linux.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
#include "cmdpkt.h"
#include "map.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
#include "rioinfo.h"
#include "func.h"
#include "errors.h"
#include "pci.h"
#include "parmmap.h"
#include "unixrup.h"
#include "board.h"
#include "host.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
#include "cirrus.h"
static struct IdentifyRta IdRta;
static struct KillNeighbour KillUnit;
int RIOFoadRta(struct Host *HostP, struct Map *MapP)
{
struct CmdBlk *CmdBlkP;
rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA\n");
CmdBlkP = RIOGetCmdBlk();
if (!CmdBlkP) {
rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: GetCmdBlk failed\n");
return -ENXIO;
}
CmdBlkP->Packet.dest_unit = MapP->ID;
CmdBlkP->Packet.dest_port = BOOT_RUP;
CmdBlkP->Packet.src_unit = 0;
CmdBlkP->Packet.src_port = BOOT_RUP;
CmdBlkP->Packet.len = 0x84;
CmdBlkP->Packet.data[0] = IFOAD;
CmdBlkP->Packet.data[1] = 0;
CmdBlkP->Packet.data[2] = IFOAD_MAGIC & 0xFF;
CmdBlkP->Packet.data[3] = (IFOAD_MAGIC >> 8) & 0xFF;
if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: Failed to queue foad command\n");
return -EIO;
}
return 0;
}
int RIOZombieRta(struct Host *HostP, struct Map *MapP)
{
struct CmdBlk *CmdBlkP;
rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA\n");
CmdBlkP = RIOGetCmdBlk();
if (!CmdBlkP) {
rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA: GetCmdBlk failed\n");
return -ENXIO;
}
CmdBlkP->Packet.dest_unit = MapP->ID;
CmdBlkP->Packet.dest_port = BOOT_RUP;
CmdBlkP->Packet.src_unit = 0;
CmdBlkP->Packet.src_port = BOOT_RUP;
CmdBlkP->Packet.len = 0x84;
CmdBlkP->Packet.data[0] = ZOMBIE;
CmdBlkP->Packet.data[1] = 0;
CmdBlkP->Packet.data[2] = ZOMBIE_MAGIC & 0xFF;
CmdBlkP->Packet.data[3] = (ZOMBIE_MAGIC >> 8) & 0xFF;
if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA: Failed to queue zombie command\n");
return -EIO;
}
return 0;
}
int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP))
{
unsigned int Host;
rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%lx func %p\n", RtaUnique, func);
if (!RtaUnique)
return (0);
for (Host = 0; Host < p->RIONumHosts; Host++) {
unsigned int Rta;
struct Host *HostP = &p->RIOHosts[Host];
for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
struct Map *MapP = &HostP->Mapping[Rta];
if (MapP->RtaUniqueNum == RtaUnique) {
uint Link;
/*
** now, lets just check we have a route to it...
** IF the routing stuff is working, then one of the
** topology entries for this unit will have a legit
** route *somewhere*. We care not where - if its got
** any connections, we can get to it.
*/
for (Link = 0;