ib_cm.c revision 16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file contains code imported from the OFED rds source file ib_cm.c
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Oracle elects to have and use the contents of ib_cm.c under and governed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by the OpenIB.org BSD license (see below for full license text). However,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the following notice accompanied the original version of this file:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright (c) 2006 Oracle. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This software is available to you under a choice of one of two
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * licenses. You may choose to be licensed under the terms of the GNU
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * General Public License (GPL) Version 2, available from the file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * COPYING in the main directory of this source tree, or the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OpenIB.org BSD license below:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Redistribution and use in source and binary forms, with or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * without modification, are permitted provided that the following
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * conditions are met:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Redistributions of source code must retain the above
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copyright notice, this list of conditions and the following
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * disclaimer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Redistributions in binary form must reproduce the above
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copyright notice, this list of conditions and the following
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * disclaimer in the documentation and/or other materials
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * provided with the distribution.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the selected protocol version
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_set_protocol(struct rdsv3_connection *conn, unsigned int version)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_DPRINTF4("rdsv3_ib_set_protocol", "conn: %p version: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set up flow control
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_set_flow_control(struct rdsv3_connection *conn, uint32_t credits)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_ib_connection *ic = conn->c_transport_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdsv3_ib_sysctl_flow_control && credits != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We're doing flow control */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Return: conn: %p credits: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Tune RNR behavior. Without flow control, we use a rather
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * low timeout, but not the absolute minimum - this should
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be tunable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We already set the RNR retry count to 7 (which is the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * smallest infinite number :-) above.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If flow control is off, we want to change this back to 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so that we learn quickly when our credit accounting is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Caller passes in a qp_attr pointer - don't waste stack spacv
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by allocation this twice.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_tune_rnr(struct rdsv3_ib_connection *ic, struct ib_qp_attr *attr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_DPRINTF2("rdsv3_ib_tune_rnr", "Enter ic: %p attr: %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ib_modify_qp(ic->i_cm_id->qp, attr, IB_QP_MIN_RNR_TIMER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ib_modify_qp(IB_QP_MIN_RNR_TIMER): err=%d", -ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Connection established.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We get here for both outgoing and incoming connection.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_cm_connect_complete(struct rdsv3_connection *conn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const struct rdsv3_ib_connect_private *dp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_ib_connection *ic = conn->c_transport_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ib_get_client_data(ic->i_cm_id->device, &rdsv3_ib_client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (event->param.conn.private_data_len >= sizeof (*dp)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make sure it isn't empty data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "RDS/IB: Connection to %u.%u.%u.%u version %u.%u failed",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "RDS/IB: connected to %u.%u.%u.%u version %u.%u%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ic->i_soft_cq = rdsv3_af_intr_thr_create(rdsv3_ib_tasklet_fn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)ic, SCQ_INTR_BIND_CPU, rds_ibdev->aft_hcagp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)ic, SCQ_INTR_BIND_CPU, rds_ibdev->aft_hcagp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ic->i_refill_rq = rdsv3_af_thr_create(rdsv3_ib_refill_fn, (void *)conn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ib_req_notify_cq(ic->i_cq, IB_CQ_SOLICITED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ib_req_notify_cq(ic->i_snd_cq, IB_CQ_NEXT_COMP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Init rings and fill recv. this needs to wait until protocol
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * negotiation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is complete, since ring layout is different from 3.0 to 3.1.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Post receive buffers - as a side effect, this will update
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the posted credit count.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Tune RNR behavior */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = ib_modify_qp(ic->i_cm_id->qp, &qp_attr, IB_QP_STATE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update ib_device with this local ipaddr & conn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = rdsv3_ib_update_ipaddr(rds_ibdev, conn->c_laddr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the peer gave us the last packet it saw, process this as if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we had received a regular ACK.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsv3_send_drop_acked(conn, ntohll(dp->dp_ack_seq), NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Return conn: %p event: %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_cm_fill_conn_param(struct rdsv3_connection *conn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_ib_connection *ic = conn->c_transport_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Enter conn: %p conn_param: %p private: %p version: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(conn_param, 0, sizeof (struct rdma_conn_param));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rds_ibdev = ib_get_client_data(ic->i_cm_id->device, &rdsv3_ib_client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MIN(rds_ibdev->max_responder_resources, max_responder_resources);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MIN(rds_ibdev->max_initiator_depth, max_initiator_depth);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conn_param->retry_count = min(rdsv3_ib_retry_count, 7);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dp->dp_protocol_major = RDS_PROTOCOL_MAJOR(protocol_version);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dp->dp_protocol_minor = RDS_PROTOCOL_MINOR(protocol_version);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Advertise flow control */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int credits;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Return conn: %p conn_param: %p private: %p version: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_cq_event_handler(struct ib_event *event, void *data)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_DPRINTF3("rdsv3_ib_cq_event_handler", "event %u data %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_snd_cq_comp_handler(struct ib_cq *cq, void *context)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_ib_connection *ic = conn->c_transport_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_ib_connection *ic = (struct rdsv3_ib_connection *)data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Poll in a loop before and after enabling the next event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ibt_poll_cq(RDSV3_CQ2CQHDL(ic->i_snd_cq), &wc, 1, &polled) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "wc_id 0x%llx type %d status %u byte_len %u imm_data %u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (unsigned long long)wc.wc_id, wc.wc_type, wc.wc_status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ibt_enable_cq_notify(RDSV3_CQ2CQHDL(ic->i_snd_cq),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ibt_poll_cq(RDSV3_CQ2CQHDL(ic->i_snd_cq), &wc, 1, &polled) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_cq_comp_handler(struct ib_cq *cq, void *context)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_ib_connection *ic = conn->c_transport_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_connection *conn = (struct rdsv3_connection *)data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_ib_connection *ic = (struct rdsv3_ib_connection *)data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Poll in a loop before and after enabling the next event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ibt_poll_cq(RDSV3_CQ2CQHDL(ic->i_cq), &wc, 1, &polled) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "wc_id 0x%llx type %d status %u byte_len %u imm_data %u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (unsigned long long)wc.wc_id, wc.wc_type, wc.wc_status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ibt_enable_cq_notify(RDSV3_CQ2CQHDL(ic->i_cq),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ack_state.ack_recv_valid && ack_state.ack_recv > ic->i_ack_recv) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsv3_send_drop_acked(conn, ack_state.ack_recv, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!test_bit(RDSV3_LL_SEND_FULL, &conn->c_flags))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_qp_event_handler(struct ib_event *event, void *data)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_ib_connection *ic = conn->c_transport_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_DPRINTF2("rdsv3_ib_qp_event_handler", "conn %p ic %p event %u",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) rdma_notify(ic->i_cm_id, IB_EVENT_COMM_EST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "RDS/IB: Fatal QP Event %u - "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "connection %u.%u.%u.%u ->%u.%u.%u.%u "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "...reconnecting",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "RDS/IB: Fatal QP Event %u - connection"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_DPRINTF2("rdsv3_ib_qp_event_handler", "Return conn: %p event: %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This needs to be very careful to not leave IS_ERR pointers around for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cleanup to trip over.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdsv3_ib_connection *ic = conn->c_transport_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_DPRINTF2("rdsv3_ib_setup_qp", "Enter conn: %p", conn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdsv3_ib_add_one creates a rdsv3_ib_device object per IB device,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and allocates a protection domain, memory range and FMR pool
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for each. If that fails for any reason, it will not register
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the rds_ibdev at all.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rds_ibdev = ib_get_client_data(dev, &rdsv3_ib_client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "RDS/IB: No client_data for device %s", dev->name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rds_ibdev->max_wrs < ic->i_send_ring.w_nr + 1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsv3_ib_ring_resize(&ic->i_send_ring, rds_ibdev->max_wrs - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rds_ibdev->max_wrs < ic->i_recv_ring.w_nr + 1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsv3_ib_ring_resize(&ic->i_recv_ring, rds_ibdev->max_wrs - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Protection domain and memory range */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IB_CQ_VECTOR_LEAST_ATTACHED and/or the corresponding feature is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not implmeneted in Hermon yet, but we can pass it to ib_create_cq()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ic->i_cq = ib_create_cq(dev, rdsv3_ib_cq_comp_handler,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (intptr_t)rdsv3_af_grp_get_sched(ic->rds_ibdev->aft_hcagp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ic->i_snd_cq = ib_create_cq(dev, rdsv3_ib_snd_cq_comp_handler,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsv3_ib_cq_event_handler, conn, ic->i_send_ring.w_nr + 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (intptr_t)rdsv3_af_grp_get_sched(ic->rds_ibdev->aft_hcagp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX negotiate max send/recv with remote? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* + 1 to allow for the single ack message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * XXX this can fail if max_*_wr is too large? Are we supposed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to back off until we get a value that the hardware can support?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = rdma_create_qp(ic->i_cm_id, ic->i_pd, &attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(ic->i_sends, 0, ic->i_send_ring.w_nr *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct rdsv3_ib_send_work));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_alloc(RDSV3_IB_SEND_WRS * (sizeof (ibt_send_wr_t) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_IB_MAX_SGE * sizeof (ibt_wr_ds_t)), KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sgl = (ibt_wr_ds_t *)((uint8_t *)ic->i_send_wrs +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < RDSV3_IB_SEND_WRS; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(ic->i_recvs, 0, ic->i_recv_ring.w_nr *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct rdsv3_ib_recv_work));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_alloc(ic->i_recv_ring.w_nr * sizeof (ibt_recv_wr_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_DPRINTF2("rdsv3_ib_setup_qp", "conn %p pd %p mr %p cq %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_protocol_compatible(struct rdma_cm_event *event)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_DPRINTF2("rdsv3_ib_protocol_compatible", "Enter event: %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdma_cm private data is odd - when there is any private data in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * request, we will be given a pretty large buffer without telling us
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * original size. The only way to tell the difference is by looking at
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the contents, which are initialized to zero.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the protocol version fields aren't set,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this is a connection attempt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from an older version. This could could be 3.0 or 2.0 -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we can't tell.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We really should have changed this for OFED 1.3 :-(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Be paranoid. RDS always has privdata */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "RDS incoming connection has no private data, rejecting");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Even if len is crap *now* I still want to check it. -ASG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (event->param.conn.private_data_len < sizeof (*dp) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "RDS: Connection from %u.%u.%u.%u using "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "incompatible protocol version %u.%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDSV3_DPRINTF2("rdsv3_ib_protocol_compatible", "Return event: %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdsv3_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_be_t lguid = cm_id->route.path_rec->sgid.global.interface_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_be_t fguid = cm_id->route.path_rec->dgid.global.interface_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check whether the remote protocol version matches ours. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "version mismatch");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "saddr %u.%u.%u.%u daddr %u.%u.%u.%u RDSv%d.%d lguid 0x%llx fguid "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "0x%llx", NIPQUAD(dp->dp_saddr), NIPQUAD(dp->dp_daddr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDS_PROTOCOL_MAJOR(version), RDS_PROTOCOL_MINOR(version),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conn = rdsv3_conn_create(dp->dp_daddr, dp->dp_saddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "rdsv3_conn_create failed (%ld)", PTR_ERR(conn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The connection request may occur while the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * previous connection exist, e.g. in case of failover.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * But as connections may be initiated simultaneously
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by both hosts, we have a random backoff mechanism -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * see the comment above rdsv3_queue_reconnect()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdsv3_conn_transition(conn, RDSV3_CONN_DOWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "incoming connect when connected: %p",
goto out;
goto out;
RDSV3_PANIC();
destroy = 0;
if (err) {
goto out;
if (err) {
goto out;
out:
return (destroy);
int ret;
cm_id);
if (ret) {
goto out;
if (ret) {
out:
if (ret) {
ret = 0;
return (ret);
int ret;
goto out;
if (ret == 0) {
if (ret) {
out:
return (ret);
int err = 0;
if (err) {
(void) ibt_flush_qp(
if (rdsv3_enable_snd_cq) {
(sizeof (ibt_send_wr_t) +
(sizeof (ibt_recv_wr_t)));
static int conn_cnt;
if (!ic)
return (-ENOMEM);
#ifndef __lock_lint