2007-09-18 17:23:49

by Denys Vlasenko

[permalink] [raw]
Subject: bnx2 dirver's firmware images

Hi Michael,

In bnx2_fw.h I see the following:

static u32 bnx2_RXP_b06FwBss[(0x13dc/4) + 1] = { 0x0 };

static struct fw_info bnx2_rxp_fw_06 = {
...
.bss = bnx2_RXP_b06FwBss,
...
};

I grepped for the usage of .bss member (grepped for '[.>]bss[^_]')
and it is used only here:

if (fw->bss) {
int j;

for (j = 0; j < (fw->bss_len/4); j++, offset += 4) {
REG_WR_IND(bp, offset, fw->bss[j]);
}
}

If I understand it correctly, you read zero words one by one from
bnx2_RXP_b06FwBss and writing them into the card. This is very
suboptimal usage of nearly 5k of kernel unswappable memory.

Do you plan to fix it?

Do you have any plans to switch to request_firmware() interface,
which will allow you to avoid keeping firmware in unswappable kernel
memory and thus free ~80k?

$ size bnx2.o
text data bss dec hex filename
52255 81551 6360 140166 22386 bnx2.o
--
vda


2007-09-18 17:47:28

by Michael Chan

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tue, 2007-09-18 at 18:23 +0100, Denys Vlasenko wrote:
> Hi Michael,
>
> In bnx2_fw.h I see the following:
>
> static u32 bnx2_RXP_b06FwBss[(0x13dc/4) + 1] = { 0x0 };
>
> static struct fw_info bnx2_rxp_fw_06 = {
> ...
> .bss = bnx2_RXP_b06FwBss,
> ...
> };
>
> I grepped for the usage of .bss member (grepped for '[.>]bss[^_]')
> and it is used only here:
>
> if (fw->bss) {
> int j;
>
> for (j = 0; j < (fw->bss_len/4); j++, offset += 4) {
> REG_WR_IND(bp, offset, fw->bss[j]);
> }
> }
>
> If I understand it correctly, you read zero words one by one from
> bnx2_RXP_b06FwBss and writing them into the card. This is very
> suboptimal usage of nearly 5k of kernel unswappable memory.
>
> Do you plan to fix it?

We can compress all the different sections of the firmware. Currently,
we only compress the biggest chunks and the rest are uncompressed.
These zeros should compress to almost nothing. But I agree that the
firmware is still big.

>
> Do you have any plans to switch to request_firmware() interface,
> which will allow you to avoid keeping firmware in unswappable kernel
> memory and thus free ~80k?

Matching the correct version of the firmware with the driver is the main
issue.

David, what's your opinion on this?

>
> $ size bnx2.o
> text data bss dec hex filename
> 52255 81551 6360 140166 22386 bnx2.o
> --
> vda
>

2007-09-18 17:56:15

by Denys Vlasenko

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tuesday 18 September 2007 19:45, Michael Chan wrote:
> We can compress all the different sections of the firmware. Currently,
> we only compress the biggest chunks and the rest are uncompressed.

> These zeros should compress to almost nothing. But I agree that the
> firmware is still big.

You don't need to store and fetch zeros at all. You *know* that
they are zeros, right? So do this:

- REG_WR_IND(bp, offset, fw->bss[j]);
+ REG_WR_IND(bp, offset, 0);

--
vda

2007-09-18 18:12:41

by Michael Chan

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tue, 2007-09-18 at 18:55 +0100, Denys Vlasenko wrote:
> On Tuesday 18 September 2007 19:45, Michael Chan wrote:
> > We can compress all the different sections of the firmware. Currently,
> > we only compress the biggest chunks and the rest are uncompressed.
>
> > These zeros should compress to almost nothing. But I agree that the
> > firmware is still big.
>
> You don't need to store and fetch zeros at all. You *know* that
> they are zeros, right? So do this:
>
> - REG_WR_IND(bp, offset, fw->bss[j]);
> + REG_WR_IND(bp, offset, 0);
>
Good point. We can do that. Looking at the file, there are other non-
zero data that can be compressed to save some more room.

