aboutsummaryrefslogtreecommitdiffstats
path: root/net/rds/ib_cm.c
diff options
context:
space:
mode:
authorZach Brown <zach.brown@oracle.com>2010-07-14 17:01:21 -0400
committerAndy Grover <andy.grover@oracle.com>2010-09-08 21:16:43 -0400
commit1bde04a63d532c2540d6fdee0a661530a62b1686 (patch)
tree222d72e75824e25396b83e82bbd3769cc07599cc /net/rds/ib_cm.c
parent8576f374ac9537674e3cccb0a9d43fa2b7ebbf5b (diff)
RDS/IB: print IB event strings as well as their number
It's nice to not have to go digging in the code to see which event occurred. It's easy to throw together a quick array that maps the ib event enums to their strings. I didn't see anything in the stack that does this translation for us, but I also didn't look very hard. Signed-off-by: Zach Brown <zach.brown@oracle.com>
Diffstat (limited to 'net/rds/ib_cm.c')
-rw-r--r--net/rds/ib_cm.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 123c7d33b54e..0e2fea893a76 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -38,6 +38,38 @@
38#include "rds.h" 38#include "rds.h"
39#include "ib.h" 39#include "ib.h"
40 40
41static char *rds_ib_event_type_strings[] = {
42#define RDS_IB_EVENT_STRING(foo) [IB_EVENT_##foo] = __stringify(foo)
43 RDS_IB_EVENT_STRING(CQ_ERR),
44 RDS_IB_EVENT_STRING(QP_FATAL),
45 RDS_IB_EVENT_STRING(QP_REQ_ERR),
46 RDS_IB_EVENT_STRING(QP_ACCESS_ERR),
47 RDS_IB_EVENT_STRING(COMM_EST),
48 RDS_IB_EVENT_STRING(SQ_DRAINED),
49 RDS_IB_EVENT_STRING(PATH_MIG),
50 RDS_IB_EVENT_STRING(PATH_MIG_ERR),
51 RDS_IB_EVENT_STRING(DEVICE_FATAL),
52 RDS_IB_EVENT_STRING(PORT_ACTIVE),
53 RDS_IB_EVENT_STRING(PORT_ERR),
54 RDS_IB_EVENT_STRING(LID_CHANGE),
55 RDS_IB_EVENT_STRING(PKEY_CHANGE),
56 RDS_IB_EVENT_STRING(SM_CHANGE),
57 RDS_IB_EVENT_STRING(SRQ_ERR),
58 RDS_IB_EVENT_STRING(SRQ_LIMIT_REACHED),
59 RDS_IB_EVENT_STRING(QP_LAST_WQE_REACHED),
60 RDS_IB_EVENT_STRING(CLIENT_REREGISTER),
61#undef RDS_IB_EVENT_STRING
62};
63
64static char *rds_ib_event_str(enum ib_event_type type)
65{
66 if (type < ARRAY_SIZE(rds_ib_event_type_strings) &&
67 rds_ib_event_type_strings[type])
68 return rds_ib_event_type_strings[type];
69 else
70 return "unknown";
71};
72
41/* 73/*
42 * Set the selected protocol version 74 * Set the selected protocol version
43 */ 75 */
@@ -202,7 +234,8 @@ static void rds_ib_cm_fill_conn_param(struct rds_connection *conn,
202 234
203static void rds_ib_cq_event_handler(struct ib_event *event, void *data) 235static void rds_ib_cq_event_handler(struct ib_event *event, void *data)
204{ 236{
205 rdsdebug("event %u data %p\n", event->event, data); 237 rdsdebug("event %u (%s) data %p\n",
238 event->event, rds_ib_event_str(event->event), data);
206} 239}
207 240
208static void rds_ib_qp_event_handler(struct ib_event *event, void *data) 241static void rds_ib_qp_event_handler(struct ib_event *event, void *data)
@@ -210,16 +243,18 @@ static void rds_ib_qp_event_handler(struct ib_event *event, void *data)
210 struct rds_connection *conn = data; 243 struct rds_connection *conn = data;
211 struct rds_ib_connection *ic = conn->c_transport_data; 244 struct rds_ib_connection *ic = conn->c_transport_data;
212 245
213 rdsdebug("conn %p ic %p event %u\n", conn, ic, event->event); 246 rdsdebug("conn %p ic %p event %u (%s)\n", conn, ic, event->event,
247 rds_ib_event_str(event->event));
214 248
215 switch (event->event) { 249 switch (event->event) {
216 case IB_EVENT_COMM_EST: 250 case IB_EVENT_COMM_EST:
217 rdma_notify(ic->i_cm_id, IB_EVENT_COMM_EST); 251 rdma_notify(ic->i_cm_id, IB_EVENT_COMM_EST);
218 break; 252 break;
219 default: 253 default:
220 rdsdebug("Fatal QP Event %u " 254 rdsdebug("Fatal QP Event %u (%s) "
221 "- connection %pI4->%pI4, reconnecting\n", 255 "- connection %pI4->%pI4, reconnecting\n",
222 event->event, &conn->c_laddr, &conn->c_faddr); 256 event->event, rds_ib_event_str(event->event),
257 &conn->c_laddr, &conn->c_faddr);
223 rds_conn_drop(conn); 258 rds_conn_drop(conn);
224 break; 259 break;
225 } 260 }