[PATCH 5/5 v2] Add the memory management driver to RapidIO.

2007-06-27 Thread Zhang Wei
This patch adds the memory management driver to RapidIO.
The RapidIO system size is changed to automatically detection.
Add the memory mapping driver to RapidIO basic driver.
Multi master ports are supported.
Add a simple Bitmap RapidIO space allocator driver.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 drivers/net/rionet.c|   17 +-
 drivers/rapidio/Kconfig |   18 +-
 drivers/rapidio/Makefile|1 +
 drivers/rapidio/rio-access.c|   10 +-
 drivers/rapidio/rio-scan.c  |   53 +++--
 drivers/rapidio/rio-sysfs.c |3 +-
 drivers/rapidio/rio.c   |  479 ++-
 drivers/rapidio/rio.h   |9 +-
 drivers/rapidio/sallocator/Kconfig  |9 +
 drivers/rapidio/sallocator/Makefile |   12 +
 drivers/rapidio/sallocator/bitmap.c |  384 
 include/linux/rio.h |   71 +-
 include/linux/rio_drv.h |   41 +++-
 13 files changed, 1048 insertions(+), 59 deletions(-)
 create mode 100644 drivers/rapidio/sallocator/Kconfig
 create mode 100644 drivers/rapidio/sallocator/Makefile
 create mode 100644 drivers/rapidio/sallocator/bitmap.c

diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index df6b738..8dcda4d 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -78,7 +78,7 @@ static int rionet_capable = 1;
  * 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) &&\
@@ -115,6 +115,7 @@ static int rionet_rx_clean(struct net_device *ndev)
 
rnet->rx_skb[i]->data = data;
skb_put(rnet->rx_skb[i], RIO_MAX_MSG_SIZE);
+   rnet->rx_skb[i]->dev = ndev;
rnet->rx_skb[i]->protocol =
eth_type_trans(rnet->rx_skb[i], ndev);
error = netif_rx(rnet->rx_skb[i]);
@@ -202,7 +203,8 @@ static int rionet_start_xmit(struct sk_buff *skb, struct 
net_device *ndev)
}
 
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]);
@@ -392,6 +394,8 @@ static void rionet_remove(struct rio_dev *rdev)
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);
 
@@ -449,6 +453,15 @@ static int rionet_setup_netdev(struct rio_mport *mport)
goto out;
}
 
+   if (!(rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
+   mport->sys_size ? __ilog2(sizeof(void *)) + 4
+   : 0))) {
+   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;
diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
index 4142115..f669108 100644
--- a/drivers/rapidio/Kconfig
+++ b/drivers/rapidio/Kconfig
@@ -1,14 +1,6 @@
 #
 # RapidIO configuration
 #
-config RAPIDIO_8_BIT_TRANSPORT
-   bool "8-bit transport addressing"
-   depends on RAPIDIO
-   ---help---
- By default, the kernel assumes a 16-bit addressed RapidIO
- network. By selecting this option, the kernel will support
- an 8-bit addressed network.
-
 config RAPIDIO_DISC_TIMEOUT
int "Discovery timeout duration (seconds)"
depends on RAPIDIO
@@ -16,3 +8,13 @@ config RAPIDIO_DISC_TIMEOUT
---help---
  Amount of time a discovery node waits for a host to complete
  enumeration before giving up.
+
+config RAPIDIO_PROC_FS
+   bool "I/O and Memory resource debug"
+   depends on RAPIDIO && PROC_FS
+   default y
+   ---help---
+ Enable this option, it will create a /proc/riores node for
+ monitoring the RapidIO I/O and Memory resource.
+
+source "drivers/rapidio/sallocator/Kconfig"
diff --git a/drivers/rapidio/Makefile b/drivers/rapidio/Makefile
index 7c0e181..e5b2f11 100644
--- a/drivers/rapidio/Makefile
+++ b/drivers/rapidio/Makefile
@@ -4,3 +4,4 @@
 obj-y += rio.o rio-access.o rio-driver.o rio-scan.o rio-sysfs.o
 
 obj-$(CONFIG_RAPIDIO)  += switches/

[PATCH 5/5 v2] Add the memory management driver to RapidIO.

2007-06-27 Thread Zhang Wei
This patch adds the memory management driver to RapidIO.
The RapidIO system size is changed to automatically detection.
Add the memory mapping driver to RapidIO basic driver.
Multi master ports are supported.
Add a simple Bitmap RapidIO space allocator driver.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 drivers/net/rionet.c|   17 +-
 drivers/rapidio/Kconfig |   18 +-
 drivers/rapidio/Makefile|1 +
 drivers/rapidio/rio-access.c|   10 +-
 drivers/rapidio/rio-scan.c  |   53 +++--
 drivers/rapidio/rio-sysfs.c |3 +-
 drivers/rapidio/rio.c   |  479 ++-
 drivers/rapidio/rio.h   |9 +-
 drivers/rapidio/sallocator/Kconfig  |9 +
 drivers/rapidio/sallocator/Makefile |   12 +
 drivers/rapidio/sallocator/bitmap.c |  384 
 include/linux/rio.h |   71 +-
 include/linux/rio_drv.h |   41 +++-
 13 files changed, 1048 insertions(+), 59 deletions(-)
 create mode 100644 drivers/rapidio/sallocator/Kconfig
 create mode 100644 drivers/rapidio/sallocator/Makefile
 create mode 100644 drivers/rapidio/sallocator/bitmap.c

diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index df6b738..8dcda4d 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -78,7 +78,7 @@ static int rionet_capable = 1;
  * 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) \
