[openib-general] [PATCH][3/5] ib_get_dma_mr(): use in MAD layer

Roland Dreier roland at topspin.com
Wed Oct 20 16:04:45 PDT 2004


Index: infiniband/core/mad_ib.c
===================================================================
--- infiniband/core/mad_ib.c	(revision 915)
+++ infiniband/core/mad_ib.c	(working copy)
@@ -59,7 +59,7 @@
 					     mad, IB_MAD_PACKET_SIZE,
 					     PCI_DMA_TODEVICE);
 	gather_list.length  = IB_MAD_PACKET_SIZE;
-	gather_list.lkey    = priv->lkey;
+	gather_list.lkey    = priv->mr->lkey;
 
 	send_param.next               = NULL;
 	send_param.opcode             = IB_WR_SEND;
@@ -303,7 +303,7 @@
 					      buf, IB_MAD_BUFFER_SIZE,
 					      PCI_DMA_FROMDEVICE);
 	scatter_list.length  = IB_MAD_BUFFER_SIZE;
-	scatter_list.lkey    = priv->lkey;
+	scatter_list.lkey    = priv->mr->lkey;
 
 	receive_param.next                = NULL;
 	receive_param.sg_list             = &scatter_list;
Index: infiniband/core/mad_main.c
===================================================================
--- infiniband/core/mad_main.c	(revision 915)
+++ infiniband/core/mad_main.c	(working copy)
@@ -42,31 +42,6 @@
 
 kmem_cache_t *mad_cache;
 
-static inline int ib_mad_register_memory(struct ib_pd  *pd,
-                                         struct ib_mr **mr,
-                                         u32           *lkey)
-{
-        u64                iova = 0;
-        struct ib_phys_buf buffer_list = {
-		.addr = 0,
-		.size = (unsigned long) high_memory - PAGE_OFFSET
-	};
-
-        *mr = ib_reg_phys_mr(pd, &buffer_list, 1, /* list_len */
-			     IB_ACCESS_LOCAL_WRITE, &iova);
-        if (IS_ERR(*mr)) {
-                printk(KERN_WARNING "ib_reg_phys_mr failed "
-		       "size 0x%016llx, iova 0x%016llx "
-		       "(return code %ld)\n",
-		       (unsigned long long) buffer_list.size,
-		       (unsigned long long) iova, PTR_ERR(*mr));
-		return PTR_ERR(*mr);
-	}
-
-	*lkey = (*mr)->lkey;
-        return 0;
-}
-
 static int ib_mad_qp_create(struct ib_device *device,
                             tTS_IB_PORT       port,
                             u32               qpn)
@@ -197,8 +172,9 @@
 
 	INIT_WORK(&priv->cq_work, ib_mad_drain_cq, device);
 
-	if (ib_mad_register_memory(priv->pd, &priv->mr, &priv->lkey)) {
-		printk(KERN_WARNING "Failed to allocate MAD MR for %s\n",
+	priv->mr = ib_get_dma_mr(priv->pd, IB_ACCESS_LOCAL_WRITE);
+	if (IS_ERR(priv->mr)) {
+		printk(KERN_WARNING "Failed to create DMA MR for %s\n",
 		       device->name);
 		goto error_free_cq;
 	}
Index: infiniband/core/mad_priv.h
===================================================================
--- infiniband/core/mad_priv.h	(revision 915)
+++ infiniband/core/mad_priv.h	(working copy)
@@ -59,7 +59,6 @@
 	struct ib_pd           *pd;
 	struct ib_cq           *cq;
 	struct ib_mr           *mr;
-	u32                     lkey;
 	struct ib_qp           *qp[IB_MAD_MAX_PORTS_PER_DEVICE + 1][2];
 
 	struct ib_mad_buf       send_buf   [IB_MAD_MAX_PORTS_PER_DEVICE + 1][2][IB_MAD_SENDS_PER_QP];




More information about the general mailing list