[openib-general] [PATCH][iWARP] iWARP Provider Functions Added

Tom Tucker tom at ammasso.com
Wed Aug 17 07:02:08 PDT 2005


This patch replaces the previous netdev driver portion with a much
cleaner implementation and adds provider wrapper functions. At this
point the driver loads and registers itself with the core. 

>From this point forward it should start getting more interesting. You
can either check this out anew from the tree or apply the enclosed patch
to your existing iWARP branch.

Signed-off-by: Tom Tucker <tom at ammasso.com>

Index: amso1100/c2.c
===================================================================
--- amso1100/c2.c	(revision 0)
+++ amso1100/c2.c	(revision 0)
@@ -0,0 +1,1183 @@
+/*
+ * c2.c: A Linux PCI-X Gigabit Ethernet driver for AMSO1100 (Cepheus2) RNIC
+ * Copyright(c) 2005 Ammasso, Inc.
+ * 
+ * History: 
+ * 
+ */
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/delay.h>
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+#include <linux/if_vlan.h>
+#include <linux/crc32.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/tcp.h>
+#include <linux/init.h>
+#include <linux/dma-mapping.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/byteorder.h>
+
+#include <ib_smi.h>
+#include "c2.h"
+
+MODULE_AUTHOR("Ranjith Balachandran <ranjith at ammasso.com>");
+MODULE_DESCRIPTION("Ammasso AMSO1100 Gigabit Ethernet driver");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRV_VERSION);
+
+static const u32 default_msg = NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK 
+	| NETIF_MSG_IFUP | NETIF_MSG_IFDOWN;
+
+static int debug = -1;	/* defaults above */
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
+
+static int  c2_up(struct net_device *netdev);
+static int  c2_down(struct net_device *netdev);
+static int  c2_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
+static void c2_tx_interrupt(struct net_device *netdev);
+static void c2_rx_interrupt(struct net_device *netdev);
+static irqreturn_t c2_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static void c2_tx_timeout(struct net_device *netdev);
+static int  c2_change_mtu(struct net_device *netdev, int new_mtu);
+static void c2_reset(struct c2_port *c2_port);
+static struct net_device_stats* c2_get_stats(struct net_device *netdev);
+
+static struct pci_device_id c2_pci_table[] = {
+	{ 0x18b8, 0xb001, PCI_ANY_ID, PCI_ANY_ID },
+    { 0 }
+};
+
+MODULE_DEVICE_TABLE(pci, c2_pci_table);
+
+#if 0
+static struct ethtool_ops c2_ethtool_ops = {
+	.get_drvinfo  = c2_get_drvinfo,
+	.get_regs_len = c2_get_regs_len,
+	.get_link     = ethtool_op_get_link,
+	.get_settings = c2_get_settings,
+	.set_settings = c2_set_settings,
+	.get_rx_csum  = c2_get_rx_csum,
+	.set_rx_csum  = c2_set_rx_csum,
+	.get_tx_csum  = ethtool_op_get_tx_csum,
+	.set_tx_csum  = ethtool_op_set_tx_csum,
+	.get_sg       = ethtool_op_get_sg,
+	.set_sg       = ethtool_op_set_sg,
+	.get_tso      = ethtool_op_get_tso,
+	.set_tso      = ethtool_op_set_tso,
+	.get_regs     = c2_get_regs,
+};
+#endif
+
+#if 0
+static void c2_link_up(struct c2_port *c2_port)
+{
+	netif_carrier_on(c2_port->netdev);
+	
+	if (c2_port->tx_avail > MAX_SKB_FRAGS + 1)
+		netif_wake_queue(c2_port->netdev);
+	
+	printk(KERN_INFO PFX "%s: Link is up\n", c2_port->netdev->name);
+}
+
+static void c2_link_down(struct c2_port *c2_port)
+{
+	netif_carrier_off(c2_port->netdev);
+	netif_stop_queue(c2_port->netdev);
+	
+	printk(KERN_INFO PFX "%s: Link is down\n", c2_port->netdev->name);
+}
+#endif
+
+static void c2_set_rxbufsize(struct c2_port *c2_port)
+{
+	struct net_device *netdev = c2_port->netdev;
+	
+	assert(netdev != NULL);
+	
+	if (netdev->mtu > RX_BUF_SIZE)
+		c2_port->rx_buf_size = netdev->mtu + ETH_HLEN + sizeof(struct c2_rxp_hdr) + NET_IP_ALIGN;
+	else
+		c2_port->rx_buf_size = sizeof(struct c2_rxp_hdr) + RX_BUF_SIZE;
+}
+
+/*
+ * Allocate TX ring elements and chain them together.
+ * One-to-one association of adapter descriptors with ring elements.
+ */
+static int c2_tx_ring_alloc(struct c2_ring *tx_ring, void *vaddr, dma_addr_t base, 
+							void __iomem *mmio_txp_ring)
+{
+	struct c2_tx_desc  *tx_desc;
+	struct c2_txp_desc *txp_desc;
+	struct c2_element  *elem;
+	int i;
+	
+	tx_ring->start = kmalloc(sizeof(*elem)*tx_ring->count, GFP_KERNEL);
+	if (!tx_ring->start)
+		return -ENOMEM;
+	
+	for (i = 0, elem = tx_ring->start, tx_desc = vaddr, txp_desc = mmio_txp_ring;
+		 i < tx_ring->count; i++, elem++, tx_desc++, txp_desc++)
+	{
+	    tx_desc->len    = 0;
+	    tx_desc->status = 0;
+		
+		/* Set TXP_HTXD_UNINIT */
+		c2_write64((void *)txp_desc + C2_TXP_ADDR,  cpu_to_be64(0x1122334455667788ULL));
+		c2_write16((void *)txp_desc + C2_TXP_LEN,   cpu_to_be16(0));
+		c2_write16((void *)txp_desc + C2_TXP_FLAGS, cpu_to_be16(TXP_HTXD_UNINIT));
+		
+		elem->skb     = NULL;
+		elem->ht_desc = tx_desc;
+		elem->hw_desc = txp_desc;
+		
+		if (i == tx_ring->count - 1) {
+			elem->next = tx_ring->start;
+			tx_desc->next_offset = base;
+		} else {
+			elem->next = elem + 1;
+			tx_desc->next_offset = base + (i + 1) * sizeof(*tx_desc);
+		}
+	}
+	
+	tx_ring->to_use = tx_ring->to_clean = tx_ring->start;
+	
+	return 0;
+}
+
+/*
+ * Allocate RX ring elements and chain them together.
+ * One-to-one association of adapter descriptors with ring elements.
+ */
+static int c2_rx_ring_alloc(struct c2_ring *rx_ring, void *vaddr, dma_addr_t base, 
+							void __iomem *mmio_rxp_ring)
+{
+	struct c2_rx_desc  *rx_desc;
+	struct c2_rxp_desc *rxp_desc;
+	struct c2_element  *elem;
+	int i;
+	
+	rx_ring->start = kmalloc(sizeof(*elem) * rx_ring->count, GFP_KERNEL);
+	if (!rx_ring->start)
+		return -ENOMEM;
+	
+	for (i = 0, elem = rx_ring->start, rx_desc = vaddr, rxp_desc = mmio_rxp_ring;
+		 i < rx_ring->count; i++, elem++, rx_desc++, rxp_desc++)
+	{
+	    rx_desc->len    = 0;
+	    rx_desc->status = 0;
+		
+		/* Set RXP_HRXD_UNINIT */
+		c2_write16((void *)rxp_desc + C2_RXP_STATUS, cpu_to_be16(RXP_HRXD_OK));
+		c2_write16((void *)rxp_desc + C2_RXP_COUNT,  cpu_to_be16(0));
+		c2_write16((void *)rxp_desc + C2_RXP_LEN,    cpu_to_be16(0));
+		c2_write64((void *)rxp_desc + C2_RXP_ADDR,   cpu_to_be64(0x99aabbccddeeffULL));
+		c2_write16((void *)rxp_desc + C2_RXP_FLAGS,  cpu_to_be16(RXP_HRXD_UNINIT));
+		
+		elem->skb     = NULL;
+		elem->ht_desc = rx_desc;
+		elem->hw_desc = rxp_desc;
+		
+		if (i == rx_ring->count - 1) {
+			elem->next = rx_ring->start;
+			rx_desc->next_offset = base;
+		} else {
+			elem->next = elem + 1;
+			rx_desc->next_offset = base + (i + 1) * sizeof(*rx_desc);
+		}
+	}
+	
+	rx_ring->to_use = rx_ring->to_clean = rx_ring->start;
+	
+	return 0;
+}
+
+/* Setup buffer for receiving */
+static inline int c2_rx_alloc(struct c2_port *c2_port, struct c2_element *elem)
+{
+	struct c2_dev      *c2dev   = c2_port->c2dev;
+	struct c2_rx_desc *rx_desc = elem->ht_desc;
+	struct sk_buff      *skb;
+	dma_addr_t          mapaddr;
+	u32                 maplen;
+	struct c2_rxp_hdr *rxp_hdr;
+	
+	skb = dev_alloc_skb(c2_port->rx_buf_size);
+	if (unlikely(!skb)) {
+		printk(KERN_ERR PFX "%s: out of memory for receive\n",
+		       c2_port->netdev->name);
+		return -ENOMEM;
+	}
+	
+	/* Zero out the rxp hdr in the sk_buff */
+	memset(skb->data, 0, sizeof(*rxp_hdr));
+	
+	skb->dev = c2_port->netdev;
+	
+	maplen  = c2_port->rx_buf_size;
+	mapaddr = pci_map_single(c2dev->pcidev, skb->data, maplen, PCI_DMA_FROMDEVICE);
+	
+	/* Set the sk_buff RXP_header to RXP_HRXD_READY */
+	rxp_hdr = (struct c2_rxp_hdr *) skb->data;
+	rxp_hdr->flags = RXP_HRXD_READY;
+	
+	//c2_write16(elem->hw_desc + C2_RXP_COUNT,  cpu_to_be16(0));
+	c2_write16(elem->hw_desc + C2_RXP_STATUS, cpu_to_be16(0));
+	c2_write16(elem->hw_desc + C2_RXP_LEN,    cpu_to_be16((u16)maplen - sizeof(*rxp_hdr)));
+	c2_write64(elem->hw_desc + C2_RXP_ADDR,   cpu_to_be64(mapaddr));
+	c2_write16(elem->hw_desc + C2_RXP_FLAGS,  cpu_to_be16(RXP_HRXD_READY));
+	
+	elem->skb     = skb;
+	elem->mapaddr = mapaddr;
+	elem->maplen  = maplen;
+	rx_desc->len  = maplen;
+	
+	return 0;
+}
+
+/*
+ * Allocate buffers for the Rx ring
+ * For receive:  rx_ring.to_clean is next received frame
+ */
+static int c2_rx_fill(struct c2_port *c2_port)
+{
+	struct c2_ring    *rx_ring = &c2_port->rx_ring;
+	struct c2_element *elem;
+	int ret = 0;
+	
+	elem = rx_ring->start;
+	do {
+		if (c2_rx_alloc(c2_port, elem)) {
+			ret = 1;
+			break;
+		}
+	} while ((elem = elem->next) != rx_ring->start);
+	
+	rx_ring->to_clean = rx_ring->start;
+	return ret;
+}
+
+/* Free all buffers in RX ring, assumes receiver stopped */
+static void c2_rx_clean(struct c2_port *c2_port)
+{
+	struct c2_dev      *c2dev = c2_port->c2dev;
+	struct c2_ring    *rx_ring = &c2_port->rx_ring;
+	struct c2_element *elem;
+	struct c2_rx_desc *rx_desc;
+	
+	elem = rx_ring->start;
+	do {
+		rx_desc = elem->ht_desc;
+		rx_desc->len = 0;
+		
+		c2_write16(elem->hw_desc + C2_RXP_STATUS, cpu_to_be16(0));
+		c2_write16(elem->hw_desc + C2_RXP_COUNT,  cpu_to_be16(0));
+		c2_write16(elem->hw_desc + C2_RXP_LEN,    cpu_to_be16(0));
+		c2_write64(elem->hw_desc + C2_RXP_ADDR,   cpu_to_be64(0x99aabbccddeeffULL));
+		c2_write16(elem->hw_desc + C2_RXP_FLAGS,  cpu_to_be16(RXP_HRXD_UNINIT));
+		
+		if (elem->skb) {
+			pci_unmap_single(c2dev->pcidev, elem->mapaddr, elem->maplen, 
+							 PCI_DMA_FROMDEVICE);
+			dev_kfree_skb(elem->skb);
+			elem->skb = NULL;
+		}
+	} while ((elem = elem->next) != rx_ring->start);
+}
+
+static inline int c2_tx_free(struct c2_dev *c2dev, struct c2_element *elem)
+{
+	struct c2_tx_desc *tx_desc  = elem->ht_desc;
+	
+	tx_desc->len = 0;
+	
+	pci_unmap_single(c2dev->pcidev, elem->mapaddr, elem->maplen, PCI_DMA_TODEVICE);
+	
+	if (elem->skb) {
+		dev_kfree_skb_any(elem->skb);
+		elem->skb = NULL;
+	}
+	
+	return 0;
+}
+
+/* Free all buffers in TX ring, assumes transmitter stopped */
+static void c2_tx_clean(struct c2_port *c2_port)
+{
+	struct c2_ring     *tx_ring = &c2_port->tx_ring;
+	struct c2_element  *elem;
+	struct c2_txp_desc txp_htxd;
+	int                  retry;
+	unsigned long        flags;
+	
+	spin_lock_irqsave(&c2_port->tx_lock, flags);
+	
+	elem = tx_ring->start;
+	
+	do {
+		retry = 0;
+		do {
+			txp_htxd.flags = c2_read16(elem->hw_desc + C2_TXP_FLAGS);
+			
+			if (txp_htxd.flags == TXP_HTXD_READY) {
+				retry = 1;
+				c2_write16(elem->hw_desc + C2_TXP_LEN,   cpu_to_be16(0));
+				c2_write64(elem->hw_desc + C2_TXP_ADDR,  cpu_to_be64(0));
+				c2_write16(elem->hw_desc + C2_TXP_FLAGS, cpu_to_be16(TXP_HTXD_DONE));
+				c2_port->netstats.tx_dropped++;
+				break;
+			} else {
+				c2_write16(elem->hw_desc + C2_TXP_LEN,   cpu_to_be16(0));
+				c2_write64(elem->hw_desc + C2_TXP_ADDR,  cpu_to_be64(0x1122334455667788ULL));
+				c2_write16(elem->hw_desc + C2_TXP_FLAGS, cpu_to_be16(TXP_HTXD_UNINIT));
+			}
+			
+			c2_tx_free(c2_port->c2dev, elem);
+			
+		} while ((elem = elem->next) != tx_ring->start);
+	} while (retry);
+	
+	c2_port->tx_avail   = c2_port->tx_ring.count - 1;
+	c2_port->c2dev->cur_tx = tx_ring->to_use - tx_ring->start;
+	
+	if (c2_port->tx_avail > MAX_SKB_FRAGS + 1)
+		netif_wake_queue(c2_port->netdev);
+	
+	spin_unlock_irqrestore(&c2_port->tx_lock, flags);
+}
+
+/*
+ * Process transmit descriptors marked 'DONE' by the firmware,
+ * freeing up their unneeded sk_buffs.
+ */
+static void c2_tx_interrupt(struct net_device *netdev)
+{
+	struct c2_port     *c2_port = netdev_priv(netdev);
+	struct c2_dev       *c2dev   = c2_port->c2dev;
+	struct c2_ring     *tx_ring = &c2_port->tx_ring;
+	struct c2_element  *elem;
+	struct c2_txp_desc txp_htxd;
+	
+	spin_lock(&c2_port->tx_lock);
+	
+	for(elem = tx_ring->to_clean; elem != tx_ring->to_use; elem = elem->next)
+	{
+		txp_htxd.flags = be16_to_cpu(c2_read16(elem->hw_desc + C2_TXP_FLAGS));
+		
+		if (txp_htxd.flags != TXP_HTXD_DONE)
+			break;
+		
+		if (netif_msg_tx_done(c2_port)) {
+			/* PCI reads are expensive in fast path */
+			//txp_htxd.addr = be64_to_cpu(c2_read64(elem->hw_desc + C2_TXP_ADDR));
+			txp_htxd.len  = be16_to_cpu(c2_read16(elem->hw_desc + C2_TXP_LEN));
+			printk(KERN_INFO PFX 
+				   "%s: tx done slot %3Zu status 0x%x len %5u bytes\n",
+				   netdev->name, elem - tx_ring->start, 
+				   txp_htxd.flags, txp_htxd.len);
+		}
+		
+		c2_tx_free(c2dev, elem);
+		++(c2_port->tx_avail);
+	}
+	
+	tx_ring->to_clean = elem;
+	
+	if (netif_queue_stopped(netdev) && c2_port->tx_avail > MAX_SKB_FRAGS + 1)
+		netif_wake_queue(netdev);
+	
+	spin_unlock(&c2_port->tx_lock);
+}
+
+static void c2_rx_error(struct c2_port *c2_port, struct c2_element *elem)
+{
+	struct c2_rx_desc *rx_desc = elem->ht_desc;
+	struct c2_rxp_hdr *rxp_hdr = (struct c2_rxp_hdr *)elem->skb->data;
+	
+	if (rxp_hdr->status != RXP_HRXD_OK || 
+		rxp_hdr->len > (rx_desc->len - sizeof(*rxp_hdr))) {
+		printk(KERN_ERR PFX "BAD RXP_HRXD\n");
+		printk(KERN_ERR PFX "  rx_desc : %p\n", rx_desc);
+		printk(KERN_ERR PFX "    index : %Zu\n", elem - c2_port->rx_ring.start);
+		printk(KERN_ERR PFX "    len   : %u\n", rx_desc->len);
+		printk(KERN_ERR PFX "  rxp_hdr : %p [PA %p]\n", rxp_hdr, 
+			   (void *)__pa((unsigned long)rxp_hdr));
+		printk(KERN_ERR PFX "    flags : 0x%x\n", rxp_hdr->flags);
+		printk(KERN_ERR PFX "    status: 0x%x\n", rxp_hdr->status);
+		printk(KERN_ERR PFX "    len   : %u\n", rxp_hdr->len);
+		printk(KERN_ERR PFX "    rsvd  : 0x%x\n", rxp_hdr->rsvd);
+	}
+	
+	/* Setup the skb for reuse since we're dropping this pkt */
+	elem->skb->tail = elem->skb->data = elem->skb->head;
+	
+	/* Zero out the rxp hdr in the sk_buff */
+	memset(elem->skb->data, 0, sizeof(*rxp_hdr));
+	
+	/* Write the descriptor to the adapter's rx ring */
+	c2_write16(elem->hw_desc + C2_RXP_STATUS, cpu_to_be16(0));
+	c2_write16(elem->hw_desc + C2_RXP_COUNT,  cpu_to_be16(0));
+	c2_write16(elem->hw_desc + C2_RXP_LEN,    cpu_to_be16((u16)elem->maplen - sizeof(*rxp_hdr)));
+	c2_write64(elem->hw_desc + C2_RXP_ADDR,   cpu_to_be64(elem->mapaddr));
+	c2_write16(elem->hw_desc + C2_RXP_FLAGS,  cpu_to_be16(RXP_HRXD_READY));
+	
+	printk(KERN_INFO PFX "packet dropped\n");
+	c2_port->netstats.rx_dropped++;	
+}
+
+static void c2_rx_interrupt(struct net_device *netdev)
+{
+	struct c2_port     *c2_port = netdev_priv(netdev);
+	struct c2_dev       *c2dev   = c2_port->c2dev;
+	struct c2_ring     *rx_ring = &c2_port->rx_ring;
+	struct c2_element  *elem;
+	struct c2_rx_desc  *rx_desc;
+	struct c2_rxp_hdr  *rxp_hdr;
+	struct sk_buff       *skb;
+	dma_addr_t           mapaddr;
+	u32                  maplen, buflen;
+	unsigned long        flags;
+	
+    spin_lock_irqsave(&c2dev->lock, flags);
+	
+	/* Begin where we left off */
+	rx_ring->to_clean = rx_ring->start + c2dev->cur_rx;
+	
+	for(elem = rx_ring->to_clean; elem->next != rx_ring->to_clean; elem = elem->next)
+	{
+		rx_desc  = elem->ht_desc;
+		mapaddr  = elem->mapaddr;
+		maplen   = elem->maplen;
+		skb      = elem->skb;
+		rxp_hdr  = (struct c2_rxp_hdr *)skb->data;
+		
+		if (rxp_hdr->flags != RXP_HRXD_DONE)
+			break;
+		
+		if (netif_msg_rx_status(c2_port))
+			printk(KERN_INFO PFX "%s: rx done slot %3Zu status 0x%x len %5u bytes\n",
+				   netdev->name, elem - rx_ring->start, 
+				   rxp_hdr->flags, rxp_hdr->len);
+		
+		buflen = rxp_hdr->len;
+		
+		/* Sanity check the RXP header */
+		if (rxp_hdr->status != RXP_HRXD_OK || 
+			buflen > (rx_desc->len - sizeof(*rxp_hdr))) {
+			c2_rx_error(c2_port, elem);
+			continue;
+		}
+		
+		/* Allocate and map a new skb for replenishing the host RX desc */
+		if (c2_rx_alloc(c2_port, elem)) {
+			c2_rx_error(c2_port, elem);
+			continue;
+		}
+		
+		/* Unmap the old skb */
+		pci_unmap_single(c2dev->pcidev, mapaddr, maplen, PCI_DMA_FROMDEVICE);
+		
+		/*
+		 * Skip past the leading 8 bytes comprising of the 
+		 * "struct c2_rxp_hdr", prepended by the adapter 
+		 * to the usual Ethernet header ("struct ethhdr"), 
+		 * to the start of the raw Ethernet packet.
+		 * 
+		 * Fix up the various fields in the sk_buff before 
+		 * passing it up to netif_rx(). The transfer size 
+		 * (in bytes) specified by the adapter len field of 
+		 * the "struct rxp_hdr_t" does NOT include the 
+		 * "sizeof(struct c2_rxp_hdr)".
+		 */
+		skb->data    += sizeof(*rxp_hdr);
+		skb->tail     = skb->data + buflen;
+		skb->len      = buflen;
+		skb->dev      = netdev;
+		skb->protocol = eth_type_trans(skb, netdev);
+		
+		netif_rx(skb);
+		
+		netdev->last_rx = jiffies;
+		c2_port->netstats.rx_packets++;
+		c2_port->netstats.rx_bytes += buflen;
+	}
+	
+	/* Save where we left off */
+	rx_ring->to_clean = elem;
+	c2dev->cur_rx     = elem - rx_ring->start;
+	C2_SET_CUR_RX(c2dev, c2dev->cur_rx);
+	
+    spin_unlock_irqrestore(&c2dev->lock, flags);
+}
+
+/*
+ * Handle netisr0 TX & RX interrupts.
+ */
+static irqreturn_t c2_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	unsigned int   netisr0;
+	struct c2_dev *c2dev = dev_id;
+	
+	assert(c2dev != NULL);
+	
+	netisr0 = c2_read32(c2dev->regs + C2_NISR0);
+	
+	if (netisr0 & ~(C2_PCI_HRX_INT | C2_PCI_HRX_INT)) {
+		printk(KERN_ERR PFX "Unknown IRQ!\n");
+		return IRQ_NONE;
+	}
+	
+	/* Process RX 'DONE' descriptors */
+	if (netisr0 & C2_PCI_HRX_INT) {
+		c2_rx_interrupt(c2dev->netdev);
+		
+		/*
+		 * Also process TX 'DONE' descriptors here 
+		 * since the fw provides the status of RX for 
+		 * both TX & RX interrupts.
+		 */
+		c2_tx_interrupt(c2dev->netdev);
+		
+		c2_write32(c2dev->regs + C2_NISR0, C2_PCI_HRX_INT);
+	}
+	
+	/* Process TX 'DONE' descriptors */
+	if (netisr0 & C2_PCI_HTX_INT) {
+		c2_tx_interrupt(c2dev->netdev);
+		
+		c2_write32(c2dev->regs + C2_NISR0, C2_PCI_HTX_INT);
+	}
+	
+	return IRQ_HANDLED;
+}
+
+static int c2_up(struct net_device *netdev)
+{
+	struct c2_port    *c2_port = netdev_priv(netdev);
+	struct c2_dev      *c2dev   = c2_port->c2dev;
+	struct c2_element *elem;
+	struct c2_rxp_hdr *rxp_hdr;
+	size_t       rx_size, tx_size;
+	int          ret, i;
+	unsigned int netimr0;
+	
+    assert(c2dev != NULL);
+	
+	if (netif_msg_ifup(c2_port))
+		printk(KERN_INFO PFX "%s: enabling interface\n", netdev->name);
+	
+	/* Set the Rx buffer size based on MTU */
+	c2_set_rxbufsize(c2_port);
+	
+	/* Allocate DMA'able memory for Tx/Rx host descriptor rings */
+	rx_size = c2_port->rx_ring.count * sizeof(struct c2_rx_desc);
+	tx_size = c2_port->tx_ring.count * sizeof(struct c2_tx_desc);
+	
+	c2_port->mem_size = tx_size + rx_size;
+	c2_port->mem = pci_alloc_consistent(c2dev->pcidev, c2_port->mem_size, 
+										&c2_port->dma);
+	if (c2_port->mem == NULL) {
+		printk(KERN_ERR PFX "Unable to allocate memory for host descriptor rings\n");
+		return -ENOMEM;
+	}
+	
+	memset(c2_port->mem, 0, c2_port->mem_size);
+	
+	/* Create the Rx host descriptor ring */
+	if ((ret = c2_rx_ring_alloc(&c2_port->rx_ring, c2_port->mem, c2_port->dma, 
+								c2dev->mmio_rxp_ring))) {
+		printk(KERN_ERR PFX "Unable to create RX ring\n");
+		goto bail0;
+	}
+	
+	/* Allocate Rx buffers for the host descriptor ring */
+	if (c2_rx_fill(c2_port)) {
+		printk(KERN_ERR PFX "Unable to fill RX ring\n");
+		goto bail1;
+	}
+	
+	/* Create the Tx host descriptor ring */
+	if ((ret = c2_tx_ring_alloc(&c2_port->tx_ring, c2_port->mem + rx_size,
+								c2_port->dma + rx_size, c2dev->mmio_txp_ring))) {
+		printk(KERN_ERR PFX "Unable to create TX ring\n");
+		goto bail1;
+	}
+	
+	/* Set the TX pointer to where we left off */
+	c2_port->tx_avail = c2_port->tx_ring.count - 1;
+	c2_port->tx_ring.to_use = c2_port->tx_ring.to_clean = c2_port->tx_ring.start + c2dev->cur_tx;
+	
+	/* missing: Initialize MAC */
+	
+	BUG_ON(c2_port->tx_ring.to_use != c2_port->tx_ring.to_clean);
+	
+	/* Reset the adapter, ensures the driver is in sync with the RXP */
+	c2_reset(c2_port);
+	
+	/* Reset the READY bit in the sk_buff RXP headers & adapter HRXDQ */
+	for(i = 0, elem = c2_port->rx_ring.start; i < c2_port->rx_ring.count; 
+		i++, elem++)
+	{
+		rxp_hdr  = (struct c2_rxp_hdr *)elem->skb->data;
+		rxp_hdr->flags  = 0;
+		c2_write16(elem->hw_desc + C2_RXP_FLAGS, cpu_to_be16(RXP_HRXD_READY));
+	}
+	
+	/* Enable network packets */
+	netif_start_queue(netdev);
+	
+	/* Enable IRQ */
+	c2_write32(c2dev->regs + C2_IDIS, 0);
+	netimr0 = c2_read32(c2dev->regs + C2_NIMR0);
+	netimr0 &= ~(C2_PCI_HTX_INT | C2_PCI_HRX_INT);
+	c2_write32(c2dev->regs + C2_NIMR0, netimr0);
+	
+	return 0;
+	
+  bail1:
+	c2_rx_clean(c2_port);
+	kfree(c2_port->rx_ring.start);
+	
+  bail0:
+	pci_free_consistent(c2dev->pcidev, c2_port->mem_size, c2_port->mem, c2_port->dma);
+	
+	return ret;
+}
+
+static int c2_down(struct net_device *netdev)
+{
+    struct c2_port *c2_port = netdev_priv(netdev);
+    struct c2_dev   *c2dev = c2_port->c2dev;
+	
+	if (netif_msg_ifdown(c2_port))
+		printk(KERN_INFO PFX "%s: disabling interface\n", netdev->name);
+	
+	/* Wait for all the queued packets to get sent */
+	c2_tx_interrupt(netdev);
+	
+	/* Disable network packets */
+	netif_stop_queue(netdev);
+	
+	/* Disable IRQs by clearing the interrupt mask */
+	c2_write32(c2dev->regs + C2_IDIS, 1);
+	c2_write32(c2dev->regs + C2_NIMR0, 0);
+	
+	/* missing: Stop transmitter */
+	
+	/* missing: Stop receiver */
+	
+	/* Reset the adapter, ensures the driver is in sync with the RXP */
+	c2_reset(c2_port);
+	
+	/* missing: Turn off LEDs here */
+	
+	/* Free all buffers in the host descriptor rings */
+	c2_tx_clean(c2_port);
+	c2_rx_clean(c2_port);
+	
+	/* Free the host descriptor rings */
+	kfree(c2_port->rx_ring.start);
+	kfree(c2_port->tx_ring.start);
+	pci_free_consistent(c2dev->pcidev, c2_port->mem_size, c2_port->mem, c2_port->dma);
+	
+	return 0;
+}
+
+static void c2_reset(struct c2_port *c2_port)
+{
+	struct c2_dev *c2dev = c2_port->c2dev;
+	unsigned int cur_rx = c2dev->cur_rx;
+	
+	/* Tell the hardware to quiesce */
+	C2_SET_CUR_RX(c2dev, cur_rx|C2_PCI_HRX_QUI);
+	
+	/*
+	 * The hardware will reset the C2_PCI_HRX_QUI bit once
+	 * the RXP is quiesced.  Wait 2 seconds for this.
+	 */
+	ssleep(2);
+	
+	cur_rx = C2_GET_CUR_RX(c2dev);
+	
+	if (cur_rx & C2_PCI_HRX_QUI)
+		printk(KERN_ERR PFX "c2_reset: failed to quiesce the hardware!\n");
+	
+	cur_rx &= ~C2_PCI_HRX_QUI;
+	
+	c2dev->cur_rx = cur_rx;
+	
+	dprintk("Current RX: %u\n", c2dev->cur_rx);
+}
+
+static int c2_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
+{
+	struct c2_port    *c2_port = netdev_priv(netdev);
+	struct c2_dev      *c2dev   = c2_port->c2dev;
+	struct c2_ring    *tx_ring = &c2_port->tx_ring;
+	struct c2_element *elem;
+	dma_addr_t          mapaddr;
+	u32                 maplen;
+	unsigned long       flags;
+	unsigned int        i;
+	
+	spin_lock_irqsave(&c2_port->tx_lock, flags);
+	
+	if (unlikely(c2_port->tx_avail < (skb_shinfo(skb)->nr_frags + 1))) {
+		netif_stop_queue(netdev);
+		spin_unlock_irqrestore(&c2_port->tx_lock, flags);
+		
+		printk(KERN_WARNING PFX "%s: Tx ring full when queue awake!\n",
+		       netdev->name);
+		return NETDEV_TX_BUSY;
+	}
+	
+	maplen  = skb_headlen(skb);
+	mapaddr = pci_map_single(c2dev->pcidev, skb->data, maplen, PCI_DMA_TODEVICE);
+	
+	elem          = tx_ring->to_use;
+	elem->skb     = skb;
+	elem->mapaddr = mapaddr;
+	elem->maplen  = maplen;
+	
+	/* Tell HW to xmit */
+	c2_write64(elem->hw_desc + C2_TXP_ADDR,  cpu_to_be64(mapaddr));
+	c2_write16(elem->hw_desc + C2_TXP_LEN,   cpu_to_be16(maplen));
+	c2_write16(elem->hw_desc + C2_TXP_FLAGS, cpu_to_be16(TXP_HTXD_READY));
+	
+	c2_port->netstats.tx_packets++;
+	c2_port->netstats.tx_bytes += maplen;
+	
+	/* Loop thru additional data fragments and queue them */
+	if (skb_shinfo(skb)->nr_frags) {
+		for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
+		{
+			skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+			maplen  = frag->size;
+			mapaddr = pci_map_page(c2dev->pcidev, frag->page, frag->page_offset, 
+								   maplen, PCI_DMA_TODEVICE);
+			
+			elem          = elem->next;
+			elem->skb     = NULL;
+			elem->mapaddr = mapaddr;
+			elem->maplen  = maplen;
+			
+			/* Tell HW to xmit */
+			c2_write64(elem->hw_desc + C2_TXP_ADDR,  cpu_to_be64(mapaddr));
+			c2_write16(elem->hw_desc + C2_TXP_LEN,   cpu_to_be16(maplen));
+			c2_write16(elem->hw_desc + C2_TXP_FLAGS, cpu_to_be16(TXP_HTXD_READY));
+			
+			c2_port->netstats.tx_packets++;
+			c2_port->netstats.tx_bytes += maplen;
+		}
+	}
+	
+	tx_ring->to_use = elem->next;
+	c2_port->tx_avail -= (skb_shinfo(skb)->nr_frags + 1);
+	
+	if (netif_msg_tx_queued(c2_port))
+		printk(KERN_DEBUG PFX "%s: tx queued, slot %3Zu, len %5u bytes, avail = %u\n",
+			   netdev->name, elem - tx_ring->start, maplen, c2_port->tx_avail);
+	
+	if (c2_port->tx_avail <= MAX_SKB_FRAGS + 1) {
+		netif_stop_queue(netdev);
+		if (netif_msg_tx_queued(c2_port))
+			printk(KERN_INFO PFX "%s: transmit queue full\n", netdev->name);
+	}
+	
+	spin_unlock_irqrestore(&c2_port->tx_lock, flags);
+	
+	netdev->trans_start = jiffies;
+	
+	return NETDEV_TX_OK;
+}
+
+static struct net_device_stats *c2_get_stats(struct net_device *netdev)
+{
+	struct c2_port *c2_port = netdev_priv(netdev);
+	
+	return &c2_port->netstats;
+}
+
+static int c2_set_mac_address(struct net_device *netdev, void *p)
+{
+	return -1;
+}
+
+static void c2_tx_timeout(struct net_device *netdev)
+{
+	struct c2_port *c2_port = netdev_priv(netdev);
+	
+	if (netif_msg_timer(c2_port))
+		printk(KERN_DEBUG PFX "%s: tx timeout\n", netdev->name);
+	
+	c2_tx_clean(c2_port);
+}
+
+static int c2_change_mtu(struct net_device *netdev, int new_mtu)
+{
+	int ret = 0;
+	
+	if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
+		return -EINVAL;
+	
+	netdev->mtu = new_mtu;
+	
+	if (netif_running(netdev)) {
+		c2_down(netdev);
+		
+		c2_up(netdev);
+	}
+	
+	return ret;
+}
+
+/* Initialize network device */
+static struct net_device *c2_devinit(struct c2_dev *c2dev, void __iomem *mmio_addr)
+{
+	struct c2_port  *c2_port = NULL;
+	struct net_device *netdev = alloc_etherdev(sizeof(*c2_port));
+	
+	if (!netdev) {
+		printk(KERN_ERR PFX "c2_port etherdev alloc failed");
+		return NULL;
+	}
+	
+	SET_MODULE_OWNER(netdev);
+	SET_NETDEV_DEV(netdev, &c2dev->pcidev->dev);
+	
+	netdev->open            = c2_up;
+	netdev->stop            = c2_down;
+	netdev->hard_start_xmit = c2_xmit_frame;
+	netdev->get_stats       = c2_get_stats;
+#if 0
+	SET_ETHTOOL_OPS(netdev, &c2_ethtool_ops);
+#endif
+	netdev->tx_timeout      = c2_tx_timeout;
+	netdev->set_mac_address = c2_set_mac_address;
+	netdev->change_mtu      = c2_change_mtu;
+	netdev->watchdog_timeo  = C2_TX_TIMEOUT;
+	netdev->irq             = c2dev->pcidev->irq;
+	
+	c2_port                = netdev_priv(netdev);
+	c2_port->netdev        = netdev;
+	c2_port->c2dev            = c2dev;
+	c2_port->msg_enable    = netif_msg_init(debug, default_msg);
+	c2_port->tx_ring.count = C2_NUM_TX_DESC;
+	c2_port->rx_ring.count = C2_NUM_RX_DESC;
+	
+	spin_lock_init(&c2_port->tx_lock);
+	
+	/* Copy our 48-bit ethernet hardware address */
+	memcpy_fromio(netdev->dev_addr, mmio_addr + C2_REGS_ENADDR, 6);
+	
+	/* Validate the MAC address */
+	if(!is_valid_ether_addr(netdev->dev_addr)) {
+		printk(KERN_ERR PFX "Invalid MAC Address\n");
+		c2_print_macaddr(netdev);
+		free_netdev(netdev);
+		return NULL;
+	}
+	
+	c2dev->netdev = netdev;
+	
+	return netdev;
+}
+
+static int __devinit c2_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
+{
+	int               ret = 0, i;
+	unsigned long     reg0_start, reg0_flags, reg0_len;
+	unsigned long     reg2_start, reg2_flags, reg2_len;
+	unsigned long     reg4_start, reg4_flags, reg4_len;
+	struct net_device *netdev = NULL;
+	struct c2_dev    *c2dev = NULL;
+	void __iomem      *mmio_regs = NULL;
+	
+	assert(pcidev != NULL);
+	assert(ent != NULL);
+	
+	printk(KERN_INFO PFX "AMSO1100 Gigabit Ethernet driver v%s loaded\n", 
+		   DRV_VERSION);
+	
+	/* Enable PCI device */
+	ret = pci_enable_device(pcidev);
+	if (ret) {
+		printk(KERN_ERR PFX "%s: Unable to enable PCI device\n", pci_name(pcidev));
+		goto bail0;
+	}
+	
+	reg0_start = pci_resource_start(pcidev, BAR_0);
+	reg0_len   = pci_resource_len(pcidev, BAR_0);
+	reg0_flags = pci_resource_flags(pcidev, BAR_0);
+	
+	reg2_start = pci_resource_start(pcidev, BAR_2);
+	reg2_len   = pci_resource_len(pcidev, BAR_2);
+	reg2_flags = pci_resource_flags(pcidev, BAR_2);
+	
+	reg4_start = pci_resource_start(pcidev, BAR_4);
+	reg4_len   = pci_resource_len(pcidev, BAR_4);
+	reg4_flags = pci_resource_flags(pcidev, BAR_4);
+	
+	printk(KERN_INFO PFX "BAR0 size = 0x%lX bytes\n", reg0_len);
+	printk(KERN_INFO PFX "BAR2 size = 0x%lX bytes\n", reg2_len);
+	printk(KERN_INFO PFX "BAR4 size = 0x%lX bytes\n", reg4_len);
+	
+	/* Make sure PCI base addr are MMIO */
+	if (!(reg0_flags & IORESOURCE_MEM) || 
+		!(reg2_flags & IORESOURCE_MEM) || 
+		!(reg4_flags & IORESOURCE_MEM)) {
+		printk (KERN_ERR PFX "PCI regions not an MMIO resource\n");
+		ret = -ENODEV;
+		goto bail1;
+	}
+	
+	/* Check for weird/broken PCI region reporting */
+	if ((reg0_len < C2_REG0_SIZE) || 
+		(reg2_len < C2_REG2_SIZE) || 
+		(reg4_len < C2_REG4_SIZE)) {
+		printk (KERN_ERR PFX "Invalid PCI region sizes\n");
+		ret = -ENODEV;
+		goto bail1;
+	}
+	
+	/* Reserve PCI I/O and memory resources */
+	ret = pci_request_regions(pcidev, DRV_NAME);
+	if (ret) {
+		printk(KERN_ERR PFX "%s: Unable to request regions\n", pci_name(pcidev));
+		goto bail1;
+	}
+	
+	if ((sizeof(dma_addr_t) > 4)) {
+		ret = pci_set_dma_mask(pcidev, DMA_64BIT_MASK);
+		if (ret < 0) {
+			printk(KERN_ERR PFX "64b DMA configuration failed\n");
+			goto bail2;
+		}
+	} else {
+		ret = pci_set_dma_mask(pcidev, DMA_32BIT_MASK);
+		if (ret < 0) {
+			printk(KERN_ERR PFX "32b DMA configuration failed\n");
+			goto bail2;
+		}
+	}
+	
+	/* Enables bus-mastering on the device */
+	pci_set_master(pcidev);
+	
+	/* Remap the adapter PCI registers in BAR4 */
+	mmio_regs = ioremap_nocache(reg4_start + C2_PCI_REGS_OFFSET, 
+								sizeof(struct c2_adapter_pci_regs));
+	if (mmio_regs == 0UL) {
+		printk(KERN_ERR PFX "Unable to remap adapter PCI registers in BAR4\n");
+		ret = -EIO;
+		goto bail2;
+	}
+	
+	/* Validate PCI regs magic */
+	for (i = 0; i < sizeof(c2_magic); i++)
+	{
+		if (c2_magic[i] != c2_read8(mmio_regs + C2_REGS_MAGIC + i)) {
+			printk(KERN_ERR PFX 
+				   "Invalid PCI regs magic [%d/%Zd: got 0x%x, exp 0x%x]\n",
+				   i + 1, sizeof(c2_magic), 
+				   c2_read8(mmio_regs + C2_REGS_MAGIC + i), c2_magic[i]);
+			printk(KERN_ERR PFX "Adapter not claimed\n");
+			iounmap(mmio_regs);
+			ret = -EIO;
+			goto bail2;
+		}
+	}
+	
+	/* Validate the adapter version */
+	if (be32_to_cpu(c2_read32(mmio_regs + C2_REGS_VERS)) != C2_VERSION) {
+		printk(KERN_ERR PFX "Version mismatch [fw=%u, c2=%u], Adapter not claimed\n",
+			   be32_to_cpu(c2_read32(mmio_regs + C2_REGS_VERS)), C2_VERSION);
+		ret = -EINVAL;
+		iounmap(mmio_regs);
+		goto bail2;
+	}
+	
+	/* Validate the adapter IVN */
+	if (be32_to_cpu(c2_read32(mmio_regs + C2_REGS_IVN)) != C2_IVN) {
+		printk(KERN_ERR PFX "IVN mismatch [fw=0x%x, c2=0x%x], Adapter not claimed\n",
+			   be32_to_cpu(c2_read32(mmio_regs + C2_REGS_IVN)), C2_IVN);
+		ret = -EINVAL;
+		iounmap(mmio_regs);
+		goto bail2;
+	}
+	
+	/* Allocate hardware structure */
+	c2dev = kmalloc(sizeof(*c2dev), GFP_KERNEL);
+	if (!c2dev) {
+		printk(KERN_ERR PFX "%s: Unable to alloc hardware struct\n",
+			   pci_name(pcidev));
+		ret = -ENOMEM;
+		iounmap(mmio_regs);
+		goto bail2;
+	}
+	
+	memset(c2dev, 0, sizeof(*c2dev));
+	spin_lock_init(&c2dev->lock);
+	c2dev->pcidev = pcidev;
+	c2dev->cur_tx = 0;
+	
+	/* Get the last RX index */
+	c2dev->cur_rx = (be32_to_cpu(c2_read32(mmio_regs + C2_REGS_HRX_CUR)) - 0xffffc000) / sizeof(struct c2_rxp_desc);
+	
+	/* Request an interrupt line for the driver */
+	ret = request_irq(pcidev->irq, c2_interrupt, SA_SHIRQ, DRV_NAME, c2dev);
+	if (ret) {
+		printk(KERN_ERR PFX "%s: requested IRQ %u is busy\n",
+			   pci_name(pcidev), pcidev->irq);
+		iounmap(mmio_regs);
+		goto bail3;
+	}
+	
+	/* Set driver specific data */
+	pci_set_drvdata(pcidev, c2dev);
+	
+	/* Initialize network device */
+	if ((netdev = c2_devinit(c2dev, mmio_regs)) == NULL) {
+		iounmap(mmio_regs);
+		goto bail4;
+	}
+	
+	/* Unmap the adapter PCI registers in BAR4 */
+	iounmap(mmio_regs);
+	
+	/* Register network device */
+	ret = register_netdev(netdev);
+	if (ret) {
+		printk(KERN_ERR PFX "Unable to register netdev, ret = %d\n", ret);
+		goto bail5;
+	}
+	
+	/* Disable network packets */
+	netif_stop_queue(netdev);
+	
+	/* Remap the adapter HRXDQ PA space to kernel VA space */
+	c2dev->mmio_rxp_ring = ioremap_nocache(reg4_start + C2_RXP_HRXDQ_OFFSET, 
+										   C2_RXP_HRXDQ_SIZE);
+	if (c2dev->mmio_rxp_ring == 0UL) {
+		printk(KERN_ERR PFX "Unable to remap MMIO HRXDQ region\n");
+		ret = -EIO;
+		goto bail6;
+	}
+	
+	/* Remap the adapter HTXDQ PA space to kernel VA space */
+	c2dev->mmio_txp_ring = ioremap_nocache(reg4_start + C2_TXP_HTXDQ_OFFSET, 
+										   C2_TXP_HTXDQ_SIZE);
+	if (c2dev->mmio_txp_ring == 0UL) {
+		printk(KERN_ERR PFX "Unable to remap MMIO HTXDQ region\n");
+		ret = -EIO;
+		goto bail7;
+	}
+	
+	/* Save off the current RX index in the last 4 bytes of the TXP Ring */
+	C2_SET_CUR_RX(c2dev, c2dev->cur_rx);
+	
+	/* Remap the PCI registers in adapter BAR0 to kernel VA space */
+	c2dev->regs = ioremap_nocache(reg0_start, sizeof(struct c2_pci_regs));
+	if (c2dev->regs == 0UL) {
+		printk(KERN_ERR PFX "Unable to remap BAR0\n");
+		ret = -EIO;
+		goto bail8;
+	}
+	
+	/* Print out the MAC address */
+	c2_print_macaddr(netdev);
+	
+	return 0;
+	
+  bail8:
+	iounmap(c2dev->mmio_txp_ring);
+	
+  bail7:
+	iounmap(c2dev->mmio_rxp_ring);
+	
+  bail6:
+	unregister_netdev(netdev);
+	
+  bail5:
+	free_netdev(netdev);
+	
+  bail4:
+	free_irq(pcidev->irq, c2dev);
+	
+  bail3:
+	kfree(c2dev);
+	
+  bail2:
+	pci_release_regions(pcidev);
+	
+  bail1:
+	pci_disable_device(pcidev);
+	
+  bail0:
+	return ret;
+}
+
+static void __devexit c2_remove(struct pci_dev *pcidev)
+{
+	struct c2_dev    *c2dev  = pci_get_drvdata(pcidev);
+	struct net_device *netdev = c2dev->netdev;
+	
+	assert(netdev != NULL);
+	
+	/* Remove network device from the kernel */
+	unregister_netdev(netdev);
+	
+	/* Free network device */
+	free_netdev(netdev);
+	
+	/* Free the interrupt line */
+	free_irq(pcidev->irq, c2dev);
+	
+	/* missing: Turn LEDs off here */
+	
+	/* Unmap adapter PA space */
+	iounmap(c2dev->regs);
+	iounmap(c2dev->mmio_txp_ring);
+	iounmap(c2dev->mmio_rxp_ring);
+	
+	/* Free the hardware structure */
+	kfree(c2dev);
+	
+	/* Release reserved PCI I/O and memory resources */
+	pci_release_regions(pcidev);
+	
+	/* Disable PCI device */
+	pci_disable_device(pcidev);
+	
+	/* Clear driver specific data */
+	pci_set_drvdata(pcidev, NULL);
+}
+
+static struct pci_driver c2_pci_driver = {
+	.name     = DRV_NAME,
+	.id_table = c2_pci_table,
+	.probe    = c2_probe,
+	.remove   = __devexit_p(c2_remove),
+};
+
+static int __init c2_init_module(void)
+{
+	return pci_module_init(&c2_pci_driver);
+}
+
+static void __exit c2_exit_module(void)
+{
+	pci_unregister_driver(&c2_pci_driver);
+}
+
+module_init(c2_init_module);
+module_exit(c2_exit_module);
Index: amso1100/c2.h
===================================================================
--- amso1100/c2.h	(revision 0)
+++ amso1100/c2.h	(revision 0)
@@ -0,0 +1,326 @@
+/*
+ * c2.h: A Linux PCI-X Gigabit Ethernet driver for AMSO1100 (Cepheus2) RNIC
+ * 
+ * Copyright(c) 2005 Ammasso, Inc.
+ */
+
+#define DRV_NAME     "c2"
+#define DRV_VERSION  "1.1"
+#define PFX          DRV_NAME ": "
+
+#undef C2_DEBUG
+
+#ifdef C2_DEBUG
+#define assert(expr)                                                  \
+    if(!(expr)) {                                                     \
+        printk(KERN_ERR PFX "Assertion failed! %s, %s, %s, line %d\n",\
+               #expr, __FILE__, __FUNCTION__, __LINE__);              \
+    }
+#define dprintk(fmt, args...) do {printk(KERN_INFO PFX fmt, ##args);} while (0)
+#else
+#define assert(expr)          do {} while (0)
+#define dprintk(fmt, args...) do {} while (0)
+#endif /* C2_DEBUG */
+
+#define BAR_0                0
+#define BAR_2                2
+#define BAR_4                4
+
+#define RX_BUF_SIZE         (1536 + 8)
+#define ETH_JUMBO_MTU        9000
+#define C2_MAGIC            "CEPHEUS"
+#define C2_VERSION           4
+#define C2_IVN              (18 & 0x7fffffff)
+
+#define C2_REG0_SIZE        (16 * 1024)
+#define C2_REG2_SIZE        (2 * 1024 * 1024)
+#define C2_REG4_SIZE        (256 * 1024 * 1024)
+#define C2_NUM_TX_DESC       341
+#define C2_NUM_RX_DESC       256
+#define C2_PCI_REGS_OFFSET  (0x10000)
+#define C2_RXP_HRXDQ_OFFSET (((C2_REG4_SIZE)/2))
+#define C2_RXP_HRXDQ_SIZE   (4096)
+#define C2_TXP_HTXDQ_OFFSET (((C2_REG4_SIZE)/2) + C2_RXP_HRXDQ_SIZE)
+#define C2_TXP_HTXDQ_SIZE   (4096)
+#define C2_TX_TIMEOUT	    (6*HZ)
+
+/* CEPHEUS */
+static const u8 c2_magic[] = {
+	0x43, 0x45, 0x50, 0x48, 0x45, 0x55, 0x53
+ };
+
+enum adapter_pci_regs {
+	C2_REGS_MAGIC   = 0x0000,
+	C2_REGS_VERS    = 0x0008,
+	C2_REGS_IVN     = 0x000C,
+	C2_REGS_ENADDR  = 0x004C,
+	C2_REGS_HRX_CUR = 0x006C,
+};
+
+struct c2_adapter_pci_regs {
+    char reg_magic[8];
+    u32  version;
+    u32  ivn;
+    u32  pci_window_size;
+    u32  q0_q_size;
+    u32  q0_msg_size;
+    u32  q0_pool_start;
+    u32  q0_shared;
+    u32  q1_q_size;
+    u32  q1_msg_size;
+    u32  q1_pool_start;
+    u32  q1_shared;
+    u32  q2_q_size;
+    u32  q2_msg_size;
+    u32  q2_pool_start;
+    u32  q2_shared;
+    u32  log_start;
+    u32  log_size;
+    u8   host_enaddr[8];
+    u8   rdma_enaddr[8];
+    u32  crash_entry;
+    u32  crash_ready[2];
+    u32  fw_txd_cur;
+    u32  fw_hrxd_cur;
+    u32  fw_rxd_cur;
+};
+
+enum pci_regs {
+	C2_HISR	 = 0x0000,
+	C2_DISR	 = 0x0004,
+	C2_HIMR	 = 0x0008,
+	C2_DIMR	 = 0x000C,
+	C2_NISR0 = 0x0010,
+	C2_NISR1 = 0x0014,
+	C2_NIMR0 = 0x0018,
+	C2_NIMR1 = 0x001C,
+	C2_IDIS  = 0x0020,
+};
+
+enum {
+	C2_PCI_HRX_INT = 1<<8,
+	C2_PCI_HTX_INT = 1<<17,
+	C2_PCI_HRX_QUI = 1<<31,
+};
+
+/*
+ * Cepheus registers in BAR0.
+ */
+struct c2_pci_regs {
+    u32 hostisr;
+    u32 dmaisr;
+    u32 hostimr;
+    u32 dmaimr;
+    u32 netisr0;
+    u32 netisr1;
+    u32 netimr0;
+    u32 netimr1;
+    u32 int_disable;
+};
+
+/* TXP flags */
+enum c2_txp_flags {
+	TXP_HTXD_DONE   = 0,
+	TXP_HTXD_READY  = 1<<0,
+	TXP_HTXD_UNINIT = 1<<1,
+};
+
+/* RXP flags */
+enum c2_rxp_flags {
+	RXP_HRXD_UNINIT = 0,
+	RXP_HRXD_READY  = 1<<0,
+	RXP_HRXD_DONE   = 1<<1,
+};
+
+/* RXP status */
+enum c2_rxp_status {
+	RXP_HRXD_ZERO   = 0,
+	RXP_HRXD_OK     = 1<<0,
+	RXP_HRXD_BUF_OV = 1<<1,
+};
+
+/* TXP descriptor fields */
+enum txp_desc {
+	C2_TXP_FLAGS = 0x0000,
+	C2_TXP_LEN   = 0x0002,
+	C2_TXP_ADDR  = 0x0004,
+};
+
+/* RXP descriptor fields */
+enum rxp_desc {
+	C2_RXP_FLAGS  = 0x0000,
+	C2_RXP_STATUS = 0x0002,
+	C2_RXP_COUNT  = 0x0004,
+	C2_RXP_LEN    = 0x0006,
+	C2_RXP_ADDR   = 0x0008,
+};
+
+struct c2_txp_desc {
+    u16 flags;
+    u16 len;
+    u64 addr;
+} __attribute__ ((packed));
+
+struct c2_rxp_desc {
+    u16 flags;
+    u16 status;
+    u16 count;
+    u16 len;
+    u64 addr;
+} __attribute__ ((packed));
+
+struct c2_rxp_hdr {
+    u16 flags;
+    u16 status;
+    u16 len;
+    u16 rsvd;
+} __attribute__ ((packed));
+
+struct c2_tx_desc {
+	u32        len;
+	u32        status;
+	dma_addr_t next_offset;
+};
+
+struct c2_rx_desc {
+	u32        len;
+	u32        status;
+	dma_addr_t next_offset;
+};
+
+struct c2_element {
+	struct c2_element *next;
+	void                *ht_desc; /* host     descriptor */
+	void                *hw_desc; /* hardware descriptor */
+	struct sk_buff      *skb;
+	dma_addr_t          mapaddr;
+	u32                 maplen;
+};
+
+struct c2_ring {
+	struct c2_element *to_clean;
+	struct c2_element *to_use;
+	struct c2_element *start;
+	unsigned long       count;
+};
+
+struct ib_device;
+struct c2_dev {
+	struct ib_device  ibdev;
+	void __iomem      *regs;
+	void __iomem      *mmio_txp_ring; /* remapped adapter memory for hw rings */
+	void __iomem      *mmio_rxp_ring;
+	spinlock_t        lock;
+	struct pci_dev    *pcidev;
+	struct net_device *netdev;
+	unsigned int      cur_tx;
+	unsigned int      cur_rx;
+};
+
+struct c2_port {
+	u32               msg_enable;
+	struct c2_dev    *c2dev;
+	struct net_device *netdev;
+	
+	spinlock_t        tx_lock;
+	u32               tx_avail;
+	struct c2_ring  tx_ring;
+	struct c2_ring  rx_ring;
+	
+	void              *mem; /* PCI memory for host rings */
+	dma_addr_t        dma;
+	unsigned long     mem_size;
+	
+	u32               rx_buf_size;
+	
+	struct net_device_stats netstats;
+};
+
+#ifndef readq
+static inline u64 readq(const void __iomem *addr)
+{
+	u64 ret = readl(addr + 4);
+	ret <<= 32;
+	ret |= readl(addr);
+	
+	return ret;
+}
+#endif
+
+#ifndef writeq
+static inline void writeq(u64 val, void __iomem *addr)
+{
+	writel((u32) (val), addr);
+	writel((u32) (val >> 32), (addr + 4));
+}
+#endif
+
+/* Read from memory-mapped device */
+static inline u64 c2_read64(const void __iomem *addr)
+{
+	return readq(addr);
+}
+
+static inline u32 c2_read32(const void __iomem *addr)
+{
+	return readl(addr);
+}
+
+static inline u16 c2_read16(const void __iomem *addr)
+{
+	return readw(addr);
+}
+
+static inline u8 c2_read8(const void __iomem *addr)
+{
+	return readb(addr);
+}
+
+/* Write to memory-mapped device */
+static inline void c2_write64(void __iomem *addr, u64 val)
+{
+	writeq(val, addr);
+}
+
+static inline void c2_write32(void __iomem *addr, u32 val)
+{
+	writel(val, addr);
+}
+
+static inline void c2_write16(void __iomem *addr, u16 val)
+{
+	writew(val, addr);
+}
+
+static inline void c2_write8(void __iomem *addr, u8 val)
+{
+	writeb(val, addr);
+}
+
+#define C2_SET_CUR_RX(c2dev, cur_rx) \
+	c2_write32(c2dev->mmio_txp_ring + 4092, cpu_to_be32(cur_rx))
+
+#define C2_GET_CUR_RX(c2dev) \
+	be32_to_cpu(c2_read32(c2dev->mmio_txp_ring + 4092))
+
+#if 0
+static void c2_print_ethhdr(struct ethhdr *ehdr)
+{
+	printk(KERN_DEBUG PFX "ehdr[h_src(%02x:%02x:%02x:%02x:%02x:%02x) -> "
+		   "h_dst(%02x:%02x:%02x:%02x:%02x:%02x) h_proto(%04x)]\n",
+	       ehdr->h_source[0], ehdr->h_source[1], ehdr->h_source[2],
+	       ehdr->h_source[3], ehdr->h_source[4], ehdr->h_source[5],
+	       ehdr->h_dest[0], ehdr->h_dest[1], ehdr->h_dest[2], 
+	       ehdr->h_dest[3], ehdr->h_dest[4], ehdr->h_dest[5], 
+	       htons(ehdr->h_proto));
+}
+#endif
+
+static void c2_print_macaddr(struct net_device *netdev)
+{
+	printk(KERN_INFO PFX "%s: MAC %02X:%02X:%02X:%02X:%02X:%02X, "
+		   "IRQ %u\n", netdev->name, 
+		   netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2],
+		   netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5],
+		   netdev->irq);
+}
Index: amso1100/Makefile
===================================================================
--- amso1100/Makefile	(revision 3074)
+++ amso1100/Makefile	(working copy)
@@ -4,27 +4,30 @@
 EXTRA_CFLAGS += -DDEBUG
 endif
 
