Skip to contentSkip to conversation

libata: PATA driver for Celleb

PATCH In review Akira Iguchi 10 participants 38 messages Jan 26, 2007 – Feb 20, 2007 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libata: PATA driver for Celleb

Dear everyone.

Thank you for many useful comments.
This is the latest patchset for the PATA controller of Celleb.

This patchset consists of
[1] add another IRQ calls (core and headers)
[2] add another IRQ calls (libata drivers)
[3] PATA driver for Celleb

And patch[3] depends on patch[1,2].

This patchset is based on the Tejun's "devres" git tree, which is available at the followin URL.

http://htj.dyndns.org/git/?p=libata-tj.git;a=commit;h=efc6607aefe728b2721f6a0126bc527bc23eb46f

Best regards,
Akira Iguchi

#1 lore raw
Quoted 10 lines · Akira Iguchi

Dear everyone.

Thank you for many useful comments.
This is the latest patchset for the PATA controller of Celleb.

This patchset consists of
[1] add another IRQ calls (core and headers)
[2] add another IRQ calls (libata drivers)
[3] PATA driver for Celleb

Quoted 4 lines

And patch[3] depends on patch[1,2].

This patchset is based on the Tejun's "devres" git tree, which is available at the followin URL.

Everything looks great, thanks!

I'll apply this patchset immediately after applying Tejun's devres patchset.

Jeff

#2 lore raw

Hi, Jeff-san.

Quoted 6 lines
Quoted 5 lines · Jeff Garzik

This patchset consists of
[1] add another IRQ calls (core and headers)
[2] add another IRQ calls (libata drivers)
[3] PATA driver for Celleb

Quoted 9 lines
Quoted 4 lines

And patch[3] depends on patch[1,2].

This patchset is based on the Tejun's "devres" git tree, which is available at the followin URL.

Everything looks great, thanks!

I'll apply this patchset immediately after applying Tejun's devres patchset.

Thank you for applying some parts of my patches (patch[1,2]).
But it is my goal that this Celleb patch (patch[3]) is merged into your git tree. What's the status of this patch?

2.6.20 has been released and (I think) it is the time of merge-window for 2.6.21. I want this patch to be merged at this time. Please tell me if there are anything I should do.

Best regards,
Akira Iguchi

#3 lore raw
In reply to Jeff Garzik

Hi, Jeff-san.

Quoted 6 lines
Quoted 5 lines · Jeff Garzik

This patchset consists of
[1] add another IRQ calls (core and headers)
[2] add another IRQ calls (libata drivers)
[3] PATA driver for Celleb

Quoted 9 lines
Quoted 4 lines

And patch[3] depends on patch[1,2].

This patchset is based on the Tejun's "devres" git tree, which is available at the followin URL.

Everything looks great, thanks!

I'll apply this patchset immediately after applying Tejun's devres patchset.

Thank you for applying some parts of my patches (patch[1,2]).
But it is my goal that this Celleb patch (patch[3]) is merged into your git tree. What's the status of this patch?

2.6.20 has been released and (I think) it is the time of merge-window for 2.6.21. I want this patch to be merged at this time. Please tell me if there are anything I should do.

Best regards,
Akira Iguchi

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 4 lines

2.6.20 has been released and (I think) it is the time of merge-window for 2.6.21. I want this patch to be merged at this time. Please tell me if there are anything I should do.

FYI, Jeff, we have merged the rest of the celleb platform support in the 2.6.21 merge window, so it would be annoying if that didn't make it (that and some spidernet fixes).

Ben.

#6 lore raw
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 3 lines

2.6.20 has been released and (I think) it is the time of merge-window for 2.6.21. I want this patch to be merged at this time. Please tell me if there are anything I should do.

FYI, Jeff, we have merged the rest of the celleb platform support in the 2.6.21 merge window, so it would be annoying if that didn't make it

agreed, that's on the list to get pushed

Quoted 1 line

(that and some spidernet fixes).

I'm totally confused about who the heck is the spidernet maintainer. My inbox is pelted by spidernet driver updates from multiple people, and often the spidernet patches (regardless of author) receive comments that give me pause. The MAINTAINERS file says

Quoted 5 lines

SPIDERNET NETWORK DRIVER for CELL

P:      Jim Lewis
M:      [email protected]
L:      [email protected]
S:      Supported

but I do not see patch roll-ups or much activity from him at all. In practice, it seems like Linas does patchsets for spidernet, but there is also Jakob Osterkemp(sp?) and Ishizaki and....

My overall impression of spidernet development is that EVERYBODY is submitting patches at once, and expecting me to sort out the mess. No thanks.

Speaking with one voice would be much appreciated. And said speaker should patch the MAINTAINERS file to reflect reality.

Jeff

#7 lore raw
Quoted 2 lines

I'm totally confused about who the heck is the spidernet maintainer.

Me too :-)

Quoted 11 lines

My
inbox is pelted by spidernet driver updates from multiple people, and often the spidernet patches (regardless of author) receive comments that give me pause. The MAINTAINERS file says

Quoted 5 lines

SPIDERNET NETWORK DRIVER for CELL

P:      Jim Lewis
M:      [email protected]
L:      [email protected]
S:      Supported
Quoted 3 lines

but I do not see patch roll-ups or much activity from him at all. In practice, it seems like Linas does patchsets for spidernet, but there is also Jakob Osterkemp(sp?) and Ishizaki and....

I think Jens Osterkampf should be the final ACK/NAK'er as he has all the hardware to test except the Toshiba gear :-) In fact, Jens, if you are ok with that, I'd like to have you be the maintainer of that driver, unless you think it's better for Linas to do it.

Quoted 3 lines

My overall impression of spidernet development is that EVERYBODY is submitting patches at once, and expecting me to sort out the mess. No thanks.

It's been a bit of a mess. I suggest we get our gear together (Linas, Jens, Kou) and provide you a single patch set from a single source in the upcoming couple of days coming from the designated maintainer.

Jens ? Linas ? Is that ok with you guys ? Who gets to be that maintainer ?

_ALSO_ since spidernet uses (and modifies) sungem_phy.c, we need either DaveM or my ack there (DaveM is sungem maintainer but I wrote sungem_phy and most of it is only used on powermacs).

Thus let's move that back to the cbe-oss-dev mailing list, our designated maintainer will post there a candidate patch set, I will verify the sungem_phy change is ok with powermac (I myself haven't followed enough to figure out what patch is the latest there), we'll all test on our respective hardware, and then that maintainer will send you one patch set to apply.

That shouldn't take more than a few days. If we miss -rc1, well, then it will be in -rc2, as most of the patches have been around for long enough etc... it's really mostly a matter of getting our gear together.

Quoted 2 lines

Speaking with one voice would be much appreciated. And said speaker should patch the MAINTAINERS file to reflect reality.

Agreed,

Ben.

#8 lore raw
Quoted 47 lines · Benjamin Herrenschmidt
Quoted 2 lines

I'm totally confused about who the heck is the spidernet maintainer.

Me too :-)

Quoted 11 lines

My
inbox is pelted by spidernet driver updates from multiple people, and often the spidernet patches (regardless of author) receive comments that give me pause. The MAINTAINERS file says

Quoted 5 lines

SPIDERNET NETWORK DRIVER for CELL

P:      Jim Lewis
M:      [email protected]
L:      [email protected]
S:      Supported
Quoted 3 lines

but I do not see patch roll-ups or much activity from him at all. In practice, it seems like Linas does patchsets for spidernet, but there is also Jakob Osterkemp(sp?) and Ishizaki and....

I think Jens Osterkampf should be the final ACK/NAK'er as he has all the hardware to test except the Toshiba gear :-) In fact, Jens, if you are ok with that, I'd like to have you be the maintainer of that driver, unless you think it's better for Linas to do it.

Quoted 3 lines

My overall impression of spidernet development is that EVERYBODY is submitting patches at once, and expecting me to sort out the mess. No thanks.

It's been a bit of a mess. I suggest we get our gear together (Linas, Jens, Kou) and provide you a single patch set from a single source in the upcoming couple of days coming from the designated maintainer.

Jens ? Linas ? Is that ok with you guys ? Who gets to be that maintainer ?

_ALSO_ since spidernet uses (and modifies) sungem_phy.c, we need either DaveM or my ack there (DaveM is sungem maintainer but I wrote sungem_phy and most of it is only used on powermacs).

Thus let's move that back to the cbe-oss-dev mailing list, our designated maintainer will post there a candidate patch set, I will verify the sungem_phy change is ok with powermac (I myself haven't followed enough to figure out what patch is the latest there), we'll all test on our respective hardware, and then that maintainer will send you one patch set to apply.

Quoted 6 lines

That shouldn't take more than a few days. If we miss -rc1, well, then it will be in -rc2, as most of the patches have been around for long enough etc... it's really mostly a matter of getting our gear together.

Quoted 2 lines

Speaking with one voice would be much appreciated. And said speaker should patch the MAINTAINERS file to reflect reality.

Sounds reasonable. I fully agree.

Linas has done a pretty good job on improving the driver in the last half year or so and he also has access to all the necessary hardware so I think he would be the right person for the job.

Jens

