xref: /illumos-gate/usr/src/uts/common/sys/fc4/fcal_transport.h (revision e5803b76927480e8f9b67b22201c484ccf4c2bcf)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FC4_FCAL_TRANSPORT_H
28 #define	_SYS_FC4_FCAL_TRANSPORT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/fc4/fcal.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * fc_devdata_t definitions
40  *
41  * See fc.h for TYPE field definitions
42  */
43 typedef int fc_devdata_t;
44 
45 /*
46  * fc_ioclass_t definitions.
47  */
48 typedef enum {
49 	FC_CLASS_OUTBOUND,
50 	FC_CLASS_INBOUND,
51 	FC_CLASS_SIMPLE,
52 	FC_CLASS_IO_WRITE,
53 	FC_CLASS_IO_READ,
54 	FC_CLASS_OFFLINE,
55 	FC_CLASS_UNSOLICITED
56 } fc_ioclass_t;
57 
58 /*
59  * fc_transport() sleep parameter
60  */
61 typedef enum {
62 	FCAL_SLEEP,			/* sleep on queue full */
63 	FCAL_NOSLEEP			/* do not sleep on queue full */
64 } fcal_sleep_t;
65 
66 typedef struct fcal_packet {
67 	void		*fcal_pkt_cookie; /* identifies which FC device */
68 	struct fcal_packet	*fcal_pkt_next;
69 	void		(*fcal_pkt_comp)(struct fcal_packet *);
70 	void		*fcal_pkt_private;
71 	uint_t		fcal_pkt_flags;		/* flags */
72 	uint_t		fcal_cmd_state;
73 	uint_t		fcal_pkt_status;	/* SOC Status when complete */
74 	uint_t		fcal_diag_status;	/* used only for diagnostics */
75 	union {
76 		soc_request_t	req;
77 		longlong_t	l;
78 	} w;
79 
80 #define	fcal_socal_request	w.req
81 
82 	fc_frame_header_t	fcal_resp_hdr;
83 	uint_t		fcal_magic;
84 	ushort_t	fcal_ncmds;
85 } fcal_packet_t;
86 
87 /*
88  *	Fibre channel packet flags
89  */
90 #define	FCFLAG_NOINTR		1	/* run this command without intr */
91 #define	FCFLAG_COMPLETE		2	/* command has completed */
92 #define	FCFLAG_RESP_HEADER	4	/* valid response frame header */
93 #define	FCFLAG_ABORTING		8	/* this packet is being aborted */
94 #define	FCFLAG_ABORTED		0x10	/* the abort completed */
95 
96 /*
97  * definitions for the cmd_state
98  */
99 #define	FCAL_CMD_IN_TRANSPORT	0x1	/* command in transport */
100 #define	FCAL_CMD_COMPLETE	0x4	/* command complete */
101 #define	FCAL_CMPLT_CALLED	0x10	/* Completion routine called */
102 
103 #define	FCALP_MAGIC	0x4750703
104 
105 typedef struct fcal_transport {
106 	void			*fcal_handle; 	/* identifies which FC dev */
107 	ddi_dma_lim_t		*fcal_dmalimp;
108 	ddi_iblock_cookie_t	fcal_iblock;
109 	ddi_dma_attr_t		*fcal_dmaattr;
110 	ddi_device_acc_attr_t	*fcal_accattr;
111 	caddr_t			fcal_loginparms;	/* from soc+ xram */
112 	la_wwn_t		fcal_n_wwn;	/* node Worldwide name */
113 	la_wwn_t		fcal_p_wwn;	/* port Worldwide name */
114 	uint_t			fcal_portno;	/* which port */
115 	uint_t			fcal_cmdmax;	/* max number of exchanges */
116 	kmutex_t		fcal_mtx;
117 	kcondvar_t		fcal_cv;
118 	struct fcal_transport_ops	*fcal_ops;
119 } fcal_transport_t;
120 
121 typedef struct fcal_transport_ops {
122 	uint_t			(*fcal_transport)(fcal_packet_t *fcalpkt,
123 						fcal_sleep_t sleep, int
124 						req_q_no);
125 	uint_t			(*fcal_transport_poll)(fcal_packet_t *fcalpkt,
126 						uint_t	 timeout,
127 						int req_q_no);
128 	uint_t			(*fcal_lilp_map)(void *fcal_handle,
129 						uint_t	 port,
130 						uint32_t bufid,
131 						uint_t	 poll);
132 	uint_t			(*fcal_force_lip)(void *fcal_handle,
133 						uint_t	 port,
134 						uint_t	 poll,
135 						uint_t	 lip_req);
136 	uint_t			(*fcal_abort_cmd)(void *fcal_handle,
137 						uint_t	port,
138 						fcal_packet_t *fcalpkt,
139 						uint_t	 poll);
140 	uint_t			(*fcal_els)(void *fcal_handle,
141 						uint_t	 port,
142 						uint_t	 els_code,
143 						uint_t	 dest,
144 						void (*callback)(),
145 						void *arg,
146 						caddr_t reqpayload,
147 						caddr_t *rsppayload,
148 						uint_t	 poll);
149 	uint_t			(*fcal_bypass_dev)(void *fcal_handle,
150 						uint_t	 port,
151 						uint_t	 dest);
152 	void			(*fcal_force_reset)(void *fcal_handle,
153 						uint_t	 port,
154 						uint_t	reset);
155 	void			(*fcal_add_ulp)(void *fcal_handle,
156 						uint_t	 port,
157 						uchar_t type,
158 						void (*ulp_statec_callback)(),
159 						void (*ulp_els_callback)(),
160 						void (*ulp_data_callback)(),
161 						void *arg);
162 	void			(*fcal_remove_ulp)(void *fcal_handle,
163 						uint_t port,
164 						uchar_t type,
165 						void *arg);
166 	void			(*fcal_take_core)(void *fcal_handle);
167 } fcal_transport_ops_t;
168 
169 /*
170  * additional pseudo-status codes for login
171  */
172 #define	FCAL_STATUS_LOGIN_TIMEOUT	0x80000001
173 #define	FCAL_STATUS_CQFULL		0x80000002
174 #define	FCAL_STATUS_TRANSFAIL		0x80000003
175 #define	FCAL_STATUS_RESETFAIL		0x80000004
176 
177 /*
178  * interface and transport function return values
179  */
180 #define	FCAL_SUCCESS		0x000
181 #define	FCAL_TIMEOUT		0x001
182 #define	FCAL_ALLOC_FAILED	0x002
183 #define	FCAL_OLD_PORT		0x003
184 #define	FCAL_LINK_ERROR		0x004
185 #define	FCAL_OFFLINE		0x005
186 #define	FCAL_ABORTED		0x006
187 #define	FCAL_ABORT_FAILED	0x007
188 #define	FCAL_BAD_ABORT		0x008
189 #define	FCAL_BAD_PARAMS		0x009
190 #define	FCAL_OVERRUN		0x00a
191 #define	FCAL_NO_TRANSPORT	0x00b
192 #define	FCAL_TRANSPORT_SUCCESS	0x000
193 #define	FCAL_TRANSPORT_FAILURE	0x101
194 #define	FCAL_BAD_PACKET		0x102
195 #define	FCAL_TRANSPORT_UNAVAIL	0x103
196 #define	FCAL_TRANSPORT_QFULL	0x104
197 #define	FCAL_TRANSPORT_TIMEOUT	0x105
198 
199 #define	FCAL_FAILURE 		0xffffffff
200 /*
201  * fc_uc_register() return values
202  */
203 typedef void * fc_uc_cookie_t;
204 
205 /*
206  * fc_transport() iotype parameter
207  */
208 typedef enum {
209 	FC_TYPE_UNCATEGORIZED,
210 	FC_TYPE_DATA,
211 	FC_TYPE_UNSOL_CONTROL,
212 	FC_TYPE_SOLICITED_CONTROL,
213 	FC_TYPE_UNSOL_DATA,
214 	FC_TYPE_XFER_RDY,
215 	FC_TYPE_COMMAND,
216 	FC_TYPE_RESPONSE
217 } fc_iotype_t;
218 
219 /*
220  * State changes related to the N-port interface communicated from below
221  */
222 #define	FCAL_STATE_RESET	((int)0xffffffffu)
223 						/* port reset, all cmds lost */
224 
225 #define	FCAL_LILP_MAGIC		0x1107
226 #define	FCAL_BADLILP_MAGIC	0x1105
227 #define	FCAL_NO_LIP		0x0
228 #define	FCAL_FORCE_LIP		0x1
229 
230 typedef struct fcal_lilp_map {
231 	ushort_t	lilp_magic;
232 	ushort_t	lilp_myalpa;
233 	uchar_t		lilp_length;
234 	uchar_t		lilp_alpalist[127];
235 } fcal_lilp_map_t;
236 #ifdef	__cplusplus
237 }
238 #endif
239 
240 #endif	/* !_SYS_FC4_FCAL_TRANSPORT_H */
241