-obj-$(CONFIG_INFINIBAND_AMSO1100) += ib_amso1100.o
+obj-$(CONFIG_INFINIBAND_AMSO1100) += ib_c2.o
 
-ib_amso1100-y := cc_cq_common.o \
-		ccilnet.o \
-		ccilnet_dbg.o \
-		cc_mq_common.o \
-		cc_qp_common.o \
-		devccil_adapter.o \
-		devccil_ae.o \
-		devccil.o \
-		devccil_cq.o \
-		devccil_eh.o \
-		devccil_ep.o \
-		devccil_logging.o \
-		devccil_mem.o \
-		devccil_mm.o \
-		devccil_mq.o \
-		devccil_pd.o \
-		devccil_qp.o \
-		devccil_rnic.o \
-		devccil_srq.o \
-		devccil_vq.o \
-		devccil_wrappers.o \
-		devnet.o 
+ib_c2-y := c2_provider.o \
+	 c2.o
+
+#		cc_cq_common.o \
+#		ccilnet.o \
+#		ccilnet_dbg.o \
+#		cc_mq_common.o \
+#		cc_qp_common.o \
+#		devccil_adapter.o \
+#		devccil_ae.o \
+#		devccil.o \
+#		devccil_cq.o \
+#		devccil_eh.o \
+#		devccil_ep.o \
+#		devccil_logging.o \
+#		devccil_mem.o \
+#		devccil_mm.o \
+#		devccil_mq.o \
+#		devccil_pd.o \
+#		devccil_qp.o \
+#		devccil_rnic.o \
+#		devccil_srq.o \
+#		devccil_vq.o \
+#		devccil_wrappers.o \
+#		devnet.o 
Index: amso1100/c2_provider.c
===================================================================
--- amso1100/c2_provider.c	(revision 0)
+++ amso1100/c2_provider.c	(revision 0)
@@ -0,0 +1,330 @@
+/*
+ * Copyright (c) 2005 Ammasso, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/delay.h>
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+#include <linux/if_vlan.h>
+#include <linux/crc32.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/tcp.h>
+#include <linux/init.h>
+#include <linux/dma-mapping.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/byteorder.h>
+
+#include <ib_smi.h>
+
+#include "c2.h"
+#include "c2_provider.h"
+
+static int c2_query_device(struct ib_device *ibdev,
+			      struct ib_device_attr *props)
+{
+	int err = -ENOMEM;
+	return err;
+}
+
+static int c2_query_port(struct ib_device *ibdev,
+			    u8 port, struct ib_port_attr *props)
+{
+	return ENOSYS;
+}
+
+static int c2_modify_port(struct ib_device *ibdev,
+			     u8 port, int port_modify_mask,
+			     struct ib_port_modify *props)
+{
+	return ENOSYS;
+}
+
+static int c2_query_pkey(struct ib_device *ibdev,
+			    u8 port, u16 index, u16 *pkey)
+{
+	return ENOSYS;
+}
+
+static int c2_query_gid(struct ib_device *ibdev, u8 port,
+			   int index, union ib_gid *gid)
+{
+	return ENOSYS;
+}
+
+static struct ib_ucontext *c2_alloc_ucontext(struct ib_device *ibdev,
+						struct ib_udata *udata)
+{
+	return 0;
+}
+
+static int c2_dealloc_ucontext(struct ib_ucontext *context)
+{
+	return 0;
+}
+
+static int c2_mmap_uar(struct ib_ucontext *context,
+			  struct vm_area_struct *vma)
+{
+	return 0;
+}
+
+static struct ib_pd *c2_alloc_pd(struct ib_device *ibdev,
+				    struct ib_ucontext *context,
+				    struct ib_udata *udata)
+{
+	return 0;
+}
+
+static int c2_dealloc_pd(struct ib_pd *pd)
+{
+	return 0;
+}
+
+static struct ib_ah *c2_ah_create(struct ib_pd *pd,
+				     struct ib_ah_attr *ah_attr)
+{
+	return 0;
+}
+
+static int c2_ah_destroy(struct ib_ah *ah)
+{
+	return 0;
+}
+
+static struct ib_qp *c2_create_qp(struct ib_pd *pd,
+				     struct ib_qp_init_attr *init_attr,
+				     struct ib_udata *udata)
+{
+	return 0;
+}
+
+static int c2_destroy_qp(struct ib_qp *qp)
+{
+	return 0;
+}
+
+static struct ib_cq *c2_create_cq(struct ib_device *ibdev, int entries,
+				     struct ib_ucontext *context,
+				     struct ib_udata *udata)
+{
+	return ERR_PTR(0);
+}
+
+static int c2_destroy_cq(struct ib_cq *cq)
+{
+	return 0;
+}
+
+static struct ib_mr *c2_get_dma_mr(struct ib_pd *pd, int acc)
+{
+	return 0;
+}
+
+static struct ib_mr *c2_reg_phys_mr(struct ib_pd       *pd,
+				       struct ib_phys_buf *buffer_list,
+				       int                 num_phys_buf,
+				       int                 acc,
+				       u64                *iova_start)
+{
+	return 0;
+}
+
+static struct ib_mr *c2_reg_user_mr(struct ib_pd *pd, struct ib_umem *region,
+				       int acc, struct ib_udata *udata)
+{
+	return ERR_PTR(0);
+}
+
+static int c2_dereg_mr(struct ib_mr *mr)
+{
+	return 0;
+}
+
+static ssize_t show_rev(struct class_device *cdev, char *buf)
+{
+	struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev);
+	return sprintf(buf, "%x\n", 1);
+}
+
+static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+{
+	struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev);
+	return sprintf(buf, "%x.%x.%x\n", 1,2,3);
+}
+
+static ssize_t show_hca(struct class_device *cdev, char *buf)
+{
+	return sprintf(buf, "AMSO1100\n");
+}
+
+static ssize_t show_board(struct class_device *cdev, char *buf)
+{
+	struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev);
+	return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID");
+}
+
+static CLASS_DEVICE_ATTR(hw_rev,   S_IRUGO, show_rev,    NULL);
+static CLASS_DEVICE_ATTR(fw_ver,   S_IRUGO, show_fw_ver, NULL);
+static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca,    NULL);
+static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board,  NULL);
+
+static struct class_device_attribute *c2_class_attributes[] = {
+	&class_device_attr_hw_rev,
+	&class_device_attr_fw_ver,
+	&class_device_attr_hca_type,
+	&class_device_attr_board_id
+};
+
+int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
+{
+	return ENOSYS;
+}
+
+int c2_poll_cq(struct ib_cq *ibcq, int num_entries,
+                  struct ib_wc *entry)
+{
+	return 0;
+}
+int c2_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
+{
+	return ENOSYS;
+}
+
+int c2_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
+{
+	return ENOSYS;
+}
+
+int c2_process_mad(struct ib_device *ibdev,
+                      int mad_flags,
+                      u8 port_num,
+                      struct ib_wc *in_wc,
+                      struct ib_grh *in_grh,
+                      struct ib_mad *in_mad,
+                      struct ib_mad *out_mad)
+{
+	return ENOSYS;
+}
+
+int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify notify)
+{
+	return 0;
+}
+
+int c2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
+                          struct ib_send_wr **bad_wr)
+{
+	return 0;
+}
+
+int c2_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
+                             struct ib_recv_wr **bad_wr)
+{
+	return 0;
+}
+
+
+int c2_register_device(struct c2_dev *dev)
+{
+	int ret;
+	int i;
+
+	strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX);
+	dev->ibdev.owner                = THIS_MODULE;
+
+	dev->ibdev.node_type            = IB_NODE_CA;
+	dev->ibdev.phys_port_cnt        = 1;
+	dev->ibdev.dma_device           = &dev->pcidev->dev;
+	dev->ibdev.class_dev.dev        = &dev->pcidev->dev;
+	dev->ibdev.query_device         = c2_query_device;
+	dev->ibdev.query_port           = c2_query_port;
+	dev->ibdev.modify_port          = c2_modify_port;
+	dev->ibdev.query_pkey           = c2_query_pkey;
+	dev->ibdev.query_gid            = c2_query_gid;
+	dev->ibdev.alloc_ucontext       = c2_alloc_ucontext;
+	dev->ibdev.dealloc_ucontext     = c2_dealloc_ucontext;
+	dev->ibdev.mmap                 = c2_mmap_uar;
+	dev->ibdev.alloc_pd             = c2_alloc_pd;
+	dev->ibdev.dealloc_pd           = c2_dealloc_pd;
+	dev->ibdev.create_ah            = c2_ah_create;
+	dev->ibdev.destroy_ah           = c2_ah_destroy;
+	dev->ibdev.create_qp            = c2_create_qp;
+	dev->ibdev.modify_qp            = c2_modify_qp;
+	dev->ibdev.destroy_qp           = c2_destroy_qp;
+	dev->ibdev.create_cq            = c2_create_cq;
+	dev->ibdev.destroy_cq           = c2_destroy_cq;
+	dev->ibdev.poll_cq              = c2_poll_cq;
+	dev->ibdev.get_dma_mr           = c2_get_dma_mr;
+	dev->ibdev.reg_phys_mr          = c2_reg_phys_mr;
+	dev->ibdev.reg_user_mr          = c2_reg_user_mr;
+	dev->ibdev.dereg_mr             = c2_dereg_mr;
+
+	dev->ibdev.alloc_fmr            = 0;
+	dev->ibdev.unmap_fmr            = 0;
+	dev->ibdev.dealloc_fmr          = 0;
+	dev->ibdev.map_phys_fmr         = 0;
+
+	dev->ibdev.attach_mcast         = c2_multicast_attach;
+	dev->ibdev.detach_mcast         = c2_multicast_detach;
+	dev->ibdev.process_mad          = c2_process_mad;
+
+	dev->ibdev.req_notify_cq = c2_arm_cq;
+	dev->ibdev.post_send     = c2_post_send;
+	dev->ibdev.post_recv     = c2_post_receive;
+
+	ret = ib_register_device(&dev->ibdev);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) {
+		ret = class_device_create_file(&dev->ibdev.class_dev,
+					       c2_class_attributes[i]);
+		if (ret) {
+			ib_unregister_device(&dev->ibdev);
+			return ret;
+		}
+	}
+	return 0;
+}
+
+void c2_unregister_device(struct c2_dev *dev)
+{
+	ib_unregister_device(&dev->ibdev);
+}
Index: amso1100/c2_provider.h
===================================================================
--- amso1100/c2_provider.h	(revision 0)
+++ amso1100/c2_provider.h	(revision 0)
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2005 Ammasso, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef C2_PROVIDER_H
+#define C2_PROVIDER_H
+
+#include <ib_verbs.h>
+#include <ib_pack.h>
+
+#define C2_MPT_FLAG_ATOMIC        (1 << 14)
+#define C2_MPT_FLAG_REMOTE_WRITE  (1 << 13)
+#define C2_MPT_FLAG_REMOTE_READ   (1 << 12)
+#define C2_MPT_FLAG_LOCAL_WRITE   (1 << 11)
+#define C2_MPT_FLAG_LOCAL_READ    (1 << 10)
+
+struct c2_buf_list {
+	void *buf;
+	DECLARE_PCI_UNMAP_ADDR(mapping)
+};
+
+struct c2_uar {
+	unsigned long pfn;
+	int           index;
+};
+
+struct c2_user_db_table;
+
+struct c2_ucontext {
+	struct ib_ucontext             ibucontext;
+	struct c2_uar            uar;
+	struct c2_user_db_table *db_tab;
+};
+
+struct c2_mtt;
+
+struct c2_mr {
+	struct ib_mr         ibmr;
+};
+
+struct c2_pd {
+	struct ib_pd        ibpd;
+};
+
+struct c2_av;
+
+enum c2_ah_type {
+	C2_AH_ON_HCA,
+	C2_AH_PCI_POOL,
+	C2_AH_KMALLOC
+};
+
+struct c2_ah {
+	struct ib_ah       ibah;
+};
+
+struct c2_cq {
+	struct ib_cq           ibcq;
+};
+
+struct c2_wq {
+	spinlock_t lock;
+};
+
+struct c2_qp {
+	struct ib_qp           ibqp;
+};
+
+static inline struct c2_dev *to_dev(struct ib_device* ibdev)
+{
+	return container_of(ibdev, struct c2_dev, ibdev);
+}
+
+#if 0
+static inline struct c2_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
+{
+	return container_of(ibucontext, struct c2_ucontext, ibucontext);
+}
+
+static inline struct c2_mr *to_mmr(struct ib_mr *ibmr)
+{
+	return container_of(ibmr, struct c2_mr, ibmr);
+}
+
+static inline struct c2_pd *to_mpd(struct ib_pd *ibpd)
+{
+	return container_of(ibpd, struct c2_pd, ibpd);
+}
+
+static inline struct c2_ah *to_mah(struct ib_ah *ibah)
+{
+	return container_of(ibah, struct c2_ah, ibah);
+}
+
+static inline struct c2_cq *to_mcq(struct ib_cq *ibcq)
+{
+	return container_of(ibcq, struct c2_cq, ibcq);
+}
+
+static inline struct c2_qp *to_mqp(struct ib_qp *ibqp)
+{
+	return container_of(ibqp, struct c2_qp, ibqp);
+}
+#endif
+#endif /* C2_PROVIDER_H */
Index: amso1100/TODO
===================================================================
--- amso1100/TODO	(revision 3074)
+++ amso1100/TODO	(working copy)
@@ -1,3 +1,5 @@
+An X in the boxes below indicates the work is completed. A '-' indicates 
+it's remains to be completed.
 
 [X] Kconfig: replace 'mthca' with 'ams1100' in help text :)
 
