* [PATCH] bna: Implement ethtool flash_device entry point.
@ 2012-02-02 1:02 kgudipat
2012-02-02 1:29 ` Ben Hutchings
0 siblings, 1 reply; 7+ messages in thread
From: kgudipat @ 2012-02-02 1:02 UTC (permalink / raw)
To: davem, netdev; +Cc: adapter_linux_open_src_team, kgudipat
From: Krishna Gudipati <kgudipat@brocade.com>
Incorporated review comments from Ben Hutchings.
Change details:
- Implement ethtool flash_device() entry point to write the
firmware image to the flash firmware partition.
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
---
drivers/net/ethernet/brocade/bna/bfa_defs.h | 1 +
drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 42 +++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs.h b/drivers/net/ethernet/brocade/bna/bfa_defs.h
index 871c630..48f8773 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs.h
@@ -297,6 +297,7 @@ enum bfa_mode {
#define BFA_FLASH_PART_ENTRY_SIZE 32 /* partition entry size */
#define BFA_FLASH_PART_MAX 32 /* maximal # of partitions */
#define BFA_TOTAL_FLASH_SIZE 0x400000
+#define BFA_FLASH_PART_FWIMG 2
#define BFA_FLASH_PART_MFG 7
/*
diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
index 9b44ec8..a27c601 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
@@ -1072,6 +1072,47 @@ done:
return ret;
}
+static int
+bnad_flash_device(struct net_device *netdev, struct ethtool_flash *eflash)
+{
+ struct bnad *bnad = netdev_priv(netdev);
+ struct bnad_iocmd_comp fcomp;
+ const struct firmware *fw;
+ int ret = 0;
+
+ ret = request_firmware(&fw, eflash->data, &bnad->pcidev->dev);
+ if (ret) {
+ pr_err("BNA: Can't locate firmware %s\n", eflash->data);
+ goto out;
+ }
+
+ fcomp.bnad = bnad;
+ fcomp.comp_status = 0;
+
+ init_completion(&fcomp.comp);
+ spin_lock_irq(&bnad->bna_lock);
+ ret = bfa_nw_flash_update_part(&bnad->bna.flash, BFA_FLASH_PART_FWIMG,
+ bnad->id, (u8 *)fw->data, fw->size, 0,
+ bnad_cb_completion, &fcomp);
+ if (ret != BFA_STATUS_OK) {
+ pr_warn("BNA: Flash update failed with err: %d\n", ret);
+ ret = -EIO;
+ spin_unlock_irq(&bnad->bna_lock);
+ goto out;
+ }
+
+ spin_unlock_irq(&bnad->bna_lock);
+ wait_for_completion(&fcomp.comp);
+ if (fcomp.comp_status != BFA_STATUS_OK) {
+ ret = -EIO;
+ pr_warn("BNA: Firmware image update to flash failed with: %d\n",
+ fcomp.comp_status);
+ }
+out:
+ release_firmware(fw);
+ return ret;
+}
+
static const struct ethtool_ops bnad_ethtool_ops = {
.get_settings = bnad_get_settings,
.set_settings = bnad_set_settings,
@@ -1090,6 +1131,7 @@ static const struct ethtool_ops bnad_ethtool_ops = {
.get_eeprom_len = bnad_get_eeprom_len,
.get_eeprom = bnad_get_eeprom,
.set_eeprom = bnad_set_eeprom,
+ .flash_device = bnad_flash_device,
};
void
--
1.7.3.rc1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] bna: Implement ethtool flash_device entry point.
2012-02-02 1:02 [PATCH] bna: Implement ethtool flash_device entry point kgudipat
@ 2012-02-02 1:29 ` Ben Hutchings
2012-02-02 4:13 ` David Miller
0 siblings, 1 reply; 7+ messages in thread
From: Ben Hutchings @ 2012-02-02 1:29 UTC (permalink / raw)
To: kgudipat; +Cc: davem, netdev, adapter_linux_open_src_team
On Wed, 2012-02-01 at 17:02 -0800, kgudipat@brocade.com wrote:
> From: Krishna Gudipati <kgudipat@brocade.com>
>
> Incorporated review comments from Ben Hutchings.
>
> Change details:
> - Implement ethtool flash_device() entry point to write the
> firmware image to the flash firmware partition.
>
> Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] bna: Implement ethtool flash_device entry point.
2012-02-02 1:29 ` Ben Hutchings
@ 2012-02-02 4:13 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2012-02-02 4:13 UTC (permalink / raw)
To: bhutchings; +Cc: kgudipat, netdev, adapter_linux_open_src_team
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Thu, 2 Feb 2012 01:29:54 +0000
> On Wed, 2012-02-01 at 17:02 -0800, kgudipat@brocade.com wrote:
>> From: Krishna Gudipati <kgudipat@brocade.com>
>>
>> Incorporated review comments from Ben Hutchings.
>>
>> Change details:
>> - Implement ethtool flash_device() entry point to write the
>> firmware image to the flash firmware partition.
>>
>> Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
> Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] bna: Implement ethtool flash_device entry point.
@ 2012-02-01 0:06 kgudipat
2012-02-01 19:14 ` Ben Hutchings
0 siblings, 1 reply; 7+ messages in thread
From: kgudipat @ 2012-02-01 0:06 UTC (permalink / raw)
To: davem, netdev; +Cc: adapter_linux_open_src_team, kgudipat
From: Krishna Gudipati <kgudipat@brocade.com>
Change details:
- Implement ethtool flash_device() entry point to write the
firmware image to the flash firmware partition.
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
---
drivers/net/ethernet/brocade/bna/bfa_defs.h | 1 +
drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 36 +++++++++++++++++++++++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs.h b/drivers/net/ethernet/brocade/bna/bfa_defs.h
index 871c630..48f8773 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs.h
@@ -297,6 +297,7 @@ enum bfa_mode {
#define BFA_FLASH_PART_ENTRY_SIZE 32 /* partition entry size */
#define BFA_FLASH_PART_MAX 32 /* maximal # of partitions */
#define BFA_TOTAL_FLASH_SIZE 0x400000
+#define BFA_FLASH_PART_FWIMG 2
#define BFA_FLASH_PART_MFG 7
/*
diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
index 9b44ec8..3e18ee7 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
@@ -1072,6 +1072,41 @@ done:
return ret;
}
+static int
+bnad_flash_device(struct net_device *netdev, struct ethtool_flash *eflash)
+{
+ struct bnad *bnad = netdev_priv(netdev);
+ struct bnad_iocmd_comp fcomp;
+ const struct firmware *fw;
+ unsigned long flags = 0;
+ int ret = 0;
+
+ if (request_firmware(&fw, eflash->data, &bnad->pcidev->dev)) {
+ pr_err("Can't locate firmware %s\n", eflash->data);
+ goto out;
+ }
+
+ fcomp.bnad = bnad;
+ fcomp.comp_status = 0;
+
+ init_completion(&fcomp.comp);
+ spin_lock_irqsave(&bnad->bna_lock, flags);
+ ret = bfa_nw_flash_update_part(&bnad->bna.flash, BFA_FLASH_PART_FWIMG,
+ bnad->id, (u8 *)fw->data, fw->size, 0,
+ bnad_cb_completion, &fcomp);
+ if (ret != BFA_STATUS_OK) {
+ spin_unlock_irqrestore(&bnad->bna_lock, flags);
+ goto out;
+ }
+
+ spin_unlock_irqrestore(&bnad->bna_lock, flags);
+ wait_for_completion(&fcomp.comp);
+ ret = fcomp.comp_status;
+out:
+ release_firmware(fw);
+ return ret;
+}
+
static const struct ethtool_ops bnad_ethtool_ops = {
.get_settings = bnad_get_settings,
.set_settings = bnad_set_settings,
@@ -1090,6 +1125,7 @@ static const struct ethtool_ops bnad_ethtool_ops = {
.get_eeprom_len = bnad_get_eeprom_len,
.get_eeprom = bnad_get_eeprom,
.set_eeprom = bnad_set_eeprom,
+ .flash_device = bnad_flash_device,
};
void
--
1.7.3.rc1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] bna: Implement ethtool flash_device entry point.
2012-02-01 0:06 kgudipat
@ 2012-02-01 19:14 ` Ben Hutchings
2012-02-01 22:10 ` Krishna Gudipati
0 siblings, 1 reply; 7+ messages in thread
From: Ben Hutchings @ 2012-02-01 19:14 UTC (permalink / raw)
To: kgudipat; +Cc: davem, netdev, adapter_linux_open_src_team
On Tue, 2012-01-31 at 16:06 -0800, kgudipat@brocade.com wrote:
> From: Krishna Gudipati <kgudipat@brocade.com>
>
> Change details:
> - Implement ethtool flash_device() entry point to write the
> firmware image to the flash firmware partition.
>
> Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
> ---
> drivers/net/ethernet/brocade/bna/bfa_defs.h | 1 +
> drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 36 +++++++++++++++++++++++
> 2 files changed, 37 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs.h b/drivers/net/ethernet/brocade/bna/bfa_defs.h
> index 871c630..48f8773 100644
> --- a/drivers/net/ethernet/brocade/bna/bfa_defs.h
> +++ b/drivers/net/ethernet/brocade/bna/bfa_defs.h
> @@ -297,6 +297,7 @@ enum bfa_mode {
> #define BFA_FLASH_PART_ENTRY_SIZE 32 /* partition entry size */
> #define BFA_FLASH_PART_MAX 32 /* maximal # of partitions */
> #define BFA_TOTAL_FLASH_SIZE 0x400000
> +#define BFA_FLASH_PART_FWIMG 2
> #define BFA_FLASH_PART_MFG 7
>
> /*
> diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
> index 9b44ec8..3e18ee7 100644
> --- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
> +++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
> @@ -1072,6 +1072,41 @@ done:
> return ret;
> }
>
> +static int
> +bnad_flash_device(struct net_device *netdev, struct ethtool_flash *eflash)
> +{
> + struct bnad *bnad = netdev_priv(netdev);
> + struct bnad_iocmd_comp fcomp;
> + const struct firmware *fw;
> + unsigned long flags = 0;
> + int ret = 0;
> +
> + if (request_firmware(&fw, eflash->data, &bnad->pcidev->dev)) {
> + pr_err("Can't locate firmware %s\n", eflash->data);
> + goto out;
This results in returning 0.
> + }
> +
> + fcomp.bnad = bnad;
> + fcomp.comp_status = 0;
> +
> + init_completion(&fcomp.comp);
> + spin_lock_irqsave(&bnad->bna_lock, flags);
No need to save flags, this is not called in IRQ context!
> + ret = bfa_nw_flash_update_part(&bnad->bna.flash, BFA_FLASH_PART_FWIMG,
> + bnad->id, (u8 *)fw->data, fw->size, 0,
> + bnad_cb_completion, &fcomp);
> + if (ret != BFA_STATUS_OK) {
> + spin_unlock_irqrestore(&bnad->bna_lock, flags);
> + goto out;
> + }
> +
> + spin_unlock_irqrestore(&bnad->bna_lock, flags);
> + wait_for_completion(&fcomp.comp);
> + ret = fcomp.comp_status;
> +out:
> + release_firmware(fw);
> + return ret;
It looks like the value of ret will be an enumerator from enum
bfa_status and not a Linux error code. In that case you need to convert
it before returning.
Ben.
> +}
> +
> static const struct ethtool_ops bnad_ethtool_ops = {
> .get_settings = bnad_get_settings,
> .set_settings = bnad_set_settings,
> @@ -1090,6 +1125,7 @@ static const struct ethtool_ops bnad_ethtool_ops = {
> .get_eeprom_len = bnad_get_eeprom_len,
> .get_eeprom = bnad_get_eeprom,
> .set_eeprom = bnad_set_eeprom,
> + .flash_device = bnad_flash_device,
> };
>
> void
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] bna: Implement ethtool flash_device entry point.
2012-02-01 19:14 ` Ben Hutchings
@ 2012-02-01 22:10 ` Krishna Gudipati
2012-02-01 22:17 ` Ben Hutchings
0 siblings, 1 reply; 7+ messages in thread
From: Krishna Gudipati @ 2012-02-01 22:10 UTC (permalink / raw)
To: 'Ben Hutchings'
Cc: 'davem@davemloft.net', 'netdev@vger.kernel.org',
Adapter Linux Open SRC Team
Thanks Ben for the review.
I am making the changes as per the review comments to return proper error code.
> + init_completion(&fcomp.comp);
> + spin_lock_irqsave(&bnad->bna_lock, flags);
No need to save flags, this is not called in IRQ context!
[Krishna]: bna_lock is used in Interrupt context as well, by using spin_lock_irq instead of
spin_lock_irqsave() - we will lose the state of the interrupts & will
unconditionally enable interrupts. We plan to stay with using spin_lock_irqsave()
as it's safe.
Thanks,
Krishna.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] bna: Implement ethtool flash_device entry point.
2012-02-01 22:10 ` Krishna Gudipati
@ 2012-02-01 22:17 ` Ben Hutchings
0 siblings, 0 replies; 7+ messages in thread
From: Ben Hutchings @ 2012-02-01 22:17 UTC (permalink / raw)
To: Krishna Gudipati
Cc: 'davem@davemloft.net', 'netdev@vger.kernel.org',
Adapter Linux Open SRC Team
On Wed, 2012-02-01 at 14:10 -0800, Krishna Gudipati wrote:
> Thanks Ben for the review.
>
> I am making the changes as per the review comments to return proper error code.
>
> > + init_completion(&fcomp.comp);
> > + spin_lock_irqsave(&bnad->bna_lock, flags);
>
> No need to save flags, this is not called in IRQ context!
>
> [Krishna]: bna_lock is used in Interrupt context as well, by using spin_lock_irq instead of
> spin_lock_irqsave() - we will lose the state of the interrupts & will
> unconditionally enable interrupts. We plan to stay with using spin_lock_irqsave()
> as it's safe.
bnad_flash_device() will be called in process context, therefore it is
correct to unconditionally enable interrupts. It is safe but odd to use
spin_lock_irqsave()/spin_lock_irqrestore() in such a function.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-02-02 4:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-02 1:02 [PATCH] bna: Implement ethtool flash_device entry point kgudipat
2012-02-02 1:29 ` Ben Hutchings
2012-02-02 4:13 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2012-02-01 0:06 kgudipat
2012-02-01 19:14 ` Ben Hutchings
2012-02-01 22:10 ` Krishna Gudipati
2012-02-01 22:17 ` Ben Hutchings
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).