aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx
diff options
context:
space:
mode:
authorandrew.vasquez@qlogic.com <andrew.vasquez@qlogic.com>2006-03-09 17:27:34 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-03-12 10:39:55 -0500
commit6f6417905cf272337a9762e1f92a1fffa651fcd3 (patch)
tree39164863fb9325279c708e9dd08b1d2e76db393c /drivers/scsi/qla2xxx
parentfdbc6833c53a1c2ec2b122cd53e69e6136dcc774 (diff)
[SCSI] qla2xxx: Add VPD sysfs attribute.
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/qla2xxx')
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c57
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_fw.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c6
4 files changed, 65 insertions, 2 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 2b9e329a240c..488b3d16427b 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -308,6 +308,61 @@ static struct bin_attribute sysfs_optrom_ctl_attr = {
308 .write = qla2x00_sysfs_write_optrom_ctl, 308 .write = qla2x00_sysfs_write_optrom_ctl,
309}; 309};
310 310
311static ssize_t
312qla2x00_sysfs_read_vpd(struct kobject *kobj, char *buf, loff_t off,
313 size_t count)
314{
315 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
316 struct device, kobj)));
317 unsigned long flags;
318
319 if (!capable(CAP_SYS_ADMIN) || off != 0)
320 return 0;
321
322 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
323 return -ENOTSUPP;
324
325 /* Read NVRAM. */
326 spin_lock_irqsave(&ha->hardware_lock, flags);
327 ha->isp_ops.read_nvram(ha, (uint8_t *)buf, ha->vpd_base, ha->vpd_size);
328 spin_unlock_irqrestore(&ha->hardware_lock, flags);
329
330 return ha->vpd_size;
331}
332
333static ssize_t
334qla2x00_sysfs_write_vpd(struct kobject *kobj, char *buf, loff_t off,
335 size_t count)
336{
337 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
338 struct device, kobj)));
339 unsigned long flags;
340
341 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size)
342 return 0;
343
344 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
345 return -ENOTSUPP;
346
347 /* Write NVRAM. */
348 spin_lock_irqsave(&ha->hardware_lock, flags);
349 ha->isp_ops.write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count);
350 spin_unlock_irqrestore(&ha->hardware_lock, flags);
351
352 return count;
353}
354
355static struct bin_attribute sysfs_vpd_attr = {
356 .attr = {
357 .name = "vpd",
358 .mode = S_IRUSR | S_IWUSR,
359 .owner = THIS_MODULE,
360 },
361 .size = 0,
362 .read = qla2x00_sysfs_read_vpd,
363 .write = qla2x00_sysfs_write_vpd,
364};
365
311void 366void
312qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) 367qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha)
313{ 368{
@@ -318,6 +373,7 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha)
318 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); 373 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr);
319 sysfs_create_bin_file(&host->shost_gendev.kobj, 374 sysfs_create_bin_file(&host->shost_gendev.kobj,
320 &sysfs_optrom_ctl_attr); 375 &sysfs_optrom_ctl_attr);
376 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_vpd_attr);
321} 377}
322 378
323void 379void
@@ -330,6 +386,7 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
330 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); 386 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr);
331 sysfs_remove_bin_file(&host->shost_gendev.kobj, 387 sysfs_remove_bin_file(&host->shost_gendev.kobj,
332 &sysfs_optrom_ctl_attr); 388 &sysfs_optrom_ctl_attr);
389 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_vpd_attr);
333 390
334 if (ha->beacon_blink_led == 1) 391 if (ha->beacon_blink_led == 1)
335 ha->isp_ops.beacon_off(ha); 392 ha->isp_ops.beacon_off(ha);
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index e1a7769008ee..20798f93d8da 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2344,6 +2344,8 @@ typedef struct scsi_qla_host {
2344 /* NVRAM configuration data */ 2344 /* NVRAM configuration data */
2345 uint16_t nvram_size; 2345 uint16_t nvram_size;
2346 uint16_t nvram_base; 2346 uint16_t nvram_base;
2347 uint16_t vpd_size;
2348 uint16_t vpd_base;
2347 2349
2348 uint16_t loop_reset_delay; 2350 uint16_t loop_reset_delay;
2349 uint8_t retry_count; 2351 uint8_t retry_count;
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index 9fb562aa4acc..1ee58ad2f4dd 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -759,7 +759,7 @@ struct device_reg_24xx {
759#define FA_NVRAM_FUNC0_ADDR 0x80 759#define FA_NVRAM_FUNC0_ADDR 0x80
760#define FA_NVRAM_FUNC1_ADDR 0x180 760#define FA_NVRAM_FUNC1_ADDR 0x180
761 761
762#define FA_NVRAM_VPD_SIZE 0x80 762#define FA_NVRAM_VPD_SIZE 0x200
763#define FA_NVRAM_VPD0_ADDR 0x00 763#define FA_NVRAM_VPD0_ADDR 0x00
764#define FA_NVRAM_VPD1_ADDR 0x100 764#define FA_NVRAM_VPD1_ADDR 0x100
765 /* 765 /*
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 3bc3e1749f32..71b6bcc181f9 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -3263,8 +3263,12 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3263 /* Determine NVRAM starting address. */ 3263 /* Determine NVRAM starting address. */
3264 ha->nvram_size = sizeof(struct nvram_24xx); 3264 ha->nvram_size = sizeof(struct nvram_24xx);
3265 ha->nvram_base = FA_NVRAM_FUNC0_ADDR; 3265 ha->nvram_base = FA_NVRAM_FUNC0_ADDR;
3266 if (PCI_FUNC(ha->pdev->devfn)) 3266 ha->vpd_size = FA_NVRAM_VPD_SIZE;
3267 ha->vpd_base = FA_NVRAM_VPD0_ADDR;
3268 if (PCI_FUNC(ha->pdev->devfn)) {
3267 ha->nvram_base = FA_NVRAM_FUNC1_ADDR; 3269 ha->nvram_base = FA_NVRAM_FUNC1_ADDR;
3270 ha->vpd_base = FA_NVRAM_VPD1_ADDR;
3271 }
3268 3272
3269 /* Get NVRAM data and calculate checksum. */ 3273 /* Get NVRAM data and calculate checksum. */
3270 dptr = (uint32_t *)nv; 3274 dptr = (uint32_t *)nv;