diff options
author | Alexandre Bounine <alexandre.bounine@idt.com> | 2011-01-12 20:00:38 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 11:03:17 -0500 |
commit | a93192a5d245a262dc52fa426de5b20467308a77 (patch) | |
tree | f3231240286ef3d204375e047f6b2e1a8efbbcd2 /drivers/rapidio/rio-scan.c | |
parent | e6d7202b66d99bf514c8e901db68386b1fcd6d56 (diff) |
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: Alexandre 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rapidio/rio-scan.c')
-rw-r--r-- | drivers/rapidio/rio-scan.c | 84 |
1 files changed, 43 insertions, 41 deletions
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index 1eb82c4c712e..51f0af241eb7 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c | |||
@@ -437,9 +437,15 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, | |||
437 | next_destid++; | 437 | next_destid++; |
438 | } else | 438 | } else |
439 | rdev->destid = rio_get_device_id(port, destid, hopcount); | 439 | rdev->destid = rio_get_device_id(port, destid, hopcount); |
440 | } else | 440 | |
441 | /* Switch device has an associated destID */ | 441 | rdev->hopcount = 0xff; |
442 | rdev->destid = RIO_INVALID_DESTID; | 442 | } else { |
443 | /* Switch device has an associated destID which | ||
444 | * will be adjusted later | ||
445 | */ | ||
446 | rdev->destid = destid; | ||
447 | rdev->hopcount = hopcount; | ||
448 | } | ||
443 | 449 | ||
444 | /* If a PE has both switch and other functions, show it as a switch */ | 450 | /* If a PE has both switch and other functions, show it as a switch */ |
445 | if (rio_is_switch(rdev)) { | 451 | if (rio_is_switch(rdev)) { |
@@ -450,8 +456,6 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, | |||
450 | if (!rswitch) | 456 | if (!rswitch) |
451 | goto cleanup; | 457 | goto cleanup; |
452 | rswitch->switchid = next_switchid; | 458 | rswitch->switchid = next_switchid; |
453 | rswitch->hopcount = hopcount; | ||
454 | rswitch->destid = destid; | ||
455 | rswitch->port_ok = 0; | 459 | rswitch->port_ok = 0; |
456 | rswitch->route_table = kzalloc(sizeof(u8)* | 460 | rswitch->route_table = kzalloc(sizeof(u8)* |
457 | RIO_MAX_ROUTE_ENTRIES(port->sys_size), | 461 | RIO_MAX_ROUTE_ENTRIES(port->sys_size), |
@@ -632,8 +636,7 @@ rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount) | |||
632 | 636 | ||
633 | /** | 637 | /** |
634 | * rio_route_add_entry- Add a route entry to a switch routing table | 638 | * rio_route_add_entry- Add a route entry to a switch routing table |
635 | * @mport: Master port to send transaction | 639 | * @rdev: RIO device |
636 | * @rswitch: Switch device | ||
637 | * @table: Routing table ID | 640 | * @table: Routing table ID |
638 | * @route_destid: Destination ID to be routed | 641 | * @route_destid: Destination ID to be routed |
639 | * @route_port: Port number to be routed | 642 | * @route_port: Port number to be routed |
@@ -647,31 +650,31 @@ rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount) | |||
647 | * on failure. | 650 | * on failure. |
648 | */ | 651 | */ |
649 | static int | 652 | static int |
650 | rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch, | 653 | rio_route_add_entry(struct rio_dev *rdev, |
651 | u16 table, u16 route_destid, u8 route_port, int lock) | 654 | u16 table, u16 route_destid, u8 route_port, int lock) |
652 | { | 655 | { |
653 | int rc; | 656 | int rc; |
654 | 657 | ||
655 | if (lock) { | 658 | if (lock) { |
656 | rc = rio_lock_device(mport, rswitch->destid, | 659 | rc = rio_lock_device(rdev->net->hport, rdev->destid, |
657 | rswitch->hopcount, 1000); | 660 | rdev->hopcount, 1000); |
658 | if (rc) | 661 | if (rc) |
659 | return rc; | 662 | return rc; |
660 | } | 663 | } |
661 | 664 | ||
662 | rc = rswitch->add_entry(mport, rswitch->destid, | 665 | rc = rdev->rswitch->add_entry(rdev->net->hport, rdev->destid, |
663 | rswitch->hopcount, table, | 666 | rdev->hopcount, table, |
664 | route_destid, route_port); | 667 | route_destid, route_port); |
665 | if (lock) | 668 | if (lock) |
666 | rio_unlock_device(mport, rswitch->destid, rswitch->hopcount); | 669 | rio_unlock_device(rdev->net->hport, rdev->destid, |
670 | rdev->hopcount); | ||
667 | 671 | ||
668 | return rc; | 672 | return rc; |
669 | } | 673 | } |
670 | 674 | ||
671 | /** | 675 | /** |
672 | * rio_route_get_entry- Read a route entry in a switch routing table | 676 | * rio_route_get_entry- Read a route entry in a switch routing table |
673 | * @mport: Master port to send transaction | 677 | * @rdev: RIO device |
674 | * @rswitch: Switch device | ||
675 | * @table: Routing table ID | 678 | * @table: Routing table ID |
676 | * @route_destid: Destination ID to be routed | 679 | * @route_destid: Destination ID to be routed |
677 | * @route_port: Pointer to read port number into | 680 | * @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 | * on failure. | 688 | * on failure. |
686 | */ | 689 | */ |
687 | static int | 690 | static int |
688 | rio_route_get_entry(struct rio_mport *mport, struct rio_switch *rswitch, u16 table, | 691 | rio_route_get_entry(struct rio_dev *rdev, u16 table, |
689 | u16 route_destid, u8 *route_port, int lock) | 692 | u16 route_destid, u8 *route_port, int lock) |
690 | { | 693 | { |
691 | int rc; | 694 | int rc; |
692 | 695 | ||
693 | if (lock) { | 696 | if (lock) { |
694 | rc = rio_lock_device(mport, rswitch->destid, | 697 | rc = rio_lock_device(rdev->net->hport, rdev->destid, |
695 | rswitch->hopcount, 1000); | 698 | rdev->hopcount, 1000); |
696 | if (rc) | 699 | if (rc) |
697 | return rc; | 700 | return rc; |
698 | } | 701 | } |
699 | 702 | ||
700 | rc = rswitch->get_entry(mport, rswitch->destid, | 703 | rc = rdev->rswitch->get_entry(rdev->net->hport, rdev->destid, |
701 | rswitch->hopcount, table, | 704 | rdev->hopcount, table, |
702 | route_destid, route_port); | 705 | route_destid, route_port); |
703 | if (lock) | 706 | if (lock) |
704 | rio_unlock_device(mport, rswitch->destid, rswitch->hopcount); | 707 | rio_unlock_device(rdev->net->hport, rdev->destid, |
708 | rdev->hopcount); | ||
705 | 709 | ||
706 | return rc; | 710 | return rc; |
707 | } | 711 | } |
@@ -811,14 +815,14 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
811 | if (rio_is_switch(rdev)) { | 815 | if (rio_is_switch(rdev)) { |
812 | next_switchid++; | 816 | next_switchid++; |
813 | sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo); | 817 | sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo); |
814 | rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, | 818 | rio_route_add_entry(rdev, RIO_GLOBAL_TABLE, |
815 | port->host_deviceid, sw_inport, 0); | 819 | port->host_deviceid, sw_inport, 0); |
816 | rdev->rswitch->route_table[port->host_deviceid] = sw_inport; | 820 | rdev->rswitch->route_table[port->host_deviceid] = sw_inport; |
817 | 821 | ||
818 | for (destid = 0; destid < next_destid; destid++) { | 822 | for (destid = 0; destid < next_destid; destid++) { |
819 | if (destid == port->host_deviceid) | 823 | if (destid == port->host_deviceid) |
820 | continue; | 824 | continue; |
821 | rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, | 825 | rio_route_add_entry(rdev, RIO_GLOBAL_TABLE, |
822 | destid, sw_inport, 0); | 826 | destid, sw_inport, 0); |
823 | rdev->rswitch->route_table[destid] = sw_inport; | 827 | rdev->rswitch->route_table[destid] = sw_inport; |
824 | } | 828 | } |
@@ -850,8 +854,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
850 | "RIO: scanning device on port %d\n", | 854 | "RIO: scanning device on port %d\n", |
851 | port_num); | 855 | port_num); |
852 | rdev->rswitch->port_ok |= (1 << port_num); | 856 | rdev->rswitch->port_ok |= (1 << port_num); |
853 | rio_route_add_entry(port, rdev->rswitch, | 857 | rio_route_add_entry(rdev, RIO_GLOBAL_TABLE, |
854 | RIO_GLOBAL_TABLE, | ||
855 | RIO_ANY_DESTID(port->sys_size), | 858 | RIO_ANY_DESTID(port->sys_size), |
856 | port_num, 0); | 859 | port_num, 0); |
857 | 860 | ||
@@ -865,7 +868,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
865 | destid < next_destid; destid++) { | 868 | destid < next_destid; destid++) { |
866 | if (destid == port->host_deviceid) | 869 | if (destid == port->host_deviceid) |
867 | continue; | 870 | continue; |
868 | rio_route_add_entry(port, rdev->rswitch, | 871 | rio_route_add_entry(rdev, |
869 | RIO_GLOBAL_TABLE, | 872 | RIO_GLOBAL_TABLE, |
870 | destid, | 873 | destid, |
871 | port_num, | 874 | port_num, |
@@ -904,7 +907,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
904 | next_destid++; | 907 | next_destid++; |
905 | } | 908 | } |
906 | 909 | ||
907 | rdev->rswitch->destid = sw_destid; | 910 | rdev->destid = sw_destid; |
908 | } else | 911 | } else |
909 | pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n", | 912 | pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n", |
910 | rio_name(rdev), rdev->vid, rdev->did); | 913 | 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 | next_switchid++; | 961 | next_switchid++; |
959 | 962 | ||
960 | /* Associated destid is how we accessed this switch */ | 963 | /* Associated destid is how we accessed this switch */ |
961 | rdev->rswitch->destid = destid; | 964 | rdev->destid = destid; |
962 | 965 | ||
963 | pr_debug( | 966 | pr_debug( |
964 | "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", | 967 | "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 | for (ndestid = 0; | 984 | for (ndestid = 0; |
982 | ndestid < RIO_ANY_DESTID(port->sys_size); | 985 | ndestid < RIO_ANY_DESTID(port->sys_size); |
983 | ndestid++) { | 986 | ndestid++) { |
984 | rio_route_get_entry(port, rdev->rswitch, | 987 | rio_route_get_entry(rdev, |
985 | RIO_GLOBAL_TABLE, | 988 | RIO_GLOBAL_TABLE, |
986 | ndestid, | 989 | ndestid, |
987 | &route_port, 0); | 990 | &route_port, 0); |
@@ -1076,7 +1079,7 @@ static void rio_update_route_tables(struct rio_mport *port) | |||
1076 | 1079 | ||
1077 | list_for_each_entry(rdev, &rio_devices, global_list) { | 1080 | list_for_each_entry(rdev, &rio_devices, global_list) { |
1078 | 1081 | ||
1079 | destid = (rio_is_switch(rdev))?rdev->rswitch->destid:rdev->destid; | 1082 | destid = rdev->destid; |
1080 | 1083 | ||
1081 | list_for_each_entry(rswitch, &rio_switches, node) { | 1084 | list_for_each_entry(rswitch, &rio_switches, node) { |
1082 | 1085 | ||
@@ -1085,13 +1088,13 @@ static void rio_update_route_tables(struct rio_mport *port) | |||
1085 | 1088 | ||
1086 | if (RIO_INVALID_ROUTE == rswitch->route_table[destid]) { | 1089 | if (RIO_INVALID_ROUTE == rswitch->route_table[destid]) { |
1087 | /* Skip if destid ends in empty switch*/ | 1090 | /* Skip if destid ends in empty switch*/ |
1088 | if (rswitch->destid == destid) | 1091 | if (rswitch->rdev->destid == destid) |
1089 | continue; | 1092 | continue; |
1090 | 1093 | ||
1091 | sport = RIO_GET_PORT_NUM(rswitch->rdev->swpinfo); | 1094 | sport = RIO_GET_PORT_NUM(rswitch->rdev->swpinfo); |
1092 | 1095 | ||
1093 | if (rswitch->add_entry) { | 1096 | if (rswitch->add_entry) { |
1094 | rio_route_add_entry(port, rswitch, | 1097 | rio_route_add_entry(rswitch->rdev, |
1095 | RIO_GLOBAL_TABLE, destid, | 1098 | RIO_GLOBAL_TABLE, destid, |
1096 | sport, 0); | 1099 | sport, 0); |
1097 | rswitch->route_table[destid] = sport; | 1100 | rswitch->route_table[destid] = sport; |
@@ -1203,21 +1206,20 @@ static void rio_build_route_tables(void) | |||
1203 | 1206 | ||
1204 | list_for_each_entry(rdev, &rio_devices, global_list) | 1207 | list_for_each_entry(rdev, &rio_devices, global_list) |
1205 | if (rio_is_switch(rdev)) { | 1208 | if (rio_is_switch(rdev)) { |
1206 | rio_lock_device(rdev->net->hport, rdev->rswitch->destid, | 1209 | rio_lock_device(rdev->net->hport, rdev->destid, |
1207 | rdev->rswitch->hopcount, 1000); | 1210 | rdev->hopcount, 1000); |
1208 | for (i = 0; | 1211 | for (i = 0; |
1209 | i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); | 1212 | i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); |
1210 | i++) { | 1213 | i++) { |
1211 | if (rio_route_get_entry | 1214 | if (rio_route_get_entry(rdev, |
1212 | (rdev->net->hport, rdev->rswitch, | 1215 | RIO_GLOBAL_TABLE, i, &sport, 0) < 0) |
1213 | RIO_GLOBAL_TABLE, i, &sport, 0) < 0) | ||
1214 | continue; | 1216 | continue; |
1215 | rdev->rswitch->route_table[i] = sport; | 1217 | rdev->rswitch->route_table[i] = sport; |
1216 | } | 1218 | } |
1217 | 1219 | ||
1218 | rio_unlock_device(rdev->net->hport, | 1220 | rio_unlock_device(rdev->net->hport, |
1219 | rdev->rswitch->destid, | 1221 | rdev->destid, |
1220 | rdev->rswitch->hopcount); | 1222 | rdev->hopcount); |
1221 | } | 1223 | } |
1222 | } | 1224 | } |
1223 | 1225 | ||