#9 lore raw

We have had some discussions previously about Linas Vepstas taking over
the maintainership of Spidernet from me. I will look into this and see if we can make it happen.

Jim Lewis

Quoted 62 lines · Jens Osterkamp
Quoted 47 lines · Benjamin Herrenschmidt
Quoted 2 lines

I'm totally confused about who the heck is the spidernet maintainer.

Me too :-)

Quoted 11 lines

My
inbox is pelted by spidernet driver updates from multiple people, and often the spidernet patches (regardless of author) receive comments that give me pause. The MAINTAINERS file says

Quoted 5 lines

SPIDERNET NETWORK DRIVER for CELL

P:      Jim Lewis
M:      [email protected]
L:      [email protected]
S:      Supported
Quoted 3 lines

but I do not see patch roll-ups or much activity from him at all. In practice, it seems like Linas does patchsets for spidernet, but there is also Jakob Osterkemp(sp?) and Ishizaki and....

I think Jens Osterkampf should be the final ACK/NAK'er as he has all the hardware to test except the Toshiba gear :-) In fact, Jens, if you are ok with that, I'd like to have you be the maintainer of that driver, unless you think it's better for Linas to do it.

Quoted 3 lines

My overall impression of spidernet development is that EVERYBODY is submitting patches at once, and expecting me to sort out the mess. No thanks.

It's been a bit of a mess. I suggest we get our gear together (Linas, Jens, Kou) and provide you a single patch set from a single source in the upcoming couple of days coming from the designated maintainer.

Jens ? Linas ? Is that ok with you guys ? Who gets to be that maintainer ?

_ALSO_ since spidernet uses (and modifies) sungem_phy.c, we need either DaveM or my ack there (DaveM is sungem maintainer but I wrote sungem_phy and most of it is only used on powermacs).

Thus let's move that back to the cbe-oss-dev mailing list, our designated maintainer will post there a candidate patch set, I will verify the sungem_phy change is ok with powermac (I myself haven't followed enough to figure out what patch is the latest there), we'll all test on our respective hardware, and then that maintainer will send you one patch set to apply.

Quoted 6 lines

That shouldn't take more than a few days. If we miss -rc1, well, then it will be in -rc2, as most of the patches have been around for long enough etc... it's really mostly a matter of getting our gear together.

Quoted 2 lines

Speaking with one voice would be much appreciated. And said speaker should patch the MAINTAINERS file to reflect reality.

Sounds reasonable. I fully agree.

Linas has done a pretty good job on improving the driver in the last half year or so and he also has access to all the necessary hardware so I think he would be the right person for the job.

Jens

#10 lore raw
In reply to Jens Osterkamp
Quoted 8 lines · Jens Osterkamp
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 1 line

I'm totally confused about who the heck is the spidernet maintainer.

Me too :-)

It's been a bit of a mess. I suggest we get our gear together (Linas, Jens, Kou) and provide you a single patch set from a single source in the upcoming couple of days coming from the designated maintainer.

OK.

However, I think the blast of paches is a statistical anomoly, I'm expecting future activity on spidernet to drop to just about zero.

Quoted 6 lines
Quoted 2 lines

Jens ? Linas ? Is that ok with you guys ? Who gets to be that maintainer ?

Linas has done a pretty good job on improving the driver in the last half year or so and he also has access to all the necessary hardware so I think he would be the right person for the job.

It seems I've been nominated twice. Since I'm expecting future activity to drop to zero, how hard can this be? :-)

I can send a tested patch series (merging all three sources) immediately, assuming you like the tree these would be based on. Any special instructions or proceedures to follow, any secret initiation rites, hazing, or change of citizenship required?

--linas

#11 lore raw
Quoted 6 lines · Linas Vepstas
Quoted 3 lines

Linas has done a pretty good job on improving the driver in the last half year or so and he also has access to all the necessary hardware so I think he would be the right person for the job.

It seems I've been nominated twice. Since I'm expecting future activity to drop to zero, how hard can this be? :-)

I fear that the hardest part is yet to come, when we integrate the driver for the the PS3 (currently called gelic_net) into spidernet. The trouble is that the hardware is sufficiently similar to share all the high-level mechanisms like the DMA data structures and descriptor chains, but the low-level mechanisms are hidden in the hypervisor on the PS3. Someone will have to invest a significant amount of time coordinating this so we don't break celleb and qs20 in the process.

I also think that you'd do a good job doing this, but it may be more that what you are willing to do without official funding of the time you spend on it. Of course the actual amount of work will depend a lot on the quality of the spidernet patches coming from Sony to the spidernet maintainer.

	Arnd <><
#12 lore raw
Quoted 9 lines · Arnd Bergmann
Quoted 6 lines · Linas Vepstas
Quoted 3 lines

Linas has done a pretty good job on improving the driver in the last half year or so and he also has access to all the necessary hardware so I think he would be the right person for the job.

It seems I've been nominated twice. Since I'm expecting future activity to drop to zero, how hard can this be? :-)

I fear that the hardest part is yet to come,

Well, then, its a good thing I put a smiley face at the end of the sentence, eh?

Quoted 8 lines

when we integrate the
driver for the the PS3 (currently called gelic_net) into spidernet. The trouble is that the hardware is sufficiently similar to share all the high-level mechanisms like the DMA data structures and descriptor chains, but the low-level mechanisms are hidden in the hypervisor on the PS3. Someone will have to invest a significant amount of time coordinating this so we don't break celleb and qs20 in the process.

Since I've got the driver more or less memorized, I don't expect this to be an intellectual challenge. Which sometimes has the side effect of my getting bored, and dropping things on the floor.

Quoted 3 lines

I also think that you'd do a good job doing this, but it may be more that what you are willing to do without official funding of the time you spend on it.

(Ardnt knows that my spidernet work is "moonlighting", off-the-books work.) I'll ask my employer.

Quoted 3 lines

Of course the actual amount of work will
depend a lot on the quality of the spidernet patches coming from Sony to the spidernet maintainer.

I guess I'll have to ask my employer for a ps3 that I can do some "research" on.

--linas

#13 lore raw
In reply to Arnd Bergmann
Quoted 8 lines

I fear that the hardest part is yet to come, when we integrate the driver for the the PS3 (currently called gelic_net) into spidernet. The trouble is that the hardware is sufficiently similar to share all the high-level mechanisms like the DMA data structures and descriptor chains, but the low-level mechanisms are hidden in the hypervisor on the PS3. Someone will have to invest a significant amount of time coordinating this so we don't break celleb and qs20 in the process.

That to me implies they should be different drivers using a common libata-something file. The PPC mac drivers likewise are currently mashed into one in drivers/ide but really want splitting for libata with some kind of libata-pmac owning the shared stuff

Alan

#14 lore raw
Quoted 9 lines · Alan
Quoted 8 lines

I fear that the hardest part is yet to come, when we integrate the driver for the the PS3 (currently called gelic_net) into spidernet. The trouble is that the hardware is sufficiently similar to share all the high-level mechanisms like the DMA data structures and descriptor chains, but the low-level mechanisms are hidden in the hypervisor on the PS3. Someone will have to invest a significant amount of time coordinating this so we don't break celleb and qs20 in the process.

Quoted 4 lines

That to me implies they should be different drivers using a common libata-something file. The PPC mac drivers likewise are currently mashed into one in drivers/ide but really want splitting for libata with some kind of libata-pmac owning the shared stuff

You meand driver/ide/ppc/pmac.c ?

This driver is really for one family of IP blocks, the apple ones. They have the same DMA engine and same taskfile register layout, they only differ in the timning register format & timing abilities.

However, they also differ in probing mecanism because Apple has been moving them out of the macio_asic to a PCI device at one point, so yes, maybe you are right, I should move the DMA bits to some "common" file and split the various implementations.

Ben.

#15 lore raw
Quoted 4 lines
Quoted 2 lines

into one in drivers/ide but really want splitting for libata with some kind of libata-pmac owning the shared stuff

You meand driver/ide/ppc/pmac.c ?

Yes

Quoted 3 lines

moving them out of the macio_asic to a PCI device at one point, so yes, maybe you are right, I should move the DMA bits to some "common" file and split the various implementations.

I suspect it is worth doing when moving to libata at least, even if not for the older driver.

Alan

#16 lore raw
Quoted 5 lines · Alan
Quoted 4 lines
Quoted 2 lines

into one in drivers/ide but really want splitting for libata with some kind of libata-pmac owning the shared stuff

You meand driver/ide/ppc/pmac.c ?

Quoted 8 lines

Yes

Quoted 3 lines

moving them out of the macio_asic to a PCI device at one point, so yes, maybe you are right, I should move the DMA bits to some "common" file and split the various implementations.

I suspect it is worth doing when moving to libata at least, even if not for the older driver.

fully agreed, the way to go for both drivers

Bart

#17 lore raw
Quoted 8 lines · Bartlomiej Zolnierkiewicz
Quoted 7 lines · Alan
Quoted 4 lines
Quoted 2 lines

into one in drivers/ide but really want splitting for libata with some kind of libata-pmac owning the shared stuff

You meand driver/ide/ppc/pmac.c ?

Yes

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

