diff options
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_attr.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_attr.c | 200 |
1 files changed, 136 insertions, 64 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 0f2a9f5d801c..05fa7796a559 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c | |||
@@ -18,7 +18,7 @@ qla2x00_sysfs_read_fw_dump(struct kobject *kobj, | |||
18 | struct bin_attribute *bin_attr, | 18 | struct bin_attribute *bin_attr, |
19 | char *buf, loff_t off, size_t count) | 19 | char *buf, loff_t off, size_t count) |
20 | { | 20 | { |
21 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 21 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
22 | struct device, kobj))); | 22 | struct device, kobj))); |
23 | char *rbuf = (char *)ha->fw_dump; | 23 | char *rbuf = (char *)ha->fw_dump; |
24 | 24 | ||
@@ -39,7 +39,7 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj, | |||
39 | struct bin_attribute *bin_attr, | 39 | struct bin_attribute *bin_attr, |
40 | char *buf, loff_t off, size_t count) | 40 | char *buf, loff_t off, size_t count) |
41 | { | 41 | { |
42 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 42 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
43 | struct device, kobj))); | 43 | struct device, kobj))); |
44 | int reading; | 44 | int reading; |
45 | 45 | ||
@@ -89,7 +89,7 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj, | |||
89 | struct bin_attribute *bin_attr, | 89 | struct bin_attribute *bin_attr, |
90 | char *buf, loff_t off, size_t count) | 90 | char *buf, loff_t off, size_t count) |
91 | { | 91 | { |
92 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 92 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
93 | struct device, kobj))); | 93 | struct device, kobj))); |
94 | int size = ha->nvram_size; | 94 | int size = ha->nvram_size; |
95 | char *nvram_cache = ha->nvram; | 95 | char *nvram_cache = ha->nvram; |
@@ -112,7 +112,7 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, | |||
112 | struct bin_attribute *bin_attr, | 112 | struct bin_attribute *bin_attr, |
113 | char *buf, loff_t off, size_t count) | 113 | char *buf, loff_t off, size_t count) |
114 | { | 114 | { |
115 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 115 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
116 | struct device, kobj))); | 116 | struct device, kobj))); |
117 | unsigned long flags; | 117 | unsigned long flags; |
118 | uint16_t cnt; | 118 | uint16_t cnt; |
@@ -146,7 +146,7 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, | |||
146 | /* Write NVRAM. */ | 146 | /* Write NVRAM. */ |
147 | spin_lock_irqsave(&ha->hardware_lock, flags); | 147 | spin_lock_irqsave(&ha->hardware_lock, flags); |
148 | ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); | 148 | ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); |
149 | ha->isp_ops->read_nvram(ha, (uint8_t *)&ha->nvram, ha->nvram_base, | 149 | ha->isp_ops->read_nvram(ha, (uint8_t *)ha->nvram, ha->nvram_base, |
150 | count); | 150 | count); |
151 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 151 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
152 | 152 | ||
@@ -170,15 +170,15 @@ qla2x00_sysfs_read_optrom(struct kobject *kobj, | |||
170 | struct bin_attribute *bin_attr, | 170 | struct bin_attribute *bin_attr, |
171 | char *buf, loff_t off, size_t count) | 171 | char *buf, loff_t off, size_t count) |
172 | { | 172 | { |
173 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 173 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
174 | struct device, kobj))); | 174 | struct device, kobj))); |
175 | 175 | ||
176 | if (ha->optrom_state != QLA_SREADING) | 176 | if (ha->optrom_state != QLA_SREADING) |
177 | return 0; | 177 | return 0; |
178 | if (off > ha->optrom_size) | 178 | if (off > ha->optrom_region_size) |
179 | return 0; | 179 | return 0; |
180 | if (off + count > ha->optrom_size) | 180 | if (off + count > ha->optrom_region_size) |
181 | count = ha->optrom_size - off; | 181 | count = ha->optrom_region_size - off; |
182 | 182 | ||
183 | memcpy(buf, &ha->optrom_buffer[off], count); | 183 | memcpy(buf, &ha->optrom_buffer[off], count); |
184 | 184 | ||
@@ -190,15 +190,15 @@ qla2x00_sysfs_write_optrom(struct kobject *kobj, | |||
190 | struct bin_attribute *bin_attr, | 190 | struct bin_attribute *bin_attr, |
191 | char *buf, loff_t off, size_t count) | 191 | char *buf, loff_t off, size_t count) |
192 | { | 192 | { |
193 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 193 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
194 | struct device, kobj))); | 194 | struct device, kobj))); |
195 | 195 | ||
196 | if (ha->optrom_state != QLA_SWRITING) | 196 | if (ha->optrom_state != QLA_SWRITING) |
197 | return -EINVAL; | 197 | return -EINVAL; |
198 | if (off > ha->optrom_size) | 198 | if (off > ha->optrom_region_size) |
199 | return -ERANGE; | 199 | return -ERANGE; |
200 | if (off + count > ha->optrom_size) | 200 | if (off + count > ha->optrom_region_size) |
201 | count = ha->optrom_size - off; | 201 | count = ha->optrom_region_size - off; |
202 | 202 | ||
203 | memcpy(&ha->optrom_buffer[off], buf, count); | 203 | memcpy(&ha->optrom_buffer[off], buf, count); |
204 | 204 | ||
@@ -220,14 +220,18 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj, | |||
220 | struct bin_attribute *bin_attr, | 220 | struct bin_attribute *bin_attr, |
221 | char *buf, loff_t off, size_t count) | 221 | char *buf, loff_t off, size_t count) |
222 | { | 222 | { |
223 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 223 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
224 | struct device, kobj))); | 224 | struct device, kobj))); |
225 | int val; | 225 | uint32_t start = 0; |
226 | uint32_t size = ha->optrom_size; | ||
227 | int val, valid; | ||
226 | 228 | ||
227 | if (off) | 229 | if (off) |
228 | return 0; | 230 | return 0; |
229 | 231 | ||
230 | if (sscanf(buf, "%d", &val) != 1) | 232 | if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1) |
233 | return -EINVAL; | ||
234 | if (start > ha->optrom_size) | ||
231 | return -EINVAL; | 235 | return -EINVAL; |
232 | 236 | ||
233 | switch (val) { | 237 | switch (val) { |
@@ -237,6 +241,11 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj, | |||
237 | break; | 241 | break; |
238 | 242 | ||
239 | ha->optrom_state = QLA_SWAITING; | 243 | ha->optrom_state = QLA_SWAITING; |
244 | |||
245 | DEBUG2(qla_printk(KERN_INFO, ha, | ||
246 | "Freeing flash region allocation -- 0x%x bytes.\n", | ||
247 | ha->optrom_region_size)); | ||
248 | |||
240 | vfree(ha->optrom_buffer); | 249 | vfree(ha->optrom_buffer); |
241 | ha->optrom_buffer = NULL; | 250 | ha->optrom_buffer = NULL; |
242 | break; | 251 | break; |
@@ -244,44 +253,107 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj, | |||
244 | if (ha->optrom_state != QLA_SWAITING) | 253 | if (ha->optrom_state != QLA_SWAITING) |
245 | break; | 254 | break; |
246 | 255 | ||
256 | if (start & 0xfff) { | ||
257 | qla_printk(KERN_WARNING, ha, | ||
258 | "Invalid start region 0x%x/0x%x.\n", start, size); | ||
259 | return -EINVAL; | ||
260 | } | ||
261 | |||
262 | ha->optrom_region_start = start; | ||
263 | ha->optrom_region_size = start + size > ha->optrom_size ? | ||
264 | ha->optrom_size - start : size; | ||
265 | |||
247 | ha->optrom_state = QLA_SREADING; | 266 | ha->optrom_state = QLA_SREADING; |
248 | ha->optrom_buffer = (uint8_t *)vmalloc(ha->optrom_size); | 267 | ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
249 | if (ha->optrom_buffer == NULL) { | 268 | if (ha->optrom_buffer == NULL) { |
250 | qla_printk(KERN_WARNING, ha, | 269 | qla_printk(KERN_WARNING, ha, |
251 | "Unable to allocate memory for optrom retrieval " | 270 | "Unable to allocate memory for optrom retrieval " |
252 | "(%x).\n", ha->optrom_size); | 271 | "(%x).\n", ha->optrom_region_size); |
253 | 272 | ||
254 | ha->optrom_state = QLA_SWAITING; | 273 | ha->optrom_state = QLA_SWAITING; |
255 | return count; | 274 | return count; |
256 | } | 275 | } |
257 | 276 | ||
258 | memset(ha->optrom_buffer, 0, ha->optrom_size); | 277 | DEBUG2(qla_printk(KERN_INFO, ha, |
259 | ha->isp_ops->read_optrom(ha, ha->optrom_buffer, 0, | 278 | "Reading flash region -- 0x%x/0x%x.\n", |
260 | ha->optrom_size); | 279 | ha->optrom_region_start, ha->optrom_region_size)); |
280 | |||
281 | memset(ha->optrom_buffer, 0, ha->optrom_region_size); | ||
282 | ha->isp_ops->read_optrom(ha, ha->optrom_buffer, | ||
283 | ha->optrom_region_start, ha->optrom_region_size); | ||
261 | break; | 284 | break; |
262 | case 2: | 285 | case 2: |
263 | if (ha->optrom_state != QLA_SWAITING) | 286 | if (ha->optrom_state != QLA_SWAITING) |
264 | break; | 287 | break; |
265 | 288 | ||
289 | /* | ||
290 | * We need to be more restrictive on which FLASH regions are | ||
291 | * allowed to be updated via user-space. Regions accessible | ||
292 | * via this method include: | ||
293 | * | ||
294 | * ISP21xx/ISP22xx/ISP23xx type boards: | ||
295 | * | ||
296 | * 0x000000 -> 0x020000 -- Boot code. | ||
297 | * | ||
298 | * ISP2322/ISP24xx type boards: | ||
299 | * | ||
300 | * 0x000000 -> 0x07ffff -- Boot code. | ||
301 | * 0x080000 -> 0x0fffff -- Firmware. | ||
302 | * | ||
303 | * ISP25xx type boards: | ||
304 | * | ||
305 | * 0x000000 -> 0x07ffff -- Boot code. | ||
306 | * 0x080000 -> 0x0fffff -- Firmware. | ||
307 | * 0x120000 -> 0x12ffff -- VPD and HBA parameters. | ||
308 | */ | ||
309 | valid = 0; | ||
310 | if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0) | ||
311 | valid = 1; | ||
312 | else if (start == (FA_BOOT_CODE_ADDR*4) || | ||
313 | start == (FA_RISC_CODE_ADDR*4)) | ||
314 | valid = 1; | ||
315 | else if (IS_QLA25XX(ha) && start == (FA_VPD_NVRAM_ADDR*4)) | ||
316 | valid = 1; | ||
317 | if (!valid) { | ||
318 | qla_printk(KERN_WARNING, ha, | ||
319 | "Invalid start region 0x%x/0x%x.\n", start, size); | ||
320 | return -EINVAL; | ||
321 | } | ||
322 | |||
323 | ha->optrom_region_start = start; | ||
324 | ha->optrom_region_size = start + size > ha->optrom_size ? | ||
325 | ha->optrom_size - start : size; | ||
326 | |||
266 | ha->optrom_state = QLA_SWRITING; | 327 | ha->optrom_state = QLA_SWRITING; |
267 | ha->optrom_buffer = (uint8_t *)vmalloc(ha->optrom_size); | 328 | ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
268 | if (ha->optrom_buffer == NULL) { | 329 | if (ha->optrom_buffer == NULL) { |
269 | qla_printk(KERN_WARNING, ha, | 330 | qla_printk(KERN_WARNING, ha, |
270 | "Unable to allocate memory for optrom update " | 331 | "Unable to allocate memory for optrom update " |
271 | "(%x).\n", ha->optrom_size); | 332 | "(%x).\n", ha->optrom_region_size); |
272 | 333 | ||
273 | ha->optrom_state = QLA_SWAITING; | 334 | ha->optrom_state = QLA_SWAITING; |
274 | return count; | 335 | return count; |
275 | } | 336 | } |
276 | memset(ha->optrom_buffer, 0, ha->optrom_size); | 337 | |
338 | DEBUG2(qla_printk(KERN_INFO, ha, | ||
339 | "Staging flash region write -- 0x%x/0x%x.\n", | ||
340 | ha->optrom_region_start, ha->optrom_region_size)); | ||
341 | |||
342 | memset(ha->optrom_buffer, 0, ha->optrom_region_size); | ||
277 | break; | 343 | break; |
278 | case 3: | 344 | case 3: |
279 | if (ha->optrom_state != QLA_SWRITING) | 345 | if (ha->optrom_state != QLA_SWRITING) |
280 | break; | 346 | break; |
281 | 347 | ||
282 | ha->isp_ops->write_optrom(ha, ha->optrom_buffer, 0, | 348 | DEBUG2(qla_printk(KERN_INFO, ha, |
283 | ha->optrom_size); | 349 | "Writing flash region -- 0x%x/0x%x.\n", |
350 | ha->optrom_region_start, ha->optrom_region_size)); | ||
351 | |||
352 | ha->isp_ops->write_optrom(ha, ha->optrom_buffer, | ||
353 | ha->optrom_region_start, ha->optrom_region_size); | ||
284 | break; | 354 | break; |
355 | default: | ||
356 | count = -EINVAL; | ||
285 | } | 357 | } |
286 | return count; | 358 | return count; |
287 | } | 359 | } |
@@ -300,7 +372,7 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj, | |||
300 | struct bin_attribute *bin_attr, | 372 | struct bin_attribute *bin_attr, |
301 | char *buf, loff_t off, size_t count) | 373 | char *buf, loff_t off, size_t count) |
302 | { | 374 | { |
303 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 375 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
304 | struct device, kobj))); | 376 | struct device, kobj))); |
305 | int size = ha->vpd_size; | 377 | int size = ha->vpd_size; |
306 | char *vpd_cache = ha->vpd; | 378 | char *vpd_cache = ha->vpd; |
@@ -323,7 +395,7 @@ qla2x00_sysfs_write_vpd(struct kobject *kobj, | |||
323 | struct bin_attribute *bin_attr, | 395 | struct bin_attribute *bin_attr, |
324 | char *buf, loff_t off, size_t count) | 396 | char *buf, loff_t off, size_t count) |
325 | { | 397 | { |
326 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 398 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
327 | struct device, kobj))); | 399 | struct device, kobj))); |
328 | unsigned long flags; | 400 | unsigned long flags; |
329 | 401 | ||
@@ -354,7 +426,7 @@ qla2x00_sysfs_read_sfp(struct kobject *kobj, | |||
354 | struct bin_attribute *bin_attr, | 426 | struct bin_attribute *bin_attr, |
355 | char *buf, loff_t off, size_t count) | 427 | char *buf, loff_t off, size_t count) |
356 | { | 428 | { |
357 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 429 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
358 | struct device, kobj))); | 430 | struct device, kobj))); |
359 | uint16_t iter, addr, offset; | 431 | uint16_t iter, addr, offset; |
360 | int rval; | 432 | int rval; |
@@ -459,7 +531,7 @@ qla2x00_drvr_version_show(struct class_device *cdev, char *buf) | |||
459 | static ssize_t | 531 | static ssize_t |
460 | qla2x00_fw_version_show(struct class_device *cdev, char *buf) | 532 | qla2x00_fw_version_show(struct class_device *cdev, char *buf) |
461 | { | 533 | { |
462 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 534 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
463 | char fw_str[30]; | 535 | char fw_str[30]; |
464 | 536 | ||
465 | return snprintf(buf, PAGE_SIZE, "%s\n", | 537 | return snprintf(buf, PAGE_SIZE, "%s\n", |
@@ -469,7 +541,7 @@ qla2x00_fw_version_show(struct class_device *cdev, char *buf) | |||
469 | static ssize_t | 541 | static ssize_t |
470 | qla2x00_serial_num_show(struct class_device *cdev, char *buf) | 542 | qla2x00_serial_num_show(struct class_device *cdev, char *buf) |
471 | { | 543 | { |
472 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 544 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
473 | uint32_t sn; | 545 | uint32_t sn; |
474 | 546 | ||
475 | sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; | 547 | sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; |
@@ -480,14 +552,14 @@ qla2x00_serial_num_show(struct class_device *cdev, char *buf) | |||
480 | static ssize_t | 552 | static ssize_t |
481 | qla2x00_isp_name_show(struct class_device *cdev, char *buf) | 553 | qla2x00_isp_name_show(struct class_device *cdev, char *buf) |
482 | { | 554 | { |
483 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 555 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
484 | return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device); | 556 | return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device); |
485 | } | 557 | } |
486 | 558 | ||
487 | static ssize_t | 559 | static ssize_t |
488 | qla2x00_isp_id_show(struct class_device *cdev, char *buf) | 560 | qla2x00_isp_id_show(struct class_device *cdev, char *buf) |
489 | { | 561 | { |
490 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 562 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
491 | return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", | 563 | return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", |
492 | ha->product_id[0], ha->product_id[1], ha->product_id[2], | 564 | ha->product_id[0], ha->product_id[1], ha->product_id[2], |
493 | ha->product_id[3]); | 565 | ha->product_id[3]); |
@@ -496,14 +568,14 @@ qla2x00_isp_id_show(struct class_device *cdev, char *buf) | |||
496 | static ssize_t | 568 | static ssize_t |
497 | qla2x00_model_name_show(struct class_device *cdev, char *buf) | 569 | qla2x00_model_name_show(struct class_device *cdev, char *buf) |
498 | { | 570 | { |
499 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 571 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
500 | return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); | 572 | return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); |
501 | } | 573 | } |
502 | 574 | ||
503 | static ssize_t | 575 | static ssize_t |
504 | qla2x00_model_desc_show(struct class_device *cdev, char *buf) | 576 | qla2x00_model_desc_show(struct class_device *cdev, char *buf) |
505 | { | 577 | { |
506 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 578 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
507 | return snprintf(buf, PAGE_SIZE, "%s\n", | 579 | return snprintf(buf, PAGE_SIZE, "%s\n", |
508 | ha->model_desc ? ha->model_desc: ""); | 580 | ha->model_desc ? ha->model_desc: ""); |
509 | } | 581 | } |
@@ -511,7 +583,7 @@ qla2x00_model_desc_show(struct class_device *cdev, char *buf) | |||
511 | static ssize_t | 583 | static ssize_t |
512 | qla2x00_pci_info_show(struct class_device *cdev, char *buf) | 584 | qla2x00_pci_info_show(struct class_device *cdev, char *buf) |
513 | { | 585 | { |
514 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 586 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
515 | char pci_info[30]; | 587 | char pci_info[30]; |
516 | 588 | ||
517 | return snprintf(buf, PAGE_SIZE, "%s\n", | 589 | return snprintf(buf, PAGE_SIZE, "%s\n", |
@@ -521,7 +593,7 @@ qla2x00_pci_info_show(struct class_device *cdev, char *buf) | |||
521 | static ssize_t | 593 | static ssize_t |
522 | qla2x00_state_show(struct class_device *cdev, char *buf) | 594 | qla2x00_state_show(struct class_device *cdev, char *buf) |
523 | { | 595 | { |
524 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 596 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
525 | int len = 0; | 597 | int len = 0; |
526 | 598 | ||
527 | if (atomic_read(&ha->loop_state) == LOOP_DOWN || | 599 | if (atomic_read(&ha->loop_state) == LOOP_DOWN || |
@@ -559,7 +631,7 @@ qla2x00_state_show(struct class_device *cdev, char *buf) | |||
559 | static ssize_t | 631 | static ssize_t |
560 | qla2x00_zio_show(struct class_device *cdev, char *buf) | 632 | qla2x00_zio_show(struct class_device *cdev, char *buf) |
561 | { | 633 | { |
562 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 634 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
563 | int len = 0; | 635 | int len = 0; |
564 | 636 | ||
565 | switch (ha->zio_mode) { | 637 | switch (ha->zio_mode) { |
@@ -576,7 +648,7 @@ qla2x00_zio_show(struct class_device *cdev, char *buf) | |||
576 | static ssize_t | 648 | static ssize_t |
577 | qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count) | 649 | qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count) |
578 | { | 650 | { |
579 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 651 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
580 | int val = 0; | 652 | int val = 0; |
581 | uint16_t zio_mode; | 653 | uint16_t zio_mode; |
582 | 654 | ||
@@ -602,7 +674,7 @@ qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count) | |||
602 | static ssize_t | 674 | static ssize_t |
603 | qla2x00_zio_timer_show(struct class_device *cdev, char *buf) | 675 | qla2x00_zio_timer_show(struct class_device *cdev, char *buf) |
604 | { | 676 | { |
605 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 677 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
606 | 678 | ||
607 | return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100); | 679 | return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100); |
608 | } | 680 | } |
@@ -611,7 +683,7 @@ static ssize_t | |||
611 | qla2x00_zio_timer_store(struct class_device *cdev, const char *buf, | 683 | qla2x00_zio_timer_store(struct class_device *cdev, const char *buf, |
612 | size_t count) | 684 | size_t count) |
613 | { | 685 | { |
614 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 686 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
615 | int val = 0; | 687 | int val = 0; |
616 | uint16_t zio_timer; | 688 | uint16_t zio_timer; |
617 | 689 | ||
@@ -629,7 +701,7 @@ qla2x00_zio_timer_store(struct class_device *cdev, const char *buf, | |||
629 | static ssize_t | 701 | static ssize_t |
630 | qla2x00_beacon_show(struct class_device *cdev, char *buf) | 702 | qla2x00_beacon_show(struct class_device *cdev, char *buf) |
631 | { | 703 | { |
632 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 704 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
633 | int len = 0; | 705 | int len = 0; |
634 | 706 | ||
635 | if (ha->beacon_blink_led) | 707 | if (ha->beacon_blink_led) |
@@ -643,7 +715,7 @@ static ssize_t | |||
643 | qla2x00_beacon_store(struct class_device *cdev, const char *buf, | 715 | qla2x00_beacon_store(struct class_device *cdev, const char *buf, |
644 | size_t count) | 716 | size_t count) |
645 | { | 717 | { |
646 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 718 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
647 | int val = 0; | 719 | int val = 0; |
648 | int rval; | 720 | int rval; |
649 | 721 | ||
@@ -673,7 +745,7 @@ qla2x00_beacon_store(struct class_device *cdev, const char *buf, | |||
673 | static ssize_t | 745 | static ssize_t |
674 | qla2x00_optrom_bios_version_show(struct class_device *cdev, char *buf) | 746 | qla2x00_optrom_bios_version_show(struct class_device *cdev, char *buf) |
675 | { | 747 | { |
676 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 748 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
677 | 749 | ||
678 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1], | 750 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1], |
679 | ha->bios_revision[0]); | 751 | ha->bios_revision[0]); |
@@ -682,7 +754,7 @@ qla2x00_optrom_bios_version_show(struct class_device *cdev, char *buf) | |||
682 | static ssize_t | 754 | static ssize_t |
683 | qla2x00_optrom_efi_version_show(struct class_device *cdev, char *buf) | 755 | qla2x00_optrom_efi_version_show(struct class_device *cdev, char *buf) |
684 | { | 756 | { |
685 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 757 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
686 | 758 | ||
687 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1], | 759 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1], |
688 | ha->efi_revision[0]); | 760 | ha->efi_revision[0]); |
@@ -691,7 +763,7 @@ qla2x00_optrom_efi_version_show(struct class_device *cdev, char *buf) | |||
691 | static ssize_t | 763 | static ssize_t |
692 | qla2x00_optrom_fcode_version_show(struct class_device *cdev, char *buf) | 764 | qla2x00_optrom_fcode_version_show(struct class_device *cdev, char *buf) |
693 | { | 765 | { |
694 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 766 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
695 | 767 | ||
696 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1], | 768 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1], |
697 | ha->fcode_revision[0]); | 769 | ha->fcode_revision[0]); |
@@ -700,7 +772,7 @@ qla2x00_optrom_fcode_version_show(struct class_device *cdev, char *buf) | |||
700 | static ssize_t | 772 | static ssize_t |
701 | qla2x00_optrom_fw_version_show(struct class_device *cdev, char *buf) | 773 | qla2x00_optrom_fw_version_show(struct class_device *cdev, char *buf) |
702 | { | 774 | { |
703 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | 775 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); |
704 | 776 | ||
705 | return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n", | 777 | return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n", |
706 | ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2], | 778 | ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2], |
@@ -757,7 +829,7 @@ struct class_device_attribute *qla2x00_host_attrs[] = { | |||
757 | static void | 829 | static void |
758 | qla2x00_get_host_port_id(struct Scsi_Host *shost) | 830 | qla2x00_get_host_port_id(struct Scsi_Host *shost) |
759 | { | 831 | { |
760 | scsi_qla_host_t *ha = to_qla_host(shost); | 832 | scsi_qla_host_t *ha = shost_priv(shost); |
761 | 833 | ||
762 | fc_host_port_id(shost) = ha->d_id.b.domain << 16 | | 834 | fc_host_port_id(shost) = ha->d_id.b.domain << 16 | |
763 | ha->d_id.b.area << 8 | ha->d_id.b.al_pa; | 835 | ha->d_id.b.area << 8 | ha->d_id.b.al_pa; |
@@ -766,7 +838,7 @@ qla2x00_get_host_port_id(struct Scsi_Host *shost) | |||
766 | static void | 838 | static void |
767 | qla2x00_get_host_speed(struct Scsi_Host *shost) | 839 | qla2x00_get_host_speed(struct Scsi_Host *shost) |
768 | { | 840 | { |
769 | scsi_qla_host_t *ha = to_qla_host(shost); | 841 | scsi_qla_host_t *ha = shost_priv(shost); |
770 | uint32_t speed = 0; | 842 | uint32_t speed = 0; |
771 | 843 | ||
772 | switch (ha->link_data_rate) { | 844 | switch (ha->link_data_rate) { |
@@ -786,7 +858,7 @@ qla2x00_get_host_speed(struct Scsi_Host *shost) | |||
786 | static void | 858 | static void |
787 | qla2x00_get_host_port_type(struct Scsi_Host *shost) | 859 | qla2x00_get_host_port_type(struct Scsi_Host *shost) |
788 | { | 860 | { |
789 | scsi_qla_host_t *ha = to_qla_host(shost); | 861 | scsi_qla_host_t *ha = shost_priv(shost); |
790 | uint32_t port_type = FC_PORTTYPE_UNKNOWN; | 862 | uint32_t port_type = FC_PORTTYPE_UNKNOWN; |
791 | 863 | ||
792 | switch (ha->current_topology) { | 864 | switch (ha->current_topology) { |
@@ -810,7 +882,7 @@ static void | |||
810 | qla2x00_get_starget_node_name(struct scsi_target *starget) | 882 | qla2x00_get_starget_node_name(struct scsi_target *starget) |
811 | { | 883 | { |
812 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); | 884 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); |
813 | scsi_qla_host_t *ha = to_qla_host(host); | 885 | scsi_qla_host_t *ha = shost_priv(host); |
814 | fc_port_t *fcport; | 886 | fc_port_t *fcport; |
815 | u64 node_name = 0; | 887 | u64 node_name = 0; |
816 | 888 | ||
@@ -828,7 +900,7 @@ static void | |||
828 | qla2x00_get_starget_port_name(struct scsi_target *starget) | 900 | qla2x00_get_starget_port_name(struct scsi_target *starget) |
829 | { | 901 | { |
830 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); | 902 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); |
831 | scsi_qla_host_t *ha = to_qla_host(host); | 903 | scsi_qla_host_t *ha = shost_priv(host); |
832 | fc_port_t *fcport; | 904 | fc_port_t *fcport; |
833 | u64 port_name = 0; | 905 | u64 port_name = 0; |
834 | 906 | ||
@@ -846,7 +918,7 @@ static void | |||
846 | qla2x00_get_starget_port_id(struct scsi_target *starget) | 918 | qla2x00_get_starget_port_id(struct scsi_target *starget) |
847 | { | 919 | { |
848 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); | 920 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); |
849 | scsi_qla_host_t *ha = to_qla_host(host); | 921 | scsi_qla_host_t *ha = shost_priv(host); |
850 | fc_port_t *fcport; | 922 | fc_port_t *fcport; |
851 | uint32_t port_id = ~0U; | 923 | uint32_t port_id = ~0U; |
852 | 924 | ||
@@ -865,7 +937,7 @@ static void | |||
865 | qla2x00_get_rport_loss_tmo(struct fc_rport *rport) | 937 | qla2x00_get_rport_loss_tmo(struct fc_rport *rport) |
866 | { | 938 | { |
867 | struct Scsi_Host *host = rport_to_shost(rport); | 939 | struct Scsi_Host *host = rport_to_shost(rport); |
868 | scsi_qla_host_t *ha = to_qla_host(host); | 940 | scsi_qla_host_t *ha = shost_priv(host); |
869 | 941 | ||
870 | rport->dev_loss_tmo = ha->port_down_retry_count + 5; | 942 | rport->dev_loss_tmo = ha->port_down_retry_count + 5; |
871 | } | 943 | } |
@@ -874,7 +946,7 @@ static void | |||
874 | qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | 946 | qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
875 | { | 947 | { |
876 | struct Scsi_Host *host = rport_to_shost(rport); | 948 | struct Scsi_Host *host = rport_to_shost(rport); |
877 | scsi_qla_host_t *ha = to_qla_host(host); | 949 | scsi_qla_host_t *ha = shost_priv(host); |
878 | 950 | ||
879 | if (timeout) | 951 | if (timeout) |
880 | ha->port_down_retry_count = timeout; | 952 | ha->port_down_retry_count = timeout; |
@@ -887,7 +959,7 @@ qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | |||
887 | static int | 959 | static int |
888 | qla2x00_issue_lip(struct Scsi_Host *shost) | 960 | qla2x00_issue_lip(struct Scsi_Host *shost) |
889 | { | 961 | { |
890 | scsi_qla_host_t *ha = to_qla_host(shost); | 962 | scsi_qla_host_t *ha = shost_priv(shost); |
891 | 963 | ||
892 | set_bit(LOOP_RESET_NEEDED, &ha->dpc_flags); | 964 | set_bit(LOOP_RESET_NEEDED, &ha->dpc_flags); |
893 | return 0; | 965 | return 0; |
@@ -896,7 +968,7 @@ qla2x00_issue_lip(struct Scsi_Host *shost) | |||
896 | static struct fc_host_statistics * | 968 | static struct fc_host_statistics * |
897 | qla2x00_get_fc_host_stats(struct Scsi_Host *shost) | 969 | qla2x00_get_fc_host_stats(struct Scsi_Host *shost) |
898 | { | 970 | { |
899 | scsi_qla_host_t *ha = to_qla_host(shost); | 971 | scsi_qla_host_t *ha = shost_priv(shost); |
900 | int rval; | 972 | int rval; |
901 | uint16_t mb_stat[1]; | 973 | uint16_t mb_stat[1]; |
902 | link_stat_t stat_buf; | 974 | link_stat_t stat_buf; |
@@ -934,7 +1006,7 @@ done: | |||
934 | static void | 1006 | static void |
935 | qla2x00_get_host_symbolic_name(struct Scsi_Host *shost) | 1007 | qla2x00_get_host_symbolic_name(struct Scsi_Host *shost) |
936 | { | 1008 | { |
937 | scsi_qla_host_t *ha = to_qla_host(shost); | 1009 | scsi_qla_host_t *ha = shost_priv(shost); |
938 | 1010 | ||
939 | qla2x00_get_sym_node_name(ha, fc_host_symbolic_name(shost)); | 1011 | qla2x00_get_sym_node_name(ha, fc_host_symbolic_name(shost)); |
940 | } | 1012 | } |
@@ -942,7 +1014,7 @@ qla2x00_get_host_symbolic_name(struct Scsi_Host *shost) | |||
942 | static void | 1014 | static void |
943 | qla2x00_set_host_system_hostname(struct Scsi_Host *shost) | 1015 | qla2x00_set_host_system_hostname(struct Scsi_Host *shost) |
944 | { | 1016 | { |
945 | scsi_qla_host_t *ha = to_qla_host(shost); | 1017 | scsi_qla_host_t *ha = shost_priv(shost); |
946 | 1018 | ||
947 | set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); | 1019 | set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); |
948 | } | 1020 | } |
@@ -950,7 +1022,7 @@ qla2x00_set_host_system_hostname(struct Scsi_Host *shost) | |||
950 | static void | 1022 | static void |
951 | qla2x00_get_host_fabric_name(struct Scsi_Host *shost) | 1023 | qla2x00_get_host_fabric_name(struct Scsi_Host *shost) |
952 | { | 1024 | { |
953 | scsi_qla_host_t *ha = to_qla_host(shost); | 1025 | scsi_qla_host_t *ha = shost_priv(shost); |
954 | u64 node_name; | 1026 | u64 node_name; |
955 | 1027 | ||
956 | if (ha->device_flags & SWITCH_FOUND) | 1028 | if (ha->device_flags & SWITCH_FOUND) |
@@ -964,7 +1036,7 @@ qla2x00_get_host_fabric_name(struct Scsi_Host *shost) | |||
964 | static void | 1036 | static void |
965 | qla2x00_get_host_port_state(struct Scsi_Host *shost) | 1037 | qla2x00_get_host_port_state(struct Scsi_Host *shost) |
966 | { | 1038 | { |
967 | scsi_qla_host_t *ha = to_qla_host(shost); | 1039 | scsi_qla_host_t *ha = shost_priv(shost); |
968 | 1040 | ||
969 | if (!ha->flags.online) | 1041 | if (!ha->flags.online) |
970 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; | 1042 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
@@ -978,7 +1050,7 @@ static int | |||
978 | qla24xx_vport_create(struct fc_vport *fc_vport, bool disable) | 1050 | qla24xx_vport_create(struct fc_vport *fc_vport, bool disable) |
979 | { | 1051 | { |
980 | int ret = 0; | 1052 | int ret = 0; |
981 | scsi_qla_host_t *ha = (scsi_qla_host_t *) fc_vport->shost->hostdata; | 1053 | scsi_qla_host_t *ha = shost_priv(fc_vport->shost); |
982 | scsi_qla_host_t *vha; | 1054 | scsi_qla_host_t *vha; |
983 | 1055 | ||
984 | ret = qla24xx_vport_create_req_sanity_check(fc_vport); | 1056 | ret = qla24xx_vport_create_req_sanity_check(fc_vport); |
@@ -1047,7 +1119,7 @@ vport_create_failed_2: | |||
1047 | int | 1119 | int |
1048 | qla24xx_vport_delete(struct fc_vport *fc_vport) | 1120 | qla24xx_vport_delete(struct fc_vport *fc_vport) |
1049 | { | 1121 | { |
1050 | scsi_qla_host_t *ha = (scsi_qla_host_t *) fc_vport->shost->hostdata; | 1122 | scsi_qla_host_t *ha = shost_priv(fc_vport->shost); |
1051 | scsi_qla_host_t *vha = fc_vport->dd_data; | 1123 | scsi_qla_host_t *vha = fc_vport->dd_data; |
1052 | 1124 | ||
1053 | qla24xx_disable_vp(vha); | 1125 | qla24xx_disable_vp(vha); |
@@ -1178,6 +1250,6 @@ qla2x00_init_host_attr(scsi_qla_host_t *ha) | |||
1178 | fc_host_node_name(ha->host) = wwn_to_u64(ha->node_name); | 1250 | fc_host_node_name(ha->host) = wwn_to_u64(ha->node_name); |
1179 | fc_host_port_name(ha->host) = wwn_to_u64(ha->port_name); | 1251 | fc_host_port_name(ha->host) = wwn_to_u64(ha->port_name); |
1180 | fc_host_supported_classes(ha->host) = FC_COS_CLASS3; | 1252 | fc_host_supported_classes(ha->host) = FC_COS_CLASS3; |
1181 | fc_host_max_npiv_vports(ha->host) = MAX_NUM_VPORT_FABRIC; | 1253 | fc_host_max_npiv_vports(ha->host) = ha->max_npiv_vports;; |
1182 | fc_host_npiv_vports_inuse(ha->host) = ha->cur_vport_count; | 1254 | fc_host_npiv_vports_inuse(ha->host) = ha->cur_vport_count; |
1183 | } | 1255 | } |