2 * Copyright (c) 2006 Oracle. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #include <linux/kernel.h>
35 #include <linux/vmalloc.h>
41 * Set the selected protocol version
43 static void rds_ib_set_protocol(struct rds_connection
*conn
, unsigned int version
)
45 conn
->c_version
= version
;
51 static void rds_ib_set_flow_control(struct rds_connection
*conn
, u32 credits
)
53 struct rds_ib_connection
*ic
= conn
->c_transport_data
;
55 if (rds_ib_sysctl_flow_control
&& credits
!= 0) {
56 /* We're doing flow control */
58 rds_ib_send_add_credits(conn
, credits
);
65 * Tune RNR behavior. Without flow control, we use a rather
66 * low timeout, but not the absolute minimum - this should
69 * We already set the RNR retry count to 7 (which is the
70 * smallest infinite number :-) above.
71 * If flow control is off, we want to change this back to 0
72 * so that we learn quickly when our credit accounting is
75 * Caller passes in a qp_attr pointer - don't waste stack spacv
76 * by allocation this twice.
79 rds_ib_tune_rnr(struct rds_ib_connection
*ic
, struct ib_qp_attr
*attr
)
83 attr
->min_rnr_timer
= IB_RNR_TIMER_000_32
;
84 ret
= ib_modify_qp(ic
->i_cm_id
->qp
, attr
, IB_QP_MIN_RNR_TIMER
);
86 printk(KERN_NOTICE
"ib_modify_qp(IB_QP_MIN_RNR_TIMER): err=%d\n", -ret
);
90 * Connection established.
91 * We get here for both outgoing and incoming connection.
93 void rds_ib_cm_connect_complete(struct rds_connection
*conn
, struct rdma_cm_event
*event
)
95 const struct rds_ib_connect_private
*dp
= NULL
;
96 struct rds_ib_connection
*ic
= conn
->c_transport_data
;
97 struct rds_ib_device
*rds_ibdev
;
98 struct ib_qp_attr qp_attr
;
101 if (event
->param
.conn
.private_data_len
) {
102 dp
= event
->param
.conn
.private_data
;
104 rds_ib_set_protocol(conn
,
105 RDS_PROTOCOL(dp
->dp_protocol_major
,
106 dp
->dp_protocol_minor
));
107 rds_ib_set_flow_control(conn
, be32_to_cpu(dp
->dp_credit
));
110 printk(KERN_NOTICE
"RDS/IB: connected to %pI4 version %u.%u%s\n",
112 RDS_PROTOCOL_MAJOR(conn
->c_version
),
113 RDS_PROTOCOL_MINOR(conn
->c_version
),
114 ic
->i_flowctl
? ", flow control" : "");
116 /* Tune RNR behavior */
117 rds_ib_tune_rnr(ic
, &qp_attr
);
119 qp_attr
.qp_state
= IB_QPS_RTS
;
120 err
= ib_modify_qp(ic
->i_cm_id
->qp
, &qp_attr
, IB_QP_STATE
);
122 printk(KERN_NOTICE
"ib_modify_qp(IB_QP_STATE, RTS): err=%d\n", err
);
124 /* update ib_device with this local ipaddr & conn */
125 rds_ibdev
= ib_get_client_data(ic
->i_cm_id
->device
, &rds_ib_client
);
126 err
= rds_ib_update_ipaddr(rds_ibdev
, conn
->c_laddr
);
128 printk(KERN_ERR
"rds_ib_update_ipaddr failed (%d)\n", err
);
129 rds_ib_add_conn(rds_ibdev
, conn
);
131 /* If the peer gave us the last packet it saw, process this as if
132 * we had received a regular ACK. */
133 if (dp
&& dp
->dp_ack_seq
)
134 rds_send_drop_acked(conn
, be64_to_cpu(dp
->dp_ack_seq
), NULL
);
136 rds_connect_complete(conn
);
139 static void rds_ib_cm_fill_conn_param(struct rds_connection
*conn
,
140 struct rdma_conn_param
*conn_param
,
141 struct rds_ib_connect_private
*dp
,
142 u32 protocol_version
)
144 memset(conn_param
, 0, sizeof(struct rdma_conn_param
));
145 /* XXX tune these? */
146 conn_param
->responder_resources
= 1;
147 conn_param
->initiator_depth
= 1;
148 conn_param
->retry_count
= 7;
149 conn_param
->rnr_retry_count
= 7;
152 struct rds_ib_connection
*ic
= conn
->c_transport_data
;
154 memset(dp
, 0, sizeof(*dp
));
155 dp
->dp_saddr
= conn
->c_laddr
;
156 dp
->dp_daddr
= conn
->c_faddr
;
157 dp
->dp_protocol_major
= RDS_PROTOCOL_MAJOR(protocol_version
);
158 dp
->dp_protocol_minor
= RDS_PROTOCOL_MINOR(protocol_version
);
159 dp
->dp_protocol_minor_mask
= cpu_to_be16(RDS_IB_SUPPORTED_PROTOCOLS
);
160 dp
->dp_ack_seq
= rds_ib_piggyb_ack(ic
);
162 /* Advertise flow control */
164 unsigned int credits
;
166 credits
= IB_GET_POST_CREDITS(atomic_read(&ic
->i_credits
));
167 dp
->dp_credit
= cpu_to_be32(credits
);
168 atomic_sub(IB_SET_POST_CREDITS(credits
), &ic
->i_credits
);
171 conn_param
->private_data
= dp
;
172 conn_param
->private_data_len
= sizeof(*dp
);
176 static void rds_ib_cq_event_handler(struct ib_event
*event
, void *data
)
178 rdsdebug("event %u data %p\n", event
->event
, data
);
181 static void rds_ib_qp_event_handler(struct ib_event
*event
, void *data
)
183 struct rds_connection
*conn
= data
;
184 struct rds_ib_connection
*ic
= conn
->c_transport_data
;
186 rdsdebug("conn %p ic %p event %u\n", conn
, ic
, event
->event
);
188 switch (event
->event
) {
189 case IB_EVENT_COMM_EST
:
190 rdma_notify(ic
->i_cm_id
, IB_EVENT_COMM_EST
);
193 printk(KERN_WARNING
"RDS/ib: unhandled QP event %u "
194 "on connection to %pI4\n", event
->event
,
201 * This needs to be very careful to not leave IS_ERR pointers around for
202 * cleanup to trip over.
204 static int rds_ib_setup_qp(struct rds_connection
*conn
)
206 struct rds_ib_connection
*ic
= conn
->c_transport_data
;
207 struct ib_device
*dev
= ic
->i_cm_id
->device
;
208 struct ib_qp_init_attr attr
;
209 struct rds_ib_device
*rds_ibdev
;
212 /* rds_ib_add_one creates a rds_ib_device object per IB device,
213 * and allocates a protection domain, memory range and FMR pool
214 * for each. If that fails for any reason, it will not register
215 * the rds_ibdev at all.
217 rds_ibdev
= ib_get_client_data(dev
, &rds_ib_client
);
218 if (rds_ibdev
== NULL
) {
219 if (printk_ratelimit())
220 printk(KERN_NOTICE
"RDS/IB: No client_data for device %s\n",
225 if (rds_ibdev
->max_wrs
< ic
->i_send_ring
.w_nr
+ 1)
226 rds_ib_ring_resize(&ic
->i_send_ring
, rds_ibdev
->max_wrs
- 1);
227 if (rds_ibdev
->max_wrs
< ic
->i_recv_ring
.w_nr
+ 1)
228 rds_ib_ring_resize(&ic
->i_recv_ring
, rds_ibdev
->max_wrs
- 1);
230 /* Protection domain and memory range */
231 ic
->i_pd
= rds_ibdev
->pd
;
232 ic
->i_mr
= rds_ibdev
->mr
;
234 ic
->i_send_cq
= ib_create_cq(dev
, rds_ib_send_cq_comp_handler
,
235 rds_ib_cq_event_handler
, conn
,
236 ic
->i_send_ring
.w_nr
+ 1, 0);
237 if (IS_ERR(ic
->i_send_cq
)) {
238 ret
= PTR_ERR(ic
->i_send_cq
);
239 ic
->i_send_cq
= NULL
;
240 rdsdebug("ib_create_cq send failed: %d\n", ret
);
244 ic
->i_recv_cq
= ib_create_cq(dev
, rds_ib_recv_cq_comp_handler
,
245 rds_ib_cq_event_handler
, conn
,
246 ic
->i_recv_ring
.w_nr
, 0);
247 if (IS_ERR(ic
->i_recv_cq
)) {
248 ret
= PTR_ERR(ic
->i_recv_cq
);
249 ic
->i_recv_cq
= NULL
;
250 rdsdebug("ib_create_cq recv failed: %d\n", ret
);
254 ret
= ib_req_notify_cq(ic
->i_send_cq
, IB_CQ_NEXT_COMP
);
256 rdsdebug("ib_req_notify_cq send failed: %d\n", ret
);
260 ret
= ib_req_notify_cq(ic
->i_recv_cq
, IB_CQ_SOLICITED
);
262 rdsdebug("ib_req_notify_cq recv failed: %d\n", ret
);
266 /* XXX negotiate max send/recv with remote? */
267 memset(&attr
, 0, sizeof(attr
));
268 attr
.event_handler
= rds_ib_qp_event_handler
;
269 attr
.qp_context
= conn
;
270 /* + 1 to allow for the single ack message */
271 attr
.cap
.max_send_wr
= ic
->i_send_ring
.w_nr
+ 1;
272 attr
.cap
.max_recv_wr
= ic
->i_recv_ring
.w_nr
+ 1;
273 attr
.cap
.max_send_sge
= rds_ibdev
->max_sge
;
274 attr
.cap
.max_recv_sge
= RDS_IB_RECV_SGE
;
275 attr
.sq_sig_type
= IB_SIGNAL_REQ_WR
;
276 attr
.qp_type
= IB_QPT_RC
;
277 attr
.send_cq
= ic
->i_send_cq
;
278 attr
.recv_cq
= ic
->i_recv_cq
;
281 * XXX this can fail if max_*_wr is too large? Are we supposed
282 * to back off until we get a value that the hardware can support?
284 ret
= rdma_create_qp(ic
->i_cm_id
, ic
->i_pd
, &attr
);
286 rdsdebug("rdma_create_qp failed: %d\n", ret
);
290 ic
->i_send_hdrs
= ib_dma_alloc_coherent(dev
,
291 ic
->i_send_ring
.w_nr
*
292 sizeof(struct rds_header
),
293 &ic
->i_send_hdrs_dma
, GFP_KERNEL
);
294 if (ic
->i_send_hdrs
== NULL
) {
296 rdsdebug("ib_dma_alloc_coherent send failed\n");
300 ic
->i_recv_hdrs
= ib_dma_alloc_coherent(dev
,
301 ic
->i_recv_ring
.w_nr
*
302 sizeof(struct rds_header
),
303 &ic
->i_recv_hdrs_dma
, GFP_KERNEL
);
304 if (ic
->i_recv_hdrs
== NULL
) {
306 rdsdebug("ib_dma_alloc_coherent recv failed\n");
310 ic
->i_ack
= ib_dma_alloc_coherent(dev
, sizeof(struct rds_header
),
311 &ic
->i_ack_dma
, GFP_KERNEL
);
312 if (ic
->i_ack
== NULL
) {
314 rdsdebug("ib_dma_alloc_coherent ack failed\n");
318 ic
->i_sends
= vmalloc(ic
->i_send_ring
.w_nr
* sizeof(struct rds_ib_send_work
));
319 if (ic
->i_sends
== NULL
) {
321 rdsdebug("send allocation failed\n");
324 rds_ib_send_init_ring(ic
);
326 ic
->i_recvs
= vmalloc(ic
->i_recv_ring
.w_nr
* sizeof(struct rds_ib_recv_work
));
327 if (ic
->i_recvs
== NULL
) {
329 rdsdebug("recv allocation failed\n");
333 rds_ib_recv_init_ring(ic
);
334 rds_ib_recv_init_ack(ic
);
336 /* Post receive buffers - as a side effect, this will update
337 * the posted credit count. */
338 rds_ib_recv_refill(conn
, GFP_KERNEL
, GFP_HIGHUSER
, 1);
340 rdsdebug("conn %p pd %p mr %p cq %p %p\n", conn
, ic
->i_pd
, ic
->i_mr
,
341 ic
->i_send_cq
, ic
->i_recv_cq
);
347 static u32
rds_ib_protocol_compatible(const struct rds_ib_connect_private
*dp
)
352 /* rdma_cm private data is odd - when there is any private data in the
353 * request, we will be given a pretty large buffer without telling us the
354 * original size. The only way to tell the difference is by looking at
355 * the contents, which are initialized to zero.
356 * If the protocol version fields aren't set, this is a connection attempt
357 * from an older version. This could could be 3.0 or 2.0 - we can't tell.
358 * We really should have changed this for OFED 1.3 :-( */
359 if (dp
->dp_protocol_major
== 0)
360 return RDS_PROTOCOL_3_0
;
362 common
= be16_to_cpu(dp
->dp_protocol_minor_mask
) & RDS_IB_SUPPORTED_PROTOCOLS
;
363 if (dp
->dp_protocol_major
== 3 && common
) {
364 version
= RDS_PROTOCOL_3_0
;
365 while ((common
>>= 1) != 0)
367 } else if (printk_ratelimit()) {
368 printk(KERN_NOTICE
"RDS: Connection from %pI4 using "
369 "incompatible protocol version %u.%u\n",
371 dp
->dp_protocol_major
,
372 dp
->dp_protocol_minor
);
377 int rds_ib_cm_handle_connect(struct rdma_cm_id
*cm_id
,
378 struct rdma_cm_event
*event
)
380 __be64 lguid
= cm_id
->route
.path_rec
->sgid
.global
.interface_id
;
381 __be64 fguid
= cm_id
->route
.path_rec
->dgid
.global
.interface_id
;
382 const struct rds_ib_connect_private
*dp
= event
->param
.conn
.private_data
;
383 struct rds_ib_connect_private dp_rep
;
384 struct rds_connection
*conn
= NULL
;
385 struct rds_ib_connection
*ic
= NULL
;
386 struct rdma_conn_param conn_param
;
388 int err
, destroy
= 1;
390 /* Check whether the remote protocol version matches ours. */
391 version
= rds_ib_protocol_compatible(dp
);
395 rdsdebug("saddr %pI4 daddr %pI4 RDSv%u.%u lguid 0x%llx fguid "
396 "0x%llx\n", &dp
->dp_saddr
, &dp
->dp_daddr
,
397 RDS_PROTOCOL_MAJOR(version
), RDS_PROTOCOL_MINOR(version
),
398 (unsigned long long)be64_to_cpu(lguid
),
399 (unsigned long long)be64_to_cpu(fguid
));
401 conn
= rds_conn_create(dp
->dp_daddr
, dp
->dp_saddr
, &rds_ib_transport
,
404 rdsdebug("rds_conn_create failed (%ld)\n", PTR_ERR(conn
));
410 * The connection request may occur while the
411 * previous connection exist, e.g. in case of failover.
412 * But as connections may be initiated simultaneously
413 * by both hosts, we have a random backoff mechanism -
414 * see the comment above rds_queue_reconnect()
416 mutex_lock(&conn
->c_cm_lock
);
417 if (!rds_conn_transition(conn
, RDS_CONN_DOWN
, RDS_CONN_CONNECTING
)) {
418 if (rds_conn_state(conn
) == RDS_CONN_UP
) {
419 rdsdebug("incoming connect while connecting\n");
421 rds_ib_stats_inc(s_ib_listen_closed_stale
);
423 if (rds_conn_state(conn
) == RDS_CONN_CONNECTING
) {
424 /* Wait and see - our connect may still be succeeding */
425 rds_ib_stats_inc(s_ib_connect_raced
);
427 mutex_unlock(&conn
->c_cm_lock
);
431 ic
= conn
->c_transport_data
;
433 rds_ib_set_protocol(conn
, version
);
434 rds_ib_set_flow_control(conn
, be32_to_cpu(dp
->dp_credit
));
436 /* If the peer gave us the last packet it saw, process this as if
437 * we had received a regular ACK. */
439 rds_send_drop_acked(conn
, be64_to_cpu(dp
->dp_ack_seq
), NULL
);
441 BUG_ON(cm_id
->context
);
445 cm_id
->context
= conn
;
447 /* We got halfway through setting up the ib_connection, if we
448 * fail now, we have to take the long route out of this mess. */
451 err
= rds_ib_setup_qp(conn
);
453 rds_ib_conn_error(conn
, "rds_ib_setup_qp failed (%d)\n", err
);
457 rds_ib_cm_fill_conn_param(conn
, &conn_param
, &dp_rep
, version
);
459 /* rdma_accept() calls rdma_reject() internally if it fails */
460 err
= rdma_accept(cm_id
, &conn_param
);
461 mutex_unlock(&conn
->c_cm_lock
);
463 rds_ib_conn_error(conn
, "rdma_accept failed (%d)\n", err
);
470 rdma_reject(cm_id
, NULL
, 0);
475 int rds_ib_cm_initiate_connect(struct rdma_cm_id
*cm_id
)
477 struct rds_connection
*conn
= cm_id
->context
;
478 struct rds_ib_connection
*ic
= conn
->c_transport_data
;
479 struct rdma_conn_param conn_param
;
480 struct rds_ib_connect_private dp
;
483 /* If the peer doesn't do protocol negotiation, we must
484 * default to RDSv3.0 */
485 rds_ib_set_protocol(conn
, RDS_PROTOCOL_3_0
);
486 ic
->i_flowctl
= rds_ib_sysctl_flow_control
; /* advertise flow control */
488 ret
= rds_ib_setup_qp(conn
);
490 rds_ib_conn_error(conn
, "rds_ib_setup_qp failed (%d)\n", ret
);
494 rds_ib_cm_fill_conn_param(conn
, &conn_param
, &dp
, RDS_PROTOCOL_VERSION
);
496 ret
= rdma_connect(cm_id
, &conn_param
);
498 rds_ib_conn_error(conn
, "rdma_connect failed (%d)\n", ret
);
501 /* Beware - returning non-zero tells the rdma_cm to destroy
502 * the cm_id. We should certainly not do it as long as we still
503 * "own" the cm_id. */
505 if (ic
->i_cm_id
== cm_id
)
511 int rds_ib_conn_connect(struct rds_connection
*conn
)
513 struct rds_ib_connection
*ic
= conn
->c_transport_data
;
514 struct sockaddr_in src
, dest
;
517 /* XXX I wonder what affect the port space has */
518 /* delegate cm event handler to rdma_transport */
519 ic
->i_cm_id
= rdma_create_id(rds_rdma_cm_event_handler
, conn
,
521 if (IS_ERR(ic
->i_cm_id
)) {
522 ret
= PTR_ERR(ic
->i_cm_id
);
524 rdsdebug("rdma_create_id() failed: %d\n", ret
);
528 rdsdebug("created cm id %p for conn %p\n", ic
->i_cm_id
, conn
);
530 src
.sin_family
= AF_INET
;
531 src
.sin_addr
.s_addr
= (__force u32
)conn
->c_laddr
;
532 src
.sin_port
= (__force u16
)htons(0);
534 dest
.sin_family
= AF_INET
;
535 dest
.sin_addr
.s_addr
= (__force u32
)conn
->c_faddr
;
536 dest
.sin_port
= (__force u16
)htons(RDS_PORT
);
538 ret
= rdma_resolve_addr(ic
->i_cm_id
, (struct sockaddr
*)&src
,
539 (struct sockaddr
*)&dest
,
540 RDS_RDMA_RESOLVE_TIMEOUT_MS
);
542 rdsdebug("addr resolve failed for cm id %p: %d\n", ic
->i_cm_id
,
544 rdma_destroy_id(ic
->i_cm_id
);
553 * This is so careful about only cleaning up resources that were built up
554 * so that it can be called at any point during startup. In fact it
555 * can be called multiple times for a given connection.
557 void rds_ib_conn_shutdown(struct rds_connection
*conn
)
559 struct rds_ib_connection
*ic
= conn
->c_transport_data
;
562 rdsdebug("cm %p pd %p cq %p %p qp %p\n", ic
->i_cm_id
,
563 ic
->i_pd
, ic
->i_send_cq
, ic
->i_recv_cq
,
564 ic
->i_cm_id
? ic
->i_cm_id
->qp
: NULL
);
567 struct ib_device
*dev
= ic
->i_cm_id
->device
;
569 rdsdebug("disconnecting cm %p\n", ic
->i_cm_id
);
570 err
= rdma_disconnect(ic
->i_cm_id
);
572 /* Actually this may happen quite frequently, when
573 * an outgoing connect raced with an incoming connect.
575 rdsdebug("failed to disconnect, cm: %p err %d\n",
579 wait_event(rds_ib_ring_empty_wait
,
580 rds_ib_ring_empty(&ic
->i_send_ring
) &&
581 rds_ib_ring_empty(&ic
->i_recv_ring
));
584 ib_dma_free_coherent(dev
,
585 ic
->i_send_ring
.w_nr
*
586 sizeof(struct rds_header
),
588 ic
->i_send_hdrs_dma
);
591 ib_dma_free_coherent(dev
,
592 ic
->i_recv_ring
.w_nr
*
593 sizeof(struct rds_header
),
595 ic
->i_recv_hdrs_dma
);
598 ib_dma_free_coherent(dev
, sizeof(struct rds_header
),
599 ic
->i_ack
, ic
->i_ack_dma
);
602 rds_ib_send_clear_ring(ic
);
604 rds_ib_recv_clear_ring(ic
);
607 rdma_destroy_qp(ic
->i_cm_id
);
609 ib_destroy_cq(ic
->i_send_cq
);
611 ib_destroy_cq(ic
->i_recv_cq
);
612 rdma_destroy_id(ic
->i_cm_id
);
615 * Move connection back to the nodev list.
618 rds_ib_remove_conn(ic
->rds_ibdev
, conn
);
623 ic
->i_send_cq
= NULL
;
624 ic
->i_recv_cq
= NULL
;
625 ic
->i_send_hdrs
= NULL
;
626 ic
->i_recv_hdrs
= NULL
;
629 BUG_ON(ic
->rds_ibdev
);
631 /* Clear pending transmit */
633 rds_message_put(ic
->i_rm
);
637 /* Clear the ACK state */
638 clear_bit(IB_ACK_IN_FLIGHT
, &ic
->i_ack_flags
);
639 #ifdef KERNEL_HAS_ATOMIC64
640 atomic64_set(&ic
->i_ack_next
, 0);
646 /* Clear flow control state */
648 atomic_set(&ic
->i_credits
, 0);
650 rds_ib_ring_init(&ic
->i_send_ring
, rds_ib_sysctl_max_send_wr
);
651 rds_ib_ring_init(&ic
->i_recv_ring
, rds_ib_sysctl_max_recv_wr
);
654 rds_inc_put(&ic
->i_ibinc
->ii_inc
);
664 int rds_ib_conn_alloc(struct rds_connection
*conn
, gfp_t gfp
)
666 struct rds_ib_connection
*ic
;
670 ic
= kzalloc(sizeof(struct rds_ib_connection
), GFP_KERNEL
);
674 INIT_LIST_HEAD(&ic
->ib_node
);
675 mutex_init(&ic
->i_recv_mutex
);
676 #ifndef KERNEL_HAS_ATOMIC64
677 spin_lock_init(&ic
->i_ack_lock
);
681 * rds_ib_conn_shutdown() waits for these to be emptied so they
682 * must be initialized before it can be called.
684 rds_ib_ring_init(&ic
->i_send_ring
, rds_ib_sysctl_max_send_wr
);
685 rds_ib_ring_init(&ic
->i_recv_ring
, rds_ib_sysctl_max_recv_wr
);
688 conn
->c_transport_data
= ic
;
690 spin_lock_irqsave(&ib_nodev_conns_lock
, flags
);
691 list_add_tail(&ic
->ib_node
, &ib_nodev_conns
);
692 spin_unlock_irqrestore(&ib_nodev_conns_lock
, flags
);
695 rdsdebug("conn %p conn ic %p\n", conn
, conn
->c_transport_data
);
700 * Free a connection. Connection must be shut down and not set for reconnect.
702 void rds_ib_conn_free(void *arg
)
704 struct rds_ib_connection
*ic
= arg
;
705 spinlock_t
*lock_ptr
;
707 rdsdebug("ic %p\n", ic
);
710 * Conn is either on a dev's list or on the nodev list.
711 * A race with shutdown() or connect() would cause problems
712 * (since rds_ibdev would change) but that should never happen.
714 lock_ptr
= ic
->rds_ibdev
? &ic
->rds_ibdev
->spinlock
: &ib_nodev_conns_lock
;
716 spin_lock_irq(lock_ptr
);
717 list_del(&ic
->ib_node
);
718 spin_unlock_irq(lock_ptr
);
725 * An error occurred on the connection
728 __rds_ib_conn_error(struct rds_connection
*conn
, const char *fmt
, ...)