moving them out of the macio_asic to a PCI device at one point, so yes, maybe you are right, I should move the DMA bits to some "common" file and split the various implementations.

I suspect it is worth doing when moving to libata at least, even if not for the older driver.

fully agreed, the way to go for both drivers

I don't think it's worth touching the drivers/ide version.

Ben.

#18 lore raw
In reply to Alan
Quoted 5 lines · Alan
Quoted 4 lines
Quoted 2 lines

into one in drivers/ide but really want splitting for libata with some kind of libata-pmac owning the shared stuff

You meand driver/ide/ppc/pmac.c ?

Quoted 8 lines

Yes

Quoted 3 lines

moving them out of the macio_asic to a PCI device at one point, so yes, maybe you are right, I should move the DMA bits to some "common" file and split the various implementations.

I suspect it is worth doing when moving to libata at least, even if not for the older driver.

Yup. I don't when I'll have time to "libataify" it though. I need to look into the best way of handling hotplug with the mediabay for that. The current hacks are only really suitable for drivers/ide

Ben.

#19 lore raw
In reply to Alan
Quoted 9 lines · Alan
Quoted 8 lines

I fear that the hardest part is yet to come, when we integrate the driver for the the PS3 (currently called gelic_net) into spidernet. The trouble is that the hardware is sufficiently similar to share all the high-level mechanisms like the DMA data structures and descriptor chains, but the low-level mechanisms are hidden in the hypervisor on the PS3. Someone will have to invest a significant amount of time coordinating this so we don't break celleb and qs20 in the process.

Quoted 4 lines

That to me implies they should be different drivers using a common libata-something file. The PPC mac drivers likewise are currently mashed into one in drivers/ide but really want splitting for libata with some kind of libata-pmac owning the shared stuff

Also note that for spidernet vs. gelic, I'm actually very tempted to keep them as separate drivers.

Ben.

#20 lore raw
In reply to Alan
Quoted 9 lines · Alan
Quoted 8 lines

I fear that the hardest part is yet to come, when we integrate the driver for the the PS3 (currently called gelic_net) into spidernet. The trouble is that the hardware is sufficiently similar to share all the high-level mechanisms like the DMA data structures and descriptor chains, but the low-level mechanisms are hidden in the hypervisor on the PS3. Someone will have to invest a significant amount of time coordinating this so we don't break celleb and qs20 in the process.

Quoted 4 lines

That to me implies they should be different drivers using a common libata-something file. The PPC mac drivers likewise are currently mashed into one in drivers/ide but really want splitting for libata with some kind of libata-pmac owning the shared stuff

FYI, the gelic_net and spidernet drivers Arnd was talking about are _Ethernet_ drivers, not (S)ATA drivers.

That's what happens to the casual reader when the email subjects no longer match ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE) [email protected] ------- The Corporate Village, Da Vincilaan 7-D1 Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium

#21 lore raw
In reply to Linas Vepstas
Quoted 5 lines

I can send a tested patch series (merging all three sources) immediately, assuming you like the tree these would be based on. Any special instructions or proceedures to follow, any secret initiation rites, hazing, or change of citizenship required?

Just send the blast to our list first so I can verify that the sungem_phy doesn't adversely affect sungem and everybody (especially Kou sine you dn't have the Toshiba hardware, do you ?) can verify it all works fine.

Cheers,
Ben

#22 lore raw

PATCH 1/1 spidernet, sungem_phy: consolidated patch series

Quoted 5 lines · Benjamin Herrenschmidt
Quoted 2 lines

I can send a tested patch series (merging all three sources)

Just send the blast to our list first so I can verify that the sungem_phy doesn't adversely affect sungem and everybody

By "our list", I assume you mean "[email protected]". I'm going to severely trim the cc list at this point, and send a patch series of 12 shortly. I'm going to pretend as if I was maintainer (formalities on this side pending) and attach a "signed-off-by" to each. Ben, it'll be up to you to go/no-go; if you say "go", I'll repost to eff Garzik (right?)

Quoted 3 lines

(especially Kou
sine you dn't have the Toshiba hardware, do you ?) can verify it all works fine.

I don't have Toshiba hardware. FWIW, I also don't have a ps3.

--linas

#23 lore raw

PATCH 1/12 : sungem_phy: support bcm5461 phy, autoneg.

This version moves the medium variable to the card specific structure and changes the GMII_* to BCM54XX_* #defines.

This patch adds improved version of enable_fiber for both the 5421 and the 5461 phy. It is now possible to specify with these wether you want autonegotiation or not. This is needed for bladecenter switches where some expect autonegotiation and some dont seem to like this at all. Depending on this flag it sets phy->autoneg accordingly for the fiber mode.

More importantly it implements proper read_link and poll_link functions for both phys which can handle both copper and fiber mode by determining the medium first and then branching to the required functions. For fiber they all work fine, for copper they are not tested but return the result of the genmii_* function anyway which is supposed to work.

The patch moves the genmii_* functions around to avoid foreward declarations.

----

 drivers/net/sungem_phy.c |  389 ++++++++++++++++++++++++++++++-----------------
 drivers/net/sungem_phy.h |   10 +
 2 files changed, 263 insertions(+), 136 deletions(-)
drivers/net/sungem_phy.c +254 -135
Index: linux-2.6.20-git4/drivers/net/sungem_phy.c
===================================================================
@@ -311,6 +311,107 @@ static int bcm5411_init(struct mii_phy* 
 	return 0;
 }
 
+static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise)
+{
+	u16 ctl, adv;
+
+	phy->autoneg = 1;
+	phy->speed = SPEED_10;
+	phy->duplex = DUPLEX_HALF;
+	phy->pause = 0;
+	phy->advertising = advertise;
+
+	/* Setup standard advertise */
+	adv = phy_read(phy, MII_ADVERTISE);
+	adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
+	if (advertise & ADVERTISED_10baseT_Half)
+		adv |= ADVERTISE_10HALF;
+	if (advertise & ADVERTISED_10baseT_Full)
+		adv |= ADVERTISE_10FULL;
+	if (advertise & ADVERTISED_100baseT_Half)
+		adv |= ADVERTISE_100HALF;
+	if (advertise & ADVERTISED_100baseT_Full)
+		adv |= ADVERTISE_100FULL;
+	phy_write(phy, MII_ADVERTISE, adv);
+
+	/* Start/Restart aneg */
+	ctl = phy_read(phy, MII_BMCR);
+	ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
+	phy_write(phy, MII_BMCR, ctl);
+
+	return 0;
+}
+
+static int genmii_setup_forced(struct mii_phy *phy, int speed, int fd)
+{
+	u16 ctl;
+
+	phy->autoneg = 0;
+	phy->speed = speed;
+	phy->duplex = fd;
+	phy->pause = 0;
+
+	ctl = phy_read(phy, MII_BMCR);
+	ctl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_ANENABLE);
+
+	/* First reset the PHY */
+	phy_write(phy, MII_BMCR, ctl | BMCR_RESET);
+
+	/* Select speed & duplex */
+	switch(speed) {
+	case SPEED_10:
+		break;
+	case SPEED_100:
+		ctl |= BMCR_SPEED100;
+		break;
+	case SPEED_1000:
+	default:
+		return -EINVAL;
+	}
+	if (fd == DUPLEX_FULL)
+		ctl |= BMCR_FULLDPLX;
+	phy_write(phy, MII_BMCR, ctl);
+
+	return 0;
+}
+
+static int genmii_poll_link(struct mii_phy *phy)
+{
+	u16 status;
+
+	(void)phy_read(phy, MII_BMSR);
+	status = phy_read(phy, MII_BMSR);
+	if ((status & BMSR_LSTATUS) == 0)
+		return 0;
+	if (phy->autoneg && !(status & BMSR_ANEGCOMPLETE))
+		return 0;
+	return 1;
+}
+
+static int genmii_read_link(struct mii_phy *phy)
+{
+	u16 lpa;
+
+	if (phy->autoneg) {
+		lpa = phy_read(phy, MII_LPA);
+
+		if (lpa & (LPA_10FULL | LPA_100FULL))
+			phy->duplex = DUPLEX_FULL;
+		else
+			phy->duplex = DUPLEX_HALF;
+		if (lpa & (LPA_100FULL | LPA_100HALF))
+			phy->speed = SPEED_100;
+		else
+			phy->speed = SPEED_10;
+		phy->pause = 0;
+	}
+	/* On non-aneg, we assume what we put in BMCR is the speed,
+	 * though magic-aneg shouldn't prevent this case from occurring
+	 */
+
+	 return 0;
+}
+
 static int generic_suspend(struct mii_phy* phy)
 {
 	phy_write(phy, MII_BMCR, BMCR_PDOWN);
@@ -365,30 +466,6 @@ static int bcm5421_init(struct mii_phy* 
 	return 0;
 }
 
-static int bcm5421_enable_fiber(struct mii_phy* phy)
-{
-	/* enable fiber mode */
-	phy_write(phy, MII_NCONFIG, 0x9020);
-	/* LEDs active in both modes, autosense prio = fiber */
-	phy_write(phy, MII_NCONFIG, 0x945f);
-
-	/* switch off fibre autoneg */
-	phy_write(phy, MII_NCONFIG, 0xfc01);
-	phy_write(phy, 0x0b, 0x0004);
-
-	return 0;
-}
-
-static int bcm5461_enable_fiber(struct mii_phy* phy)
-{
-	phy_write(phy, MII_NCONFIG, 0xfc0c);
-	phy_write(phy, MII_BMCR, 0x4140);
-	phy_write(phy, MII_NCONFIG, 0xfc0b);
-	phy_write(phy, MII_BMCR, 0x0140);
-
-	return 0;
-}
-
 static int bcm54xx_setup_aneg(struct mii_phy *phy, u32 advertise)
 {
 	u16 ctl, adv;
@@ -516,6 +593,155 @@ static int marvell88e1111_init(struct mi
 	return 0;
 }
 
+#define BCM5421_MODE_MASK	(1 << 5)
+
+static int bcm5421_poll_link(struct mii_phy* phy)
+{
+	u32 phy_reg;
+	int mode;
+
+	/* find out in what mode we are */
+	phy_write(phy, MII_NCONFIG, 0x1000);
+	phy_reg = phy_read(phy, MII_NCONFIG);
+
+	mode = (phy_reg & BCM5421_MODE_MASK) >> 5;
+
+	if ( mode == BCM54XX_COPPER)
+		return genmii_poll_link(phy);
+
+	/* try to find out wether we have a link */
+	phy_write(phy, MII_NCONFIG, 0x2000);
+	phy_reg = phy_read(phy, MII_NCONFIG);
+
+	if (phy_reg & 0x0020)
+		return 0;
+	else
+		return 1;
+}
+
+static int bcm5421_read_link(struct mii_phy* phy)
+{
+	u32 phy_reg;
+	int mode;
+
+	/* find out in what mode we are */
+	phy_write(phy, MII_NCONFIG, 0x1000);
+	phy_reg = phy_read(phy, MII_NCONFIG);
+
+	mode = (phy_reg & BCM5421_MODE_MASK ) >> 5;
+
+	if ( mode == BCM54XX_COPPER)
+		return bcm54xx_read_link(phy);
+
+	phy->speed = SPEED_1000;
+
+	/* find out wether we are running half- or full duplex */
+	phy_write(phy, MII_NCONFIG, 0x2000);
+	phy_reg = phy_read(phy, MII_NCONFIG);
+
+	if ( (phy_reg & 0x0080) >> 7)
+		phy->duplex |=  DUPLEX_HALF;
+	else
+		phy->duplex |=  DUPLEX_FULL;
+
+	return 0;
+}
+
+static int bcm5421_enable_fiber(struct mii_phy* phy, int autoneg)
+{
+	/* enable fiber mode */
+	phy_write(phy, MII_NCONFIG, 0x9020);
+	/* LEDs active in both modes, autosense prio = fiber */
+	phy_write(phy, MII_NCONFIG, 0x945f);
+
+	if (!autoneg) {
+		/* switch off fibre autoneg */
+		phy_write(phy, MII_NCONFIG, 0xfc01);
+		phy_write(phy, 0x0b, 0x0004);
+	}
+
+	phy->autoneg = autoneg;
+
+	return 0;
+}
+
+#define BCM5461_FIBER_LINK	(1 << 2)
+#define BCM5461_MODE_MASK	(3 << 1)
+
+static int bcm5461_poll_link(struct mii_phy* phy)
+{
+	u32 phy_reg;
+	int mode;
+
+	/* find out in what mode we are */
+	phy_write(phy, MII_NCONFIG, 0x7c00);
+	phy_reg = phy_read(phy, MII_NCONFIG);
+
+	mode = (phy_reg & BCM5461_MODE_MASK ) >> 1;
+
+	if ( mode == BCM54XX_COPPER)
+		return genmii_poll_link(phy);
+
+	/* find out wether we have a link */
+	phy_write(phy, MII_NCONFIG, 0x7000);
+	phy_reg = phy_read(phy, MII_NCONFIG);
+
+	if (phy_reg & BCM5461_FIBER_LINK)
+		return 1;
+	else
+		return 0;
+}
+
+#define BCM5461_FIBER_DUPLEX	(1 << 3)
+
+static int bcm5461_read_link(struct mii_phy* phy)
+{
+	u32 phy_reg;
+	int mode;
+
+	/* find out in what mode we are */
+	phy_write(phy, MII_NCONFIG, 0x7c00);
+	phy_reg = phy_read(phy, MII_NCONFIG);
+
+	mode = (phy_reg & BCM5461_MODE_MASK ) >> 1;
+
+	if ( mode == BCM54XX_COPPER) {
+		return bcm54xx_read_link(phy);
+	}
+
+	phy->speed = SPEED_1000;
+
+	/* find out wether we are running half- or full duplex */
+	phy_write(phy, MII_NCONFIG, 0x7000);
+	phy_reg = phy_read(phy, MII_NCONFIG);
+
+	if (phy_reg & BCM5461_FIBER_DUPLEX)
+		phy->duplex |=  DUPLEX_FULL;
+	else
+		phy->duplex |=  DUPLEX_HALF;
+
+	return 0;
+}
+
+static int bcm5461_enable_fiber(struct mii_phy* phy, int autoneg)
+{
+	/* select fiber mode, enable 1000 base-X registers */
+	phy_write(phy, MII_NCONFIG, 0xfc0b);
+
+	if (autoneg) {
+		/* enable fiber with no autonegotiation */
+		phy_write(phy, MII_ADVERTISE, 0x01e0);
+		phy_write(phy, MII_BMCR, 0x1140);
+	} else {
+		/* enable fiber with autonegotiation */
+		phy_write(phy, MII_BMCR, 0x0140);
+	}
+
+	phy->autoneg = autoneg;
+
+	return 0;
+}
+
 static int marvell_setup_aneg(struct mii_phy *phy, u32 advertise)
 {
 	u16 ctl, adv;
@@ -646,113 +872,6 @@ static int marvell_read_link(struct mii_
 	return 0;
 }
 
-static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise)
-{
-	u16 ctl, adv;
-
-	phy->autoneg = 1;
-	phy->speed = SPEED_10;
-	phy->duplex = DUPLEX_HALF;
-	phy->pause = 0;
-	phy->advertising = advertise;
-
-	/* Setup standard advertise */
-	adv = phy_read(phy, MII_ADVERTISE);
-	adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
-	if (advertise & ADVERTISED_10baseT_Half)
-		adv |= ADVERTISE_10HALF;
-	if (advertise & ADVERTISED_10baseT_Full)
-		adv |= ADVERTISE_10FULL;
-	if (advertise & ADVERTISED_100baseT_Half)
-		adv |= ADVERTISE_100HALF;
-	if (advertise & ADVERTISED_100baseT_Full)
-		adv |= ADVERTISE_100FULL;
-	if (advertise & ADVERTISED_Pause)
-		adv |= ADVERTISE_PAUSE_CAP;
-	if (advertise & ADVERTISED_Asym_Pause)
-		adv |= ADVERTISE_PAUSE_ASYM;
-	phy_write(phy, MII_ADVERTISE, adv);
-
-	/* Start/Restart aneg */
-	ctl = phy_read(phy, MII_BMCR);
-	ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
-	phy_write(phy, MII_BMCR, ctl);
-
-	return 0;
-}
-
-static int genmii_setup_forced(struct mii_phy *phy, int speed, int fd)
-{
-	u16 ctl;
-
-	phy->autoneg = 0;
-	phy->speed = speed;
-	phy->duplex = fd;
-	phy->pause = 0;
-
-	ctl = phy_read(phy, MII_BMCR);
-	ctl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_ANENABLE);
-
-	/* First reset the PHY */
-	phy_write(phy, MII_BMCR, ctl | BMCR_RESET);
-
-	/* Select speed & duplex */
-	switch(speed) {
-	case SPEED_10:
-		break;
-	case SPEED_100:
-		ctl |= BMCR_SPEED100;
-		break;
-	case SPEED_1000:
-	default:
-		return -EINVAL;
-	}
-	if (fd == DUPLEX_FULL)
-		ctl |= BMCR_FULLDPLX;
-	phy_write(phy, MII_BMCR, ctl);
-
-	return 0;
-}
-
-static int genmii_poll_link(struct mii_phy *phy)
-{
-	u16 status;
-
-	(void)phy_read(phy, MII_BMSR);
-	status = phy_read(phy, MII_BMSR);
-	if ((status & BMSR_LSTATUS) == 0)
-		return 0;
-	if (phy->autoneg && !(status & BMSR_ANEGCOMPLETE))
-		return 0;
-	return 1;
-}
-
-static int genmii_read_link(struct mii_phy *phy)
-{
-	u16 lpa;
-
-	if (phy->autoneg) {
-		lpa = phy_read(phy, MII_LPA);
-
-		if (lpa & (LPA_10FULL | LPA_100FULL))
-			phy->duplex = DUPLEX_FULL;
-		else
-			phy->duplex = DUPLEX_HALF;
-		if (lpa & (LPA_100FULL | LPA_100HALF))
-			phy->speed = SPEED_100;
-		else
-			phy->speed = SPEED_10;
-		phy->pause = (phy->duplex == DUPLEX_FULL) &&
-			((lpa & LPA_PAUSE) != 0);
-	}
-	/* On non-aneg, we assume what we put in BMCR is the speed,
-	 * though magic-aneg shouldn't prevent this case from occurring
-	 */
-
-	 return 0;
-}
-
-
 #define MII_BASIC_FEATURES \
 	(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |	\
 	 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |	\
@@ -886,8 +1005,8 @@ static struct mii_phy_ops bcm5421_phy_op
 	.suspend	= generic_suspend,
 	.setup_aneg	= bcm54xx_setup_aneg,
 	.setup_forced	= bcm54xx_setup_forced,
-	.poll_link	= genmii_poll_link,
-	.read_link	= bcm54xx_read_link,
+	.poll_link	= bcm5421_poll_link,
+	.read_link	= bcm5421_read_link,
 	.enable_fiber   = bcm5421_enable_fiber,
 };
 
@@ -924,8 +1043,8 @@ static struct mii_phy_ops bcm5461_phy_op
 	.suspend	= generic_suspend,
 	.setup_aneg	= bcm54xx_setup_aneg,
 	.setup_forced	= bcm54xx_setup_forced,
-	.poll_link	= genmii_poll_link,
-	.read_link	= bcm54xx_read_link,
+	.poll_link	= bcm5461_poll_link,
+	.read_link	= bcm5461_read_link,
 	.enable_fiber   = bcm5461_enable_fiber,
 };
 
