xref: /titanic_44/usr/src/uts/common/sys/portif.h (revision 1a024a4828552f36f41749085bad547c64a0f0a6)
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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 #ifndef	_PORTIF_H
25 #define	_PORTIF_H
26 
27 /*
28  * Definitions for stmf local ports and port providers.
29  */
30 
31 #include <sys/stmf_defines.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 typedef struct stmf_dbuf_store {
38 	void			*ds_stmf_private;
39 	void			*ds_port_private;
40 
41 	stmf_data_buf_t		*(*ds_alloc_data_buf)(struct scsi_task *task,
42 	    uint32_t size, uint32_t *pminsize, uint32_t flags);
43 
44 	void			(*ds_free_data_buf)(
45 	    struct stmf_dbuf_store *ds, stmf_data_buf_t *dbuf);
46 
47 	stmf_status_t		(*ds_setup_dbuf)(struct scsi_task *task,
48 	    stmf_data_buf_t *dbuf, uint32_t flags);
49 
50 	void			(*ds_teardown_dbuf)(
51 	    struct stmf_dbuf_store *ds, stmf_data_buf_t *dbuf);
52 } stmf_dbuf_store_t;
53 
54 #define	PORTIF_REV_1	0x00010000
55 
56 typedef struct stmf_local_port {
57 	void			*lport_stmf_private;
58 	void			*lport_port_private;
59 
60 	uint32_t		lport_abort_timeout;
61 
62 	struct scsi_devid_desc	*lport_id;
63 	char			*lport_alias;
64 	struct stmf_port_provider *lport_pp;
65 	struct stmf_dbuf_store	*lport_ds;
66 	/* lport ops */
67 	stmf_status_t		(*lport_xfer_data)(struct scsi_task *task,
68 		struct stmf_data_buf *dbuf, uint32_t ioflags);
69 	stmf_status_t		(*lport_send_status)(struct scsi_task *task,
70 						uint32_t ioflags);
71 	void			(*lport_task_free)(struct scsi_task *task);
72 	stmf_status_t		(*lport_abort)(struct stmf_local_port *lport,
73 		int abort_cmd, void *arg, uint32_t flags);
74 	void			(*lport_task_poll)(struct scsi_task *task);
75 	void			(*lport_ctl)(struct stmf_local_port *lport,
76 						int cmd, void *arg);
77 	stmf_status_t		(*lport_info)(uint32_t cmd,
78 		struct stmf_local_port *lport, void *arg, uint8_t *buf,
79 		uint32_t *bufsizep);
80 	void			(*lport_event_handler)(
81 		struct stmf_local_port *lport, int eventid, void *arg,
82 		uint32_t flags);
83 } stmf_local_port_t;
84 
85 typedef struct stmf_remote_port {
86 	struct scsi_transport_id	*rport_tptid;
87 	uint16_t			rport_tptid_sz;
88 } stmf_remote_port_t;
89 
90 typedef struct stmf_dflt_scsi_tptid {
91 #if defined(_BIT_FIELDS_LTOH)
92 	uint8_t			protocol_id : 4,
93 				resbits : 2,
94 				format_code : 2;
95 #elif defined(_BIT_FIELDS_HTOL)
96 	uint8_t			format_code : 2,
97 				resbits : 2,
98 				protocol_id : 4;
99 #else
100 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
101 #endif	/* _BIT_FIELDS_LTOH */
102 	uint8_t			rsvbyte1;
103 	uint8_t			ident_len[2];
104 	char			ident[1];
105 } stmf_dflt_scsi_tptid_t;
106 /*
107  * abort cmd
108  */
109 #define	STMF_LPORT_ABORT_TASK	0x40
110 
111 typedef struct stmf_port_provider {
112 	void			*pp_stmf_private;
113 	void			*pp_provider_private;
114 
115 	uint32_t		pp_portif_rev;	/* Currently PORTIF_REV_1 */
116 	int			pp_instance;
117 	char			*pp_name;
118 	void			(*pp_cb)(struct stmf_port_provider *pp,
119 	    int cmd, void *arg, uint32_t flags);
120 } stmf_port_provider_t;
121 
122 #define	STMF_SESSION_ID_NONE		((uint64_t)0)
123 
124 typedef struct stmf_scsi_session {
125 	void			*ss_stmf_private;
126 	void			*ss_port_private;
127 
128 	struct scsi_devid_desc	*ss_rport_id;
129 	char			*ss_rport_alias;
130 	struct stmf_local_port	*ss_lport;
131 	uint64_t		ss_session_id;
132 	struct stmf_remote_port	*ss_rport;
133 } stmf_scsi_session_t;
134 
135 stmf_status_t stmf_register_port_provider(stmf_port_provider_t *pp);
136 stmf_status_t stmf_deregister_port_provider(stmf_port_provider_t *pp);
137 stmf_status_t stmf_register_local_port(stmf_local_port_t *lportp);
138 stmf_status_t stmf_deregister_local_port(stmf_local_port_t *lport);
139 stmf_status_t stmf_register_scsi_session(stmf_local_port_t *lport,
140 				stmf_scsi_session_t *ss);
141 void stmf_deregister_scsi_session(stmf_local_port_t *lport,
142 				stmf_scsi_session_t *ss);
143 void stmf_set_port_standby(stmf_local_port_t *lport, uint16_t rtpid);
144 void stmf_set_port_alua(stmf_local_port_t *lport);
145 
146 #ifdef	__cplusplus
147 }
148 #endif
149 
150 #endif /* _PORTIF_H */
151