Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/ib/clients/rdsv3/rdsv3_ddi.c
+++ new/usr/src/uts/common/io/ib/clients/rdsv3/rdsv3_ddi.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24 #include <sys/types.h>
25 25 #include <sys/stat.h>
26 26 #include <sys/conf.h>
27 27 #include <sys/ddi.h>
28 28 #include <sys/sunddi.h>
29 29 #include <sys/modctl.h>
30 30 #include <sys/strsubr.h>
31 31 #include <sys/socketvar.h>
32 32 #include <sys/rds.h>
33 33
34 34 #include <sys/ib/ibtl/ibti.h>
35 35 #include <sys/ib/clients/rdsv3/rdsv3.h>
36 36 #include <sys/ib/clients/rdsv3/rdsv3_debug.h>
37 37 #include <sys/ib/clients/rdsv3/rdsv3_af_thr.h>
38 38
39 39 extern int rdsv3_init(void);
40 40 extern void rdsv3_exit(void);
41 41 extern void rdsv3_cong_init(void);
42 42 extern void rdsv3_cong_exit(void);
43 43 extern void rdsv3_trans_init(void);
44 44 extern void rdsv3_trans_exit(void);
45 45 extern int rdsv3_sock_init(void);
46 46 extern void rdsv3_sock_exit(void);
47 47
48 48 /* global */
49 49 dev_info_t *rdsv3_dev_info = NULL;
50 50 kmem_cache_t *rdsv3_alloc_cache = NULL;
51 51
52 52 extern kmutex_t rdsv3_rdma_listen_id_lock;
53 53 extern struct rdma_cm_id *rdsv3_rdma_listen_id;
54 54
55 55 extern kmutex_t rdsv3_sock_lock;
56 56 extern list_t rdsv3_sock_list;
57 57
58 58 extern void rdsv3_bind_init();
59 59 extern void rdsv3_bind_exit();
60 60
61 61 int
62 62 rdsv3_sock_init()
63 63 {
64 64 RDSV3_DPRINTF4("rdsv3_sock_init", "Enter");
65 65
66 66 rdsv3_alloc_cache = kmem_cache_create("rdsv3_alloc_cache",
67 67 sizeof (struct rsock) + sizeof (struct rdsv3_sock), 0, NULL,
68 68 NULL, NULL, NULL, NULL, 0);
69 69 if (rdsv3_alloc_cache == NULL) {
70 70 RDSV3_DPRINTF2("rdsv3_alloc_cache",
71 71 "kmem_cache_create(rdsv3_alloc_cache) failed");
72 72 return (-1);
73 73 }
74 74 rdsv3_bind_init();
75 75
76 76 mutex_init(&rdsv3_sock_lock, NULL, MUTEX_DRIVER, NULL);
77 77 list_create(&rdsv3_sock_list, sizeof (struct rdsv3_sock),
78 78 offsetof(struct rdsv3_sock, rs_item));
79 79
80 80 RDSV3_DPRINTF4("rdsv3_sock_init", "Return");
81 81
82 82 return (0);
83 83 }
84 84
85 85 void
86 86 rdsv3_sock_exit()
87 87 {
88 88 RDSV3_DPRINTF2("rdsv3_sock_exit", "Enter");
89 89
90 90 rdsv3_bind_exit();
91 91
92 92 kmem_cache_destroy(rdsv3_alloc_cache);
93 93
94 94 list_destroy(&rdsv3_sock_list);
95 95 mutex_destroy(&rdsv3_sock_lock);
96 96
97 97 RDSV3_DPRINTF2("rdsv3_sock_exit", "Return");
98 98 }
99 99
100 100 static int
101 101 rdsv3_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
102 102 {
103 103 int ret;
104 104
105 105 RDSV3_DPRINTF2("rdsv3_attach", "Enter (dip: %p)", dip);
106 106
107 107 if (cmd != DDI_ATTACH)
108 108 return (DDI_FAILURE);
109 109
110 110 if (rdsv3_dev_info != NULL) {
111 111 RDSV3_DPRINTF2("rdsv3_attach", "Multiple RDS instances are"
112 112 " not supported (rdsv3_dev_info: 0x%p)", rdsv3_dev_info);
113 113 return (DDI_FAILURE);
114 114 }
115 115 rdsv3_dev_info = dip;
116 116
117 117 mutex_init(&rdsv3_rdma_listen_id_lock, NULL, MUTEX_DRIVER, NULL);
118 118 rdsv3_rdma_listen_id = NULL;
119 119
120 120 rdsv3_af_init(dip);
121 121 rdsv3_trans_init();
122 122 ret = rdsv3_init();
123 123 if (ret) {
124 124 RDSV3_DPRINTF2("rdsv3_attach", "rdsv3_init failed: %d", ret);
125 125 rdsv3_trans_exit();
126 126 mutex_destroy(&rdsv3_rdma_listen_id_lock);
127 127 rdsv3_dev_info = NULL;
128 128 return (DDI_FAILURE);
129 129 }
130 130
131 131 ret = rdsv3_sock_init();
132 132 if (ret) {
133 133 rdsv3_exit();
134 134 rdsv3_trans_exit();
135 135 mutex_destroy(&rdsv3_rdma_listen_id_lock);
136 136 rdsv3_dev_info = NULL;
137 137 return (DDI_FAILURE);
138 138 }
139 139
140 140 ret = ddi_create_minor_node(dip, "rdsv3", S_IFCHR, 0, DDI_PSEUDO, 0);
141 141 if (ret != DDI_SUCCESS) {
142 142 cmn_err(CE_CONT, "ddi_create_minor_node failed: %d", ret);
143 143 rdsv3_sock_exit();
144 144 rdsv3_exit();
145 145 rdsv3_trans_exit();
146 146 mutex_destroy(&rdsv3_rdma_listen_id_lock);
147 147 rdsv3_dev_info = NULL;
148 148 return (DDI_FAILURE);
149 149 }
150 150
151 151 RDSV3_DPRINTF2("rdsv3_attach", "Return");
152 152
153 153 return (DDI_SUCCESS);
154 154 }
155 155
156 156 static int
157 157 rdsv3_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
158 158 {
159 159 RDSV3_DPRINTF2("rdsv3_detach", "Enter (dip: %p)", dip);
160 160
161 161 if (cmd != DDI_DETACH)
162 162 return (DDI_FAILURE);
163 163
164 164 rdsv3_sock_exit();
165 165 rdsv3_exit();
166 166 rdsv3_trans_exit();
167 167 ddi_remove_minor_node(dip, "rdsv3");
168 168 rdsv3_dev_info = NULL;
169 169
170 170 RDSV3_DPRINTF2("rdsv3_detach", "Return");
171 171
172 172 return (DDI_SUCCESS);
173 173 }
174 174
175 175 /* ARGSUSED */
176 176 static int
177 177 rdsv3_info(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
178 178 {
179 179 int ret = DDI_FAILURE;
180 180
181 181 RDSV3_DPRINTF2("rdsv3_info", "Enter (dip: %p, cmd: %d)", dip, cmd);
182 182
183 183 switch (cmd) {
184 184 case DDI_INFO_DEVT2DEVINFO:
185 185 if (rdsv3_dev_info != NULL) {
186 186 *result = (void *)rdsv3_dev_info;
187 187 ret = DDI_SUCCESS;
188 188 }
189 189 break;
190 190
191 191 case DDI_INFO_DEVT2INSTANCE:
192 192 *result = NULL;
193 193 ret = DDI_SUCCESS;
194 194 break;
195 195
196 196 default:
197 197 break;
198 198 }
199 199
200 200 RDSV3_DPRINTF4("rdsv3_info", "Return");
201 201
202 202 return (ret);
203 203 }
204 204
205 205 /* Driver entry points */
206 206 static struct cb_ops rdsv3_cb_ops = {
207 207 nulldev, /* open */
208 208 nulldev, /* close */
209 209 nodev, /* strategy */
210 210 nodev, /* print */
211 211 nodev, /* dump */
212 212 nodev, /* read */
213 213 nodev, /* write */
214 214 nodev, /* ioctl */
215 215 nodev, /* devmap */
216 216 nodev, /* mmap */
217 217 nodev, /* segmap */
218 218 nochpoll, /* poll */
219 219 ddi_prop_op, /* prop_op */
220 220 NULL, /* stream */
221 221 D_MP, /* cb_flag */
222 222 CB_REV, /* rev */
223 223 nodev, /* int (*cb_aread)() */
224 224 nodev, /* int (*cb_awrite)() */
225 225 };
226 226
227 227 /* Device options */
228 228 static struct dev_ops rdsv3_ops = {
229 229 DEVO_REV, /* devo_rev, */
230 230 0, /* refcnt */
231 231 rdsv3_info, /* info */
232 232 nulldev, /* identify */
233 233 nulldev, /* probe */
234 234 rdsv3_attach, /* attach */
235 235 rdsv3_detach, /* detach */
236 236 nodev, /* reset */
237 237 &rdsv3_cb_ops, /* driver ops - devctl interfaces */
238 238 NULL, /* bus operations */
239 239 NULL, /* power */
240 240 ddi_quiesce_not_needed /* quiesce */
241 241 };
242 242
243 243 /*
244 244 * Module linkage information.
↓ open down ↓ |
244 lines elided |
↑ open up ↑ |
245 245 */
246 246 #define RDSV3_DEVDESC "RDSv3 IB transport driver"
247 247 static struct modldrv rdsv3_modldrv = {
248 248 &mod_driverops, /* Driver module */
249 249 RDSV3_DEVDESC, /* Driver name and version */
250 250 &rdsv3_ops, /* Driver ops */
251 251 };
252 252
253 253 static struct modlinkage rdsv3_modlinkage = {
254 254 MODREV_1,
255 - (void *)&rdsv3_modldrv,
256 - NULL
255 + { (void *)&rdsv3_modldrv, NULL }
257 256 };
258 257
259 258 int
260 259 _init(void)
261 260 {
262 261 int ret;
263 262
264 263 if (ibt_hw_is_present() == 0) {
265 264 return (ENODEV);
266 265 }
267 266
268 267 /* Initialize logging */
269 268 rdsv3_logging_initialization();
270 269
271 270 ret = mod_install(&rdsv3_modlinkage);
272 271 if (ret != 0) {
273 272 /*
274 273 * Could not load module
275 274 */
276 275 rdsv3_logging_destroy();
277 276 return (ret);
278 277 }
279 278
280 279 return (0);
281 280 }
282 281
283 282 int
284 283 _fini()
285 284 {
286 285 int ret;
287 286
288 287 /*
289 288 * Remove module
290 289 */
291 290 if ((ret = mod_remove(&rdsv3_modlinkage)) != 0) {
292 291 return (ret);
293 292 }
294 293
295 294 /* Stop logging */
296 295 rdsv3_logging_destroy();
297 296
298 297 return (0);
299 298 }
300 299
301 300 int
302 301 _info(struct modinfo *modinfop)
303 302 {
304 303 return (mod_info(&rdsv3_modlinkage, modinfop));
305 304 }
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX