Commit e6374e07 authored by claes's avatar claes

Added i/o swap-method to avoid stall during warm restart

parent a8395fd3
This diff is collapsed.
/*
* Proview $Id: rt_io_base.h,v 1.8 2006-06-30 12:17:12 claes Exp $
* Proview $Id: rt_io_base.h,v 1.9 2007-05-18 12:05:12 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -68,7 +68,8 @@ typedef enum {
typedef enum {
io_mAction_None = 0,
io_mAction_Read = 1 << 0,
io_mAction_Write = 1 << 1
io_mAction_Write = 1 << 1,
io_mAction_Swap = 1 << 2
} io_mAction;
typedef enum {
......@@ -107,6 +108,7 @@ typedef struct s_Card {
pwr_tStatus (* Close) (); /* Close method */
pwr_tStatus (* Read) (); /* Read method */
pwr_tStatus (* Write) (); /* Write method */
pwr_tStatus (* Swap) (); /* Write method */
pwr_tAddress *op; /* Pointer to card object */
pwr_tDlid Dlid; /* Dlid for card object pointer */
pwr_tUInt32 size; /* Size of card data area in byte */
......@@ -130,6 +132,7 @@ typedef struct s_Rack {
pwr_tStatus (* Close) (); /* Close method */
pwr_tStatus (* Read) (); /* Read method */
pwr_tStatus (* Write) (); /* Write method */
pwr_tStatus (* Swap) (); /* Swap method */
void *op; /* Pointer to rack object */
pwr_tDlid Dlid; /* Dlid fr rack object pointer */
pwr_tUInt32 size; /* Size of rack data area in byte */
......@@ -152,6 +155,7 @@ typedef struct s_Agent {
pwr_tStatus (* Close) (); /* Close method */
pwr_tStatus (* Read) (); /* Read method */
pwr_tStatus (* Write) (); /* Write method */
pwr_tStatus (* Swap) (); /* Write method */
void *op; /* Pointer to agent object */
pwr_tDlid Dlid; /* Dlid for agent object pointer */
int scan_interval; /* Interval between scans */
......@@ -197,6 +201,14 @@ pwr_tStatus io_init(
float scan_time
);
pwr_tStatus io_init_swap(
io_mProcess process,
pwr_tObjid thread,
io_tCtx *ctx,
int relativ_vector,
float scan_time
);
pwr_tStatus io_read(
io_tCtx ctx
);
......@@ -205,6 +217,10 @@ pwr_tStatus io_write(
io_tCtx ctx
);
pwr_tStatus io_swap(
io_tCtx ctx
);
pwr_tStatus io_close(
io_tCtx ctx
);
......
/*
* Proview $Id: rt_io_m_node.c,v 1.2 2005-09-01 14:57:55 claes Exp $
* Proview $Id: rt_io_m_node.c,v 1.3 2007-05-18 12:05:12 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -40,6 +40,15 @@ static pwr_tStatus IoAgentInit (
return 1;
}
static pwr_tStatus IoAgentSwap (
io_tCtx ctx,
io_sAgent *ap
)
{
return 1;
}
/*----------------------------------------------------------------------------*\
......@@ -52,5 +61,6 @@ static pwr_tStatus IoAgentInit (
pwr_dExport pwr_BindIoMethods(Node) = {
pwr_BindIoMethod(IoAgentInit),
pwr_BindIoMethod(IoAgentSwap),
pwr_NullMethod
};
!
! Proview $Id: pwrs_c_node.wb_load,v 1.11 2006-03-31 14:47:15 claes Exp $
! Proview $Id: pwrs_c_node.wb_load,v 1.12 2007-05-18 12:06:05 claes Exp $
! Copyright (C) 2005 SSAB Oxelsund AB.
!
! This program is free software; you can redistribute it and/or
......@@ -344,6 +344,11 @@ SObject pwrs:Class
Attr MethodName = "Node-IoAgentInit"
EndBody
EndObject
Object IoAgentSwap $Method
Body SysBody
Attr MethodName = "Node-IoAgentSwap"
EndBody
EndObject
EndObject
EndObject
EndSObject
/*
* Proview $Id: rt_io_m_rack_ssab.c,v 1.2 2006-04-12 10:14:49 claes Exp $
* Proview $Id: rt_io_m_rack_ssab.c,v 1.3 2007-05-18 12:06:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -64,6 +64,31 @@ static pwr_tStatus IoRackInit (
return 1;
}
static pwr_tStatus IoRackSwap (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
io_sRackLocal *local;
if (!rp->Local) {
/* Open Qbus driver */
local = calloc( 1, sizeof(*local));
rp->Local = local;
local->Qbus_fp = open("/dev/qbus", O_RDWR);
if ( local->Qbus_fp == -1)
{
errh_Error( "Qbus swap initialization error, IO rack %s", rp->Name);
return IO__ERRDEVICE;
}
errh_Info( "Swap init of IO rack %s", rp->Name);
}
return 1;
}
static pwr_tStatus IoRackClose (
io_tCtx ctx,
io_sAgent *ap,
......@@ -93,6 +118,7 @@ static pwr_tStatus IoRackClose (
pwr_dExport pwr_BindIoMethods(Rack_SSAB) = {
pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackSwap),
pwr_BindIoMethod(IoRackClose),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ssab_do.c,v 1.4 2007-04-30 12:08:08 claes Exp $
* Proview $Id: rt_io_m_ssab_do.c,v 1.5 2007-05-18 12:06:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -250,6 +250,54 @@ static pwr_tStatus IoCardWrite (
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardSwap (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_tUInt16 data = 0;
pwr_sClass_Ssab_BaseDoCard *op;
int i;
qbus_io_read rb;
int sts;
if (!cp->Local) {
local = calloc( 1, sizeof(*local));
cp->Local = local;
local->Address[0] = op->RegAddress;
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
}
op = (pwr_sClass_Ssab_BaseDoCard *) cp->op;
for ( i = 0; i < 2; i++)
{
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Write to local Q-bus */
rb.Address = local->Address[i];
sts = read( local->Qbus_fp, &rb, sizeof(rb));
}
else {
/* Ethernet I/O, Get data from current address */
data = bfbeth_get_data(r_local, (pwr_tUInt16) local->Address[i], &sts);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) local->Address[i]);
sts = 1;
}
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
......@@ -259,5 +307,6 @@ pwr_dExport pwr_BindIoMethods(Ssab_Do) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardSwap),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ssab_remoterack.c,v 1.5 2006-09-05 12:03:01 claes Exp $
* Proview $Id: rt_io_m_ssab_remoterack.c,v 1.6 2007-05-18 12:06:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -134,6 +134,64 @@ static pwr_tStatus IoRackInit (
return IO__SUCCESS;
}
static pwr_tStatus IoRackSwap (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
io_sRackLocal *local;
pwr_sClass_Ssab_RemoteRack *op;
int sts;
fd_set fds;
struct timeval tv;
struct bfb_buf rbuf;
int size;
if (!rp->Local) {
sts = IoRackInit(ctx, ap, rp);
if (sts != IO__SUCCESS)
return IO__ERRINIDEVICE;
}
local = (io_sRackLocal *) rp->Local;
op = (pwr_sClass_Ssab_RemoteRack *) rp->op;
// Calc length and send read request
local->read_req.service = BFB_SERVICE_READ;
local->read_req.length = local->next_read_req_item*4 + 4;
sts = send(local->s, &local->read_req, local->read_req.length, 0);
op->TX_packets++;
local->next_read_req_item = 0;
bzero(&local->read_area, sizeof(local->read_area));
sts = 1;
while (sts > 0) {
FD_ZERO(&fds);
FD_SET(local->s, &fds);
tv.tv_sec = 0;
tv.tv_usec = 0;
sts = select(32, &fds, NULL, NULL, &tv);
if (sts > 0) {
size = recv(local->s, &rbuf, sizeof(rbuf), 0);
if (rbuf.service == BFB_SERVICE_READ) {
bzero(&local->read_area, sizeof(local->read_area));
memcpy(&local->read_area, &rbuf, size);
}
else if (rbuf.service == BFB_SERVICE_WRITE) {
bzero(&local->write_area, sizeof(local->write_area));
memcpy(&local->write_area, &rbuf, size);
}
op->RX_packets++;
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoRackClose (
io_tCtx ctx,
io_sAgent *ap,
......@@ -223,6 +281,7 @@ static pwr_tStatus IoRackWrite (
pwr_dExport pwr_BindIoMethods(Ssab_RemoteRack) = {
pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackSwap),
pwr_BindIoMethod(IoRackClose),
pwr_BindIoMethod(IoRackRead),
pwr_BindIoMethod(IoRackWrite),
......
Volume SsabOx $ClassVolume 0.0.250.5
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X160"
Attr NextOix = "_X162"
Attr NextCix = "_X30"
Attr NextTix[0] = "_X5"
EndBody
......@@ -145,6 +145,11 @@ Volume SsabOx $ClassVolume 0.0.250.5
Attr MethodName = "Rack_SSAB-IoRackClose"
EndBody
EndObject
Object IoRackSwap $Method 161 18-MAY-2007 10:19:42.40
Body SysBody 18-MAY-2007 10:19:47.20
Attr MethodName = "Rack_SSAB-IoRackSwap"
EndBody
EndObject
EndObject
Object Template Rack_SSAB 2154004480 01-JAN-1970 01:00:00.00
Body RtBody 30-DEC-2005 14:46:17.32
......@@ -3815,6 +3820,11 @@ Volume SsabOx $ClassVolume 0.0.250.5
Attr MethodName = "Ssab_Do-IoCardWrite"
EndBody
EndObject
Object IoCardSwap $Method 162 18-MAY-2007 10:20:35.84
Body SysBody 18-MAY-2007 10:20:39.25
Attr MethodName = "Ssab_Do-IoCardSwap"
EndBody
EndObject
EndObject
EndObject
!/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment