xref: /titanic_50/usr/src/uts/common/sys/lpif.h (revision 3fb517f786391b507780c78aabb8d98bfea9efe9)
1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
22*3fb517f7SJames Moore  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23fcf3ce44SJohn Forte  */
24fcf3ce44SJohn Forte #ifndef	_LPIF_H
25fcf3ce44SJohn Forte #define	_LPIF_H
26fcf3ce44SJohn Forte 
27fcf3ce44SJohn Forte /*
28fcf3ce44SJohn Forte  * Definitions for stmf LUs and lu providers.
29fcf3ce44SJohn Forte  */
30fcf3ce44SJohn Forte 
31fcf3ce44SJohn Forte #include <sys/stmf_defines.h>
3245039663SJohn Forte #include <sys/stmf.h>
33fcf3ce44SJohn Forte 
34fcf3ce44SJohn Forte #ifdef	__cplusplus
35fcf3ce44SJohn Forte extern "C" {
36fcf3ce44SJohn Forte #endif
37fcf3ce44SJohn Forte 
38fcf3ce44SJohn Forte #define	LPIF_REV_1	0x00010000
3945039663SJohn Forte #define	LPIF_REV_2	0x00020000
40fcf3ce44SJohn Forte 
41fcf3ce44SJohn Forte typedef struct stmf_lu {
42fcf3ce44SJohn Forte 	void			*lu_stmf_private;
43fcf3ce44SJohn Forte 	void			*lu_provider_private;
44fcf3ce44SJohn Forte 
45fcf3ce44SJohn Forte 	struct scsi_devid_desc	*lu_id;
46fcf3ce44SJohn Forte 	char			*lu_alias;	/* optional */
47fcf3ce44SJohn Forte 	struct stmf_lu_provider *lu_lp;
48fcf3ce44SJohn Forte 	uint32_t		lu_abort_timeout;	/* In seconds */
49fcf3ce44SJohn Forte 
50fcf3ce44SJohn Forte 	/* SAM Device Server Class */
51fcf3ce44SJohn Forte 	stmf_status_t		(*lu_task_alloc)(struct scsi_task *task);
52fcf3ce44SJohn Forte 	void			(*lu_new_task)(struct scsi_task *task,
53fcf3ce44SJohn Forte 		struct stmf_data_buf *initial_dbuf);
54fcf3ce44SJohn Forte 	void			(*lu_dbuf_xfer_done)(struct scsi_task *task,
55fcf3ce44SJohn Forte 		struct stmf_data_buf *dbuf);
56fcf3ce44SJohn Forte 	/*
57fcf3ce44SJohn Forte 	 * If completion confirmation is not requested, status xfer done
58fcf3ce44SJohn Forte 	 * is called after the transport has confirmed that status has been
59fcf3ce44SJohn Forte 	 * sent. If completion confirmation is requested then the HBA will
60fcf3ce44SJohn Forte 	 * request a completion confirmation from the host and upon receiving
61fcf3ce44SJohn Forte 	 * the same, this entry point will be called.
62fcf3ce44SJohn Forte 	 */
63fcf3ce44SJohn Forte 	void			(*lu_send_status_done)(struct scsi_task *task);
64fcf3ce44SJohn Forte 	void			(*lu_task_free)(struct scsi_task *task);
65fcf3ce44SJohn Forte 	stmf_status_t		(*lu_abort)(struct stmf_lu *lu,
66fcf3ce44SJohn Forte 		int abort_cmd, void *arg, uint32_t flags);
67fcf3ce44SJohn Forte 	void			(*lu_task_poll)(struct scsi_task *task);
68fcf3ce44SJohn Forte 	void			(*lu_ctl)(struct stmf_lu *lu, int cmd,
69fcf3ce44SJohn Forte 								void *arg);
70fcf3ce44SJohn Forte 	stmf_status_t		(*lu_info)(uint32_t cmd, struct stmf_lu *lu,
71fcf3ce44SJohn Forte 		void *arg, uint8_t *buf, uint32_t *bufsizep);
72fcf3ce44SJohn Forte 	void			(*lu_event_handler)(struct stmf_lu *lu,
73fcf3ce44SJohn Forte 		int eventid, void *arg, uint32_t flags);
7445039663SJohn Forte 	void			*lu_proxy_reg_arg;
7545039663SJohn Forte 	uint32_t		lu_proxy_reg_arg_len;
76*3fb517f7SJames Moore 	void			(*lu_dbuf_free)(struct scsi_task *task,
77*3fb517f7SJames Moore 		struct stmf_data_buf *dbuf);
78fcf3ce44SJohn Forte } stmf_lu_t;
79fcf3ce44SJohn Forte 
80fcf3ce44SJohn Forte /*
81fcf3ce44SJohn Forte  * Abort cmd
82fcf3ce44SJohn Forte  */
83fcf3ce44SJohn Forte #define	STMF_LU_ABORT_TASK		1
84fcf3ce44SJohn Forte #define	STMF_LU_RESET_STATE		2
85fcf3ce44SJohn Forte #define	STMF_LU_ITL_HANDLE_REMOVED	3
86fcf3ce44SJohn Forte 
87fcf3ce44SJohn Forte /*
8845039663SJohn Forte  * Asymmetric access state
8945039663SJohn Forte  */
9045039663SJohn Forte #define	STMF_LU_ACTIVE			0
9145039663SJohn Forte #define	STMF_LU_STANDBY			1
9245039663SJohn Forte 
9345039663SJohn Forte /*
9445039663SJohn Forte  * proxy register msg types
9545039663SJohn Forte  */
9645039663SJohn Forte #define	STMF_MSG_LU_REGISTER		0
9745039663SJohn Forte #define	STMF_MSG_LU_ACTIVE		1
9845039663SJohn Forte #define	STMF_MSG_LU_DEREGISTER		2
9945039663SJohn Forte 
10045039663SJohn Forte 
10145039663SJohn Forte #define	STMF_PROXY_READ			1
10245039663SJohn Forte #define	STMF_PROXY_WRITE		2
10345039663SJohn Forte 
10445039663SJohn Forte /*
105fcf3ce44SJohn Forte  * Reasons for itl handle removal. Passed in flags.
106fcf3ce44SJohn Forte  */
107fcf3ce44SJohn Forte #define	STMF_ITL_REASON_MASK		0x0f
108fcf3ce44SJohn Forte #define	STMF_ITL_REASON_UNKNOWN		0x0
109fcf3ce44SJohn Forte #define	STMF_ITL_REASON_DEREG_REQUEST	0x1
110fcf3ce44SJohn Forte #define	STMF_ITL_REASON_USER_REQUEST	0x2
111fcf3ce44SJohn Forte #define	STMF_ITL_REASON_IT_NEXUS_LOSS	0x3
112fcf3ce44SJohn Forte 
113fcf3ce44SJohn Forte typedef struct stmf_lu_provider {
114fcf3ce44SJohn Forte 	void			*lp_stmf_private;
115fcf3ce44SJohn Forte 	void			*lp_private;
116fcf3ce44SJohn Forte 
11745039663SJohn Forte 	uint32_t		lp_lpif_rev;	/* Currently LPIF_REV_2 */
118fcf3ce44SJohn Forte 	int			lp_instance;
119fcf3ce44SJohn Forte 	char			*lp_name;
120fcf3ce44SJohn Forte 	void			(*lp_cb)(struct stmf_lu_provider *lp,
121fcf3ce44SJohn Forte 	    int cmd, void *arg, uint32_t flags);
12245039663SJohn Forte 	uint8_t			lp_alua_support;
12345039663SJohn Forte 	stmf_status_t		(*lp_proxy_msg)(uint8_t *luid,
12445039663SJohn Forte 	    void *proxy_reg_arg, uint32_t proxy_reg_arg_len, uint32_t type);
125fcf3ce44SJohn Forte } stmf_lu_provider_t;
126fcf3ce44SJohn Forte 
127fcf3ce44SJohn Forte stmf_status_t stmf_deregister_lu_provider(stmf_lu_provider_t *lp);
128fcf3ce44SJohn Forte stmf_status_t stmf_register_lu_provider(stmf_lu_provider_t *lp);
129fcf3ce44SJohn Forte stmf_status_t stmf_register_lu(stmf_lu_t *lup);
130fcf3ce44SJohn Forte stmf_status_t stmf_deregister_lu(stmf_lu_t *lup);
13145039663SJohn Forte stmf_status_t stmf_set_lu_access(stmf_lu_t *lup, uint8_t access_state);
13245039663SJohn Forte stmf_status_t stmf_proxy_scsi_cmd(scsi_task_t *, stmf_data_buf_t *dbuf);
13345039663SJohn Forte int stmf_is_standby_port(scsi_task_t *);
134427fcaf8Stim szeto void stmf_lu_xfer_start(struct scsi_task *task);
135427fcaf8Stim szeto void stmf_lu_xfer_done(struct scsi_task *task, boolean_t read,
136427fcaf8Stim szeto     uint64_t xfer_bytes, hrtime_t elapsed_time);
137fcf3ce44SJohn Forte 
138fcf3ce44SJohn Forte #ifdef	__cplusplus
139fcf3ce44SJohn Forte }
140fcf3ce44SJohn Forte #endif
141fcf3ce44SJohn Forte 
142fcf3ce44SJohn Forte #endif /* _LPIF_H */
143