diff -r cc600dbe3266 -r 32eb33e02c92 drivers/net/comcerto/Makefile
--- a/drivers/net/comcerto/Makefile	Mon Aug 10 17:08:05 2009 -0500
+++ b/drivers/net/comcerto/Makefile	Mon Aug 17 16:44:03 2009 -0500
@@ -3,5 +3,5 @@
 	obj-$(CONFIG_ARCH_M821XX) += comcerto_gemac.o comcerto_gem_AL.o comcerto_mii.o comcerto_ethtool.o comcerto_sysfs.o
 endif
 #	obj-$(CONFIG_COMCERTO_FPP) += comcerto_fpp.o
-#	obj-$(CONFIG_COMCERTO_VED) += comcerto_ved.o comcerto_smi_part.o comcerto_smi_queue.o comcerto_msp.o
+	obj-$(CONFIG_COMCERTO_VED) += comcerto_ved.o comcerto_smi_part.o comcerto_smi_queue.o comcerto_msp.o
 #	obj-$(CONFIG_COMCERTO_MSP_COREDUMP) += comcerto_coredump.o
diff -r cc600dbe3266 -r 32eb33e02c92 drivers/net/comcerto/comcerto_ved.c
--- a/drivers/net/comcerto/comcerto_ved.c	Mon Aug 10 17:08:05 2009 -0500
+++ b/drivers/net/comcerto/comcerto_ved.c	Mon Aug 17 16:44:03 2009 -0500
@@ -42,102 +42,36 @@
 #include "comcerto_smi_queue.h"
 #include "comcerto_msp.h"
 
-char ctrl_mac[6] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE };
-
 #define IP_SEC_HEADROOM	40
 #define PKT_BUF_SZ (1540+IP_SEC_HEADROOM)	/* Size of each rx buffer */
-
-#define VED_STATE_RESET		0
-#define VED_STATE_DIRECT	1
-#define VED_STATE_MSP		2
-#define VED_STATE_CHANGING	3
-
 #define NAPI_WA 1
 
-int ved_state = VED_STATE_RESET;
-
 static int ved_xmit(struct sk_buff *skb, struct net_device *dev);
 static struct net_device_stats *ved_get_stats(struct net_device *dev);
-void ved_rx(struct net_device *dev, int len, char *buf);
-irqreturn_t ved_interrupt(int irq, void *dev_id);
-int device_open(struct net_device *dev);
-int device_release(struct net_device *dev);
-void ved_tx_timeout(struct net_device *dev);
-int ved_rebuild_header(struct sk_buff *skb);
-
-int ved_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned int len);
-
-int ved_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+static irqreturn_t ved_interrupt(int irq, void *dev_id);
+static int device_open(struct net_device *dev);
+static int device_release(struct net_device *dev);
+static int ved_rebuild_header(struct sk_buff *skb);
+static int ved_header(struct sk_buff *skb, struct net_device *dev,
+		      unsigned short type, const void *daddr,
+		      const void *saddr, unsigned int len);
 static int ved_write_packet(struct sk_buff *skb, struct net_device *dev);
 static int ved_read_packet(struct net_device *dev, struct FDesc * ThisFdesc);
-static int ved_poll(struct net_device *dev, int *budget);
+static int ved_poll(struct napi_struct *napi, int budget);
+static int start_ved(struct net_device *dev);
 
-static int __init ctrl_init(struct net_device *dev);
-
-void ved_set_eth_header(char *set_eth);
-
-
-static int start_ved(struct net_device *dev);
-static int stop_ved(void);
-
-struct net_device ctrl_dev[1] = {
-      {init:ctrl_init,}
-};
-
+static struct net_device *ctrl_dev;
 static struct platform_device *msp_coprocessor;
