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 /*
23 * Copyright 2000 by Cisco Systems, Inc. All rights reserved.
24 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
26 */
27
28 #ifndef _ISCSI_H
29 #define _ISCSI_H
30
31 /*
32 * Block comment which describes the contents of this file.
33 */
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #include <sys/scsi/scsi.h>
40 #include <sys/ddi.h>
41 #include <sys/sunddi.h>
42 #include <sys/socket.h>
43 #include <sys/kstat.h>
44 #include <sys/sunddi.h>
45 #include <sys/sunmdi.h>
532
533 struct iscsi_lun *lun_next; /* next lun on this sess. */
534 struct iscsi_sess *lun_sess; /* parent sess. for lun */
535 dev_info_t *lun_dip;
536 mdi_pathinfo_t *lun_pip;
537
538 uint16_t lun_num; /* LUN */
539 uint8_t lun_addr_type; /* LUN addressing type */
540 uint32_t lun_oid; /* OID */
541 char *lun_guid; /* GUID */
542 int lun_guid_size; /* GUID allocation size */
543 char *lun_addr; /* sess,lun */
544 time_t lun_time_online;
545
546 uchar_t lun_cap; /* bitmap of scsi caps */
547
548 uchar_t lun_vid[ISCSI_INQ_VID_BUF_LEN]; /* Vendor ID */
549 uchar_t lun_pid[ISCSI_INQ_PID_BUF_LEN]; /* Product ID */
550
551 uchar_t lun_type;
552 } iscsi_lun_t;
553
554 #define ISCSI_LUN_STATE_CLEAR 0 /* used to clear all states */
555 #define ISCSI_LUN_STATE_OFFLINE 1
556 #define ISCSI_LUN_STATE_ONLINE 2
557 #define ISCSI_LUN_STATE_INVALID 4 /* offline failed */
558 #define ISCSI_LUN_STATE_BUSY 8 /* logic unit is in reset */
559
560 #define ISCSI_LUN_CAP_RESET 0x01
561
562 #define ISCSI_SCSI_RESET_SENSE_CODE 0x29
563 #define ISCSI_SCSI_LUNCHANGED_CODE 0x3f
564
565 #define ISCSI_SCSI_LUNCHANGED_ASCQ 0x0e
566
567 /*
568 *
569 *
570 */
571 typedef struct iscsi_queue {
1310 iscsi_enum_result_t iscsi_sess_enum_query(iscsi_sess_t *isp);
1311 void iscsi_sess_enter_state_zone(iscsi_sess_t *isp);
1312 void iscsi_sess_exit_state_zone(iscsi_sess_t *isp);
1313
1314 /* iscsi_conn.c */
1315 iscsi_status_t iscsi_conn_create(struct sockaddr *addr, iscsi_sess_t *isp,
1316 iscsi_conn_t **icpp);
1317 iscsi_status_t iscsi_conn_online(iscsi_conn_t *icp);
1318 iscsi_status_t iscsi_conn_offline(iscsi_conn_t *icp);
1319 iscsi_status_t iscsi_conn_destroy(iscsi_conn_t *icp);
1320 void iscsi_conn_set_login_min_max(iscsi_conn_t *icp, int min, int max);
1321 iscsi_status_t iscsi_conn_sync_params(iscsi_conn_t *icp);
1322 void iscsi_conn_retry(iscsi_sess_t *isp, iscsi_conn_t *icp);
1323 void iscsi_conn_update_state(iscsi_conn_t *icp, iscsi_conn_state_t next_state);
1324 void iscsi_conn_update_state_locked(iscsi_conn_t *icp,
1325 iscsi_conn_state_t next_state);
1326
1327 /* iscsi_lun.c */
1328 iscsi_status_t iscsi_lun_create(iscsi_sess_t *isp, uint16_t lun_num,
1329 uint8_t lun_addr_type, struct scsi_inquiry *inq, char *guid);
1330 iscsi_status_t iscsi_lun_destroy(iscsi_hba_t *ihp,
1331 iscsi_lun_t *ilp);
1332 void iscsi_lun_online(iscsi_hba_t *ihp,
1333 iscsi_lun_t *ilp);
1334 iscsi_status_t iscsi_lun_offline(iscsi_hba_t *ihp,
1335 iscsi_lun_t *ilp, boolean_t lun_free);
1336
1337 /* iscsi_cmd.c */
1338 void iscsi_cmd_state_machine(iscsi_cmd_t *icmdp,
1339 iscsi_cmd_event_t event, void *arg);
1340 iscsi_cmd_t *iscsi_cmd_alloc(iscsi_conn_t *icp, int km_flags);
1341 void iscsi_cmd_free(iscsi_cmd_t *icmdp);
1342
1343 /* iscsi_ioctl.c */
1344 void * iscsi_ioctl_copyin(caddr_t arg, int mode, size_t size);
1345 int iscsi_ioctl_copyout(void *data, size_t size, caddr_t arg, int mode);
1346 iscsi_conn_list_t *iscsi_ioctl_conn_oid_list_get_copyin(caddr_t, int);
1347 int iscsi_ioctl_conn_oid_list_get_copyout(iscsi_conn_list_t *, caddr_t, int);
1348 boolean_t iscsi_ioctl_conn_oid_list_get(iscsi_hba_t *ihp,
1349 iscsi_conn_list_t *cl);
1350 boolean_t iscsi_ioctl_conn_props_get(iscsi_hba_t *ihp, iscsi_conn_props_t *cp);
1351 int iscsi_ioctl_sendtgts_get(iscsi_hba_t *ihp, iscsi_sendtgts_list_t *stl);
|
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 /*
23 * Copyright 2000 by Cisco Systems, Inc. All rights reserved.
24 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright 2014-2015 Nexenta Systems, Inc. All rights reserved.
26 */
27
28 #ifndef _ISCSI_H
29 #define _ISCSI_H
30
31 /*
32 * Block comment which describes the contents of this file.
33 */
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #include <sys/scsi/scsi.h>
40 #include <sys/ddi.h>
41 #include <sys/sunddi.h>
42 #include <sys/socket.h>
43 #include <sys/kstat.h>
44 #include <sys/sunddi.h>
45 #include <sys/sunmdi.h>
532
533 struct iscsi_lun *lun_next; /* next lun on this sess. */
534 struct iscsi_sess *lun_sess; /* parent sess. for lun */
535 dev_info_t *lun_dip;
536 mdi_pathinfo_t *lun_pip;
537
538 uint16_t lun_num; /* LUN */
539 uint8_t lun_addr_type; /* LUN addressing type */
540 uint32_t lun_oid; /* OID */
541 char *lun_guid; /* GUID */
542 int lun_guid_size; /* GUID allocation size */
543 char *lun_addr; /* sess,lun */
544 time_t lun_time_online;
545
546 uchar_t lun_cap; /* bitmap of scsi caps */
547
548 uchar_t lun_vid[ISCSI_INQ_VID_BUF_LEN]; /* Vendor ID */
549 uchar_t lun_pid[ISCSI_INQ_PID_BUF_LEN]; /* Product ID */
550
551 uchar_t lun_type;
552 kmutex_t lun_mutex;
553 int lun_refcnt;
554 } iscsi_lun_t;
555
556 #define ISCSI_LUN_STATE_CLEAR 0 /* used to clear all states */
557 #define ISCSI_LUN_STATE_OFFLINE 1
558 #define ISCSI_LUN_STATE_ONLINE 2
559 #define ISCSI_LUN_STATE_INVALID 4 /* offline failed */
560 #define ISCSI_LUN_STATE_BUSY 8 /* logic unit is in reset */
561
562 #define ISCSI_LUN_CAP_RESET 0x01
563
564 #define ISCSI_SCSI_RESET_SENSE_CODE 0x29
565 #define ISCSI_SCSI_LUNCHANGED_CODE 0x3f
566
567 #define ISCSI_SCSI_LUNCHANGED_ASCQ 0x0e
568
569 /*
570 *
571 *
572 */
573 typedef struct iscsi_queue {
1312 iscsi_enum_result_t iscsi_sess_enum_query(iscsi_sess_t *isp);
1313 void iscsi_sess_enter_state_zone(iscsi_sess_t *isp);
1314 void iscsi_sess_exit_state_zone(iscsi_sess_t *isp);
1315
1316 /* iscsi_conn.c */
1317 iscsi_status_t iscsi_conn_create(struct sockaddr *addr, iscsi_sess_t *isp,
1318 iscsi_conn_t **icpp);
1319 iscsi_status_t iscsi_conn_online(iscsi_conn_t *icp);
1320 iscsi_status_t iscsi_conn_offline(iscsi_conn_t *icp);
1321 iscsi_status_t iscsi_conn_destroy(iscsi_conn_t *icp);
1322 void iscsi_conn_set_login_min_max(iscsi_conn_t *icp, int min, int max);
1323 iscsi_status_t iscsi_conn_sync_params(iscsi_conn_t *icp);
1324 void iscsi_conn_retry(iscsi_sess_t *isp, iscsi_conn_t *icp);
1325 void iscsi_conn_update_state(iscsi_conn_t *icp, iscsi_conn_state_t next_state);
1326 void iscsi_conn_update_state_locked(iscsi_conn_t *icp,
1327 iscsi_conn_state_t next_state);
1328
1329 /* iscsi_lun.c */
1330 iscsi_status_t iscsi_lun_create(iscsi_sess_t *isp, uint16_t lun_num,
1331 uint8_t lun_addr_type, struct scsi_inquiry *inq, char *guid);
1332 void iscsi_lun_hold(iscsi_lun_t *ilp);
1333 void iscsi_lun_rele(iscsi_lun_t *ilp);
1334 iscsi_status_t iscsi_lun_destroy(iscsi_hba_t *ihp, iscsi_lun_t *ilp);
1335 void iscsi_lun_online(iscsi_hba_t *ihp,
1336 iscsi_lun_t *ilp);
1337 iscsi_status_t iscsi_lun_offline(iscsi_hba_t *ihp,
1338 iscsi_lun_t *ilp, boolean_t lun_free);
1339
1340 /* iscsi_cmd.c */
1341 void iscsi_cmd_state_machine(iscsi_cmd_t *icmdp,
1342 iscsi_cmd_event_t event, void *arg);
1343 iscsi_cmd_t *iscsi_cmd_alloc(iscsi_conn_t *icp, int km_flags);
1344 void iscsi_cmd_free(iscsi_cmd_t *icmdp);
1345
1346 /* iscsi_ioctl.c */
1347 void * iscsi_ioctl_copyin(caddr_t arg, int mode, size_t size);
1348 int iscsi_ioctl_copyout(void *data, size_t size, caddr_t arg, int mode);
1349 iscsi_conn_list_t *iscsi_ioctl_conn_oid_list_get_copyin(caddr_t, int);
1350 int iscsi_ioctl_conn_oid_list_get_copyout(iscsi_conn_list_t *, caddr_t, int);
1351 boolean_t iscsi_ioctl_conn_oid_list_get(iscsi_hba_t *ihp,
1352 iscsi_conn_list_t *cl);
1353 boolean_t iscsi_ioctl_conn_props_get(iscsi_hba_t *ihp, iscsi_conn_props_t *cp);
1354 int iscsi_ioctl_sendtgts_get(iscsi_hba_t *ihp, iscsi_sendtgts_list_t *stl);
|