PERFORCE change 129007 for review

Steve Wise swise at FreeBSD.org
Mon Nov 12 16:55:12 PST 2007


http://perforce.freebsd.org/chv.cgi?CH=129007

Change 129007 by swise at swise:vic10:iwarp on 2007/11/13 00:54:56

	iw_cxgb loads and registers with rdma_core. (still lots o' hacks).

Affected files ...

.. //depot/projects/iwarp/sys/dev/cxgb/common/cxgb_ctl_defs.h#3 edit
.. //depot/projects/iwarp/sys/dev/cxgb/cxgb_offload.c#4 edit
.. //depot/projects/iwarp/sys/dev/cxgb/cxgb_osdep.h#3 edit
.. //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cxio_hal.c#2 edit
.. //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cxio_resource.c#2 edit
.. //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_iwch.c#2 edit
.. //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_iwch_provider.c#2 edit

Differences ...

==== //depot/projects/iwarp/sys/dev/cxgb/common/cxgb_ctl_defs.h#3 (text+ko) ====

@@ -126,7 +126,7 @@
 	unsigned int udbell_len; /* user doorbell region length */
 	unsigned long udbell_physbase;  /* user doorbell physical start addr */
 	void *kdb_addr;  /* kernel doorbell register address */
-	struct pci_dev *pdev;    /* associated PCI device */
+	struct device *pdev;    /* associated PCI device */
 };
 
 /*

==== //depot/projects/iwarp/sys/dev/cxgb/cxgb_offload.c#4 (text+ko) ====

@@ -303,6 +303,7 @@
 		req->rqt_base = t3_read_reg(adapter, A_ULPRX_RQ_LLIMIT);
 		req->rqt_top  = t3_read_reg(adapter, A_ULPRX_RQ_ULIMIT);
 		req->kdb_addr = (void *)(rman_get_start(adapter->regs_res) + A_SG_KDOORBELL);
+		req->pdev = adapter->dev;
 		break;
 	}
 	case RDMA_CQ_OP: {

==== //depot/projects/iwarp/sys/dev/cxgb/cxgb_osdep.h#3 (text+ko) ====


==== //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cxio_hal.c#2 (text+ko) ====

@@ -207,7 +207,7 @@
 	cq->sw_queue = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO);
 	if (!cq->sw_queue)
 		return (ENOMEM);
-	cq->queue = dma_alloc_coherent(rdev_p->rnic_info.pdev->dev,
+	cq->queue = dma_alloc_coherent(rdev_p->rnic_info.pdev,
 					     (1UL << (cq->size_log2)) *
 					     sizeof(struct t3_cqe),
 					     &(cq->dma_addr), M_WAITOK);
@@ -307,7 +307,7 @@
 cxio_init_ucontext(struct cxio_rdev *rdev_p, struct cxio_ucontext *uctx)
 {
 	TAILQ_INIT(&uctx->qpids);
-	mtx_init(&uctx->lock, "cxio ctx", NULL, MTX_DEF);
+	mtx_init(&uctx->lock, "cxio uctx", NULL, MTX_DEF|MTX_DUPOK);
 }
 
 int
@@ -333,7 +333,7 @@
 	if (!wq->sq)
 		goto err3;
 
-	wq->queue = dma_alloc_coherent(rdev_p->rnic_info.pdev->dev,
+	wq->queue = dma_alloc_coherent(rdev_p->rnic_info.pdev,
 					     depth * sizeof(union t3_wr),
 					     &(wq->dma_addr), M_WAITOK);
 	if (!wq->queue)
@@ -365,7 +365,7 @@
 	int err;
 	err = cxio_hal_clear_cq_ctx(rdev_p, cq->cqid);
 	free(cq->sw_queue, M_DEVBUF);
-	dma_free_coherent(&(rdev_p->rnic_info.pdev->dev),
+	dma_free_coherent(&(rdev_p->rnic_info.pdev),
 			  (1UL << (cq->size_log2))
 			  * sizeof(struct t3_cqe), cq->queue,
 			  pci_unmap_addr(cq, mapping));
@@ -377,7 +377,7 @@
 cxio_destroy_qp(struct cxio_rdev *rdev_p, struct t3_wq *wq,
     struct cxio_ucontext *uctx)
 {
-	dma_free_coherent(&(rdev_p->rnic_info.pdev->dev),
+	dma_free_coherent(&(rdev_p->rnic_info.pdev),
 			  (1UL << (wq->size_log2))
 			  * sizeof(union t3_wr), wq->queue,
 			  pci_unmap_addr(wq, mapping));
@@ -571,7 +571,7 @@
 		goto err;
 	}
 	rdev_p->ctrl_qp.workq = dma_alloc_coherent(
-		rdev_p->rnic_info.pdev->dev,
+		rdev_p->rnic_info.pdev,
 		    (1 << T3_CTRL_QP_SIZE_LOG2) *
 		    sizeof(union t3_wr),
 		    &(rdev_p->ctrl_qp.dma_addr),
@@ -587,8 +587,8 @@
 	memset(rdev_p->ctrl_qp.workq, 0,
 	       (1 << T3_CTRL_QP_SIZE_LOG2) * sizeof(union t3_wr));
 
-	mtx_init(&rdev_p->ctrl_qp.lock, "qp lock", NULL, MTX_DEF);
-	cv_init(&rdev_p->ctrl_qp.waitq, "qp wait");
+	mtx_init(&rdev_p->ctrl_qp.lock, "ctrl-qp lock", NULL, MTX_DEF|MTX_DUPOK);
+	cv_init(&rdev_p->ctrl_qp.waitq, "ctrl-qp wait");
 
 	/* update HW Ctrl QP context */
 	base_addr = rdev_p->ctrl_qp.dma_addr;
