aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Bounine <alexandre.bounine@idt.com>2010-10-27 18:34:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-27 21:03:15 -0400
commitae05cbd5adef897d405ce8f90484c1239f79e086 (patch)
tree1b235d02a42e40ae2071f2ce0983de1f0feadaf1
parent93e2cbd24e71f5eedf6e49e075973fda9b2135e8 (diff)
rapidio: use stored ingress port number instead of register read
The switch port information is obtained and stored during RIO device setup. Therefore repeated reads from Switch Port Information CAR may be removed. Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Thomas Moll <thomas.moll@sysgo.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Li Yang <leoli@freescale.com> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Micha Nelissen <micha@neli.hopto.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/rapidio/rio-scan.c36
-rw-r--r--include/linux/rio.h4
-rw-r--r--include/linux/rio_regs.h2
3 files changed, 14 insertions, 28 deletions
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 1123be8f4b18..d09c359844f3 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -420,6 +420,11 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
420 hopcount, RIO_EFB_ERR_MGMNT); 420 hopcount, RIO_EFB_ERR_MGMNT);
421 } 421 }
422 422
423 if (rdev->pef & (RIO_PEF_SWITCH | RIO_PEF_MULTIPORT)) {
424 rio_mport_read_config_32(port, destid, hopcount,
425 RIO_SWP_INFO_CAR, &rdev->swpinfo);
426 }
427
423 rio_mport_read_config_32(port, destid, hopcount, RIO_SRC_OPS_CAR, 428 rio_mport_read_config_32(port, destid, hopcount, RIO_SRC_OPS_CAR,
424 &rdev->src_ops); 429 &rdev->src_ops);
425 rio_mport_read_config_32(port, destid, hopcount, RIO_DST_OPS_CAR, 430 rio_mport_read_config_32(port, destid, hopcount, RIO_DST_OPS_CAR,
@@ -439,8 +444,6 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
439 444
440 /* If a PE has both switch and other functions, show it as a switch */ 445 /* If a PE has both switch and other functions, show it as a switch */
441 if (rio_is_switch(rdev)) { 446 if (rio_is_switch(rdev)) {
442 rio_mport_read_config_32(port, destid, hopcount,
443 RIO_SWP_INFO_CAR, &rdev->swpinfo);
444 rswitch = kzalloc(sizeof(struct rio_switch), GFP_KERNEL); 447 rswitch = kzalloc(sizeof(struct rio_switch), GFP_KERNEL);
445 if (!rswitch) 448 if (!rswitch)
446 goto cleanup; 449 goto cleanup;
@@ -458,6 +461,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
458 rdid++) 461 rdid++)
459 rswitch->route_table[rdid] = RIO_INVALID_ROUTE; 462 rswitch->route_table[rdid] = RIO_INVALID_ROUTE;
460 rdev->rswitch = rswitch; 463 rdev->rswitch = rswitch;
464 rswitch->rdev = rdev;
461 dev_set_name(&rdev->dev, "%02x:s:%04x", rdev->net->id, 465 dev_set_name(&rdev->dev, "%02x:s:%04x", rdev->net->id,
462 rdev->rswitch->switchid); 466 rdev->rswitch->switchid);
463 rio_switch_init(rdev, do_enum); 467 rio_switch_init(rdev, do_enum);
@@ -719,25 +723,6 @@ static u16 rio_get_host_deviceid_lock(struct rio_mport *port, u8 hopcount)
719} 723}
720 724
721/** 725/**
722 * rio_get_swpinfo_inport- Gets the ingress port number
723 * @mport: Master port to send transaction
724 * @destid: Destination ID associated with the switch
725 * @hopcount: Number of hops to the device
726 *
727 * Returns port number being used to access the switch device.
728 */
729static u8
730rio_get_swpinfo_inport(struct rio_mport *mport, u16 destid, u8 hopcount)
731{
732 u32 result;
733
734 rio_mport_read_config_32(mport, destid, hopcount, RIO_SWP_INFO_CAR,
735 &result);
736
737 return (u8) (result & 0xff);
738}
739
740/**
741 * rio_get_swpinfo_tports- Gets total number of ports on the switch 726 * rio_get_swpinfo_tports- Gets total number of ports on the switch
742 * @mport: Master port to send transaction 727 * @mport: Master port to send transaction
743 * @destid: Destination ID associated with the switch 728 * @destid: Destination ID associated with the switch
@@ -834,8 +819,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
834 819
835 if (rio_is_switch(rdev)) { 820 if (rio_is_switch(rdev)) {
836 next_switchid++; 821 next_switchid++;
837 sw_inport = rio_get_swpinfo_inport(port, 822 sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo);
838 RIO_ANY_DESTID(port->sys_size), hopcount);
839 rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, 823 rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE,
840 port->host_deviceid, sw_inport, 0); 824 port->host_deviceid, sw_inport, 0);
841 rdev->rswitch->route_table[port->host_deviceid] = sw_inport; 825 rdev->rswitch->route_table[port->host_deviceid] = sw_inport;
@@ -989,8 +973,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
989 "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", 973 "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n",
990 rio_name(rdev), rdev->vid, rdev->did, num_ports); 974 rio_name(rdev), rdev->vid, rdev->did, num_ports);
991 for (port_num = 0; port_num < num_ports; port_num++) { 975 for (port_num = 0; port_num < num_ports; port_num++) {
992 if (rio_get_swpinfo_inport(port, destid, hopcount) == 976 if (RIO_GET_PORT_NUM(rdev->swpinfo) == port_num)
993 port_num)
994 continue; 977 continue;
995 978
996 if (rio_sport_is_active 979 if (rio_sport_is_active
@@ -1109,8 +1092,7 @@ static void rio_update_route_tables(struct rio_mport *port)
1109 if (rswitch->destid == destid) 1092 if (rswitch->destid == destid)
1110 continue; 1093 continue;
1111 1094
1112 sport = rio_get_swpinfo_inport(port, 1095 sport = RIO_GET_PORT_NUM(rswitch->rdev->swpinfo);
1113 rswitch->destid, rswitch->hopcount);
1114 1096
1115 if (rswitch->add_entry) { 1097 if (rswitch->add_entry) {
1116 rio_route_add_entry(port, rswitch, 1098 rio_route_add_entry(port, rswitch,
diff --git a/include/linux/rio.h b/include/linux/rio.h
index 84c9f8c5fb23..ffdfe5ad43bf 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -112,7 +112,7 @@ struct rio_dev {
112 u16 asm_rev; 112 u16 asm_rev;
113 u16 efptr; 113 u16 efptr;
114 u32 pef; 114 u32 pef;
115 u32 swpinfo; /* Only used for switches */ 115 u32 swpinfo;
116 u32 src_ops; 116 u32 src_ops;
117 u32 dst_ops; 117 u32 dst_ops;
118 u32 comp_tag; 118 u32 comp_tag;
@@ -219,6 +219,7 @@ struct rio_net {
219/** 219/**
220 * struct rio_switch - RIO switch info 220 * struct rio_switch - RIO switch info
221 * @node: Node in global list of switches 221 * @node: Node in global list of switches
222 * @rdev: Associated RIO device structure
222 * @switchid: Switch ID that is unique across a network 223 * @switchid: Switch ID that is unique across a network
223 * @hopcount: Hopcount to this switch 224 * @hopcount: Hopcount to this switch
224 * @destid: Associated destid in the path 225 * @destid: Associated destid in the path
@@ -234,6 +235,7 @@ struct rio_net {
234 */ 235 */
235struct rio_switch { 236struct rio_switch {
236 struct list_head node; 237 struct list_head node;
238 struct rio_dev *rdev;
237 u16 switchid; 239 u16 switchid;
238 u16 hopcount; 240 u16 hopcount;
239 u16 destid; 241 u16 destid;
diff --git a/include/linux/rio_regs.h b/include/linux/rio_regs.h
index aedee0489fb4..be80b1b21815 100644
--- a/include/linux/rio_regs.h
+++ b/include/linux/rio_regs.h
@@ -33,6 +33,7 @@
33#define RIO_PEF_MEMORY 0x40000000 /* [I] MMIO */ 33#define RIO_PEF_MEMORY 0x40000000 /* [I] MMIO */
34#define RIO_PEF_PROCESSOR 0x20000000 /* [I] Processor */ 34#define RIO_PEF_PROCESSOR 0x20000000 /* [I] Processor */
35#define RIO_PEF_SWITCH 0x10000000 /* [I] Switch */ 35#define RIO_PEF_SWITCH 0x10000000 /* [I] Switch */
36#define RIO_PEF_MULTIPORT 0x08000000 /* [VI, 2.1] Multiport */
36#define RIO_PEF_INB_MBOX 0x00f00000 /* [II] Mailboxes */ 37#define RIO_PEF_INB_MBOX 0x00f00000 /* [II] Mailboxes */
37#define RIO_PEF_INB_MBOX0 0x00800000 /* [II] Mailbox 0 */ 38#define RIO_PEF_INB_MBOX0 0x00800000 /* [II] Mailbox 0 */
38#define RIO_PEF_INB_MBOX1 0x00400000 /* [II] Mailbox 1 */ 39#define RIO_PEF_INB_MBOX1 0x00400000 /* [II] Mailbox 1 */
@@ -51,6 +52,7 @@
51#define RIO_SWP_INFO_PORT_TOTAL_MASK 0x0000ff00 /* [I] Total number of ports */ 52#define RIO_SWP_INFO_PORT_TOTAL_MASK 0x0000ff00 /* [I] Total number of ports */
52#define RIO_SWP_INFO_PORT_NUM_MASK 0x000000ff /* [I] Maintenance transaction port number */ 53#define RIO_SWP_INFO_PORT_NUM_MASK 0x000000ff /* [I] Maintenance transaction port number */
53#define RIO_GET_TOTAL_PORTS(x) ((x & RIO_SWP_INFO_PORT_TOTAL_MASK) >> 8) 54#define RIO_GET_TOTAL_PORTS(x) ((x & RIO_SWP_INFO_PORT_TOTAL_MASK) >> 8)
55#define RIO_GET_PORT_NUM(x) (x & RIO_SWP_INFO_PORT_NUM_MASK)
54 56
55#define RIO_SRC_OPS_CAR 0x18 /* [I] Source Operations CAR */ 57#define RIO_SRC_OPS_CAR 0x18 /* [I] Source Operations CAR */
56#define RIO_SRC_OPS_READ 0x00008000 /* [I] Read op */ 58#define RIO_SRC_OPS_READ 0x00008000 /* [I] Read op */