* could be made into a hash table to save memory depending
  * on system trade-offs.
  */
-static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES];
+static struct rio_dev **rionet_active;
 
 #define is_rionet_capable(pef, src_ops, dst_ops)               \
                        ((pef & RIO_PEF_INB_MBOX) &&            \
        }
 
        if (eth->h_dest[0] & 0x01) {
-               for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++)
+               for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size);
+                               i++)
                        if (rionet_active[i])
                                rionet_queue_tx_msg(skb, ndev,
                                                    rionet_active[i]);
        struct net_device *ndev = NULL;
        struct rionet_peer *peer, *tmp;
 
+       free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ?
+                                       __ilog2(sizeof(void *)) + 4 : 0);
        unregister_netdev(ndev);
        kfree(ndev);
 
                goto out;
        }
 
+       rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
+                       mport->sys_size ? __ilog2(sizeof(void *)) + 4 : 0);
+       if (!rionet_active) {
+               rc = -ENOMEM;
+               goto out;
+       }
+       memset((void *)rionet_active, 0, sizeof(void *) *
+                               RIO_MAX_ROUTE_ENTRIES(mport->sys_size));
+
        /* Set up private area */
        rnet = (struct rionet_private *)ndev->priv;
        rnet->mport = mport;
 
 
        rio_mport_read_config_32(port, destid, hopcount, RIO_DID_CSR, &result);
 
-       return RIO_GET_DID(result);
+       return RIO_GET_DID(port->sys_size, result);
 }
 
 /**
 static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u16 did)
 {
        rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR,
-                                 RIO_SET_DID(did));
+                                 RIO_SET_DID(port->sys_size, did));
 }
 
 /**
  */
 static void rio_local_set_device_id(struct rio_mport *port, u16 did)
 {
-       rio_local_write_config_32(port, RIO_DID_CSR, RIO_SET_DID(did));
+       rio_local_write_config_32(port, RIO_DID_CSR, RIO_SET_DID(port->sys_size,
+                               did));
 }
 
 /**
                rswitch->switchid = next_switchid;
                rswitch->hopcount = hopcount;
                rswitch->destid = destid;
+               rswitch->route_table = kzalloc(sizeof(u8)*
+                                       RIO_MAX_ROUTE_ENTRIES(port->sys_size),
+                                       GFP_KERNEL);
+               if (!rswitch->route_table) {
+                       kfree(rdev);
+                       rdev = NULL;
+                       kfree(rswitch);
+                       goto out;
+               }
                /* Initialize switch route table */
