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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
29 #ifndef _SYS_IB_MGT_IBDM_IBDM_IBNEX_H
30 #define _SYS_IB_MGT_IBDM_IBDM_IBNEX_H
33 * This file contains the definitions of private interfaces
34 * and data structures used between IB nexus and IBDM.
37 #include <sys/ib/ibtl/ibti_common.h>
38 #include <sys/ib/mgt/ibmf/ibmf.h>
39 #include <sys/ib/mgt/ib_dm_attr.h>
45 /* DM return status codes from private interfaces */
46 typedef enum ibdm_status_e
{
52 * IBDM events that are passed to IB nexus driver
53 * NOTE: These are different from ibt_async_code_t
55 typedef enum ibdm_events_e
{
57 IBDM_EVENT_HCA_REMOVED
,
58 IBDM_EVENT_IOC_PROP_UPDATE
,
60 IBDM_EVENT_PORT_PKEY_CHANGE
64 * Flags for ibdm_ibnex_get_ioc_list.
65 * The flags determine the functioning of ibdm_ibnex_get_ioc_list.
67 * IBDM_IBNEX_NORMAL_PROBE
68 * Sweep fabric and discover new GIDs only
69 * This value should be same as IBNEX_PROBE_ALLOWED_FLAG
70 * IBDM_IBNEX_DONOT_PROBE
71 * Do not probe, just get the current ioc_list.
72 * This value should be same as IBNEX_DONOT_PROBE_FLAG
73 * IBDM_IBNEX_REPROBE_ALL
74 * Sweep fabric, discover new GIDs. For GIDs
75 * discovered before, reprobe the IOCs on it.
77 typedef enum ibdm_ibnex_get_ioclist_mtd_e
{
78 IBDM_IBNEX_NORMAL_PROBE
,
79 IBDM_IBNEX_DONOT_PROBE
,
80 IBDM_IBNEX_REPROBE_ALL
81 } ibdm_ibnex_get_ioclist_mtd_t
;
85 * Private data structure called from IBDM timeout handler
87 typedef struct ibdm_timeout_cb_args_s
{
88 struct ibdm_dp_gidinfo_s
*cb_gid_info
;
90 int cb_ioc_num
; /* IOC# */
94 } ibdm_timeout_cb_args_t
;
97 * Service entry structure
99 typedef struct ibdm_srvents_info_s
{
102 timeout_id_t se_timeout_id
; /* IBDM specific */
103 ibdm_timeout_cb_args_t se_cb_args
;
104 } ibdm_srvents_info_t
;
106 /* values for "se_state" */
107 #define IBDM_SE_VALID 0x1
108 #define IBDM_SE_INVALID 0x0
111 /* I/O Controller information */
112 typedef struct ibdm_ioc_info_s
{
113 ib_dm_ioc_ctrl_profile_t ioc_profile
;
115 ibdm_srvents_info_t
*ioc_serv
;
116 struct ibdm_gid_s
*ioc_gid_list
;
117 uint_t ioc_nportgids
;
118 ib_guid_t ioc_iou_guid
;
119 timeout_id_t ioc_timeout_id
;
120 timeout_id_t ioc_dc_timeout_id
;
121 boolean_t ioc_dc_valid
;
122 boolean_t ioc_iou_dc_valid
;
123 ibdm_timeout_cb_args_t ioc_cb_args
;
124 ibdm_timeout_cb_args_t ioc_dc_cb_args
;
125 ib_guid_t ioc_nodeguid
;
126 uint16_t ioc_diagcode
;
127 uint16_t ioc_iou_diagcode
;
128 uint16_t ioc_diagdeviceid
;
129 struct ibdm_iou_info_s
*ioc_iou_info
;
130 struct ibdm_ioc_info_s
*ioc_next
;
132 /* Previous fields for reprobe */
133 ibdm_srvents_info_t
*ioc_prev_serv
;
134 struct ibdm_gid_s
*ioc_prev_gid_list
;
135 uint8_t ioc_prev_serv_cnt
;
136 uint_t ioc_prev_nportgids
;
138 /* Flag indicating which IOC info has changed */
139 ibt_prop_update_payload_t ioc_info_updated
;
142 * List of HCAs through which IOC is accessible
143 * This field will be initialized in ibdm_ibnex_probe_ioc
144 * and ibdm_get_ioc_list for all IOCs in the fabric.
146 * HCAs could have been added or deleted from the list,
147 * on calls to ibdm_ibnex_get_ioc_list & ibdm_ibnex_probe_ioc.
149 * Updates to HCAs in the list will be reported by
150 * IBDM_EVENT_HCA_DOWN and IBDM_EVENT_IOC_HCA_UNREACHABLE events
151 * in the IBDM<->IBDM callback.
153 * IOC not visible to the host system(because all HCAs cannot
154 * reach the IOC) will be reported in the same manner as TCA
155 * ports getting to 0 (using IOC_PROP_UPDATE event).
157 struct ibdm_hca_list_s
*ioc_hca_list
;
160 _NOTE(SCHEME_PROTECTS_DATA("Serialized access by cv",
161 ibdm_ioc_info_s::ioc_next
))
162 _NOTE(SCHEME_PROTECTS_DATA("Unique per copy of ibdm_ioc_info_t",
163 ibdm_ioc_info_s::ioc_info_updated
))
164 _NOTE(DATA_READABLE_WITHOUT_LOCK(ibdm_ioc_info_s::ioc_dc_valid
))
166 /* values for "ioc_state */
167 #define IBDM_IOC_STATE_PROBE_SUCCESS 0x0
168 #define IBDM_IOC_STATE_PROBE_INVALID 0x1
169 #define IBDM_IOC_STATE_PROBE_FAILED 0x2
170 #define IBDM_IOC_STATE_REPROBE_PROGRESS 0x4
172 /* I/O Unit Information */
173 typedef struct ibdm_iou_info_s
{
174 ib_dm_io_unitinfo_t iou_info
;
175 ibdm_ioc_info_t
*iou_ioc_info
;
177 boolean_t iou_dc_valid
;
178 uint16_t iou_diagcode
;
179 int iou_niocs_probe_in_progress
;
183 /* P_Key table related info */
184 typedef struct ibdm_pkey_tbl_s
{
185 ib_pkey_t pt_pkey
; /* P_Key value */
186 ibmf_qp_handle_t pt_qp_hdl
; /* QP handle */
188 _NOTE(SCHEME_PROTECTS_DATA("Serialized access by cv", ibdm_pkey_tbl_s
))
192 * Port Attributes structure
194 typedef struct ibdm_port_attr_s
{
195 ibdm_pkey_tbl_t
*pa_pkey_tbl
;
196 ib_guid_t pa_hca_guid
;
197 ib_guid_t pa_port_guid
;
199 ibmf_handle_t pa_ibmf_hdl
;
200 ib_sn_prefix_t pa_sn_prefix
;
201 uint16_t pa_port_num
;
202 uint32_t pa_vendorid
;
203 uint32_t pa_productid
;
204 uint32_t pa_dev_version
;
205 ibt_port_state_t pa_state
;
206 ibmf_saa_handle_t pa_sa_hdl
;
207 ibmf_impl_caps_t pa_ibmf_caps
;
208 ibt_hca_hdl_t pa_hca_hdl
;
210 _NOTE(SCHEME_PROTECTS_DATA("Serialized access by cv", ibdm_port_attr_s
))
213 * HCA list structure.
215 typedef struct ibdm_hca_list_s
{
216 ibdm_port_attr_t
*hl_port_attr
; /* port attributes */
217 struct ibdm_hca_list_s
*hl_next
; /* ptr to next list */
218 ib_guid_t hl_hca_guid
; /* HCA GUID */
219 uint32_t hl_nports
; /* #ports of this HCA */
220 uint32_t hl_nports_active
; /* #ports active */
221 hrtime_t hl_attach_time
; /* attach time */
222 ibt_hca_hdl_t hl_hca_hdl
; /* HCA handle */
223 ibdm_port_attr_t
*hl_hca_port_attr
; /* Dummy Port Attr */
226 _NOTE(SCHEME_PROTECTS_DATA("Serialized access by cv", ibdm_hca_list_s
))
229 * The DM callback definitions
232 * Pointer to DM callback function
233 * IBDM notifies IB nexus of ibdm_event_t using this callback.
235 * arg : The value of "arg" depends on the "event"
236 * IBDM_EVENT_CREATE_HCA_NODE (pointer to HCA GUID)
237 * IBDM_EVENT_REMOVE_HCA_NODE (pointer to HCA GUID)
238 * IBDM_EVENT_IOC_PROP_UPDATE (ibdm_ioc_info_t *)
240 * event : ibdm_event_t values
245 typedef void (*ibdm_callback_t
)(void *arg
, ibdm_events_t event
);
249 * DM interface functions
253 * ibdm_ibnex_register_callback
254 * Register the IB nexus IBDM callback routine
256 * Arguments : IB nexus IBDM callback routine
257 * Return Values : None
259 void ibdm_ibnex_register_callback(ibdm_callback_t cb
);
262 * ibdm_ibnex_unregister_callback
263 * Unregister IB nexus DM callback with IBDM
266 * Return Values : None
268 void ibdm_ibnex_unregister_callback();
272 * PORT devices handling interfaces.
274 * ibdm_ibnex_probe_hcaport
275 * Probes the HCA port. If found, returns the port attributes.
276 * Caller is responsible for freeing the memory for the port
277 * attribute structure by calling ibdm_ibnex_free_port_attr()
279 * Arguments : GUID of the HCA and port number
280 * Return Values : ibdm_port_attr_t on SUCCESS, NULL on FAILURE.
282 ibdm_port_attr_t
*ibdm_ibnex_probe_hcaport(ib_guid_t
, uint8_t);
285 * ibdm_ibnex_get_port_attrs
286 * Scans the HCA ports for a matching port_guid. If found,
287 * returns the port attributes.
288 * Caller is responsible for freeing the memory for the port
289 * attribute structure by calling ibdm_ibnex_free_port_attr()
291 * Arguments : GUID of the port
292 * Return Values : ibdm_port_attr_t on SUCCESS, NULL on FAILURE.
294 ibdm_port_attr_t
*ibdm_ibnex_get_port_attrs(ib_guid_t
);
297 * ibdm_ibnex_free_port_attr()
298 * Deallocates the memory from ibnex_get_dip_from_port_guid() and
299 * ibdm_ibnex_get_port_attrs() functions.
301 void ibdm_ibnex_free_port_attr(ibdm_port_attr_t
*);
305 * IOC devices handling interfaces.
307 * ibdm_ibnex_probe_ioc
308 * Probes the IOC device on the fabric. If found, allocates and
309 * returns pointer to the ibdm_ioc_info_t. Caller is responsible
310 * to free the memory for the ioc attribute structure by calling
311 * ibdm_ibnex_free_ioc_list.
314 * GUID of the IOU and GUID of the IOC
315 * reprobe_flag - Set if IOC information has to be reprobed.
316 * Return Values : ibdm_ioc_info_t on SUCCESS, NULL on FAILURE.
318 ibdm_ioc_info_t
*ibdm_ibnex_probe_ioc(ib_guid_t iou_guid
, ib_guid_t ioc_guid
,
322 * ibdm_ibnex_get_ioc_count
323 * Returns number of IOCs currently discovered in the fabric.
325 * Return Values : number of IOCs seen
327 int ibdm_ibnex_get_ioc_count(void);
330 * ibdm_ibnex_get_ioc_list
331 * Returns linked list of ibdm_ioc_info_t structures for all the
332 * IOCs present on the fabric. Caller is responsible for freeing
333 * the memory allocated for the ioc attribute structure(s) by
334 * calling ibdm_ibnex_free_ioc_list().
336 * Arguments : list_flag :
337 * Get list according to ibdm_ibnex_get_ioclist_mtd_t defination.
338 * Return Values : IOC list based containing "ibdm_ioc_info_t"s if
339 * successful, otherwise NULL.
341 ibdm_ioc_info_t
*ibdm_ibnex_get_ioc_list(ibdm_ibnex_get_ioclist_mtd_t
);
344 * ibdm_ibnex_get_ioc_info
345 * Returns pointer ibdm_ioc_info_t structures for the request
346 * "ioc_guid". Caller is responsible to free the memory by
347 * calling ibdm_ibnex_free_ioc_list() when the return value is
350 * Arguments : GUID of the IOC
351 * Return Values : Address of kmem_alloc'ed memory if the IOC exists,
354 ibdm_ioc_info_t
*ibdm_ibnex_get_ioc_info(ib_guid_t ioc_guid
);
357 * ibdm_ibnex_free_ioc_list()
358 * Deallocates the memory from ibdm_ibnex_probe_ioc(),
359 * ibdm_ibnex_get_ioc_list() and ibdm_ibnex_get_ioc_info()
361 void ibdm_ibnex_free_ioc_list(ibdm_ioc_info_t
*);
364 * HCA handling interfaces.
366 * ibdm_ibnex_get_hca_list
367 * Returns linked list of ibdm_hca_list_t structures for all
368 * the HCAs present on the fabric. Caller is responsible for
369 * freeing the memory for the hca attribute structure(s) by
370 * calling ibdm_ibnex_free_hca_list().
372 * Arguments : "hca" contains pointer to pointer of ibdm_hca_list_t
373 * : "cnt" contains pointer to number of hca's
374 * Return Values : None
376 void ibdm_ibnex_get_hca_list(ibdm_hca_list_t
**hca
, int *cnt
);
379 * ibdm_ibnex_get_hca_info_by_guid
380 * Returns a linked list of ibdm_hca_list_t structure that matches the
381 * given argument. The caller is responsible for freeing the memory for
382 * the hca attribute structure by calling ibdm_ibnex_free_hca_list().
384 * Arguments : HCA GUID
385 * Return Values : Linked list of ibdm_hca_list_t(s)
387 ibdm_hca_list_t
*ibdm_ibnex_get_hca_info_by_guid(ib_guid_t
);
390 * ibdm_ibnex_free_hca_list()
391 * Deallocates the memory from ibdm_ibnex_get_hca_list() and
392 * ibdm_ibnex_get_hca_info_by_guid() functions.
394 void ibdm_ibnex_free_hca_list(ibdm_hca_list_t
*);
397 * ibdm_ibnex_update_pkey_tbls
398 * Updates the DM P_Key database.
401 * Return Values : NONE
403 void ibdm_ibnex_update_pkey_tbls(void);
406 * ibdm_ibnex_port_settle_wait
407 * Wait until the ports come up
410 * HCA GUID and the maximum wait time since the hca instance attach
412 void ibdm_ibnex_port_settle_wait(ib_guid_t
, int);
419 #endif /* _SYS_IB_MGT_IBDM_IBDM_IBNEX_H */