@@ -625,7 +625,7 @@
 static int
 cxio_hal_destroy_ctrl_qp(struct cxio_rdev *rdev_p)
 {
-	dma_free_coherent(&(rdev_p->rnic_info.pdev->dev),
+	dma_free_coherent(&(rdev_p->rnic_info.pdev),
 			  (1UL << T3_CTRL_QP_SIZE_LOG2)
 			  * sizeof(union t3_wr), rdev_p->ctrl_qp.workq,
 			  pci_unmap_addr(&rdev_p->ctrl_qp, mapping));
@@ -1077,8 +1077,11 @@
 int __init
 cxio_hal_init(void)
 {
+	TAILQ_INIT(&rdev_list);
+#ifdef needed
 	if (cxio_hal_init_rhdl_resource(T3_MAX_NUM_RI))
 		return (ENOMEM);
+#endif
 	t3_register_cpl_handler(CPL_ASYNC_NOTIF, cxio_hal_ev_handler);
 	return 0;
 }
@@ -1091,7 +1094,9 @@
 	t3_register_cpl_handler(CPL_ASYNC_NOTIF, NULL);
 	TAILQ_FOREACH_SAFE(rdev, &rdev_list, entry, tmp)
 		cxio_rdev_close(rdev);
+#ifdef needed
 	cxio_hal_destroy_rhdl_resource();
+#endif
 }
 
 static void

==== //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cxio_resource.c#2 (text+ko) ====

@@ -87,8 +87,10 @@
 #include <dev/cxgb/ulp/iw_cxgb/iw_cxgb_iwch_user.h>
 #endif
 
+#ifdef needed
 static struct buf_ring *rhdl_fifo;
 static struct mtx rhdl_fifo_lock;
+#endif
 
 #define RANDOM_SIZE 16
 
@@ -101,7 +103,7 @@
 	u32 i, j, idx;
 	u32 random_bytes;
 	u32 rarray[16];
-	mtx_init(fifo_lock, "cxio fifo", NULL, MTX_DEF);
+	mtx_init(fifo_lock, "cxio fifo", NULL, MTX_DEF|MTX_DUPOK);
 
 	*fifo = buf_ring_alloc(nr, M_WAITOK);
 	if (*fifo == NULL)
@@ -172,6 +174,7 @@
 	return 0;
 }
 
