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/rds/rdsib.c
+++ new/usr/src/uts/common/io/ib/clients/rds/rdsib.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 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26
27 27 #include <sys/types.h>
28 28 #include <sys/stat.h>
29 29 #include <sys/conf.h>
30 30 #include <sys/ddi.h>
31 31 #include <sys/sunddi.h>
32 32 #include <sys/modctl.h>
33 33 #include <inet/ip.h>
34 34 #include <sys/ib/clients/rds/rdsib_ib.h>
35 35 #include <sys/ib/clients/rds/rdsib_buf.h>
36 36 #include <sys/ib/clients/rds/rdsib_cm.h>
37 37 #include <sys/ib/clients/rds/rdsib_protocol.h>
38 38 #include <sys/ib/clients/rds/rds_transport.h>
39 39 #include <sys/ib/clients/rds/rds_kstat.h>
40 40
41 41 /*
42 42 * Global Configuration Variables
43 43 * As defined in RDS proposal
44 44 */
45 45 uint_t MaxNodes = RDS_MAX_NODES;
46 46 uint_t RdsPktSize;
47 47 uint_t NDataRX;
48 48 uint_t MaxDataSendBuffers = RDS_MAX_DATA_SEND_BUFFERS;
49 49 uint_t MaxDataRecvBuffers = RDS_MAX_DATA_RECV_BUFFERS;
50 50 uint_t MaxCtrlSendBuffers = RDS_MAX_CTRL_SEND_BUFFERS;
51 51 uint_t MaxCtrlRecvBuffers = RDS_MAX_CTRL_RECV_BUFFERS;
52 52 uint_t DataRecvBufferLWM = RDS_DATA_RECV_BUFFER_LWM;
53 53 uint_t CtrlRecvBufferLWM = RDS_CTRL_RECV_BUFFER_LWM;
54 54 uint_t PendingRxPktsHWM = RDS_PENDING_RX_PKTS_HWM;
55 55 uint_t MinRnrRetry = RDS_IB_RNR_RETRY;
56 56 uint8_t IBPathRetryCount = RDS_IB_PATH_RETRY;
57 57 uint8_t IBPktLifeTime = RDS_IB_PKT_LT;
58 58
59 59 extern int rdsib_open_ib();
60 60 extern void rdsib_close_ib();
61 61 extern void rds_resume_port(in_port_t port);
62 62 extern int rds_sendmsg(uio_t *uiop, ipaddr_t sendip, ipaddr_t recvip,
63 63 in_port_t sendport, in_port_t recvport, zoneid_t zoneid);
64 64 extern boolean_t rds_if_lookup_by_name(char *devname);
65 65
66 66 rds_transport_ops_t rds_ib_transport_ops = {
67 67 rdsib_open_ib,
68 68 rdsib_close_ib,
69 69 rds_sendmsg,
70 70 rds_resume_port,
71 71 rds_if_lookup_by_name
72 72 };
73 73
74 74 /* global */
75 75 rds_state_t *rdsib_statep = NULL;
76 76 krwlock_t rds_loopback_portmap_lock;
77 77 uint8_t rds_loopback_portmap[RDS_PORT_MAP_SIZE];
78 78 ddi_taskq_t *rds_taskq = NULL;
79 79 dev_info_t *rdsib_dev_info = NULL;
80 80 uint_t rds_rx_pkts_pending_hwm;
81 81
82 82 #ifdef DEBUG
83 83 uint32_t rdsdbglvl = RDS_LOG_L3;
84 84 #else
85 85 uint32_t rdsdbglvl = RDS_LOG_L2;
86 86 #endif
87 87
88 88 #define RDS_NUM_TASKQ_THREADS 4
89 89
90 90 static int rdsib_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
91 91 static int rdsib_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
92 92 static int rdsib_info(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg,
93 93 void **result);
94 94 static void rds_read_config_values(dev_info_t *dip);
95 95
96 96 /* Driver entry points */
97 97 static struct cb_ops rdsib_cb_ops = {
98 98 nulldev, /* open */
99 99 nulldev, /* close */
100 100 nodev, /* strategy */
101 101 nodev, /* print */
102 102 nodev, /* dump */
103 103 nodev, /* read */
104 104 nodev, /* write */
105 105 nodev, /* ioctl */
106 106 nodev, /* devmap */
107 107 nodev, /* mmap */
108 108 nodev, /* segmap */
109 109 nochpoll, /* poll */
110 110 ddi_prop_op, /* prop_op */
111 111 NULL, /* stream */
112 112 D_MP, /* cb_flag */
113 113 CB_REV, /* rev */
114 114 nodev, /* int (*cb_aread)() */
115 115 nodev, /* int (*cb_awrite)() */
116 116 };
117 117
118 118 /* Device options */
119 119 static struct dev_ops rdsib_ops = {
120 120 DEVO_REV, /* devo_rev, */
121 121 0, /* refcnt */
122 122 rdsib_info, /* info */
123 123 nulldev, /* identify */
124 124 nulldev, /* probe */
125 125 rdsib_attach, /* attach */
126 126 rdsib_detach, /* detach */
127 127 nodev, /* reset */
128 128 &rdsib_cb_ops, /* driver ops - devctl interfaces */
129 129 NULL, /* bus operations */
130 130 NULL, /* power */
131 131 ddi_quiesce_not_needed, /* devo_quiesce */
132 132 };
133 133
134 134 /*
135 135 * Module linkage information.
↓ open down ↓ |
135 lines elided |
↑ open up ↑ |
136 136 */
137 137 #define RDS_DEVDESC "RDS IB driver"
138 138 static struct modldrv rdsib_modldrv = {
139 139 &mod_driverops, /* Driver module */
140 140 RDS_DEVDESC, /* Driver name and version */
141 141 &rdsib_ops, /* Driver ops */
142 142 };
143 143
144 144 static struct modlinkage rdsib_modlinkage = {
145 145 MODREV_1,
146 - (void *)&rdsib_modldrv,
147 - NULL
146 + { (void *)&rdsib_modldrv, NULL }
148 147 };
149 148
150 149 /* Called from _init */
151 150 int
152 151 rdsib_init()
153 152 {
154 153 /* RDS supports only one instance */
155 154 rdsib_statep = kmem_zalloc(sizeof (rds_state_t), KM_SLEEP);
156 155
157 156 rw_init(&rdsib_statep->rds_sessionlock, NULL, RW_DRIVER, NULL);
158 157 rw_init(&rdsib_statep->rds_hca_lock, NULL, RW_DRIVER, NULL);
159 158
160 159 rw_init(&rds_loopback_portmap_lock, NULL, RW_DRIVER, NULL);
161 160 bzero(rds_loopback_portmap, RDS_PORT_MAP_SIZE);
162 161
163 162 mutex_init(&rds_dpool.pool_lock, NULL, MUTEX_DRIVER, NULL);
164 163 cv_init(&rds_dpool.pool_cv, NULL, CV_DRIVER, NULL);
165 164 mutex_init(&rds_cpool.pool_lock, NULL, MUTEX_DRIVER, NULL);
166 165 cv_init(&rds_cpool.pool_cv, NULL, CV_DRIVER, NULL);
167 166
168 167 /* Initialize logging */
169 168 rds_logging_initialization();
170 169
171 170 RDS_SET_NPORT(1); /* this should never be 0 */
172 171
173 172 ASSERT(rds_transport_ops == NULL);
174 173 rds_transport_ops = &rds_ib_transport_ops;
175 174
176 175 return (0);
177 176 }
178 177
179 178 /* Called from _fini */
180 179 void
181 180 rdsib_fini()
182 181 {
183 182 /* Stop logging */
184 183 rds_logging_destroy();
185 184
186 185 cv_destroy(&rds_dpool.pool_cv);
187 186 mutex_destroy(&rds_dpool.pool_lock);
188 187 cv_destroy(&rds_cpool.pool_cv);
189 188 mutex_destroy(&rds_cpool.pool_lock);
190 189
191 190 rw_destroy(&rds_loopback_portmap_lock);
192 191
193 192 rw_destroy(&rdsib_statep->rds_hca_lock);
194 193 rw_destroy(&rdsib_statep->rds_sessionlock);
195 194 kmem_free(rdsib_statep, sizeof (rds_state_t));
196 195
197 196 rds_transport_ops = NULL;
198 197 }
199 198
200 199 int
201 200 _init(void)
202 201 {
203 202 int ret;
204 203
205 204 if (ibt_hw_is_present() == 0) {
206 205 return (ENODEV);
207 206 }
208 207
209 208 ret = rdsib_init();
210 209 if (ret != 0) {
211 210 return (ret);
212 211 }
213 212
214 213 ret = mod_install(&rdsib_modlinkage);
215 214 if (ret != 0) {
216 215 /*
217 216 * Could not load module
218 217 */
219 218 rdsib_fini();
220 219 return (ret);
221 220 }
222 221
223 222 return (0);
224 223 }
225 224
226 225 int
227 226 _fini()
228 227 {
229 228 int ret;
230 229
231 230 /*
232 231 * Remove module
233 232 */
234 233 if ((ret = mod_remove(&rdsib_modlinkage)) != 0) {
235 234 return (ret);
236 235 }
237 236
238 237 rdsib_fini();
239 238
240 239 return (0);
241 240 }
242 241
243 242 int
244 243 _info(struct modinfo *modinfop)
245 244 {
246 245 return (mod_info(&rdsib_modlinkage, modinfop));
247 246 }
248 247
249 248 static int
250 249 rdsib_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
251 250 {
252 251 int ret;
253 252
254 253 RDS_DPRINTF2("rdsib_attach", "enter");
255 254
256 255 if (cmd != DDI_ATTACH)
257 256 return (DDI_FAILURE);
258 257
259 258 if (rdsib_dev_info != NULL) {
260 259 RDS_DPRINTF1("rdsib_attach", "Multiple RDS instances are"
261 260 " not supported (rds_dev_info: 0x%p)", rdsib_dev_info);
262 261 return (DDI_FAILURE);
263 262 }
264 263
265 264 rdsib_dev_info = dip;
266 265 rds_read_config_values(dip);
267 266
268 267 rds_taskq = ddi_taskq_create(dip, "rds_taskq", RDS_NUM_TASKQ_THREADS,
269 268 TASKQ_DEFAULTPRI, 0);
270 269 if (rds_taskq == NULL) {
271 270 RDS_DPRINTF1("rdsib_attach",
272 271 "ddi_taskq_create failed for rds_taskq");
273 272 rdsib_dev_info = NULL;
274 273 return (DDI_FAILURE);
275 274 }
276 275
277 276 ret = ddi_create_minor_node(dip, "rdsib", S_IFCHR, 0, DDI_PSEUDO, 0);
278 277 if (ret != DDI_SUCCESS) {
279 278 RDS_DPRINTF1("rdsib_attach",
280 279 "ddi_create_minor_node failed: %d", ret);
281 280 ddi_taskq_destroy(rds_taskq);
282 281 rds_taskq = NULL;
283 282 rdsib_dev_info = NULL;
284 283 return (DDI_FAILURE);
285 284 }
286 285
287 286 /* Max number of receive buffers on the system */
288 287 NDataRX = (MaxNodes - 1) * MaxDataRecvBuffers * 2;
289 288
290 289 /*
291 290 * High water mark for the receive buffers in the system. If the
292 291 * number of buffers used crosses this mark then all sockets in
293 292 * would be stalled. The port quota for the sockets is set based
294 293 * on this limit.
295 294 */
296 295 rds_rx_pkts_pending_hwm = (PendingRxPktsHWM * NDataRX)/100;
297 296
298 297 ret = rdsib_initialize_ib();
299 298 if (ret != 0) {
300 299 RDS_DPRINTF1("rdsib_attach",
301 300 "rdsib_initialize_ib failed: %d", ret);
302 301 ddi_taskq_destroy(rds_taskq);
303 302 rds_taskq = NULL;
304 303 rdsib_dev_info = NULL;
305 304 return (DDI_FAILURE);
306 305 }
307 306
308 307 RDS_DPRINTF2("rdsib_attach", "return");
309 308
310 309 return (DDI_SUCCESS);
311 310 }
312 311
313 312 static int
314 313 rdsib_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
315 314 {
316 315 RDS_DPRINTF2("rdsib_detach", "enter");
317 316
318 317 if (cmd != DDI_DETACH)
319 318 return (DDI_FAILURE);
320 319
321 320 rdsib_deinitialize_ib();
322 321
323 322 ddi_remove_minor_node(dip, "rdsib");
324 323
325 324 /* destroy taskq */
326 325 if (rds_taskq != NULL) {
327 326 ddi_taskq_destroy(rds_taskq);
328 327 rds_taskq = NULL;
329 328 }
330 329
331 330 rdsib_dev_info = NULL;
332 331
333 332 RDS_DPRINTF2("rdsib_detach", "return");
334 333
335 334 return (DDI_SUCCESS);
336 335 }
337 336
338 337 /* ARGSUSED */
339 338 static int
340 339 rdsib_info(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
341 340 {
342 341 int ret = DDI_FAILURE;
343 342
344 343 switch (cmd) {
345 344 case DDI_INFO_DEVT2DEVINFO:
346 345 if (rdsib_dev_info != NULL) {
347 346 *result = (void *)rdsib_dev_info;
348 347 ret = DDI_SUCCESS;
349 348 }
350 349 break;
351 350
352 351 case DDI_INFO_DEVT2INSTANCE:
353 352 *result = NULL;
354 353 ret = DDI_SUCCESS;
355 354 break;
356 355
357 356 default:
358 357 break;
359 358 }
360 359
361 360 return (ret);
362 361 }
363 362
364 363 static void
365 364 rds_read_config_values(dev_info_t *dip)
366 365 {
367 366 MaxNodes = ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
368 367 "MaxNodes", RDS_MAX_NODES);
369 368
370 369 UserBufferSize = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
371 370 DDI_PROP_DONTPASS, "UserBufferSize", RDS_USER_DATA_BUFFER_SIZE);
372 371
373 372 MaxDataSendBuffers = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
374 373 DDI_PROP_DONTPASS, "MaxDataSendBuffers", RDS_MAX_DATA_SEND_BUFFERS);
375 374
376 375 MaxDataRecvBuffers = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
377 376 DDI_PROP_DONTPASS, "MaxDataRecvBuffers", RDS_MAX_DATA_RECV_BUFFERS);
378 377
379 378 MaxCtrlSendBuffers = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
380 379 DDI_PROP_DONTPASS, "MaxCtrlSendBuffers", RDS_MAX_CTRL_SEND_BUFFERS);
381 380
382 381 MaxCtrlRecvBuffers = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
383 382 DDI_PROP_DONTPASS, "MaxCtrlRecvBuffers", RDS_MAX_CTRL_RECV_BUFFERS);
384 383
385 384 DataRecvBufferLWM = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
386 385 DDI_PROP_DONTPASS, "DataRecvBufferLWM", RDS_DATA_RECV_BUFFER_LWM);
387 386
388 387 CtrlRecvBufferLWM = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
389 388 DDI_PROP_DONTPASS, "CtrlRecvBufferLWM", RDS_CTRL_RECV_BUFFER_LWM);
390 389
391 390 PendingRxPktsHWM = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
392 391 DDI_PROP_DONTPASS, "PendingRxPktsHWM", RDS_PENDING_RX_PKTS_HWM);
393 392
394 393 MinRnrRetry = ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
395 394 "MinRnrRetry", RDS_IB_RNR_RETRY);
396 395
397 396 IBPathRetryCount = (uint8_t)ddi_prop_get_int(DDI_DEV_T_ANY, dip,
398 397 DDI_PROP_DONTPASS, "IBPathRetryCount", RDS_IB_PATH_RETRY);
399 398
400 399 IBPktLifeTime = (uint8_t)ddi_prop_get_int(DDI_DEV_T_ANY, dip,
401 400 DDI_PROP_DONTPASS, "IBPktLifeTime", RDS_IB_PKT_LT);
402 401
403 402 rdsdbglvl = ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
404 403 "rdsdbglvl", RDS_LOG_L2);
405 404
406 405 if (MaxNodes < 2) {
407 406 cmn_err(CE_WARN, "MaxNodes is set to less than 2");
408 407 MaxNodes = 2;
409 408 }
410 409 }
↓ open down ↓ |
253 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX