From: Shahed Shaikh <shahed.shaikh@qlogic.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <Dept-HSGLinuxNICDev@qlogic.com>,
Pratik Pujar <pratik.pujar@qlogic.com>
Subject: [PATCH net-next 7/9] qlcnic: Restructuring of qlc_83xx_fw_info structure.
Date: Fri, 30 Aug 2013 13:51:22 -0400 [thread overview]
Message-ID: <1377885084-6441-8-git-send-email-shahed.shaikh@qlogic.com> (raw)
In-Reply-To: <1377885084-6441-1-git-send-email-shahed.shaikh@qlogic.com>
From: Pratik Pujar <pratik.pujar@qlogic.com>
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: Pratik Pujar <pratik.pujar@qlogic.com>
---
drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 2 +-
.../net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h | 6 +-
.../net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c | 97 ++++++++++++--------
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 1 +
4 files changed, 61 insertions(+), 45 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
index 27e34a5..0cd993f 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
@@ -463,7 +463,7 @@ struct qlcnic_hardware_context {
struct qlcnic_fdt fdt;
struct qlc_83xx_reset reset;
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_sriov *sriov;
u32 *reg_tbl;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
index 6752d58..2a2ab6b 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
@@ -274,11 +274,7 @@ struct qlcnic_macvlan_mbx {
struct qlc_83xx_fw_info {
const struct firmware *fw;
- u16 major_fw_version;
- u8 minor_fw_version;
- u8 sub_fw_version;
- u8 fw_build_num;
- u8 load_from_file;
+ char fw_file_name[QLC_FW_FILE_NAME_LEN];
};
struct qlc_83xx_reset {
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
index b7eddfe..c24c2a4 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
@@ -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)
{
+ struct qlc_83xx_fw_info *fw_info = adapter->ahw->fw_info;
+ const struct firmware *fw = fw_info->fw;
u32 dest, *p_cache;
- u64 addr;
+ int i, ret = -EIO;
u8 data[16];
size_t size;
- int i, ret = -EIO;
+ u64 addr;
dest = QLCRDX(adapter->ahw, QLCNIC_FW_IMAGE_ADDR);
- size = (adapter->ahw->fw_info.fw->size & ~0xF);
- p_cache = (u32 *)adapter->ahw->fw_info.fw->data;
+ size = (fw->size & ~0xF);
+ p_cache = (u32 *)fw->data;
addr = (u64)dest;
ret = qlcnic_83xx_ms_mem_write128(adapter, addr,
(u32 *)p_cache, size / 16);
if (ret) {
dev_err(&adapter->pdev->dev, "MS memory write failed\n");
- release_firmware(adapter->ahw->fw_info.fw);
- adapter->ahw->fw_info.fw = NULL;
+ release_firmware(fw);
+ fw_info->fw = NULL;
return -EIO;
}
/* alignment check */
- if (adapter->ahw->fw_info.fw->size & 0xF) {
+ if (fw->size & 0xF) {
addr = dest + size;
- for (i = 0; i < (adapter->ahw->fw_info.fw->size & 0xF); i++)
- data[i] = adapter->ahw->fw_info.fw->data[size + i];
+ for (i = 0; i < (fw->size & 0xF); i++)
+ data[i] = fw->data[size + i];
for (; i < 16; i++)
data[i] = 0;
ret = qlcnic_83xx_ms_mem_write128(adapter, addr,
@@ -1299,13 +1301,13 @@ static int qlcnic_83xx_copy_fw_file(struct qlcnic_adapter *adapter)
if (ret) {
dev_err(&adapter->pdev->dev,
"MS memory write failed\n");
- release_firmware(adapter->ahw->fw_info.fw);
- adapter->ahw->fw_info.fw = NULL;
+ release_firmware(fw);
+ fw_info->fw = NULL;
return -EIO;
}
}
- release_firmware(adapter->ahw->fw_info.fw);
- adapter->ahw->fw_info.fw = NULL;
+ release_firmware(fw);
+ fw_info->fw = NULL;
return 0;
}
@@ -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__);
}
-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)
{
- char fw_file_name[QLC_FW_FILE_NAME_LEN];
+ struct qlc_83xx_fw_info *fw_info = adapter->ahw->fw_info;
int err = -EIO;
- qlcnic_83xx_get_fw_file_name(adapter, fw_file_name);
- if (request_firmware(&adapter->ahw->fw_info.fw, fw_file_name,
+ if (request_firmware(&fw_info->fw, fw_info->fw_file_name,
&(adapter->pdev->dev))) {
dev_err(&adapter->pdev->dev,
"No file FW image, loading flash FW image.\n");
@@ -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)
{
struct qlcnic_hardware_context *ahw = adapter->ahw;
@@ -2198,10 +2210,14 @@ int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac)
if (!qlcnic_83xx_read_flash_descriptor_table(adapter))
qlcnic_83xx_read_flash_mfg_id(adapter);
- err = qlcnic_83xx_idc_init(adapter);
+ err = qlcnic_83xx_get_fw_info(adapter);
if (err)
goto detach_mbx;
+ err = qlcnic_83xx_idc_init(adapter);
+ if (err)
+ goto clear_fw_info;
+
err = qlcnic_setup_intr(adapter, 0, 0);
if (err) {
dev_err(&adapter->pdev->dev, "Failed to setup interrupt\n");
@@ -2242,6 +2258,9 @@ disable_mbx_intr:
disable_intr:
qlcnic_teardown_intr(adapter);
+clear_fw_info:
+ kfree(ahw->fw_info);
+
detach_mbx:
qlcnic_83xx_detach_mailbox_work(adapter);
qlcnic_83xx_free_mailbox(ahw->mailbox);
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 33dcb81..98d6a9d 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -2402,6 +2402,7 @@ static void qlcnic_remove(struct pci_dev *pdev)
qlcnic_83xx_free_mbx_intr(adapter);
qlcnic_83xx_detach_mailbox_work(adapter);
qlcnic_83xx_free_mailbox(ahw->mailbox);
+ kfree(ahw->fw_info);
}
qlcnic_detach(adapter);
--
1.5.6
next prev parent reply other threads:[~2013-08-30 18:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-30 17:51 [PATCH net-next 0/9] qlcnic: Enhancements and cleanup Shahed Shaikh
2013-08-30 17:51 ` [PATCH net-next 1/9] qlcnic: Enhance PVID handling for 84xx adapters Shahed Shaikh
2013-08-30 17:51 ` [PATCH net-next 2/9] qlcnic: Remove inline keyword Shahed Shaikh
2013-08-30 17:51 ` [PATCH net-next 3/9] qlcnic: Use firmware recommended dump capture mask as default Shahed Shaikh
2013-08-30 17:51 ` [PATCH net-next 4/9] qlcnic: Store firmware dump state in CAMRAM register Shahed Shaikh
2013-08-30 17:51 ` [PATCH net-next 5/9] qlcnic: Add AER callback handlers Shahed Shaikh
2013-08-30 17:51 ` [PATCH net-next 6/9] qlcnic: Add AER support for 83xx adapter Shahed Shaikh
2013-08-30 17:51 ` Shahed Shaikh [this message]
2013-08-30 17:51 ` [PATCH net-next 8/9] qlcnic: Add support for per port eswitch configuration Shahed Shaikh
2013-08-30 17:51 ` [PATCH net-next 9/9] qlcnic: Update version to 5.3.50 Shahed Shaikh
2013-09-01 2:35 ` [PATCH net-next 0/9] qlcnic: Enhancements and cleanup David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377885084-6441-8-git-send-email-shahed.shaikh@qlogic.com \
--to=shahed.shaikh@qlogic.com \
--cc=Dept-HSGLinuxNICDev@qlogic.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=pratik.pujar@qlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).