Commit a93192a5 authored by Alexandre Bounine's avatar Alexandre Bounine Committed by Linus Torvalds

rapidio: use common destid storage for endpoints and switches

Change code to use one storage location common for switches and endpoints.
This eliminates unnecessary device type checks during basic access
operations.  Logic that assigns destid to RIO devices stays unchanged - as
before, switches use an associated destid because they do not have their
own.
Signed-off-by: default avatarAlexandre Bounine <alexandre.bounine@idt.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Li Yang <leoli@freescale.com>
Cc: Thomas Moll <thomas.moll@sysgo.com>
Cc: Micha Nelissen <micha@neli.hopto.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e6d7202b
...@@ -437,9 +437,15 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, ...@@ -437,9 +437,15 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
next_destid++; next_destid++;
} else } else
rdev->destid = rio_get_device_id(port, destid, hopcount); rdev->destid = rio_get_device_id(port, destid, hopcount);
} else
/* Switch device has an associated destID */ rdev->hopcount = 0xff;
rdev->destid = RIO_INVALID_DESTID; } else {
/* Switch device has an associated destID which
* will be adjusted later
*/
rdev->destid = destid;
rdev->hopcount = hopcount;
}
/* If a PE has both switch and other functions, show it as a switch */ /* If a PE has both switch and other functions, show it as a switch */
if (rio_is_switch(rdev)) { if (rio_is_switch(rdev)) {
...@@ -450,8 +456,6 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, ...@@ -450,8 +456,6 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
if (!rswitch) if (!rswitch)
goto cleanup; goto cleanup;
rswitch->switchid = next_switchid; rswitch->switchid = next_switchid;
rswitch->hopcount = hopcount;
rswitch->destid = destid;
rswitch->port_ok = 0; rswitch->port_ok = 0;
rswitch->route_table = kzalloc(sizeof(u8)* rswitch->route_table = kzalloc(sizeof(u8)*
RIO_MAX_ROUTE_ENTRIES(port->sys_size), RIO_MAX_ROUTE_ENTRIES(port->sys_size),
...@@ -632,8 +636,7 @@ rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount) ...@@ -632,8 +636,7 @@ rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount)
/** /**
* rio_route_add_entry- Add a route entry to a switch routing table * rio_route_add_entry- Add a route entry to a switch routing table
* @mport: Master port to send transaction * @rdev: RIO device
* @rswitch: Switch device
* @table: Routing table ID * @table: Routing table ID
* @route_destid: Destination ID to be routed * @route_destid: Destination ID to be routed
* @route_port: Port number to be routed * @route_port: Port number to be routed
...@@ -647,31 +650,31 @@ rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount) ...@@ -647,31 +650,31 @@ rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount)
* on failure. * on failure.
*/ */
static int static int
rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch, rio_route_add_entry(struct rio_dev *rdev,
u16 table, u16 route_destid, u8 route_port, int lock) u16 table, u16 route_destid, u8 route_port, int lock)
{ {
int rc; int rc;
if (lock) { if (lock) {
rc = rio_lock_device(mport, rswitch->destid, rc = rio_lock_device(rdev->net->hport, rdev->destid,
rswitch->hopcount, 1000); rdev->hopcount, 1000);
if (rc) if (rc)
return rc; return rc;
} }
rc = rswitch->add_entry(mport, rswitch->destid, rc = rdev->rswitch->add_entry(rdev->net->hport, rdev->destid,
rswitch->hopcount, table, rdev->hopcount, table,
route_destid, route_port); route_destid, route_port);
if (lock) if (lock)
rio_unlock_device(mport, rswitch->destid, rswitch->hopcount); rio_unlock_device(rdev->net->hport, rdev->destid,
rdev->hopcount);
return rc; return rc;
} }
/** /**
* rio_route_get_entry- Read a route entry in a switch routing table * rio_route_get_entry- Read a route entry in a switch routing table
* @mport: Master port to send transaction * @rdev: RIO device
* @rswitch: Switch device
* @table: Routing table ID * @table: Routing table ID
* @route_destid: Destination ID to be routed * @route_destid: Destination ID to be routed
* @route_port: Pointer to read port number into * @route_port: Pointer to read port number into
...@@ -685,23 +688,24 @@ rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch, ...@@ -685,23 +688,24 @@ rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch,
* on failure. * on failure.
*/ */
static int static int
rio_route_get_entry(struct rio_mport *mport, struct rio_switch *rswitch, u16 table, rio_route_get_entry(struct rio_dev *rdev, u16 table,
u16 route_destid, u8 *route_port, int lock) u16 route_destid, u8 *route_port, int lock)
{ {
int rc; int rc;
if (lock) { if (lock) {
rc = rio_lock_device(mport, rswitch->destid, rc = rio_lock_device(rdev->net->hport, rdev->destid,
rswitch->hopcount, 1000); rdev->hopcount, 1000);
if (rc) if (rc)
return rc; return rc;
} }
rc = rswitch->get_entry(mport, rswitch->destid, rc = rdev->rswitch->get_entry(rdev->net->hport, rdev->destid,
rswitch->hopcount, table, rdev->hopcount, table,
route_destid, route_port); route_destid, route_port);
if (lock) if (lock)
rio_unlock_device(mport, rswitch->destid, rswitch->hopcount); rio_unlock_device(rdev->net->hport, rdev->destid,
rdev->hopcount);
return rc; return rc;
} }
...@@ -811,14 +815,14 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, ...@@ -811,14 +815,14 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
if (rio_is_switch(rdev)) { if (rio_is_switch(rdev)) {
next_switchid++; next_switchid++;
sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo); sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo);
rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, rio_route_add_entry(rdev, RIO_GLOBAL_TABLE,
port->host_deviceid, sw_inport, 0); port->host_deviceid, sw_inport, 0);
rdev->rswitch->route_table[port->host_deviceid] = sw_inport; rdev->rswitch->route_table[port->host_deviceid] = sw_inport;
for (destid = 0; destid < next_destid; destid++) { for (destid = 0; destid < next_destid; destid++) {
if (destid == port->host_deviceid) if (destid == port->host_deviceid)
continue; continue;
rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, rio_route_add_entry(rdev, RIO_GLOBAL_TABLE,
destid, sw_inport, 0); destid, sw_inport, 0);
rdev->rswitch->route_table[destid] = sw_inport; rdev->rswitch->route_table[destid] = sw_inport;
} }
...@@ -850,8 +854,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, ...@@ -850,8 +854,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
"RIO: scanning device on port %d\n", "RIO: scanning device on port %d\n",
port_num); port_num);
rdev->rswitch->port_ok |= (1 << port_num); rdev->rswitch->port_ok |= (1 << port_num);
rio_route_add_entry(port, rdev->rswitch, rio_route_add_entry(rdev, RIO_GLOBAL_TABLE,
RIO_GLOBAL_TABLE,
RIO_ANY_DESTID(port->sys_size), RIO_ANY_DESTID(port->sys_size),
port_num, 0); port_num, 0);
...@@ -865,7 +868,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, ...@@ -865,7 +868,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
destid < next_destid; destid++) { destid < next_destid; destid++) {
if (destid == port->host_deviceid) if (destid == port->host_deviceid)
continue; continue;
rio_route_add_entry(port, rdev->rswitch, rio_route_add_entry(rdev,
RIO_GLOBAL_TABLE, RIO_GLOBAL_TABLE,
destid, destid,
port_num, port_num,
...@@ -904,7 +907,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, ...@@ -904,7 +907,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
next_destid++; next_destid++;
} }
rdev->rswitch->destid = sw_destid; rdev->destid = sw_destid;
} else } else
pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n", pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n",
rio_name(rdev), rdev->vid, rdev->did); rio_name(rdev), rdev->vid, rdev->did);
...@@ -958,7 +961,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid, ...@@ -958,7 +961,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
next_switchid++; next_switchid++;
/* Associated destid is how we accessed this switch */ /* Associated destid is how we accessed this switch */
rdev->rswitch->destid = destid; rdev->destid = destid;
pr_debug( pr_debug(
"RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n",
...@@ -981,7 +984,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid, ...@@ -981,7 +984,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
for (ndestid = 0; for (ndestid = 0;
ndestid < RIO_ANY_DESTID(port->sys_size); ndestid < RIO_ANY_DESTID(port->sys_size);
ndestid++) { ndestid++) {
rio_route_get_entry(port, rdev->rswitch, rio_route_get_entry(rdev,
RIO_GLOBAL_TABLE, RIO_GLOBAL_TABLE,
ndestid, ndestid,
&route_port, 0); &route_port, 0);
...@@ -1076,7 +1079,7 @@ static void rio_update_route_tables(struct rio_mport *port) ...@@ -1076,7 +1079,7 @@ static void rio_update_route_tables(struct rio_mport *port)
list_for_each_entry(rdev, &rio_devices, global_list) { list_for_each_entry(rdev, &rio_devices, global_list) {
destid = (rio_is_switch(rdev))?rdev->rswitch->destid:rdev->destid; destid = rdev->destid;
list_for_each_entry(rswitch, &rio_switches, node) { list_for_each_entry(rswitch, &rio_switches, node) {
...@@ -1085,13 +1088,13 @@ static void rio_update_route_tables(struct rio_mport *port) ...@@ -1085,13 +1088,13 @@ static void rio_update_route_tables(struct rio_mport *port)
if (RIO_INVALID_ROUTE == rswitch->route_table[destid]) { if (RIO_INVALID_ROUTE == rswitch->route_table[destid]) {
/* Skip if destid ends in empty switch*/ /* Skip if destid ends in empty switch*/
if (rswitch->destid == destid) if (rswitch->rdev->destid == destid)
continue; continue;
sport = RIO_GET_PORT_NUM(rswitch->rdev->swpinfo); sport = RIO_GET_PORT_NUM(rswitch->rdev->swpinfo);
if (rswitch->add_entry) { if (rswitch->add_entry) {
rio_route_add_entry(port, rswitch, rio_route_add_entry(rswitch->rdev,
RIO_GLOBAL_TABLE, destid, RIO_GLOBAL_TABLE, destid,
sport, 0); sport, 0);
rswitch->route_table[destid] = sport; rswitch->route_table[destid] = sport;
...@@ -1203,21 +1206,20 @@ static void rio_build_route_tables(void) ...@@ -1203,21 +1206,20 @@ static void rio_build_route_tables(void)
list_for_each_entry(rdev, &rio_devices, global_list) list_for_each_entry(rdev, &rio_devices, global_list)
if (rio_is_switch(rdev)) { if (rio_is_switch(rdev)) {
rio_lock_device(rdev->net->hport, rdev->rswitch->destid, rio_lock_device(rdev->net->hport, rdev->destid,
rdev->rswitch->hopcount, 1000); rdev->hopcount, 1000);
for (i = 0; for (i = 0;
i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size);
i++) { i++) {
if (rio_route_get_entry if (rio_route_get_entry(rdev,
(rdev->net->hport, rdev->rswitch, RIO_GLOBAL_TABLE, i, &sport, 0) < 0)
RIO_GLOBAL_TABLE, i, &sport, 0) < 0)
continue; continue;
rdev->rswitch->route_table[i] = sport; rdev->rswitch->route_table[i] = sport;
} }
rio_unlock_device(rdev->net->hport, rio_unlock_device(rdev->net->hport,
rdev->rswitch->destid, rdev->destid,
rdev->rswitch->hopcount); rdev->hopcount);
} }
} }
......
...@@ -471,16 +471,9 @@ struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from) ...@@ -471,16 +471,9 @@ struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from)
*/ */
int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock) int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock)
{ {
u8 hopcount = 0xff;
u16 destid = rdev->destid;
u32 regval; u32 regval;
if (rdev->rswitch) { rio_read_config_32(rdev,
destid = rdev->rswitch->destid;
hopcount = rdev->rswitch->hopcount;
}
rio_mport_read_config_32(rdev->net->hport, destid, hopcount,
rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum), rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum),
&regval); &regval);
if (lock) if (lock)
...@@ -488,7 +481,7 @@ int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock) ...@@ -488,7 +481,7 @@ int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock)
else else
regval &= ~RIO_PORT_N_CTL_LOCKOUT; regval &= ~RIO_PORT_N_CTL_LOCKOUT;
rio_mport_write_config_32(rdev->net->hport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum), rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum),
regval); regval);
return 0; return 0;
...@@ -507,7 +500,7 @@ static int ...@@ -507,7 +500,7 @@ static int
rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum) rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum)
{ {
u32 result; u32 result;
int p_port, dstid, rc = -EIO; int p_port, rc = -EIO;
struct rio_dev *prev = NULL; struct rio_dev *prev = NULL;
/* Find switch with failed RIO link */ /* Find switch with failed RIO link */
...@@ -522,9 +515,7 @@ rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum) ...@@ -522,9 +515,7 @@ rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum)
if (prev == NULL) if (prev == NULL)
goto err_out; goto err_out;
dstid = (rdev->pef & RIO_PEF_SWITCH) ? p_port = prev->rswitch->route_table[rdev->destid];
rdev->rswitch->destid : rdev->destid;
p_port = prev->rswitch->route_table[dstid];
if (p_port != RIO_INVALID_ROUTE) { if (p_port != RIO_INVALID_ROUTE) {
pr_debug("RIO: link failed on [%s]-P%d\n", pr_debug("RIO: link failed on [%s]-P%d\n",
...@@ -567,15 +558,8 @@ rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, u8 hopcount) ...@@ -567,15 +558,8 @@ rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, u8 hopcount)
*/ */
static int rio_chk_dev_access(struct rio_dev *rdev) static int rio_chk_dev_access(struct rio_dev *rdev)
{ {
u8 hopcount = 0xff; return rio_mport_chk_dev_access(rdev->net->hport,
u16 destid = rdev->destid; rdev->destid, rdev->hopcount);
if (rdev->rswitch) {
destid = rdev->rswitch->destid;
hopcount = rdev->rswitch->hopcount;
}
return rio_mport_chk_dev_access(rdev->net->hport, destid, hopcount);
} }
/** /**
...@@ -588,23 +572,20 @@ static int rio_chk_dev_access(struct rio_dev *rdev) ...@@ -588,23 +572,20 @@ static int rio_chk_dev_access(struct rio_dev *rdev)
static int static int
rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp) rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp)
{ {
struct rio_mport *mport = rdev->net->hport;
u16 destid = rdev->rswitch->destid;
u8 hopcount = rdev->rswitch->hopcount;
u32 regval; u32 regval;
int checkcount; int checkcount;
if (lnkresp) { if (lnkresp) {
/* Read from link maintenance response register /* Read from link maintenance response register
* to clear valid bit */ * to clear valid bit */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum), rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum),
&regval); &regval);
udelay(50); udelay(50);
} }
/* Issue Input-status command */ /* Issue Input-status command */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_MNT_REQ_CSR(pnum), rdev->phys_efptr + RIO_PORT_N_MNT_REQ_CSR(pnum),
RIO_MNT_REQ_CMD_IS); RIO_MNT_REQ_CMD_IS);
...@@ -615,7 +596,7 @@ rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp) ...@@ -615,7 +596,7 @@ rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp)
checkcount = 3; checkcount = 3;
while (checkcount--) { while (checkcount--) {
udelay(50); udelay(50);
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum), rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum),
&regval); &regval);
if (regval & RIO_PORT_N_MNT_RSP_RVAL) { if (regval & RIO_PORT_N_MNT_RSP_RVAL) {
...@@ -635,15 +616,12 @@ rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp) ...@@ -635,15 +616,12 @@ rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp)
*/ */
static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status) static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
{ {
struct rio_mport *mport = rdev->net->hport;
u16 destid = rdev->rswitch->destid;
u8 hopcount = rdev->rswitch->hopcount;
struct rio_dev *nextdev = rdev->rswitch->nextdev[pnum]; struct rio_dev *nextdev = rdev->rswitch->nextdev[pnum];
u32 regval; u32 regval;
u32 far_ackid, far_linkstat, near_ackid; u32 far_ackid, far_linkstat, near_ackid;
if (err_status == 0) if (err_status == 0)
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum), rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum),
&err_status); &err_status);
...@@ -661,7 +639,7 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status) ...@@ -661,7 +639,7 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
pnum, regval); pnum, regval);
far_ackid = (regval & RIO_PORT_N_MNT_RSP_ASTAT) >> 5; far_ackid = (regval & RIO_PORT_N_MNT_RSP_ASTAT) >> 5;
far_linkstat = regval & RIO_PORT_N_MNT_RSP_LSTAT; far_linkstat = regval & RIO_PORT_N_MNT_RSP_LSTAT;
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_ACK_STS_CSR(pnum), rdev->phys_efptr + RIO_PORT_N_ACK_STS_CSR(pnum),
&regval); &regval);
pr_debug("RIO_EM: SP%d_ACK_STS_CSR=0x%08x\n", pnum, regval); pr_debug("RIO_EM: SP%d_ACK_STS_CSR=0x%08x\n", pnum, regval);
...@@ -679,9 +657,8 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status) ...@@ -679,9 +657,8 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
/* Align near outstanding/outbound ackIDs with /* Align near outstanding/outbound ackIDs with
* far inbound. * far inbound.
*/ */
rio_mport_write_config_32(mport, destid, rio_write_config_32(rdev,
hopcount, rdev->phys_efptr + rdev->phys_efptr + RIO_PORT_N_ACK_STS_CSR(pnum),
RIO_PORT_N_ACK_STS_CSR(pnum),
(near_ackid << 24) | (near_ackid << 24) |
(far_ackid << 8) | far_ackid); (far_ackid << 8) | far_ackid);
/* Align far outstanding/outbound ackIDs with /* Align far outstanding/outbound ackIDs with
...@@ -698,7 +675,7 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status) ...@@ -698,7 +675,7 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
pr_debug("RIO_EM: Invalid nextdev pointer (NULL)\n"); pr_debug("RIO_EM: Invalid nextdev pointer (NULL)\n");
} }
rd_err: rd_err:
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum), rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum),
&err_status); &err_status);
pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status); pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status);
...@@ -710,7 +687,7 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status) ...@@ -710,7 +687,7 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
RIO_GET_PORT_NUM(nextdev->swpinfo), NULL); RIO_GET_PORT_NUM(nextdev->swpinfo), NULL);
udelay(50); udelay(50);
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum), rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum),
&err_status); &err_status);
pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status); pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status);
...@@ -730,9 +707,6 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status) ...@@ -730,9 +707,6 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg)
{ {
struct rio_dev *rdev; struct rio_dev *rdev;
struct rio_mport *mport;
u8 hopcount;
u16 destid;
u32 err_status, em_perrdet, em_ltlerrdet; u32 err_status, em_perrdet, em_ltlerrdet;
int rc, portnum; int rc, portnum;
...@@ -800,17 +774,13 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) ...@@ -800,17 +774,13 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg)
return 0; return 0;
} }
mport = rdev->net->hport;
destid = rdev->rswitch->destid;
hopcount = rdev->rswitch->hopcount;
/* /*
* Process the port-write notification from switch * Process the port-write notification from switch
*/ */
if (rdev->rswitch->em_handle) if (rdev->rswitch->em_handle)
rdev->rswitch->em_handle(rdev, portnum); rdev->rswitch->em_handle(rdev, portnum);
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum),
&err_status); &err_status);
pr_debug("RIO_PW: SP%d_ERR_STS_CSR=0x%08x\n", portnum, err_status); pr_debug("RIO_PW: SP%d_ERR_STS_CSR=0x%08x\n", portnum, err_status);
...@@ -840,7 +810,7 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) ...@@ -840,7 +810,7 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg)
rdev->rswitch->port_ok &= ~(1 << portnum); rdev->rswitch->port_ok &= ~(1 << portnum);
rio_set_port_lockout(rdev, portnum, 1); rio_set_port_lockout(rdev, portnum, 1);
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + rdev->phys_efptr +
RIO_PORT_N_ACK_STS_CSR(portnum), RIO_PORT_N_ACK_STS_CSR(portnum),
RIO_PORT_N_ACK_CLEAR); RIO_PORT_N_ACK_CLEAR);
...@@ -851,28 +821,28 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) ...@@ -851,28 +821,28 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg)
} }
} }
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet); rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet);
if (em_perrdet) { if (em_perrdet) {
pr_debug("RIO_PW: RIO_EM_P%d_ERR_DETECT=0x%08x\n", pr_debug("RIO_PW: RIO_EM_P%d_ERR_DETECT=0x%08x\n",
portnum, em_perrdet); portnum, em_perrdet);
/* Clear EM Port N Error Detect CSR */ /* Clear EM Port N Error Detect CSR */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), 0); rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), 0);
} }
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet); rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet);
if (em_ltlerrdet) { if (em_ltlerrdet) {
pr_debug("RIO_PW: RIO_EM_LTL_ERR_DETECT=0x%08x\n", pr_debug("RIO_PW: RIO_EM_LTL_ERR_DETECT=0x%08x\n",
em_ltlerrdet); em_ltlerrdet);
/* Clear EM L/T Layer Error Detect CSR */ /* Clear EM L/T Layer Error Detect CSR */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, 0); rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, 0);
} }
/* Clear remaining error bits and Port-Write Pending bit */ /* Clear remaining error bits and Port-Write Pending bit */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum),
err_status); err_status);
......
...@@ -209,9 +209,6 @@ idtg2_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount, ...@@ -209,9 +209,6 @@ idtg2_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount,
static int static int
idtg2_em_init(struct rio_dev *rdev) idtg2_em_init(struct rio_dev *rdev)
{ {
struct rio_mport *mport = rdev->net->hport;
u16 destid = rdev->rswitch->destid;
u8 hopcount = rdev->rswitch->hopcount;
u32 regval; u32 regval;
int i, tmp; int i, tmp;
...@@ -220,29 +217,25 @@ idtg2_em_init(struct rio_dev *rdev) ...@@ -220,29 +217,25 @@ idtg2_em_init(struct rio_dev *rdev)
* All standard EM configuration should be performed at upper level. * All standard EM configuration should be performed at upper level.
*/ */
pr_debug("RIO: %s [%d:%d]\n", __func__, destid, hopcount); pr_debug("RIO: %s [%d:%d]\n", __func__, rdev->destid, rdev->hopcount);
/* Set Port-Write info CSR: PRIO=3 and CRF=1 */ /* Set Port-Write info CSR: PRIO=3 and CRF=1 */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_PW_INFO_CSR, 0x0000e000);
IDT_PW_INFO_CSR, 0x0000e000);
/* /*
* Configure LT LAYER error reporting. * Configure LT LAYER error reporting.
*/ */
/* Enable standard (RIO.p8) error reporting */ /* Enable standard (RIO.p8) error reporting */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_LT_ERR_REPORT_EN,
IDT_LT_ERR_REPORT_EN,
REM_LTL_ERR_ILLTRAN | REM_LTL_ERR_UNSOLR | REM_LTL_ERR_ILLTRAN | REM_LTL_ERR_UNSOLR |
REM_LTL_ERR_UNSUPTR); REM_LTL_ERR_UNSUPTR);
/* Use Port-Writes for LT layer error reporting. /* Use Port-Writes for LT layer error reporting.
* Enable per-port reset * Enable per-port reset
*/ */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev, IDT_DEV_CTRL_1, &regval);
IDT_DEV_CTRL_1, &regval); rio_write_config_32(rdev, IDT_DEV_CTRL_1,
rio_mport_write_config_32(mport, destid, hopcount,
IDT_DEV_CTRL_1,
regval | IDT_DEV_CTRL_1_GENPW | IDT_DEV_CTRL_1_PRSTBEH); regval | IDT_DEV_CTRL_1_GENPW | IDT_DEV_CTRL_1_PRSTBEH);
/* /*
...@@ -250,45 +243,40 @@ idtg2_em_init(struct rio_dev *rdev) ...@@ -250,45 +243,40 @@ idtg2_em_init(struct rio_dev *rdev)
*/ */
/* Report all RIO.p8 errors supported by device */ /* Report all RIO.p8 errors supported by device */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_PORT_ERR_REPORT_EN_BC, 0x807e8037);
IDT_PORT_ERR_REPORT_EN_BC, 0x807e8037);
/* Configure reporting of implementation specific errors/events */ /* Configure reporting of implementation specific errors/events */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_PORT_ISERR_REPORT_EN_BC,
IDT_PORT_ISERR_REPORT_EN_BC, IDT_PORT_INIT_TX_ACQUIRED); IDT_PORT_INIT_TX_ACQUIRED);
/* Use Port-Writes for port error reporting and enable error logging */ /* Use Port-Writes for port error reporting and enable error logging */
tmp = RIO_GET_TOTAL_PORTS(rdev->swpinfo); tmp = RIO_GET_TOTAL_PORTS(rdev->swpinfo);
for (i = 0; i < tmp; i++) { for (i = 0; i < tmp; i++) {
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev, IDT_PORT_OPS(i), &regval);
IDT_PORT_OPS(i), &regval); rio_write_config_32(rdev,
rio_mport_write_config_32(mport, destid, hopcount,
IDT_PORT_OPS(i), regval | IDT_PORT_OPS_GENPW | IDT_PORT_OPS(i), regval | IDT_PORT_OPS_GENPW |
IDT_PORT_OPS_PL_ELOG | IDT_PORT_OPS_PL_ELOG |
IDT_PORT_OPS_LL_ELOG | IDT_PORT_OPS_LL_ELOG |
IDT_PORT_OPS_LT_ELOG); IDT_PORT_OPS_LT_ELOG);
} }
/* Overwrite error log if full */ /* Overwrite error log if full */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_ERR_CAP, IDT_ERR_CAP_LOG_OVERWR);
IDT_ERR_CAP, IDT_ERR_CAP_LOG_OVERWR);
/* /*
* Configure LANE error reporting. * Configure LANE error reporting.
*/ */
/* Disable line error reporting */ /* Disable line error reporting */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_LANE_ERR_REPORT_EN_BC, 0);
IDT_LANE_ERR_REPORT_EN_BC, 0);
/* Use Port-Writes for lane error reporting (when enabled) /* Use Port-Writes for lane error reporting (when enabled)
* (do per-lane update because lanes may have different configuration) * (do per-lane update because lanes may have different configuration)
*/ */
tmp = (rdev->did == RIO_DID_IDTCPS1848) ? 48 : 16; tmp = (rdev->did == RIO_DID_IDTCPS1848) ? 48 : 16;
for (i = 0; i < tmp; i++) { for (i = 0; i < tmp; i++) {
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev, IDT_LANE_CTRL(i), &regval);
IDT_LANE_CTRL(i), &regval); rio_write_config_32(rdev, IDT_LANE_CTRL(i),
rio_mport_write_config_32(mport, destid, hopcount, regval | IDT_LANE_CTRL_GENPW);
IDT_LANE_CTRL(i), regval | IDT_LANE_CTRL_GENPW);
} }
/* /*
...@@ -296,41 +284,32 @@ idtg2_em_init(struct rio_dev *rdev) ...@@ -296,41 +284,32 @@ idtg2_em_init(struct rio_dev *rdev)
*/ */
/* Disable JTAG and I2C Error capture */ /* Disable JTAG and I2C Error capture */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_AUX_PORT_ERR_CAP_EN, 0);
IDT_AUX_PORT_ERR_CAP_EN, 0);
/* Disable JTAG and I2C Error reporting/logging */ /* Disable JTAG and I2C Error reporting/logging */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_AUX_ERR_REPORT_EN, 0);
IDT_AUX_ERR_REPORT_EN, 0);
/* Disable Port-Write notification from JTAG */ /* Disable Port-Write notification from JTAG */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_JTAG_CTRL, 0);
IDT_JTAG_CTRL, 0);
/* Disable Port-Write notification from I2C */ /* Disable Port-Write notification from I2C */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev, IDT_I2C_MCTRL, &regval);
IDT_I2C_MCTRL, &regval); rio_write_config_32(rdev, IDT_I2C_MCTRL, regval & ~IDT_I2C_MCTRL_GENPW);
rio_mport_write_config_32(mport, destid, hopcount,
IDT_I2C_MCTRL,
regval & ~IDT_I2C_MCTRL_GENPW);
/* /*
* Configure CFG_BLK error reporting. * Configure CFG_BLK error reporting.
*/ */
/* Disable Configuration Block error capture */ /* Disable Configuration Block error capture */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_CFGBLK_ERR_CAPTURE_EN, 0);
IDT_CFGBLK_ERR_CAPTURE_EN, 0);
/* Disable Port-Writes for Configuration Block error reporting */ /* Disable Port-Writes for Configuration Block error reporting */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev, IDT_CFGBLK_ERR_REPORT, &regval);
IDT_CFGBLK_ERR_REPORT, &regval); rio_write_config_32(rdev, IDT_CFGBLK_ERR_REPORT,
rio_mport_write_config_32(mport, destid, hopcount, regval & ~IDT_CFGBLK_ERR_REPORT_GENPW);
IDT_CFGBLK_ERR_REPORT,
regval & ~IDT_CFGBLK_ERR_REPORT_GENPW);
/* set TVAL = ~50us */ /* set TVAL = ~50us */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8);
return 0; return 0;
...@@ -339,18 +318,15 @@ idtg2_em_init(struct rio_dev *rdev) ...@@ -339,18 +318,15 @@ idtg2_em_init(struct rio_dev *rdev)
static int static int
idtg2_em_handler(struct rio_dev *rdev, u8 portnum) idtg2_em_handler(struct rio_dev *rdev, u8 portnum)
{ {
struct rio_mport *mport = rdev->net->hport;
u16 destid = rdev->rswitch->destid;
u8 hopcount = rdev->rswitch->hopcount;
u32 regval, em_perrdet, em_ltlerrdet; u32 regval, em_perrdet, em_ltlerrdet;
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet); rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet);
if (em_ltlerrdet) { if (em_ltlerrdet) {
/* Service Logical/Transport Layer Error(s) */ /* Service Logical/Transport Layer Error(s) */
if (em_ltlerrdet & REM_LTL_ERR_IMPSPEC) { if (em_ltlerrdet & REM_LTL_ERR_IMPSPEC) {
/* Implementation specific error reported */ /* Implementation specific error reported */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
IDT_ISLTL_ADDRESS_CAP, &regval); IDT_ISLTL_ADDRESS_CAP, &regval);
pr_debug("RIO: %s Implementation Specific LTL errors" \ pr_debug("RIO: %s Implementation Specific LTL errors" \
...@@ -358,13 +334,12 @@ idtg2_em_handler(struct rio_dev *rdev, u8 portnum) ...@@ -358,13 +334,12 @@ idtg2_em_handler(struct rio_dev *rdev, u8 portnum)
rio_name(rdev), em_ltlerrdet, regval); rio_name(rdev), em_ltlerrdet, regval);
/* Clear implementation specific address capture CSR */ /* Clear implementation specific address capture CSR */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, IDT_ISLTL_ADDRESS_CAP, 0);
IDT_ISLTL_ADDRESS_CAP, 0);
} }
} }
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet); rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet);
if (em_perrdet) { if (em_perrdet) {
/* Service Port-Level Error(s) */ /* Service Port-Level Error(s) */
...@@ -372,14 +347,14 @@ idtg2_em_handler(struct rio_dev *rdev, u8 portnum) ...@@ -372,14 +347,14 @@ idtg2_em_handler(struct rio_dev *rdev, u8 portnum)
/* Implementation Specific port error reported */ /* Implementation Specific port error reported */
/* Get IS errors reported */ /* Get IS errors reported */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
IDT_PORT_ISERR_DET(portnum), &regval); IDT_PORT_ISERR_DET(portnum), &regval);
pr_debug("RIO: %s Implementation Specific Port" \ pr_debug("RIO: %s Implementation Specific Port" \
" errors 0x%x\n", rio_name(rdev), regval); " errors 0x%x\n", rio_name(rdev), regval);
/* Clear all implementation specific events */ /* Clear all implementation specific events */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
IDT_PORT_ISERR_DET(portnum), 0); IDT_PORT_ISERR_DET(portnum), 0);
} }
} }
...@@ -391,14 +366,10 @@ static ssize_t ...@@ -391,14 +366,10 @@ static ssize_t
idtg2_show_errlog(struct device *dev, struct device_attribute *attr, char *buf) idtg2_show_errlog(struct device *dev, struct device_attribute *attr, char *buf)
{ {
struct rio_dev *rdev = to_rio_dev(dev); struct rio_dev *rdev = to_rio_dev(dev);
struct rio_mport *mport = rdev->net->hport;
u16 destid = rdev->rswitch->destid;
u8 hopcount = rdev->rswitch->hopcount;
ssize_t len = 0; ssize_t len = 0;
u32 regval; u32 regval;
while (!rio_mport_read_config_32(mport, destid, hopcount, while (!rio_read_config_32(rdev, IDT_ERR_RD, &regval)) {
IDT_ERR_RD, &regval)) {
if (!regval) /* 0 = end of log */ if (!regval) /* 0 = end of log */
break; break;
len += snprintf(buf + len, PAGE_SIZE - len, len += snprintf(buf + len, PAGE_SIZE - len,
......
...@@ -117,10 +117,6 @@ idtcps_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount, ...@@ -117,10 +117,6 @@ idtcps_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount,
static int idtcps_switch_init(struct rio_dev *rdev, int do_enum) static int idtcps_switch_init(struct rio_dev *rdev, int do_enum)
{ {
struct rio_mport *mport = rdev->net->hport;
u16 destid = rdev->rswitch->destid;
u8 hopcount = rdev->rswitch->hopcount;
pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev));
rdev->rswitch->add_entry = idtcps_route_add_entry; rdev->rswitch->add_entry = idtcps_route_add_entry;
rdev->rswitch->get_entry = idtcps_route_get_entry; rdev->rswitch->get_entry = idtcps_route_get_entry;
...@@ -132,7 +128,7 @@ static int idtcps_switch_init(struct rio_dev *rdev, int do_enum) ...@@ -132,7 +128,7 @@ static int idtcps_switch_init(struct rio_dev *rdev, int do_enum)
if (do_enum) { if (do_enum) {
/* set TVAL = ~50us */ /* set TVAL = ~50us */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8);
} }
......
...@@ -113,22 +113,17 @@ tsi568_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount, ...@@ -113,22 +113,17 @@ tsi568_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
static int static int
tsi568_em_init(struct rio_dev *rdev) tsi568_em_init(struct rio_dev *rdev)
{ {
struct rio_mport *mport = rdev->net->hport;
u16 destid = rdev->rswitch->destid;
u8 hopcount = rdev->rswitch->hopcount;
u32 regval; u32 regval;
int portnum; int portnum;
pr_debug("TSI568 %s [%d:%d]\n", __func__, destid, hopcount); pr_debug("TSI568 %s [%d:%d]\n", __func__, rdev->destid, rdev->hopcount);
/* Make sure that Port-Writes are disabled (for all ports) */ /* Make sure that Port-Writes are disabled (for all ports) */
for (portnum = 0; for (portnum = 0;
portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) { portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) {
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev, TSI568_SP_MODE(portnum), &regval);
TSI568_SP_MODE(portnum), &regval); rio_write_config_32(rdev, TSI568_SP_MODE(portnum),
rio_mport_write_config_32(mport, destid, hopcount, regval | TSI568_SP_MODE_PW_DIS);
TSI568_SP_MODE(portnum),
regval | TSI568_SP_MODE_PW_DIS);
} }
return 0; return 0;
......
...@@ -158,48 +158,45 @@ tsi57x_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount, ...@@ -158,48 +158,45 @@ tsi57x_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount,
static int static int
tsi57x_em_init(struct rio_dev *rdev) tsi57x_em_init(struct rio_dev *rdev)
{ {
struct rio_mport *mport = rdev->net->hport;
u16 destid = rdev->rswitch->destid;
u8 hopcount = rdev->rswitch->hopcount;
u32 regval; u32 regval;
int portnum; int portnum;
pr_debug("TSI578 %s [%d:%d]\n", __func__, destid, hopcount); pr_debug("TSI578 %s [%d:%d]\n", __func__, rdev->destid, rdev->hopcount);
for (portnum = 0; for (portnum = 0;
portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) { portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) {
/* Make sure that Port-Writes are enabled (for all ports) */ /* Make sure that Port-Writes are enabled (for all ports) */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
TSI578_SP_MODE(portnum), &regval); TSI578_SP_MODE(portnum), &regval);
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
TSI578_SP_MODE(portnum), TSI578_SP_MODE(portnum),
regval & ~TSI578_SP_MODE_PW_DIS); regval & ~TSI578_SP_MODE_PW_DIS);
/* Clear all pending interrupts */ /* Clear all pending interrupts */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + rdev->phys_efptr +
RIO_PORT_N_ERR_STS_CSR(portnum), RIO_PORT_N_ERR_STS_CSR(portnum),
&regval); &regval);
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + rdev->phys_efptr +
RIO_PORT_N_ERR_STS_CSR(portnum), RIO_PORT_N_ERR_STS_CSR(portnum),
regval & 0x07120214); regval & 0x07120214);
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
TSI578_SP_INT_STATUS(portnum), &regval); TSI578_SP_INT_STATUS(portnum), &regval);
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
TSI578_SP_INT_STATUS(portnum), TSI578_SP_INT_STATUS(portnum),
regval & 0x000700bd); regval & 0x000700bd);
/* Enable all interrupts to allow ports to send a port-write */ /* Enable all interrupts to allow ports to send a port-write */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
TSI578_SP_CTL_INDEP(portnum), &regval); TSI578_SP_CTL_INDEP(portnum), &regval);
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
TSI578_SP_CTL_INDEP(portnum), TSI578_SP_CTL_INDEP(portnum),
regval | 0x000b0000); regval | 0x000b0000);
/* Skip next (odd) port if the current port is in x4 mode */ /* Skip next (odd) port if the current port is in x4 mode */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
&regval); &regval);
if ((regval & RIO_PORT_N_CTL_PWIDTH) == RIO_PORT_N_CTL_PWIDTH_4) if ((regval & RIO_PORT_N_CTL_PWIDTH) == RIO_PORT_N_CTL_PWIDTH_4)
...@@ -207,7 +204,7 @@ tsi57x_em_init(struct rio_dev *rdev) ...@@ -207,7 +204,7 @@ tsi57x_em_init(struct rio_dev *rdev)
} }
/* set TVAL = ~50us */ /* set TVAL = ~50us */
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x9a << 8); rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x9a << 8);
return 0; return 0;
...@@ -217,14 +214,12 @@ static int ...@@ -217,14 +214,12 @@ static int
tsi57x_em_handler(struct rio_dev *rdev, u8 portnum) tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
{ {
struct rio_mport *mport = rdev->net->hport; struct rio_mport *mport = rdev->net->hport;
u16 destid = rdev->rswitch->destid;
u8 hopcount = rdev->rswitch->hopcount;
u32 intstat, err_status; u32 intstat, err_status;
int sendcount, checkcount; int sendcount, checkcount;
u8 route_port; u8 route_port;
u32 regval; u32 regval;
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum),
&err_status); &err_status);
...@@ -232,15 +227,15 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum) ...@@ -232,15 +227,15 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
(err_status & (RIO_PORT_N_ERR_STS_PW_OUT_ES | (err_status & (RIO_PORT_N_ERR_STS_PW_OUT_ES |
RIO_PORT_N_ERR_STS_PW_INP_ES))) { RIO_PORT_N_ERR_STS_PW_INP_ES))) {
/* Remove any queued packets by locking/unlocking port */ /* Remove any queued packets by locking/unlocking port */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
&regval); &regval);
if (!(regval & RIO_PORT_N_CTL_LOCKOUT)) { if (!(regval & RIO_PORT_N_CTL_LOCKOUT)) {
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
regval | RIO_PORT_N_CTL_LOCKOUT); regval | RIO_PORT_N_CTL_LOCKOUT);
udelay(50); udelay(50);
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
regval); regval);
} }
...@@ -248,7 +243,7 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum) ...@@ -248,7 +243,7 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
/* Read from link maintenance response register to clear /* Read from link maintenance response register to clear
* valid bit * valid bit
*/ */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(portnum), rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(portnum),
&regval); &regval);
...@@ -257,13 +252,12 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum) ...@@ -257,13 +252,12 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
*/ */
sendcount = 3; sendcount = 3;
while (sendcount) { while (sendcount) {
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev,
TSI578_SP_CS_TX(portnum), 0x40fc8000); TSI578_SP_CS_TX(portnum), 0x40fc8000);
checkcount = 3; checkcount = 3;
while (checkcount--) { while (checkcount--) {
udelay(50); udelay(50);
rio_mport_read_config_32( rio_read_config_32(rdev,
mport, destid, hopcount,
rdev->phys_efptr + rdev->phys_efptr +
RIO_PORT_N_MNT_RSP_CSR(portnum), RIO_PORT_N_MNT_RSP_CSR(portnum),
&regval); &regval);
...@@ -277,25 +271,23 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum) ...@@ -277,25 +271,23 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
exit_es: exit_es:
/* Clear implementation specific error status bits */ /* Clear implementation specific error status bits */
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev, TSI578_SP_INT_STATUS(portnum), &intstat);
TSI578_SP_INT_STATUS(portnum), &intstat);
pr_debug("TSI578[%x:%x] SP%d_INT_STATUS=0x%08x\n", pr_debug("TSI578[%x:%x] SP%d_INT_STATUS=0x%08x\n",
destid, hopcount, portnum, intstat); rdev->destid, rdev->hopcount, portnum, intstat);
if (intstat & 0x10000) { if (intstat & 0x10000) {
rio_mport_read_config_32(mport, destid, hopcount, rio_read_config_32(rdev,
TSI578_SP_LUT_PEINF(portnum), &regval); TSI578_SP_LUT_PEINF(portnum), &regval);
regval = (mport->sys_size) ? (regval >> 16) : (regval >> 24); regval = (mport->sys_size) ? (regval >> 16) : (regval >> 24);
route_port = rdev->rswitch->route_table[regval]; route_port = rdev->rswitch->route_table[regval];
pr_debug("RIO: TSI578[%s] P%d LUT Parity Error (destID=%d)\n", pr_debug("RIO: TSI578[%s] P%d LUT Parity Error (destID=%d)\n",
rio_name(rdev), portnum, regval); rio_name(rdev), portnum, regval);
tsi57x_route_add_entry(mport, destid, hopcount, tsi57x_route_add_entry(mport, rdev->destid, rdev->hopcount,
RIO_GLOBAL_TABLE, regval, route_port); RIO_GLOBAL_TABLE, regval, route_port);
} }
rio_mport_write_config_32(mport, destid, hopcount, rio_write_config_32(rdev, TSI578_SP_INT_STATUS(portnum),
TSI578_SP_INT_STATUS(portnum), intstat & 0x000700bd);
intstat & 0x000700bd);
return 0; return 0;
} }
......
...@@ -98,7 +98,8 @@ union rio_pw_msg; ...@@ -98,7 +98,8 @@ union rio_pw_msg;
* @dev: Device model device * @dev: Device model device
* @riores: RIO resources this device owns * @riores: RIO resources this device owns
* @pwcback: port-write callback function for this device * @pwcback: port-write callback function for this device
* @destid: Network destination ID * @destid: Network destination ID (or associated destid for switch)
* @hopcount: Hopcount to this device
* @prev: Previous RIO device connected to the current one * @prev: Previous RIO device connected to the current one
*/ */
struct rio_dev { struct rio_dev {
...@@ -126,6 +127,7 @@ struct rio_dev { ...@@ -126,6 +127,7 @@ struct rio_dev {
struct resource riores[RIO_MAX_DEV_RESOURCES]; struct resource riores[RIO_MAX_DEV_RESOURCES];
int (*pwcback) (struct rio_dev *rdev, union rio_pw_msg *msg, int step); int (*pwcback) (struct rio_dev *rdev, union rio_pw_msg *msg, int step);
u16 destid; u16 destid;
u8 hopcount;
struct rio_dev *prev; struct rio_dev *prev;
}; };
...@@ -229,8 +231,6 @@ struct rio_net { ...@@ -229,8 +231,6 @@ struct rio_net {
* @node: Node in global list of switches * @node: Node in global list of switches
* @rdev: Associated RIO device structure * @rdev: Associated RIO device structure
* @switchid: Switch ID that is unique across a network * @switchid: Switch ID that is unique across a network
* @hopcount: Hopcount to this switch
* @destid: Associated destid in the path
* @route_table: Copy of switch routing table * @route_table: Copy of switch routing table
* @port_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0 * @port_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0
* @add_entry: Callback for switch-specific route add function * @add_entry: Callback for switch-specific route add function
...@@ -247,8 +247,6 @@ struct rio_switch { ...@@ -247,8 +247,6 @@ struct rio_switch {
struct list_head node; struct list_head node;
struct rio_dev *rdev; struct rio_dev *rdev;
u16 switchid; u16 switchid;
u16 hopcount;
u16 destid;
u8 *route_table; u8 *route_table;
u32 port_ok; u32 port_ok;
int (*add_entry) (struct rio_mport * mport, u16 destid, u8 hopcount, int (*add_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
......
...@@ -150,16 +150,8 @@ static inline int rio_local_write_config_8(struct rio_mport *port, u32 offset, ...@@ -150,16 +150,8 @@ static inline int rio_local_write_config_8(struct rio_mport *port, u32 offset,
static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset, static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset,
u32 * data) u32 * data)
{ {
u8 hopcount = 0xff; return rio_mport_read_config_32(rdev->net->hport, rdev->destid,
u16 destid = rdev->destid; rdev->hopcount, offset, data);
if (rdev->rswitch) {
destid = rdev->rswitch->destid;
hopcount = rdev->rswitch->hopcount;
}
return rio_mport_read_config_32(rdev->net->hport, destid, hopcount,
offset, data);
}; };
/** /**
...@@ -174,16 +166,8 @@ static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset, ...@@ -174,16 +166,8 @@ static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset,
static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset, static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset,
u32 data) u32 data)
{ {
u8 hopcount = 0xff; return rio_mport_write_config_32(rdev->net->hport, rdev->destid,
u16 destid = rdev->destid; rdev->hopcount, offset, data);
if (rdev->rswitch) {
destid = rdev->rswitch->destid;
hopcount = rdev->rswitch->hopcount;
}
return rio_mport_write_config_32(rdev->net->hport, destid, hopcount,
offset, data);
}; };
/** /**
...@@ -198,16 +182,8 @@ static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset, ...@@ -198,16 +182,8 @@ static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset,
static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset, static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset,
u16 * data) u16 * data)
{ {
u8 hopcount = 0xff; return rio_mport_read_config_16(rdev->net->hport, rdev->destid,
u16 destid = rdev->destid; rdev->hopcount, offset, data);
if (rdev->rswitch) {
destid = rdev->rswitch->destid;
hopcount = rdev->rswitch->hopcount;
}
return rio_mport_read_config_16(rdev->net->hport, destid, hopcount,
offset, data);
}; };
/** /**
...@@ -222,16 +198,8 @@ static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset, ...@@ -222,16 +198,8 @@ static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset,
static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset, static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset,
u16 data) u16 data)
{ {
u8 hopcount = 0xff; return rio_mport_write_config_16(rdev->net->hport, rdev->destid,
u16 destid = rdev->destid; rdev->hopcount, offset, data);
if (rdev->rswitch) {
destid = rdev->rswitch->destid;
hopcount = rdev->rswitch->hopcount;
}
return rio_mport_write_config_16(rdev->net->hport, destid, hopcount,
offset, data);
}; };
/** /**
...@@ -245,16 +213,8 @@ static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset, ...@@ -245,16 +213,8 @@ static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset,
*/ */
static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data) static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data)
{ {
u8 hopcount = 0xff; return rio_mport_read_config_8(rdev->net->hport, rdev->destid,
u16 destid = rdev->destid; rdev->hopcount, offset, data);
if (rdev->rswitch) {
destid = rdev->rswitch->destid;
hopcount = rdev->rswitch->hopcount;
}
return rio_mport_read_config_8(rdev->net->hport, destid, hopcount,
offset, data);
}; };
/** /**
...@@ -268,16 +228,8 @@ static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data) ...@@ -268,16 +228,8 @@ static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data)
*/ */
static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data) static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data)
{ {
u8 hopcount = 0xff; return rio_mport_write_config_8(rdev->net->hport, rdev->destid,
u16 destid = rdev->destid; rdev->hopcount, offset, data);
if (rdev->rswitch) {
destid = rdev->rswitch->destid;
hopcount = rdev->rswitch->hopcount;
}
return rio_mport_write_config_8(rdev->net->hport, destid, hopcount,
offset, data);
}; };
extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid,
......
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