iser.c revision 30e7468f8f41aa30ada067b2c1d5d284046514da
6fb9b25791778f69002eb72be6235e20d98ec452Tinderbox User * CDDL HEADER START
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * The contents of this file are subject to the terms of the
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Common Development and Distribution License (the "License").
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * You may not use this file except in compliance with the License.
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * See the License for the specific language governing permissions
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * and limitations under the License.
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * When distributing Covered Code, include this CDDL HEADER in each
e7fb847ed570dd8c1bcdacabb3d69bd81feb79aeMark Andrews * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d4034b48fd112ef43933f1455b194b5249a88ee6Mark Andrews * If applicable, add the following below this CDDL HEADER, with the
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * fields enclosed by brackets "[]" replaced with your own identifying
996f4a8bc34cb0203ce6a40ff82bca8bf32423ccAndreas Gustafsson * information: Portions Copyright [yyyy] [name of copyright owner]
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont * CDDL HEADER END
364a82f7c25b62967678027043425201a5e5171aBob Halley * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * Use is subject to license terms.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * DDI and core routines for Solaris iSER implementation.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeiniser_state_t *iser_state = NULL; /* global state */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinddi_taskq_t *iser_taskq = NULL; /* global taskq */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/* set B_TRUE for console logging */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/* Driver functions */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinstatic int iser_attach(dev_info_t *, ddi_attach_cmd_t);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinstatic int iser_detach(dev_info_t *, ddi_detach_cmd_t);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinstatic int iser_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinstatic int iser_open(dev_t *, int, int, cred_t *);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinstatic int iser_close(dev_t, int, int, cred_t *);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinstatic int iser_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/* static int iser_close(dev_t, int, int, cred_t *); */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/* Char/Block operations */
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson/* Device operations */
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson 0, /* refcnt */
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence/* Module Driver Info */
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence#define ISER_NAME_VERSION "iSCSI Extensions for RDMA"
9e933a78a3177fab864723ee9a2aab8aad1be526Andreas Gustafsson/* Module Linkage */
9e933a78a3177fab864723ee9a2aab8aad1be526Andreas Gustafssonstatic struct modlinkage iser_modlinkage = {
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence iser_state = kmem_zalloc(sizeof (iser_state_t), KM_SLEEP);
f0131db6c395757c88526db8e8071921e33a5211David Lawrence kmem_free(iser_state, sizeof (iser_state_t));
56a2bee13318d8bb4578434d60c82a65c32ace28David Lawrence kmem_free(iser_state, sizeof (iser_state_t));
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * iser_attach()
a8da00ef95ba37b9d071c2b8db1a0c967e060106Mark Andrewsiser_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson /* Initialize the open refcnt and it's lock */
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson mutex_init(&iser_state->is_refcnt_lock, NULL, MUTEX_DRIVER,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein iser_taskq = ddi_taskq_create(dip, "iser_taskq",
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson ISER_TASKQ_NTHREADS, TASKQ_DEFAULTPRI, 0);
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson ISER_LOG(CE_CONT, "%s%d: failed to create taskq",
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson mutex_destroy(&iser_state->is_refcnt_lock);
e13efecaa524364f9bc8706c79e90ad2525616f7David Lawrence /* initialize iSER as IB service */
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson mutex_destroy(&iser_state->is_refcnt_lock);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein ISER_LOG(CE_CONT, "%s%d: failed to initialize IB",
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson dip, ddi_get_name(dip), S_IFCHR, instance,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein ISER_LOG(CE_CONT, "%s%d: failed ddi_create_minor_node",
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein ISER_LOG(CE_CONT, "iser_detach: DDI_RESUME unsupported");
f30785f506a522ed6a5e394af2bb13b6f883927eEvan Hunt ISER_LOG(CE_CONT, "%s%d: unknown cmd in attach (0x%x)", "iser",
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * iser_detach()
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafssoniser_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson mutex_destroy(&iser_state->is_refcnt_lock);
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson ISER_LOG(CE_CONT, "iser_detach: DDI_DETACH");
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson ISER_LOG(CE_CONT, "iser_detach: DDI_SUSPEND unsupported");
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson ISER_LOG(CE_CONT, "iser: unknown cmd in detach (0x%x)", cmd);
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * iser_getinfo()
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence/* ARGSUSED */
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafssoniser_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence/* ARGSUSED */
f30785f506a522ed6a5e394af2bb13b6f883927eEvan Huntiser_open(dev_t *devp, int flag, int otyp, cred_t *credp)
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson /* Register the transport with IDM */
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson ISER_LOG(CE_CONT, "%s%d: failed to register with IDM",
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson /* Increment our open refcnt */
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * iser_close()
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/* ARGSUSED */
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrenceiser_close(dev_t devp, int flag, int otyp, cred_t *credp)
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafssoniser_deregister_service(idm_svc_t *idm_svc)
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * iser_path_exists
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * This function takes in a pair of endpoints and determines if an iSER path
91ed1cc821ccef38c30f3fcaad32d78233fad94bMark Andrews * exists between the two. The actual path information (required for creating
f30785f506a522ed6a5e394af2bb13b6f883927eEvan Hunt * a RC channel) is not returned, instead a boolean value indicating if a path
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * exists is returned.
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * To use an implicit source, a value of NULL is allowed for laddr.
f30785f506a522ed6a5e394af2bb13b6f883927eEvan Huntiser_path_exists(idm_sockaddr_t *laddr, idm_sockaddr_t *raddr)
91ed1cc821ccef38c30f3fcaad32d78233fad94bMark Andrews iser_ib_conv_sockaddr2ibtaddr(raddr, &remote_ip);
f30785f506a522ed6a5e394af2bb13b6f883927eEvan Hunt status = iser_ib_get_paths(&local_ip, &remote_ip, &path, NULL);
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson return ((status == IBT_SUCCESS) ? B_TRUE : B_FALSE);
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff * iser_channel_alloc
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * This function allocates a reliable communication channel between the
996f4a8bc34cb0203ce6a40ff82bca8bf32423ccAndreas Gustafsson * given endpoints.
996f4a8bc34cb0203ce6a40ff82bca8bf32423ccAndreas Gustafssoniser_channel_alloc(idm_sockaddr_t *laddr, idm_sockaddr_t *raddr)
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff iser_ib_conv_sockaddr2ibtaddr(raddr, &remote_ip);
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson iser_ib_conv_sockaddr2ibtaddr(laddr, &local_ip);
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (iser_ib_alloc_rc_channel(&local_ip, &remote_ip));
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * iser_channel_open
996f4a8bc34cb0203ce6a40ff82bca8bf32423ccAndreas Gustafsson * This function opens the already allocated communication channel between the
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * two endpoints.
3532ed3bbda3b7daa2373513e51a6f04d0dd3ddaAndreas Gustafsson * iser_channel_close
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews * This function closes the already opened communication channel between the
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff * two endpoints.
ec9f7bd203028162522b225d7731f0a52aca7727Andreas Gustafsson * iser_channel_free
996f4a8bc34cb0203ce6a40ff82bca8bf32423ccAndreas Gustafsson * This function frees the channel between the given endpoints
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff/* ARGSUSED */