2007-09-18 18:23:55

by David Miller

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

From: "Michael Chan" <[email protected]>
Date: Tue, 18 Sep 2007 11:45:14 -0700

> On Tue, 2007-09-18 at 18:23 +0100, Denys Vlasenko wrote:
> > Do you have any plans to switch to request_firmware() interface,
> > which will allow you to avoid keeping firmware in unswappable kernel
> > memory and thus free ~80k?
>
> Matching the correct version of the firmware with the driver is the main
> issue.
>
> David, what's your opinion on this?

I don't like it because it means people have to setup full initrd's
in order to do network booting with such network cards.

But the days of my opinion mattering on that issue are long gone,
the momentum is just too greatly behind using request_firmware()
across the board, so there is no reason for bnx2 to be any different.

2007-09-18 18:42:01

by H. Peter Anvin

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

David Miller wrote:
>
> I don't like it because it means people have to setup full initrd's
> in order to do network booting with such network cards.
>

klibc could help with that, if there is interest in exploring that
avenue again.

-hpa

2007-09-18 19:08:18

by Michael Chan

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tue, 2007-09-18 at 11:23 -0700, David Miller wrote:

> I don't like it because it means people have to setup full initrd's
> in order to do network booting with such network cards.
>
> But the days of my opinion mattering on that issue are long gone,
> the momentum is just too greatly behind using request_firmware()
> across the board, so there is no reason for bnx2 to be any different.
>

The bnx2 firmware changes quite frequently. A new driver quite often
requires new firmware to work correctly. Splitting them up makes things
difficult for the user.

The firmware in tg3 is a lot more mature and I don't expect it to
change. I think tg3 is better suited for using request_firmware().

2007-09-18 19:21:42

by David Miller

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

From: "H. Peter Anvin" <[email protected]>
Date: Tue, 18 Sep 2007 11:41:34 -0700

> David Miller wrote:
> >
> > I don't like it because it means people have to setup full initrd's
> > in order to do network booting with such network cards.
> >
>
> klibc could help with that, if there is interest in exploring that
> avenue again.

I appreciate the effort you put into klibc and the offer to
make initrd's easier to build.

But the point is that the initrd shouldn't be necessary in the first
place. There becomes zero point in building these drivers statically
into the kernel, which many of us do specifically to avoid module
loading, initrds, and all that fuss. Because the driver is totally
crippled even though it's been fully built into the main kernel image.

I mean, it's so incredibly stupid and makes kernel development that
much more difficult.

Every new dependency, be it requiring initrd or something else,
is one more barrier added to kernel development.

I really pine for the days where everything was so simple, and initrd
and modules were the odd ball cases, most developers built everything
into their kernel image.

2007-09-18 19:22:17

by David Miller

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

From: "Michael Chan" <[email protected]>
Date: Tue, 18 Sep 2007 13:05:51 -0700

> The bnx2 firmware changes quite frequently. A new driver quite often
> requires new firmware to work correctly. Splitting them up makes things
> difficult for the user.
>
> The firmware in tg3 is a lot more mature and I don't expect it to
> change. I think tg3 is better suited for using request_firmware().

Like I said, I think neither should change and the driver should
be fully functional when built statically into the kernel.

:-)

2007-09-18 19:27:26

by H. Peter Anvin

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

David Miller wrote:
> From: "H. Peter Anvin" <[email protected]>
> Date: Tue, 18 Sep 2007 11:41:34 -0700
>
>> David Miller wrote:
>>> I don't like it because it means people have to setup full initrd's
>>> in order to do network booting with such network cards.
>>>
>> klibc could help with that, if there is interest in exploring that
>> avenue again.
>
> I appreciate the effort you put into klibc and the offer to
> make initrd's easier to build.
>
> But the point is that the initrd shouldn't be necessary in the first
> place. There becomes zero point in building these drivers statically
> into the kernel, which many of us do specifically to avoid module
> loading, initrds, and all that fuss. Because the driver is totally
> crippled even though it's been fully built into the main kernel image.
>
> I mean, it's so incredibly stupid and makes kernel development that
> much more difficult.
>
> Every new dependency, be it requiring initrd or something else,
> is one more barrier added to kernel development.
>
> I really pine for the days where everything was so simple, and initrd
> and modules were the odd ball cases, most developers built everything
> into their kernel image.

