[openib-general] [PATCH][iWARP] Added provider CM verbs and query provider methods

Tom Tucker tom at ammasso.com
Wed Aug 24 16:28:43 PDT 2005



This patch is against the iWARP branch. It adds CM related 
methods to the ib_device structure as well as simple versions
of the low level port, gid, pkey, etc... query methods.

I also added printks to the provider methods so I could track the 
loading process. These will be removed when the driver is stable.

Please take a look and let me know what you think. I'll check 
this in to the iWRAP branch tomorrow if no one expresses dismay.

Please feel free to send me patches to this patch if you see 
something.

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

Index: include/ib_verbs.h
===================================================================
--- include/ib_verbs.h	(revision 3120)
+++ include/ib_verbs.h	(working copy)
@@ -43,6 +43,7 @@
 
 #include <linux/types.h>
 #include <linux/device.h>
+#include <linux/in.h>
 
 #include <asm/atomic.h>
 #include <asm/scatterlist.h>
@@ -59,7 +60,8 @@
 enum ib_node_type {
 	IB_NODE_CA 	= 1,
 	IB_NODE_SWITCH,
-	IB_NODE_ROUTER
+	IB_NODE_ROUTER,
+	IB_NODE_IWARP
 };
 
 enum ib_device_cap_flags {
@@ -273,6 +275,42 @@
 	enum ib_event_type	event;
 };
 
+/* Connection events. */
+enum ib_xcm_event_type {
+	IB_EVENT_ACTIVE_CONNECT_RESULTS,
+	IB_EVENT_CONNECT_REQUEST
+};
+
+/* iwarp connection attributes. */
+struct ib_connect_attr {
+	struct in_addr	 	local_addr;	
+	struct in_addr	 	remote_addr;	
+	u16 			local_port;
+	u16 			remote_port;
+};
+struct ib_conn_results {
+	int			errno;
+	struct ib_connect_attr  conn_attr;
+	int 			priv_len;
+        u8			private_data[0];
+};
+
+struct ib_conn_request {
+	int			cr_id;
+	struct ib_connect_attr  conn_attr;
+	int 			priv_len;
+        u8			private_data[0];
+};
+
+struct ib_xcm_event {
+	struct ib_device	*device;
+	union {
+		struct ib_conn_results 	connect_qp_results;
+		struct ib_conn_request 	connect_request;
+	} element;
+	enum ib_xcm_event_type	event;
+};
+
 struct ib_event_handler {
 	struct ib_device *device;
 	void            (*handler)(struct ib_event_handler *, struct
ib_event *);
@@ -795,6 +833,25 @@
 	IB_MAD_RESULT_CONSUMED = 1 << 2  /* Packet consumed: stop
processing */
 };
 
+/* Listening endpoint. */
+struct ib_listen_ep_attr {
+	void		(*event_handler)(struct ib_xcm_event *, void *);
+	void		*listen_context;
+	struct in_addr   addr;
+	u16		 port;
+	int		 backlog;
+};
+
+struct ib_listen_ep {
+	struct ib_device	*device;
+	void			(*event_handler)(struct ib_xcm_event *,
void *);
+	void			*listen_context;
+	struct in_addr  	addr;
+	u16			port;
+	int			backlog;
+};
+
+
 #define IB_DEVICE_NAME_MAX 64
 
 struct ib_cache {
@@ -941,6 +998,21 @@
 						  struct ib_mad *in_mad,
 						  struct ib_mad
*out_mad);
 
+	int                        (*connect_qp)(struct ib_qp *qp, 
+						 struct ib_connect_attr
*conn_attr);
+	int                        (*accept_cr)(int cr_id, 
+						struct ib_qp *qp, 
+						u8 *pdata, 
+						int pdata_len); 
+	int                        (*reject_cr)(int cr_id, 
+						struct ib_qp *qp, 
+						u8 *pdata, 
+						int pdata_len); 
+	int                        (*query_cr)(int cr_id, 
+					       struct ib_connect_attr
*conn_attr);
+	struct ib_listen_ep *      (*create_listen_ep)(struct
ib_listen_ep_attr *);
+	int                        (*destroy_listen_ep)(struct
ib_listen_ep *ep);
+
 	struct module               *owner;
 	struct class_device          class_dev;
 	struct kobject               ports_parent;
Index: hw/amso1100/c2.c
===================================================================
--- hw/amso1100/c2.c	(revision 3121)
+++ hw/amso1100/c2.c	(working copy)
@@ -1,9 +1,33 @@
 /*
- * c2.c: A Linux PCI-X Gigabit Ethernet driver for AMSO1100 (Cepheus2)
RNIC
- * Copyright(c) 2005 Ammasso, Inc.
- * 
- * History: 
- * 
+ * 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>
@@ -28,8 +52,8 @@
 #include <ib_smi.h>
 #include "c2.h"
 
-MODULE_AUTHOR("Ranjith Balachandran <ranjith at ammasso.com>");
-MODULE_DESCRIPTION("Ammasso AMSO1100 Gigabit Ethernet driver");
+MODULE_AUTHOR("Tom Tucker <tom at ammasso.com>");
+MODULE_DESCRIPTION("Ammasso AMSO1100 Low-level iWARP Driver");
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(DRV_VERSION);
 
@@ -230,7 +254,7 @@
 	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_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));
@@ -975,7 +999,7 @@
 	
 	/* Remap the adapter PCI registers in BAR4 */
 	mmio_regs = ioremap_nocache(reg4_start + C2_PCI_REGS_OFFSET, 
-
sizeof(struct c2_adapter_pci_regs));
+				    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;
@@ -1000,7 +1024,7 @@
 	/* 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);
+		       be32_to_cpu(c2_read32(mmio_regs + C2_REGS_VERS)),
C2_VERSION);
 		ret = -EINVAL;
 		iounmap(mmio_regs);
 		goto bail2;
@@ -1009,7 +1033,7 @@
 	/* 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);
+		       be32_to_cpu(c2_read32(mmio_regs + C2_REGS_IVN)),
C2_IVN);
 		ret = -EINVAL;
 		iounmap(mmio_regs);
 		goto bail2;
@@ -1019,7 +1043,7 @@
 	c2dev = kmalloc(sizeof(*c2dev), GFP_KERNEL);
 	if (!c2dev) {
 		printk(KERN_ERR PFX "%s: Unable to alloc hardware
struct\n",
-			   pci_name(pcidev));
+		       pci_name(pcidev));
 		ret = -ENOMEM;
 		iounmap(mmio_regs);
 		goto bail2;
@@ -1066,7 +1090,7 @@
 	
 	/* 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);
+					       C2_RXP_HRXDQ_SIZE);
 	if (c2dev->mmio_rxp_ring == 0UL) {
 		printk(KERN_ERR PFX "Unable to remap MMIO HRXDQ
region\n");
 		ret = -EIO;
@@ -1075,7 +1099,7 @@
 	
 	/* 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);
+					       C2_TXP_HTXDQ_SIZE);
 	if (c2dev->mmio_txp_ring == 0UL) {
 		printk(KERN_ERR PFX "Unable to remap MMIO HTXDQ
region\n");
 		ret = -EIO;
@@ -1096,6 +1120,8 @@
 	/* Print out the MAC address */
 	c2_print_macaddr(netdev);
 	
+	c2_register_device(c2dev); 
+
 	return 0;
 	
   bail8:
Index: hw/amso1100/devccil_adapter.c
===================================================================
--- hw/amso1100/devccil_adapter.c	(revision 3120)
+++ hw/amso1100/devccil_adapter.c	(working copy)
@@ -46,13 +46,6 @@
     {0,}
 };
 
-static struct pci_driver devccil_driver = {
-    .name	= "cepheus",
-    .id_table	= devccil_id_table,
-    .probe	= devccil_probe,
-    .remove	= __devexit_p(devccil_remove),
-};
-
 /*
  * global linked lists of CC adapters and open rnic instances.
  */
@@ -482,10 +475,8 @@
 
 
 /*
- *  Called once on the first open of a host process to simulate reading
- *  the PCI regs and setting access to the system iface for this
- *  adapter.  For a real adapter, we can do this as the result of a
probe
- *  call.  For now, we do it on the first user open.
+ *  Called by device_probe to allocate and initialize adapter hardware 
+ *  resources.
  */
 int
 alloc_adapter(cc_adapter_t **p_cca)
@@ -541,21 +532,6 @@
 	return 0;
 }
 
-int
-adapter_init(struct pci_driver *driver)
-{
-	memcpy(driver, &devccil_driver, sizeof(struct pci_driver));
-
-	return 0;
-}
-
-void
-adapter_term(void)
-{
-	;
-}
-
-
 cc_status_t
 init_adapter_queues(cc_adapter_t* cca)
 {
Index: hw/amso1100/c2.h
===================================================================
--- hw/amso1100/c2.h	(revision 3120)
+++ hw/amso1100/c2.h	(working copy)
@@ -1,9 +1,42 @@
 /*
- * c2.h: A Linux PCI-X Gigabit Ethernet driver for AMSO1100 (Cepheus2)
RNIC
- * 
- * Copyright(c) 2005 Ammasso, Inc.
+ * 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 "cc_queue.h"
+#include "cc_adapter.h"
+
+#include "devccil_mq.h"
+#include "devccil_eh.h"
+#include "devccil_lock.h"
+
 #define DRV_NAME     "c2"
 #define DRV_VERSION  "1.1"
 #define PFX          DRV_NAME ": "
@@ -215,6 +248,49 @@
 	struct net_device *netdev;
 	unsigned int      cur_tx;
 	unsigned int      cur_rx;
+	u64               fw_ver;
+	u32               hw_rev;
+	u32               device_cap_flags;
+	u32               vendor_id;
+	u32               vendor_part_id;
+	void __iomem   	  *kva;		/* KVA device memory */
+	void __iomem	  *pa;		/* PA device memory */
+	void**		  qptr_array;
+	kmem_cache_t* 	  host_msg_cache;
+	kmem_cache_t* 	  ae_msg_cache;
+	struct list_head  cca_link; 	  /* adapter list */
+	struct list_head  eh_wakeup_list; /* event wakeup list */
+	wait_queue_head_t req_vq_wo;
+	cc_mq_t		  req_vq;	/* Verbs Request MQ */
+	
+	/* RNIC Limits */
+	u32               max_mr_size;
+	u32               max_qp;
+	u32               max_qp_wr;
+	u32               max_sge;
+	u32               max_cq;
+	u32               max_cqe;
+	u32               max_mr;
+	u32               max_pd;
+
+	int		  ports;	/* num of GigE ports */
+	int		  devnum;
+	cc_lock_t	  vqlock;	/* sync vbs req MQ */
+	cc_mq_t		  rep_vq;	/* Verbs Reply MQ */
+	cc_mq_t	 	  aeq;		/* Async Events MQ */
+	cc_lock_t	  aeq_lock;
+	cc_lock_t	  rnic_lock;
+	u16		  q1_shared;
+	u16		  q2_shared;
+	u16               irq_claimed;
+
+	u16               hint_count;
+	u16               hints_read;
+
+	u16		  q0_shared;
+	cc_bool_t	  init;		/* TRUE if it's ready */
+        char              ae_cache_name[16];
+        char              vq_cache_name[16];
 };
 
 struct c2_port {
@@ -224,8 +300,8 @@
 	
 	spinlock_t        tx_lock;
 	u32               tx_avail;
-	struct c2_ring  tx_ring;
-	struct c2_ring  rx_ring;
+	struct c2_ring    tx_ring;
+	struct c2_ring    rx_ring;
 	
 	void              *mem; /* PCI memory for host rings */
 	dma_addr_t        dma;
Index: hw/amso1100/devccil_adapter.h
===================================================================
--- hw/amso1100/devccil_adapter.h	(revision 3120)
+++ hw/amso1100/devccil_adapter.h	(working copy)
@@ -34,8 +34,6 @@
 #define ADAPTER_MAGIC 0x54504441 /* 'ADPT' */
 
 typedef struct cc_adapter_s {
-	struct ib_device 	ib_dev;
-	struct pci_dev		*dev;		/* Linux PCI Dev */
 	struct port_s {
 		void		*phys;
 		void		*virt;
@@ -76,12 +74,6 @@
         char                    vq_cache_name[16];
 } cc_adapter_t;
 
-static inline cc_adapter_t* to_adapter(struct ib_device *ibdev)
-{
-	return container_of(ibdev, cc_adapter_t, ib_dev);
-}
-
-
 extern CC_TAILQ_HEAD(cca_list, cc_adapter_s) adapter_list; 
 extern int alloc_adapter(cc_adapter_t **p_cca);
 extern void free_adapter(cc_adapter_t *cca);
Index: hw/amso1100/devnet.h
===================================================================
--- hw/amso1100/devnet.h	(revision 3120)
+++ hw/amso1100/devnet.h	(working copy)
@@ -74,7 +74,7 @@
 #else
 extern int ccilnet_init_module(struct pci_driver *);
 #endif /* STANDALONE */
-extern int devccil_init_module(struct pci_driver *);
+extern int devccil_init_module(void);
 extern void devccil_exit_module(void);
 extern void ccilnet_exit_module(void);
 
Index: hw/amso1100/devccil.c
===================================================================
--- hw/amso1100/devccil.c	(revision 3120)
+++ hw/amso1100/devccil.c	(working copy)
@@ -87,56 +87,6 @@
 MODULE_PARM_DESC(pinned_max_percent, "The maximum percent of real
memory that devccil can pin.");
 
 /*
- * define the kdapl verbs list
- */
-#undef CCIL_KDAPL
-#ifdef CCIL_KDAPL
-#include <dapl/verbslist.h>
-
-CCVerbs ccil_kdapl_verbs_list = {
-	1,	/* version number */
-	cc_rnic_enum_kern,
-	cc_rnic_open_kern,
-	cc_rnic_query_kern,
-	cc_rnic_close_kern,
-	cc_rnic_getconfig_kern,
-	cc_pd_alloc_kern,
-	cc_pd_dealloc_kern,
-	cc_qp_create_kern,
-	cc_qp_modify_kern,
-	cc_qp_modify_user_context_kern,
-	cc_qp_query_kern,
-	cc_qp_destroy_kern,
-	cc_cq_create_kern,
-	cc_cq_modify_kern,
-	cc_cq_destroy_kern,
-	cc_nsmr_register_phys_kern,
-	cc_mw_alloc_kern,
-	cc_stag_dealloc_kern,
-	cc_smr_register_kern,
-	cc_qp_post_sq_kern,
-	cc_qp_post_rq_kern,
-	cc_cq_poll_kern,
-	cc_eh_set_ce_handler_kern,
-	cc_eh_set_async_handler_kern,
-	cc_cq_request_notification_kern,
-	cc_ep_listen_create_kern,
-	cc_ep_listen_destroy_kern,
-	cc_ep_query_kern,
-	cc_qp_connect_kern,
-	cc_cr_accept_kern,
-	cc_cr_reject_kern
-};
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
-EXPORT_SYMBOL_NOVERS(ccil_kdapl_verbs_list);
-#else
-EXPORT_SYMBOL(ccil_kdapl_verbs_list);
-#endif
-
-#endif
-
-/*
  * Fileops declarations.
  */
 Static int ccilopen(struct inode *inode, struct file *f);
@@ -171,7 +121,7 @@
  *  device memory and pin it.
  */
 int
-devccil_init_module(struct pci_driver *driver)
+devccil_init_module(void)
 
 {
 	int rc;
@@ -220,12 +170,6 @@
         }
 #endif
 
-	if ((rc = adapter_init(driver))) {
-		(void)unregister_chrdev (ccil_major_num, CCILMOD);
-		devccil_err("DEVCCIL: adapter initialization failed\n");
-		return rc;
-	}
-
 	if ((rc = rnic_init())) {
 		adapter_term();
 		(void)unregister_chrdev (ccil_major_num, CCILMOD);
@@ -240,13 +184,6 @@
 		return rc;
 	}
 
-#if defined CCIL_KDAPL && !defined symbol_get
-	/*
-	 * register the verbs list for the kdapl module
-	 */
-	inter_module_register("ccil_kdapl_verbs_list", THIS_MODULE,
&ccil_kdapl_verbs_list);
-#endif
-
 	devccil_info("DEVCCIL: module loaded\n");
 	return(0);
 }
@@ -265,13 +202,6 @@
 
     adapter_term();
 
-#if defined CCIL_KDAPL && !defined symbol_get
-	/*
-	 * unregister the verbs list
-	 */
-	inter_module_unregister("ccil_kdapl_verbs_list");
-#endif
-
     error = unregister_32bit_ioctls();
     if (error) {
 		devccil_err("DEVCCIL: unregistering 32 bit ioctls
failed\n");
Index: hw/amso1100/c2_provider.c
===================================================================
--- hw/amso1100/c2_provider.c	(revision 3120)
+++ hw/amso1100/c2_provider.c	(working copy)
@@ -55,53 +55,132 @@
 
 #include "c2.h"
 #include "c2_provider.h"
+#include "c2_user.h"
 
 static int c2_query_device(struct ib_device *ibdev,
 			      struct ib_device_attr *props)
 {
-	int err = -ENOMEM;
-	return err;
+	struct c2_dev* c2dev = to_dev(ibdev);
+
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+
+	memset(props, 0, sizeof *props);
+
+	memcpy(&props->sys_image_guid, c2dev->netdev->dev_addr, 6);
+	memcpy(&props->node_guid,      c2dev->netdev->dev_addr, 6);
+
+	props->fw_ver              = c2dev->fw_ver;
+	props->device_cap_flags    = c2dev->device_cap_flags;
+	props->vendor_id           = c2dev->vendor_id;
+	props->vendor_part_id      = c2dev->vendor_part_id;
+	props->hw_ver              = c2dev->hw_rev;
+	props->max_mr_size         = ~0ull;
+	props->max_qp              = c2dev->max_qp;
+	props->max_qp_wr           = c2dev->max_qp_wr;
+	props->max_sge             = c2dev->max_sge;
+	props->max_cq              = c2dev->max_cq;
+	props->max_cqe             = c2dev->max_cqe;
+	props->max_mr              = c2dev->max_mr;
+	props->max_pd              = c2dev->max_pd;
+	props->max_qp_rd_atom      = 0;
+	props->max_qp_init_rd_atom = 0;
+	props->local_ca_ack_delay  = 0;
+
+	return 0;
 }
 
 static int c2_query_port(struct ib_device *ibdev,
-			    u8 port, struct ib_port_attr *props)
+			 u8 port, struct ib_port_attr *props)
 {
-	return ENOSYS;
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+
+	props->max_mtu           = IB_MTU_4096;
+	props->lid               = 0;
+	props->lmc               = 0;
+	props->sm_lid            = 0;
+	props->sm_sl             = 0;
+	props->state             = IB_PORT_ACTIVE;
+	props->phys_state        = 0;
+	props->port_cap_flags    = 0; 
+	props->gid_tbl_len       = 128;
+	props->pkey_tbl_len      = 1;
+	props->qkey_viol_cntr    = 0;
+	props->active_width      = 1;
+	props->active_speed      = 1;
+
+	return 0;
 }
 
 static int c2_modify_port(struct ib_device *ibdev,
 			     u8 port, int port_modify_mask,
 			     struct ib_port_modify *props)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return ENOSYS;
 }
 
 static int c2_query_pkey(struct ib_device *ibdev,
-			    u8 port, u16 index, u16 *pkey)
+			 u8 port, u16 index, u16 *pkey)
 {
-	return ENOSYS;
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	*pkey = 0;
+	return 0;
 }
 
 static int c2_query_gid(struct ib_device *ibdev, u8 port,
 			   int index, union ib_gid *gid)
 {
-	return ENOSYS;
+	struct c2_dev* c2dev = to_dev(ibdev);
+
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	memcpy(&(gid->raw[2]),c2dev->netdev->dev_addr, 6);
+	gid->raw[0] = 0;
+	gid->raw[1] = 0;
+
+	return 0;
 }
 
+/* Allocate the user context data structure. This keeps track
+ * of all objects associated with a particular user-mode client.
+ */
 static struct ib_ucontext *c2_alloc_ucontext(struct ib_device *ibdev,
 						struct ib_udata *udata)
 {
-	return 0;
+	struct c2_alloc_ucontext_resp uresp;
+	struct c2_ucontext            *context;
+
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	memset(&uresp, 0, sizeof uresp);
+
+	uresp.qp_tab_size = to_dev(ibdev)->max_qp;
+
+	context = kmalloc(sizeof *context, GFP_KERNEL);
+	if (!context)
+		return ERR_PTR(-ENOMEM);
+
+	/* The OpenIB user context is logically similar to the RNIC
+	 * Instance of our existing driver
+	 */
+	/* context->rnic_p = rnic_open */
+
+	if (ib_copy_to_udata(udata, &uresp, sizeof uresp)) {
+		kfree(context);
+		return ERR_PTR(-EFAULT);
+	}
+
+	return &context->ibucontext;
 }
 
 static int c2_dealloc_ucontext(struct ib_ucontext *context)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 static int c2_mmap_uar(struct ib_ucontext *context,
 			  struct vm_area_struct *vma)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
@@ -109,22 +188,26 @@
 				    struct ib_ucontext *context,
 				    struct ib_udata *udata)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 static int c2_dealloc_pd(struct ib_pd *pd)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 static struct ib_ah *c2_ah_create(struct ib_pd *pd,
 				     struct ib_ah_attr *ah_attr)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 static int c2_ah_destroy(struct ib_ah *ah)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
@@ -132,11 +215,13 @@
 				     struct ib_qp_init_attr *init_attr,
 				     struct ib_udata *udata)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 static int c2_destroy_qp(struct ib_qp *qp)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
@@ -144,16 +229,19 @@
 				     struct ib_ucontext *context,
 				     struct ib_udata *udata)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return ERR_PTR(0);
 }
 
 static int c2_destroy_cq(struct ib_cq *cq)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 static struct ib_mr *c2_get_dma_mr(struct ib_pd *pd, int acc)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
@@ -163,40 +251,49 @@
 				       int                 acc,
 				       u64                *iova_start)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 static struct ib_mr *c2_reg_user_mr(struct ib_pd *pd, struct ib_umem
*region,
 				       int acc, struct ib_udata *udata)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return ERR_PTR(0);
 }
 
 static int c2_dereg_mr(struct ib_mr *mr)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	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);
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	return sprintf(buf, "%x\n", dev->hw_rev);
 }
 
 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);
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	return sprintf(buf, "%x.%x.%x\n", 
+		       (int)(dev->fw_ver >> 32),
+		       (int)(dev->fw_ver >> 16) & 0xffff,
+		       (int)(dev->fw_ver & 0xffff));
 }
 
 static ssize_t show_hca(struct class_device *cdev, char *buf)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	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);
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID");
 }
 
