提交 7000078a 编写于 作者: P Pratik Pujar 提交者: David S. Miller

qlcnic: Restructuring of qlc_83xx_fw_info structure.

o Removed unused and unnecessary members from qlc_83xx_fw_info
  structure.
o Made fw_info member of qlcnic_hardware_context as a pointer to
  qlc_83xx_fw_info structure.
o Added a member fw_file_name to qlc_83xx_fw_info structure which
  will hold the name of firmware image file name.
Signed-off-by: NPratik Pujar <pratik.pujar@qlogic.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 9ce226fa
...@@ -463,7 +463,7 @@ struct qlcnic_hardware_context { ...@@ -463,7 +463,7 @@ struct qlcnic_hardware_context {
struct qlcnic_fdt fdt; struct qlcnic_fdt fdt;
struct qlc_83xx_reset reset; struct qlc_83xx_reset reset;
struct qlc_83xx_idc idc; struct qlc_83xx_idc idc;
struct qlc_83xx_fw_info fw_info; struct qlc_83xx_fw_info *fw_info;
struct qlcnic_intrpt_config *intr_tbl; struct qlcnic_intrpt_config *intr_tbl;
struct qlcnic_sriov *sriov; struct qlcnic_sriov *sriov;
u32 *reg_tbl; u32 *reg_tbl;
......
...@@ -274,11 +274,7 @@ struct qlcnic_macvlan_mbx { ...@@ -274,11 +274,7 @@ struct qlcnic_macvlan_mbx {
struct qlc_83xx_fw_info { struct qlc_83xx_fw_info {
const struct firmware *fw; const struct firmware *fw;
u16 major_fw_version; char fw_file_name[QLC_FW_FILE_NAME_LEN];
u8 minor_fw_version;
u8 sub_fw_version;
u8 fw_build_num;
u8 load_from_file;
}; };
struct qlc_83xx_reset { struct qlc_83xx_reset {
......
...@@ -1267,31 +1267,33 @@ static int qlcnic_83xx_copy_bootloader(struct qlcnic_adapter *adapter) ...@@ -1267,31 +1267,33 @@ static int qlcnic_83xx_copy_bootloader(struct qlcnic_adapter *adapter)
static int qlcnic_83xx_copy_fw_file(struct qlcnic_adapter *adapter) static int qlcnic_83xx_copy_fw_file(struct qlcnic_adapter *adapter)
{ {
struct qlc_83xx_fw_info *fw_info = adapter->ahw->fw_info;
const struct firmware *fw = fw_info->fw;
u32 dest, *p_cache; u32 dest, *p_cache;
u64 addr; int i, ret = -EIO;
u8 data[16]; u8 data[16];
size_t size; size_t size;
int i, ret = -EIO; u64 addr;
dest = QLCRDX(adapter->ahw, QLCNIC_FW_IMAGE_ADDR); dest = QLCRDX(adapter->ahw, QLCNIC_FW_IMAGE_ADDR);
size = (adapter->ahw->fw_info.fw->size & ~0xF); size = (fw->size & ~0xF);
p_cache = (u32 *)adapter->ahw->fw_info.fw->data; p_cache = (u32 *)fw->data;
addr = (u64)dest; addr = (u64)dest;
ret = qlcnic_83xx_ms_mem_write128(adapter, addr, ret = qlcnic_83xx_ms_mem_write128(adapter, addr,
(u32 *)p_cache, size / 16); (u32 *)p_cache, size / 16);
if (ret) { if (ret) {
dev_err(&adapter->pdev->dev, "MS memory write failed\n"); dev_err(&adapter->pdev->dev, "MS memory write failed\n");
release_firmware(adapter->ahw->fw_info.fw); release_firmware(fw);
adapter->ahw->fw_info.fw = NULL; fw_info->fw = NULL;
return -EIO; return -EIO;
} }
/* alignment check */ /* alignment check */
if (adapter->ahw->fw_info.fw->size & 0xF) { if (fw->size & 0xF) {
addr = dest + size; addr = dest + size;
for (i = 0; i < (adapter->ahw->fw_info.fw->size & 0xF); i++) for (i = 0; i < (fw->size & 0xF); i++)
data[i] = adapter->ahw->fw_info.fw->data[size + i]; data[i] = fw->data[size + i];
for (; i < 16; i++) for (; i < 16; i++)
data[i] = 0; data[i] = 0;
ret = qlcnic_83xx_ms_mem_write128(adapter, addr, ret = qlcnic_83xx_ms_mem_write128(adapter, addr,
...@@ -1299,13 +1301,13 @@ static int qlcnic_83xx_copy_fw_file(struct qlcnic_adapter *adapter) ...@@ -1299,13 +1301,13 @@ static int qlcnic_83xx_copy_fw_file(struct qlcnic_adapter *adapter)
if (ret) { if (ret) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
"MS memory write failed\n"); "MS memory write failed\n");
release_firmware(adapter->ahw->fw_info.fw); release_firmware(fw);
adapter->ahw->fw_info.fw = NULL; fw_info->fw = NULL;
return -EIO; return -EIO;
} }
} }
release_firmware(adapter->ahw->fw_info.fw); release_firmware(fw);
adapter->ahw->fw_info.fw = NULL; fw_info->fw = NULL;
return 0; return 0;
} }
...@@ -1949,35 +1951,12 @@ static void qlcnic_83xx_init_hw(struct qlcnic_adapter *p_dev) ...@@ -1949,35 +1951,12 @@ static void qlcnic_83xx_init_hw(struct qlcnic_adapter *p_dev)
dev_err(&p_dev->pdev->dev, "%s: failed\n", __func__); dev_err(&p_dev->pdev->dev, "%s: failed\n", __func__);
} }
static void qlcnic_83xx_get_fw_file_name(struct qlcnic_adapter *adapter,
char *file_name)
{
struct pci_dev *pdev = adapter->pdev;
memset(file_name, 0, QLC_FW_FILE_NAME_LEN);
switch (pdev->device) {
case PCI_DEVICE_ID_QLOGIC_QLE834X:
strncpy(file_name, QLC_83XX_FW_FILE_NAME,
QLC_FW_FILE_NAME_LEN);
break;
case PCI_DEVICE_ID_QLOGIC_QLE844X:
strncpy(file_name, QLC_84XX_FW_FILE_NAME,
QLC_FW_FILE_NAME_LEN);
break;
default:
dev_err(&pdev->dev, "%s: Invalid device id\n",
__func__);
}
}
static int qlcnic_83xx_load_fw_image_from_host(struct qlcnic_adapter *adapter) static int qlcnic_83xx_load_fw_image_from_host(struct qlcnic_adapter *adapter)
{ {
char fw_file_name[QLC_FW_FILE_NAME_LEN]; struct qlc_83xx_fw_info *fw_info = adapter->ahw->fw_info;
int err = -EIO; int err = -EIO;
qlcnic_83xx_get_fw_file_name(adapter, fw_file_name); if (request_firmware(&fw_info->fw, fw_info->fw_file_name,
if (request_firmware(&adapter->ahw->fw_info.fw, fw_file_name,
&(adapter->pdev->dev))) { &(adapter->pdev->dev))) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
"No file FW image, loading flash FW image.\n"); "No file FW image, loading flash FW image.\n");
...@@ -2173,6 +2152,39 @@ static void qlcnic_83xx_clear_function_resources(struct qlcnic_adapter *adapter) ...@@ -2173,6 +2152,39 @@ static void qlcnic_83xx_clear_function_resources(struct qlcnic_adapter *adapter)
} }
} }
static int qlcnic_83xx_get_fw_info(struct qlcnic_adapter *adapter)
{
struct qlcnic_hardware_context *ahw = adapter->ahw;
struct pci_dev *pdev = adapter->pdev;
struct qlc_83xx_fw_info *fw_info;
int err = 0;
ahw->fw_info = kzalloc(sizeof(*fw_info), GFP_KERNEL);
if (!ahw->fw_info) {
err = -ENOMEM;
} else {
fw_info = ahw->fw_info;
switch (pdev->device) {
case PCI_DEVICE_ID_QLOGIC_QLE834X:
strncpy(fw_info->fw_file_name, QLC_83XX_FW_FILE_NAME,
QLC_FW_FILE_NAME_LEN);
break;
case PCI_DEVICE_ID_QLOGIC_QLE844X:
strncpy(fw_info->fw_file_name, QLC_84XX_FW_FILE_NAME,
QLC_FW_FILE_NAME_LEN);
break;
default:
dev_err(&pdev->dev, "%s: Invalid device id\n",
__func__);
err = -EINVAL;
break;
}
}
return err;
}
int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac) int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac)
{ {
struct qlcnic_hardware_context *ahw = adapter->ahw; struct qlcnic_hardware_context *ahw = adapter->ahw;
...@@ -2198,10 +2210,14 @@ int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac) ...@@ -2198,10 +2210,14 @@ int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac)
if (!qlcnic_83xx_read_flash_descriptor_table(adapter)) if (!qlcnic_83xx_read_flash_descriptor_table(adapter))
qlcnic_83xx_read_flash_mfg_id(adapter); qlcnic_83xx_read_flash_mfg_id(adapter);
err = qlcnic_83xx_idc_init(adapter); err = qlcnic_83xx_get_fw_info(adapter);
if (err) if (err)
goto detach_mbx; goto detach_mbx;
err = qlcnic_83xx_idc_init(adapter);
if (err)
goto clear_fw_info;
err = qlcnic_setup_intr(adapter, 0, 0); err = qlcnic_setup_intr(adapter, 0, 0);
if (err) { if (err) {
dev_err(&adapter->pdev->dev, "Failed to setup interrupt\n"); dev_err(&adapter->pdev->dev, "Failed to setup interrupt\n");
...@@ -2242,6 +2258,9 @@ int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac) ...@@ -2242,6 +2258,9 @@ int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac)
disable_intr: disable_intr:
qlcnic_teardown_intr(adapter); qlcnic_teardown_intr(adapter);
clear_fw_info:
kfree(ahw->fw_info);
detach_mbx: detach_mbx:
qlcnic_83xx_detach_mailbox_work(adapter); qlcnic_83xx_detach_mailbox_work(adapter);
qlcnic_83xx_free_mailbox(ahw->mailbox); qlcnic_83xx_free_mailbox(ahw->mailbox);
......
...@@ -2402,6 +2402,7 @@ static void qlcnic_remove(struct pci_dev *pdev) ...@@ -2402,6 +2402,7 @@ static void qlcnic_remove(struct pci_dev *pdev)
qlcnic_83xx_free_mbx_intr(adapter); qlcnic_83xx_free_mbx_intr(adapter);
qlcnic_83xx_detach_mailbox_work(adapter); qlcnic_83xx_detach_mailbox_work(adapter);
qlcnic_83xx_free_mailbox(ahw->mailbox); qlcnic_83xx_free_mailbox(ahw->mailbox);
kfree(ahw->fw_info);
} }
qlcnic_detach(adapter); qlcnic_detach(adapter);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册