Well, what I was referring to here, of course, was the initramfs
integrated in the kernel image, so it all comes out of the kernel build
tree and produces a single bootable image. The fact that part of it
contains userspace code is in that way invisible.

That was kind of the point here, and the only reason for pushing klibc
into the kernel build tree at all. Under the "distros use external
initrd anyway" school of thought, whatever libc used for that can be
external anyway.

-hpa

2007-09-18 20:08:23

by David Miller

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

From: "H. Peter Anvin" <[email protected]>
Date: Tue, 18 Sep 2007 12:27:04 -0700

> Well, what I was referring to here, of course, was the initramfs
> integrated in the kernel image, so it all comes out of the kernel build
> tree and produces a single bootable image. The fact that part of it
> contains userspace code is in that way invisible.
>
> That was kind of the point here, and the only reason for pushing klibc
> into the kernel build tree at all. Under the "distros use external
> initrd anyway" school of thought, whatever libc used for that can be
> external anyway.

Sounds good to me :)

2007-09-18 20:34:19

by Sam Ravnborg

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tue, Sep 18, 2007 at 01:08:10PM -0700, David Miller wrote:
> From: "H. Peter Anvin" <[email protected]>
> Date: Tue, 18 Sep 2007 12:27:04 -0700
>
> > Well, what I was referring to here, of course, was the initramfs
> > integrated in the kernel image, so it all comes out of the kernel build
> > tree and produces a single bootable image. The fact that part of it
> > contains userspace code is in that way invisible.
> >
> > That was kind of the point here, and the only reason for pushing klibc
> > into the kernel build tree at all. Under the "distros use external
> > initrd anyway" school of thought, whatever libc used for that can be
> > external anyway.
>
> Sounds good to me :)

Except there seems to be great resistance to include userland code in the
kernel as demonstrated at last KS. Or this is maybe just a single vocal
person and the topic were brought up late?

Anyway - if we again consider klibc I will do my best to make the
build stuff as smooth as possible.

Sam

2007-09-18 20:41:23

by H. Peter Anvin

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

Sam Ravnborg wrote:
>
> Except there seems to be great resistance to include userland code in the
> kernel as demonstrated at last KS. Or this is maybe just a single vocal
> person and the topic were brought up late?
>
> Anyway - if we again consider klibc I will do my best to make the
> build stuff as smooth as possible.
>

At least as of the last merged tree it was very smooth indeed, thanks to
your help.

-hpa

2007-09-18 21:30:45

by Willy Tarreau

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tue, Sep 18, 2007 at 12:21:50PM -0700, David Miller wrote:
> From: "Michael Chan" <[email protected]>
> Date: Tue, 18 Sep 2007 13:05:51 -0700
>
> > The bnx2 firmware changes quite frequently. A new driver quite often
> > requires new firmware to work correctly. Splitting them up makes things
> > difficult for the user.
> >
> > The firmware in tg3 is a lot more mature and I don't expect it to
> > change. I think tg3 is better suited for using request_firmware().
>
> Like I said, I think neither should change and the driver should
> be fully functional when built statically into the kernel.

Michael, doesn't a functional-yet-suboptimal firmware exist ? I mean,
just the same principle as we all have kernels, boot CDs, statically
built tools, etc... which run everywhere. If you have such a beast,
maybe it would be a good start to have it in the kernel, and provide
the users with the ability to upgrade the firmware once the system
is able to do more complex things.

Just a thought...

Regards,
Willy

2007-09-18 21:37:57

