[PATCH 3/3] Add memory mapping support to rionet driver.
Signed-off-by: Zhang Wei <[EMAIL PROTECTED]> --- drivers/net/Kconfig | 10 ++ drivers/net/rionet.c | 337 +- 2 files changed, 345 insertions(+), 2 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index e8d69b0..b1129cc 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2637,6 +2637,16 @@ config RIONET_RX_SIZE depends on RIONET default "128" +config RIONET_MEMMAP + bool "Use memory map instead of message" + depends on RIONET + default n + +config RIONET_DMA + bool "Use DMA for memory mapping data transfer" + depends on RIONET_MEMMAP && FSL_DMA + default y + config FDDI bool "FDDI driver support" depends on (PCI || EISA || TC) diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c index e7fd08a..53b53a8 100644 --- a/drivers/net/rionet.c +++ b/drivers/net/rionet.c @@ -1,6 +1,13 @@ /* * rionet - Ethernet driver over RapidIO messaging services * + * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved. + * Author: Zhang Wei, [EMAIL PROTECTED], Jun 2007 + * + * Changelog: + * Jun 2007 Zhang Wei <[EMAIL PROTECTED]> + * - Added the support to RapidIO memory driver. 2007. + * * Copyright 2005 MontaVista Software, Inc. * Matt Porter <[EMAIL PROTECTED]> * @@ -8,6 +15,7 @@ * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. + * */ #include @@ -23,6 +31,7 @@ #include #include #include +#include #define DRV_NAME"rionet" #define DRV_VERSION "0.2" @@ -40,13 +49,47 @@ MODULE_LICENSE("GPL"); NETIF_MSG_TX_ERR) #define RIONET_DOORBELL_JOIN 0x1000 +#ifdef CONFIG_RIONET_MEMMAP +#define RIONET_DOORBELL_SEND 0x1001 +#define RIONET_DOORBELL_LEAVE 0x1002 +#else #define RIONET_DOORBELL_LEAVE 0x1001 +#endif #define RIONET_MAILBOX 0 #define RIONET_TX_RING_SIZECONFIG_RIONET_TX_SIZE #define RIONET_RX_RING_SIZECONFIG_RIONET_RX_SIZE +#define ERR(fmt, arg...) \ + printk(KERN_ERR "ERROR %s - %s: " fmt, __FILE__, __FUNCTION__, ## arg) + +#ifdef CONFIG_RIONET_MEMMAP +/* Definitions for rionet memory map driver */ +#define RIONET_DRVID 0x101 +#define RIONET_MAX_SK_DATA_SIZE0x1000 +#define RIONET_TX_RX_BUFF_SIZE (0x1000 * (128 + 128)) +#define RIONET_QUEUE_NEXT(x) (((x) < 127) ? ((x) + 1) : 0) +#define RIONET_QUEUE_INC(x)(x = RIONET_QUEUE_NEXT(x)) + +struct sk_data { + u8 data[0x1000]; +}; + +#define RIONET_SKDATA_EN 0x8000 +struct rionet_tx_rx_buff { + volatile intenqueue;/* enqueue point */ + volatile intdequeue;/* dequeue point */ + u32 size[128]; /* size[i] is skdata[i] size +* the most high bit [31] is +* enable bit. The +* max size is 4096. +*/ + u8 rev1[3576]; + struct sk_data skdata[128];/* all size are 0x1000 * 128 */ +}; +#endif /* CONFIG_RIONET_MEMMAP */ + static LIST_HEAD(rionet_peers); struct rionet_private { @@ -60,6 +103,18 @@ struct rionet_private { spinlock_t lock; spinlock_t tx_lock; u32 msg_enable; +#ifdef CONFIG_RIONET_MEMMAP + struct rionet_tx_rx_buff *rxbuff; + struct rionet_tx_rx_buff __iomem *txbuff; + struct rio_mem *rxmem; + struct rio_mem *txmem; +#ifdef CONFIG_RIONET_DMA + struct dma_chan *txdmachan; + struct dma_chan *rxdmachan; + struct dma_client rio_dma_client; + spinlock_t rio_dma_event_lock; +#endif +#endif }; struct rionet_peer { @@ -77,7 +132,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) &&\ @@ -108,9 +163,11 @@ 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]); + rnet->rx_skb[i] = NULL; if (error == NET_RX_DROP) { ndev->stats.rx_dropped++; @@ -141,19 +198,96 @@ static void rionet_rx_fill(struct net_device *ndev, int end) if (!rnet->rx_skb[i]) break; +#ifndef
[PATCH 3/3] Add memory mapping support to rionet driver.
Signed-off-by: Zhang Wei [EMAIL PROTECTED] --- drivers/net/Kconfig | 10 ++ drivers/net/rionet.c | 337 +- 2 files changed, 345 insertions(+), 2 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index e8d69b0..b1129cc 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2637,6 +2637,16 @@ config RIONET_RX_SIZE depends on RIONET default 128 +config RIONET_MEMMAP + bool Use memory map instead of message + depends on RIONET + default n + +config RIONET_DMA + bool Use DMA for memory mapping data transfer + depends on RIONET_MEMMAP FSL_DMA + default y + config FDDI bool FDDI driver support depends on (PCI || EISA || TC) diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c index e7fd08a..53b53a8 100644 --- a/drivers/net/rionet.c +++ b/drivers/net/rionet.c @@ -1,6 +1,13 @@ /* * rionet - Ethernet driver over RapidIO messaging services * + * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved. + * Author: Zhang Wei, [EMAIL PROTECTED], Jun 2007 + * + * Changelog: + * Jun 2007 Zhang Wei [EMAIL PROTECTED] + * - Added the support to RapidIO memory driver. 2007. + * * Copyright 2005 MontaVista Software, Inc. * Matt Porter [EMAIL PROTECTED] * @@ -8,6 +15,7 @@ * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. + * */ #include linux/module.h @@ -23,6 +31,7 @@ #include linux/skbuff.h #include linux/crc32.h #include linux/ethtool.h +#include linux/dmaengine.h #define DRV_NAMErionet #define DRV_VERSION 0.2 @@ -40,13 +49,47 @@ MODULE_LICENSE(GPL); NETIF_MSG_TX_ERR) #define RIONET_DOORBELL_JOIN 0x1000 +#ifdef CONFIG_RIONET_MEMMAP +#define RIONET_DOORBELL_SEND 0x1001 +#define RIONET_DOORBELL_LEAVE 0x1002 +#else #define RIONET_DOORBELL_LEAVE 0x1001 +#endif #define RIONET_MAILBOX 0 #define RIONET_TX_RING_SIZECONFIG_RIONET_TX_SIZE #define RIONET_RX_RING_SIZECONFIG_RIONET_RX_SIZE +#define ERR(fmt, arg...) \ + printk(KERN_ERR ERROR %s - %s: fmt, __FILE__, __FUNCTION__, ## arg) + +#ifdef CONFIG_RIONET_MEMMAP +/* Definitions for rionet memory map driver */ +#define RIONET_DRVID 0x101 +#define RIONET_MAX_SK_DATA_SIZE0x1000 +#define RIONET_TX_RX_BUFF_SIZE (0x1000 * (128 + 128)) +#define RIONET_QUEUE_NEXT(x) (((x) 127) ? ((x) + 1) : 0) +#define RIONET_QUEUE_INC(x)(x = RIONET_QUEUE_NEXT(x)) + +struct sk_data { + u8 data[0x1000]; +}; + +#define RIONET_SKDATA_EN 0x8000 +struct rionet_tx_rx_buff { + volatile intenqueue;/* enqueue point */ + volatile intdequeue;/* dequeue point */ + u32 size[128]; /* size[i] is skdata[i] size +* the most high bit [31] is +* enable bit. The +* max size is 4096. +*/ + u8 rev1[3576]; + struct sk_data skdata[128];/* all size are 0x1000 * 128 */ +}; +#endif /* CONFIG_RIONET_MEMMAP */ + static LIST_HEAD(rionet_peers); struct rionet_private { @@ -60,6 +103,18 @@ struct rionet_private { spinlock_t lock; spinlock_t tx_lock; u32 msg_enable; +#ifdef CONFIG_RIONET_MEMMAP + struct rionet_tx_rx_buff *rxbuff; + struct rionet_tx_rx_buff __iomem *txbuff; + struct rio_mem *rxmem; + struct rio_mem *txmem; +#ifdef CONFIG_RIONET_DMA + struct dma_chan *txdmachan; + struct dma_chan *rxdmachan; + struct dma_client rio_dma_client; + spinlock_t rio_dma_event_lock; +#endif +#endif }; struct rionet_peer { @@ -77,7 +132,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) \ @@ -108,9 +163,11 @@ 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]); + rnet-rx_skb[i] = NULL; if (error == NET_RX_DROP) { ndev-stats.rx_dropped++; @@ -141,19 +198,96 @@ static void rionet_rx_fill(struct net_device *ndev, int end) if (!rnet-rx_skb[i])