+#ifdef needed
 int cxio_hal_init_rhdl_resource(u32 nr_rhdl)
 {
 	return cxio_init_resource_fifo(&rhdl_fifo, &rhdl_fifo_lock, nr_rhdl, 1,
@@ -182,6 +185,7 @@
 {
 	buf_ring_free(rhdl_fifo);
 }
+#endif
 
 /* nr_* must be power of 2 */
 int cxio_hal_init_resource(struct cxio_rdev *rdev_p,
@@ -191,7 +195,7 @@
 	int err = 0;
 	struct cxio_hal_resource *rscp;
 
-	rscp = malloc(sizeof(*rscp), M_DEVBUF, M_WAITOK);
+	rscp = malloc(sizeof(*rscp), M_DEVBUF, M_WAITOK|M_ZERO);
 	if (!rscp)
 		return (ENOMEM);
 	rdev_p->rscp = rscp;

==== //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_iwch.c#2 (text+ko) ====

@@ -102,18 +102,11 @@
 static void
 rnic_init(struct iwch_dev *rnicp)
 {
-	static int inited = 0;
-
-	if (inited == 0) {
-		TAILQ_INIT(&dev_list);
-		inited = 1;
-	}
-	
 	PDBG("%s iwch_dev %p\n", __FUNCTION__,  rnicp);
 	idr_init(&rnicp->cqidr);
 	idr_init(&rnicp->qpidr);
 	idr_init(&rnicp->mmidr);
-	mtx_init(&rnicp->lock, "iwch lock", NULL, MTX_DEF);
+	mtx_init(&rnicp->lock, "iwch rnic lock", NULL, MTX_DEF|MTX_DUPOK);
 	
 	rnicp->attr.vendor_id = 0x168;
 	rnicp->attr.vendor_part_id = 7;
@@ -210,11 +203,13 @@
 	mtx_unlock(&dev_mutex);
 }
 
-#ifdef notyet
 static int __init iwch_init_module(void)
 {
 	int err;
 
+	TAILQ_INIT(&dev_list);
+	mtx_init(&dev_mutex, "iwch dev_list lock", NULL, MTX_DEF);
+	
 	err = cxio_hal_init();
 	if (err)
 		return err;
@@ -233,4 +228,41 @@
 	iwch_cm_term();
 	cxio_hal_exit();
 }
-#endif
+
+static int 
+iwch_load(module_t mod, int cmd, void *arg)
+{
+        int err = 0;
+
+        switch (cmd) {
+        case MOD_LOAD:
+                printf("Loading iw_cxgb.\n");
+
+                iwch_init_module();
+                break;
+        case MOD_QUIESCE:
+                break;
+        case MOD_UNLOAD:
+                printf("Unloading iw_cxgb.\n");
+		iwch_exit_module();
+                break;
+        case MOD_SHUTDOWN:
+                break;
+        default:
+                err = EOPNOTSUPP;
+                break;
+        }
+
+        return (err);
+}
+
+static moduledata_t mod_data = {
+	"iw_cxgb",
+	iwch_load,
+	0
+};
+
+MODULE_VERSION(iw_cxgb, 1);
+DECLARE_MODULE(iw_cxgb, mod_data, SI_SUB_EXEC, SI_ORDER_ANY);
+MODULE_DEPEND(iw_cxgb, rdma_core, 1, 1, 1);
+MODULE_DEPEND(iw_cxgb, if_cxgb, 1, 1, 1);

==== //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_iwch_provider.c#2 (text+ko) ====

@@ -1015,7 +1015,7 @@
 	       __FUNCTION__, ibdev, port, index, gid);
 	dev = to_iwch_dev(ibdev);
 	BUG_ON(port == 0 || port > 2);
-	pi = ((struct port_info *)dev->rdev.ifp->if_softc);
+	pi = ((struct port_info *)dev->rdev.port_info.lldevs[port-1]->if_softc);
 	memset(&(gid->raw[0]), 0, sizeof(gid->raw));
 	memcpy(&(gid->raw[0]), pi->hw_addr, 6);
 	return 0;
@@ -1034,8 +1034,10 @@
 	memcpy(&props->sys_image_guid, dev->rdev.t3cdev_p->lldev->if_addr.ifa_addr, 6);
 #endif	
 	props->device_cap_flags = dev->device_cap_flags;
+#ifdef notyet
 	props->vendor_id = (u32)dev->rdev.rnic_info.pdev->vendor;
 	props->vendor_part_id = (u32)dev->rdev.rnic_info.pdev->device;
+#endif
 	props->max_mr_size = ~0ull;
 	props->max_qp = dev->attr.max_qps;
 	props->max_qp_wr = dev->attr.max_wrs;
@@ -1116,8 +1118,12 @@
 	struct iwch_dev *dev = container_of(cdev, struct iwch_dev,
 					    ibdev.class_dev);
 	PDBG("%s class dev 0x%p\n", __FUNCTION__, dev);
+#ifdef notyet
 	return sprintf(buf, "%x.%x\n", dev->rdev.rnic_info.pdev->vendor,
 		                       dev->rdev.rnic_info.pdev->device);
+#else
+	return sprintf(buf, "%x.%x\n", 0xdead, 0xbeef);	 /* XXX */
+#endif
 }
 
 static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
@@ -1171,7 +1177,7 @@
 	memcpy(dev->ibdev.node_desc, IWCH_NODE_DESC, sizeof(IWCH_NODE_DESC));
 	dev->ibdev.phys_port_cnt = dev->rdev.port_info.nports;
 	dev->ibdev.num_comp_vectors = 1;
-	dev->ibdev.dma_device = dev->rdev.rnic_info.pdev->dev;
+	dev->ibdev.dma_device = dev->rdev.rnic_info.pdev;
 	dev->ibdev.query_device = iwch_query_device;
 	dev->ibdev.query_port = iwch_query_port;
 	dev->ibdev.modify_port = iwch_modify_port;


More information about the p4-projects mailing list