drivers/net/sungem_phy.h +9 -1
Index: linux-2.6.20-git4/drivers/net/sungem_phy.h
===================================================================
@@ -12,7 +12,7 @@ struct mii_phy_ops
 	int		(*setup_forced)(struct mii_phy *phy, int speed, int fd);
 	int		(*poll_link)(struct mii_phy *phy);
 	int		(*read_link)(struct mii_phy *phy);
-	int		(*enable_fiber)(struct mii_phy *phy);
+	int		(*enable_fiber)(struct mii_phy *phy, int autoneg);
 };
 
 /* Structure used to statically define an mii/gii based PHY */
@@ -26,6 +26,14 @@ struct mii_phy_def
 	const struct mii_phy_ops*	ops;
 };
 
+enum {
+	BCM54XX_COPPER,
+	BCM54XX_FIBER,
+	BCM54XX_GBIC,
+	BCM54XX_SGMII,
+	BCM54XX_UNKNOWN,
+};
+
 /* An instance of a PHY, partially borrowed from mii_if_info */
 struct mii_phy
 {
#24 lore raw

PATCH 2/12 : spidernet: compile break.

Subject: [PATCH 2/12]: spidernet: compile break.

As of 2.6.20-git4, the spider_net driver does not compile. This appears to be due to some archaic usage involving kobjects.

It also fixes a nasty double-free during ifdown of the interface.

Cc Jens Osterkamp <[email protected]>
Cc Kou Ishizaki <[email protected]>

----

 drivers/net/spider_net.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/spider_net.c +1 -4
Index: linux-2.6.20-git4/drivers/net/spider_net.c
===================================================================
@@ -1906,8 +1906,7 @@ spider_net_stop(struct net_device *netde
 	spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0);
 	spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0);
 
-	/* free_irq(netdev->irq, netdev);*/
-	free_irq(to_pci_dev(netdev->class_dev.dev)->irq, netdev);
+	free_irq(netdev->irq, netdev);
 
 	spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,
 			     SPIDER_NET_DMA_TX_FEND_VALUE);
@@ -1919,8 +1918,6 @@ spider_net_stop(struct net_device *netde
 	spider_net_release_tx_chain(card, 1);
 	spider_net_free_rx_chain_contents(card);
 
-	spider_net_free_rx_chain_contents(card);
-
 	spider_net_free_chain(card, &card->tx_chain);
 	spider_net_free_chain(card, &card->rx_chain);
 
#25 lore raw

PATCH 3/12 spidernet: autoneg support for Celleb

In reply to Linas Vepstas

Add auto negotiation support for Celleb.

----

 drivers/net/spider_net.c |  176 ++++++++++++++++++++++++++++++++++++++++++-----
 drivers/net/spider_net.h |   10 ++
 2 files changed, 170 insertions(+), 16 deletions(-)
drivers/net/spider_net.h +9 -1
Index: linux-2.6.20-git4/drivers/net/spider_net.h
===================================================================
@@ -50,6 +50,8 @@ extern char spider_net_driver_name[];
 #define SPIDER_NET_TX_DESCRIPTORS_MAX		512
 
 #define SPIDER_NET_TX_TIMER			(HZ/5)
+#define SPIDER_NET_ANEG_TIMER			(HZ)
+#define SPIDER_NET_ANEG_TIMEOUT			2
 
 #define SPIDER_NET_RX_CSUM_DEFAULT		1
 
@@ -104,6 +106,7 @@ extern char spider_net_driver_name[];
 
 #define SPIDER_NET_GMACOPEMD		0x00000100
 #define SPIDER_NET_GMACLENLMT		0x00000108
+#define SPIDER_NET_GMACST		0x00000110
 #define SPIDER_NET_GMACINTEN		0x00000118
 #define SPIDER_NET_GMACPHYCTRL		0x00000120
 
@@ -333,9 +336,12 @@ enum spider_net_int2_status {
 /* We rely on flagged descriptor interrupts */
 #define SPIDER_NET_RXINT	( (1 << SPIDER_NET_GDAFDCINT) )
 
+#define SPIDER_NET_LINKINT	( 1 << SPIDER_NET_GMAC2INT )
+
 #define SPIDER_NET_ERRINT	( 0xffffffff & \
 				  (~SPIDER_NET_TXINT) & \
-				  (~SPIDER_NET_RXINT) )
+				  (~SPIDER_NET_RXINT) & \
+				  (~SPIDER_NET_LINKINT) )
 
 #define SPIDER_NET_GPREXEC			0x80000000
 #define SPIDER_NET_GPRDAT_MASK			0x0000ffff
@@ -442,6 +448,8 @@ struct spider_net_card {
 	struct spider_net_descr_chain rx_chain;
 	struct spider_net_descr *low_watermark;
 
+	int aneg_count;
+	struct timer_list aneg_timer;
 	struct timer_list tx_timer;
 	struct work_struct tx_timeout_task;
 	atomic_t tx_timeout_task_counter;
drivers/net/spider_net.c +161 -15

248 lines not on this page · raw message

#26 lore raw

PATCH 4/12 spidernet: load firmware when open

In reply to Linas Vepstas

This patch moves calling init_firmware() from spider_net_probe() to spider_net_open() so as to use the driver by built-in.

----

 drivers/net/spider_net.c |  247 +++++++++++++++++++++++------------------------
 1 file changed, 123 insertions(+), 124 deletions(-)
drivers/net/spider_net.c +123 -124
Index: linux-2.6.20-git4/drivers/net/spider_net.c
===================================================================
@@ -1705,6 +1705,124 @@ spider_net_enable_card(struct spider_net
 }
 
 /**
+ * spider_net_download_firmware - loads firmware into the adapter
+ * @card: card structure
+ * @firmware_ptr: pointer to firmware data
+ *
+ * spider_net_download_firmware loads the firmware data into the
+ * adapter. It assumes the length etc. to be allright.
+ */
+static int
+spider_net_download_firmware(struct spider_net_card *card,
+			     const void *firmware_ptr)
+{
+	int sequencer, i;
+	const u32 *fw_ptr = firmware_ptr;
+
+	/* stop sequencers */
+	spider_net_write_reg(card, SPIDER_NET_GSINIT,
+			     SPIDER_NET_STOP_SEQ_VALUE);
+
+	for (sequencer = 0; sequencer < SPIDER_NET_FIRMWARE_SEQS;
+	     sequencer++) {
+		spider_net_write_reg(card,
+				     SPIDER_NET_GSnPRGADR + sequencer * 8, 0);
+		for (i = 0; i < SPIDER_NET_FIRMWARE_SEQWORDS; i++) {
+			spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT +
+					     sequencer * 8, *fw_ptr);
+			fw_ptr++;
+		}
+	}
+
+	if (spider_net_read_reg(card, SPIDER_NET_GSINIT))
+		return -EIO;
+
+	spider_net_write_reg(card, SPIDER_NET_GSINIT,
+			     SPIDER_NET_RUN_SEQ_VALUE);
+
+	return 0;
+}
+
+/**
+ * spider_net_init_firmware - reads in firmware parts
+ * @card: card structure
+ *
+ * Returns 0 on success, <0 on failure
+ *
+ * spider_net_init_firmware opens the sequencer firmware and does some basic
+ * checks. This function opens and releases the firmware structure. A call
+ * to download the firmware is performed before the release.
+ *
+ * Firmware format
+ * ===============
+ * spider_fw.bin is expected to be a file containing 6*1024*4 bytes, 4k being
+ * the program for each sequencer. Use the command
+ *    tail -q -n +2 Seq_code1_0x088.txt Seq_code2_0x090.txt              \
+ *         Seq_code3_0x098.txt Seq_code4_0x0A0.txt Seq_code5_0x0A8.txt   \
+ *         Seq_code6_0x0B0.txt | xxd -r -p -c4 > spider_fw.bin
+ *
+ * to generate spider_fw.bin, if you have sequencer programs with something
+ * like the following contents for each sequencer:
+ *    <ONE LINE COMMENT>
+ *    <FIRST 4-BYTES-WORD FOR SEQUENCER>
+ *    <SECOND 4-BYTES-WORD FOR SEQUENCER>
+ *     ...
+ *    <1024th 4-BYTES-WORD FOR SEQUENCER>
+ */
+static int
+spider_net_init_firmware(struct spider_net_card *card)
+{
+	struct firmware *firmware = NULL;
+	struct device_node *dn;
+	const u8 *fw_prop = NULL;
+	int err = -ENOENT;
+	int fw_size;
+
+	if (request_firmware((const struct firmware **)&firmware,
+			     SPIDER_NET_FIRMWARE_NAME, &card->pdev->dev) == 0) {
+		if ( (firmware->size != SPIDER_NET_FIRMWARE_LEN) &&
+		     netif_msg_probe(card) ) {
+			pr_err("Incorrect size of spidernet firmware in " \
+			       "filesystem. Looking in host firmware...\n");
+			goto try_host_fw;
+		}
+		err = spider_net_download_firmware(card, firmware->data);
+
+		release_firmware(firmware);
+		if (err)
+			goto try_host_fw;
+
+		goto done;
+	}
+
+try_host_fw:
+	dn = pci_device_to_OF_node(card->pdev);
+	if (!dn)
+		goto out_err;
+
+	fw_prop = get_property(dn, "firmware", &fw_size);
+	if (!fw_prop)
+		goto out_err;
+
+	if ( (fw_size != SPIDER_NET_FIRMWARE_LEN) &&
+	     netif_msg_probe(card) ) {
+		pr_err("Incorrect size of spidernet firmware in " \
+		       "host firmware\n");
+		goto done;
+	}
+
+	err = spider_net_download_firmware(card, fw_prop);
+
+done:
+	return err;
+out_err:
+	if (netif_msg_probe(card))
+		pr_err("Couldn't find spidernet firmware in filesystem " \
+		       "or host firmware\n");
+	return err;
+}
+
+/**
  * spider_net_open - called upon ifonfig up
  * @netdev: interface device structure
  *
@@ -1719,6 +1837,10 @@ spider_net_open(struct net_device *netde
 	struct spider_net_card *card = netdev_priv(netdev);
 	int result;
 
+	result = spider_net_init_firmware(card);
+	if (result)
+		goto init_firmware_failed;
+
 	/* start probing with copper */
 	spider_net_setup_aneg(card);
 	if (card->phy.def->phy_id)
