33 #include <linux/kernel.h>
35 #include <linux/slab.h>
42 static char *rds_ib_event_type_strings[] = {
43 #define RDS_IB_EVENT_STRING(foo) \
44 [IB_EVENT_##foo] = __stringify(IB_EVENT_##foo)
63 #undef RDS_IB_EVENT_STRING
132 if (event->
param.
conn.private_data_len >=
sizeof(*dp)) {
133 dp =
event->param.conn.private_data;
137 rds_ib_set_protocol(conn,
146 " no longer supported\n",
171 rds_ib_tune_rnr(ic, &qp_attr);
192 static void rds_ib_cm_fill_conn_param(
struct rds_connection *conn,
196 u32 max_responder_resources,
197 u32 max_initiator_depth)
212 memset(dp, 0,
sizeof(*dp));
222 unsigned int credits;
236 rdsdebug(
"event %u (%s) data %p\n",
237 event->
event, rds_ib_event_str(event->
event), data);
240 static void rds_ib_qp_event_handler(
struct ib_event *event,
void *data)
245 rdsdebug(
"conn %p ic %p event %u (%s)\n", conn, ic, event->
event,
246 rds_ib_event_str(event->
event));
248 switch (event->
event) {
253 rdsdebug(
"Fatal QP Event %u (%s) "
254 "- connection %pI4->%pI4, reconnecting\n",
295 rds_ib_cq_event_handler, conn,
300 rdsdebug(
"ib_create_cq send failed: %d\n", ret);
305 rds_ib_cq_event_handler, conn,
310 rdsdebug(
"ib_create_cq recv failed: %d\n", ret);
316 rdsdebug(
"ib_req_notify_cq send failed: %d\n", ret);
322 rdsdebug(
"ib_req_notify_cq recv failed: %d\n", ret);
327 memset(&attr, 0,
sizeof(attr));
328 attr.event_handler = rds_ib_qp_event_handler;
329 attr.qp_context = conn;
346 rdsdebug(
"rdma_create_qp failed: %d\n", ret);
356 rdsdebug(
"ib_dma_alloc_coherent send failed\n");
366 rdsdebug(
"ib_dma_alloc_coherent recv failed\n");
374 rdsdebug(
"ib_dma_alloc_coherent ack failed\n");
382 rdsdebug(
"send allocation failed\n");
390 rdsdebug(
"recv allocation failed\n");
396 rdsdebug(
"conn %p pd %p mr %p cq %p %p\n", conn, ic->
i_pd, ic->
i_mr,
421 if (!event->
param.
conn.private_data_len) {
435 while ((common >>= 1) != 0)
439 "incompatible protocol version %u.%u\n",
449 __be64 lguid = cm_id->
route.path_rec->sgid.global.interface_id;
450 __be64 fguid = cm_id->
route.path_rec->dgid.global.interface_id;
460 version = rds_ib_protocol_compatible(event);
464 rdsdebug(
"saddr %pI4 daddr %pI4 RDSv%u.%u lguid 0x%llx fguid "
473 rdsdebug(
"rds_conn_create failed (%ld)\n", PTR_ERR(conn));
488 rdsdebug(
"incoming connect while connecting\n");
501 rds_ib_set_protocol(conn, version);
519 err = rds_ib_setup_qp(conn);
525 rds_ib_cm_fill_conn_param(conn, &conn_param, &dp_rep, version,
556 ret = rds_ib_setup_qp(conn);
592 rdsdebug(
"rdma_create_id() failed: %d\n", ret);
596 rdsdebug(
"created cm id %p for conn %p\n", ic->
i_cm_id, conn);
610 rdsdebug(
"addr resolve failed for cm id %p: %d\n", ic->
i_cm_id,
630 rdsdebug(
"cm %p pd %p cq %p %p qp %p\n", ic->
i_cm_id,
637 rdsdebug(
"disconnecting cm %p\n", ic->
i_cm_id);
643 rdsdebug(
"failed to disconnect, cm: %p err %d\n",
662 ib_dma_free_coherent(dev,
669 ib_dma_free_coherent(dev,
676 ib_dma_free_coherent(dev,
sizeof(
struct rds_header),
720 #ifdef KERNEL_HAS_ATOMIC64
766 #ifndef KERNEL_HAS_ATOMIC64
798 rdsdebug(
"ic %p\n", ic);
807 spin_lock_irq(lock_ptr);
809 spin_unlock_irq(lock_ptr);