/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* IB CM handlers for s Solaris SCSI RDMA Protocol Target (SRP)
* transport port provider module for the COMSTAR framework.
*/
#include <sys/sysmacros.h>
#include <sys/stmf_ioctl.h>
#include "srp.h"
#include "srpt_impl.h"
#include "srpt_cm.h"
#include "srpt_stp.h"
#include "srpt_ch.h"
extern uint16_t srpt_send_msg_depth;
extern srpt_ctxt_t *srpt_ctxt;
/*
* srpt_cm_req_hdlr() - Login request
*
* CM has called back with a CM REQ message associated with an
* SRP initiator login request.
*/
static ibt_cm_status_t
{
SRPT_DPRINTF_L2("cm_req_hdlr, IU size expected (>= %d),"
return (IBT_CM_REJECT);
}
SRPT_DPRINTF_L2("cm_req_hdlr, NULL ULP private data pointer");
return (IBT_CM_REJECT);
}
if (ret_priv_data_len < sizeof (srp_login_rej_t)) {
SRPT_DPRINTF_L2("cm_req_hdlr, return private len too"
" small (%d)", ret_priv_data_len);
return (IBT_CM_REJECT);
}
if (ret_priv_data == NULL) {
SRPT_DPRINTF_L2("cm_req_hdlr, NULL ULP return private data"
" pointer");
return (IBT_CM_REJECT);
}
/*
* Copy to avoid potential alignment problems, process login
* creating a new channel and possibly session.
*/
SRPT_DPRINTF_L3("cm_req_hdlr, rsp priv len(%d)"
" ch created on port(%d)"
", cm_req_hdlr, req ra_out(%d), ra_in(%d)"
", retry(%d)",
req->req_retry_cnt);
SRPT_DPRINTF_L3("cm_req_hdlr, hca_max_rdma_in_chan (%d)"
", hca_max_rdma_out_chan (%d)"
", updated ra_out(%d), ra_in(%d), retry(%d)",
} else {
}
return (status);
}
/*
* srpt_cm_conn_est_hdlr() - Connection established
*
* CM has called back to inform us that a connection attempt has
* completed (explicit or implicit) and may now be used.
*/
/* ARGSUSED */
static ibt_cm_status_t
{
SRPT_DPRINTF_L3("cm_conn_est_hdlr, invoked for ch(%p)",
(void *)ch);
SRPT_DPRINTF_L2("cm_conn_est_hdlr, invalid ch state (%d)",
return (IBT_CM_REJECT);
}
return (IBT_CM_ACCEPT);
}
/*
* srpt_cm_conn_closed_hdlr() - Channel closed
*
* CM callback indicating a channel has been completely closed.
*/
/* ARGSUSED */
static ibt_cm_status_t
{
SRPT_DPRINTF_L3("cm_conn_closed_hdlr, invoked for chan_hdl(%p),"
case IBT_CM_CLOSED_DREP_RCVD:
case IBT_CM_CLOSED_DUP:
case IBT_CM_CLOSED_ABORT:
case IBT_CM_CLOSED_ALREADY:
/*
* These cases indicate the SRP target initiated
* the closing of the channel and it is now closed.
* Cleanup the channel (which will remove the targets
* reference) and then release CM's reference.
*/
SRPT_DPRINTF_L3("cm_conn_closed_hdlr, local close call-back");
break;
case IBT_CM_CLOSED_DREQ_RCVD:
case IBT_CM_CLOSED_REJ_RCVD:
case IBT_CM_CLOSED_STALE:
/*
* These cases indicate that the SRP initiator is closing
* the channel. CM will have already closed the RC channel,
* so simply initiate cleanup which will remove the target
* ports reference to the channel and then release the
* reference held by the CM.
*/
SRPT_DPRINTF_L3("cm_conn_closed_hdlr, remote close,"
" free channel");
} else {
SRPT_DPRINTF_L2("cm_conn_closed_hdlr, NULL channel");
}
break;
default:
SRPT_DPRINTF_L2("cm_conn_closed_hdlr, unknown close type (%d)",
break;
}
return (status);
}
/*
* srpt_cm_failure_hdlr() - Called when the channel is in error. Cleanup
* and release the channel.
*/
static ibt_cm_status_t
{
SRPT_DPRINTF_L3("cm_failure_hdlr, chan_hdl: 0x%p, code: %d"
return (IBT_CM_ACCEPT);
}
/*
* srpt_cm_hdlr() - CM call-back handler.
*/
{
case IBT_CM_EVENT_REQ_RCV:
SRPT_DPRINTF_L3("cm_hdlr, REQ received");
break;
case IBT_CM_EVENT_REP_RCV:
SRPT_DPRINTF_L3("cm_hdlr, REP received");
break;
case IBT_CM_EVENT_MRA_RCV:
SRPT_DPRINTF_L3("cm_hdlr, MRA received");
break;
case IBT_CM_EVENT_CONN_EST:
SRPT_DPRINTF_L3("cm_hdlr, Connection established");
break;
case IBT_CM_EVENT_CONN_CLOSED:
SRPT_DPRINTF_L3("cm_hdlr, Connection closed");
break;
case IBT_CM_EVENT_FAILURE:
SRPT_DPRINTF_L3("cm_hdlr, Event failure");
break;
case IBT_CM_EVENT_LAP_RCV:
SRPT_DPRINTF_L3("cm_hdlr, LAP received");
break;
case IBT_CM_EVENT_APR_RCV:
SRPT_DPRINTF_L3("cm_hdlr, APR received");
break;
default:
SRPT_DPRINTF_L3("cm_hdlr, unknown event received");
break;
}
return (status);
}