LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2.6.21 2/4] cxgb3 - Auto-load FW if mismatch detected
@ 2007-03-18 20:10 divy
2007-03-21 22:07 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: divy @ 2007-03-18 20:10 UTC (permalink / raw)
To: jeff; +Cc: netdev, linux-kernel, swise
From: Divy Le Ray <divy@chelsio.com>
The driver attempts to upgrade the FW if the card has the wrong version.
Signed-off-by: Divy Le Ray <divy@chelsio.com>
---
---
drivers/net/Kconfig | 1 +
drivers/net/cxgb3/cxgb3_main.c | 25 +++++++++++++++++++++++++
drivers/net/cxgb3/t3_hw.c | 5 +++--
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 5ff0922..1b6459b 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2374,6 +2374,7 @@ config CHELSIO_T1_NAPI
config CHELSIO_T3
tristate "Chelsio Communications T3 10Gb Ethernet support"
depends on PCI
+ select FW_LOADER
help
This driver supports Chelsio T3-based gigabit and 10Gb Ethernet
adapters.
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index eb0a4e0..b9bcda8 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -42,6 +42,7 @@
#include <linux/workqueue.h>
#include <linux/proc_fs.h>
#include <linux/rtnetlink.h>
+#include <linux/firmware.h>
#include <asm/uaccess.h>
#include "common.h"
@@ -707,6 +708,28 @@ static void bind_qsets(struct adapter *a
}
}
+#define FW_FNAME "t3fw-%d.%d.bin"
+
+static int upgrade_fw(struct adapter *adap)
+{
+ int ret;
+ char buf[64];
+ const struct firmware *fw;
+ struct device *dev = &adap->pdev->dev;
+
+ snprintf(buf, sizeof(buf), FW_FNAME, FW_VERSION_MAJOR,
+ FW_VERSION_MINOR);
+ ret = request_firmware(&fw, buf, dev);
+ if (ret < 0) {
+ dev_err(dev, "could not upgrade firmware: unable to load %s\n",
+ buf);
+ return ret;
+ }
+ ret = t3_load_fw(adap, fw->data, fw->size);
+ release_firmware(fw);
+ return ret;
+}
+
/**
* cxgb_up - enable the adapter
* @adapter: adapter being enabled
@@ -723,6 +746,8 @@ static int cxgb_up(struct adapter *adap)
if (!(adap->flags & FULL_INIT_DONE)) {
err = t3_check_fw_version(adap);
+ if (err == -EINVAL)
+ err = upgrade_fw(adap);
if (err)
goto out;
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index eaa7a2e..983ee81 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -681,7 +681,8 @@ enum {
SF_ERASE_SECTOR = 0xd8, /* erase sector */
FW_FLASH_BOOT_ADDR = 0x70000, /* start address of FW in flash */
- FW_VERS_ADDR = 0x77ffc /* flash address holding FW version */
+ FW_VERS_ADDR = 0x77ffc, /* flash address holding FW version */
+ FW_MIN_SIZE = 8 /* at least version and csum */
};
/**
@@ -935,7 +936,7 @@ int t3_load_fw(struct adapter *adapter,
const u32 *p = (const u32 *)fw_data;
int ret, addr, fw_sector = FW_FLASH_BOOT_ADDR >> 16;
- if (size & 3)
+ if ((size & 3) || size < FW_MIN_SIZE)
return -EINVAL;
if (size > FW_VERS_ADDR + 8 - FW_FLASH_BOOT_ADDR)
return -EFBIG;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.21 2/4] cxgb3 - Auto-load FW if mismatch detected
2007-03-18 20:10 [PATCH 2.6.21 2/4] cxgb3 - Auto-load FW if mismatch detected divy
@ 2007-03-21 22:07 ` Andrew Morton
2007-03-22 2:02 ` Divy Le Ray
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2007-03-21 22:07 UTC (permalink / raw)
To: divy; +Cc: jeff, netdev, linux-kernel, swise
On Sun, 18 Mar 2007 13:10:06 -0700
divy@chelsio.com wrote:
> config CHELSIO_T3
> tristate "Chelsio Communications T3 10Gb Ethernet support"
> depends on PCI
> + select FW_LOADER
Something has gone wrong with the indenting there.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.21 2/4] cxgb3 - Auto-load FW if mismatch detected
2007-03-21 22:07 ` Andrew Morton
@ 2007-03-22 2:02 ` Divy Le Ray
0 siblings, 0 replies; 3+ messages in thread
From: Divy Le Ray @ 2007-03-22 2:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: jeff, netdev, linux-kernel, swise
Andrew Morton wrote:
> On Sun, 18 Mar 2007 13:10:06 -0700
> divy@chelsio.com wrote:
>
>
>> config CHELSIO_T3
>> tristate "Chelsio Communications T3 10Gb Ethernet support"
>> depends on PCI
>> + select FW_LOADER
>>
>
> Something has gone wrong with the indenting there.
>
The added line is fine. The surrounding lines are not. They use white
spaces.
I'll send a patch over the last series to use tabs in drivers/net/Kconfig.
Cheers,
Divy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-22 2:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-18 20:10 [PATCH 2.6.21 2/4] cxgb3 - Auto-load FW if mismatch detected divy
2007-03-21 22:07 ` Andrew Morton
2007-03-22 2:02 ` Divy Le Ray
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).