diff options
author | Andy Grover <andy.grover@oracle.com> | 2010-01-12 17:43:06 -0500 |
---|---|---|
committer | Andy Grover <andy.grover@oracle.com> | 2010-09-08 21:11:47 -0400 |
commit | 9c030391e8741695ff6114703e4edccccb634479 (patch) | |
tree | 20e1a55a0f952c85d07dc02662e1b85605464791 | |
parent | 809fa148a29467954280fe8b7f97c92403f6293c (diff) |
RDS/IB: eliminate duplicate code
both atomics and rdmas need to convert ib-specific completion codes
into RDS status codes. Rename rds_ib_rdma_send_complete to
rds_ib_send_complete, and have it take a pointer to the function to
call with the new error code.
Signed-off-by: Andy Grover <andy.grover@oracle.com>
-rw-r--r-- | net/rds/ib_send.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c index b2bd164434ad..d2516d3f87e2 100644 --- a/net/rds/ib_send.c +++ b/net/rds/ib_send.c | |||
@@ -38,8 +38,13 @@ | |||
38 | #include "rds.h" | 38 | #include "rds.h" |
39 | #include "ib.h" | 39 | #include "ib.h" |
40 | 40 | ||
41 | static void rds_ib_send_rdma_complete(struct rds_message *rm, | 41 | /* |
42 | int wc_status) | 42 | * Convert IB-specific error message to RDS error message and call core |
43 | * completion handler. | ||
44 | */ | ||
45 | static void rds_ib_send_complete(struct rds_message *rm, | ||
46 | int wc_status, | ||
47 | void (*complete)(struct rds_message *rm, int status)) | ||
43 | { | 48 | { |
44 | int notify_status; | 49 | int notify_status; |
45 | 50 | ||
@@ -59,20 +64,7 @@ static void rds_ib_send_rdma_complete(struct rds_message *rm, | |||
59 | notify_status = RDS_RDMA_OTHER_ERROR; | 64 | notify_status = RDS_RDMA_OTHER_ERROR; |
60 | break; | 65 | break; |
61 | } | 66 | } |
62 | rds_rdma_send_complete(rm, notify_status); | 67 | complete(rm, notify_status); |
63 | } | ||
64 | |||
65 | static void rds_ib_send_atomic_complete(struct rds_message *rm, | ||
66 | int wc_status) | ||
67 | { | ||
68 | int notify_status; | ||
69 | |||
70 | if (wc_status != IB_WC_SUCCESS) | ||
71 | notify_status = RDS_RDMA_OTHER_ERROR; | ||
72 | else | ||
73 | notify_status = RDS_RDMA_SUCCESS; | ||
74 | |||
75 | rds_atomic_send_complete(rm, notify_status); | ||
76 | } | 68 | } |
77 | 69 | ||
78 | static void rds_ib_send_unmap_rm(struct rds_ib_connection *ic, | 70 | static void rds_ib_send_unmap_rm(struct rds_ib_connection *ic, |
@@ -117,7 +109,7 @@ static void rds_ib_send_unmap_rm(struct rds_ib_connection *ic, | |||
117 | * operation itself unmapped the RDMA buffers, which takes care | 109 | * operation itself unmapped the RDMA buffers, which takes care |
118 | * of synching. | 110 | * of synching. |
119 | */ | 111 | */ |
120 | rds_ib_send_rdma_complete(rm, wc_status); | 112 | rds_ib_send_complete(rm, wc_status, rds_rdma_send_complete); |
121 | 113 | ||
122 | if (rm->rdma.m_rdma_op.r_write) | 114 | if (rm->rdma.m_rdma_op.r_write) |
123 | rds_stats_add(s_send_rdma_bytes, rm->rdma.m_rdma_op.r_bytes); | 115 | rds_stats_add(s_send_rdma_bytes, rm->rdma.m_rdma_op.r_bytes); |
@@ -135,7 +127,7 @@ static void rds_ib_send_unmap_rm(struct rds_ib_connection *ic, | |||
135 | op->op_mapped = 0; | 127 | op->op_mapped = 0; |
136 | } | 128 | } |
137 | 129 | ||
138 | rds_ib_send_atomic_complete(rm, wc_status); | 130 | rds_ib_send_complete(rm, wc_status, rds_atomic_send_complete); |
139 | 131 | ||
140 | if (rm->atomic.op_type == RDS_ATOMIC_TYPE_CSWP) | 132 | if (rm->atomic.op_type == RDS_ATOMIC_TYPE_CSWP) |
141 | rds_stats_inc(s_atomic_cswp); | 133 | rds_stats_inc(s_atomic_cswp); |
@@ -270,7 +262,7 @@ void rds_ib_send_cq_comp_handler(struct ib_cq *cq, void *context) | |||
270 | rm = rds_send_get_message(conn, send->s_op); | 262 | rm = rds_send_get_message(conn, send->s_op); |
271 | if (rm) { | 263 | if (rm) { |
272 | rds_ib_send_unmap_rm(ic, send, wc.status); | 264 | rds_ib_send_unmap_rm(ic, send, wc.status); |
273 | rds_ib_send_rdma_complete(rm, wc.status); | 265 | rds_ib_send_complete(rm, wc.status, rds_rdma_send_complete); |
274 | rds_message_put(rm); | 266 | rds_message_put(rm); |
275 | } | 267 | } |
276 | } | 268 | } |