[openib-general] [PATCH v2 6/7] IB/sdp - Use the new verbs DMA mapping functions

Ralph Campbell ralph.campbell at qlogic.com
Thu Nov 30 10:28:16 PST 2006


This patch converts SDP to use the new DMA mapping functions
for kernel verbs consumers.

From: Ralph Campbell <ralph.campbell at qlogic.com>

Index: sdp_bcopy.c
===================================================================
--- sdp_bcopy.c	(revision 9441)
+++ sdp_bcopy.c	(working copy)
@@ -66,8 +66,8 @@ void sdp_post_send(struct sdp_sock *ssk,
 	struct sdp_bsdh *h = (struct sdp_bsdh *)skb_push(skb, sizeof *h);
 	unsigned mseq = ssk->tx_head;
 	int i, rc, frags;
-	dma_addr_t addr;
-	struct device *hwdev;
+	u64 addr;
+	struct ib_device *dev;
 	struct ib_sge *sge;
 	struct ib_send_wr *bad_wr;
 
@@ -80,27 +80,26 @@ void sdp_post_send(struct sdp_sock *ssk,
 
 	tx_req = &ssk->tx_ring[mseq & (SDP_TX_SIZE - 1)];
 	tx_req->skb = skb;
-	hwdev = ssk->dma_device;
+	dev = ssk->mr->device;
 	sge = ssk->ibsge;
-	addr = dma_map_single(hwdev,
-			      skb->data, skb->len - skb->data_len,
-			      DMA_TO_DEVICE);
+	addr = ib_dma_map_single(dev, skb->data, skb->len - skb->data_len,
+				 DMA_TO_DEVICE);
 	tx_req->mapping[0] = addr;
 	
 	/* TODO: proper error handling */
-	BUG_ON(dma_mapping_error(addr));
+	BUG_ON(ib_dma_mapping_error(dev, addr));
 
-	sge->addr = (u64)addr;
+	sge->addr = addr;
 	sge->length = skb->len - skb->data_len;
 	sge->lkey = ssk->mr->lkey;
 	frags = skb_shinfo(skb)->nr_frags;
 	for (i = 0; i < frags; ++i) {
 		++sge;
-		addr = dma_map_page(hwdev, skb_shinfo(skb)->frags[i].page,
-				    skb_shinfo(skb)->frags[i].page_offset,
-				    skb_shinfo(skb)->frags[i].size,
-				    DMA_TO_DEVICE);
-		BUG_ON(dma_mapping_error(addr));
+		addr = ib_dma_map_page(dev, skb_shinfo(skb)->frags[i].page,
+				       skb_shinfo(skb)->frags[i].page_offset,
+				       skb_shinfo(skb)->frags[i].size,
+				       DMA_TO_DEVICE);
+		BUG_ON(ib_dma_mapping_error(dev, addr));
 		tx_req->mapping[i + 1] = addr;
 		sge->addr = addr;
 		sge->length = skb_shinfo(skb)->frags[i].size;
@@ -124,7 +123,7 @@ void sdp_post_send(struct sdp_sock *ssk,
 
 struct sk_buff *sdp_send_completion(struct sdp_sock *ssk, int mseq)
 {
-	struct device *hwdev;
+	struct ib_device *dev;
 	struct sdp_buf *tx_req;
 	struct sk_buff *skb;
 	int i, frags;
@@ -135,16 +134,16 @@ struct sk_buff *sdp_send_completion(stru
 		return NULL;
 	}
 
-	hwdev = ssk->dma_device;
+	dev = ssk->mr->device;
         tx_req = &ssk->tx_ring[mseq & (SDP_TX_SIZE - 1)];
 	skb = tx_req->skb;
-	dma_unmap_single(hwdev, tx_req->mapping[0], skb->len - skb->data_len,
-			 DMA_TO_DEVICE);
+	ib_dma_unmap_single(dev, tx_req->mapping[0], skb->len - skb->data_len,
+			    DMA_TO_DEVICE);
 	frags = skb_shinfo(skb)->nr_frags;
 	for (i = 0; i < frags; ++i) {
-		dma_unmap_page(hwdev, tx_req->mapping[i + 1],
-			       skb_shinfo(skb)->frags[i].size,
-			       DMA_TO_DEVICE);
+		ib_dma_unmap_page(dev, tx_req->mapping[i + 1],
+				  skb_shinfo(skb)->frags[i].size,
+				  DMA_TO_DEVICE);
 	}
 
 	++ssk->tx_tail;
@@ -156,8 +155,8 @@ static void sdp_post_recv(struct sdp_soc
 {
 	struct sdp_buf *rx_req;
 	int i, rc, frags;
-	dma_addr_t addr;
-	struct device *hwdev;
+	u64 addr;
+	struct ib_device *dev;
 	struct ib_sge *sge;
 	struct ib_recv_wr *bad_wr;
 	struct sk_buff *skb;
@@ -188,26 +187,25 @@ static void sdp_post_recv(struct sdp_soc
 
         rx_req = ssk->rx_ring + (id & (SDP_RX_SIZE - 1));
 	rx_req->skb = skb;
-	hwdev = ssk->dma_device;
+	dev = ssk->mr->device;
 	sge = ssk->ibsge;
-	addr = dma_map_single(hwdev, h, skb_headlen(skb),
-			      DMA_FROM_DEVICE);
-	BUG_ON(dma_mapping_error(addr));
+	addr = ib_dma_map_single(dev, h, skb_headlen(skb), DMA_FROM_DEVICE);
+	BUG_ON(ib_dma_mapping_error(dev, addr));
 
 	rx_req->mapping[0] = addr;
 	
 	/* TODO: proper error handling */
-	sge->addr = (u64)addr;
+	sge->addr = addr;
 	sge->length = skb_headlen(skb);
 	sge->lkey = ssk->mr->lkey;
 	frags = skb_shinfo(skb)->nr_frags;
 	for (i = 0; i < frags; ++i) {
 		++sge;
-		addr = dma_map_page(hwdev, skb_shinfo(skb)->frags[i].page,
-				    skb_shinfo(skb)->frags[i].page_offset,
-				    skb_shinfo(skb)->frags[i].size,
-				    DMA_FROM_DEVICE);
-		BUG_ON(dma_mapping_error(addr));
+		addr = ib_dma_map_page(dev, skb_shinfo(skb)->frags[i].page,
+				       skb_shinfo(skb)->frags[i].page_offset,
+				       skb_shinfo(skb)->frags[i].size,
+				       DMA_FROM_DEVICE);
+		BUG_ON(ib_dma_mapping_error(dev, addr));
 		rx_req->mapping[i + 1] = addr;
 		sge->addr = addr;
 		sge->length = skb_shinfo(skb)->frags[i].size;
@@ -242,7 +240,7 @@ void sdp_post_recvs(struct sdp_sock *ssk
 struct sk_buff *sdp_recv_completion(struct sdp_sock *ssk, int id)
 {
 	struct sdp_buf *rx_req;
-	struct device *hwdev;
+	struct ib_device *dev;
 	struct sk_buff *skb;
 	int i, frags;
 
@@ -252,16 +250,16 @@ struct sk_buff *sdp_recv_completion(stru
 		return NULL;
 	}
 
-	hwdev = ssk->dma_device;
+	dev = ssk->mr->device;
         rx_req = &ssk->rx_ring[id & (SDP_RX_SIZE - 1)];
 	skb = rx_req->skb;
-	dma_unmap_single(hwdev, rx_req->mapping[0], skb_headlen(skb),
-			 DMA_FROM_DEVICE);
+	ib_dma_unmap_single(dev, rx_req->mapping[0], skb_headlen(skb),
+			    DMA_FROM_DEVICE);
 	frags = skb_shinfo(skb)->nr_frags;
 	for (i = 0; i < frags; ++i)
-		dma_unmap_page(hwdev, rx_req->mapping[i + 1],
-			       skb_shinfo(skb)->frags[i].size,
-			       DMA_TO_DEVICE);
+		ib_dma_unmap_page(dev, rx_req->mapping[i + 1],
+				  skb_shinfo(skb)->frags[i].size,
+				  DMA_TO_DEVICE);
 	++ssk->rx_tail;
 	--ssk->remote_credits;
 	return skb;
Index: sdp_cma.c
===================================================================
--- sdp_cma.c	(revision 9441)
+++ sdp_cma.c	(working copy)
@@ -159,7 +159,6 @@ int sdp_init_qp(struct sock *sk, struct 
 	}
 	sdp_sk(sk)->cq = cq;
 	sdp_sk(sk)->qp = id->qp;
-	sdp_sk(sk)->dma_device = device->dma_device;
 
 	init_waitqueue_head(&sdp_sk(sk)->wq);
 
Index: sdp.h
===================================================================
--- sdp.h	(revision 9441)
+++ sdp.h	(working copy)
@@ -65,7 +65,7 @@ struct sdp_bsdh {
 
 struct sdp_buf {
         struct sk_buff *skb;
-        dma_addr_t      mapping[SDP_MAX_SEND_SKB_FRAGS + 1];
+        u64		mapping[SDP_MAX_SEND_SKB_FRAGS + 1];
 };
 
 struct sdp_sock {
@@ -79,7 +79,6 @@ struct sdp_sock {
 	struct ib_qp *qp;
 	struct ib_cq *cq;
 	struct ib_mr *mr;
-	struct device *dma_device;
 	/* Like tcp_sock */
 	__u16 urg_data;
 	int offset; /* like seq in tcp */






More information about the general mailing list