xref: /titanic_51/usr/src/uts/common/sys/fct.h (revision 4558d122136f151d62acbbc02ddb42df89a5ef66)
1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
223fb517f7SJames Moore  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23fcf3ce44SJohn Forte  */
24fcf3ce44SJohn Forte #ifndef	_FCT_H
25fcf3ce44SJohn Forte #define	_FCT_H
26fcf3ce44SJohn Forte 
27fcf3ce44SJohn Forte /*
28fcf3ce44SJohn Forte  * Definitions for common FC Target.
29fcf3ce44SJohn Forte  */
30fcf3ce44SJohn Forte #include <sys/note.h>
31fcf3ce44SJohn Forte #include <sys/stmf_defines.h>
32fcf3ce44SJohn Forte #include <sys/fct_defines.h>
33fcf3ce44SJohn Forte #include <sys/portif.h>
34fcf3ce44SJohn Forte 
35fcf3ce44SJohn Forte #ifdef	__cplusplus
36fcf3ce44SJohn Forte extern "C" {
37fcf3ce44SJohn Forte #endif
38fcf3ce44SJohn Forte 
39fcf3ce44SJohn Forte typedef enum fct_struct_id {
40fcf3ce44SJohn Forte 	FCT_STRUCT_LOCAL_PORT = 1,
41fcf3ce44SJohn Forte 	FCT_STRUCT_REMOTE_PORT,
42fcf3ce44SJohn Forte 	FCT_STRUCT_CMD_RCVD_ELS,
43fcf3ce44SJohn Forte 	FCT_STRUCT_CMD_SOL_ELS,
44fcf3ce44SJohn Forte 	FCT_STRUCT_CMD_SOL_CT,
45fcf3ce44SJohn Forte 	FCT_STRUCT_CMD_RCVD_ABTS,
46fcf3ce44SJohn Forte 	FCT_STRUCT_CMD_FCP_XCHG,
47fcf3ce44SJohn Forte 	FCT_STRUCT_DBUF_STORE,
48fcf3ce44SJohn Forte 
49fcf3ce44SJohn Forte 	FCT_MAX_STRUCT_IDS
50fcf3ce44SJohn Forte } fct_struct_id_t;
51fcf3ce44SJohn Forte 
52fcf3ce44SJohn Forte typedef struct fct_remote_port {
53fcf3ce44SJohn Forte 	void		*rp_fct_private;
54fcf3ce44SJohn Forte 	void		*rp_fca_private;
55fcf3ce44SJohn Forte 
56fcf3ce44SJohn Forte 	struct fct_local_port *rp_port;
57d8c54e3dSSam Cramer 	char		rp_nwwn_str[FC_WWN_BUFLEN];
58d8c54e3dSSam Cramer 	char		rp_pwwn_str[FC_WWN_BUFLEN];
59fcf3ce44SJohn Forte 	uint8_t		rp_nwwn[FC_WWN_LEN];
60fcf3ce44SJohn Forte 	uint8_t		rp_pwwn[FC_WWN_LEN];
61fcf3ce44SJohn Forte 	uint32_t	rp_id;		/* 8 or 24 bit */
62fcf3ce44SJohn Forte 	uint32_t	rp_hard_address;
63fcf3ce44SJohn Forte 	uint16_t	rp_handle;
64fcf3ce44SJohn Forte } fct_remote_port_t;
65fcf3ce44SJohn Forte 
66fcf3ce44SJohn Forte #define	FCT_HANDLE_NONE	0xffff
67fcf3ce44SJohn Forte 
68fcf3ce44SJohn Forte typedef struct fct_cmd {
69fcf3ce44SJohn Forte 	void		*cmd_fct_private;
70fcf3ce44SJohn Forte 	void		*cmd_fca_private;
71fcf3ce44SJohn Forte 	void		*cmd_specific;
72fcf3ce44SJohn Forte 
73fcf3ce44SJohn Forte 	struct fct_local_port	*cmd_port;
74fcf3ce44SJohn Forte 
75fcf3ce44SJohn Forte 	/* During cmd porting this can be set to NULL */
76fcf3ce44SJohn Forte 	struct fct_remote_port	*cmd_rp;
77fcf3ce44SJohn Forte 
78fcf3ce44SJohn Forte 	/* To link cmds together for handling things like ABTS. */
79fcf3ce44SJohn Forte 	struct fct_cmd	*cmd_link;
80fcf3ce44SJohn Forte 	uint8_t		cmd_type;
81fcf3ce44SJohn Forte 	uint8_t		cmd_rsvd1;
82fcf3ce44SJohn Forte 
83fcf3ce44SJohn Forte 	/* During cmd posting this can be set to FCT_HANDLE_NONE */
84fcf3ce44SJohn Forte 	uint16_t	cmd_rp_handle;
85fcf3ce44SJohn Forte 	uint32_t	cmd_handle;
86fcf3ce44SJohn Forte 	uint32_t	cmd_rportid;
87fcf3ce44SJohn Forte 	uint32_t	cmd_lportid;
88fcf3ce44SJohn Forte 	uint32_t	cmd_rsvd2;
89fcf3ce44SJohn Forte 	uint16_t	cmd_oxid;
90fcf3ce44SJohn Forte 	uint16_t	cmd_rxid;
91fcf3ce44SJohn Forte 	fct_status_t	cmd_comp_status;
92fcf3ce44SJohn Forte } fct_cmd_t;
93fcf3ce44SJohn Forte 
94fcf3ce44SJohn Forte /*
95fcf3ce44SJohn Forte  * fcmd_cmd_handle: Bit definitions.
96fcf3ce44SJohn Forte  *   31		  23	       15	    7	       0
97fcf3ce44SJohn Forte  *  +--------------+------------+------------+------------+
98fcf3ce44SJohn Forte  *  | V |uniq_cntr |fca specific|   cmd slot index	  |
99fcf3ce44SJohn Forte  *  +--------------+------------+------------+------------+
100fcf3ce44SJohn Forte  * V = handle valid.
101fcf3ce44SJohn Forte  */
102fcf3ce44SJohn Forte #define	CMD_HANDLE_SLOT_INDEX(x)	((x) & 0xffff)
103fcf3ce44SJohn Forte #define	CMD_HANDLE_VALID(x)		((x) & 0x80000000)
104fcf3ce44SJohn Forte 
105fcf3ce44SJohn Forte enum fct_cmd_types {
106fcf3ce44SJohn Forte 	FCT_CMD_FCP_XCHG =	0x0001,
107fcf3ce44SJohn Forte 	FCT_CMD_RCVD_ELS =	0x0002,
108fcf3ce44SJohn Forte 	FCT_CMD_SOL_ELS =	0x0004,
109fcf3ce44SJohn Forte 	FCT_CMD_RCVD_ABTS =	0x0008,
110fcf3ce44SJohn Forte 	FCT_CMD_SOL_CT =	0x0010,
111fcf3ce44SJohn Forte 
112fcf3ce44SJohn Forte 	FCT_CMD_TYPE_ALL =	0xffff
113fcf3ce44SJohn Forte };
114fcf3ce44SJohn Forte 
115fcf3ce44SJohn Forte typedef struct fct_els {
116fcf3ce44SJohn Forte 	uint16_t	els_req_size;
117fcf3ce44SJohn Forte 	uint16_t	els_resp_size;
118fcf3ce44SJohn Forte 	uint16_t	els_req_alloc_size;
119fcf3ce44SJohn Forte 	uint16_t	els_resp_alloc_size;
120fcf3ce44SJohn Forte 	uint8_t		*els_req_payload;
121fcf3ce44SJohn Forte 	uint8_t		*els_resp_payload;
122fcf3ce44SJohn Forte } fct_els_t;
123fcf3ce44SJohn Forte 
124fcf3ce44SJohn Forte typedef struct fct_sol_ct {
125fcf3ce44SJohn Forte 	uint16_t	ct_req_size;
126fcf3ce44SJohn Forte 	uint16_t	ct_resp_size;
127fcf3ce44SJohn Forte 	uint16_t	ct_req_alloc_size;
128fcf3ce44SJohn Forte 	uint16_t	ct_resp_alloc_size;
129fcf3ce44SJohn Forte 	uint8_t		*ct_req_payload;
130fcf3ce44SJohn Forte 	uint8_t		*ct_resp_payload;
131fcf3ce44SJohn Forte } fct_sol_ct_t;
132fcf3ce44SJohn Forte 
133fcf3ce44SJohn Forte typedef struct fct_rcvd_abts {
134fcf3ce44SJohn Forte 	uint8_t		abts_resp_rctl;	/* Can be BA_ACC or BA_RJT */
135fcf3ce44SJohn Forte 	uint8_t		abts_state;
136fcf3ce44SJohn Forte 	uint16_t	rsvd;
137fcf3ce44SJohn Forte 	uint8_t		abts_resp_payload[12];
138fcf3ce44SJohn Forte } fct_rcvd_abts_t;
139fcf3ce44SJohn Forte 
140fcf3ce44SJohn Forte /*
141fcf3ce44SJohn Forte  * abts state
142fcf3ce44SJohn Forte  */
143fcf3ce44SJohn Forte #define	ABTS_STATE_RECEIVED		0
144fcf3ce44SJohn Forte #define	ABTS_STATE_RESPONDED		1
145fcf3ce44SJohn Forte #define	ABTS_STATE_COMPLETED		2
146fcf3ce44SJohn Forte #define	ABTS_STATE_ABORT_REQUESTED	3
147fcf3ce44SJohn Forte #define	ABTS_STATE_ABORT_COMPLETED	4
148fcf3ce44SJohn Forte 
149fcf3ce44SJohn Forte #define	FCHBA_MANUFACTURER_LEN		64
150fcf3ce44SJohn Forte #define	FCHBA_SERIAL_NUMBER_LEN		64
151fcf3ce44SJohn Forte #define	FCHBA_MODEL_LEN			256
152fcf3ce44SJohn Forte #define	FCHBA_MODEL_DESCRIPTION_LEN	256
153fcf3ce44SJohn Forte #define	FCHBA_HARDWARE_VERSION_LEN	256
154fcf3ce44SJohn Forte #define	FCHBA_DRIVER_VERSION_LEN	256
155fcf3ce44SJohn Forte #define	FCHBA_OPTION_ROM_VERSION_LEN	256
156fcf3ce44SJohn Forte #define	FCHBA_FIRMWARE_VERSION_LEN	256
157fcf3ce44SJohn Forte #define	FCHBA_DRIVER_NAME_LEN		256
158fcf3ce44SJohn Forte #define	FCHBA_SYMB_NAME_LEN		255
159fcf3ce44SJohn Forte 
160*4558d122SViswanathan Kannappan #define	FCT_INFO_LEN			160
161*4558d122SViswanathan Kannappan #define	FCT_TASKQ_NAME_LEN		24
162*4558d122SViswanathan Kannappan 
163c946facaSallan #define	FC_TGT_PORT_INFO_CMD		(((uint32_t)'I') << 24)
164c946facaSallan #define	FC_TGT_PORT_RLS			FC_TGT_PORT_INFO_CMD + 0x1
165c946facaSallan 
166fcf3ce44SJohn Forte typedef struct fct_port_attrs {
167fcf3ce44SJohn Forte 	char		manufacturer[FCHBA_MANUFACTURER_LEN];
168fcf3ce44SJohn Forte 	char		serial_number[FCHBA_SERIAL_NUMBER_LEN];
169fcf3ce44SJohn Forte 	char		model[FCHBA_MODEL_LEN];
170fcf3ce44SJohn Forte 	char		model_description[FCHBA_MODEL_DESCRIPTION_LEN];
171fcf3ce44SJohn Forte 	char		hardware_version[FCHBA_HARDWARE_VERSION_LEN];
172fcf3ce44SJohn Forte 	char		driver_version[FCHBA_DRIVER_VERSION_LEN];
173fcf3ce44SJohn Forte 	char		option_rom_version[FCHBA_OPTION_ROM_VERSION_LEN];
174fcf3ce44SJohn Forte 	char		firmware_version[FCHBA_FIRMWARE_VERSION_LEN];
175fcf3ce44SJohn Forte 	char		driver_name[FCHBA_DRIVER_NAME_LEN];
176fcf3ce44SJohn Forte 	uint32_t	vendor_specific_id;
177fcf3ce44SJohn Forte 	uint32_t	supported_cos;
178fcf3ce44SJohn Forte 	uint32_t	supported_speed;
179fcf3ce44SJohn Forte 	uint32_t	max_frame_size;
180fcf3ce44SJohn Forte } fct_port_attrs_t;
181fcf3ce44SJohn Forte 
182c946facaSallan typedef struct fct_port_link_status {
183c946facaSallan 	uint32_t	LinkFailureCount;
184c946facaSallan 	uint32_t	LossOfSyncCount;
185c946facaSallan 	uint32_t	LossOfSignalsCount;
186c946facaSallan 	uint32_t	PrimitiveSeqProtocolErrorCount;
187c946facaSallan 	uint32_t	InvalidTransmissionWordCount;
188c946facaSallan 	uint32_t	InvalidCRCCount;
189c946facaSallan } fct_port_link_status_t;
190c946facaSallan 
191fcf3ce44SJohn Forte typedef struct fct_dbuf_store {
192fcf3ce44SJohn Forte 	void			*fds_fct_private;
193fcf3ce44SJohn Forte 	void			*fds_fca_private;
194fcf3ce44SJohn Forte 	struct stmf_dbuf_store	*fds_ds;
195fcf3ce44SJohn Forte 
196fcf3ce44SJohn Forte 	stmf_data_buf_t *(*fds_alloc_data_buf)(struct fct_local_port *port,
197fcf3ce44SJohn Forte 			    uint32_t size, uint32_t *pminsize, uint32_t flags);
198fcf3ce44SJohn Forte 	void		(*fds_free_data_buf)(struct fct_dbuf_store *fds,
199fcf3ce44SJohn Forte 			    stmf_data_buf_t *dbuf);
2003fb517f7SJames Moore 	stmf_status_t	(*fds_setup_dbuf)(struct fct_local_port *port,
2013fb517f7SJames Moore 			    stmf_data_buf_t *dbuf, uint32_t flags);
2023fb517f7SJames Moore 	void		(*fds_teardown_dbuf)(struct fct_dbuf_store *fds,
2033fb517f7SJames Moore 			    stmf_data_buf_t *dbuf);
2043fb517f7SJames Moore 
2053fb517f7SJames Moore 	uint32_t		fds_max_sgl_xfer_len;
2063fb517f7SJames Moore 	uint32_t		fds_copy_threshold;
207fcf3ce44SJohn Forte } fct_dbuf_store_t;
208fcf3ce44SJohn Forte 
209162fafd3Sallan #define	FCT_FCA_MODREV_1	1
210162fafd3Sallan 
211fcf3ce44SJohn Forte typedef struct fct_local_port {
212fcf3ce44SJohn Forte 	void			*port_fct_private;
213fcf3ce44SJohn Forte 	void			*port_fca_private;
214fcf3ce44SJohn Forte 	stmf_local_port_t	*port_lport;
215fcf3ce44SJohn Forte 
216d8c54e3dSSam Cramer 	char			port_nwwn_str[FC_WWN_BUFLEN];
217d8c54e3dSSam Cramer 	char			port_pwwn_str[FC_WWN_BUFLEN];
218fcf3ce44SJohn Forte 	uint8_t			port_nwwn[FC_WWN_LEN];
219fcf3ce44SJohn Forte 	uint8_t			port_pwwn[FC_WWN_LEN];
220fcf3ce44SJohn Forte 	char			*port_default_alias;
221fcf3ce44SJohn Forte 	char			*port_sym_node_name;
222fcf3ce44SJohn Forte 	char			*port_sym_port_name;
223fcf3ce44SJohn Forte 
224fcf3ce44SJohn Forte 	stmf_port_provider_t	*port_pp;
225fcf3ce44SJohn Forte 
226fcf3ce44SJohn Forte 	uint32_t		port_hard_address;
227fcf3ce44SJohn Forte 	uint16_t		port_max_logins;
228fcf3ce44SJohn Forte 	uint16_t		port_max_xchges;
229fcf3ce44SJohn Forte 	uint32_t		port_fca_fcp_cmd_size;
230fcf3ce44SJohn Forte 	uint32_t		port_fca_rp_private_size;
231fcf3ce44SJohn Forte 	uint32_t		port_fca_sol_els_private_size;
232fcf3ce44SJohn Forte 	uint32_t		port_fca_sol_ct_private_size;
233fcf3ce44SJohn Forte 
234fcf3ce44SJohn Forte 	/* in milliseconds */
235fcf3ce44SJohn Forte 	uint32_t		port_fca_abort_timeout;
236fcf3ce44SJohn Forte 
237fcf3ce44SJohn Forte 	fct_dbuf_store_t	*port_fds;
238fcf3ce44SJohn Forte 	fct_status_t		(*port_get_link_info)(
239fcf3ce44SJohn Forte 		struct fct_local_port *port, struct fct_link_info *li);
240fcf3ce44SJohn Forte 	fct_status_t		(*port_register_remote_port)(
241fcf3ce44SJohn Forte 		struct fct_local_port *port, struct fct_remote_port *rp,
242fcf3ce44SJohn Forte 		struct fct_cmd *login_els);
243fcf3ce44SJohn Forte 	fct_status_t		(*port_deregister_remote_port)(
244fcf3ce44SJohn Forte 		struct fct_local_port *port, struct fct_remote_port *rp);
245fcf3ce44SJohn Forte 	fct_status_t		(*port_send_cmd)(fct_cmd_t *cmd);
246fcf3ce44SJohn Forte 	fct_status_t		(*port_xfer_scsi_data)(fct_cmd_t *cmd,
247fcf3ce44SJohn Forte 			stmf_data_buf_t *dbuf, uint32_t flags);
248fcf3ce44SJohn Forte 	fct_status_t		(*port_send_cmd_response)(fct_cmd_t *cmd,
249fcf3ce44SJohn Forte 					uint32_t ioflags);
250fcf3ce44SJohn Forte 	fct_status_t		(*port_abort_cmd)(struct fct_local_port *port,
251fcf3ce44SJohn Forte 			fct_cmd_t *cmd, uint32_t flags);
252fcf3ce44SJohn Forte 	void			(*port_ctl)(struct fct_local_port *port,
253fcf3ce44SJohn Forte 						int cmd, void *arg);
254fcf3ce44SJohn Forte 	fct_status_t		(*port_flogi_xchg)(struct fct_local_port *port,
255fcf3ce44SJohn Forte 			struct fct_flogi_xchg *fx);
256fcf3ce44SJohn Forte 	void			(*port_populate_hba_details)(
257fcf3ce44SJohn Forte 		struct fct_local_port *port, struct fct_port_attrs *port_attrs);
258c946facaSallan 	fct_status_t		(*port_info)(uint32_t cmd,
259c946facaSallan 		struct fct_local_port *port, void *arg, uint8_t *buf,
260c946facaSallan 		uint32_t *bufsizep);
261162fafd3Sallan 	int		port_fca_version;
262fcf3ce44SJohn Forte } fct_local_port_t;
263fcf3ce44SJohn Forte 
264fcf3ce44SJohn Forte /*
265fcf3ce44SJohn Forte  * Common struct used during FLOGI exchange.
266fcf3ce44SJohn Forte  */
267fcf3ce44SJohn Forte typedef struct fct_flogi_xchg {
268fcf3ce44SJohn Forte 	uint8_t		fx_op;		/* ELS_OP_FLOGI or ELS_OP_ACC/RJT */
269fcf3ce44SJohn Forte 	uint8_t		fx_rjt_reason;
270fcf3ce44SJohn Forte 	uint8_t		fx_rjt_expl;
271fcf3ce44SJohn Forte 	uint8_t		fx_sec_timeout;	/* Timeout in seconds */
272fcf3ce44SJohn Forte 	uint32_t	fx_fport:1,	/* 0=N_port, 1=F_port */
273fcf3ce44SJohn Forte 			rsvd2:31;
274fcf3ce44SJohn Forte 	uint32_t	fx_sid;		/* 24 bit SID to use */
275fcf3ce44SJohn Forte 	uint32_t	fx_did;		/* 24 bit DID to use */
276fcf3ce44SJohn Forte 	uint8_t		fx_pwwn[8];
277fcf3ce44SJohn Forte 	uint8_t		fx_nwwn[8];
278fcf3ce44SJohn Forte } fct_flogi_xchg_t;
279fcf3ce44SJohn Forte 
280fcf3ce44SJohn Forte typedef struct fct_link_info {
281fcf3ce44SJohn Forte 	uint32_t		portid;
282fcf3ce44SJohn Forte 	uint8_t			port_topology;
283fcf3ce44SJohn Forte 	uint8_t			port_speed;
284fcf3ce44SJohn Forte 
285fcf3ce44SJohn Forte 	uint8_t			rsvd:5,
286fcf3ce44SJohn Forte 
287fcf3ce44SJohn Forte 	/*
288fcf3ce44SJohn Forte 	 * FCA sets this bit to indicate that fct does not need to do FLOGI
289fcf3ce44SJohn Forte 	 * because either FCA did the FLOGI or it determined that its a private
290fcf3ce44SJohn Forte 	 * loop. Setting this bit by FCA is optional.
291fcf3ce44SJohn Forte 	 */
292fcf3ce44SJohn Forte 				port_no_fct_flogi:1,
293fcf3ce44SJohn Forte 
294fcf3ce44SJohn Forte 	/* FCA sets this bit to indicate that it did FLOGI */
295fcf3ce44SJohn Forte 				port_fca_flogi_done:1,
296fcf3ce44SJohn Forte 
297fcf3ce44SJohn Forte 	/* FCT sets this bit to indicate that it did FLOGI */
298fcf3ce44SJohn Forte 				port_fct_flogi_done:1;
299fcf3ce44SJohn Forte 
300fcf3ce44SJohn Forte 	uint8_t			rsvd1;
301fcf3ce44SJohn Forte 
302fcf3ce44SJohn Forte 	/* The fields below are only valid if someone did a successful flogi */
303fcf3ce44SJohn Forte 	uint8_t			port_rnwwn[8];
304fcf3ce44SJohn Forte 	uint8_t			port_rpwwn[8];
305fcf3ce44SJohn Forte } fct_link_info_t;
306fcf3ce44SJohn Forte 
307c946facaSallan typedef struct fct_port_stat {
308c946facaSallan 	kstat_named_t	link_failure_cnt;
309c946facaSallan 	kstat_named_t	loss_of_sync_cnt;
310c946facaSallan 	kstat_named_t	loss_of_signals_cnt;
311c946facaSallan 	kstat_named_t	prim_seq_protocol_err_cnt;
312c946facaSallan 	kstat_named_t	invalid_tx_word_cnt;
313c946facaSallan 	kstat_named_t	invalid_crc_cnt;
314c946facaSallan } fct_port_stat_t;
315c946facaSallan 
316fcf3ce44SJohn Forte /*
317fcf3ce44SJohn Forte  * port topology
318fcf3ce44SJohn Forte  */
319fcf3ce44SJohn Forte #define	PORT_TOPOLOGY_UNKNOWN		0
320fcf3ce44SJohn Forte #define	PORT_TOPOLOGY_PT_TO_PT		1
321fcf3ce44SJohn Forte #define	PORT_TOPOLOGY_PRIVATE_LOOP	2
322fcf3ce44SJohn Forte #define	PORT_TOPOLOGY_PUBLIC_LOOP	6
323fcf3ce44SJohn Forte #define	PORT_TOPOLOGY_FABRIC_PT_TO_PT	5
324fcf3ce44SJohn Forte #define	PORT_TOPOLOGY_FABRIC_BIT	4
325fcf3ce44SJohn Forte 
326fcf3ce44SJohn Forte #define	PORT_FLOGI_DONE(li)	(((li)->port_fca_flogi_done) || \
327fcf3ce44SJohn Forte 					((li)->port_fct_flogi_done))
328fcf3ce44SJohn Forte 
329fcf3ce44SJohn Forte /*
330fcf3ce44SJohn Forte  * port speed
331fcf3ce44SJohn Forte  */
332fcf3ce44SJohn Forte #define	PORT_SPEED_UNKNOWN		0
333fcf3ce44SJohn Forte #define	PORT_SPEED_1G			1
334fcf3ce44SJohn Forte #define	PORT_SPEED_2G			2
335fcf3ce44SJohn Forte #define	PORT_SPEED_4G			4
336fcf3ce44SJohn Forte #define	PORT_SPEED_8G			8
3372a8164dfSZhong Wang #define	PORT_SPEED_10G			16
338fcf3ce44SJohn Forte 
339fcf3ce44SJohn Forte /*
340fcf3ce44SJohn Forte  * Abort commands
341fcf3ce44SJohn Forte  */
342fcf3ce44SJohn Forte #define	FCT_TERMINATE_CMD		1
343fcf3ce44SJohn Forte 
344fcf3ce44SJohn Forte /*
345fcf3ce44SJohn Forte  * FCT port states.
346fcf3ce44SJohn Forte  */
347fcf3ce44SJohn Forte #define	FCT_STATE_OFFLINE	0
348fcf3ce44SJohn Forte #define	FCT_STATE_ONLINING	1
349fcf3ce44SJohn Forte #define	FCT_STATE_ONLINE	2
350fcf3ce44SJohn Forte #define	FCT_STATE_OFFLINING	3
351fcf3ce44SJohn Forte 
352fcf3ce44SJohn Forte /*
353fcf3ce44SJohn Forte  * fct ctl commands. These should not conflict with stmf ctl commands
354fcf3ce44SJohn Forte  */
355fcf3ce44SJohn Forte #define	FCT_CMD_PORT_ONLINE		(STMF_LPORT_CTL_CMDS | 0x01)
356fcf3ce44SJohn Forte #define	FCT_CMD_PORT_ONLINE_COMPLETE	(STMF_LPORT_CTL_CMDS | 0x02)
357fcf3ce44SJohn Forte #define	FCT_CMD_PORT_OFFLINE		(STMF_LPORT_CTL_CMDS | 0x03)
358fcf3ce44SJohn Forte #define	FCT_CMD_PORT_OFFLINE_COMPLETE	(STMF_LPORT_CTL_CMDS | 0x04)
359fcf3ce44SJohn Forte #define	FCT_ACK_PORT_ONLINE_COMPLETE	(STMF_LPORT_CTL_CMDS | 0x05)
360fcf3ce44SJohn Forte #define	FCT_ACK_PORT_OFFLINE_COMPLETE	(STMF_LPORT_CTL_CMDS | 0x06)
361a7949318SReed #define	FCT_CMD_FORCE_LIP		(STMF_LPORT_CTL_CMDS | 0x07)
362fcf3ce44SJohn Forte 
363fcf3ce44SJohn Forte /*
364fcf3ce44SJohn Forte  * IO flags for cmd flow.
365fcf3ce44SJohn Forte  */
366fcf3ce44SJohn Forte #define	FCT_IOF_FCA_DONE		0x10000
367fcf3ce44SJohn Forte #define	FCT_IOF_FORCE_FCA_DONE		0x20000
368fcf3ce44SJohn Forte 
369fcf3ce44SJohn Forte /*
370fcf3ce44SJohn Forte  * Fill CTIU preample
371fcf3ce44SJohn Forte  */
372fcf3ce44SJohn Forte #ifdef	lint
373fcf3ce44SJohn Forte #define	FCT_FILL_CTIU_PREAMPLE(x_payload, x_ctop)	_NOTE(EMPTY)
374fcf3ce44SJohn Forte #else
375fcf3ce44SJohn Forte #define	FCT_FILL_CTIU_PREAMPLE(x_payload, x_ctop)	\
376fcf3ce44SJohn Forte 	do {						\
377fcf3ce44SJohn Forte 		x_payload[0] = 0x02;			\
378fcf3ce44SJohn Forte 		x_payload[4] = 0xFC;			\
379fcf3ce44SJohn Forte 		x_payload[5] = 0x02;			\
380fcf3ce44SJohn Forte 		x_payload[8] = 0xFF & (x_ctop >> 8);	\
381fcf3ce44SJohn Forte 		x_payload[9] = 0xFF & (x_ctop);		\
382fcf3ce44SJohn Forte 	} while (0)
383fcf3ce44SJohn Forte #endif
384fcf3ce44SJohn Forte 
385fcf3ce44SJohn Forte uint64_t fct_netbuf_to_value(uint8_t *buf, uint8_t nbytes);
386fcf3ce44SJohn Forte void fct_value_to_netbuf(uint64_t value, uint8_t *buf, uint8_t nbytes);
387fcf3ce44SJohn Forte void *fct_alloc(fct_struct_id_t struct_id, int additional_size, int flags);
388fcf3ce44SJohn Forte void fct_free(void *ptr);
389fcf3ce44SJohn Forte fct_cmd_t *fct_scsi_task_alloc(struct fct_local_port *port,
390fcf3ce44SJohn Forte     uint16_t rp_handle, uint32_t rportid, uint8_t *lun,
391fcf3ce44SJohn Forte     uint16_t cdb_length, uint16_t task_ext);
392fcf3ce44SJohn Forte fct_status_t fct_register_local_port(fct_local_port_t *port);
393fcf3ce44SJohn Forte fct_status_t fct_deregister_local_port(fct_local_port_t *port);
394fcf3ce44SJohn Forte void fct_handle_event(fct_local_port_t *port, int event_id,
395fcf3ce44SJohn Forte     uint32_t event_flags, caddr_t arg);
396fcf3ce44SJohn Forte void fct_post_rcvd_cmd(fct_cmd_t *cmd, stmf_data_buf_t *dbuf);
397fcf3ce44SJohn Forte void fct_queue_cmd_for_termination(fct_cmd_t *cmd, fct_status_t s);
398fcf3ce44SJohn Forte void fct_queue_scsi_task_for_termination(fct_cmd_t *cmd, fct_status_t s);
399fcf3ce44SJohn Forte fct_cmd_t *fct_handle_to_cmd(fct_local_port_t *port, uint32_t fct_handle);
400fcf3ce44SJohn Forte void fct_ctl(struct stmf_local_port *lport, int cmd, void *arg);
401fcf3ce44SJohn Forte void fct_cmd_fca_aborted(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags);
402fcf3ce44SJohn Forte uint16_t fct_get_rp_handle(fct_local_port_t *port, uint32_t rportid);
403fcf3ce44SJohn Forte void fct_send_response_done(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags);
404fcf3ce44SJohn Forte void fct_send_cmd_done(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags);
405fcf3ce44SJohn Forte void fct_scsi_data_xfer_done(fct_cmd_t *cmd, stmf_data_buf_t *dbuf,
406fcf3ce44SJohn Forte     uint32_t ioflags);
407fcf3ce44SJohn Forte fct_status_t fct_port_initialize(fct_local_port_t *port, uint32_t rflags,
408fcf3ce44SJohn Forte     char *additional_info);
409fcf3ce44SJohn Forte fct_status_t fct_port_shutdown(fct_local_port_t *port, uint32_t rflags,
410fcf3ce44SJohn Forte     char *additional_info);
411fcf3ce44SJohn Forte fct_status_t fct_handle_rcvd_flogi(fct_local_port_t *port,
412fcf3ce44SJohn Forte     fct_flogi_xchg_t *fx);
413fcf3ce44SJohn Forte void fct_log_local_port_event(fct_local_port_t *port, char *subclass);
414fcf3ce44SJohn Forte void fct_log_remote_port_event(fct_local_port_t *port, char *subclass,
415fcf3ce44SJohn Forte     uint8_t *rp_pwwn, uint32_t rp_id);
416d8c54e3dSSam Cramer void fct_wwn_to_str(char *to_ptr, const uint8_t *from_ptr);
417fcf3ce44SJohn Forte 
418fcf3ce44SJohn Forte #ifdef	__cplusplus
419fcf3ce44SJohn Forte }
420fcf3ce44SJohn Forte #endif
421fcf3ce44SJohn Forte 
422fcf3ce44SJohn Forte #endif /* _FCT_H */
423