@@ -214,21 +311,25 @@
 
 int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int
attr_mask)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return ENOSYS;
 }
 
 int c2_poll_cq(struct ib_cq *ibcq, int num_entries,
                   struct ib_wc *entry)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 int c2_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return ENOSYS;
 }
 
 int c2_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return ENOSYS;
 }
 
@@ -240,36 +341,85 @@
                       struct ib_mad *in_mad,
                       struct ib_mad *out_mad)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return ENOSYS;
 }
 
 int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify notify)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 int c2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
                           struct ib_send_wr **bad_wr)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 int c2_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
                              struct ib_recv_wr **bad_wr)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 
+int c2_connect_qp(struct ib_qp *qp, 
+		  struct ib_connect_attr *conn_attr)
+{
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	return ENOSYS;
+}
+
+int c2_accept_cr(int cr_id, 
+		 struct ib_qp *qp, 
+		 u8 *pdata, 
+		 int pdata_len)
+{
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	return ENOSYS;
+}
+
+int c2_reject_cr(int cr_id, 
+		 struct ib_qp *qp, 
+		 u8 *pdata, 
+		 int pdata_len)
+{
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	return ENOSYS;
+}
+
+int c2_query_cr(int cr_id, 
+		struct ib_connect_attr *conn_attr)
+{
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	return ENOSYS;
+}
+
+struct ib_listen_ep * c2_create_listen_ep(struct ib_listen_ep_attr *la)
+{
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	return 0;
+}
+
+int c2_destroy_listen_ep(struct ib_listen_ep *ep)
+{
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
+	return ENOSYS;
+}
+
 int c2_register_device(struct c2_dev *dev)
 {
 	int ret;
 	int i;
 
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX);
 	dev->ibdev.owner                = THIS_MODULE;
 
-	dev->ibdev.node_type            = IB_NODE_CA;
+	dev->ibdev.node_type            = IB_NODE_IWARP;
 	dev->ibdev.phys_port_cnt        = 1;
 	dev->ibdev.dma_device           = &dev->pcidev->dev;
 	dev->ibdev.class_dev.dev        = &dev->pcidev->dev;
@@ -305,10 +455,17 @@
 	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;
+	dev->ibdev.req_notify_cq 	= c2_arm_cq;
+	dev->ibdev.post_send     	= c2_post_send;
+	dev->ibdev.post_recv     	= c2_post_receive;
 
+	dev->ibdev.connect_qp		= c2_connect_qp;
+	dev->ibdev.accept_cr		= c2_accept_cr;
+	dev->ibdev.reject_cr		= c2_reject_cr;
+	dev->ibdev.query_cr		= c2_query_cr;
+	dev->ibdev.create_listen_ep	= c2_create_listen_ep;
+	dev->ibdev.destroy_listen_ep	= c2_destroy_listen_ep;
+
 	ret = ib_register_device(&dev->ibdev);
 	if (ret)
 		return ret;
@@ -321,10 +478,12 @@
 			return ret;
 		}
 	}
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	return 0;
 }
 
 void c2_unregister_device(struct c2_dev *dev)
 {
+	printk("%s:%s:%u\n", __FILE__, __FUNCTION__, __LINE__);
 	ib_unregister_device(&dev->ibdev);
 }
