1*fcf3ce44SJohn Forte /*
2*fcf3ce44SJohn Forte  * CDDL HEADER START
3*fcf3ce44SJohn Forte  *
4*fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5*fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6*fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7*fcf3ce44SJohn Forte  *
8*fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10*fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11*fcf3ce44SJohn Forte  * and limitations under the License.
12*fcf3ce44SJohn Forte  *
13*fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14*fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16*fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17*fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18*fcf3ce44SJohn Forte  *
19*fcf3ce44SJohn Forte  * CDDL HEADER END
20*fcf3ce44SJohn Forte  */
21*fcf3ce44SJohn Forte /*
22*fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*fcf3ce44SJohn Forte  * Use is subject to license terms.
24*fcf3ce44SJohn Forte  */
25*fcf3ce44SJohn Forte 
26*fcf3ce44SJohn Forte #ifndef	_FC_FCAIF_H
27*fcf3ce44SJohn Forte #define	_FC_FCAIF_H
28*fcf3ce44SJohn Forte 
29*fcf3ce44SJohn Forte 
30*fcf3ce44SJohn Forte #include <sys/note.h>
31*fcf3ce44SJohn Forte 
32*fcf3ce44SJohn Forte #ifdef	__cplusplus
33*fcf3ce44SJohn Forte extern "C" {
34*fcf3ce44SJohn Forte #endif
35*fcf3ce44SJohn Forte 
36*fcf3ce44SJohn Forte /*
37*fcf3ce44SJohn Forte  * Version for FCA vectors
38*fcf3ce44SJohn Forte  */
39*fcf3ce44SJohn Forte #define	FCTL_FCA_MODREV_1	1
40*fcf3ce44SJohn Forte #define	FCTL_FCA_MODREV_2	2
41*fcf3ce44SJohn Forte #define	FCTL_FCA_MODREV_3	3
42*fcf3ce44SJohn Forte #define	FCTL_FCA_MODREV_4	4
43*fcf3ce44SJohn Forte #define	FCTL_FCA_MODREV_5	5
44*fcf3ce44SJohn Forte 
45*fcf3ce44SJohn Forte /*
46*fcf3ce44SJohn Forte  * State change codes
47*fcf3ce44SJohn Forte  */
48*fcf3ce44SJohn Forte #define	FC_SC_OFFLINE		0
49*fcf3ce44SJohn Forte #define	FC_SC_ONLINE		1
50*fcf3ce44SJohn Forte 
51*fcf3ce44SJohn Forte /*
52*fcf3ce44SJohn Forte  * pm_cmd_flag definitions
53*fcf3ce44SJohn Forte  */
54*fcf3ce44SJohn Forte #define	FC_FCA_PM_NOP		0x00
55*fcf3ce44SJohn Forte #define	FC_FCA_PM_READ		0x01
56*fcf3ce44SJohn Forte #define	FC_FCA_PM_WRITE		0x02
57*fcf3ce44SJohn Forte #define	FC_FCA_PM_RW		(FC_FCA_PM_READ | FC_FCA_PM_WRITE)
58*fcf3ce44SJohn Forte 
59*fcf3ce44SJohn Forte /*
60*fcf3ce44SJohn Forte  *  Command codes for fca_reset()
61*fcf3ce44SJohn Forte  */
62*fcf3ce44SJohn Forte #define	FC_FCA_LINK_RESET	0x01
63*fcf3ce44SJohn Forte #define	FC_FCA_CORE		0x02
64*fcf3ce44SJohn Forte #define	FC_FCA_RESET_CORE	0x03
65*fcf3ce44SJohn Forte #define	FC_FCA_RESET		0x04
66*fcf3ce44SJohn Forte 
67*fcf3ce44SJohn Forte /*
68*fcf3ce44SJohn Forte  * fca_port_manage() command codes
69*fcf3ce44SJohn Forte  */
70*fcf3ce44SJohn Forte #define	FC_PORT_BYPASS		0x01
71*fcf3ce44SJohn Forte #define	FC_PORT_UNBYPASS	0x02
72*fcf3ce44SJohn Forte #define	FC_PORT_DIAG		0x03
73*fcf3ce44SJohn Forte #define	FC_PORT_ERR_STATS	0x04
74*fcf3ce44SJohn Forte #define	FC_PORT_GET_FW_REV	0x05
75*fcf3ce44SJohn Forte #define	FC_PORT_GET_FCODE_REV	0x06
76*fcf3ce44SJohn Forte #define	FC_PORT_GET_DUMP_SIZE	0x07
77*fcf3ce44SJohn Forte #define	FC_PORT_FORCE_DUMP	0x08
78*fcf3ce44SJohn Forte #define	FC_PORT_GET_DUMP	0x09
79*fcf3ce44SJohn Forte #define	FC_PORT_LOOPBACK	0x0A
80*fcf3ce44SJohn Forte #define	FC_PORT_LINK_STATE	0x0B
81*fcf3ce44SJohn Forte #define	FC_PORT_INITIALIZE	0x0C
82*fcf3ce44SJohn Forte #define	FC_PORT_DOWNLOAD_FW	0x0D
83*fcf3ce44SJohn Forte #define	FC_PORT_RLS		0x0E
84*fcf3ce44SJohn Forte #define	FC_PORT_DOWNLOAD_FCODE	0x0F
85*fcf3ce44SJohn Forte #define	FC_PORT_GET_NODE_ID	0x10
86*fcf3ce44SJohn Forte #define	FC_PORT_SET_NODE_ID	0x11
87*fcf3ce44SJohn Forte #define	FC_PORT_GET_P2P_INFO	0x12
88*fcf3ce44SJohn Forte 
89*fcf3ce44SJohn Forte /*
90*fcf3ce44SJohn Forte  * FCA capability strings
91*fcf3ce44SJohn Forte  */
92*fcf3ce44SJohn Forte #define	FC_NODE_WWN			"FCA node WWN"
93*fcf3ce44SJohn Forte #define	FC_LOGIN_PARAMS			"FCA login parameters"
94*fcf3ce44SJohn Forte #define	FC_CAP_UNSOL_BUF		"number of unsolicited bufs"
95*fcf3ce44SJohn Forte #define	FC_CAP_PAYLOAD_SIZE		"exchange payload max"
96*fcf3ce44SJohn Forte #define	FC_CAP_POST_RESET_BEHAVIOR	"port reset behavior"
97*fcf3ce44SJohn Forte #define	FC_CAP_NOSTREAM_ON_UNALIGN_BUF	"no dma streaming on unaligned buf"
98*fcf3ce44SJohn Forte #define	FC_CAP_FCP_DMA			"FCP cmd response in DVMA space"
99*fcf3ce44SJohn Forte 
100*fcf3ce44SJohn Forte typedef struct fc_fca_bind {
101*fcf3ce44SJohn Forte 	int 			port_num;
102*fcf3ce44SJohn Forte 	opaque_t 		port_handle;
103*fcf3ce44SJohn Forte 	void (*port_statec_cb) (opaque_t port_handle, uint32_t state);
104*fcf3ce44SJohn Forte 	void (*port_unsol_cb) (opaque_t port_handle,
105*fcf3ce44SJohn Forte 		fc_unsol_buf_t *buf, uint32_t type);
106*fcf3ce44SJohn Forte 	la_wwn_t		port_nwwn;	/* virtual port pwwn */
107*fcf3ce44SJohn Forte 	la_wwn_t		port_pwwn;	/* virtual port nwwn */
108*fcf3ce44SJohn Forte 	int			port_npiv;	/* virtual port flag */
109*fcf3ce44SJohn Forte } fc_fca_bind_info_t;
110*fcf3ce44SJohn Forte 
111*fcf3ce44SJohn Forte typedef struct fc_fca_rnid {
112*fcf3ce44SJohn Forte 	int		status;
113*fcf3ce44SJohn Forte 	fc_rnid_t	params;
114*fcf3ce44SJohn Forte }fc_fca_rnid_t;
115*fcf3ce44SJohn Forte 
116*fcf3ce44SJohn Forte typedef struct fc_fca_port_info {
117*fcf3ce44SJohn Forte 	uchar_t			pi_topology;	/* Unused */
118*fcf3ce44SJohn Forte 	uint32_t		pi_error;
119*fcf3ce44SJohn Forte 	uint32_t		pi_port_state;
120*fcf3ce44SJohn Forte 	fc_portid_t		pi_s_id;	/* Unused */
121*fcf3ce44SJohn Forte 	fc_hardaddr_t		pi_hard_addr;	/* Hard address */
122*fcf3ce44SJohn Forte 	la_els_logi_t		pi_login_params;
123*fcf3ce44SJohn Forte 	fc_fca_rnid_t		pi_rnid_params;
124*fcf3ce44SJohn Forte 	fca_port_attrs_t	pi_attrs;
125*fcf3ce44SJohn Forte } fc_fca_port_info_t;
126*fcf3ce44SJohn Forte 
127*fcf3ce44SJohn Forte typedef struct fc_fca_pm {
128*fcf3ce44SJohn Forte 	uint32_t	pm_cmd_code;	/* port manage command */
129*fcf3ce44SJohn Forte 	uint32_t	pm_cmd_flags;	/* READ/WRITE */
130*fcf3ce44SJohn Forte 	size_t		pm_cmd_len;	/* cmd buffer length */
131*fcf3ce44SJohn Forte 	caddr_t		pm_cmd_buf;	/* cmd buffer */
132*fcf3ce44SJohn Forte 	size_t		pm_data_len;	/* data buffer length */
133*fcf3ce44SJohn Forte 	caddr_t		pm_data_buf;	/* data buffer */
134*fcf3ce44SJohn Forte 	size_t		pm_stat_len;	/* status buffer length */
135*fcf3ce44SJohn Forte 	caddr_t		pm_stat_buf;	/* status buffer */
136*fcf3ce44SJohn Forte } fc_fca_pm_t;
137*fcf3ce44SJohn Forte 
138*fcf3ce44SJohn Forte typedef struct fc_fca_p2p_info {
139*fcf3ce44SJohn Forte 	uint32_t	fca_d_id;	/* HBA port D_ID */
140*fcf3ce44SJohn Forte 	uint32_t	d_id;		/* Remote port D_ID */
141*fcf3ce44SJohn Forte 	la_wwn_t	pwwn;		/* Remote port PWWN */
142*fcf3ce44SJohn Forte 	la_wwn_t	nwwn;		/* Remote port NWWN */
143*fcf3ce44SJohn Forte } fc_fca_p2p_info_t;
144*fcf3ce44SJohn Forte 
145*fcf3ce44SJohn Forte typedef struct fca_tran {
146*fcf3ce44SJohn Forte 	int				fca_version;
147*fcf3ce44SJohn Forte 	int				fca_numports;
148*fcf3ce44SJohn Forte 	int				fca_pkt_size;
149*fcf3ce44SJohn Forte 	uint32_t			fca_cmd_max;
150*fcf3ce44SJohn Forte 	ddi_dma_lim_t			*fca_dma_lim;
151*fcf3ce44SJohn Forte 	ddi_iblock_cookie_t		*fca_iblock;
152*fcf3ce44SJohn Forte 	ddi_dma_attr_t			*fca_dma_attr;
153*fcf3ce44SJohn Forte 	ddi_dma_attr_t			*fca_dma_fcp_cmd_attr;
154*fcf3ce44SJohn Forte 	ddi_dma_attr_t			*fca_dma_fcp_rsp_attr;
155*fcf3ce44SJohn Forte 	ddi_dma_attr_t			*fca_dma_fcp_data_attr;
156*fcf3ce44SJohn Forte 	ddi_dma_attr_t			*fca_dma_fcip_cmd_attr;
157*fcf3ce44SJohn Forte 	ddi_dma_attr_t			*fca_dma_fcip_rsp_attr;
158*fcf3ce44SJohn Forte 	ddi_dma_attr_t			*fca_dma_fcsm_cmd_attr;
159*fcf3ce44SJohn Forte 	ddi_dma_attr_t			*fca_dma_fcsm_rsp_attr;
160*fcf3ce44SJohn Forte 	ddi_device_acc_attr_t		*fca_acc_attr;
161*fcf3ce44SJohn Forte 	int				fca_num_npivports;
162*fcf3ce44SJohn Forte 		/* number of virtual ports supported, 0 means unsupported */
163*fcf3ce44SJohn Forte 	la_wwn_t			fca_perm_pwwn;
164*fcf3ce44SJohn Forte 		/* permanent port wwn for the port */
165*fcf3ce44SJohn Forte 
166*fcf3ce44SJohn Forte 	opaque_t (*fca_bind_port) (dev_info_t *dip,
167*fcf3ce44SJohn Forte 	    fc_fca_port_info_t *port_info, fc_fca_bind_info_t *bind_info);
168*fcf3ce44SJohn Forte 
169*fcf3ce44SJohn Forte 	void (*fca_unbind_port) (opaque_t fca_handle);
170*fcf3ce44SJohn Forte 
171*fcf3ce44SJohn Forte 	int (*fca_init_pkt) (opaque_t fca_handle, fc_packet_t *pkt, int sleep);
172*fcf3ce44SJohn Forte 
173*fcf3ce44SJohn Forte 	int (*fca_un_init_pkt) (opaque_t fca_handle, fc_packet_t *pkt);
174*fcf3ce44SJohn Forte 
175*fcf3ce44SJohn Forte 	int (*fca_els_send) (opaque_t fca_handle, fc_packet_t *pkt);
176*fcf3ce44SJohn Forte 
177*fcf3ce44SJohn Forte 	int (*fca_get_cap) (opaque_t fca_handle, char *cap, void *ptr);
178*fcf3ce44SJohn Forte 
179*fcf3ce44SJohn Forte 	int (*fca_set_cap) (opaque_t fca_handle, char *cap, void *ptr);
180*fcf3ce44SJohn Forte 
181*fcf3ce44SJohn Forte 	int (*fca_getmap) (opaque_t fca_handle, fc_lilpmap_t *map);
182*fcf3ce44SJohn Forte 
183*fcf3ce44SJohn Forte 	int (*fca_transport) (opaque_t fca_handle, fc_packet_t *pkt);
184*fcf3ce44SJohn Forte 
185*fcf3ce44SJohn Forte 	int (*fca_ub_alloc) (opaque_t fca_handle, uint64_t *tokens,
186*fcf3ce44SJohn Forte 	    uint32_t ub_size, uint32_t *ub_count, uint32_t type);
187*fcf3ce44SJohn Forte 
188*fcf3ce44SJohn Forte 	int (*fca_ub_free) (opaque_t fca_handle, uint32_t count,
189*fcf3ce44SJohn Forte 	    uint64_t tokens[]);
190*fcf3ce44SJohn Forte 
191*fcf3ce44SJohn Forte 	int (*fca_ub_release) (opaque_t fca_handle, uint32_t count,
192*fcf3ce44SJohn Forte 	    uint64_t tokens[]);
193*fcf3ce44SJohn Forte 
194*fcf3ce44SJohn Forte 	int (*fca_abort) (opaque_t fca_handle, fc_packet_t *pkt, int flags);
195*fcf3ce44SJohn Forte 
196*fcf3ce44SJohn Forte 	int (*fca_reset) (opaque_t fca_handle, uint32_t cmd);
197*fcf3ce44SJohn Forte 
198*fcf3ce44SJohn Forte 	int (*fca_port_manage) (opaque_t fca_port, fc_fca_pm_t *arg);
199*fcf3ce44SJohn Forte 
200*fcf3ce44SJohn Forte 	opaque_t (*fca_get_device) (opaque_t fca_port, fc_portid_t d_id);
201*fcf3ce44SJohn Forte 
202*fcf3ce44SJohn Forte 	int (*fca_notify) (opaque_t fca_handle, uint32_t cmd);
203*fcf3ce44SJohn Forte 
204*fcf3ce44SJohn Forte } fc_fca_tran_t;
205*fcf3ce44SJohn Forte 
206*fcf3ce44SJohn Forte void fc_fca_init(struct dev_ops *fca_devops_p);
207*fcf3ce44SJohn Forte int fc_fca_attach(dev_info_t *, fc_fca_tran_t *);
208*fcf3ce44SJohn Forte int fc_fca_detach(dev_info_t *fca_dip);
209*fcf3ce44SJohn Forte int fc_fca_update_errors(fc_packet_t *pkt);
210*fcf3ce44SJohn Forte int fc_fca_error(int fc_errno, char **errmsg);
211*fcf3ce44SJohn Forte int fc_fca_pkt_error(fc_packet_t *pkt, char **state, char **reason,
212*fcf3ce44SJohn Forte     char **action, char **expln);
213*fcf3ce44SJohn Forte 
214*fcf3ce44SJohn Forte #if	!defined(__lint)
215*fcf3ce44SJohn Forte _NOTE(SCHEME_PROTECTS_DATA("unique per fca_bind", fc_fca_port_info))
216*fcf3ce44SJohn Forte _NOTE(SCHEME_PROTECTS_DATA("unique per fca_bind", fc_fca_bind))
217*fcf3ce44SJohn Forte _NOTE(SCHEME_PROTECTS_DATA("stable data", fca_tran))
218*fcf3ce44SJohn Forte #endif /* __lint */
219*fcf3ce44SJohn Forte 
220*fcf3ce44SJohn Forte #ifdef	__cplusplus
221*fcf3ce44SJohn Forte }
222*fcf3ce44SJohn Forte #endif
223*fcf3ce44SJohn Forte 
224*fcf3ce44SJohn Forte #endif	/* _FC_FCAIF_H */
225