xref: /titanic_41/usr/src/uts/common/sys/portif.h (revision e11c3f44f531fdff80941ce57c065d2ae861cefc)
1 /*
2  * CDDL HEADER START
3  *
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 #ifndef	_PORTIF_H
26 #define	_PORTIF_H
27 
28 /*
29  * Definitions for stmf local ports and port providers.
30  */
31 
32 #include <sys/stmf_defines.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 typedef struct stmf_dbuf_store {
39 	void			*ds_stmf_private;
40 	void			*ds_port_private;
41 
42 	stmf_data_buf_t		*(*ds_alloc_data_buf)(struct scsi_task *task,
43 	    uint32_t size, uint32_t *pminsize, uint32_t flags);
44 	void			 (*ds_free_data_buf)(
45 		struct stmf_dbuf_store *ds, stmf_data_buf_t *dbuf);
46 } stmf_dbuf_store_t;
47 
48 #define	PORTIF_REV_1	0x00010000
49 
50 typedef struct stmf_local_port {
51 	void			*lport_stmf_private;
52 	void			*lport_port_private;
53 
54 	uint32_t		lport_abort_timeout;
55 
56 	struct scsi_devid_desc	*lport_id;
57 	char			*lport_alias;
58 	struct stmf_port_provider *lport_pp;
59 	struct stmf_dbuf_store	*lport_ds;
60 	/* lport ops */
61 	stmf_status_t		(*lport_xfer_data)(struct scsi_task *task,
62 		struct stmf_data_buf *dbuf, uint32_t ioflags);
63 	stmf_status_t		(*lport_send_status)(struct scsi_task *task,
64 						uint32_t ioflags);
65 	void			(*lport_task_free)(struct scsi_task *task);
66 	stmf_status_t		(*lport_abort)(struct stmf_local_port *lport,
67 		int abort_cmd, void *arg, uint32_t flags);
68 	void			(*lport_task_poll)(struct scsi_task *task);
69 	void			(*lport_ctl)(struct stmf_local_port *lport,
70 						int cmd, void *arg);
71 	stmf_status_t		(*lport_info)(uint32_t cmd,
72 		struct stmf_local_port *lport, void *arg, uint8_t *buf,
73 		uint32_t *bufsizep);
74 	void			(*lport_event_handler)(
75 		struct stmf_local_port *lport, int eventid, void *arg,
76 		uint32_t flags);
77 } stmf_local_port_t;
78 
79 /*
80  * abort cmd
81  */
82 #define	STMF_LPORT_ABORT_TASK	0x40
83 
84 typedef struct stmf_port_provider {
85 	void			*pp_stmf_private;
86 	void			*pp_provider_private;
87 
88 	uint32_t		pp_portif_rev;	/* Currently PORTIF_REV_1 */
89 	int			pp_instance;
90 	char			*pp_name;
91 	void			(*pp_cb)(struct stmf_port_provider *pp,
92 	    int cmd, void *arg, uint32_t flags);
93 } stmf_port_provider_t;
94 
95 #define	STMF_SESSION_ID_NONE		((uint64_t)0)
96 
97 typedef struct stmf_scsi_session {
98 	void			*ss_stmf_private;
99 	void			*ss_port_private;
100 
101 	struct scsi_devid_desc	*ss_rport_id;
102 	char			*ss_rport_alias;
103 	struct stmf_local_port	*ss_lport;
104 	uint64_t		ss_session_id;
105 } stmf_scsi_session_t;
106 
107 stmf_status_t stmf_register_port_provider(stmf_port_provider_t *pp);
108 stmf_status_t stmf_deregister_port_provider(stmf_port_provider_t *pp);
109 stmf_status_t stmf_register_local_port(stmf_local_port_t *lportp);
110 stmf_status_t stmf_deregister_local_port(stmf_local_port_t *lport);
111 stmf_status_t stmf_register_scsi_session(stmf_local_port_t *lport,
112 				stmf_scsi_session_t *ss);
113 void stmf_deregister_scsi_session(stmf_local_port_t *lport,
114 				stmf_scsi_session_t *ss);
115 
116 #ifdef	__cplusplus
117 }
118 #endif
119 
120 #endif /* _PORTIF_H */
121