2 * Copyright (c) 2005 SilverStorm Technologies. All rights reserved.
\r
3 * Portions Copyright (c) 2008 Microsoft Corporation. All rights reserved.
\r
5 * This software is available to you under the OpenIB.org BSD license
\r
8 * Redistribution and use in source and binary forms, with or
\r
9 * without modification, are permitted provided that the following
\r
10 * conditions are met:
\r
12 * - Redistributions of source code must retain the above
\r
13 * copyright notice, this list of conditions and the following
\r
16 * - Redistributions in binary form must reproduce the above
\r
17 * copyright notice, this list of conditions and the following
\r
18 * disclaimer in the documentation and/or other materials
\r
19 * provided with the distribution.
\r
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
35 #if !defined _BUS_DRIVER_H_
\r
36 #define _BUS_DRIVER_H_
\r
38 #include "complib/cl_types.h"
\r
39 #include "complib/cl_atomic.h"
\r
40 #include "complib/cl_debug.h"
\r
41 #include "complib/cl_mutex.h"
\r
42 #include "complib/cl_qlist.h"
\r
43 #include "complib/cl_ptr_vector.h"
\r
44 #include "complib/cl_pnp_po.h"
\r
45 #include "iba/ib_al.h"
\r
46 #include "bus_port_mgr.h"
\r
47 #include "bus_iou_mgr.h"
\r
49 /* Safe string functions. */
\r
52 * Windows 2000 doesn't support the inline version of safe strings.
\r
53 * Force the use of the library version of safe strings.
\r
55 #define NTSTRSAFE_LIB
\r
57 #include <ntstrsafe.h>
\r
61 * Main header for IB Bus driver.
\r
64 #define BUS_ENTER( lvl ) \
\r
65 CL_ENTER( lvl, bus_globals.dbg_lvl )
\r
67 #define BUS_EXIT( lvl ) \
\r
68 CL_EXIT( lvl, bus_globals.dbg_lvl )
\r
70 #define BUS_TRACE( lvl, msg ) \
\r
71 CL_TRACE( lvl, bus_globals.dbg_lvl, msg )
\r
73 #define BUS_TRACE_EXIT( lvl, msg ) \
\r
74 CL_TRACE_EXIT( lvl, bus_globals.dbg_lvl, msg )
\r
76 #define BUS_PRINT( lvl, msg ) \
\r
77 CL_PRINT( lvl, bus_globals.dbl_lvl, msg )
\r
79 #define BUS_DBG_ERROR CL_DBG_ERROR
\r
80 #define BUS_DBG_DRV (1 << 0)
\r
81 #define BUS_DBG_PNP (1 << 1)
\r
82 #define BUS_DBG_POWER (1 << 2)
\r
83 #define BUS_DBG_PORT (1 << 3)
\r
84 #define BUS_DBG_IOU (1 << 4)
\r
87 * ALLOC_PRAGMA sections:
\r
89 * Default pagable code. Won't be locked in memory.
\r
92 * Code that needs to be locked in memory when the device is
\r
93 * in the paging, crash dump, or hibernation path.
\r
98 * Device extension for the device object that serves as entry point for
\r
99 * the interface and IOCTL requests.
\r
101 typedef struct _bus_fdo_ext
\r
103 cl_pnp_po_ext_t cl_ext;
\r
106 * Device power map returned by the bus driver for the device, used
\r
107 * when sending IRP_MN_SET_POWER for device state in response to
\r
108 * IRP_MN_SET_POWER for system state.
\r
110 DEVICE_POWER_STATE po_state[PowerSystemMaximum];
\r
112 port_mgr_t *p_port_mgr;
\r
113 iou_mgr_t *p_iou_mgr;
\r
115 /* Interface names are generated by IoRegisterDeviceInterface. */
\r
116 UNICODE_STRING al_ifc_name;
\r
117 UNICODE_STRING ci_ifc_name;
\r
119 /* Number of references on the upper interface. */
\r
120 atomic32_t n_al_ifc_ref;
\r
121 /* Number of references on the CI interface. */
\r
122 atomic32_t n_ci_ifc_ref;
\r
128 * Device extension for bus driver PDOs.
\r
130 typedef struct _bus_pdo_ext
\r
132 cl_pnp_po_ext_t cl_ext;
\r
134 cl_list_item_t list_item;
\r
136 /* All reported PDOs are children of an HCA. */
\r
137 ib_ca_handle_t h_ca;
\r
140 * CA GUID copy - in case we get IRPs after the CA
\r
141 * handle has been released.
\r
145 POWER_STATE dev_po_state;
\r
148 * Pointer to the bus root device extension. Used to manage access to
\r
149 * child PDO pointer vector when a child is removed politely.
\r
151 bus_fdo_ext_t *p_parent_ext;
\r
154 * The following two flags are exclusively set, but can both be FALSE.
\r
155 * Flag that indicates whether the device is present in the system or not.
\r
156 * This affects how a IRP_MN_REMOVE_DEVICE IRP is handled for a child PDO.
\r
157 * This flag is cleared when:
\r
158 * - an HCA (for IPoIB devices) is removed from the system for all port
\r
159 * devices loaded for that HCA
\r
160 * - an IOU is reported as removed by the CIA.
\r
162 boolean_t b_present;
\r
165 * Flag that indicates whether the device has been reported to the PnP
\r
166 * manager as having been removed. That is, the device was reported
\r
167 * in a previous BusRelations query and not in a subsequent one.
\r
168 * This flag is set when
\r
169 * - the device is in the surprise remove state when the parent bus
\r
170 * device is removed
\r
171 * - the device is found to be not present during a BusRelations query
\r
172 * and thus not reported.
\r
174 boolean_t b_reported_missing;
\r
176 /* Flag to control the behaviour of the driver during hibernation */
\r
177 uint32_t b_hibernating;
\r
179 /* work item for handling Power Management request */
\r
180 PIO_WORKITEM p_po_work_item;
\r
186 * Global Driver parameters.
\r
188 typedef struct _bus_globals
\r
193 /* Flag to control loading of Ip Over Ib driver for each HCA port. */
\r
194 uint32_t b_report_port_nic;
\r
196 /* Driver object. Used for registering of Plug and Play notifications. */
\r
197 DRIVER_OBJECT *p_driver_obj;
\r
199 /* Pointer to the one and only bus root. */
\r
200 bus_fdo_ext_t *p_bus_ext;
\r
205 extern bus_globals_t bus_globals;
\r
208 #endif /* !defined _BUS_DRIVER_H_ */
\r