@@ -1762,6 +1884,7 @@ alloc_rx_failed:
 	spider_net_free_chain(card, &card->tx_chain);
 alloc_tx_failed:
 	del_timer_sync(&card->aneg_timer);
+init_firmware_failed:
 	return result;
 }
 
@@ -1873,124 +1996,6 @@ spider_net_setup_phy(struct spider_net_c
 }
 
 /**
- * spider_net_download_firmware - loads firmware into the adapter
- * @card: card structure
- * @firmware_ptr: pointer to firmware data
- *
- * spider_net_download_firmware loads the firmware data into the
- * adapter. It assumes the length etc. to be allright.
- */
-static int
-spider_net_download_firmware(struct spider_net_card *card,
-			     const void *firmware_ptr)
-{
-	int sequencer, i;
-	const u32 *fw_ptr = firmware_ptr;
-
-	/* stop sequencers */
-	spider_net_write_reg(card, SPIDER_NET_GSINIT,
-			     SPIDER_NET_STOP_SEQ_VALUE);
-
-	for (sequencer = 0; sequencer < SPIDER_NET_FIRMWARE_SEQS;
-	     sequencer++) {
-		spider_net_write_reg(card,
-				     SPIDER_NET_GSnPRGADR + sequencer * 8, 0);
-		for (i = 0; i < SPIDER_NET_FIRMWARE_SEQWORDS; i++) {
-			spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT +
-					     sequencer * 8, *fw_ptr);
-			fw_ptr++;
-		}
-	}
-
-	if (spider_net_read_reg(card, SPIDER_NET_GSINIT))
-		return -EIO;
-
-	spider_net_write_reg(card, SPIDER_NET_GSINIT,
-			     SPIDER_NET_RUN_SEQ_VALUE);
-
-	return 0;
-}
-
-/**
- * spider_net_init_firmware - reads in firmware parts
- * @card: card structure
- *
- * Returns 0 on success, <0 on failure
- *
- * spider_net_init_firmware opens the sequencer firmware and does some basic
- * checks. This function opens and releases the firmware structure. A call
- * to download the firmware is performed before the release.
- *
- * Firmware format
- * ===============
- * spider_fw.bin is expected to be a file containing 6*1024*4 bytes, 4k being
- * the program for each sequencer. Use the command
- *    tail -q -n +2 Seq_code1_0x088.txt Seq_code2_0x090.txt              \
- *         Seq_code3_0x098.txt Seq_code4_0x0A0.txt Seq_code5_0x0A8.txt   \
- *         Seq_code6_0x0B0.txt | xxd -r -p -c4 > spider_fw.bin
- *
- * to generate spider_fw.bin, if you have sequencer programs with something
- * like the following contents for each sequencer:
- *    <ONE LINE COMMENT>
- *    <FIRST 4-BYTES-WORD FOR SEQUENCER>
- *    <SECOND 4-BYTES-WORD FOR SEQUENCER>
- *     ...
- *    <1024th 4-BYTES-WORD FOR SEQUENCER>
- */
-static int
-spider_net_init_firmware(struct spider_net_card *card)
-{
-	struct firmware *firmware = NULL;
-	struct device_node *dn;
-	const u8 *fw_prop = NULL;
-	int err = -ENOENT;
-	int fw_size;
-
-	if (request_firmware((const struct firmware **)&firmware,
-			     SPIDER_NET_FIRMWARE_NAME, &card->pdev->dev) == 0) {
-		if ( (firmware->size != SPIDER_NET_FIRMWARE_LEN) &&
-		     netif_msg_probe(card) ) {
-			pr_err("Incorrect size of spidernet firmware in " \
-			       "filesystem. Looking in host firmware...\n");
-			goto try_host_fw;
-		}
-		err = spider_net_download_firmware(card, firmware->data);
-
-		release_firmware(firmware);
-		if (err)
-			goto try_host_fw;
-
-		goto done;
-	}
-
-try_host_fw:
-	dn = pci_device_to_OF_node(card->pdev);
-	if (!dn)
-		goto out_err;
-
-	fw_prop = get_property(dn, "firmware", &fw_size);
-	if (!fw_prop)
-		goto out_err;
-
-	if ( (fw_size != SPIDER_NET_FIRMWARE_LEN) &&
-	     netif_msg_probe(card) ) {
-		pr_err("Incorrect size of spidernet firmware in " \
-		       "host firmware\n");
-		goto done;
-	}
-
-	err = spider_net_download_firmware(card, fw_prop);
-
-done:
-	return err;
-out_err:
-	if (netif_msg_probe(card))
-		pr_err("Couldn't find spidernet firmware in filesystem " \
-		       "or host firmware\n");
-	return err;
-}
-
-/**
  * spider_net_workaround_rxramfull - work around firmware bug
  * @card: card structure
  *
@@ -2090,8 +2095,6 @@ spider_net_tx_timeout_task(struct work_s
 
 	if (spider_net_setup_phy(card))
 		goto out;
-	if (spider_net_init_firmware(card))
-		goto out;
 
 	spider_net_open(netdev);
 	spider_net_kick_tx_dma(card);
@@ -2363,10 +2366,6 @@ spider_net_probe(struct pci_dev *pdev, c
 	if (err)
 		goto out_undo_pci;
 
-	err = spider_net_init_firmware(card);
-	if (err)
-		goto out_undo_pci;
-
 	err = spider_net_setup_netdev(card);
 	if (err)
 		goto out_undo_pci;
#27 lore raw

PATCH 5/12 spidernet: spidernet: add support for Celleb

In reply to Linas Vepstas

This patch adds or changes some HW specific settings for spider_net on Celleb.

----

 drivers/net/Kconfig      |    2 +-
 drivers/net/spider_net.c |    8 +++++++-
 drivers/net/spider_net.h |    6 ++++--
 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/net/Kconfig +1 -1
Index: linux-2.6.20-git4/drivers/net/Kconfig
===================================================================
@@ -2243,7 +2243,7 @@ config BNX2
 
 config SPIDER_NET
 	tristate "Spider Gigabit Ethernet driver"
-	depends on PCI && PPC_IBM_CELL_BLADE
+	depends on PCI && (PPC_IBM_CELL_BLADE || PPC_CELLEB)
 	select FW_LOADER
 	help
 	  This driver supports the Gigabit Ethernet chips present on the
drivers/net/spider_net.h +4 -2
Index: linux-2.6.20-git4/drivers/net/spider_net.h
===================================================================
@@ -1,7 +1,8 @@
 /*
- * Network device driver for Cell Processor-Based Blade
+ * Network device driver for Cell Processor-Based Blade and Celleb platform
  *
  * (C) Copyright IBM Corp. 2005
+ * (C) Copyright 2006 TOSHIBA CORPORATION
  *
  * Authors : Utz Bacher <[email protected]>
  *           Jens Osterkamp <[email protected]>
@@ -184,7 +185,8 @@ extern char spider_net_driver_name[];
 
 /* pause frames: automatic, no upper retransmission count */
 /* outside loopback mode: ETOMOD signal dont matter, not connected */