Index: hw/amso1100/c2_provider.h
===================================================================
--- hw/amso1100/c2_provider.h	(revision 3120)
+++ hw/amso1100/c2_provider.h	(working copy)
@@ -48,17 +48,27 @@
 	DECLARE_PCI_UNMAP_ADDR(mapping)
 };
 
-struct c2_uar {
-	unsigned long pfn;
-	int           index;
-};
 
-struct c2_user_db_table;
+/* The user context keeps track of objects allocated for a
+ * particular user-mode client. */
+struct c2_ucontext {
+	struct ib_ucontext	ibucontext;
 
-struct c2_ucontext {
-	struct ib_ucontext             ibucontext;
-	struct c2_uar            uar;
-	struct c2_user_db_table *db_tab;
+	int			index;		/* rnic index (minor) */
+	int			port;		/* Which GigE port */
+
+	/*
+	 * Shared HT pages for user-accessible MQs.
+	 */
+        int                     hthead;	          /* index of
first free entry */
+	void*			htpages;	  /* kernel vaddr */
+	int			htlen;		  /* length of htpages
memory */
+	void*			htuva;		  /* user mapped vaddr
*/
+	cc_lock_t		htlock;		  /* serialize
allocation */
+	u64			adapter_hint_uva; /* Activity FIFO */
+
+	cc_rnic_query_attrs_t	rnic_attrs;	  /* cache of rnic attrs
*/
+
 };
 
 struct c2_mtt;
@@ -67,8 +77,12 @@
 	struct ib_mr         ibmr;
 };
 
+/* All objects associated with a PD are kept in the 
+ * associated user context if present. 
+ */
 struct c2_pd {
-	struct ib_pd        ibpd;
+	struct ib_pd	ibpd;
+	u32		pd_id;
 };
 
 struct c2_av;
Index: hw/amso1100/TODO
===================================================================
--- hw/amso1100/TODO	(revision 3120)
+++ hw/amso1100/TODO	(working copy)
@@ -82,11 +82,13 @@
  you need. Custom ASSERT() can probably just be replaced with
  standard BUG_ON().
 
-[-] Split out ccilnet
+[X] Split out ccilnet
 
-[-] Remove kDAT entry points
+[X] Remove kDAT entry points
 
 [-] Remove superflouos common files/code
 
 [-] Boot firmware from flash instead of loading over PCI
 
+[-] Remove MQ memory duplication in the host
+




More information about the general mailing list