Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_hba_fru.c
+++ new/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_hba_fru.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 2010 QLogic Corporation */
23 23
24 24 /*
25 25 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
26 26 */
27 27
28 28 #pragma ident "Copyright 2010 QLogic Corporation; ql_hba_fru.c"
29 29
30 30 /*
31 31 * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver source file.
32 32 *
33 33 * ***********************************************************************
34 34 * * **
35 35 * * NOTICE **
36 36 * * COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION **
37 37 * * ALL RIGHTS RESERVED **
38 38 * * **
39 39 * ***********************************************************************
40 40 *
41 41 */
42 42
43 43 /*
44 44 * Determine HBA FRU card information for T11 FC-HBA
45 45 */
46 46
47 47 #include <ql_apps.h>
48 48 #include <ql_api.h>
49 49 #include <ql_debug.h>
50 50 #include <ql_ioctl.h>
51 51 #include <ql_xioctl.h>
52 52
53 53 /*
54 54 * Temporary define until LV headers are updated
55 55 */
56 56 #ifndef FC_HBA_PORTSPEED_8GBIT
57 57 #define FC_HBA_PORTSPEED_8GBIT 16 /* 8 GBit/sec */
58 58 #endif
59 59
60 60 /* Local prototypes */
61 61 static uint32_t ql_get_basedev_len(ql_adapter_state_t *, uint32_t *,
62 62 uint32_t *);
63 63 static ql_adapter_state_t *ql_search_basedev(ql_adapter_state_t *, uint32_t);
64 64
65 65 /* Local structures */
66 66 static struct ql_known_models {
67 67 uint16_t ssid; /* Subsystem ID */
68 68 uint16_t ssvid; /* Subsystem Vendor ID */
69 69 char model[256];
70 70 char model_description[256];
71 71
72 72 } models[] = {
73 73 {
74 74 /* QLogic */
75 75 0x2, 0x1077, "QLA2200", "QLogic PCI to 1Gb FC, Single Channel"
76 76 }, {
77 77 /* QLogic */
78 78 0x9, 0x1077, "QLA2300", "QLogic PCI to 2Gb FC, Single Channel"
79 79 }, {
80 80 /* QLA2200, SUN2200 Amber */
81 81 0x4082, 0x1077, "375-3019-xx", "X6799A"
82 82 }, {
83 83 /* QLA2212, SUN2212 Crystal+ */
84 84 0x4083, 0x1077, "375-3030-xx", "X6727A"
85 85 }, {
86 86 /* QCP2202, SUNQCP2202 Diamond */
87 87 0x4084, 0x1077, "375-0118-xx", "X6748A"
88 88 }, {
89 89 /* QLA2202FS, SUN2202FS Ivory */
90 90 0x4085, 0x1077, "375-3048-xx", "X6757A"
91 91 }, {
92 92 /* QLogic */
93 93 0x100, 0x1077, "QLA2340",
94 94 "QLogic 133MHz PCI-X to 2Gb FC, Single Channel"
95 95 }, {
96 96 /* QLogic */
97 97 0x101, 0x1077, "QLA2342",
98 98 "QLogic 133MHz PCI-X to 2Gb FC, Dual Channel"
99 99 }, {
100 100 /* QLogic */
101 101 0x102, 0x1077, "QLA2344",
102 102 "QLogic 133MHz PCI-X to 2Gb FC, Quad Channel"
103 103 }, {
104 104 /* QLogic */
105 105 0x103, 0x1077, "QCP2342", "QLogic cPCI to 2Gb FC, Dual Channel"
106 106 }, {
107 107 /* QLogic */
108 108 0x104, 0x1077, "QSB2340", "QLogic SBUS to 2Gb FC, Single Channel"
109 109 }, {
110 110 /* QLogic */
111 111 0x105, 0x1077, "QSB2342", "QLogic SBUS to 2Gb FC, Dual Channel"
112 112 }, {
113 113 /* QLA2310, SUN-66MHz PCI-X to 2Gb FC, Single Channel, Amber 2 */
114 114 0x0106, 0x1077, "375-3102-xx", "SG-XPCI1FC-QF2 (X6767A)"
115 115 }, {
116 116 /* QLogic */
117 117 0x109, 0x1077, "QCP2340", "QLogic cPCI to 2Gb FC, Single Channel"
118 118 }, {
119 119 /* QLA2342, SUN-133MHz PCI-X to 2Gb FC, Dualchannel, Crystal 2A */
120 120 0x010A, 0x1077, "375-3108-xx", "SG-XPCI2FC-QF2 (X6768A)"
121 121 }, {
122 122 /* QLogic */
123 123 0x115, 0x1077, "QLA2360",
124 124 "QLogic 133MHz PCI-X to 2Gb FC, Single Channel"
125 125 }, {
126 126 /* QLogic */
127 127 0x116, 0x1077, "QLA2362",
128 128 "QLogic 133MHz PCI-X to 2Gb FC, Dual Channel"
129 129 }, {
130 130 /* QLogic */
131 131 0x117, 0x1077, "QLE2360",
132 132 "QLogic PCI-Express to 2Gb FC, Single Channel"
133 133 }, {
134 134 /* QLogic */
135 135 0x118, 0x1077, "QLE2362",
136 136 "QLogic PCI Express to 2Gb FC, Dual Channel"
137 137 }, {
138 138 /* QLogic */
139 139 0x119, 0x1077, "QLA200",
140 140 "QLogic 133MHz PCI-X to 2Gb FC, Single Channel"
141 141 }, {
142 142 /* QLogic */
143 143 0x11c, 0x1077, "QLA200P",
144 144 "QLogic 133MHz PCI-X to 2Gb FC, Single Channel"
145 145 }, {
146 146 /* QLogic */
147 147 0x12f, 0x1077, "QLA210",
148 148 "QLogic 133MHz PCI-X to 2Gb FC, Single Channel"
149 149 }, {
150 150 /* QLogic */
151 151 0x130, 0x1077, "EMC250-051-900",
152 152 "QLogic 133MHz PCI-X to 2Gb FC, Single Channel"
153 153 }, {
154 154 /* QLA210, SUN-133MHz PCI-X to 2Gb FC, Single Channel, Prism */
155 155 0x132, 0x1077, "375-32X3-01", "SG-PCI1FC-QLC"
156 156 }, {
157 157 /* QLogic */
158 158 0x13e, 0x1077, "QLE210",
159 159 "QLogic PCI Express 2Gb FC, Single Channel"
160 160 }, {
161 161 /* Sun */
162 162 0x149, 0x1077, "QLA2340",
163 163 "SUN - 133MHz PCI-X to 2Gb FC, Single Channel"
164 164 }, {
165 165 /* HP */
166 166 0x100, 0x0e11, "QLA2340-HP", "PCIX to 2Gb FC, Single Channel"
167 167 }, {
168 168 /* HP */
169 169 0x101, 0x0e11, "QLA2342-HP", "PCIX to 2Gb FC, Dual Channel"
170 170 }, {
171 171 /* HP */
172 172 0x103, 0x0e11, "QLA2312-HP",
173 173 "HP Bladed Server Balcony Card - HP BalcnL"
174 174 }, {
175 175 /* HP */
176 176 0x104, 0x0e11, "QLA2312-HP", "HP Bladed Server - HP MezzF"
177 177 }, {
178 178 /* HP */
179 179 0x105, 0x0e11, "QLA2312-HP", "HP Bladed Server - HP BalcnL"
180 180 }, {
181 181 /* HP */
182 182 0x106, 0x0e11, "QLA2312-HP", "HP Bladed Server - HP BalcnF"
183 183 }, {
184 184 /* HP */
185 185 0x107, 0x0e11, "QLA2312-HP", "HP Bladed Server"
186 186 }, {
187 187 /* HP */
188 188 0x108, 0x0e11, "QLA2312-HP", "HP Bladed Server"
189 189 }, {
190 190 /* IBM FCEC */
191 191 0x27d, 0x1014, "IBM-FCEC",
192 192 "IBM eServer Blade Center FC Expansion Card"
193 193 }, {
194 194 /* IBM FCEC */
195 195 0x2fb, 0x1014, "IBM-FCEC",
196 196 "IBM eServer Blade Center FC SFF Expansion Card"
197 197 }, {
198 198 /* Intel */
199 199 0x34ba, 0x8086, "Intel SBFCM",
200 200 "Intel Server FC Expansion Card SBFCM"
201 201 }, {
202 202 /* Intel */
203 203 0x34a0, 0x8086, "Intel SBEFCM",
↓ open down ↓ |
203 lines elided |
↑ open up ↑ |
204 204 "Intel Server SFF FC Expansion Card SBFCM"
205 205 }, {
206 206 /* FCI/O */
207 207 0x1051, 0x1734, "FCI/O-CARD2Gb/s",
208 208 "FSC-Quanta FC I/O-Card 2GBit/s"
209 209 }, {
210 210 /* Dell */
211 211 0x18a, 0x1028, "FCI/O-CARD2Gb/s", "Dell Glacier Blade Server"
212 212 }, {
213 213 /* end of list */
214 - 0, 0, 0, 0, 0, 0
214 + 0, 0, "", ""
215 215 } };
216 216
217 217 /*
218 218 * ql_populate_hba_fru_details
219 219 * Sets up HBA fru information for UL utilities
220 220 * (cfgadm, fcinfo, et. al.)
221 221 *
222 222 * Input:
223 223 * ha = adapter state structure
224 224 * port_info = ptr to LV port strcture.
225 225 *
226 226 * Returns:
227 227 *
228 228 * Context:
229 229 * Kernel context.
230 230 */
231 231 void
232 232 ql_populate_hba_fru_details(ql_adapter_state_t *ha,
233 233 fc_fca_port_info_t *port_info)
234 234 {
235 235 fca_port_attrs_t *attrs = &port_info->pi_attrs;
236 236 uint16_t chip = ha->device_id;
237 237 uint16_t model = ha->subsys_id;
238 238 uint16_t ssdevid = ha->subven_id;
239 239 size_t vlen;
240 240 int32_t i;
241 241
242 242 QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
243 243
244 244 attrs = &port_info->pi_attrs;
245 245
246 246 /* Constants */
247 247 (void) snprintf(attrs->manufacturer, FCHBA_MANUFACTURER_LEN,
248 248 "QLogic Corp.");
249 249 (void) snprintf(attrs->driver_name, FCHBA_DRIVER_NAME_LEN,
250 250 "%s", QL_NAME);
251 251 (void) snprintf(attrs->driver_version, FCHBA_DRIVER_VERSION_LEN,
252 252 "%s", ha->adapter_stats->revlvl.qlddv);
253 253
254 254 if ((i = ql_vpd_lookup(ha, (uint8_t *)VPD_TAG_SN, (uint8_t *)
255 255 attrs->serial_number, FCHBA_SERIAL_NUMBER_LEN)) == -1) {
256 256 attrs->serial_number[0] = '\0';
257 257 }
258 258 attrs->hardware_version[0] = '\0';
259 259
260 260 /* Dynamic data */
261 261 (void) snprintf(attrs->firmware_version, FCHBA_FIRMWARE_VERSION_LEN,
262 262 "%02d.%02d.%02d", ha->fw_major_version, ha->fw_minor_version,
263 263 ha->fw_subminor_version);
264 264
265 265 CACHE_LOCK(ha);
266 266
267 267 /* Report FCode / BIOS / EFI version(s). */
268 268 if (ha->fcache != NULL) {
269 269 uint32_t types = FTYPE_BIOS|FTYPE_FCODE|FTYPE_EFI;
270 270 ql_fcache_t *fptr = ha->fcache;
271 271 int8_t *orv = &*attrs->option_rom_version;
272 272
273 273 while ((fptr != NULL) && (types != 0)) {
274 274 /* Get the next image */
275 275 if ((fptr = ql_get_fbuf(ha->fcache, types)) != NULL) {
276 276
277 277 switch (fptr->type) {
278 278 case FTYPE_FCODE:
279 279 (void) snprintf(orv,
280 280 FCHBA_OPTION_ROM_VERSION_LEN,
281 281 "%s fcode: %s;", orv, fptr->verstr);
282 282 break;
283 283 case FTYPE_BIOS:
284 284 (void) snprintf(orv,
285 285 FCHBA_OPTION_ROM_VERSION_LEN,
286 286 "%s BIOS: %s;", orv, fptr->verstr);
287 287 break;
288 288 case FTYPE_EFI:
289 289 (void) snprintf(orv,
290 290 FCHBA_OPTION_ROM_VERSION_LEN,
291 291 "%s EFI: %s;", orv, fptr->verstr);
292 292 break;
293 293 default:
294 294 EL(ha, "ignoring ftype: %xh\n",
295 295 fptr->type);
296 296 break;
297 297 }
298 298 types &= ~(fptr->type);
299 299 }
300 300 }
301 301 }
302 302
303 303 CACHE_UNLOCK(ha);
304 304
305 305 if (strlen(attrs->option_rom_version) == 0) {
306 306 int rval = -1;
307 307 uint32_t i = 0;
308 308 caddr_t fcode_ver_buf = NULL;
309 309
310 310 if (CFG_IST(ha, CFG_CTRL_2200)) {
311 311 /*LINTED [Solaris DDI_DEV_T_ANY Lint warning]*/
312 312 rval = ddi_getlongprop(DDI_DEV_T_ANY, ha->dip,
313 313 DDI_PROP_DONTPASS | DDI_PROP_CANSLEEP, "version",
314 314 (caddr_t)&fcode_ver_buf, (int32_t *)&i);
315 315 }
316 316
317 317 (void) snprintf(attrs->option_rom_version,
318 318 FCHBA_OPTION_ROM_VERSION_LEN, "%s",
319 319 (rval == DDI_PROP_SUCCESS ? fcode_ver_buf :
320 320 "No boot image detected"));
321 321
322 322 if (fcode_ver_buf != NULL) {
323 323 kmem_free(fcode_ver_buf, (size_t)i);
324 324 }
325 325
326 326 }
327 327
328 328 attrs->vendor_specific_id = ha->adapter_features;
329 329 attrs->max_frame_size = CFG_IST(ha, CFG_CTRL_24258081) ?
330 330 (ha->init_ctrl_blk.cb24.max_frame_length[1] << 8 |
331 331 ha->init_ctrl_blk.cb24.max_frame_length[0]) :
332 332 (ha->init_ctrl_blk.cb.max_frame_length[1] << 8 |
333 333 ha->init_ctrl_blk.cb.max_frame_length[0]);
334 334 attrs->supported_cos = 0x10000000; /* Class 3 only */
335 335
336 336 switch (chip & 0xFF00) {
337 337 case 0x2200:
338 338 attrs->supported_speed = FC_HBA_PORTSPEED_1GBIT;
339 339 break;
340 340 case 0x2300:
341 341 attrs->supported_speed = FC_HBA_PORTSPEED_2GBIT |
342 342 FC_HBA_PORTSPEED_1GBIT;
343 343 break;
344 344 case 0x2400:
345 345 case 0x8400:
346 346 attrs->supported_speed = FC_HBA_PORTSPEED_4GBIT |
347 347 FC_HBA_PORTSPEED_2GBIT | FC_HBA_PORTSPEED_1GBIT;
348 348 break;
349 349 case 0x8000:
350 350 attrs->supported_speed = FC_HBA_PORTSPEED_10GBIT;
351 351 break;
352 352 case 0x2500:
353 353 attrs->supported_speed = FC_HBA_PORTSPEED_8GBIT |
354 354 FC_HBA_PORTSPEED_4GBIT | FC_HBA_PORTSPEED_2GBIT |
355 355 FC_HBA_PORTSPEED_1GBIT;
356 356
357 357 /*
358 358 * Correct supported speeds based on type of
359 359 * sfp that is present
360 360 */
361 361 switch (ha->sfp_stat) {
362 362 case 2:
363 363 case 4:
364 364 /* 4GB sfp */
365 365 attrs->supported_speed &= ~FC_HBA_PORTSPEED_8GBIT;
366 366 break;
367 367 case 3:
368 368 case 5:
369 369 /* 8GB sfp */
370 370 attrs->supported_speed &= ~FC_HBA_PORTSPEED_1GBIT;
371 371 break;
372 372 default:
373 373 EL(ha, "sfp_stat: %xh\n", ha->sfp_stat);
374 374 break;
375 375
376 376 }
377 377
378 378 break;
379 379 case 0x5400:
380 380 if (model == 0x13e) {
381 381 /* QLE210 */
382 382 attrs->supported_speed = FC_HBA_PORTSPEED_2GBIT;
383 383 } else {
384 384 attrs->supported_speed = FC_HBA_PORTSPEED_4GBIT;
385 385 }
386 386 break;
387 387 case 0x6300:
388 388 attrs->supported_speed = FC_HBA_PORTSPEED_2GBIT;
389 389 break;
390 390 default:
391 391 attrs->supported_speed = FC_HBA_PORTSPEED_UNKNOWN;
392 392 break;
393 393 }
394 394
395 395 /* Use parent dip as adapter identifier */
396 396 attrs->hba_fru_details.low = 0x514C6F6769630000; /* QLogic */
397 397
398 398 if (ha->fru_hba_index == 0) {
399 399 EL(ha, "unable to generate high_fru details from "
400 400 "device path: %s\n", ha->devpath);
401 401 attrs->hba_fru_details.low = 0;
402 402 attrs->hba_fru_details.high = 0;
403 403 attrs->hba_fru_details.port_index = 0;
404 404 } else {
405 405 attrs->hba_fru_details.high = ha->fru_hba_index;
406 406 attrs->hba_fru_details.port_index = ha->fru_port_index;
407 407 }
408 408
409 409 /*
410 410 * Populate the model info. Legacy (22xx, 23xx, 63xx) do not
411 411 * have vpd info, so use the hard coded table. Anything else
412 412 * has VPD (or is suppose to have VPD), so use that. For both
413 413 * cases, if the model isn't found, use defaults.
414 414 */
415 415
416 416 switch (chip & 0xFF00) {
417 417 case 0x2200:
418 418 case 0x2300:
419 419 case 0x6300:
420 420 /* Table based data */
421 421 for (i = 0; models[i].ssid; i++) {
422 422 if ((model == models[i].ssid) &&
423 423 (ssdevid == models[i].ssvid)) {
424 424 break;
425 425 }
426 426 }
427 427
428 428 if (models[i].ssid) {
429 429 (void) snprintf(attrs->model, FCHBA_MODEL_LEN, "%s",
430 430 models[i].model);
431 431 (void) snprintf(attrs->model_description,
432 432 FCHBA_MODEL_DESCRIPTION_LEN, "%s",
433 433 models[i].model_description);
434 434 } else {
435 435 (void) snprintf(attrs->model, FCHBA_MODEL_LEN,
436 436 "%x", chip);
437 437 (void) snprintf(attrs->model_description,
438 438 FCHBA_MODEL_DESCRIPTION_LEN, "%x", chip);
439 439 }
440 440
441 441 /* Special model handling for RoHS version of the HBA */
442 442 if (models[i].ssid == 0x10a && ha->adapInfo[10] ==
443 443 (uint8_t)0x36) {
444 444 (void) snprintf(attrs->model, FCHBA_MODEL_LEN, "%s",
445 445 "375-3363-xx");
446 446 (void) snprintf(attrs->model_description,
447 447 FCHBA_MODEL_DESCRIPTION_LEN, "%s",
448 448 "SG-XPCI2FC-QF2-Z");
449 449 }
450 450 break;
451 451
452 452 case 0x2400:
453 453 case 0x2500:
454 454 case 0x5400:
455 455 case 0x8400:
456 456 case 0x8000:
457 457 default:
458 458 if ((i = ql_vpd_lookup(ha, (uint8_t *)VPD_TAG_PN,
459 459 (uint8_t *)attrs->model, FCHBA_MODEL_LEN)) >= 0) {
460 460 (void) ql_vpd_lookup(ha, (uint8_t *)VPD_TAG_PRODID,
461 461 (uint8_t *)attrs->model_description,
462 462 FCHBA_MODEL_DESCRIPTION_LEN);
463 463 } else {
464 464 (void) snprintf(attrs->model, FCHBA_MODEL_LEN,
465 465 "%x", chip);
466 466 (void) snprintf(attrs->model_description,
467 467 FCHBA_MODEL_DESCRIPTION_LEN, "%x", chip);
468 468 }
469 469 break;
470 470 }
471 471
472 472 /*
473 473 * Populate the LV symbolic node and port name strings
474 474 *
475 475 * Symbolic node name format is:
476 476 * <hostname>
477 477 *
478 478 * Symbolic port name format is:
479 479 * <driver_name>(<instance>,<vp index>)
480 480 */
481 481 vlen = (strlen(utsname.nodename) > FCHBA_SYMB_NAME_LEN ?
482 482 FCHBA_SYMB_NAME_LEN : strlen(utsname.nodename));
483 483 (void) snprintf((int8_t *)attrs->sym_node_name, vlen, "%s",
484 484 utsname.nodename);
485 485
486 486 vlen = (strlen(QL_NAME) + 9 > FCHBA_SYMB_NAME_LEN ?
487 487 FCHBA_SYMB_NAME_LEN : strlen(QL_NAME) + 9);
488 488 (void) snprintf((int8_t *)attrs->sym_port_name, vlen,
489 489 "%s(%d,%d)", QL_NAME, ha->instance, ha->vp_index);
490 490
491 491 QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
492 492 }
493 493
494 494 /*
495 495 * ql_setup_fruinfo
496 496 * Generates common id's for instances on the same
497 497 * physical HBA.
498 498 *
499 499 * Input:
500 500 * ha = adapter state structure
501 501 *
502 502 * Returns:
503 503 *
504 504 * Context:
505 505 * Kernel context.
506 506 */
507 507 void
508 508 ql_setup_fruinfo(ql_adapter_state_t *ha)
509 509 {
510 510 uint32_t mybasedev_len;
511 511 ql_adapter_state_t *base_ha = NULL;
512 512
513 513 QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
514 514
515 515 /*
516 516 * To generate common id for instances residing on the
517 517 * the same HBA, the devpath for each instance is parsed
518 518 * and those instances which have matching base devpaths are
519 519 * given same hba_index, and each port on the same hba are
520 520 * then assigned unique port_indexs based on the devpath.
521 521 */
522 522
523 523 /*
524 524 * Get this ha's basedev path and its port index
525 525 */
526 526 if (ql_get_basedev_len(ha, &mybasedev_len, &ha->fru_port_index) == 0) {
527 527
528 528 GLOBAL_STATE_LOCK();
529 529
530 530 /*
531 531 * Search for this basedev against all of the
532 532 * ha in the ql_hba global list. If found one
533 533 * then we are part of other adapter in the
534 534 * ql_hba list and hence use that ha's hba_index.
535 535 * If not create a new one from the global hba index.
536 536 */
537 537 base_ha = ql_search_basedev(ha, mybasedev_len);
538 538 if (base_ha != NULL && base_ha->fru_hba_index != 0) {
539 539 ha->fru_hba_index = base_ha->fru_hba_index;
540 540 } else {
541 541 ha->fru_hba_index = ql_gfru_hba_index++;
542 542 }
543 543
544 544 if (CFG_IST(ha, CFG_CTRL_8081)) {
545 545 /*
546 546 * The FC functions on 81xx hbas are functions 2 and 3
547 547 * while the Nic functions occupy 0 and 1. Adjust
548 548 * fru port index to be like previous FCAs.
549 549 */
550 550 ha->fru_port_index = ha->flags & FUNCTION_1 ? 1 : 0;
551 551 }
552 552
553 553 GLOBAL_STATE_UNLOCK();
554 554
555 555 } else {
556 556 ha->fru_hba_index = 0;
557 557 ha->fru_port_index = 0;
558 558 }
559 559
560 560 QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
561 561 }
562 562
563 563 /*
564 564 * ql_get_basedev_len
565 565 *
566 566 * Gets the length of the base device name in the
567 567 * devpath of the current instance.
568 568 *
569 569 * Input:
570 570 * ha - adapter state pointer.
571 571 * basedev_len - pointer to the integer which
572 572 * holds the calculated length.
573 573 * port_index - pointer to the integer which
574 574 * contains the port index of
575 575 * for this device.
576 576 * Returns:
577 577 * 0 if successfully parsed, -1 otherwise.
578 578 *
579 579 * Context:
580 580 * Kernel context.
581 581 */
582 582 static uint32_t
583 583 ql_get_basedev_len(ql_adapter_state_t *ha, uint32_t *basedev_len,
584 584 uint32_t *port_index)
585 585 {
586 586 int32_t dev_off;
587 587 int32_t port_off;
588 588 int8_t *devstr;
589 589
590 590 QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
591 591
592 592 if (ha->devpath == NULL) {
593 593 return ((uint32_t)-1);
594 594 }
595 595
596 596 dev_off = (int32_t)(strlen(ha->devpath) - 1);
597 597 port_off = -1;
598 598
599 599 /* Until we reach the first char or a '@' char in the path */
600 600 while ((dev_off >= 0) && (ha->devpath[dev_off] != '@')) {
601 601
602 602 if (ha->devpath[dev_off] == ',') {
603 603 port_off = dev_off + 1;
604 604 }
605 605
606 606 dev_off--;
607 607 }
608 608
609 609 if (dev_off < 0) {
610 610 EL(ha, "Invalid device path '%s'. Cannot get basedev\n",
611 611 ha->devpath);
612 612 return ((uint32_t)-1);
613 613 }
614 614
615 615 if (port_off == -1) {
616 616 *port_index = 0;
617 617 *basedev_len = (uint32_t)strlen(ha->devpath);
618 618 } else {
619 619 /* Get the port index */
620 620 devstr = ha->devpath + port_off;
621 621 *port_index = stoi(&devstr);
622 622 if (*port_index == 0) {
623 623 EL(ha, "Invalid device path '%s'. Cannot get "
624 624 "port_index\n", ha->devpath);
625 625 return ((uint32_t)-1);
626 626 }
627 627
628 628 *basedev_len = (uint32_t)(port_off - 1);
629 629 }
630 630
631 631 QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
632 632
633 633 return (0);
634 634 }
635 635
636 636 /*
637 637 * ql_search_basedev
638 638 * Searches the list of ha instances to find which
639 639 * ha instance has same base device path as input's.
640 640 *
641 641 * Input:
642 642 * myha = current adapter state pointer.
643 643 * mybasedev_len = Length of the base device in the
644 644 * device path name.
645 645 *
646 646 * Returns:
647 647 * If match = ptr to matching ha structure.
648 648 * If no match = NULL ptr.
649 649 *
650 650 * Context:
651 651 * Kernel context.
652 652 */
653 653 static ql_adapter_state_t *
654 654 ql_search_basedev(ql_adapter_state_t *myha, uint32_t mybasedev_len)
655 655 {
656 656 ql_link_t *link;
657 657 ql_adapter_state_t *ha;
658 658 uint32_t basedev_len, port_index;
659 659
660 660 QL_PRINT_3(CE_CONT, "(%d): started\n", myha->instance);
661 661
662 662 for (link = ql_hba.first; link != NULL; link = link->next) {
663 663
664 664 ha = link->base_address;
665 665
666 666 if (ha == NULL) {
667 667 EL(myha, "null ha link detected!\n");
668 668 return (NULL);
669 669 }
670 670
671 671 if (ha == myha) {
672 672 continue;
673 673 }
674 674
675 675 if (ql_get_basedev_len(ha, &basedev_len, &port_index) != 0) {
676 676 if (ha->devpath == NULL) {
677 677 EL(myha, "Device path NULL. Unable to get "
678 678 "the basedev\n");
679 679 } else {
680 680 EL(myha, "Invalid device path '%s'. Cannot "
681 681 "get the hba index and port index\n",
682 682 ha->devpath);
683 683 }
684 684 continue;
685 685 }
686 686
687 687 /*
688 688 * If both the basedev len do not match, then it
689 689 * is obvious that both are not pointing to the
690 690 * same base device.
691 691 */
692 692 if ((basedev_len == mybasedev_len) && (strncmp(myha->devpath,
693 693 ha->devpath, basedev_len) == 0)) {
694 694
695 695 /* We found the ha with same basedev */
696 696 QL_PRINT_3(CE_CONT, "(%d): found, done\n",
697 697 myha->instance);
698 698 return (ha);
699 699 }
700 700 }
701 701
702 702 QL_PRINT_3(CE_CONT, "(%d): not found, done\n", myha->instance);
703 703
704 704 return (NULL);
705 705 }
↓ open down ↓ |
481 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX