2 * Copyright (c) 2006 Mellanox Technologies. 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
35 #ifdef CONFIG_INFINIBAND_IPOIB_CM
37 #include <netinet/ip.h>
38 #include <netinet/ip_icmp.h>
39 #include <netinet/icmp6.h>
41 #include <rdma/ib_cm.h>
42 #include <rdma/ib_cache.h>
43 #include <linux/delay.h>
45 int ipoib_max_conn_qp = 128;
47 module_param_named(max_nonsrq_conn_qp, ipoib_max_conn_qp, int, 0444);
48 MODULE_PARM_DESC(max_nonsrq_conn_qp,
49 "Max number of connected-mode QPs per interface "
50 "(applied only if shared receive queue is not available)");
52 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
53 static int data_debug_level;
55 module_param_named(cm_data_debug_level, data_debug_level, int, 0644);
56 MODULE_PARM_DESC(cm_data_debug_level,
57 "Enable data path debug tracing for connected mode if > 0");
60 #define IPOIB_CM_IETF_ID 0x1000000000000000ULL
62 #define IPOIB_CM_RX_UPDATE_TIME (256 * HZ)
63 #define IPOIB_CM_RX_TIMEOUT (2 * 256 * HZ)
64 #define IPOIB_CM_RX_DELAY (3 * 256 * HZ)
65 #define IPOIB_CM_RX_UPDATE_MASK (0x3)
67 static struct ib_qp_attr ipoib_cm_err_attr = {
68 .qp_state = IB_QPS_ERR
71 #define IPOIB_CM_RX_DRAIN_WRID 0xffffffff
73 static struct ib_send_wr ipoib_cm_rx_drain_wr = {
74 .wr_id = IPOIB_CM_RX_DRAIN_WRID,
78 static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id,
79 struct ib_cm_event *event);
81 static void ipoib_cm_dma_unmap_rx(struct ipoib_dev_priv *priv, struct ipoib_cm_rx_buf *rx_req)
84 ipoib_dma_unmap_rx(priv, (struct ipoib_rx_buf *)rx_req);
88 static int ipoib_cm_post_receive_srq(struct ipoib_dev_priv *priv, int id)
90 struct ib_recv_wr *bad_wr;
91 struct ipoib_rx_buf *rx_req;
96 rx_req = (struct ipoib_rx_buf *)&priv->cm.srq_ring[id];
97 for (m = rx_req->mb, i = 0; m != NULL; m = m->m_next, i++) {
98 priv->cm.rx_sge[i].addr = rx_req->mapping[i];
99 priv->cm.rx_sge[i].length = m->m_len;
102 priv->cm.rx_wr.num_sge = i;
103 priv->cm.rx_wr.wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV;
105 ret = ib_post_srq_recv(priv->cm.srq, &priv->cm.rx_wr, &bad_wr);
107 ipoib_warn(priv, "post srq failed for buf %d (%d)\n", id, ret);
108 ipoib_dma_unmap_rx(priv, rx_req);
109 m_freem(priv->cm.srq_ring[id].mb);
110 priv->cm.srq_ring[id].mb = NULL;
116 static int ipoib_cm_post_receive_nonsrq(struct ipoib_dev_priv *priv,
117 struct ipoib_cm_rx *rx,
118 struct ib_recv_wr *wr,
119 struct ib_sge *sge, int id)
121 struct ipoib_rx_buf *rx_req;
122 struct ib_recv_wr *bad_wr;
127 rx_req = (struct ipoib_rx_buf *)&rx->rx_ring[id];
128 for (m = rx_req->mb, i = 0; m != NULL; m = m->m_next, i++) {
129 sge[i].addr = rx_req->mapping[i];
130 sge[i].length = m->m_len;
134 wr->wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV;
136 ret = ib_post_recv(rx->qp, wr, &bad_wr);
138 ipoib_warn(priv, "post recv failed for buf %d (%d)\n", id, ret);
139 ipoib_dma_unmap_rx(priv, rx_req);
140 m_freem(rx->rx_ring[id].mb);
141 rx->rx_ring[id].mb = NULL;
148 ipoib_cm_alloc_rx_mb(struct ipoib_dev_priv *priv, struct ipoib_cm_rx_buf *rx_req)
150 return ipoib_alloc_map_mb(priv, (struct ipoib_rx_buf *)rx_req,
151 priv->cm.max_cm_mtu);
154 static void ipoib_cm_free_rx_ring(struct ipoib_dev_priv *priv,
155 struct ipoib_cm_rx_buf *rx_ring)
159 for (i = 0; i < ipoib_recvq_size; ++i)
161 ipoib_cm_dma_unmap_rx(priv, &rx_ring[i]);
162 m_freem(rx_ring[i].mb);
168 static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv *priv)
170 struct ib_send_wr *bad_wr;
171 struct ipoib_cm_rx *p;
173 /* We only reserved 1 extra slot in CQ for drain WRs, so
174 * make sure we have at most 1 outstanding WR. */
175 if (list_empty(&priv->cm.rx_flush_list) ||
176 !list_empty(&priv->cm.rx_drain_list))
180 * QPs on flush list are error state. This way, a "flush
181 * error" WC will be immediately generated for each WR we post.
183 p = list_entry(priv->cm.rx_flush_list.next, typeof(*p), list);
184 if (ib_post_send(p->qp, &ipoib_cm_rx_drain_wr, &bad_wr))
185 ipoib_warn(priv, "failed to post drain wr\n");
187 list_splice_init(&priv->cm.rx_flush_list, &priv->cm.rx_drain_list);
190 static void ipoib_cm_rx_event_handler(struct ib_event *event, void *ctx)
192 struct ipoib_cm_rx *p = ctx;
193 struct ipoib_dev_priv *priv = p->priv;
196 if (event->event != IB_EVENT_QP_LAST_WQE_REACHED)
199 spin_lock_irqsave(&priv->lock, flags);
200 list_move(&p->list, &priv->cm.rx_flush_list);
201 p->state = IPOIB_CM_RX_FLUSH;
202 ipoib_cm_start_rx_drain(priv);
203 spin_unlock_irqrestore(&priv->lock, flags);
206 static struct ib_qp *ipoib_cm_create_rx_qp(struct ipoib_dev_priv *priv,
207 struct ipoib_cm_rx *p)
209 struct ib_qp_init_attr attr = {
210 .event_handler = ipoib_cm_rx_event_handler,
211 .send_cq = priv->recv_cq, /* For drain WR */
212 .recv_cq = priv->recv_cq,
214 .cap.max_send_wr = 1, /* For drain WR */
215 .cap.max_send_sge = 1,
216 .sq_sig_type = IB_SIGNAL_ALL_WR,
217 .qp_type = IB_QPT_RC,
221 if (!ipoib_cm_has_srq(priv)) {
222 attr.cap.max_recv_wr = ipoib_recvq_size;
223 attr.cap.max_recv_sge = priv->cm.num_frags;
226 return ib_create_qp(priv->pd, &attr);
229 static int ipoib_cm_modify_rx_qp(struct ipoib_dev_priv *priv,
230 struct ib_cm_id *cm_id, struct ib_qp *qp,
233 struct ib_qp_attr qp_attr;
234 int qp_attr_mask, ret;
236 qp_attr.qp_state = IB_QPS_INIT;
237 ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask);
239 ipoib_warn(priv, "failed to init QP attr for INIT: %d\n", ret);
242 ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask);
244 ipoib_warn(priv, "failed to modify QP to INIT: %d\n", ret);
247 qp_attr.qp_state = IB_QPS_RTR;
248 ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask);
250 ipoib_warn(priv, "failed to init QP attr for RTR: %d\n", ret);
253 qp_attr.rq_psn = psn;
254 ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask);
256 ipoib_warn(priv, "failed to modify QP to RTR: %d\n", ret);
261 * Current Mellanox HCA firmware won't generate completions
262 * with error for drain WRs unless the QP has been moved to
263 * RTS first. This work-around leaves a window where a QP has
264 * moved to error asynchronously, but this will eventually get
265 * fixed in firmware, so let's not error out if modify QP
268 qp_attr.qp_state = IB_QPS_RTS;
269 ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask);
271 ipoib_warn(priv, "failed to init QP attr for RTS: %d\n", ret);
274 ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask);
276 ipoib_warn(priv, "failed to modify QP to RTS: %d\n", ret);
283 static void ipoib_cm_init_rx_wr(struct ipoib_dev_priv *priv,
284 struct ib_recv_wr *wr,
289 for (i = 0; i < IPOIB_CM_RX_SG; i++)
290 sge[i].lkey = priv->mr->lkey;
297 static int ipoib_cm_nonsrq_init_rx(struct ipoib_dev_priv *priv,
298 struct ib_cm_id *cm_id, struct ipoib_cm_rx *rx)
301 struct ib_recv_wr wr;
302 struct ib_sge sge[IPOIB_CM_RX_SG];
307 rx->rx_ring = kzalloc(ipoib_recvq_size * sizeof *rx->rx_ring, GFP_KERNEL);
309 printk(KERN_WARNING "%s: failed to allocate CM non-SRQ ring (%d entries)\n",
310 priv->ca->name, ipoib_recvq_size);
314 memset(rx->rx_ring, 0, ipoib_recvq_size * sizeof *rx->rx_ring);
316 t = kmalloc(sizeof *t, GFP_KERNEL);
322 ipoib_cm_init_rx_wr(priv, &t->wr, t->sge);
324 spin_lock_irq(&priv->lock);
326 if (priv->cm.nonsrq_conn_qp >= ipoib_max_conn_qp) {
327 spin_unlock_irq(&priv->lock);
328 ib_send_cm_rej(cm_id, IB_CM_REJ_NO_QP, NULL, 0, NULL, 0);
332 ++priv->cm.nonsrq_conn_qp;
334 spin_unlock_irq(&priv->lock);
336 for (i = 0; i < ipoib_recvq_size; ++i) {
337 if (!ipoib_cm_alloc_rx_mb(priv, &rx->rx_ring[i])) {
338 ipoib_warn(priv, "failed to allocate receive buffer %d\n", i);
342 ret = ipoib_cm_post_receive_nonsrq(priv, rx, &t->wr, t->sge, i);
344 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq "
345 "failed for buf %d\n", i);
351 rx->recv_count = ipoib_recvq_size;
358 spin_lock_irq(&priv->lock);
359 --priv->cm.nonsrq_conn_qp;
360 spin_unlock_irq(&priv->lock);
364 ipoib_cm_free_rx_ring(priv, rx->rx_ring);
369 static int ipoib_cm_send_rep(struct ipoib_dev_priv *priv, struct ib_cm_id *cm_id,
370 struct ib_qp *qp, struct ib_cm_req_event_param *req,
373 struct ipoib_cm_data data = {};
374 struct ib_cm_rep_param rep = {};
376 data.qpn = cpu_to_be32(priv->qp->qp_num);
377 data.mtu = cpu_to_be32(priv->cm.max_cm_mtu);
379 rep.private_data = &data;
380 rep.private_data_len = sizeof data;
381 rep.flow_control = 0;
382 rep.rnr_retry_count = req->rnr_retry_count;
383 rep.srq = ipoib_cm_has_srq(priv);
384 rep.qp_num = qp->qp_num;
385 rep.starting_psn = psn;
386 return ib_send_cm_rep(cm_id, &rep);
389 static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
391 struct ipoib_dev_priv *priv = cm_id->context;
392 struct ipoib_cm_rx *p;
396 ipoib_dbg(priv, "REQ arrived\n");
397 p = kzalloc(sizeof *p, GFP_KERNEL);
403 p->state = IPOIB_CM_RX_LIVE;
404 p->jiffies = jiffies;
405 INIT_LIST_HEAD(&p->list);
407 p->qp = ipoib_cm_create_rx_qp(priv, p);
409 ret = PTR_ERR(p->qp);
413 psn = random() & 0xffffff;
414 ret = ipoib_cm_modify_rx_qp(priv, cm_id, p->qp, psn);
418 if (!ipoib_cm_has_srq(priv)) {
419 ret = ipoib_cm_nonsrq_init_rx(priv, cm_id, p);
424 spin_lock_irq(&priv->lock);
425 queue_delayed_work(ipoib_workqueue,
426 &priv->cm.stale_task, IPOIB_CM_RX_DELAY);
427 /* Add this entry to passive ids list head, but do not re-add it
428 * if IB_EVENT_QP_LAST_WQE_REACHED has moved it to flush list. */
429 p->jiffies = jiffies;
430 if (p->state == IPOIB_CM_RX_LIVE)
431 list_move(&p->list, &priv->cm.passive_ids);
432 spin_unlock_irq(&priv->lock);
434 ret = ipoib_cm_send_rep(priv, cm_id, p->qp, &event->param.req_rcvd, psn);
436 ipoib_warn(priv, "failed to send REP: %d\n", ret);
437 if (ib_modify_qp(p->qp, &ipoib_cm_err_attr, IB_QP_STATE))
438 ipoib_warn(priv, "unable to move qp to error state\n");
443 ib_destroy_qp(p->qp);
449 static int ipoib_cm_rx_handler(struct ib_cm_id *cm_id,
450 struct ib_cm_event *event)
452 struct ipoib_cm_rx *p;
453 struct ipoib_dev_priv *priv;
455 switch (event->event) {
456 case IB_CM_REQ_RECEIVED:
457 return ipoib_cm_req_handler(cm_id, event);
458 case IB_CM_DREQ_RECEIVED:
460 ib_send_cm_drep(cm_id, NULL, 0);
462 case IB_CM_REJ_RECEIVED:
465 if (ib_modify_qp(p->qp, &ipoib_cm_err_attr, IB_QP_STATE))
466 ipoib_warn(priv, "unable to move qp to error state\n");
473 void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)
475 struct ipoib_cm_rx_buf saverx;
476 struct ipoib_cm_rx_buf *rx_ring;
477 unsigned int wr_id = wc->wr_id & ~(IPOIB_OP_CM | IPOIB_OP_RECV);
478 struct ifnet *dev = priv->dev;
479 struct mbuf *mb, *newmb;
480 struct ipoib_cm_rx *p;
484 ipoib_dbg_data(priv, "cm recv completion: id %d, status: %d\n",
487 if (unlikely(wr_id >= ipoib_recvq_size)) {
488 if (wr_id == (IPOIB_CM_RX_DRAIN_WRID & ~(IPOIB_OP_CM | IPOIB_OP_RECV))) {
489 spin_lock(&priv->lock);
490 list_splice_init(&priv->cm.rx_drain_list, &priv->cm.rx_reap_list);
491 ipoib_cm_start_rx_drain(priv);
492 if (priv->cm.id != NULL)
493 queue_work(ipoib_workqueue,
494 &priv->cm.rx_reap_task);
495 spin_unlock(&priv->lock);
497 ipoib_warn(priv, "cm recv completion event with wrid %d (> %d)\n",
498 wr_id, ipoib_recvq_size);
502 p = wc->qp->qp_context;
504 has_srq = ipoib_cm_has_srq(priv);
505 rx_ring = has_srq ? priv->cm.srq_ring : p->rx_ring;
507 mb = rx_ring[wr_id].mb;
509 if (unlikely(wc->status != IB_WC_SUCCESS)) {
510 ipoib_dbg(priv, "cm recv error "
511 "(status=%d, wrid=%d vend_err %x)\n",
512 wc->status, wr_id, wc->vendor_err);
517 if (!--p->recv_count) {
518 spin_lock(&priv->lock);
519 list_move(&p->list, &priv->cm.rx_reap_list);
520 queue_work(ipoib_workqueue, &priv->cm.rx_reap_task);
521 spin_unlock(&priv->lock);
527 if (unlikely(!(wr_id & IPOIB_CM_RX_UPDATE_MASK))) {
528 if (p && time_after_eq(jiffies, p->jiffies + IPOIB_CM_RX_UPDATE_TIME)) {
529 p->jiffies = jiffies;
530 /* Move this entry to list head, but do not re-add it
531 * if it has been moved out of list. */
532 if (p->state == IPOIB_CM_RX_LIVE)
533 list_move(&p->list, &priv->cm.passive_ids);
537 memcpy(&saverx, &rx_ring[wr_id], sizeof(saverx));
538 newmb = ipoib_cm_alloc_rx_mb(priv, &rx_ring[wr_id]);
539 if (unlikely(!newmb)) {
541 * If we can't allocate a new RX buffer, dump
542 * this packet and reuse the old buffer.
544 ipoib_dbg(priv, "failed to allocate receive buffer %d\n", wr_id);
546 memcpy(&rx_ring[wr_id], &saverx, sizeof(saverx));
550 ipoib_cm_dma_unmap_rx(priv, &saverx);
552 ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n",
553 wc->byte_len, wc->slid);
555 ipoib_dma_mb(priv, mb, wc->byte_len);
558 dev->if_ibytes += mb->m_pkthdr.len;
560 mb->m_pkthdr.rcvif = dev;
561 proto = *mtod(mb, uint16_t *);
562 m_adj(mb, IPOIB_ENCAP_LEN);
564 IPOIB_MTAP_PROTO(dev, mb, proto);
565 ipoib_demux(dev, mb, ntohs(proto));
569 if (unlikely(ipoib_cm_post_receive_srq(priv, wr_id)))
570 ipoib_warn(priv, "ipoib_cm_post_receive_srq failed "
571 "for buf %d\n", wr_id);
573 if (unlikely(ipoib_cm_post_receive_nonsrq(priv, p,
578 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq failed "
579 "for buf %d\n", wr_id);
584 static inline int post_send(struct ipoib_dev_priv *priv,
585 struct ipoib_cm_tx *tx,
586 struct ipoib_cm_tx_buf *tx_req,
589 struct ib_send_wr *bad_wr;
590 struct mbuf *mb = tx_req->mb;
591 u64 *mapping = tx_req->mapping;
595 for (m = mb, i = 0; m != NULL; m = m->m_next, i++) {
596 priv->tx_sge[i].addr = mapping[i];
597 priv->tx_sge[i].length = m->m_len;
599 priv->tx_wr.num_sge = i;
600 priv->tx_wr.wr_id = wr_id | IPOIB_OP_CM;
601 priv->tx_wr.opcode = IB_WR_SEND;
603 return ib_post_send(tx->qp, &priv->tx_wr, &bad_wr);
606 void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx)
608 struct ipoib_cm_tx_buf *tx_req;
609 struct ifnet *dev = priv->dev;
611 if (unlikely(priv->tx_outstanding > MAX_SEND_CQE))
612 while (ipoib_poll_tx(priv)); /* nothing */
614 m_adj(mb, sizeof(struct ipoib_pseudoheader));
615 if (unlikely(mb->m_pkthdr.len > tx->mtu)) {
616 ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n",
617 mb->m_pkthdr.len, tx->mtu);
619 ipoib_cm_mb_too_long(priv, mb, IPOIB_CM_MTU(tx->mtu));
623 ipoib_dbg_data(priv, "sending packet: head 0x%x length %d connection 0x%x\n",
624 tx->tx_head, mb->m_pkthdr.len, tx->qp->qp_num);
628 * We put the mb into the tx_ring _before_ we call post_send()
629 * because it's entirely possible that the completion handler will
630 * run before we execute anything after the post_send(). That
631 * means we have to make sure everything is properly recorded and
632 * our state is consistent before we call post_send().
634 tx_req = &tx->tx_ring[tx->tx_head & (ipoib_sendq_size - 1)];
636 if (unlikely(ipoib_dma_map_tx(priv->ca, (struct ipoib_tx_buf *)tx_req,
637 priv->cm.num_frags))) {
644 if (unlikely(post_send(priv, tx, tx_req, tx->tx_head & (ipoib_sendq_size - 1)))) {
645 ipoib_warn(priv, "post_send failed\n");
647 ipoib_dma_unmap_tx(priv->ca, (struct ipoib_tx_buf *)tx_req);
652 if (++priv->tx_outstanding == ipoib_sendq_size) {
653 ipoib_dbg(priv, "TX ring 0x%x full, stopping kernel net queue\n",
655 if (ib_req_notify_cq(priv->send_cq, IB_CQ_NEXT_COMP))
656 ipoib_warn(priv, "request notify on send CQ failed\n");
657 dev->if_drv_flags |= IFF_DRV_OACTIVE;
663 void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)
665 struct ipoib_cm_tx *tx = wc->qp->qp_context;
666 unsigned int wr_id = wc->wr_id & ~IPOIB_OP_CM;
667 struct ifnet *dev = priv->dev;
668 struct ipoib_cm_tx_buf *tx_req;
670 ipoib_dbg_data(priv, "cm send completion: id %d, status: %d\n",
673 if (unlikely(wr_id >= ipoib_sendq_size)) {
674 ipoib_warn(priv, "cm send completion event with wrid %d (> %d)\n",
675 wr_id, ipoib_sendq_size);
679 tx_req = &tx->tx_ring[wr_id];
681 ipoib_dma_unmap_tx(priv->ca, (struct ipoib_tx_buf *)tx_req);
683 /* FIXME: is this right? Shouldn't we only increment on success? */
689 if (unlikely(--priv->tx_outstanding == ipoib_sendq_size >> 1) &&
690 (dev->if_drv_flags & IFF_DRV_OACTIVE) != 0 &&
691 test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
692 dev->if_drv_flags &= ~IFF_DRV_OACTIVE;
694 if (wc->status != IB_WC_SUCCESS &&
695 wc->status != IB_WC_WR_FLUSH_ERR) {
696 struct ipoib_path *path;
698 ipoib_dbg(priv, "failed cm send event "
699 "(status=%d, wrid=%d vend_err %x)\n",
700 wc->status, wr_id, wc->vendor_err);
706 rb_erase(&path->rb_node, &priv->path_tree);
707 list_del(&path->list);
710 if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &tx->flags)) {
711 list_move(&tx->list, &priv->cm.reap_list);
712 queue_work(ipoib_workqueue, &priv->cm.reap_task);
715 clear_bit(IPOIB_FLAG_OPER_UP, &tx->flags);
720 int ipoib_cm_dev_open(struct ipoib_dev_priv *priv)
724 if (!IPOIB_CM_SUPPORTED(IF_LLADDR(priv->dev)))
727 priv->cm.id = ib_create_cm_id(priv->ca, ipoib_cm_rx_handler, priv);
728 if (IS_ERR(priv->cm.id)) {
729 printk(KERN_WARNING "%s: failed to create CM ID\n", priv->ca->name);
730 ret = PTR_ERR(priv->cm.id);
734 ret = ib_cm_listen(priv->cm.id, cpu_to_be64(IPOIB_CM_IETF_ID | priv->qp->qp_num),
737 printk(KERN_WARNING "%s: failed to listen on ID 0x%llx\n", priv->ca->name,
738 IPOIB_CM_IETF_ID | priv->qp->qp_num);
745 ib_destroy_cm_id(priv->cm.id);
751 static void ipoib_cm_free_rx_reap_list(struct ipoib_dev_priv *priv)
753 struct ipoib_cm_rx *rx, *n;
756 spin_lock_irq(&priv->lock);
757 list_splice_init(&priv->cm.rx_reap_list, &list);
758 spin_unlock_irq(&priv->lock);
760 list_for_each_entry_safe(rx, n, &list, list) {
761 ib_destroy_cm_id(rx->id);
762 ib_destroy_qp(rx->qp);
763 if (!ipoib_cm_has_srq(priv)) {
764 ipoib_cm_free_rx_ring(priv, rx->rx_ring);
765 spin_lock_irq(&priv->lock);
766 --priv->cm.nonsrq_conn_qp;
767 spin_unlock_irq(&priv->lock);
773 void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv)
775 struct ipoib_cm_rx *p;
779 if (!IPOIB_CM_SUPPORTED(IF_LLADDR(priv->dev)) || !priv->cm.id)
782 ib_destroy_cm_id(priv->cm.id);
785 cancel_work_sync(&priv->cm.rx_reap_task);
787 spin_lock_irq(&priv->lock);
788 while (!list_empty(&priv->cm.passive_ids)) {
789 p = list_entry(priv->cm.passive_ids.next, typeof(*p), list);
790 list_move(&p->list, &priv->cm.rx_error_list);
791 p->state = IPOIB_CM_RX_ERROR;
792 spin_unlock_irq(&priv->lock);
793 ret = ib_modify_qp(p->qp, &ipoib_cm_err_attr, IB_QP_STATE);
795 ipoib_warn(priv, "unable to move qp to error state: %d\n", ret);
796 spin_lock_irq(&priv->lock);
799 /* Wait for all RX to be drained */
802 while (!list_empty(&priv->cm.rx_error_list) ||
803 !list_empty(&priv->cm.rx_flush_list) ||
804 !list_empty(&priv->cm.rx_drain_list)) {
805 if (time_after(jiffies, begin + 5 * HZ)) {
806 ipoib_warn(priv, "RX drain timing out\n");
809 * assume the HW is wedged and just free up everything.
811 list_splice_init(&priv->cm.rx_flush_list,
812 &priv->cm.rx_reap_list);
813 list_splice_init(&priv->cm.rx_error_list,
814 &priv->cm.rx_reap_list);
815 list_splice_init(&priv->cm.rx_drain_list,
816 &priv->cm.rx_reap_list);
819 spin_unlock_irq(&priv->lock);
821 ipoib_drain_cq(priv);
822 spin_lock_irq(&priv->lock);
825 spin_unlock_irq(&priv->lock);
827 ipoib_cm_free_rx_reap_list(priv);
829 cancel_delayed_work(&priv->cm.stale_task);
832 static int ipoib_cm_rep_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
834 struct ipoib_cm_tx *p = cm_id->context;
835 struct ipoib_dev_priv *priv = p->priv;
836 struct ipoib_cm_data *data = event->private_data;
837 struct ifqueue mbqueue;
838 struct ib_qp_attr qp_attr;
839 int qp_attr_mask, ret;
842 ipoib_dbg(priv, "cm rep handler\n");
843 p->mtu = be32_to_cpu(data->mtu);
845 if (p->mtu <= IPOIB_ENCAP_LEN) {
846 ipoib_warn(priv, "Rejecting connection: mtu %d <= %d\n",
847 p->mtu, IPOIB_ENCAP_LEN);
851 qp_attr.qp_state = IB_QPS_RTR;
852 ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask);
854 ipoib_warn(priv, "failed to init QP attr for RTR: %d\n", ret);
858 qp_attr.rq_psn = 0 /* FIXME */;
859 ret = ib_modify_qp(p->qp, &qp_attr, qp_attr_mask);
861 ipoib_warn(priv, "failed to modify QP to RTR: %d\n", ret);
865 qp_attr.qp_state = IB_QPS_RTS;
866 ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask);
868 ipoib_warn(priv, "failed to init QP attr for RTS: %d\n", ret);
871 ret = ib_modify_qp(p->qp, &qp_attr, qp_attr_mask);
873 ipoib_warn(priv, "failed to modify QP to RTS: %d\n", ret);
877 bzero(&mbqueue, sizeof(mbqueue));
879 spin_lock_irq(&priv->lock);
880 set_bit(IPOIB_FLAG_OPER_UP, &p->flags);
883 _IF_DEQUEUE(&p->path->queue, mb);
886 _IF_ENQUEUE(&mbqueue, mb);
888 spin_unlock_irq(&priv->lock);
891 struct ifnet *dev = p->priv->dev;
892 _IF_DEQUEUE(&mbqueue, mb);
895 mb->m_pkthdr.rcvif = dev;
896 if (dev->if_transmit(dev, mb))
897 ipoib_warn(priv, "dev_queue_xmit failed "
898 "to requeue packet\n");
901 ret = ib_send_cm_rtu(cm_id, NULL, 0);
903 ipoib_warn(priv, "failed to send RTU: %d\n", ret);
909 static struct ib_qp *ipoib_cm_create_tx_qp(struct ipoib_dev_priv *priv,
910 struct ipoib_cm_tx *tx)
912 struct ib_qp_init_attr attr = {
913 .send_cq = priv->send_cq,
914 .recv_cq = priv->recv_cq,
916 .cap.max_send_wr = ipoib_sendq_size,
917 .cap.max_send_sge = priv->cm.num_frags,
918 .sq_sig_type = IB_SIGNAL_ALL_WR,
919 .qp_type = IB_QPT_RC,
923 return ib_create_qp(priv->pd, &attr);
926 static int ipoib_cm_send_req(struct ipoib_dev_priv *priv,
927 struct ib_cm_id *id, struct ib_qp *qp,
929 struct ib_sa_path_rec *pathrec)
931 struct ipoib_cm_data data = {};
932 struct ib_cm_req_param req = {};
934 ipoib_dbg(priv, "cm send req\n");
936 data.qpn = cpu_to_be32(priv->qp->qp_num);
937 data.mtu = cpu_to_be32(priv->cm.max_cm_mtu);
939 req.primary_path = pathrec;
940 req.alternate_path = NULL;
941 req.service_id = cpu_to_be64(IPOIB_CM_IETF_ID | qpn);
942 req.qp_num = qp->qp_num;
943 req.qp_type = qp->qp_type;
944 req.private_data = &data;
945 req.private_data_len = sizeof data;
946 req.flow_control = 0;
948 req.starting_psn = 0; /* FIXME */
951 * Pick some arbitrary defaults here; we could make these
952 * module parameters if anyone cared about setting them.
954 req.responder_resources = 4;
955 req.remote_cm_response_timeout = 20;
956 req.local_cm_response_timeout = 20;
957 req.retry_count = 0; /* RFC draft warns against retries */
958 req.rnr_retry_count = 0; /* RFC draft warns against retries */
959 req.max_cm_retries = 15;
960 req.srq = ipoib_cm_has_srq(priv);
961 return ib_send_cm_req(id, &req);
964 static int ipoib_cm_modify_tx_init(struct ipoib_dev_priv *priv,
965 struct ib_cm_id *cm_id, struct ib_qp *qp)
967 struct ib_qp_attr qp_attr;
968 int qp_attr_mask, ret;
969 ret = ib_find_pkey(priv->ca, priv->port, priv->pkey, &qp_attr.pkey_index);
971 ipoib_warn(priv, "pkey 0x%x not found: %d\n", priv->pkey, ret);
975 qp_attr.qp_state = IB_QPS_INIT;
976 qp_attr.qp_access_flags = IB_ACCESS_LOCAL_WRITE;
977 qp_attr.port_num = priv->port;
978 qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS | IB_QP_PKEY_INDEX | IB_QP_PORT;
980 ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask);
982 ipoib_warn(priv, "failed to modify tx QP to INIT: %d\n", ret);
988 static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn,
989 struct ib_sa_path_rec *pathrec)
991 struct ipoib_dev_priv *priv = p->priv;
994 p->tx_ring = kzalloc(ipoib_sendq_size * sizeof *p->tx_ring, GFP_KERNEL);
996 ipoib_warn(priv, "failed to allocate tx ring\n");
1000 memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring);
1002 p->qp = ipoib_cm_create_tx_qp(p->priv, p);
1003 if (IS_ERR(p->qp)) {
1004 ret = PTR_ERR(p->qp);
1005 ipoib_warn(priv, "failed to allocate tx qp: %d\n", ret);
1009 p->id = ib_create_cm_id(priv->ca, ipoib_cm_tx_handler, p);
1010 if (IS_ERR(p->id)) {
1011 ret = PTR_ERR(p->id);
1012 ipoib_warn(priv, "failed to create tx cm id: %d\n", ret);
1016 ret = ipoib_cm_modify_tx_init(p->priv, p->id, p->qp);
1018 ipoib_warn(priv, "failed to modify tx qp to rtr: %d\n", ret);
1022 ret = ipoib_cm_send_req(p->priv, p->id, p->qp, qpn, pathrec);
1024 ipoib_warn(priv, "failed to send cm req: %d\n", ret);
1028 ipoib_dbg(priv, "Request connection 0x%x for gid %pI6 qpn 0x%x\n",
1029 p->qp->qp_num, pathrec->dgid.raw, qpn);
1035 ib_destroy_cm_id(p->id);
1038 ib_destroy_qp(p->qp);
1046 static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p)
1048 struct ipoib_dev_priv *priv = p->priv;
1049 struct ifnet *dev = priv->dev;
1050 struct ipoib_cm_tx_buf *tx_req;
1051 unsigned long begin;
1053 ipoib_dbg(priv, "Destroy active connection 0x%x head 0x%x tail 0x%x\n",
1054 p->qp ? p->qp->qp_num : 0, p->tx_head, p->tx_tail);
1057 ipoib_path_free(priv, p->path);
1060 ib_destroy_cm_id(p->id);
1063 /* Wait for all sends to complete */
1065 while ((int) p->tx_tail - (int) p->tx_head < 0) {
1066 if (time_after(jiffies, begin + 5 * HZ)) {
1067 ipoib_warn(priv, "timing out; %d sends not completed\n",
1068 p->tx_head - p->tx_tail);
1078 while ((int) p->tx_tail - (int) p->tx_head < 0) {
1079 tx_req = &p->tx_ring[p->tx_tail & (ipoib_sendq_size - 1)];
1080 ipoib_dma_unmap_tx(priv->ca, (struct ipoib_tx_buf *)tx_req);
1081 m_freem(tx_req->mb);
1083 if (unlikely(--priv->tx_outstanding == ipoib_sendq_size >> 1) &&
1084 (dev->if_drv_flags & IFF_DRV_OACTIVE) != 0 &&
1085 test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
1086 dev->if_drv_flags &= ~IFF_DRV_OACTIVE;
1090 ib_destroy_qp(p->qp);
1096 static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id,
1097 struct ib_cm_event *event)
1099 struct ipoib_cm_tx *tx = cm_id->context;
1100 struct ipoib_dev_priv *priv = tx->priv;
1101 struct ipoib_path *path;
1102 unsigned long flags;
1105 switch (event->event) {
1106 case IB_CM_DREQ_RECEIVED:
1107 ipoib_dbg(priv, "DREQ received.\n");
1108 ib_send_cm_drep(cm_id, NULL, 0);
1110 case IB_CM_REP_RECEIVED:
1111 ipoib_dbg(priv, "REP received.\n");
1112 ret = ipoib_cm_rep_handler(cm_id, event);
1114 ib_send_cm_rej(cm_id, IB_CM_REJ_CONSUMER_DEFINED,
1117 case IB_CM_REQ_ERROR:
1118 case IB_CM_REJ_RECEIVED:
1119 case IB_CM_TIMEWAIT_EXIT:
1120 ipoib_dbg(priv, "CM error %d.\n", event->event);
1121 spin_lock_irqsave(&priv->lock, flags);
1127 rb_erase(&path->rb_node, &priv->path_tree);
1128 list_del(&path->list);
1131 if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &tx->flags)) {
1132 list_move(&tx->list, &priv->cm.reap_list);
1133 queue_work(ipoib_workqueue, &priv->cm.reap_task);
1136 spin_unlock_irqrestore(&priv->lock, flags);
1138 ipoib_path_free(tx->priv, path);
1147 struct ipoib_cm_tx *ipoib_cm_create_tx(struct ipoib_dev_priv *priv,
1148 struct ipoib_path *path)
1150 struct ipoib_cm_tx *tx;
1152 tx = kzalloc(sizeof *tx, GFP_ATOMIC);
1156 ipoib_dbg(priv, "Creating cm tx\n");
1160 list_add(&tx->list, &priv->cm.start_list);
1161 set_bit(IPOIB_FLAG_INITIALIZED, &tx->flags);
1162 queue_work(ipoib_workqueue, &priv->cm.start_task);
1166 void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx)
1168 struct ipoib_dev_priv *priv = tx->priv;
1169 if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &tx->flags)) {
1170 spin_lock(&priv->lock);
1171 list_move(&tx->list, &priv->cm.reap_list);
1172 spin_unlock(&priv->lock);
1173 queue_work(ipoib_workqueue, &priv->cm.reap_task);
1174 ipoib_dbg(priv, "Reap connection for gid %pI6\n",
1175 tx->path->pathrec.dgid.raw);
1180 static void ipoib_cm_tx_start(struct work_struct *work)
1182 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv,
1184 struct ipoib_path *path;
1185 struct ipoib_cm_tx *p;
1186 unsigned long flags;
1189 struct ib_sa_path_rec pathrec;
1192 ipoib_dbg(priv, "cm start task\n");
1193 spin_lock_irqsave(&priv->lock, flags);
1195 while (!list_empty(&priv->cm.start_list)) {
1196 p = list_entry(priv->cm.start_list.next, typeof(*p), list);
1197 list_del_init(&p->list);
1199 qpn = IPOIB_QPN(path->hwaddr);
1200 memcpy(&pathrec, &p->path->pathrec, sizeof pathrec);
1202 spin_unlock_irqrestore(&priv->lock, flags);
1204 ret = ipoib_cm_tx_init(p, qpn, &pathrec);
1206 spin_lock_irqsave(&priv->lock, flags);
1212 rb_erase(&path->rb_node, &priv->path_tree);
1213 list_del(&path->list);
1214 ipoib_path_free(priv, path);
1221 spin_unlock_irqrestore(&priv->lock, flags);
1224 static void ipoib_cm_tx_reap(struct work_struct *work)
1226 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv,
1228 struct ipoib_cm_tx *p;
1229 unsigned long flags;
1231 spin_lock_irqsave(&priv->lock, flags);
1233 while (!list_empty(&priv->cm.reap_list)) {
1234 p = list_entry(priv->cm.reap_list.next, typeof(*p), list);
1236 spin_unlock_irqrestore(&priv->lock, flags);
1237 ipoib_cm_tx_destroy(p);
1238 spin_lock_irqsave(&priv->lock, flags);
1241 spin_unlock_irqrestore(&priv->lock, flags);
1244 static void ipoib_cm_mb_reap(struct work_struct *work)
1246 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv,
1249 unsigned long flags;
1250 #if defined(INET) || defined(INET6)
1251 unsigned mtu = priv->mcast_mtu;
1255 spin_lock_irqsave(&priv->lock, flags);
1258 IF_DEQUEUE(&priv->cm.mb_queue, mb);
1261 spin_unlock_irqrestore(&priv->lock, flags);
1263 proto = htons(*mtod(mb, uint16_t *));
1264 m_adj(mb, IPOIB_ENCAP_LEN);
1268 icmp_error(mb, ICMP_UNREACH, ICMP_UNREACH_NEEDFRAG, 0, mtu);
1272 case ETHERTYPE_IPV6:
1273 icmp6_error(mb, ICMP6_PACKET_TOO_BIG, 0, mtu);
1280 spin_lock_irqsave(&priv->lock, flags);
1283 spin_unlock_irqrestore(&priv->lock, flags);
1287 ipoib_cm_mb_too_long(struct ipoib_dev_priv *priv, struct mbuf *mb, unsigned int mtu)
1289 int e = priv->cm.mb_queue.ifq_len;
1291 IF_ENQUEUE(&priv->cm.mb_queue, mb);
1293 queue_work(ipoib_workqueue, &priv->cm.mb_task);
1296 static void ipoib_cm_rx_reap(struct work_struct *work)
1298 ipoib_cm_free_rx_reap_list(container_of(work, struct ipoib_dev_priv,
1302 static void ipoib_cm_stale_task(struct work_struct *work)
1304 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv,
1305 cm.stale_task.work);
1306 struct ipoib_cm_rx *p;
1309 spin_lock_irq(&priv->lock);
1310 while (!list_empty(&priv->cm.passive_ids)) {
1311 /* List is sorted by LRU, start from tail,
1312 * stop when we see a recently used entry */
1313 p = list_entry(priv->cm.passive_ids.prev, typeof(*p), list);
1314 if (time_before_eq(jiffies, p->jiffies + IPOIB_CM_RX_TIMEOUT))
1316 list_move(&p->list, &priv->cm.rx_error_list);
1317 p->state = IPOIB_CM_RX_ERROR;
1318 spin_unlock_irq(&priv->lock);
1319 ret = ib_modify_qp(p->qp, &ipoib_cm_err_attr, IB_QP_STATE);
1321 ipoib_warn(priv, "unable to move qp to error state: %d\n", ret);
1322 spin_lock_irq(&priv->lock);
1325 if (!list_empty(&priv->cm.passive_ids))
1326 queue_delayed_work(ipoib_workqueue,
1327 &priv->cm.stale_task, IPOIB_CM_RX_DELAY);
1328 spin_unlock_irq(&priv->lock);
1332 static void ipoib_cm_create_srq(struct ipoib_dev_priv *priv, int max_sge)
1334 struct ib_srq_init_attr srq_init_attr = {
1336 .max_wr = ipoib_recvq_size,
1341 priv->cm.srq = ib_create_srq(priv->pd, &srq_init_attr);
1342 if (IS_ERR(priv->cm.srq)) {
1343 if (PTR_ERR(priv->cm.srq) != -ENOSYS)
1344 printk(KERN_WARNING "%s: failed to allocate SRQ, error %ld\n",
1345 priv->ca->name, PTR_ERR(priv->cm.srq));
1346 priv->cm.srq = NULL;
1350 priv->cm.srq_ring = kzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring, GFP_KERNEL);
1351 if (!priv->cm.srq_ring) {
1352 printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n",
1353 priv->ca->name, ipoib_recvq_size);
1354 ib_destroy_srq(priv->cm.srq);
1355 priv->cm.srq = NULL;
1359 memset(priv->cm.srq_ring, 0, ipoib_recvq_size * sizeof *priv->cm.srq_ring);
1362 int ipoib_cm_dev_init(struct ipoib_dev_priv *priv)
1364 struct ifnet *dev = priv->dev;
1366 struct ib_device_attr attr;
1368 INIT_LIST_HEAD(&priv->cm.passive_ids);
1369 INIT_LIST_HEAD(&priv->cm.reap_list);
1370 INIT_LIST_HEAD(&priv->cm.start_list);
1371 INIT_LIST_HEAD(&priv->cm.rx_error_list);
1372 INIT_LIST_HEAD(&priv->cm.rx_flush_list);
1373 INIT_LIST_HEAD(&priv->cm.rx_drain_list);
1374 INIT_LIST_HEAD(&priv->cm.rx_reap_list);
1375 INIT_WORK(&priv->cm.start_task, ipoib_cm_tx_start);
1376 INIT_WORK(&priv->cm.reap_task, ipoib_cm_tx_reap);
1377 INIT_WORK(&priv->cm.mb_task, ipoib_cm_mb_reap);
1378 INIT_WORK(&priv->cm.rx_reap_task, ipoib_cm_rx_reap);
1379 INIT_DELAYED_WORK(&priv->cm.stale_task, ipoib_cm_stale_task);
1381 bzero(&priv->cm.mb_queue, sizeof(priv->cm.mb_queue));
1382 mtx_init(&priv->cm.mb_queue.ifq_mtx,
1383 dev->if_xname, "if send queue", MTX_DEF);
1385 ret = ib_query_device(priv->ca, &attr);
1387 printk(KERN_WARNING "ib_query_device() failed with %d\n", ret);
1391 ipoib_dbg(priv, "max_srq_sge=%d\n", attr.max_srq_sge);
1393 attr.max_srq_sge = min_t(int, IPOIB_CM_RX_SG, attr.max_srq_sge);
1394 ipoib_cm_create_srq(priv, attr.max_srq_sge);
1395 if (ipoib_cm_has_srq(priv)) {
1396 priv->cm.max_cm_mtu = attr.max_srq_sge * MJUMPAGESIZE;
1397 priv->cm.num_frags = attr.max_srq_sge;
1398 ipoib_dbg(priv, "max_cm_mtu = 0x%x, num_frags=%d\n",
1399 priv->cm.max_cm_mtu, priv->cm.num_frags);
1401 priv->cm.max_cm_mtu = IPOIB_CM_MAX_MTU;
1402 priv->cm.num_frags = IPOIB_CM_RX_SG;
1405 ipoib_cm_init_rx_wr(priv, &priv->cm.rx_wr, priv->cm.rx_sge);
1407 if (ipoib_cm_has_srq(priv)) {
1408 for (i = 0; i < ipoib_recvq_size; ++i) {
1409 if (!ipoib_cm_alloc_rx_mb(priv, &priv->cm.srq_ring[i])) {
1410 ipoib_warn(priv, "failed to allocate "
1411 "receive buffer %d\n", i);
1412 ipoib_cm_dev_cleanup(priv);
1416 if (ipoib_cm_post_receive_srq(priv, i)) {
1417 ipoib_warn(priv, "ipoib_cm_post_receive_srq "
1418 "failed for buf %d\n", i);
1419 ipoib_cm_dev_cleanup(priv);
1425 IF_LLADDR(priv->dev)[0] = IPOIB_FLAGS_RC;
1429 void ipoib_cm_dev_cleanup(struct ipoib_dev_priv *priv)
1436 ipoib_dbg(priv, "Cleanup ipoib connected mode.\n");
1438 ret = ib_destroy_srq(priv->cm.srq);
1440 ipoib_warn(priv, "ib_destroy_srq failed: %d\n", ret);
1442 priv->cm.srq = NULL;
1443 if (!priv->cm.srq_ring)
1446 ipoib_cm_free_rx_ring(priv, priv->cm.srq_ring);
1447 priv->cm.srq_ring = NULL;
1449 mtx_destroy(&priv->cm.mb_queue.ifq_mtx);
1452 #endif /* CONFIG_INFINIBAND_IPOIB_CM */