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