stmf_impl.h revision a49dc89305dba244dc67270b5afddcf7da3e36cf
/*
* 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
*/
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
#ifndef _STMF_IMPL_H
#define _STMF_IMPL_H
#include <sys/stmf_defines.h>
#include <sys/stmf_ioctl.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint32_t stmf_event_handle_t;
#define STMF_EVENT_ADD(h, e) (atomic_or_32(&(h), \
((uint32_t)1) << (e)))
#define STMF_EVENT_REMOVE(h, e) (atomic_and_32(&(h), \
~(((uint32_t)1) << (e))))
#define STMF_EVENT_CLEAR_ALL(h) ((h) = 0)
#define STMF_EVENT_ALLOC_HANDLE(h) ((h) = 0)
#define STMF_EVENT_FREE_HANDLE(h) ((h) = 0)
#define STMF_TGT_NAME_LEN 256
#define STMF_GUID_INPUT 32
} else { \
}
struct stmf_i_scsi_task;
struct stmf_itl_data;
typedef struct stmf_i_lu_provider {
ilp_rsvd:31;
struct stmf_i_lu_provider *ilp_next;
struct stmf_pp_data *ilp_ppd;
typedef struct stmf_i_lu {
char *ilu_alias;
struct stmf_i_scsi_task *ilu_tasks;
struct stmf_i_scsi_task *ilu_free_tasks;
struct stmf_itl_data *ilu_itl_list;
/* point to the luid entry in stmf_state.stmf_luid_list */
void *ilu_luid;
} stmf_i_lu_t;
/*
* ilu_flags
*/
#define ILU_STALL_DEREGISTER 0x0001
#define ILU_RESET_ACTIVE 0x0002
typedef struct stmf_i_port_provider {
ipp_rsvd:31;
struct stmf_i_port_provider *ipp_next;
struct stmf_pp_data *ipp_ppd;
#define MAX_ILPORT 0x10000
typedef struct stmf_i_local_port {
struct stmf_i_scsi_session *ilport_ss_list;
struct stmf_i_local_port *ilport_next;
struct stmf_i_local_port *ilport_prev;
/* which target group this port belongs to in stmf_state.stmf_tg_list */
void *ilport_tg;
/* XXX Need something to track all the remote ports also */
#define MAX_IRPORT 0x10000
typedef struct stmf_i_remote_port {
struct scsi_devid_desc *irport_id;
int irport_refcnt;
typedef struct stmf_i_itl_kstat {
char iitl_kstat_nm[KSTAT_STRLEN];
char *iitl_kstat_strbuf;
int iitl_kstat_strbuflen;
/*
* ilport flags
*/
#define ILPORT_FORCED_OFFLINE 0x01
#define ILPORT_SS_GOT_INITIAL_LUNS 0x02
typedef struct stmf_i_scsi_session {
struct stmf_i_scsi_session *iss_next;
/*
* Ideally we should maintain 2 maps. One would indicate a new map
* which will become available only upon receipt of a REPORT LUN
* cmd.
*/
struct stmf_lun_map *iss_sm;
/*
* which host group the host of this session belongs to in
* stmf_state.stmf_hg_list
*/
void *iss_hg;
/*
* iss flags
*/
#define ISS_LUN_INVENTORY_CHANGED 0x0001
#define ISS_RESET_ACTIVE 0x0002
#define ISS_BEING_CREATED 0x0004
#define ISS_GOT_INITIAL_LUNS 0x0008
#define ISS_EVENT_ACTIVE 0x0010
#define ISS_NULL_TPTID 0x0020
#define ITASK_MAX_NCMDS 14
#define ITASK_DEFAULT_POLL_TIMEOUT 0
typedef enum {
#define CMD_OR_IOF_NA 0xffffffff
typedef struct stmf_task_audit_rec {
struct stmf_worker;
typedef struct stmf_i_scsi_task {
struct stmf_worker *itask_worker;
struct stmf_i_scsi_task *itask_worker_next;
struct stmf_i_scsi_task *itask_lu_next;
struct stmf_i_scsi_task *itask_lu_prev;
struct stmf_i_scsi_task *itask_lu_free_next;
struct stmf_i_scsi_task *itask_abort_next;
struct stmf_itl_data *itask_itl_datap;
/* For now we only support 4 parallel buffers. Should be enough. */
/* Task profile data */
#define ITASK_DEFAULT_ABORT_TIMEOUT 5
/*
* itask_flags
*/
#define ITASK_IN_FREE_LIST 0x0001
#define ITASK_IN_TRANSITION 0x0002
#define ITASK_IN_WORKER_QUEUE 0x0004
#define ITASK_BEING_ABORTED 0x0008
#define ITASK_BEING_COMPLETED 0x0010
#define ITASK_KNOWN_TO_TGT_PORT 0x0020
#define ITASK_KNOWN_TO_LU 0x0040
#define ITASK_LU_ABORT_CALLED 0x0080
#define ITASK_TGT_PORT_ABORT_CALLED 0x0100
#define ITASK_DEFAULT_HANDLING 0x0200
#define ITASK_CAUSING_LU_RESET 0x0400
#define ITASK_CAUSING_TARGET_RESET 0x0800
#define ITASK_KSTAT_IN_RUNQ 0x1000
#define ITASK_PROXY_TASK 0x2000
/*
* itask cmds.
*/
#define ITASK_CMD_MASK 0x1F
#define ITASK_CMD_NEW_TASK 0x1
#define ITASK_CMD_DATA_XFER_DONE 0x2
#define ITASK_CMD_STATUS_DONE 0x3
#define ITASK_CMD_ABORT 0x4
#define ITASK_CMD_SEND_STATUS 0x5
#define ITASK_CMD_POLL 0x10
/*
* struct maintained on a per itl basis when the lu registers ITL handle.
*/
typedef struct stmf_itl_data {
char *itl_kstat_strbuf;
int itl_kstat_strbuflen;
void *itl_handle;
struct stmf_i_scsi_session *itl_session;
struct stmf_itl_data *itl_next;
/*
* itl flags
*/
#define STMF_ITL_BEING_TERMINATED 0x01
/*
* data structures to maintain provider private data.
*/
typedef struct stmf_pp_data {
struct stmf_pp_data *ppd_next;
void *ppd_provider;
ppd_rsvd:30;
char ppd_name[8];
typedef struct stmf_worker {
/*
* worker flags
*/
#define STMF_WORKER_STARTED 1
#define STMF_WORKER_ACTIVE 2
#define STMF_WORKER_TERMINATE 4
/*
* data struct for managing transfers.
*/
typedef struct stmf_xfer_data {
/*
* Define frequently used macros
*/
#define TASK_TO_ITASK(x_task) \
void stmf_dlun_init();
void stmf_worker_init();
#ifdef __cplusplus
}
#endif
#endif /* _STMF_IMPL_H */