-#define SPIDER_NET_OPMODE_VALUE		0x00000063
+/* ETOMOD signal is brought to PHY reset. bit 2 must be 1 in Celleb */
+#define SPIDER_NET_OPMODE_VALUE		0x00000067
 /*#define SPIDER_NET_OPMODE_VALUE		0x001b0062*/
 #define SPIDER_NET_LENLMT_VALUE		0x00000908
 
drivers/net/spider_net.c +7 -1
Index: linux-2.6.20-git4/drivers/net/spider_net.c
===================================================================
@@ -1,7 +1,8 @@
 /*
- * Network device driver for Cell Processor-Based Blade
+ * Network device driver for Cell Processor-Based Blade and Celleb platform
  *
  * (C) Copyright IBM Corp. 2005
+ * (C) Copyright 2006 TOSHIBA CORPORATION
  *
  * Authors : Utz Bacher <[email protected]>
  *           Jens Osterkamp <[email protected]>
@@ -1605,6 +1606,11 @@ spider_net_init_card(struct spider_net_c
 
 	spider_net_write_reg(card, SPIDER_NET_CKRCTRL,
 			     SPIDER_NET_CKRCTRL_RUN_VALUE);
+
+	/* trigger ETOMOD signal */
+	spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,
+		spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 0x4);
+
 }
 
 /**
#28 lore raw

PATCH 6/12 spidernet: remove txram full logging

In reply to Linas Vepstas

This patches removes logging for SPIDER_NET_GTMFLLINT interrupts. Since the interrupts are not irregular, and they happen frequently when using 100Mbps network switches.

----

 drivers/net/spider_net.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/spider_net.c +2 -2
Index: linux-2.6.20-git4/drivers/net/spider_net.c
===================================================================
@@ -1422,8 +1422,8 @@ spider_net_handle_error_irq(struct spide
 				switch (i)
 	{
 	case SPIDER_NET_GTMFLLINT:
-		if (netif_msg_intr(card) && net_ratelimit())
-			pr_err("Spider TX RAM full\n");
+		/* TX RAM full may happen on a usual case.
+		 * Logging is not needed. */
 		show_error = 0;
 		break;
 	case SPIDER_NET_GRFDFLLINT: /* fallthrough */
#29 lore raw

PATCH 7/12 spidernet: move medium variable into card struct

In reply to Linas Vepstas

This moves the medium variable into the spidernet card structure. It renames the GMII_ variables to BCM54XX specific ones.

----

 drivers/net/spider_net.c |   14 +++++++-------
 drivers/net/spider_net.h |    2 ++
 2 files changed, 9 insertions(+), 7 deletions(-)
