.write = qla2x00_sysfs_write_fw_dump,
};
-static ssize_t
-qla2x00_sysfs_read_fw_dump_template(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr,
- char *buf, loff_t off, size_t count)
-{
- struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
- struct device, kobj)));
- struct qla_hw_data *ha = vha->hw;
-
- if (!ha->fw_dump_template || !ha->fw_dump_template_len)
- return 0;
-
- ql_dbg(ql_dbg_user, vha, 0x70e2,
- "chunk <- off=%llx count=%zx\n", off, count);
- return memory_read_from_buffer(buf, count, &off,
- ha->fw_dump_template, ha->fw_dump_template_len);
-}
-
-static ssize_t
-qla2x00_sysfs_write_fw_dump_template(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr,
- char *buf, loff_t off, size_t count)
-{
- struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
- struct device, kobj)));
- struct qla_hw_data *ha = vha->hw;
- uint32_t size;
-
- if (off == 0) {
- if (ha->fw_dump)
- vfree(ha->fw_dump);
- if (ha->fw_dump_template)
- vfree(ha->fw_dump_template);
-
- ha->fw_dump = NULL;
- ha->fw_dump_len = 0;
- ha->fw_dump_template = NULL;
- ha->fw_dump_template_len = 0;
-
- size = qla27xx_fwdt_template_size(buf);
- ql_dbg(ql_dbg_user, vha, 0x70d1,
- "-> allocating fwdt (%x bytes)...\n", size);
- ha->fw_dump_template = vmalloc(size);
- if (!ha->fw_dump_template) {
- ql_log(ql_log_warn, vha, 0x70d2,
- "Failed allocate fwdt (%x bytes).\n", size);
- return -ENOMEM;
- }
- ha->fw_dump_template_len = size;
- }
-
- if (off + count > ha->fw_dump_template_len) {
- count = ha->fw_dump_template_len - off;
- ql_dbg(ql_dbg_user, vha, 0x70d3,
- "chunk -> truncating to %zx bytes.\n", count);
- }
-
- ql_dbg(ql_dbg_user, vha, 0x70d4,
- "chunk -> off=%llx count=%zx\n", off, count);
- memcpy(ha->fw_dump_template + off, buf, count);
-
- if (off + count == ha->fw_dump_template_len) {
- size = qla27xx_fwdt_calculate_dump_size(vha);
- ql_dbg(ql_dbg_user, vha, 0x70d5,
- "-> allocating fwdump (%x bytes)...\n", size);
- ha->fw_dump = vmalloc(size);
- if (!ha->fw_dump) {
- ql_log(ql_log_warn, vha, 0x70d6,
- "Failed allocate fwdump (%x bytes).\n", size);
- return -ENOMEM;
- }
- ha->fw_dump_len = size;
- }
-
- return count;
-}
-static struct bin_attribute sysfs_fw_dump_template_attr = {
- .attr = {
- .name = "fw_dump_template",
- .mode = S_IRUSR | S_IWUSR,
- },
- .size = 0,
- .read = qla2x00_sysfs_read_fw_dump_template,
- .write = qla2x00_sysfs_write_fw_dump_template,
-};
-
static ssize_t
qla2x00_sysfs_read_nvram(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr,
int is4GBp_only;
} bin_file_entries[] = {
{ "fw_dump", &sysfs_fw_dump_attr, },
- { "fw_dump_template", &sysfs_fw_dump_template_attr, 0x27 },
{ "nvram", &sysfs_nvram_attr, },
{ "optrom", &sysfs_optrom_attr, },
{ "optrom_ctl", &sysfs_optrom_ctl_attr, },
continue;
if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw)))
continue;
- if (iter->is4GBp_only == 0x27 && !IS_QLA27XX(vha->hw))
- continue;
ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
iter->attr);