+static char ctrl_mac[6] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE };
 
 /* fake multicast ability */
 static void set_multicast_list(struct net_device *dev)
 {
-
-}
-
-static int __init ctrl_init(struct net_device *dev)
-{
-	struct ved_priv *priv;
-
-	/* Initialize the device structure. */
-	priv = kmalloc(sizeof(struct ved_priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	memset(priv, 0, sizeof(struct ved_priv));
-
-	spin_lock_init(&priv->lock);
-	// init private section
-	priv->default_packet_type = PROTID_ETH;
-	priv->state = 0; /* closed */
-
-	/* Fill in device structure with ethernet-generic values. */
-	ether_setup(dev);
-	
-	//dev->do_ioctl = ved_ioctl;
-	dev->priv = priv;
-	dev->open = device_open;
-	dev->stop = device_release;
-	dev->get_stats = ved_get_stats;
-	dev->hard_start_xmit = ved_xmit;
-	dev->rebuild_header = ved_rebuild_header;
-	dev->hard_header = ved_header;
-	dev->set_multicast_list = set_multicast_list;
-	dev->irq = IRQ_CTRL;
-	
-	dev->poll = ved_poll;
-	dev->weight = 32;
-
-	dev->flags &= ~IFF_MULTICAST;
-	dev->flags |= IFF_NOARP;
-
-	skb_queue_head_init(&priv->msp.MSP_list);
-
-	netif_stop_queue(dev);
-	printk(KERN_DEBUG "%s init\n", CTRL);
-	return 0;
 }
 
 static int ved_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct ved_priv *priv = (struct ved_priv *)dev->priv;
+	struct ved_priv *priv = netdev_priv(dev);
 	unsigned long flags;
 	int rc;
 
@@ -169,7 +103,6 @@
 		__raw_writel(__raw_readl(COMCERTO_INTC_CSP_IRQMASK_0) & ~(1UL << irq), COMCERTO_INTC_CSP_IRQMASK_0);
 	else
 		__raw_writel(__raw_readl(COMCERTO_INTC_CSP_IRQMASK_1) & ~(1UL << (irq - 32)), COMCERTO_INTC_CSP_IRQMASK_1);
-
 }
 
 static inline void ved_enable_int(unsigned int irq)
@@ -178,7 +111,6 @@
 		__raw_writel(__raw_readl(COMCERTO_INTC_CSP_IRQMASK_0) | (1UL << irq), COMCERTO_INTC_CSP_IRQMASK_0);
 	else
 		__raw_writel(__raw_readl(COMCERTO_INTC_CSP_IRQMASK_1) | (1UL << (irq - 32)), COMCERTO_INTC_CSP_IRQMASK_1);
-
 }
 
 static inline void ved_ack_int(unsigned int irq)
@@ -203,22 +135,20 @@
 		__raw_writel((1UL << irq), COMCERTO_INTC_SET_STATUS_REG_0);
 	else
 		__raw_writel((1UL << (irq - 32)), COMCERTO_INTC_SET_STATUS_REG_1);
-
 }
 
-irqreturn_t ved_interrupt(int irq, void *dev_id)
+static irqreturn_t ved_interrupt(int irq, void *dev_id)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
-	struct ved_priv *priv = dev->priv;
+	struct ved_priv *priv = netdev_priv(dev);
 
 	spin_lock(&priv->lock);
 
-	if (netif_rx_schedule_prep(dev)) {
-
+	if (napi_schedule_prep(&priv->napi)) {
 		ved_generate_int(irq);
 		PDEBUG(VED_RX_FUNC, "%s  ved_interruptRX : schedule poll\n", dev->name);
 		disable_irq(irq);
-		__netif_rx_schedule(dev);
+		__napi_schedule(&priv->napi);
 	} else {
 		PDEBUG(VED_RX_FUNC, "%s ved_interruptRX bug! interrupt while in poll\n", dev->name);
 		/* FIX by disabling interrupts  */
@@ -231,7 +161,7 @@
 	return IRQ_HANDLED;
 }
 
-int ved_rebuild_header(struct sk_buff *skb)
+static int ved_rebuild_header(struct sk_buff *skb)
 {
 	struct ethhdr *eth = (struct ethhdr *)skb->data;
 	struct net_device *dev = skb->dev;
@@ -243,7 +173,9 @@
 	return 0;
 }
 
-int ved_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned int len)
+static int ved_header(struct sk_buff *skb, struct net_device *dev,
+		      unsigned short type, const void *daddr,
+		      const void *saddr, unsigned int len)
 {
 	struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
 
@@ -256,26 +188,26 @@
 	return (dev->hard_header_len);
 }
 
