diff options
author | Zach Brown <zach.brown@oracle.com> | 2010-08-03 16:52:47 -0400 |
---|---|---|
committer | Andy Grover <andy.grover@oracle.com> | 2010-09-08 21:16:50 -0400 |
commit | 59f740a6aeb2cde2f79fe0df38262d4c1ef35cd8 (patch) | |
tree | e05c12cc5c8892bcca3928deb62121b1ee4cedd0 | |
parent | 4518071ac1bcb76c64a55a3fddb39fb3d39add41 (diff) |
RDS/IB: print string constants in more places
This prints the constant identifier for work completion status and rdma
cm event types, like we already do for IB event types.
A core string array helper is added that each string type uses.
Signed-off-by: Zach Brown <zach.brown@oracle.com>
-rw-r--r-- | net/rds/af_rds.c | 9 | ||||
-rw-r--r-- | net/rds/ib.h | 1 | ||||
-rw-r--r-- | net/rds/ib_cm.c | 10 | ||||
-rw-r--r-- | net/rds/ib_recv.c | 12 | ||||
-rw-r--r-- | net/rds/ib_send.c | 47 | ||||
-rw-r--r-- | net/rds/rdma_transport.c | 38 | ||||
-rw-r--r-- | net/rds/rds.h | 1 |
7 files changed, 97 insertions, 21 deletions
diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c index 8e3886d353b5..bb6ad81b671d 100644 --- a/net/rds/af_rds.c +++ b/net/rds/af_rds.c | |||
@@ -40,6 +40,15 @@ | |||
40 | 40 | ||
41 | #include "rds.h" | 41 | #include "rds.h" |
42 | 42 | ||
43 | char *rds_str_array(char **array, size_t elements, size_t index) | ||
44 | { | ||
45 | if ((index < elements) && array[index]) | ||
46 | return array[index]; | ||
47 | else | ||
48 | return "unknown"; | ||
49 | } | ||
50 | EXPORT_SYMBOL(rds_str_array); | ||
51 | |||
43 | /* this is just used for stats gathering :/ */ | 52 | /* this is just used for stats gathering :/ */ |
44 | static DEFINE_SPINLOCK(rds_sock_lock); | 53 | static DEFINE_SPINLOCK(rds_sock_lock); |
45 | static unsigned long rds_sock_count; | 54 | static unsigned long rds_sock_count; |
diff --git a/net/rds/ib.h b/net/rds/ib.h index 2189fd47a738..7ad3d57e06a5 100644 --- a/net/rds/ib.h +++ b/net/rds/ib.h | |||
@@ -345,6 +345,7 @@ u32 rds_ib_ring_completed(struct rds_ib_work_ring *ring, u32 wr_id, u32 oldest); | |||
345 | extern wait_queue_head_t rds_ib_ring_empty_wait; | 345 | extern wait_queue_head_t rds_ib_ring_empty_wait; |
346 | 346 | ||
347 | /* ib_send.c */ | 347 | /* ib_send.c */ |
348 | char *rds_ib_wc_status_str(enum ib_wc_status status); | ||
348 | void rds_ib_xmit_complete(struct rds_connection *conn); | 349 | void rds_ib_xmit_complete(struct rds_connection *conn); |
349 | int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm, | 350 | int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm, |
350 | unsigned int hdr_off, unsigned int sg, unsigned int off); | 351 | unsigned int hdr_off, unsigned int sg, unsigned int off); |
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c index 0e2fea893a76..bc3dbc1ba61f 100644 --- a/net/rds/ib_cm.c +++ b/net/rds/ib_cm.c | |||
@@ -39,7 +39,8 @@ | |||
39 | #include "ib.h" | 39 | #include "ib.h" |
40 | 40 | ||
41 | static char *rds_ib_event_type_strings[] = { | 41 | static char *rds_ib_event_type_strings[] = { |
42 | #define RDS_IB_EVENT_STRING(foo) [IB_EVENT_##foo] = __stringify(foo) | 42 | #define RDS_IB_EVENT_STRING(foo) \ |
43 | [IB_EVENT_##foo] = __stringify(IB_EVENT_##foo) | ||
43 | RDS_IB_EVENT_STRING(CQ_ERR), | 44 | RDS_IB_EVENT_STRING(CQ_ERR), |
44 | RDS_IB_EVENT_STRING(QP_FATAL), | 45 | RDS_IB_EVENT_STRING(QP_FATAL), |
45 | RDS_IB_EVENT_STRING(QP_REQ_ERR), | 46 | RDS_IB_EVENT_STRING(QP_REQ_ERR), |
@@ -63,11 +64,8 @@ static char *rds_ib_event_type_strings[] = { | |||
63 | 64 | ||
64 | static char *rds_ib_event_str(enum ib_event_type type) | 65 | static char *rds_ib_event_str(enum ib_event_type type) |
65 | { | 66 | { |
66 | if (type < ARRAY_SIZE(rds_ib_event_type_strings) && | 67 | return rds_str_array(rds_ib_event_type_strings, |
67 | rds_ib_event_type_strings[type]) | 68 | ARRAY_SIZE(rds_ib_event_type_strings), type); |
68 | return rds_ib_event_type_strings[type]; | ||
69 | else | ||
70 | return "unknown"; | ||
71 | }; | 69 | }; |
72 | 70 | ||
73 | /* | 71 | /* |
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c index a2f5f6faf35c..e29e0ca32f74 100644 --- a/net/rds/ib_recv.c +++ b/net/rds/ib_recv.c | |||
@@ -966,8 +966,9 @@ static inline void rds_poll_cq(struct rds_ib_connection *ic, | |||
966 | struct rds_ib_recv_work *recv; | 966 | struct rds_ib_recv_work *recv; |
967 | 967 | ||
968 | while (ib_poll_cq(ic->i_recv_cq, 1, &wc) > 0) { | 968 | while (ib_poll_cq(ic->i_recv_cq, 1, &wc) > 0) { |
969 | rdsdebug("wc wr_id 0x%llx status %u byte_len %u imm_data %u\n", | 969 | rdsdebug("wc wr_id 0x%llx status %u (%s) byte_len %u imm_data %u\n", |
970 | (unsigned long long)wc.wr_id, wc.status, wc.byte_len, | 970 | (unsigned long long)wc.wr_id, wc.status, |
971 | rds_ib_wc_status_str(wc.status), wc.byte_len, | ||
971 | be32_to_cpu(wc.ex.imm_data)); | 972 | be32_to_cpu(wc.ex.imm_data)); |
972 | rds_ib_stats_inc(s_ib_rx_cq_event); | 973 | rds_ib_stats_inc(s_ib_rx_cq_event); |
973 | 974 | ||
@@ -985,10 +986,11 @@ static inline void rds_poll_cq(struct rds_ib_connection *ic, | |||
985 | } else { | 986 | } else { |
986 | /* We expect errors as the qp is drained during shutdown */ | 987 | /* We expect errors as the qp is drained during shutdown */ |
987 | if (rds_conn_up(conn) || rds_conn_connecting(conn)) | 988 | if (rds_conn_up(conn) || rds_conn_connecting(conn)) |
988 | rds_ib_conn_error(conn, "recv completion on " | 989 | rds_ib_conn_error(conn, "recv completion on %pI4 had " |
989 | "%pI4 had status %u, disconnecting and " | 990 | "status %u (%s), disconnecting and " |
990 | "reconnecting\n", &conn->c_faddr, | 991 | "reconnecting\n", &conn->c_faddr, |
991 | wc.status); | 992 | wc.status, |
993 | rds_ib_wc_status_str(wc.status)); | ||
992 | } | 994 | } |
993 | 995 | ||
994 | /* | 996 | /* |
diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c index 15f75692574c..808544aebb70 100644 --- a/net/rds/ib_send.c +++ b/net/rds/ib_send.c | |||
@@ -38,6 +38,40 @@ | |||
38 | #include "rds.h" | 38 | #include "rds.h" |
39 | #include "ib.h" | 39 | #include "ib.h" |
40 | 40 | ||
41 | static char *rds_ib_wc_status_strings[] = { | ||
42 | #define RDS_IB_WC_STATUS_STR(foo) \ | ||
43 | [IB_WC_##foo] = __stringify(IB_WC_##foo) | ||
44 | RDS_IB_WC_STATUS_STR(SUCCESS), | ||
45 | RDS_IB_WC_STATUS_STR(LOC_LEN_ERR), | ||
46 | RDS_IB_WC_STATUS_STR(LOC_QP_OP_ERR), | ||
47 | RDS_IB_WC_STATUS_STR(LOC_EEC_OP_ERR), | ||
48 | RDS_IB_WC_STATUS_STR(LOC_PROT_ERR), | ||
49 | RDS_IB_WC_STATUS_STR(WR_FLUSH_ERR), | ||
50 | RDS_IB_WC_STATUS_STR(MW_BIND_ERR), | ||
51 | RDS_IB_WC_STATUS_STR(BAD_RESP_ERR), | ||
52 | RDS_IB_WC_STATUS_STR(LOC_ACCESS_ERR), | ||
53 | RDS_IB_WC_STATUS_STR(REM_INV_REQ_ERR), | ||
54 | RDS_IB_WC_STATUS_STR(REM_ACCESS_ERR), | ||
55 | RDS_IB_WC_STATUS_STR(REM_OP_ERR), | ||
56 | RDS_IB_WC_STATUS_STR(RETRY_EXC_ERR), | ||
57 | RDS_IB_WC_STATUS_STR(RNR_RETRY_EXC_ERR), | ||
58 | RDS_IB_WC_STATUS_STR(LOC_RDD_VIOL_ERR), | ||
59 | RDS_IB_WC_STATUS_STR(REM_INV_RD_REQ_ERR), | ||
60 | RDS_IB_WC_STATUS_STR(REM_ABORT_ERR), | ||
61 | RDS_IB_WC_STATUS_STR(INV_EECN_ERR), | ||
62 | RDS_IB_WC_STATUS_STR(INV_EEC_STATE_ERR), | ||
63 | RDS_IB_WC_STATUS_STR(FATAL_ERR), | ||
64 | RDS_IB_WC_STATUS_STR(RESP_TIMEOUT_ERR), | ||
65 | RDS_IB_WC_STATUS_STR(GENERAL_ERR), | ||
66 | #undef RDS_IB_WC_STATUS_STR | ||
67 | }; | ||
68 | |||
69 | char *rds_ib_wc_status_str(enum ib_wc_status status) | ||
70 | { | ||
71 | return rds_str_array(rds_ib_wc_status_strings, | ||
72 | ARRAY_SIZE(rds_ib_wc_status_strings), status); | ||
73 | } | ||
74 | |||
41 | /* | 75 | /* |
42 | * Convert IB-specific error message to RDS error message and call core | 76 | * Convert IB-specific error message to RDS error message and call core |
43 | * completion handler. | 77 | * completion handler. |
@@ -257,8 +291,9 @@ void rds_ib_send_cq_comp_handler(struct ib_cq *cq, void *context) | |||
257 | rdsdebug("ib_req_notify_cq send failed: %d\n", ret); | 291 | rdsdebug("ib_req_notify_cq send failed: %d\n", ret); |
258 | 292 | ||
259 | while (ib_poll_cq(cq, 1, &wc) > 0) { | 293 | while (ib_poll_cq(cq, 1, &wc) > 0) { |
260 | rdsdebug("wc wr_id 0x%llx status %u byte_len %u imm_data %u\n", | 294 | rdsdebug("wc wr_id 0x%llx status %u (%s) byte_len %u imm_data %u\n", |
261 | (unsigned long long)wc.wr_id, wc.status, wc.byte_len, | 295 | (unsigned long long)wc.wr_id, wc.status, |
296 | rds_ib_wc_status_str(wc.status), wc.byte_len, | ||
262 | be32_to_cpu(wc.ex.imm_data)); | 297 | be32_to_cpu(wc.ex.imm_data)); |
263 | rds_ib_stats_inc(s_ib_tx_cq_event); | 298 | rds_ib_stats_inc(s_ib_tx_cq_event); |
264 | 299 | ||
@@ -306,10 +341,10 @@ void rds_ib_send_cq_comp_handler(struct ib_cq *cq, void *context) | |||
306 | 341 | ||
307 | /* We expect errors as the qp is drained during shutdown */ | 342 | /* We expect errors as the qp is drained during shutdown */ |
308 | if (wc.status != IB_WC_SUCCESS && rds_conn_up(conn)) { | 343 | if (wc.status != IB_WC_SUCCESS && rds_conn_up(conn)) { |
309 | rds_ib_conn_error(conn, | 344 | rds_ib_conn_error(conn, "send completion on %pI4 had status " |
310 | "send completion on %pI4 " | 345 | "%u (%s), disconnecting and reconnecting\n", |
311 | "had status %u, disconnecting and reconnecting\n", | 346 | &conn->c_faddr, wc.status, |
312 | &conn->c_faddr, wc.status); | 347 | rds_ib_wc_status_str(wc.status)); |
313 | } | 348 | } |
314 | } | 349 | } |
315 | } | 350 | } |
diff --git a/net/rds/rdma_transport.c b/net/rds/rdma_transport.c index 550d34837fe7..e6ed10aee190 100644 --- a/net/rds/rdma_transport.c +++ b/net/rds/rdma_transport.c | |||
@@ -36,6 +36,34 @@ | |||
36 | 36 | ||
37 | static struct rdma_cm_id *rds_rdma_listen_id; | 37 | static struct rdma_cm_id *rds_rdma_listen_id; |
38 | 38 | ||
39 | static char *rds_cm_event_strings[] = { | ||
40 | #define RDS_CM_EVENT_STRING(foo) \ | ||
41 | [RDMA_CM_EVENT_##foo] = __stringify(RDMA_CM_EVENT_##foo) | ||
42 | RDS_CM_EVENT_STRING(ADDR_RESOLVED), | ||
43 | RDS_CM_EVENT_STRING(ADDR_ERROR), | ||
44 | RDS_CM_EVENT_STRING(ROUTE_RESOLVED), | ||
45 | RDS_CM_EVENT_STRING(ROUTE_ERROR), | ||
46 | RDS_CM_EVENT_STRING(CONNECT_REQUEST), | ||
47 | RDS_CM_EVENT_STRING(CONNECT_RESPONSE), | ||
48 | RDS_CM_EVENT_STRING(CONNECT_ERROR), | ||
49 | RDS_CM_EVENT_STRING(UNREACHABLE), | ||
50 | RDS_CM_EVENT_STRING(REJECTED), | ||
51 | RDS_CM_EVENT_STRING(ESTABLISHED), | ||
52 | RDS_CM_EVENT_STRING(DISCONNECTED), | ||
53 | RDS_CM_EVENT_STRING(DEVICE_REMOVAL), | ||
54 | RDS_CM_EVENT_STRING(MULTICAST_JOIN), | ||
55 | RDS_CM_EVENT_STRING(MULTICAST_ERROR), | ||
56 | RDS_CM_EVENT_STRING(ADDR_CHANGE), | ||
57 | RDS_CM_EVENT_STRING(TIMEWAIT_EXIT), | ||
58 | #undef RDS_CM_EVENT_STRING | ||
59 | }; | ||
60 | |||
61 | static char *rds_cm_event_str(enum rdma_cm_event_type type) | ||
62 | { | ||
63 | return rds_str_array(rds_cm_event_strings, | ||
64 | ARRAY_SIZE(rds_cm_event_strings), type); | ||
65 | }; | ||
66 | |||
39 | int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id, | 67 | int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id, |
40 | struct rdma_cm_event *event) | 68 | struct rdma_cm_event *event) |
41 | { | 69 | { |
@@ -44,8 +72,8 @@ int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id, | |||
44 | struct rds_transport *trans; | 72 | struct rds_transport *trans; |
45 | int ret = 0; | 73 | int ret = 0; |
46 | 74 | ||
47 | rdsdebug("conn %p id %p handling event %u\n", conn, cm_id, | 75 | rdsdebug("conn %p id %p handling event %u (%s)\n", conn, cm_id, |
48 | event->event); | 76 | event->event, rds_cm_event_str(event->event)); |
49 | 77 | ||
50 | if (cm_id->device->node_type == RDMA_NODE_RNIC) | 78 | if (cm_id->device->node_type == RDMA_NODE_RNIC) |
51 | trans = &rds_iw_transport; | 79 | trans = &rds_iw_transport; |
@@ -109,7 +137,8 @@ int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id, | |||
109 | 137 | ||
110 | default: | 138 | default: |
111 | /* things like device disconnect? */ | 139 | /* things like device disconnect? */ |
112 | printk(KERN_ERR "RDS: unknown event %u!\n", event->event); | 140 | printk(KERN_ERR "RDS: unknown event %u (%s)!\n", |
141 | event->event, rds_cm_event_str(event->event)); | ||
113 | break; | 142 | break; |
114 | } | 143 | } |
115 | 144 | ||
@@ -117,7 +146,8 @@ out: | |||
117 | if (conn) | 146 | if (conn) |
118 | mutex_unlock(&conn->c_cm_lock); | 147 | mutex_unlock(&conn->c_cm_lock); |
119 | 148 | ||
120 | rdsdebug("id %p event %u handling ret %d\n", cm_id, event->event, ret); | 149 | rdsdebug("id %p event %u (%s) handling ret %d\n", cm_id, event->event, |
150 | rds_cm_event_str(event->event), ret); | ||
121 | 151 | ||
122 | return ret; | 152 | return ret; |
123 | } | 153 | } |
diff --git a/net/rds/rds.h b/net/rds/rds.h index aab5e949fa93..aadaddba88a7 100644 --- a/net/rds/rds.h +++ b/net/rds/rds.h | |||
@@ -566,6 +566,7 @@ struct rds_statistics { | |||
566 | }; | 566 | }; |
567 | 567 | ||
568 | /* af_rds.c */ | 568 | /* af_rds.c */ |
569 | char *rds_str_array(char **array, size_t elements, size_t index); | ||
569 | void rds_sock_addref(struct rds_sock *rs); | 570 | void rds_sock_addref(struct rds_sock *rs); |
570 | void rds_sock_put(struct rds_sock *rs); | 571 | void rds_sock_put(struct rds_sock *rs); |
571 | void rds_wake_sk_sleep(struct rds_sock *rs); | 572 | void rds_wake_sk_sleep(struct rds_sock *rs); |