xref: /onnv-gate/usr/src/uts/common/sys/lpif.h (revision 12314:0ed71edeac88)
17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM  * CDDL HEADER START
37836SJohn.Forte@Sun.COM  *
47836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM  *
87836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM  * and limitations under the License.
127836SJohn.Forte@Sun.COM  *
137836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM  *
197836SJohn.Forte@Sun.COM  * CDDL HEADER END
207836SJohn.Forte@Sun.COM  */
217836SJohn.Forte@Sun.COM /*
22*12314SJames.Moore@Sun.COM  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
237836SJohn.Forte@Sun.COM  */
247836SJohn.Forte@Sun.COM #ifndef	_LPIF_H
257836SJohn.Forte@Sun.COM #define	_LPIF_H
267836SJohn.Forte@Sun.COM 
277836SJohn.Forte@Sun.COM /*
287836SJohn.Forte@Sun.COM  * Definitions for stmf LUs and lu providers.
297836SJohn.Forte@Sun.COM  */
307836SJohn.Forte@Sun.COM 
317836SJohn.Forte@Sun.COM #include <sys/stmf_defines.h>
3210725SJohn.Forte@Sun.COM #include <sys/stmf.h>
337836SJohn.Forte@Sun.COM 
347836SJohn.Forte@Sun.COM #ifdef	__cplusplus
357836SJohn.Forte@Sun.COM extern "C" {
367836SJohn.Forte@Sun.COM #endif
377836SJohn.Forte@Sun.COM 
387836SJohn.Forte@Sun.COM #define	LPIF_REV_1	0x00010000
3910725SJohn.Forte@Sun.COM #define	LPIF_REV_2	0x00020000
407836SJohn.Forte@Sun.COM 
417836SJohn.Forte@Sun.COM typedef struct stmf_lu {
427836SJohn.Forte@Sun.COM 	void			*lu_stmf_private;
437836SJohn.Forte@Sun.COM 	void			*lu_provider_private;
447836SJohn.Forte@Sun.COM 
457836SJohn.Forte@Sun.COM 	struct scsi_devid_desc	*lu_id;
467836SJohn.Forte@Sun.COM 	char			*lu_alias;	/* optional */
477836SJohn.Forte@Sun.COM 	struct stmf_lu_provider *lu_lp;
487836SJohn.Forte@Sun.COM 	uint32_t		lu_abort_timeout;	/* In seconds */
497836SJohn.Forte@Sun.COM 
507836SJohn.Forte@Sun.COM 	/* SAM Device Server Class */
517836SJohn.Forte@Sun.COM 	stmf_status_t		(*lu_task_alloc)(struct scsi_task *task);
527836SJohn.Forte@Sun.COM 	void			(*lu_new_task)(struct scsi_task *task,
537836SJohn.Forte@Sun.COM 		struct stmf_data_buf *initial_dbuf);
547836SJohn.Forte@Sun.COM 	void			(*lu_dbuf_xfer_done)(struct scsi_task *task,
557836SJohn.Forte@Sun.COM 		struct stmf_data_buf *dbuf);
567836SJohn.Forte@Sun.COM 	/*
577836SJohn.Forte@Sun.COM 	 * If completion confirmation is not requested, status xfer done
587836SJohn.Forte@Sun.COM 	 * is called after the transport has confirmed that status has been
597836SJohn.Forte@Sun.COM 	 * sent. If completion confirmation is requested then the HBA will
607836SJohn.Forte@Sun.COM 	 * request a completion confirmation from the host and upon receiving
617836SJohn.Forte@Sun.COM 	 * the same, this entry point will be called.
627836SJohn.Forte@Sun.COM 	 */
637836SJohn.Forte@Sun.COM 	void			(*lu_send_status_done)(struct scsi_task *task);
647836SJohn.Forte@Sun.COM 	void			(*lu_task_free)(struct scsi_task *task);
657836SJohn.Forte@Sun.COM 	stmf_status_t		(*lu_abort)(struct stmf_lu *lu,
667836SJohn.Forte@Sun.COM 		int abort_cmd, void *arg, uint32_t flags);
677836SJohn.Forte@Sun.COM 	void			(*lu_task_poll)(struct scsi_task *task);
687836SJohn.Forte@Sun.COM 	void			(*lu_ctl)(struct stmf_lu *lu, int cmd,
697836SJohn.Forte@Sun.COM 								void *arg);
707836SJohn.Forte@Sun.COM 	stmf_status_t		(*lu_info)(uint32_t cmd, struct stmf_lu *lu,
717836SJohn.Forte@Sun.COM 		void *arg, uint8_t *buf, uint32_t *bufsizep);
727836SJohn.Forte@Sun.COM 	void			(*lu_event_handler)(struct stmf_lu *lu,
737836SJohn.Forte@Sun.COM 		int eventid, void *arg, uint32_t flags);
7410725SJohn.Forte@Sun.COM 	void			*lu_proxy_reg_arg;
7510725SJohn.Forte@Sun.COM 	uint32_t		lu_proxy_reg_arg_len;
76*12314SJames.Moore@Sun.COM 	void			(*lu_dbuf_free)(struct scsi_task *task,
77*12314SJames.Moore@Sun.COM 		struct stmf_data_buf *dbuf);
787836SJohn.Forte@Sun.COM } stmf_lu_t;
797836SJohn.Forte@Sun.COM 
807836SJohn.Forte@Sun.COM /*
817836SJohn.Forte@Sun.COM  * Abort cmd
827836SJohn.Forte@Sun.COM  */
837836SJohn.Forte@Sun.COM #define	STMF_LU_ABORT_TASK		1
847836SJohn.Forte@Sun.COM #define	STMF_LU_RESET_STATE		2
857836SJohn.Forte@Sun.COM #define	STMF_LU_ITL_HANDLE_REMOVED	3
867836SJohn.Forte@Sun.COM 
877836SJohn.Forte@Sun.COM /*
8810725SJohn.Forte@Sun.COM  * Asymmetric access state
8910725SJohn.Forte@Sun.COM  */
9010725SJohn.Forte@Sun.COM #define	STMF_LU_ACTIVE			0
9110725SJohn.Forte@Sun.COM #define	STMF_LU_STANDBY			1
9210725SJohn.Forte@Sun.COM 
9310725SJohn.Forte@Sun.COM /*
9410725SJohn.Forte@Sun.COM  * proxy register msg types
9510725SJohn.Forte@Sun.COM  */
9610725SJohn.Forte@Sun.COM #define	STMF_MSG_LU_REGISTER		0
9710725SJohn.Forte@Sun.COM #define	STMF_MSG_LU_ACTIVE		1
9810725SJohn.Forte@Sun.COM #define	STMF_MSG_LU_DEREGISTER		2
9910725SJohn.Forte@Sun.COM 
10010725SJohn.Forte@Sun.COM 
10110725SJohn.Forte@Sun.COM #define	STMF_PROXY_READ			1
10210725SJohn.Forte@Sun.COM #define	STMF_PROXY_WRITE		2
10310725SJohn.Forte@Sun.COM 
10410725SJohn.Forte@Sun.COM /*
1057836SJohn.Forte@Sun.COM  * Reasons for itl handle removal. Passed in flags.
1067836SJohn.Forte@Sun.COM  */
1077836SJohn.Forte@Sun.COM #define	STMF_ITL_REASON_MASK		0x0f
1087836SJohn.Forte@Sun.COM #define	STMF_ITL_REASON_UNKNOWN		0x0
1097836SJohn.Forte@Sun.COM #define	STMF_ITL_REASON_DEREG_REQUEST	0x1
1107836SJohn.Forte@Sun.COM #define	STMF_ITL_REASON_USER_REQUEST	0x2
1117836SJohn.Forte@Sun.COM #define	STMF_ITL_REASON_IT_NEXUS_LOSS	0x3
1127836SJohn.Forte@Sun.COM 
1137836SJohn.Forte@Sun.COM typedef struct stmf_lu_provider {
1147836SJohn.Forte@Sun.COM 	void			*lp_stmf_private;
1157836SJohn.Forte@Sun.COM 	void			*lp_private;
1167836SJohn.Forte@Sun.COM 
11710725SJohn.Forte@Sun.COM 	uint32_t		lp_lpif_rev;	/* Currently LPIF_REV_2 */
1187836SJohn.Forte@Sun.COM 	int			lp_instance;
1197836SJohn.Forte@Sun.COM 	char			*lp_name;
1207836SJohn.Forte@Sun.COM 	void			(*lp_cb)(struct stmf_lu_provider *lp,
1217836SJohn.Forte@Sun.COM 	    int cmd, void *arg, uint32_t flags);
12210725SJohn.Forte@Sun.COM 	uint8_t			lp_alua_support;
12310725SJohn.Forte@Sun.COM 	stmf_status_t		(*lp_proxy_msg)(uint8_t *luid,
12410725SJohn.Forte@Sun.COM 	    void *proxy_reg_arg, uint32_t proxy_reg_arg_len, uint32_t type);
1257836SJohn.Forte@Sun.COM } stmf_lu_provider_t;
1267836SJohn.Forte@Sun.COM 
1277836SJohn.Forte@Sun.COM stmf_status_t stmf_deregister_lu_provider(stmf_lu_provider_t *lp);
1287836SJohn.Forte@Sun.COM stmf_status_t stmf_register_lu_provider(stmf_lu_provider_t *lp);
1297836SJohn.Forte@Sun.COM stmf_status_t stmf_register_lu(stmf_lu_t *lup);
1307836SJohn.Forte@Sun.COM stmf_status_t stmf_deregister_lu(stmf_lu_t *lup);
13110725SJohn.Forte@Sun.COM stmf_status_t stmf_set_lu_access(stmf_lu_t *lup, uint8_t access_state);
13210725SJohn.Forte@Sun.COM stmf_status_t stmf_proxy_scsi_cmd(scsi_task_t *, stmf_data_buf_t *dbuf);
13310725SJohn.Forte@Sun.COM int stmf_is_standby_port(scsi_task_t *);
13411773STim.Szeto@Sun.COM void stmf_lu_xfer_start(struct scsi_task *task);
13511773STim.Szeto@Sun.COM void stmf_lu_xfer_done(struct scsi_task *task, boolean_t read,
13611773STim.Szeto@Sun.COM     uint64_t xfer_bytes, hrtime_t elapsed_time);
1377836SJohn.Forte@Sun.COM 
1387836SJohn.Forte@Sun.COM #ifdef	__cplusplus
1397836SJohn.Forte@Sun.COM }
1407836SJohn.Forte@Sun.COM #endif
1417836SJohn.Forte@Sun.COM 
1427836SJohn.Forte@Sun.COM #endif /* _LPIF_H */
143