by Willy Tarreau

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tue, Sep 18, 2007 at 02:31:34PM -0700, David Miller wrote:
> From: Willy Tarreau <[email protected]>
> Date: Tue, 18 Sep 2007 23:30:25 +0200
>
> > On Tue, Sep 18, 2007 at 12:21:50PM -0700, David Miller wrote:
> > > From: "Michael Chan" <[email protected]>
> > > Date: Tue, 18 Sep 2007 13:05:51 -0700
> > >
> > > > The bnx2 firmware changes quite frequently. A new driver quite often
> > > > requires new firmware to work correctly. Splitting them up makes things
> > > > difficult for the user.
> > > >
> > > > The firmware in tg3 is a lot more mature and I don't expect it to
> > > > change. I think tg3 is better suited for using request_firmware().
> > >
> > > Like I said, I think neither should change and the driver should
> > > be fully functional when built statically into the kernel.
> >
> > Michael, doesn't a functional-yet-suboptimal firmware exist ? I mean,
> > just the same principle as we all have kernels, boot CDs, statically
> > built tools, etc... which run everywhere. If you have such a beast,
> > maybe it would be a good start to have it in the kernel, and provide
> > the users with the ability to upgrade the firmware once the system
> > is able to do more complex things.
> >
> > Just a thought...
>
> So let's save 60K instead of 80K.

That's not for this reason I said this. Michael said the firmware needs
to be updated somewhat often. What I was wondering was if it was not
possible to stick to a stable one (and hopefully small) so that the
driver could require less frequent updates. Sorry if it's not the main
point of the discussion, but I grepped on this :-)

> I mean, the entire discussion is just plain silly :)

yes, possibly :-)

Cheers,
Willy

2007-09-18 22:11:19

by David Miller

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

From: Willy Tarreau <[email protected]>
Date: Tue, 18 Sep 2007 23:30:25 +0200

> On Tue, Sep 18, 2007 at 12:21:50PM -0700, David Miller wrote:
> > From: "Michael Chan" <[email protected]>
> > Date: Tue, 18 Sep 2007 13:05:51 -0700
> >
> > > The bnx2 firmware changes quite frequently. A new driver quite often
> > > requires new firmware to work correctly. Splitting them up makes things
> > > difficult for the user.
> > >
> > > The firmware in tg3 is a lot more mature and I don't expect it to
> > > change. I think tg3 is better suited for using request_firmware().
> >
> > Like I said, I think neither should change and the driver should
> > be fully functional when built statically into the kernel.
>
> Michael, doesn't a functional-yet-suboptimal firmware exist ? I mean,
> just the same principle as we all have kernels, boot CDs, statically
> built tools, etc... which run everywhere. If you have such a beast,
> maybe it would be a good start to have it in the kernel, and provide
> the users with the ability to upgrade the firmware once the system
> is able to do more complex things.
>
> Just a thought...

So let's save 60K instead of 80K.

I mean, the entire discussion is just plain silly :)

2007-09-18 22:17:15

by Michael Chan

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tue, 2007-09-18 at 23:37 +0200, Willy Tarreau wrote:

> > > Michael, doesn't a functional-yet-suboptimal firmware exist ? I mean,
> > > just the same principle as we all have kernels, boot CDs, statically
> > > built tools, etc... which run everywhere. If you have such a beast,
> > > maybe it would be a good start to have it in the kernel, and provide
> > > the users with the ability to upgrade the firmware once the system
> > > is able to do more complex things.
> > >
> > > Just a thought...
> >
> > So let's save 60K instead of 80K.
>
> That's not for this reason I said this. Michael said the firmware needs
> to be updated somewhat often. What I was wondering was if it was not
> possible to stick to a stable one (and hopefully small) so that the
> driver could require less frequent updates. Sorry if it's not the main
> point of the discussion, but I grepped on this :-)
>

The bnx2 chip requires a lot of firmware to begin with, so it won't save
much space no matter what version is used in the kernel. We update the
firmware to fix bugs and sometimes to add new features. New features
often require matching changes in the driver. For example, we're
planning to add S/G support for jumbo rx frames and this requires
changes in both driver and firmware.

It's possible to make the driver work with multiple firmware versions,
but that adds complexity to enable/disable certain features. Testing
also becomes more difficult as it has to cover different combinations.


2007-09-19 08:31:10

