[openib-general] [PATCH] sdpc_buff trivial changes

Michael S. Tsirkin mst at mellanox.co.il
Tue May 10 03:00:21 PDT 2005


struct sdpc_buff has a copy of ib_sge and uses casts to turn that into
a real ib_sge. The right thing is obviously to keep ib_sge
as part of sdpc_buff.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: ulp/sdp/sdp_buff.h
===================================================================
--- ulp/sdp/sdp_buff.h	(revision 2292)
+++ ulp/sdp/sdp_buff.h	(working copy)
@@ -71,9 +71,7 @@ struct sdpc_buff {
 	 * IB specific data (The main buffer pool sets the lkey when 
 	 * it is created)
 	 */
-	u64 real; /* component of scather/gather list (address) */
-	u32 size; /* component of scather/gather list (lenght)  */
-	u32 lkey; /* component of scather/gather list (key) */
+	struct ib_sge sge;
 };
 
 struct sdpc_buff_root {
@@ -112,13 +110,7 @@ struct sdpc_buff_root {
 #define SDP_BUFF_F_GET_UNSIG(buff) ((buff)->flags &    SDP_BUFF_F_UNSIG)
 #define SDP_BUFF_F_SET_UNSIG(buff) ((buff)->flags |=   SDP_BUFF_F_UNSIG)
 #define SDP_BUFF_F_CLR_UNSIG(buff) ((buff)->flags &= (~SDP_BUFF_F_UNSIG))
-/*
- * data accessors.
- */
-#define SDP_BUFF_GAT_SCAT(buff)                   \
-   ({ (buff)->real = virt_to_phys((buff)->data);  \
-      (buff)->size = (buff)->tail - (buff)->data; \
-      (struct ib_sge *)(&(buff)->real); })
+
 /*
  * pool size
  */
Index: ulp/sdp/sdp_rcvd.c
===================================================================
--- ulp/sdp/sdp_rcvd.c	(revision 2292)
+++ ulp/sdp/sdp_rcvd.c	(working copy)
@@ -1137,7 +1137,7 @@ int sdp_event_recv(struct sdp_opt *conn,
 	}
 
 	dma_unmap_single(conn->ca->dma_device,
-			 buff->real, 
+			 buff->sge.addr, 
 			 buff->tail - buff->data,
 			 PCI_DMA_FROMDEVICE);
 
Index: ulp/sdp/sdp_send.c
===================================================================
--- ulp/sdp/sdp_send.c	(revision 2292)
+++ ulp/sdp/sdp_send.c	(working copy)
@@ -57,7 +57,7 @@ static int sdp_send_buff_post(struct sdp
 	conn->oob_offset -= (conn->oob_offset > 0) ? buff->data_size : 0;
 
 	buff->wrid = conn->send_wrid++;
-	buff->lkey = conn->l_key;
+	buff->sge.lkey = conn->l_key;
 	buff->bsdh_hdr->recv_bufs = conn->l_advt_bf;
 	buff->bsdh_hdr->size = buff->tail - buff->data;
 	buff->bsdh_hdr->seq_num = ++conn->send_seq;
@@ -136,14 +136,14 @@ static int sdp_send_buff_post(struct sdp
 	/*
 	 * post send
 	 */
- 	buff->size = buff->tail - buff->data;
- 	buff->real = dma_map_single(conn->ca->dma_device,
+ 	buff->sge.length = buff->tail - buff->data;
+ 	buff->sge.addr = dma_map_single(conn->ca->dma_device,
 				    buff->data,
- 				    buff->size,
+ 				    buff->sge.length,
  				    PCI_DMA_TODEVICE);
 	send_param.next    = NULL;
 	send_param.wr_id   = buff->wrid;
- 	send_param.sg_list = (struct ib_sge *)&buff->real;
+ 	send_param.sg_list = &buff->sge;
 	send_param.num_sge = 1;
 	send_param.opcode  = IB_WR_SEND;
 
@@ -350,7 +350,7 @@ static int sdp_send_data_buff_snk(struct
 	send_param.send_flags          = IB_SEND_SIGNALED;
 
 	buff->wrid = conn->send_wrid++;
-	buff->lkey = conn->l_key;
+	buff->sge.lkey = conn->l_key;
 
 	advt->wrid  = buff->wrid;
 	advt->size -= (buff->tail - buff->data);
@@ -382,9 +382,12 @@ static int sdp_send_data_buff_snk(struct
 	/*
 	 * post RDMA
 	 */
+	buff->sge.addr     = virt_to_phys(buff->data);
+	buff->sge.length   = buff->tail - buff->data;
+
 	send_param.next    = NULL;
 	send_param.wr_id   = buff->wrid;
-	send_param.sg_list = SDP_BUFF_GAT_SCAT(buff);
+	send_param.sg_list = &buff->sge;
 	send_param.num_sge = 1;
 
 	result = ib_post_send(conn->qp, &send_param, &bad_wr);
Index: ulp/sdp/sdp_recv.c
===================================================================
--- ulp/sdp/sdp_recv.c	(revision 2292)
+++ ulp/sdp/sdp_recv.c	(working copy)
@@ -65,7 +65,7 @@ static int sdp_post_recv_buff(struct sdp
 	 */
 	buff->tail = buff->end;
 	buff->data = buff->tail - conn->recv_size;
-	buff->lkey = conn->l_key;
+	buff->sge.lkey = conn->l_key;
 	buff->wrid = conn->recv_wrid++;
 
 	conn->l_recv_bf++;
@@ -86,14 +86,14 @@ static int sdp_post_recv_buff(struct sdp
 	/*
 	 * post recv
 	 */
- 	buff->size = buff->tail - buff->data;
- 	buff->real = dma_map_single(conn->ca->dma_device,
+ 	buff->sge.length = buff->tail - buff->data;
+ 	buff->sge.addr = dma_map_single(conn->ca->dma_device,
 				    buff->data,
- 				    buff->size,
+ 				    buff->sge.length,
  				    PCI_DMA_FROMDEVICE);
 	receive_param.next       = NULL;
 	receive_param.wr_id      = buff->wrid;
-	receive_param.sg_list    = (struct ib_sge *)&buff->real;
+	receive_param.sg_list    = &buff->sge;
 	receive_param.num_sge    = 1;
 
 	result = ib_post_recv(conn->qp, &receive_param, &bad_wr);
@@ -155,7 +155,7 @@ static int sdp_post_rdma_buff(struct sdp
 	 */
 	buff->tail  = buff->end;
 	buff->data = buff->tail - min((s32)conn->recv_size, advt->size);
-	buff->lkey = conn->l_key;
+	buff->sge.lkey = conn->l_key;
 	buff->wrid = conn->send_wrid++;
 
 	send_param.opcode              = IB_WR_RDMA_READ;
@@ -196,9 +196,12 @@ static int sdp_post_rdma_buff(struct sdp
 	/*
 	 * post rdma
 	 */
-	send_param.next = NULL;
-	send_param.wr_id = buff->wrid;
-	send_param.sg_list = SDP_BUFF_GAT_SCAT(buff);
+	buff->sge.addr     = virt_to_phys(buff->data);
+	buff->sge.length   = buff->tail - buff->data;
+
+	send_param.next    = NULL;
+	send_param.wr_id   = buff->wrid;
+	send_param.sg_list = &buff->sge;
 	send_param.num_sge = 1;
 
 	result = ib_post_send(conn->qp, &send_param, &bad_wr);
Index: ulp/sdp/sdp_sent.c
===================================================================
--- ulp/sdp/sdp_sent.c	(revision 2292)
+++ ulp/sdp/sdp_sent.c	(working copy)
@@ -380,7 +380,7 @@ int sdp_event_send(struct sdp_opt *conn,
 		}
 
 		dma_unmap_single(conn->ca->dma_device,
-				 buff->real, buff->tail - buff->data,
+				 buff->sge.addr, buff->tail - buff->data,
 				 PCI_DMA_TODEVICE);
 
 		/*
Index: ulp/sdp/sdp_buff.c
===================================================================
--- ulp/sdp/sdp_buff.c	(revision 2292)
+++ ulp/sdp/sdp_buff.c	(working copy)
@@ -321,7 +321,7 @@ void sdp_buff_q_clear_unmap(struct sdpc_
 
 	while ((buff = do_buff_q_get(pool, 0, NULL, NULL))) {
 		if (dev)
-			dma_unmap_single(dev, buff->real,
+			dma_unmap_single(dev, buff->sge.addr,
 					 buff->tail - buff->data, direction);
 
 		result = sdp_buff_pool_put(buff);
@@ -418,15 +418,15 @@ static int sdp_buff_pool_alloc(struct sd
 			break;
 		}
 		
-		buff->end     = buff->head + PAGE_SIZE;
-		buff->data    = buff->head;
-		buff->tail    = buff->head;
-		buff->lkey    = 0;
-		buff->real    = 0;
-		buff->size    = 0;
-		buff->pool    = NULL;
-		buff->type    = SDP_DESC_TYPE_BUFF;
-		buff->release = sdp_buff_pool_put;
+		buff->end         = buff->head + PAGE_SIZE;
+		buff->data        = buff->head;
+		buff->tail        = buff->head;
+		buff->sge.lkey    = 0;
+		buff->sge.addr    = 0;
+		buff->sge.length  = 0;
+		buff->pool        = NULL;
+		buff->type        = SDP_DESC_TYPE_BUFF;
+		buff->release     = sdp_buff_pool_put;
 
 		result = sdp_buff_q_put(&m_pool->pool, buff);
 		if (result < 0) {
@@ -619,7 +619,7 @@ struct sdpc_buff *sdp_buff_pool_get(void
 	 */
 	buff->bsdh_hdr = NULL;
 	buff->flags = 0;
-	buff->lkey = 0;
+	buff->sge.lkey = 0;
 
 	buff->data_size = 0;
 	buff->wrid = 0;

-- 
MST - Michael S. Tsirkin



More information about the general mailing list