-int device_open(struct net_device *dev)
+static int device_open(struct net_device *dev)
 {
-	struct ved_priv *priv = dev->priv;
+	struct ved_priv *priv = netdev_priv(dev);
 	const struct firmware *fw_entry;
 	int rc = 0;
 
-	/* Check if the interface is alredy open (MSP already download)*/
-	if(priv->state == 1)
+	/* Check if the interface is alredy open (MSP already download) */
+	if (priv->state == 1)
 		return rc;
 
 	comcerto_stop_msp(&priv->msp);
 
 	might_sleep();
 
-	if(request_firmware(&fw_entry,"msp.axf",&msp_coprocessor->dev) !=0 ) {
+	if(request_firmware(&fw_entry,"msp.axf",&msp_coprocessor->dev) != 0 ) {
 		printk(KERN_ERR "Error finding the Firmware\n");
 		rc = -ETIMEDOUT;
 		goto out;
 	}
-	
+
 	priv->msp.code_info.code = fw_entry->data;
 	priv->msp.code_info.size = fw_entry->size;
 	if (SDRAM_MSP_MEMORY_PHY) // MSP @ address 0x0
@@ -283,19 +215,19 @@
 	else
 		priv->msp.vectors_base = (void *)SDRAM_MSP_MEMORY_VADDR;
 
-	if(!priv->msp.vectors_base) {
+	if (!priv->msp.vectors_base) {
 		printk(KERN_ERR "Cannot map msp vectors, aborting.\n");
 		goto out;
 	}
 
 	comcerto_download_to_msp(&priv->msp);
-	
-	if(comcerto_start_msp(&priv->msp) < 0)
+
+	if (comcerto_start_msp(&priv->msp) < 0)
 		goto out;
-	
+
 	start_ved(dev);
 
-	rc = request_irq(dev->irq, ved_interrupt, SA_SHIRQ, "comcerto_ved", dev);
+	rc = request_irq(dev->irq, ved_interrupt, IRQF_SHARED, "comcerto_ved", dev);
 	if (rc) {
 		printk(KERN_ERR "Failed to get the IRQ = %d\n", dev->irq);
 		goto out;
@@ -303,24 +235,23 @@
 
 	netif_start_queue(dev);
 	priv->state = 1; /* open */
-	
-	
+
      out:
 	release_firmware(fw_entry);
 	return rc;
 }
 
-int device_release(struct net_device *dev)
+static int device_release(struct net_device *dev)
 {
-	struct ved_priv *priv = dev->priv;
+	struct ved_priv *priv = netdev_priv(dev);
 
-	PDEBUG(VED_STATE,"%s device_release state %d", CTRL, priv->state);
+	PDEBUG(VED_STATE, "%s device_release state %d", CTRL, priv->state);
 
 	/* do nothing if interface is already down */
 	if(priv->state == 1)
 	{
 		netif_stop_queue(dev);	/* can't transmit any more */
-		
+
 		/* disable irq */
 		free_irq(dev->irq, dev);
 
@@ -329,7 +260,6 @@
 		if (SDRAM_MSP_MEMORY_PHY) // MSP @ address 0x0
 			iounmap(priv->msp.vectors_base );
 
-		stop_ved();
 		priv->state = 0;
 	}
 
@@ -338,48 +268,71 @@
 
 static struct net_device_stats *ved_get_stats(struct net_device *dev)
 {
-	return &(((struct ved_priv *)dev->priv)->stats);
+	struct ved_priv *priv = netdev_priv(dev);
+	return &priv->stats;
 }
 
-int __init ved_init_module(void)
+static const struct header_ops ved_header_ops = {
+	.create = ved_header,
+	.rebuild = ved_rebuild_header,
+};
+
+static void ved_setup(struct net_device *dev)
 {
+	ether_setup(dev);
+	dev->header_ops = &ved_header_ops;
+	dev->flags &= ~IFF_MULTICAST;
+	dev->flags |= IFF_NOARP;
+	dev->open = device_open;
+	dev->stop = device_release;
+	dev->get_stats = ved_get_stats;
+	dev->hard_start_xmit = ved_xmit;
+	dev->set_multicast_list = set_multicast_list;
+	dev->irq = IRQ_CTRL;
+
+	/* assign the MAC address for second virtual device */
+	memcpy(dev->dev_addr, ctrl_mac, ETH_ALEN);
+}
+
+static int __init ved_init_module(void)
+{
+	struct ved_priv *priv;
 	int rc;
+
 //	PDEBUG(VED_INIT_FUNC,"ved_init_module");
 
-	/* Find a name for this unit */
-	rc = dev_alloc_name(&ctrl_dev[0], CTRL);
-	if (rc < 0) {
-		printk(KERN_ERR "ved_init_module: failed to alloc device name %s\n", CTRL);
-		goto err0;
+	ctrl_dev = alloc_netdev(sizeof(struct ved_priv), CTRL, ved_setup);
+	if (!ctrl_dev)
+		return -ENOMEM;
+
+	priv = netdev_priv(ctrl_dev);
+	spin_lock_init(&priv->lock);
+	priv->default_packet_type = PROTID_ETH;
+	priv->state = 0; /* closed */
+	netif_napi_add(ctrl_dev, &priv->napi, ved_poll, 64);
+	skb_queue_head_init(&priv->msp.MSP_list);
+
+	netif_stop_queue(ctrl_dev);
+	printk(KERN_DEBUG "%s init\n", CTRL);
+
+	rc = register_netdev(ctrl_dev);
+	if (rc) {
+		printk(KERN_ERR "ved_init_module: failed to register dev %s\n", CTRL);
+		return rc;
 	}
 
-	rc = register_netdev(&ctrl_dev[0]);
-	if (rc) {
-		printk(KERN_ERR "ved_init_module: failed to register dev %s\n", CTRL);
-		goto err1;
-	}
-
-	/* assign the MAC address for second virtual device */
-	memcpy_fromio(ctrl_dev[0].dev_addr, ctrl_mac, ETH_ALEN);
 	msp_coprocessor = platform_device_register_simple("MSP_Copro", -1, NULL, 0);
 
 	return 0;
-
-      err1:
-	kfree(ctrl_dev[0].priv);
-
-      err0:
-	return rc;
 }
 
 static void __exit ved_cleanup_module(void)
 {
-	unregister_netdev(&ctrl_dev[0]);
-	kfree(ctrl_dev[0].priv);
+	unregister_netdev(ctrl_dev);
 }
 
 /**
- *	ved_read_packet - read and process an REALPACKET (Ethernet) frame 
+ *	ved_read_packet - read and process an REALPACKET (Ethernet) frame
  *	@dev: device id
  *	@ThisFdesc: Frame descriptor to parse
  *
@@ -387,7 +340,7 @@
  */
 static int ved_read_packet(struct net_device *dev, struct FDesc *ThisFdesc)
 {
-	struct ved_priv *priv = (struct ved_priv *)dev->priv;
+	struct ved_priv *priv = netdev_priv(dev);
 	char *data_addr;
 	int length, offset, reason;
 	struct sk_buff *skb;
@@ -416,11 +369,11 @@
 			priv->stats.rx_dropped++;
 			PDEBUG(VED_RX_FUNC, "WARN: skb not delivered - reason %lx - proto %lx\n", (unsigned long)reason, (unsigned long)skb->protocol);
 		}
-		
+
 		priv->stats.rx_packets++;
 		priv->stats.rx_bytes += length;
 		dev->last_rx = jiffies;
-		
+
 	} else {
 		PDEBUG(VED_RX_FUNC, "%s ved_read_packet: low on mem - packet dropped\n", dev->name);
 		priv->stats.rx_dropped++;
@@ -431,13 +384,12 @@
 	return 1;
 }
 
-static int ved_poll(struct net_device *dev, int *budget)
+static int ved_poll(struct napi_struct *napi, int budget)
 {
-
-	struct ved_priv *priv = (struct ved_priv *)dev->priv;
-	struct FDesc * ThisFdesc = NULL;
+	struct ved_priv *priv = container_of(napi, struct ved_priv, napi);
+	struct net_device *dev = napi->dev;
+	struct FDesc *ThisFdesc = NULL;
 	int done;
-	int rx_work_limit = dev->quota;
 	int received = 0;
 
 	PDEBUG(VED_RX_FUNC, "%s : ved_poll: entry\n", dev->name);
@@ -447,11 +399,6 @@
 		ved_ack_int(dev->irq);
 
 		while (!SFL_queue_empty(priv->rx_smiq.fpq)) {
-
-			if (--rx_work_limit < 0) {
-				goto not_done;
-			}
-
 			ThisFdesc = SFL_dequeue(&priv->rx_smiq);
 
 			done = ved_read_packet(dev, ThisFdesc);
@@ -460,22 +407,17 @@
 			if (!done)
 				goto not_done;
 			else
-				received++;
+				budget--;
 			break;
-			
 		}
-
 	}
 	while (ved_get_int_status(dev->irq));
 
 //	PDEBUG(VED_RX_FUNC, "%s ved_poll : done %d packets \n", dev->name, received);
 
-	dev->quota -= received;
-	*budget -= received;
 	/* we are happy/done, no more packets on ring; put us back
 	   to where we can start processing interrupts again */
-	netif_rx_complete(dev);
-	//enable_irq(dev->irq);
+	napi_complete(napi);
 
 	/* The last op happens after poll completion. Which means the following:
 	 * 1. it can race with disabling irqs in irq handler (which are done to
@@ -490,18 +432,16 @@
 	 * processed irqs. The good news: no events are ever lost.
 	 */
 
-	/* Let's have a last chance to process any missing interrupts we may 
+	/* Let's have a last chance to process any missing interrupts we may
 	* we may have missed while the IRQs line was masqued. Before leaving
 	* poll mode, we check if data have been posted in the queue from MSP.
 	* If true, then the IRQ line is disabled again and a new loop of polling
-	* is scheduled. This double check work arround is well known in NAPI 
+	* is scheduled. This double check work arround is well known in NAPI
 	* based implementation (see documentations/NAPI_HOWTO.txt - appendix2)
 	*/
 #if NAPI_WA
-	if(!SFL_queue_empty(priv->rx_smiq.fpq) && netif_rx_reschedule(dev, received)) {
-		//disable_irq(dev->irq);
+	if(!SFL_queue_empty(priv->rx_smiq.fpq) && napi_reschedule(napi))
 		goto restart_poll;
-	}
 #endif
 	enable_irq(dev->irq);
 	return 0;		/* done */
@@ -510,18 +450,12 @@
 
 	PDEBUG(VED_RX_FUNC, "%s ved_poll : not done %d packets \n", dev->name, received);
 
-	if (!received) {
-		received = 1;
-	}
-	dev->quota -= received;
-	*budget -= received;
-
 	return 1;		/* not_done */
 }
 
 static int ved_write_packet(struct sk_buff *skb, struct net_device *dev)
 {
-	struct ved_priv *priv = (struct ved_priv *)dev->priv;
+	struct ved_priv *priv = netdev_priv(dev);
 	struct FDesc *ThisFdesc;
 	struct u8 *buf;
 	u32 offset;
@@ -529,7 +463,6 @@
 	PDEBUG(VED_TX_FUNC, "%s ved_write_packet : entry \n", dev->name);
 	PDEBUG(VED_TX_FUNC, "%s : ved_write_packet: packet protocol %x \n", dev->name, skb->protocol);
 
-	
 	ThisFdesc = SFL_alloc_part(priv->tx_smipart);
 	if (!ThisFdesc) {
 		dev_kfree_skb(skb);
@@ -538,7 +471,7 @@
 
 	offset = NET_IP_ALIGN;
 	buf = msp_to_virt(ThisFdesc->Payload) + offset;
-	
+
 	memcpy(buf, skb->data, skb->len);
 
 	ThisFdesc->Offset = offset;
@@ -562,23 +495,11 @@
 
 }
 
-static int stop_ved(void)
-{
-	struct net_device *dev;
-	struct ved_priv *priv;
-	unsigned long flags;
-
-	dev = &ctrl_dev[0];
-	priv = (struct ved_priv *)dev->priv;
-	
-	return 0;
-}
-
 static int start_ved(struct net_device *dev)
 {
-	struct ved_priv *priv= (struct ved_priv *)dev->priv;
+	struct ved_priv *priv= netdev_priv(dev);
 	struct msp_info *info= (struct msp_info *)priv->msp.info;
-	
+
 	if(info)
 	{
 		PDEBUG(VED_INIT_FUNC, "info \n\tDevice=%lx\n\tRevision=%lx\n\tspu_version=%s\n\tCSPtoMSPQueuePhyaddr=%lx\n\tMSPtoCSPQueuePhyaddr=%lx\n\tSMRXCSPhyaddr=%lx\n\tSMTXCSPhyaddr=%lx\n\t",(unsigned long) info->Device,(unsigned long) info->Revision, info->spu_version,(unsigned long) info->CSPtoMSPQueuePhyaddr,(unsigned long) info->MSPtoCSPQueuePhyaddr,(unsigned long) info->SMRXCSPhyaddr,(unsigned long) info->SMTXCSPhyaddr);
diff -r cc600dbe3266 -r 32eb33e02c92 drivers/net/comcerto/comcerto_ved.h
--- a/drivers/net/comcerto/comcerto_ved.h	Mon Aug 10 17:08:05 2009 -0500
+++ b/drivers/net/comcerto/comcerto_ved.h	Mon Aug 17 16:44:03 2009 -0500
@@ -63,6 +63,7 @@
 
 struct ved_priv {
 	struct net_device_stats stats;
+	struct napi_struct napi;
 
 	spinlock_t lock;
 
