aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/bnx2x/bnx2x_cmn.c20
-rw-r--r--drivers/net/bnx2x/bnx2x_cmn.h9
-rw-r--r--drivers/net/bnx2x/bnx2x_main.c26
3 files changed, 36 insertions, 19 deletions
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index 02bf710629a3..da96d1a18c20 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -20,6 +20,7 @@
20#include <linux/ip.h> 20#include <linux/ip.h>
21#include <linux/ipv6.h> 21#include <linux/ipv6.h>
22#include <net/ip6_checksum.h> 22#include <net/ip6_checksum.h>
23#include <linux/firmware.h>
23#include "bnx2x_cmn.h" 24#include "bnx2x_cmn.h"
24 25
25#ifdef BCM_VLAN 26#ifdef BCM_VLAN
@@ -1206,12 +1207,27 @@ static int bnx2x_set_num_queues(struct bnx2x *bp)
1206 return rc; 1207 return rc;
1207} 1208}
1208 1209
1210static void bnx2x_release_firmware(struct bnx2x *bp)
1211{
1212 kfree(bp->init_ops_offsets);
1213 kfree(bp->init_ops);
1214 kfree(bp->init_data);
1215 release_firmware(bp->firmware);
1216}
1217
1209/* must be called with rtnl_lock */ 1218/* must be called with rtnl_lock */
1210int bnx2x_nic_load(struct bnx2x *bp, int load_mode) 1219int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
1211{ 1220{
1212 u32 load_code; 1221 u32 load_code;
1213 int i, rc; 1222 int i, rc;
1214 1223
1224 /* Set init arrays */
1225 rc = bnx2x_init_firmware(bp);
1226 if (rc) {
1227 BNX2X_ERR("Error loading firmware\n");
1228 return rc;
1229 }
1230
1215#ifdef BNX2X_STOP_ON_ERROR 1231#ifdef BNX2X_STOP_ON_ERROR
1216 if (unlikely(bp->panic)) 1232 if (unlikely(bp->panic))
1217 return -EPERM; 1233 return -EPERM;
@@ -1427,6 +1443,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
1427#endif 1443#endif
1428 bnx2x_inc_load_cnt(bp); 1444 bnx2x_inc_load_cnt(bp);
1429 1445
1446 bnx2x_release_firmware(bp);
1447
1430 return 0; 1448 return 0;
1431 1449
1432#ifdef BCM_CNIC 1450#ifdef BCM_CNIC
@@ -1454,6 +1472,8 @@ load_error1:
1454 netif_napi_del(&bnx2x_fp(bp, i, napi)); 1472 netif_napi_del(&bnx2x_fp(bp, i, napi));
1455 bnx2x_free_mem(bp); 1473 bnx2x_free_mem(bp);
1456 1474
1475 bnx2x_release_firmware(bp);
1476
1457 return rc; 1477 return rc;
1458} 1478}
1459 1479
diff --git a/drivers/net/bnx2x/bnx2x_cmn.h b/drivers/net/bnx2x/bnx2x_cmn.h
index d1979b1a7ed2..32543c32805c 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/bnx2x/bnx2x_cmn.h
@@ -115,6 +115,15 @@ void bnx2x_int_enable(struct bnx2x *bp);
115void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw); 115void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw);
116 116
117/** 117/**
118 * Loads device firmware
119 *
120 * @param bp
121 *
122 * @return int
123 */
124int bnx2x_init_firmware(struct bnx2x *bp);
125
126/**
118 * Init HW blocks according to current initialization stage: 127 * Init HW blocks according to current initialization stage:
119 * COMMON, PORT or FUNCTION. 128 * COMMON, PORT or FUNCTION.
120 * 129 *
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index b4ec2b02a465..13309f1717b9 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -7254,7 +7254,7 @@ static void __devinit bnx2x_get_pcie_width_speed(struct bnx2x *bp,
7254 *speed = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT; 7254 *speed = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT;
7255} 7255}
7256 7256
7257static int __devinit bnx2x_check_firmware(struct bnx2x *bp) 7257static int bnx2x_check_firmware(struct bnx2x *bp)
7258{ 7258{
7259 const struct firmware *firmware = bp->firmware; 7259 const struct firmware *firmware = bp->firmware;
7260 struct bnx2x_fw_file_hdr *fw_hdr; 7260 struct bnx2x_fw_file_hdr *fw_hdr;
@@ -7365,7 +7365,7 @@ do { \
7365 (u8 *)bp->arr, len); \ 7365 (u8 *)bp->arr, len); \
7366} while (0) 7366} while (0)
7367 7367
7368static int __devinit bnx2x_init_firmware(struct bnx2x *bp, struct device *dev) 7368int bnx2x_init_firmware(struct bnx2x *bp)
7369{ 7369{
7370 const char *fw_file_name; 7370 const char *fw_file_name;
7371 struct bnx2x_fw_file_hdr *fw_hdr; 7371 struct bnx2x_fw_file_hdr *fw_hdr;
@@ -7376,21 +7376,21 @@ static int __devinit bnx2x_init_firmware(struct bnx2x *bp, struct device *dev)
7376 else if (CHIP_IS_E1H(bp)) 7376 else if (CHIP_IS_E1H(bp))
7377 fw_file_name = FW_FILE_NAME_E1H; 7377 fw_file_name = FW_FILE_NAME_E1H;
7378 else { 7378 else {
7379 dev_err(dev, "Unsupported chip revision\n"); 7379 BNX2X_ERR("Unsupported chip revision\n");
7380 return -EINVAL; 7380 return -EINVAL;
7381 } 7381 }
7382 7382
7383 dev_info(dev, "Loading %s\n", fw_file_name); 7383 BNX2X_DEV_INFO("Loading %s\n", fw_file_name);
7384 7384
7385 rc = request_firmware(&bp->firmware, fw_file_name, dev); 7385 rc = request_firmware(&bp->firmware, fw_file_name, &bp->pdev->dev);
7386 if (rc) { 7386 if (rc) {
7387 dev_err(dev, "Can't load firmware file %s\n", fw_file_name); 7387 BNX2X_ERR("Can't load firmware file %s\n", fw_file_name);
7388 goto request_firmware_exit; 7388 goto request_firmware_exit;
7389 } 7389 }
7390 7390
7391 rc = bnx2x_check_firmware(bp); 7391 rc = bnx2x_check_firmware(bp);
7392 if (rc) { 7392 if (rc) {
7393 dev_err(dev, "Corrupt firmware file %s\n", fw_file_name); 7393 BNX2X_ERR("Corrupt firmware file %s\n", fw_file_name);
7394 goto request_firmware_exit; 7394 goto request_firmware_exit;
7395 } 7395 }
7396 7396
@@ -7468,13 +7468,6 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
7468 if (rc) 7468 if (rc)
7469 goto init_one_exit; 7469 goto init_one_exit;
7470 7470
7471 /* Set init arrays */
7472 rc = bnx2x_init_firmware(bp, &pdev->dev);
7473 if (rc) {
7474 dev_err(&pdev->dev, "Error loading firmware\n");
7475 goto init_one_exit;
7476 }
7477
7478 rc = register_netdev(dev); 7471 rc = register_netdev(dev);
7479 if (rc) { 7472 if (rc) {
7480 dev_err(&pdev->dev, "Cannot register net device\n"); 7473 dev_err(&pdev->dev, "Cannot register net device\n");
@@ -7525,11 +7518,6 @@ static void __devexit bnx2x_remove_one(struct pci_dev *pdev)
7525 /* Make sure RESET task is not scheduled before continuing */ 7518 /* Make sure RESET task is not scheduled before continuing */
7526 cancel_delayed_work_sync(&bp->reset_task); 7519 cancel_delayed_work_sync(&bp->reset_task);
7527 7520
7528 kfree(bp->init_ops_offsets);
7529 kfree(bp->init_ops);
7530 kfree(bp->init_data);
7531 release_firmware(bp->firmware);
7532
7533 if (bp->regview) 7521 if (bp->regview)
7534 iounmap(bp->regview); 7522 iounmap(bp->regview);
7535 7523