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