Commit 459c5378 authored by Andrew Vasquez's avatar Andrew Vasquez Committed by James Bottomley

[SCSI] qla2xxx: Add ISP24xx flash-manipulation routines.

Add ISP24xx flash-manipulation routines.

Add read/write flash manipulation routines for the ISP24xx.
Update sysfs NVRAM objects to use generalized accessor
functions.
Signed-off-by: default avatarAndrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 1c7c6357
...@@ -118,23 +118,15 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj, char *buf, loff_t off, ...@@ -118,23 +118,15 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj, char *buf, loff_t off,
{ {
struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
struct device, kobj))); struct device, kobj)));
uint16_t *witer;
unsigned long flags; unsigned long flags;
uint16_t cnt;
if (!capable(CAP_SYS_ADMIN) || off != 0 || count != sizeof(nvram_t)) if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size)
return 0; return 0;
/* Read NVRAM. */ /* Read NVRAM. */
spin_lock_irqsave(&ha->hardware_lock, flags); spin_lock_irqsave(&ha->hardware_lock, flags);
qla2x00_lock_nvram_access(ha); ha->isp_ops.read_nvram(ha, (uint8_t *)buf, ha->nvram_base,
witer = (uint16_t *)buf; ha->nvram_size);
for (cnt = 0; cnt < count / 2; cnt++) {
*witer = cpu_to_le16(qla2x00_get_nvram_word(ha,
cnt+ha->nvram_base));
witer++;
}
qla2x00_unlock_nvram_access(ha);
spin_unlock_irqrestore(&ha->hardware_lock, flags); spin_unlock_irqrestore(&ha->hardware_lock, flags);
return (count); return (count);
...@@ -146,34 +138,38 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, char *buf, loff_t off, ...@@ -146,34 +138,38 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, char *buf, loff_t off,
{ {
struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
struct device, kobj))); struct device, kobj)));
uint8_t *iter;
uint16_t *witer;
unsigned long flags; unsigned long flags;
uint16_t cnt; uint16_t cnt;
uint8_t chksum;
if (!capable(CAP_SYS_ADMIN) || off != 0 || count != sizeof(nvram_t)) if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size)
return 0; return 0;
/* Checksum NVRAM. */ /* Checksum NVRAM. */
iter = (uint8_t *)buf; if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
chksum = 0; uint32_t *iter;
for (cnt = 0; cnt < count - 1; cnt++) uint32_t chksum;
chksum += *iter++;
chksum = ~chksum + 1; iter = (uint32_t *)buf;
*iter = chksum; chksum = 0;
for (cnt = 0; cnt < ((count >> 2) - 1); cnt++)
chksum += le32_to_cpu(*iter++);
chksum = ~chksum + 1;
*iter = cpu_to_le32(chksum);
} else {
uint8_t *iter;
uint8_t chksum;
iter = (uint8_t *)buf;
chksum = 0;
for (cnt = 0; cnt < count - 1; cnt++)
chksum += *iter++;
chksum = ~chksum + 1;
*iter = chksum;
}
/* Write NVRAM. */ /* Write NVRAM. */
spin_lock_irqsave(&ha->hardware_lock, flags); spin_lock_irqsave(&ha->hardware_lock, flags);
qla2x00_lock_nvram_access(ha); ha->isp_ops.write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count);
qla2x00_release_nvram_protection(ha);
witer = (uint16_t *)buf;
for (cnt = 0; cnt < count / 2; cnt++) {
qla2x00_write_nvram_word(ha, cnt+ha->nvram_base,
cpu_to_le16(*witer));
witer++;
}
qla2x00_unlock_nvram_access(ha);
spin_unlock_irqrestore(&ha->hardware_lock, flags); spin_unlock_irqrestore(&ha->hardware_lock, flags);
return (count); return (count);
...@@ -185,7 +181,7 @@ static struct bin_attribute sysfs_nvram_attr = { ...@@ -185,7 +181,7 @@ static struct bin_attribute sysfs_nvram_attr = {
.mode = S_IRUSR | S_IWUSR, .mode = S_IRUSR | S_IWUSR,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.size = sizeof(nvram_t), .size = 0,
.read = qla2x00_sysfs_read_nvram, .read = qla2x00_sysfs_read_nvram,
.write = qla2x00_sysfs_write_nvram, .write = qla2x00_sysfs_write_nvram,
}; };
...@@ -196,6 +192,7 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) ...@@ -196,6 +192,7 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha)
struct Scsi_Host *host = ha->host; struct Scsi_Host *host = ha->host;
sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr);
sysfs_nvram_attr.size = ha->nvram_size;
sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr);
} }
......
...@@ -220,6 +220,17 @@ extern void qla2x00_unlock_nvram_access(scsi_qla_host_t *); ...@@ -220,6 +220,17 @@ extern void qla2x00_unlock_nvram_access(scsi_qla_host_t *);
extern void qla2x00_release_nvram_protection(scsi_qla_host_t *); extern void qla2x00_release_nvram_protection(scsi_qla_host_t *);
extern uint16_t qla2x00_get_nvram_word(scsi_qla_host_t *, uint32_t); extern uint16_t qla2x00_get_nvram_word(scsi_qla_host_t *, uint32_t);
extern void qla2x00_write_nvram_word(scsi_qla_host_t *, uint32_t, uint16_t); extern void qla2x00_write_nvram_word(scsi_qla_host_t *, uint32_t, uint16_t);
extern uint32_t *qla24xx_read_flash_data(scsi_qla_host_t *, uint32_t *,
uint32_t, uint32_t);
extern uint8_t *qla2x00_read_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t,
uint32_t);
extern uint8_t *qla24xx_read_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t,
uint32_t);
extern int qla2x00_write_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t,
uint32_t);
extern int qla24xx_write_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t,
uint32_t);
/* /*
* Global Function Prototypes in qla_dbg.c source file. * Global Function Prototypes in qla_dbg.c source file.
*/ */
......
...@@ -1187,6 +1187,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) ...@@ -1187,6 +1187,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_32; ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_32;
ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_32; ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_32;
ha->isp_ops.prep_ms_iocb = qla2x00_prep_ms_iocb; ha->isp_ops.prep_ms_iocb = qla2x00_prep_ms_iocb;
ha->isp_ops.read_nvram = qla2x00_read_nvram_data;
ha->isp_ops.write_nvram = qla2x00_write_nvram_data;
ha->isp_ops.fw_dump = qla2100_fw_dump; ha->isp_ops.fw_dump = qla2100_fw_dump;
ha->isp_ops.ascii_fw_dump = qla2100_ascii_fw_dump; ha->isp_ops.ascii_fw_dump = qla2100_ascii_fw_dump;
if (IS_QLA2100(ha)) { if (IS_QLA2100(ha)) {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment