4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2000 by Cisco Systems, Inc. All rights reserved.
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 *
25 * iSCSI Software Initiator
26 */
27
28 /*
29 * Framework interface routines for iSCSI
30 */
31
32 #include "iscsi.h" /* main header */
33 #include <sys/iscsi_protocol.h> /* protocol structs */
34 #include <sys/scsi/adapters/iscsi_if.h> /* ioctl interfaces */
35 #include "iscsi_targetparam.h"
36 #include "persistent.h"
37 #include <sys/scsi/adapters/iscsi_door.h>
38 #include <sys/dlpi.h>
39 #include <sys/utsname.h>
40 #include "isns_client.h"
41 #include "isns_protocol.h"
42 #include <sys/bootprops.h>
43 #include <sys/types.h>
835 if (bp && (bp->b_bcount != 0) &&
836 bp_mapin_common(bp, (callback == NULL_FUNC) ?
837 VM_NOSLEEP : VM_SLEEP) == NULL) {
838 return (NULL);
839 }
840
841 ilp = (iscsi_lun_t *)ap->a_hba_tran->tran_tgt_private;
842 ASSERT(ilp != NULL);
843
844 if (pkt == NULL) {
845 pkt = scsi_hba_pkt_alloc(ilp->lun_sess->sess_hba->hba_dip,
846 ap, cmdlen, statuslen, tgtlen, sizeof (iscsi_cmd_t),
847 callback, arg);
848 if (pkt == NULL) {
849 return (NULL);
850 }
851 icmdp = (iscsi_cmd_t *)pkt->pkt_ha_private;
852 icmdp->cmd_sig = ISCSI_SIG_CMD;
853 icmdp->cmd_state = ISCSI_CMD_STATE_FREE;
854 icmdp->cmd_lun = ilp;
855 icmdp->cmd_type = ISCSI_CMD_TYPE_SCSI;
856 /* add the report lun addressing type on to the lun */
857 icmdp->cmd_un.scsi.lun = ilp->lun_addr_type << 14;
858 icmdp->cmd_un.scsi.lun = icmdp->cmd_un.scsi.lun |
859 ilp->lun_num;
860 icmdp->cmd_un.scsi.pkt = pkt;
861 icmdp->cmd_un.scsi.bp = bp;
862 icmdp->cmd_un.scsi.cmdlen = cmdlen;
863 icmdp->cmd_un.scsi.statuslen = statuslen;
864 icmdp->cmd_crc_error_seen = B_FALSE;
865 icmdp->cmd_misc_flags = 0;
866 if (flags & PKT_XARQ) {
867 icmdp->cmd_misc_flags |= ISCSI_CMD_MISCFLAG_XARQ;
868 }
869
870
871 idm_sm_audit_init(&icmdp->cmd_state_audit);
872
873 mutex_init(&icmdp->cmd_mutex, NULL, MUTEX_DRIVER, NULL);
874 cv_init(&icmdp->cmd_completion, NULL, CV_DRIVER, NULL);
1078 iscsi_tran_setcap(struct scsi_address *ap, char *cap, int value, int whom)
1079 {
1080 return (iscsi_i_commoncap(ap, cap, value, whom, 1));
1081 }
1082
1083
1084 /*
1085 * iscsi_tran_destroy_pkt - Clean up packet
1086 */
1087 static void
1088 iscsi_tran_destroy_pkt(struct scsi_address *ap, struct scsi_pkt *pkt)
1089 {
1090 iscsi_cmd_t *icmdp;
1091
1092 icmdp = (iscsi_cmd_t *)pkt->pkt_ha_private;
1093
1094 ASSERT(icmdp != NULL);
1095 ASSERT(icmdp->cmd_sig == ISCSI_SIG_CMD);
1096 ASSERT(icmdp->cmd_state == ISCSI_CMD_STATE_FREE);
1097
1098 mutex_destroy(&icmdp->cmd_mutex);
1099 cv_destroy(&icmdp->cmd_completion);
1100 scsi_hba_pkt_free(ap, pkt);
1101 }
1102
1103 /*
1104 * iscsi_tran_dmafree - This is a software driver, NO DMA
1105 */
1106 /* ARGSUSED */
1107 static void
1108 iscsi_tran_dmafree(struct scsi_address *ap, struct scsi_pkt *pkt)
1109 {
1110 /*
1111 * The iSCSI interface doesn't deal with DMA
1112 */
1113 }
1114
1115 /*
1116 * iscsi_tran_sync_pkt - This is a software driver, NO DMA
1117 */
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2000 by Cisco Systems, Inc. All rights reserved.
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
25 *
26 * iSCSI Software Initiator
27 */
28
29 /*
30 * Framework interface routines for iSCSI
31 */
32
33 #include "iscsi.h" /* main header */
34 #include <sys/iscsi_protocol.h> /* protocol structs */
35 #include <sys/scsi/adapters/iscsi_if.h> /* ioctl interfaces */
36 #include "iscsi_targetparam.h"
37 #include "persistent.h"
38 #include <sys/scsi/adapters/iscsi_door.h>
39 #include <sys/dlpi.h>
40 #include <sys/utsname.h>
41 #include "isns_client.h"
42 #include "isns_protocol.h"
43 #include <sys/bootprops.h>
44 #include <sys/types.h>
836 if (bp && (bp->b_bcount != 0) &&
837 bp_mapin_common(bp, (callback == NULL_FUNC) ?
838 VM_NOSLEEP : VM_SLEEP) == NULL) {
839 return (NULL);
840 }
841
842 ilp = (iscsi_lun_t *)ap->a_hba_tran->tran_tgt_private;
843 ASSERT(ilp != NULL);
844
845 if (pkt == NULL) {
846 pkt = scsi_hba_pkt_alloc(ilp->lun_sess->sess_hba->hba_dip,
847 ap, cmdlen, statuslen, tgtlen, sizeof (iscsi_cmd_t),
848 callback, arg);
849 if (pkt == NULL) {
850 return (NULL);
851 }
852 icmdp = (iscsi_cmd_t *)pkt->pkt_ha_private;
853 icmdp->cmd_sig = ISCSI_SIG_CMD;
854 icmdp->cmd_state = ISCSI_CMD_STATE_FREE;
855 icmdp->cmd_lun = ilp;
856 iscsi_lun_hold(ilp);
857 icmdp->cmd_type = ISCSI_CMD_TYPE_SCSI;
858 /* add the report lun addressing type on to the lun */
859 icmdp->cmd_un.scsi.lun = ilp->lun_addr_type << 14;
860 icmdp->cmd_un.scsi.lun = icmdp->cmd_un.scsi.lun |
861 ilp->lun_num;
862 icmdp->cmd_un.scsi.pkt = pkt;
863 icmdp->cmd_un.scsi.bp = bp;
864 icmdp->cmd_un.scsi.cmdlen = cmdlen;
865 icmdp->cmd_un.scsi.statuslen = statuslen;
866 icmdp->cmd_crc_error_seen = B_FALSE;
867 icmdp->cmd_misc_flags = 0;
868 if (flags & PKT_XARQ) {
869 icmdp->cmd_misc_flags |= ISCSI_CMD_MISCFLAG_XARQ;
870 }
871
872
873 idm_sm_audit_init(&icmdp->cmd_state_audit);
874
875 mutex_init(&icmdp->cmd_mutex, NULL, MUTEX_DRIVER, NULL);
876 cv_init(&icmdp->cmd_completion, NULL, CV_DRIVER, NULL);
1080 iscsi_tran_setcap(struct scsi_address *ap, char *cap, int value, int whom)
1081 {
1082 return (iscsi_i_commoncap(ap, cap, value, whom, 1));
1083 }
1084
1085
1086 /*
1087 * iscsi_tran_destroy_pkt - Clean up packet
1088 */
1089 static void
1090 iscsi_tran_destroy_pkt(struct scsi_address *ap, struct scsi_pkt *pkt)
1091 {
1092 iscsi_cmd_t *icmdp;
1093
1094 icmdp = (iscsi_cmd_t *)pkt->pkt_ha_private;
1095
1096 ASSERT(icmdp != NULL);
1097 ASSERT(icmdp->cmd_sig == ISCSI_SIG_CMD);
1098 ASSERT(icmdp->cmd_state == ISCSI_CMD_STATE_FREE);
1099
1100 iscsi_lun_rele(icmdp->cmd_lun);
1101 mutex_destroy(&icmdp->cmd_mutex);
1102 cv_destroy(&icmdp->cmd_completion);
1103 scsi_hba_pkt_free(ap, pkt);
1104 }
1105
1106 /*
1107 * iscsi_tran_dmafree - This is a software driver, NO DMA
1108 */
1109 /* ARGSUSED */
1110 static void
1111 iscsi_tran_dmafree(struct scsi_address *ap, struct scsi_pkt *pkt)
1112 {
1113 /*
1114 * The iSCSI interface doesn't deal with DMA
1115 */
1116 }
1117
1118 /*
1119 * iscsi_tran_sync_pkt - This is a software driver, NO DMA
1120 */
|