drivers/net/spider_net.c +7 -7
Index: linux-2.6.20-git4/drivers/net/spider_net.c
===================================================================
@@ -1909,26 +1909,26 @@ static void spider_net_link_phy(unsigned
 
 		pr_info("%s: link is down trying to bring it up\n", card->netdev->name);
 
-		switch (phy->medium) {
-		case GMII_COPPER:
+		switch (card->medium) {
+		case BCM54XX_COPPER:
 			/* enable fiber with autonegotiation first */
 			if (phy->def->ops->enable_fiber)
 				phy->def->ops->enable_fiber(phy, 1);
-			phy->medium = GMII_FIBER;
+			card->medium = BCM54XX_FIBER;
 			break;
 
-		case GMII_FIBER:
+		case BCM54XX_FIBER:
 			/* fiber didn't come up, try to disable fiber autoneg */
 			if (phy->def->ops->enable_fiber)
 				phy->def->ops->enable_fiber(phy, 0);
-			phy->medium = GMII_UNKNOWN;
+			card->medium = BCM54XX_UNKNOWN;
 			break;
 
-		case GMII_UNKNOWN:
+		case BCM54XX_UNKNOWN:
 			/* copper, fiber with and without failed,
 			 * retry from beginning */
 			spider_net_setup_aneg(card);
-			phy->medium = GMII_COPPER;
+			card->medium = BCM54XX_COPPER;
 			break;
 		}
 
drivers/net/spider_net.h +2 -0
Index: linux-2.6.20-git4/drivers/net/spider_net.h
===================================================================
@@ -444,6 +444,8 @@ struct spider_net_card {
 	struct pci_dev *pdev;
 	struct mii_phy phy;
 
+	int medium;
+
 	void __iomem *regs;
 
 	struct spider_net_descr_chain tx_chain;
#30 lore raw

PATCH 8/12 Spidernet: separate hardware state from driver state.

In reply to Linas Vepstas

This patch separates the hardware descriptor state from the driver descriptor state, per (old) suggestion from Ben Herrenschmidt. This compiles and boots and seems to work.

Cc Jens Osterkamp <[email protected]>
Cc Kou Ishizaki <[email protected]>

----

 drivers/net/spider_net.c |  150 ++++++++++++++++++++++++++---------------------
 drivers/net/spider_net.h |   16 +++--
 2 files changed, 95 insertions(+), 71 deletions(-)
drivers/net/spider_net.h +11 -5
Index: linux-2.6.20-git4/drivers/net/spider_net.h
===================================================================
@@ -25,7 +25,7 @@
 #ifndef _SPIDER_NET_H
 #define _SPIDER_NET_H
 
-#define VERSION "1.6 B"
+#define VERSION "1.6 C"
 
 #include "sungem_phy.h"
 
@@ -364,8 +364,8 @@ enum spider_net_int2_status {
 #define SPIDER_NET_DESCR_NOT_IN_USE		0xF0000000
 #define SPIDER_NET_DESCR_TXDESFLG		0x00800000
 
-struct spider_net_descr {
-	/* as defined by the hardware */
+/* Descriptor, as defined by the hardware */
+struct spider_net_hw_descr {
 	u32 buf_addr;
 	u32 buf_size;
 	u32 next_descr_addr;
@@ -374,13 +374,15 @@ struct spider_net_descr {
 	u32 valid_size;	/* all zeroes for tx */
 	u32 data_status;
 	u32 data_error;	/* all zeroes for tx */
+} __attribute__((aligned(32)));
 
-	/* used in the driver */
+struct spider_net_descr {
+	struct spider_net_hw_descr *hwdescr;
 	struct sk_buff *skb;
 	u32 bus_addr;
 	struct spider_net_descr *next;
 	struct spider_net_descr *prev;
-} __attribute__((aligned(32)));
+};
 
 struct spider_net_descr_chain {
 	spinlock_t lock;
@@ -388,6 +390,7 @@ struct spider_net_descr_chain {
 	struct spider_net_descr *tail;
 	struct spider_net_descr *ring;
 	int num_desc;
+	struct spider_net_hw_descr *hwring;
 	dma_addr_t dma_addr;
 };
 
@@ -464,6 +467,9 @@ struct spider_net_card {
 	struct net_device_stats netdev_stats;
 	struct spider_net_extra_stats spider_stats;
 	struct spider_net_options options;
+
+	/* Must be last item in struct */
+	struct spider_net_descr darray[0];
 };
 
 #define pr_err(fmt,arg...) \
drivers/net/spider_net.c +84 -66

375 lines not on this page · raw message

#31 lore raw

PATCH 9/12 : spidernet: fix racy double-free of skb

In reply to Linas Vepstas

It appears that under certain circumstances, a race will result in a double-free of an skb. This patch null's out the skb pointer upon the skb free, avoiding the inadvertent deref of bogus data. The next patch fixes the actual race.

Cc Jens Osterkamp <[email protected]>
Cc Kou Ishizaki <[email protected]>

----

 drivers/net/spider_net.c |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/net/spider_net.c +15 -8
Index: linux-2.6.20-git4/drivers/net/spider_net.c
===================================================================
@@ -396,10 +396,11 @@ spider_net_free_rx_chain_contents(struct
 	descr = card->rx_chain.head;
 	do {
 		if (descr->skb) {
-			dev_kfree_skb(descr->skb);
 			pci_unmap_single(card->pdev, descr->hwdescr->buf_addr,
 					 SPIDER_NET_MAX_FRAME,
 					 PCI_DMA_BIDIRECTIONAL);
+			dev_kfree_skb(descr->skb);
+			descr->skb = NULL;
 		}
 		descr = descr->next;
 	} while (descr != card->rx_chain.head);
@@ -453,6 +454,7 @@ spider_net_prepare_rx_descr(struct spide
 			SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
 	if (pci_dma_mapping_error(buf)) {
 		dev_kfree_skb_any(descr->skb);
+		descr->skb = NULL;
 		if (netif_msg_rx_err(card) && net_ratelimit())
 			pr_err("Could not iommu-map rx buffer\n");
 		card->spider_stats.rx_iommu_map_error++;
@@ -682,6 +684,7 @@ static int
 spider_net_prepare_tx_descr(struct spider_net_card *card,
 			    struct sk_buff *skb)
 {
+	struct spider_net_descr_chain *chain = &card->tx_chain;
 	struct spider_net_descr *descr;
 	struct spider_net_hw_descr *hwdescr;
 	dma_addr_t buf;
@@ -696,10 +699,15 @@ spider_net_prepare_tx_descr(struct spide
 		return -ENOMEM;
 	}
 
-	spin_lock_irqsave(&card->tx_chain.lock, flags);
+	spin_lock_irqsave(&chain->lock, flags);
 	descr = card->tx_chain.head;
+	if (descr->next == chain->tail->prev) {
+		spin_unlock_irqrestore(&chain->lock, flags);
+		pci_unmap_single(card->pdev, buf, skb->len, PCI_DMA_TODEVICE);
+		return -ENOMEM;
+	}
 	hwdescr = descr->hwdescr;
-	card->tx_chain.head = descr->next;
+	chain->head = descr->next;
 
 	descr->skb = skb;
 	hwdescr->buf_addr = buf;
@@ -709,7 +717,7 @@ spider_net_prepare_tx_descr(struct spide
 
 	hwdescr->dmac_cmd_status =
 			SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS;
-	spin_unlock_irqrestore(&card->tx_chain.lock, flags);
+	spin_unlock_irqrestore(&chain->lock, flags);
 
 	if (skb->protocol == htons(ETH_P_IP))
 		switch (skb->nh.iph->protocol) {
@@ -838,6 +846,7 @@ spider_net_release_tx_chain(struct spide
 		chain->tail = descr->next;
 		hwdescr->dmac_cmd_status |= SPIDER_NET_DESCR_NOT_IN_USE;
 		skb = descr->skb;
+		descr->skb = NULL;
 		buf_addr = hwdescr->buf_addr;
 		spin_unlock_irqrestore(&chain->lock, flags);
 
@@ -903,13 +912,10 @@ spider_net_xmit(struct sk_buff *skb, str
 {
 	int cnt;
 	struct spider_net_card *card = netdev_priv(netdev);
-	struct spider_net_descr_chain *chain = &card->tx_chain;
 
 	spider_net_release_tx_chain(card, 0);
 
-	if ((chain->head->next == chain->tail->prev) ||
-	   (spider_net_prepare_tx_descr(card, skb) != 0)) {
-
+	if (spider_net_prepare_tx_descr(card, skb) != 0) {
 		card->netdev_stats.tx_dropped++;
 		netif_stop_queue(netdev);
 		return NETDEV_TX_BUSY;
@@ -1127,6 +1133,7 @@ spider_net_decode_one_descr(struct spide
 
 bad_desc:
 	dev_kfree_skb_irq(descr->skb);
+	descr->skb = NULL;
 	hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
 	return 0;
 }
#32 lore raw

PATCH 10/12 spidernet: transmit race

In reply to Linas Vepstas

Multiple threads performing a transmit can race into the spidernet tx ring cleanup code. This puts the relevant check under a lock.

Cc Jens Osterkamp <[email protected]>
Cc Kou Ishizaki <[email protected]>

----

 drivers/net/spider_net.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/spider_net.c +5 -1
Index: linux-2.6.20-git4/drivers/net/spider_net.c
===================================================================
@@ -803,8 +803,12 @@ spider_net_release_tx_chain(struct spide
 	unsigned long flags;
 	int status;
 
-	while (chain->tail != chain->head) {
+	while (1) {
 		spin_lock_irqsave(&chain->lock, flags);
+		if (chain->tail == chain->head) {
+			spin_unlock_irqrestore(&chain->lock, flags);
+			return 0;
+		}
 		descr = chain->tail;
 		hwdescr = descr->hwdescr;
 
#33 lore raw

PATCH 11/12 spidernet: janitorial, typos

In reply to Linas Vepstas

Janitorial patch. Undo long lines, fix typo in err msg.

Cc Jens Osterkamp <[email protected]>
Cc Kou Ishizaki <[email protected]>

----

 drivers/net/spider_net.c |   13 +++++++------
 drivers/net/spider_net.h |    2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/net/spider_net.c +7 -6
Index: linux-2.6.20-git4/drivers/net/spider_net.c
===================================================================
@@ -1053,14 +1053,15 @@ static void show_rx_chain(struct spider_
 #endif
 
 /**
- * spider_net_decode_one_descr - processes an rx descriptor
+ * spider_net_decode_one_descr - processes an RX descriptor
  * @card: card structure
  *
- * Returns 1 if a packet has been sent to the stack, otherwise 0
+ * Returns 1 if a packet has been sent to the stack, otherwise 0.
  *
- * Processes an rx descriptor by iommu-unmapping the data buffer and passing
- * the packet up to the stack. This function is called in softirq
- * context, e.g. either bottom half from interrupt or NAPI polling context
+ * Processes an RX descriptor by iommu-unmapping the data buffer
+ * and passing the packet up to the stack. This function is called
+ * in softirq context, e.g. either bottom half from interrupt or
+ * NAPI polling context.
  */
 static int
 spider_net_decode_one_descr(struct spider_net_card *card)
@@ -1097,7 +1098,7 @@ spider_net_decode_one_descr(struct spide
 	if ( (status != SPIDER_NET_DESCR_COMPLETE) &&
 	     (status != SPIDER_NET_DESCR_FRAME_END) ) {
 		if (netif_msg_rx_err(card))
-			pr_err("%s: RX descriptor with unkown state %d\n",
+			pr_err("%s: RX descriptor with unknown state %d\n",
 			       card->netdev->name, status);
 		card->spider_stats.rx_desc_unk_state++;
 		goto bad_desc;
drivers/net/spider_net.h +1 -1
Index: linux-2.6.20-git4/drivers/net/spider_net.h
===================================================================
@@ -25,7 +25,7 @@
 #ifndef _SPIDER_NET_H
 #define _SPIDER_NET_H
 
-#define VERSION "1.6 C"
+#define VERSION "2.0 A"
 
 #include "sungem_phy.h"
 
#34 lore raw

PATCH 12/12 : spidernet: maintainership

In reply to Linas Vepstas

Provisionally change maintinership.

Cc Jens Osterkamp <[email protected]>
Cc Kou Ishizaki <[email protected]>

----

 MAINTAINERS |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
MAINTAINERS +2 -2
Index: linux-2.6.20-git4/MAINTAINERS
===================================================================
@@ -3119,8 +3119,8 @@ L:	[email protected] ?
 S:	Supported
 
 SPIDERNET NETWORK DRIVER for CELL
-P:	Jim Lewis
-M:	[email protected]
+P:	Linas Vepstas
+M:	[email protected]
 L:	[email protected]
 S:	Supported
 
#35 lore raw

Re: [PATCH 1/12]: sungem_phy: support bcm5461 phy, autoneg.

In reply to Linas Vepstas
Quoted 3 lines · Linas Vepstas

You only have the Signed-off-by information here and in the other patches, but no 'From:' line.

I assume that Jeff uses the git-applymbox tool to import mails, in which case the first line of the patch description should be 'From: Someone Else <[email protected]>', unless you are the author of the patch yourself.

	Arnd <><
#36 lore raw

Re: [PATCH 1/12]: sungem_phy: support bcm5461 phy, autoneg.

Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Linas Vepstas
Quoted 7 lines

You only have the Signed-off-by information here and in the other patches, but no 'From:' line.

I assume that Jeff uses the git-applymbox tool to import mails, in which case the first line of the patch description should be 'From: Someone Else <[email protected]>', unless you are the author of the patch yourself.

Ahh. OK. I was assuming it was the first signed-off-by that counted.

--linas

#37 lore raw

spidernet (was Re: [PATCHSET] libata: PATA driver for Celleb)

In reply to Benjamin Herrenschmidt
Quoted 3 lines

My overall impression of spidernet development is that EVERYBODY is submitting patches at once, and expecting me to sort out the mess. No thanks.

Speaking with one voice would be much appreciated. And said speaker should patch the MAINTAINERS file to reflect reality.

To be specific, I have dropped -all- spidernet patches I had pending in email, and at the present time there are no unsent spidernet commits in netdev-2.6.git.

I'll await the resend of any pending patches from the driver maintainer, once you guys sort out who that is.

Jeff

#38 lore raw

Re: spidernet (was Re: [PATCHSET] libata: PATA driver for Celleb)

Quoted 11 lines · Jeff Garzik
Quoted 3 lines

My overall impression of spidernet development is that EVERYBODY is submitting patches at once, and expecting me to sort out the mess. No thanks.

Speaking with one voice would be much appreciated. And said speaker should patch the MAINTAINERS file to reflect reality.

To be specific, I have dropped -all- spidernet patches I had pending in email, and at the present time there are no unsent spidernet commits in netdev-2.6.git.

I'll await the resend of any pending patches from the driver maintainer, once you guys sort out who that is.

That's the right approach. Agreed.

Ben.