RDS/IB: Remove ib_[header/data]_sge() functions
Andy Grover [Thu, 14 Jan 2010 00:32:24 +0000 (16:32 -0800)]
These functions were to cope with differently ordered
sg entries depending on RDS 3.0 or 3.1+. Now that
we've dropped 3.0 compatibility we no longer need them.

Also, modify usage sites for these to refer to sge[0] or [1]
directly. Reorder code to initialize header sgs first.

Signed-off-by: Andy Grover <andy.grover@oracle.com>

net/rds/ib.h
net/rds/ib_recv.c
net/rds/ib_send.c

index 426035a..dbf8d6e 100644 (file)
@@ -356,28 +356,4 @@ extern unsigned long rds_ib_sysctl_max_recv_allocation;
 extern unsigned int rds_ib_sysctl_flow_control;
 extern ctl_table rds_ib_sysctl_table[];
 
-/*
- * Helper functions for getting/setting the header and data SGEs in
- * RDS packets (not RDMA)
- *
- * From version 3.1 onwards, header is in front of data in the sge.
- */
-static inline struct ib_sge *
-rds_ib_header_sge(struct rds_ib_connection *ic, struct ib_sge *sge)
-{
-       if (ic->conn->c_version > RDS_PROTOCOL_3_0)
-               return &sge[0];
-       else
-               return &sge[1];
-}
-
-static inline struct ib_sge *
-rds_ib_data_sge(struct rds_ib_connection *ic, struct ib_sge *sge)
-{
-       if (ic->conn->c_version > RDS_PROTOCOL_3_0)
-               return &sge[1];
-       else
-               return &sge[0];
-}
-
 #endif
index a68a3a7..e9fe08a 100644 (file)
@@ -95,15 +95,15 @@ void rds_ib_recv_init_ring(struct rds_ib_connection *ic)
                recv->r_wr.sg_list = recv->r_sge;
                recv->r_wr.num_sge = RDS_IB_RECV_SGE;
 
-               sge = rds_ib_data_sge(ic, recv->r_sge);
-               sge->addr = 0;
-               sge->length = RDS_FRAG_SIZE;
-               sge->lkey = ic->i_mr->lkey;
-
-               sge = rds_ib_header_sge(ic, recv->r_sge);
+               sge = &recv->r_sge[0];
                sge->addr = ic->i_recv_hdrs_dma + (i * sizeof(struct rds_header));
                sge->length = sizeof(struct rds_header);
                sge->lkey = ic->i_mr->lkey;
+
+               sge = &recv->r_sge[1];
+               sge->addr = 0;
+               sge->length = RDS_FRAG_SIZE;
+               sge->lkey = ic->i_mr->lkey;
        }
 }
 
@@ -190,14 +190,14 @@ static int rds_ib_recv_refill_one(struct rds_connection *conn,
        recv->r_frag->f_offset = ic->i_frag.f_offset;
        recv->r_frag->f_mapped = dma_addr;
 
-       sge = rds_ib_data_sge(ic, recv->r_sge);
-       sge->addr = dma_addr;
-       sge->length = RDS_FRAG_SIZE;
-
-       sge = rds_ib_header_sge(ic, recv->r_sge);
+       sge = &recv->r_sge[0];
        sge->addr = ic->i_recv_hdrs_dma + (recv - ic->i_recvs) * sizeof(struct rds_header);
        sge->length = sizeof(struct rds_header);
 
+       sge = &recv->r_sge[1];
+       sge->addr = dma_addr;
+       sge->length = RDS_FRAG_SIZE;
+
        get_page(recv->r_frag->f_page);
 
        if (ic->i_frag.f_offset < RDS_PAGE_LAST_OFF) {
index e869084..46026d9 100644 (file)
@@ -156,18 +156,14 @@ void rds_ib_send_init_ring(struct rds_ib_connection *ic)
 
                send->s_wr.wr_id = i;
                send->s_wr.sg_list = send->s_sge;
-               send->s_wr.num_sge = 1;
-               send->s_wr.opcode = IB_WR_SEND;
-               send->s_wr.send_flags = 0;
                send->s_wr.ex.imm_data = 0;
 
-               sge = rds_ib_data_sge(ic, send->s_sge);
-               sge->lkey = ic->i_mr->lkey;
-
-               sge = rds_ib_header_sge(ic, send->s_sge);
+               sge = &send->s_sge[0];
                sge->addr = ic->i_send_hdrs_dma + (i * sizeof(struct rds_header));
                sge->length = sizeof(struct rds_header);
                sge->lkey = ic->i_mr->lkey;
+
+               send->s_sge[1].lkey = ic->i_mr->lkey;
        }
 }
 
@@ -441,28 +437,24 @@ rds_ib_xmit_populate_wr(struct rds_ib_connection *ic,
 
        send->s_wr.send_flags = send_flags;
        send->s_wr.opcode = IB_WR_SEND;
-       send->s_wr.num_sge = 2;
+       send->s_wr.num_sge = 1;
        send->s_wr.next = NULL;
        send->s_queued = jiffies;
        send->s_op = NULL;
 
+       sge = &send->s_sge[0];
+       sge->addr = ic->i_send_hdrs_dma + (pos * sizeof(struct rds_header));
+       sge->length = sizeof(struct rds_header);
+       sge->lkey = ic->i_mr->lkey;
+
        if (length != 0) {
-               sge = rds_ib_data_sge(ic, send->s_sge);
+               send->s_wr.num_sge = 2;
+
+               sge = &send->s_sge[1];
                sge->addr = buffer;
                sge->length = length;
                sge->lkey = ic->i_mr->lkey;
-
-               sge = rds_ib_header_sge(ic, send->s_sge);
-       } else {
-               /* We're sending a packet with no payload. There is only
-                * one SGE */
-               send->s_wr.num_sge = 1;
-               sge = &send->s_sge[0];
        }
-
-       sge->addr = ic->i_send_hdrs_dma + (pos * sizeof(struct rds_header));
-       sge->length = sizeof(struct rds_header);
-       sge->lkey = ic->i_mr->lkey;
 }
 
 /*