by Denys Vlasenko

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tuesday 18 September 2007 21:05, Michael Chan wrote:
> The bnx2 firmware changes quite frequently. A new driver quite often
> requires new firmware to work correctly. Splitting them up makes things
> difficult for the user.

sounds reasonable.

I see that bnx2 has support for unpacking gzipped binary blobs,
and it it the only such net driver (maybe the only such driver
in the entire tree, I didn't check).

This can be very useful for all other firmware images in other drivers.

Last night I prepared a patch which basically separates unpacking
function from bnx2-related code. Can you run-test attached patch?

Meanwhile I will prepare follow-on patch which actually moves this
function out of the driver and into lib/*.

Size difference:

# size */bn*.o
text data bss dec hex filename
54884 81689 6424 142997 22e95 net/bnx2.o
55276 81823 6424 143523 230a3 net.org/bnx2.o

Signed-off-by: Denys Vlasenko <[email protected]>
--
vda


Attachments:
(No filename) (985.00 B)
linux-2.6.23-rc6.gunzip.patch (11.94 kB)
Download all attachments

2007-09-19 13:36:46

by Bill Davidsen

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

David Miller wrote:
> From: "Michael Chan" <[email protected]>
> Date: Tue, 18 Sep 2007 13:05:51 -0700
>
>> The bnx2 firmware changes quite frequently. A new driver quite often
>> requires new firmware to work correctly. Splitting them up makes things
>> difficult for the user.
>>
>> The firmware in tg3 is a lot more mature and I don't expect it to
>> change. I think tg3 is better suited for using request_firmware().
>
> Like I said, I think neither should change and the driver should
> be fully functional when built statically into the kernel.
>
Is that a suggestion that the driver work differently when built as a
module or built in? I've seen that behavior many time over the years,
but it usually not deliberate. ;-)

--
Bill Davidsen <[email protected]>
"We have more to fear from the bungling of the incompetent than from
the machinations of the wicked." - from Slashdot

2007-09-19 16:10:27

by David Miller

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

From: Bill Davidsen <[email protected]>
Date: Wed, 19 Sep 2007 09:40:14 -0400

> Is that a suggestion that the driver work differently when built as a
> module or built in?

Absolutely.

2007-09-19 16:33:33

by maximilian attems

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tue, 18 Sep 2007, Michael Chan wrote:

> The bnx2 firmware changes quite frequently. A new driver quite often
> requires new firmware to work correctly. Splitting them up makes things
> difficult for the user.

sorry didn't check, what's the license of the firmware?

> The firmware in tg3 is a lot more mature and I don't expect it to
> change. I think tg3 is better suited for using request_firmware().

well thanks that would help us a lot,
we have to strip the firmware for Debian for the upcoming Lenny release.
as the shipping exception for the previous 2 releases will not be granted
again. so a separate firmware would be great. also afaik only some boards
need it. it is a pressing need for us as tg3 with stripped firmware of
course doesn't build.

--
maks

2007-09-19 16:38:59

by David Miller

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

From: maximilian attems <[email protected]>
Date: Wed, 19 Sep 2007 18:33:18 +0200

> we have to strip the firmware for Debian for the upcoming Lenny release.

Why do you "have to"? The vendor has given you explicit rights
to distribute it:

* Firmware is:
* Derived from proprietary unpublished source code,
* Copyright (C) 2000-2003 Broadcom Corporation.
*
* Permission is hereby granted for the distribution of this firmware
* data in hexadecimal or equivalent format, provided this copyright
* notice is accompanying it.

This whole firmware stripping thing in debian is beyond rediculious
and only serves to hurt users.

2007-09-19 16:51:43

by maximilian attems

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

hello dave,

i appreciate a lot your opinon, but please cool down.
this is not a four spin on your beloved pipe. :)