@@ -3,5 +5,5 @@
 [X] Replace all // comments with /* */.
 
-[-] Why are members of cc_pci_regs_t and cc_adapter_pci_regs_t volatile?
+[X] Why are members of cc_pci_regs_t and cc_adapter_pci_regs_t volatile?
  Volatile declarations are almost inevitably buggy. It's better to
  use ordered accessors (readl(), writel(), etc) or insert explicit
@@ -20,7 +22,7 @@
   ...
  };
 
-[-] Can cc_byteorder.h be eliminated? Most of the wrappers are
+[X] Can cc_byteorder.h be eliminated? Most of the wrappers are
  definitely superfluous. Can the WR byte order ever change? ie are
  the cpu_to_wrXX() functions actually a useful abstraction?
 
@@ -43,7 +45,7 @@
 
 [-] cc_mq_common.c: BUMP is pretty inefficient, does a divide every time
 
-[-] cc_qp_common.c: cc_memcpy8 corrupts FPU state, is it really needed?
+[X] cc_qp_common.c: cc_memcpy8 corrupts FPU state, is it really needed?
  it's never called. Why is it declared in cc_mq_common.c?
  memcpy4 similarly corrupts state. If it's fixed to save CR0 and do
  clts, is it really faster than a normal memcpy (considering it also
@@ -85,3 +87,6 @@
 [-] Remove kDAT entry points
 
 [-] Remove superflouos common files/code
+
+[-] Boot firmware from flash instead of loading over PCI
+



More information about the general mailing list