@@ -115,6 +115,7 @@ static int rionet_rx_clean(struct net_device *ndev)
 
rnet-rx_skb[i]-data = data;
skb_put(rnet-rx_skb[i], RIO_MAX_MSG_SIZE);
+   rnet-rx_skb[i]-dev = ndev;
rnet-rx_skb[i]-protocol =
eth_type_trans(rnet-rx_skb[i], ndev);
error = netif_rx(rnet-rx_skb[i]);
@@ -202,7 +203,8 @@ static int rionet_start_xmit(struct sk_buff *skb, struct 
net_device *ndev)
}
 
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]);
@@ -392,6 +394,8 @@ static void rionet_remove(struct rio_dev *rdev)
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);
 
@@ -449,6 +453,15 @@ static int rionet_setup_netdev(struct rio_mport *mport)
goto out;
}
 
+   if (!(rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
+   mport-sys_size ? __ilog2(sizeof(void *)) + 4
+   : 0))) {
+   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;
diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
index 4142115..f669108 100644
--- a/drivers/rapidio/Kconfig
+++ b/drivers/rapidio/Kconfig
@@ -1,14 +1,6 @@
 #
 # RapidIO configuration
 #
-config RAPIDIO_8_BIT_TRANSPORT
-   bool 8-bit transport addressing
-   depends on RAPIDIO
-   ---help---
- By default, the kernel assumes a 16-bit addressed RapidIO
- network. By selecting this option, the kernel will support
- an 8-bit addressed network.
-
 config RAPIDIO_DISC_TIMEOUT
int Discovery timeout duration (seconds)
depends on RAPIDIO
@@ -16,3 +8,13 @@ config RAPIDIO_DISC_TIMEOUT
---help---
  Amount of time a discovery node waits for a host to complete
  enumeration before giving up.
+
+config RAPIDIO_PROC_FS
+   bool I/O and Memory resource debug
+   depends on RAPIDIO  PROC_FS
+   default y
+   ---help---
+ Enable this option, it will create a /proc/riores node for
+ monitoring the RapidIO I/O and Memory resource.
+
+source drivers/rapidio/sallocator/Kconfig
diff --git a/drivers/rapidio/Makefile b/drivers/rapidio/Makefile
index 7c0e181..e5b2f11 100644
--- a/drivers/rapidio/Makefile
+++ b/drivers/rapidio/Makefile
@@ -4,3 +4,4 @@
 obj-y += rio.o rio-access.o rio-driver.o rio-scan.o rio-sysfs.o
 
 obj-$(CONFIG_RAPIDIO)  += switches/
+obj-$(CONFIG_RAPIDIO)  += sallocator/
diff --git