-               for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES; rdid++)
+               for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES(port->sys_size);
+                               rdid++)
                        rswitch->route_table[rdid] = RIO_INVALID_ROUTE;
                rdev->rswitch = rswitch;
                sprintf(rio_name(rdev), "%02x:s:%04x", rdev->net->id,
 {
        u32 result;
 
-       rio_mport_read_config_32(port, RIO_ANY_DESTID, hopcount,
+       rio_mport_read_config_32(port, RIO_ANY_DESTID(port->sys_size), hopcount,
                                 RIO_HOST_DID_LOCK_CSR, &result);
 
        return (u16) (result & 0xffff);
        }
 
        /* Attempt to acquire device lock */
-       rio_mport_write_config_32(port, RIO_ANY_DESTID, hopcount,
+       rio_mport_write_config_32(port, RIO_ANY_DESTID(port->sys_size),
+                                 hopcount,
                                  RIO_HOST_DID_LOCK_CSR, port->host_deviceid);
        while ((tmp = rio_get_host_deviceid_lock(port, hopcount))
               < port->host_deviceid) {
                /* Delay a bit */
                mdelay(1);
                /* Attempt to acquire device lock again */
-               rio_mport_write_config_32(port, RIO_ANY_DESTID, hopcount,
+               rio_mport_write_config_32(port, RIO_ANY_DESTID(port->sys_size),
+                                         hopcount,
                                          RIO_HOST_DID_LOCK_CSR,
                                          port->host_deviceid);
        }
        }
 
        /* Setup new RIO device */
-       if ((rdev = rio_setup_device(net, port, RIO_ANY_DESTID, hopcount, 1))) {
+       rdev = rio_setup_device(net, port, RIO_ANY_DESTID(port->sys_size),
+                                       hopcount, 1);
+       if (rdev) {
                /* Add device to the global and bus/net specific list. */
                list_add_tail(&rdev->net_list, &net->devices);
        } else
 
        if (rio_is_switch(rdev)) {
                next_switchid++;
-               sw_inport = rio_get_swpinfo_inport(port, RIO_ANY_DESTID, hopcount);
+               sw_inport = rio_get_swpinfo_inport(port,
+                               RIO_ANY_DESTID(port->sys_size), hopcount);
                rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE,
                                    port->host_deviceid, sw_inport);
                rdev->rswitch->route_table[port->host_deviceid] = sw_inport;
                }
 
                num_ports =
-                   rio_get_swpinfo_tports(port, RIO_ANY_DESTID, hopcount);
+                   rio_get_swpinfo_tports(port, RIO_ANY_DESTID(port->sys_size),
+                                               hopcount);
                pr_debug(
                    "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n",
                    rio_name(rdev), rdev->vid, rdev->did, num_ports);
                        cur_destid = next_destid;
 
                        if (rio_sport_is_active
-                           (port, RIO_ANY_DESTID, hopcount, port_num)) {
+                           (port, RIO_ANY_DESTID(port->sys_size), hopcount,
+                            port_num)) {
                                pr_debug(
                                    "RIO: scanning device on port %d\n",
                                    port_num);
                                rio_route_add_entry(port, rdev->rswitch,
-                                                   RIO_GLOBAL_TABLE,
-                                                   RIO_ANY_DESTID, port_num);
+                                               RIO_GLOBAL_TABLE,
+                                               RIO_ANY_DESTID(port->sys_size),
+                                               port_num);
 
                                if (rio_enum_peer(net, port, hopcount + 1) < 0)
                                        return -1;
                                pr_debug(
                                    "RIO: scanning device on port %d\n",
                                    port_num);
-                               for (ndestid = 0; ndestid < RIO_ANY_DESTID;
+                               for (ndestid = 0;
+                                    ndestid < RIO_ANY_DESTID(port->sys_size);
                                     ndestid++) {
                                        rio_route_get_entry(port, rdev->rswitch,
                                                            RIO_GLOBAL_TABLE,
 
        list_for_each_entry(rdev, &rio_devices, global_list)
            if (rio_is_switch(rdev))
-               for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) {
+               for (i = 0;
+                    i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size);
+                    i++) {
                        if (rio_route_get_entry
                            (rdev->net->hport, rdev->rswitch, RIO_GLOBAL_TABLE,
                             i, &sport) < 0)
                del_timer_sync(&rio_enum_timer);
 
                pr_debug("done\n");
-               if (rio_disc_peer(net, mport, RIO_ANY_DESTID, 0) < 0) {
+               if (rio_disc_peer(net, mport, RIO_ANY_DESTID(mport->sys_size),
+                                       0) < 0) {
                        printk(KERN_INFO
                               "RIO: master port %d device has failed discovery\n",
                               mport->id);
 
 #include <linux/device.h>
 #include <linux/rio_regs.h>
 
-#define RIO_ANY_DESTID         0xff
 #define RIO_NO_HOPCOUNT                -1
 #define RIO_INVALID_DESTID     0xffff
 
                                           entry is invalid (no route
                                           exists for the device ID) */
 
-#ifdef CONFIG_RAPIDIO_8_BIT_TRANSPORT
-#define RIO_MAX_ROUTE_ENTRIES  (1 << 8)
-#else
-#define RIO_MAX_ROUTE_ENTRIES  (1 << 16)
-#endif
+#define RIO_MAX_ROUTE_ENTRIES(size)    (size ? (1 << 16) : (1 << 8))
+#define RIO_ANY_DESTID(size)           (size ? 0xffff : 0xff)
 
 #define RIO_MAX_MBOX           4
 #define RIO_MAX_MSG_SIZE       0x1000
        unsigned char id;       /* port ID, unique among all ports */
        unsigned char index;    /* port index, unique among all port
                                   interfaces of the same type */
+       unsigned int sys_size;  /* RapidIO common transport system size.
+                                * 0 - Small size. 256 devices.
+                                * 1 - Large size, 65536 devices.
+                                */
        unsigned char name[40];
        void *priv;             /* Master port private data */
 };
        u16 switchid;
        u16 hopcount;
        u16 destid;
-       u8 route_table[RIO_MAX_ROUTE_ENTRIES];
+       u8 *route_table;
        int (*add_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
                          u16 table, u16 route_destid, u8 route_port);
        int (*get_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,