From: Ben Hutchings <bhutchings@solarflare.com>
To: <kgudipat@brocade.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
<adapter_linux_open_src_team@brocade.com>
Subject: Re: [PATCH] bna: Implement ethtool flash_device entry point.
Date: Wed, 1 Feb 2012 19:14:47 +0000 [thread overview]
Message-ID: <1328123687.2541.10.camel@bwh-desktop> (raw)
In-Reply-To: <1328054801-11322-1-git-send-email-kgudipat@brocade.com>
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.
next prev parent reply other threads:[~2012-02-01 19:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-01 0:06 [PATCH] bna: Implement ethtool flash_device entry point kgudipat
2012-02-01 19:14 ` Ben Hutchings [this message]
2012-02-01 22:10 ` Krishna Gudipati
2012-02-01 22:17 ` Ben Hutchings
-- strict thread matches above, loose matches on Subject: below --
2012-02-02 1:02 kgudipat
2012-02-02 1:29 ` Ben Hutchings
2012-02-02 4:13 ` 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=1328123687.2541.10.camel@bwh-desktop \
--to=bhutchings@solarflare.com \
--cc=adapter_linux_open_src_team@brocade.com \
--cc=davem@davemloft.net \
--cc=kgudipat@brocade.com \
--cc=netdev@vger.kernel.org \
/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