On Wed, Sep 19, 2007 at 09:38:32AM -0700, David Miller wrote:
> From: maximilian attems <[email protected]>
> Date: Wed, 19 Sep 2007 18:33:18 +0200
>
> > we have to strip the firmware for Debian for the upcoming Lenny release.
>
> Why do you "have to"? The vendor has given you explicit rights
> to distribute it:
>
> * Firmware is:
> * Derived from proprietary unpublished source code,
> * Copyright (C) 2000-2003 Broadcom Corporation.
> *
> * Permission is hereby granted for the distribution of this firmware
> * data in hexadecimal or equivalent format, provided this copyright
> * notice is accompanying it.

afair the trouble is that it does not give permission to change
unlike some other gpl or bsd licensed blob.
so it is dfsg non-free and not suitable for main distribution.

> This whole firmware stripping thing in debian is beyond rediculious
> and only serves to hurt users.

i'm not of the d-legal department,
but seeing free firmwares would be cool.

--
maks

2007-09-19 17:10:46

by maximilian attems

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Tue, 18 Sep 2007, Sam Ravnborg wrote:

> Anyway - if we again consider klibc I will do my best to make the
> build stuff as smooth as possible.
>
> Sam

<nitpicking mode on>
currently klibc has tendency to rebuild a bit too much if you
touch some part of it, seen in usr/utils
for the main klibc i agree that it makes sense

--
maks

2007-09-19 17:13:28

by H. Peter Anvin

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

maximilian attems wrote:
> On Tue, 18 Sep 2007, Sam Ravnborg wrote:
>
>> Anyway - if we again consider klibc I will do my best to make the
>> build stuff as smooth as possible.
>>
>> Sam
>
> <nitpicking mode on>
> currently klibc has tendency to rebuild a bit too much if you
> touch some part of it, seen in usr/utils
> for the main klibc i agree that it makes sense
>

Could you give a concrete example?

-hpa

2007-09-19 17:18:57

by maximilian attems

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Wed, Sep 19, 2007 at 10:12:38AM -0700, H. Peter Anvin wrote:
>
> Could you give a concrete example?
>
> -hpa

max@dual:~/src/klibc$ touch usr/utils/mount_main.c
max@dual:~/src/klibc$ make
KLIBCCC usr/utils/mount_main.o
KLIBCLD usr/utils/static/halt
LN usr/utils/static/reboot
LN usr/utils/static/poweroff
KLIBCLD usr/utils/shared/halt
LN usr/utils/shared/reboot
LN usr/utils/shared/poweroff
KLIBCLD usr/utils/static/chroot
KLIBCLD usr/utils/static/dd
<snipp>

--
maks

2007-09-19 17:37:36

by Sam Ravnborg

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

Hi Maks.

On Wed, Sep 19, 2007 at 07:18:41PM +0200, maximilian attems wrote:
> On Wed, Sep 19, 2007 at 10:12:38AM -0700, H. Peter Anvin wrote:
> >
> > Could you give a concrete example?
> >
> > -hpa
>
> max@dual:~/src/klibc$ touch usr/utils/mount_main.c
> max@dual:~/src/klibc$ make
> KLIBCCC usr/utils/mount_main.o
> KLIBCLD usr/utils/static/halt
> LN usr/utils/static/reboot
> LN usr/utils/static/poweroff
> KLIBCLD usr/utils/shared/halt
> LN usr/utils/shared/reboot
> LN usr/utils/shared/poweroff
> KLIBCLD usr/utils/static/chroot
> KLIBCLD usr/utils/static/dd
> <snipp>

I do not recall the details at the moment but I recall I had to
do this tradeoff for some reasons.
I do not say it is not fixable but when I did the static-y support
I recall I took a shortcut or two under the assumption that everything
build by klibc was anyway so simple that compiling a bit too much was no harm.

Too buried with other stuff right now.
But feel free to poke me in roughly a month and I will take a deeper look.

Sam

2007-09-19 20:02:58

by Michael Chan

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Wed, 2007-09-19 at 09:30 +0100, Denys Vlasenko wrote:
+ /* gzip header (1f,8b,08... 10 bytes total + possible asciz filename)
+ * is stripped, 32-bit unpacked size (LE) is prepended instead */
+ sz = *zbuf++;
+ sz = (sz << 8) + *zbuf++;
+ sz = (sz << 8) + *zbuf++;
+ sz = (sz << 8) + *zbuf++;

