xref: /illumos-gate/usr/src/uts/common/sys/fibre-channel/impl/fc_ulpif.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_ULPIF_H
27 #define	_FC_ULPIF_H
28 
29 
30 
31 #include <sys/note.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * fctl does not support downward compatibility. When there is any change of
39  * non-private structure or non-static interface in fctl, the module revision
40  * number needs to be bumped up here, and for each ulp, the module revision
41  * number in fc_ulp_modinfo needs to be updated.
42  */
43 #define	FCTL_ULP_MODREV_1		1
44 #define	FCTL_ULP_MODREV_2		2
45 #define	FCTL_ULP_MODREV_3		3
46 #define	FCTL_ULP_MODREV_4		4
47 
48 /*
49  * Flag definitions to fc_ulp_get_portmap function.
50  */
51 #define	FC_ULP_PLOGI_DONTCARE		0
52 #define	FC_ULP_PLOGI_PRESERVE		1
53 
54 #define	FC_ULP_DEVICE_OFFLINE		0
55 #define	FC_ULP_DEVICE_ONLINE		1
56 
57 /*
58  * fc_ulp_port_reset() command codes
59  */
60 #define	FC_RESET_PORT			0x01
61 #define	FC_RESET_ADAPTER		0x02
62 #define	FC_RESET_DUMP			0x03
63 #define	FC_RESET_CRASH			0x04
64 
65 /*
66  * port attach callback commands
67  */
68 typedef enum fc_attach_cmd {
69 	FC_CMD_ATTACH,
70 	FC_CMD_RESUME,
71 	FC_CMD_POWER_UP
72 } fc_attach_cmd_t;
73 
74 /*
75  * port detach callback commands
76  */
77 typedef enum fc_detach_cmd {
78 	FC_CMD_DETACH,
79 	FC_CMD_SUSPEND,
80 	FC_CMD_POWER_DOWN
81 } fc_detach_cmd_t;
82 
83 typedef struct fc_portmap {
84 	int			map_state;
85 	int			map_flags;		/* Status flags */
86 	int			map_type;		/* OLD, NEW, CHANGED */
87 	uint32_t		map_fc4_types[8];	/* fc4 types */
88 	la_wwn_t    		map_pwwn;
89 	la_wwn_t		map_nwwn;
90 	fc_portid_t		map_did;
91 	fc_hardaddr_t		map_hard_addr;
92 	opaque_t		map_pd;			/* port device */
93 	fc_ulp_rscn_info_t	map_rscn_info;		/* xport's RSCN info */
94 } fc_portmap_t;
95 
96 typedef struct ulp_port_info {
97 	struct modlinkage 	*port_linkage;
98 	dev_info_t		*port_dip;
99 	opaque_t		port_handle;
100 	ddi_dma_attr_t		*port_data_dma_attr;
101 	ddi_dma_attr_t		*port_cmd_dma_attr;
102 	ddi_dma_attr_t		*port_resp_dma_attr;
103 	ddi_device_acc_attr_t 	*port_acc_attr;
104 	int			port_fca_pkt_size;
105 	int			port_fca_max_exch;
106 	uint32_t		port_state;
107 	uint32_t		port_flags;
108 	la_wwn_t		port_pwwn;		/* port WWN */
109 	la_wwn_t		port_nwwn;		/* node WWN */
110 	fc_reset_action_t	port_reset_action;	/* FCA reset action */
111 	fc_dma_behavior_t	port_dma_behavior;	/* FCA DMA behavior */
112 	fc_fcp_dma_t		port_fcp_dma;		/* FCP DVMA space */
113 } fc_ulp_port_info_t;
114 
115 typedef struct ulp_modinfo {
116 	opaque_t	ulp_handle;		/* not really needed */
117 	uint32_t	ulp_rev;		/* ULP revision */
118 	uchar_t		ulp_type;		/* FC-4 type */
119 	char 		*ulp_name;		/* ULP Name */
120 	int		ulp_statec_mask;	/* state change mask */
121 	int		(*ulp_port_attach) (opaque_t ulp_handle,
122 			    struct ulp_port_info *, fc_attach_cmd_t cmd,
123 			    uint32_t s_id);
124 	int		(*ulp_port_detach) (opaque_t ulp_handle,
125 			    struct ulp_port_info *, fc_detach_cmd_t cmd);
126 	int		(*ulp_port_ioctl) (opaque_t ulp_handle,
127 			    opaque_t port_handle, dev_t dev, int cmd,
128 			    intptr_t data, int mode, cred_t *credp,
129 			    int *rval, uint32_t claimed);
130 	int		(*ulp_els_callback) (opaque_t ulp_handle,
131 			    opaque_t port_handle, fc_unsol_buf_t *payload,
132 			    uint32_t claimed);
133 	int		(*ulp_data_callback) (opaque_t ulp_handle,
134 			    opaque_t port_handle, fc_unsol_buf_t *buf,
135 			    uint32_t claimed);
136 	void		(*ulp_statec_callback) (opaque_t ulp_handle,
137 			    opaque_t port_handle, uint32_t statec,
138 			    uint32_t port_flags, fc_portmap_t changelist[],
139 			    uint32_t listlen, uint32_t s_id);
140 } fc_ulp_modinfo_t;
141 
142 #if	!defined(__lint)
143 _NOTE(SCHEME_PROTECTS_DATA("unique for attach", ulp_port_info))
144 _NOTE(SCHEME_PROTECTS_DATA("stable data", ulp_modinfo))
145 _NOTE(SCHEME_PROTECTS_DATA("unique per request", fc_portmap))
146 #endif	/* __lint */
147 
148 int fc_ulp_add(fc_ulp_modinfo_t *ulp_info);
149 int fc_ulp_remove(fc_ulp_modinfo_t *ulp_info);
150 int fc_ulp_init_packet(opaque_t port_handle, fc_packet_t *pkt, int sleep);
151 int fc_ulp_uninit_packet(opaque_t port_handle, fc_packet_t *pkt);
152 int fc_ulp_getportmap(opaque_t port_handle, fc_portmap_t **map,
153     uint32_t *len, int flag);
154 int fc_ulp_login(opaque_t port_handle, fc_packet_t **ulp_pkt,
155     uint32_t listlen);
156 opaque_t fc_ulp_get_remote_port(opaque_t port_handle, la_wwn_t *pwwn,
157     int *error, int create);
158 int fc_ulp_port_ns(opaque_t port_handle, opaque_t pd, fc_ns_cmd_t *ns_req);
159 int fc_ulp_transport(opaque_t port_handle, fc_packet_t *pkt);
160 int fc_ulp_issue_els(opaque_t port_handle, fc_packet_t *pkt);
161 int fc_ulp_uballoc(opaque_t port_handle, uint32_t *count,
162     uint32_t size, uint32_t type, uint64_t *tokens);
163 int fc_ulp_ubfree(opaque_t port_handle, uint32_t count,
164     uint64_t *tokens);
165 int fc_ulp_ubrelease(opaque_t port_handle, uint32_t count,
166     uint64_t *tokens);
167 int fc_ulp_abort(opaque_t port_handle, fc_packet_t *pkt, int flags);
168 int fc_ulp_linkreset(opaque_t port_handle, la_wwn_t *pwwn, int sleep);
169 int fc_ulp_port_reset(opaque_t port_handle, uint32_t cmd);
170 int fc_ulp_get_port_login_params(opaque_t port_handle,
171     la_els_logi_t *login_params);
172 int fc_ulp_get_port_instance(opaque_t port_handle);
173 opaque_t fc_ulp_get_port_handle(int instance);
174 int fc_ulp_error(int fc_errno, char **errmsg);
175 int fc_ulp_pkt_error(fc_packet_t *pkt, char **state, char **reason,
176     char **action, char **expln);
177 int fc_ulp_is_name_present(caddr_t ulp_name);
178 int fc_ulp_get_pwwn_by_did(opaque_t port_handle, fc_portid_t d_id,
179     la_wwn_t *pwwn);
180 int fc_ulp_pwwn_to_portmap(opaque_t port_handle, la_wwn_t *bytes,
181     fc_portmap_t *map);
182 opaque_t fc_ulp_get_fca_device(opaque_t port_handle, fc_portid_t d_id);
183 int fc_ulp_port_notify(opaque_t port_handle, uint32_t cmd);
184 void fc_ulp_disable_relogin(opaque_t *fc_port, la_wwn_t *pwwn);
185 void fc_ulp_enable_relogin(opaque_t *fc_port, la_wwn_t *pwwn);
186 int fc_ulp_busy_port(opaque_t port_handle);
187 void fc_ulp_idle_port(opaque_t port_handle);
188 void fc_ulp_copy_portmap(fc_portmap_t *map, opaque_t pd);
189 int fc_ulp_get_adapter_paths(char *pathList, int count);
190 uint32_t fc_ulp_get_rscn_count(opaque_t port_handle);
191 void fc_ulp_hold_remote_port(opaque_t port_handle);
192 int fc_ulp_get_npiv_port_list(opaque_t port_handle, char *pathList);
193 int fc_ulp_get_npiv_port_num(opaque_t port_handle);
194 void fc_ulp_log_device_event(opaque_t port_handle, int type);
195 
196 #ifdef	__cplusplus
197 }
198 #endif
199 
200 #endif	/* _FC_ULPIF_H */
201