Re: [PATCH 6/6] Change the kernel configurated RapidIO system size to auto-probing.
On Wed, Jan 30, 2008 at 06:30:53PM +0800, Zhang Wei wrote: > The RapidIO system size will auto probe in RIO setup. The route > table and rionet_active in rionet.c are changed to be allocated > dynamically according the system size. > + port->sys_size = (in_be32((priv->regs_win + RIO_PEF_CAR)) > + & RIO_PEF_CTLS) >> 4; > + dev_info(>dev, "RapidIO Common Transport System size: %d\n", > + port->sys_size ? 65536 : 256); > + This is much nicer than the original hardcoded transport size implementation. -Matt -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 6/6] Change the kernel configurated RapidIO system size to auto-probing.
On Wed, Jan 30, 2008 at 06:30:53PM +0800, Zhang Wei wrote: The RapidIO system size will auto probe in RIO setup. The route table and rionet_active in rionet.c are changed to be allocated dynamically according the system size. snip + port-sys_size = (in_be32((priv-regs_win + RIO_PEF_CAR)) + RIO_PEF_CTLS) 4; + dev_info(dev-dev, RapidIO Common Transport System size: %d\n, + port-sys_size ? 65536 : 256); + This is much nicer than the original hardcoded transport size implementation. -Matt -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 6/6] Change the kernel configurated RapidIO system size to auto-probing.
The RapidIO system size will auto probe in RIO setup. The route table and rionet_active in rionet.c are changed to be allocated dynamically according the system size. Signed-off-by: Zhang Wei <[EMAIL PROTECTED]> --- arch/powerpc/sysdev/fsl_rio.c |6 + drivers/net/rionet.c | 16 +++- drivers/rapidio/Kconfig |8 -- drivers/rapidio/rio-scan.c| 51 + drivers/rapidio/rio-sysfs.c |3 +- drivers/rapidio/rio.c |2 +- drivers/rapidio/rio.h |9 +- include/linux/rio.h | 14 +- 8 files changed, 68 insertions(+), 41 deletions(-) diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c index 36b43ec..4877203 100644 --- a/arch/powerpc/sysdev/fsl_rio.c +++ b/arch/powerpc/sysdev/fsl_rio.c @@ -1001,6 +1001,12 @@ int fsl_rio_setup(struct of_device *dev) rio_register_mport(port); priv->regs_win = (u32) ioremap(regs.start, regs.end - regs.start + 1); + + port->sys_size = (in_be32((priv->regs_win + RIO_PEF_CAR)) + & RIO_PEF_CTLS) >> 4; + dev_info(>dev, "RapidIO Common Transport System size: %d\n", + port->sys_size ? 65536 : 256); + priv->atmu_regs = (struct rio_atmu_regs *)(priv->regs_win + RIO_ATMU_REGS_OFFSET); priv->maint_atmu_regs = priv->atmu_regs + 1; diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c index e7fd08a..f2c103b 100644 --- a/drivers/net/rionet.c +++ b/drivers/net/rionet.c @@ -77,7 +77,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) &&\ @@ -195,7 +195,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->syssize); + i++) if (rionet_active[i]) rionet_queue_tx_msg(skb, ndev, rionet_active[i]); @@ -385,6 +386,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); @@ -443,6 +446,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..c32822a 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 diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index 4442072..ca895d1 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c @@ -73,7 +73,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 destid, u8 hopcount) rio_mport_read_config_32(port, destid, hopcount, RIO_DID_CSR, ); - return RIO_GET_DID(result); + return RIO_GET_DID(port->sys_size, result); } /** @@ -88,7 +88,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 destid, u8 hopcount) 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)); } /** @@ -100,7 +100,8 @@ static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount,
[PATCH 6/6] Change the kernel configurated RapidIO system size to auto-probing.
The RapidIO system size will auto probe in RIO setup. The route table and rionet_active in rionet.c are changed to be allocated dynamically according the system size. Signed-off-by: Zhang Wei [EMAIL PROTECTED] --- arch/powerpc/sysdev/fsl_rio.c |6 + drivers/net/rionet.c | 16 +++- drivers/rapidio/Kconfig |8 -- drivers/rapidio/rio-scan.c| 51 + drivers/rapidio/rio-sysfs.c |3 +- drivers/rapidio/rio.c |2 +- drivers/rapidio/rio.h |9 +- include/linux/rio.h | 14 +- 8 files changed, 68 insertions(+), 41 deletions(-) diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c index 36b43ec..4877203 100644 --- a/arch/powerpc/sysdev/fsl_rio.c +++ b/arch/powerpc/sysdev/fsl_rio.c @@ -1001,6 +1001,12 @@ int fsl_rio_setup(struct of_device *dev) rio_register_mport(port); priv-regs_win = (u32) ioremap(regs.start, regs.end - regs.start + 1); + + port-sys_size = (in_be32((priv-regs_win + RIO_PEF_CAR)) +RIO_PEF_CTLS) 4; + dev_info(dev-dev, RapidIO Common Transport System size: %d\n, + port-sys_size ? 65536 : 256); + priv-atmu_regs = (struct rio_atmu_regs *)(priv-regs_win + RIO_ATMU_REGS_OFFSET); priv-maint_atmu_regs = priv-atmu_regs + 1; diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c index e7fd08a..f2c103b 100644 --- a/drivers/net/rionet.c +++ b/drivers/net/rionet.c @@ -77,7 +77,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) \ @@ -195,7 +195,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-syssize); + i++) if (rionet_active[i]) rionet_queue_tx_msg(skb, ndev, rionet_active[i]); @@ -385,6 +386,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); @@ -443,6 +446,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..c32822a 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 diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index 4442072..ca895d1 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c @@ -73,7 +73,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 destid, u8 hopcount) 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); } /** @@ -88,7 +88,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 destid, u8 hopcount) 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)); } /** @@ -100,7 +100,8 @@ static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u */ static void