I don't have a problem with removing the gzip header. It doesn't
contain very useful information other than a valid header for sanity
check. But I don't think we need to arbitrarily add the unpacked size
in front of the gzipped data. The driver knows the size (e.g. the size
of RAM on the chip) and should pass it to the call. The driver should
also allocate the memory for the unpacked data instead of allocating the
memory inside the call and freeing it by the caller. For example, the
driver may need to use pci_alloc_consistent() if the firmware is to be
DMA'ed to the chip.

Other than that, everything else looks fine. Thanks.

2007-09-19 20:29:44

by Denys Vlasenko

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Wednesday 19 September 2007 22:00, Michael Chan wrote:
> On Wed, 2007-09-19 at 09:30 +0100, Denys Vlasenko wrote:
> + /* gzip header (1f,8b,08... 10 bytes total + possible asciz filename)
> + * is stripped, 32-bit unpacked size (LE) is prepended instead */
> + sz = *zbuf++;
> + sz = (sz << 8) + *zbuf++;
> + sz = (sz << 8) + *zbuf++;
> + sz = (sz << 8) + *zbuf++;
>
> I don't have a problem with removing the gzip header. It doesn't
> contain very useful information other than a valid header for sanity
> check. But I don't think we need to arbitrarily add the unpacked size
> in front of the gzipped data. The driver knows the size (e.g. the size
> of RAM on the chip) and should pass it to the call. The driver should
> also allocate the memory for the unpacked data instead of allocating the
> memory inside the call and freeing it by the caller. For example, the
> driver may need to use pci_alloc_consistent() if the firmware is to be
> DMA'ed to the chip.
>
> Other than that, everything else looks fine. Thanks.

Are you saying that you successfully run-tested it?
--
vda

2007-09-19 20:46:26

by Michael Chan

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Wed, 2007-09-19 at 21:29 +0100, Denys Vlasenko wrote:

> Are you saying that you successfully run-tested it?

I've only reviewed the code. Let's resolve these issues first before
testing the code.

2007-09-20 14:49:31

by Denys Vlasenko

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Wednesday 19 September 2007 22:43, Michael Chan wrote:
> On Wed, 2007-09-19 at 21:29 +0100, Denys Vlasenko wrote:
>
> > Are you saying that you successfully run-tested it?
>
> I've only reviewed the code. Let's resolve these issues first before
> testing the code.

Please test these two patches.
I updated them according to your comments.
--
vda


Attachments:
(No filename) (353.00 B)
linux-2.6.23-rc6.bnx2-1.patch (12.16 kB)
linux-2.6.23-rc6.bnx2-2.patch (8.97 kB)
Download all attachments

2007-09-21 01:36:00

by Michael Chan

[permalink] [raw]
Subject: Re: bnx2 dirver's firmware images

On Thu, 2007-09-20 at 15:49 +0100, Denys Vlasenko wrote:
>
>
> Please test these two patches.
> I updated them according to your comments.
>
>

I've only tested patch #1. It worked after some minor modifications
below.

>
>
>
>
>
> plain text
> document
> attachment
> (linux-2.6.23-
> rc6.bnx2-1.patch)
>
>
> @@ -2767,89 +2769,44 @@ bnx2_set_rx_mode(struct net_device *dev)
> spin_unlock_bh(&bp->phy_lock);
> }
>
> -#define FW_BUF_SIZE 0x8000
> -
> +/* To be moved to generic lib/ */
> static int
> -bnx2_gunzip_init(struct bnx2 *bp)
> +bnx2_gunzip(void *gunzip_buf, unsigned sz, u8 *zbuf, int len, void **outbuf)

outbuf is no longer needed.

> + rc = zlib_inflateInit2(strm, -MAX_WBITS);
> + if (rc == Z_OK) {
> + rc = zlib_inflate(strm, Z_FINISH);
> + if (rc == Z_OK)

rc will always be Z_STREAM_END in this case since we provide a big
enough gunzip_buf for the whole blob.