Skip to contentSkip to conversation

issue patch in next net/eth: fix link handling

DISCUSSION Jean-Christophe PLAGNIOL-VILLARD 2 participants 5 messages Sep 28, 2012

Subsystems (3)
lore
Share & tools
lore
#1 lore raw
Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD

HI,

The patch is next
net/eth: fix link handling

was NEVER send to the ML

IIRC I was the author of the first version and this disapear

Uwe and I just get this discussion on the kernel ML about patch update

I was basically pissed off because I got the strong feeling that I spent more time reviewing and testing the patch than you initially spent writing it in the first place. The second version still stored apples in edev->phydev->link and bananas in edev->carrier, but still did a edev->carrier = dev->link.

Sorry for not posting it on the ML, doing that now.

Sascha

8<--------------------------------------------------

From 0dc9de2efd7ea6fb613afec822b52b4bfe5a7b2e Mon Sep 17 00:00:00 2001
From: Sascha Hauer <[email protected]>
Date: Wed, 26 Sep 2012 17:53:29 +0200
Subject: [PATCH] net/eth: fix link handling

Check link status on eth device open time and then periodically every 5 seconds. Based on work from from Jean-Christophe, but this version does not duplicate the link status information in two different variables.

---
 drivers/net/phy/phy.c |   35 ++++++++++++++++-------
 include/linux/phy.h   |    3 ++
 net/eth.c             |   75 +++++++++++++++++++++++++++++++++++++------------
 3 files changed, 85 insertions(+), 28 deletions(-)
drivers/net/phy/phy.c +25 -10
index e1a24fa..88c3ff7 100644
@@ -29,6 +29,30 @@
 
 static int genphy_config_init(struct phy_device *phydev);
 
+int phy_update_status(struct phy_device *dev)
+{
+	struct phy_driver *drv = to_phy_driver(dev->dev.driver);
+	struct eth_device *edev = dev->attached_dev;
+	int ret;
+	int oldspeed = dev->speed, oldduplex = dev->duplex;
+
+	ret = drv->read_status(dev);
+	if (ret)
+		return ret;
+
+	if (dev->speed == oldspeed && dev->duplex == oldduplex)
+		return 0;
+
+	if (dev->adjust_link)
+		dev->adjust_link(edev);
+
+	if (dev->link)
+		printf("%dMbps %s duplex link detected\n", dev->speed,
+			dev->duplex ? "full" : "half");
+
+	return 0;
+}
+
 struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id)
 {
 	struct phy_device *dev;
@@ -172,16 +196,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 
 	drv->config_aneg(dev);
 
-	ret = drv->read_status(dev);
-	if (ret < 0)
-		return ret;
-
-	if (dev->link)
-		printf("%dMbps %s duplex link detected\n", dev->speed,
-			dev->duplex ? "full" : "half");
-
-	if (adjust_link)
-		adjust_link(edev);
+	dev->adjust_link = adjust_link;
 
 	return 0;
 
include/linux/phy.h +3 -0
index 8fe6b86..76f9edb 100644
@@ -164,6 +164,7 @@ struct phy_device {
 	void *priv;
 
 	struct eth_device *attached_dev;
+	void (*adjust_link)(struct eth_device *dev);
 
 	struct cdev cdev;
 };
@@ -253,6 +254,8 @@ int phy_device_connect(struct eth_device *dev, struct mii_bus *bus, int addr,
 		       void (*adjust_link) (struct eth_device *edev),
 		       u32 flags, phy_interface_t interface);
 
+int phy_update_status(struct phy_device *phydev);
+
 /* Generic PHY support and helper functions */
 int genphy_restart_aneg(struct phy_device *phydev);
 int genphy_config_aneg(struct phy_device *phydev);
net/eth.c +57 -18

102 lines not on this page · raw message

Signature · 12 lines
1.7.10.4

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 10 lines · Sascha Hauer
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD

HI,

The patch is next
net/eth: fix link handling

was NEVER send to the ML

IIRC I was the author of the first version and this disapear

Quoted 8 lines
Quoted 2 lines

Uwe and I just get this discussion on the kernel ML about patch update

I was basically pissed off because I got the strong feeling that I spent more time reviewing and testing the patch than you initially spent writing it in the first place. The second version still stored apples in edev->phydev->link and bananas in edev->carrier, but still did a edev->carrier = dev->link.

I did this on purpose as I do want to store the link and later export it via env as I get a patch here for 2 wifi driver where I'll not use the phylib

so store the carrier is the correct way

we could use a net_carrier(xx) as in the kernel to update the field but I do need the carrier to not be manage only for the phylib

my work on thiose wifi driver is not finished but on the way maybe next release

Quoted 2 lines

Sorry for not posting it on the ML, doing that now.

I was pissed off that this is based on my work and I lost the author of the patch and no mention about my work

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
Quoted 19 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 10 lines · Sascha Hauer
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD

HI,

The patch is next
net/eth: fix link handling

was NEVER send to the ML

IIRC I was the author of the first version and this disapear

Quoted 8 lines
Quoted 2 lines

Uwe and I just get this discussion on the kernel ML about patch update

I was basically pissed off because I got the strong feeling that I spent more time reviewing and testing the patch than you initially spent writing it in the first place. The second version still stored apples in edev->phydev->link and bananas in edev->carrier, but still did a edev->carrier = dev->link.

Quoted 4 lines

I did this on purpose as I do want to store the link and later export it via env as I get a patch here for 2 wifi driver where I'll not use the phylib

so store the carrier is the correct way

Whatever it is, adding a variable to an ethernet device and then manipulating it in both the phylib and the ethernet code is desastrous. It must be clear everytime who owns a variable. Doing a

eth_current->carrier = CARRIER_UNKNOW;

in the ethernet code, and then:

edev->carrier = dev->link;

in the phy code is a recipe for spaghetti code.

Sascha (Who loves spaghetti - on his plate)

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
Quoted 29 lines · Sascha Hauer
Quoted 19 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 10 lines · Sascha Hauer
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD

HI,

The patch is next
net/eth: fix link handling

was NEVER send to the ML

IIRC I was the author of the first version and this disapear

Quoted 8 lines
Quoted 2 lines

Uwe and I just get this discussion on the kernel ML about patch update

I was basically pissed off because I got the strong feeling that I spent more time reviewing and testing the patch than you initially spent writing it in the first place. The second version still stored apples in edev->phydev->link and bananas in edev->carrier, but still did a edev->carrier = dev->link.

Quoted 4 lines

I did this on purpose as I do want to store the link and later export it via env as I get a patch here for 2 wifi driver where I'll not use the phylib

so store the carrier is the correct way

Whatever it is, adding a variable to an ethernet device and then manipulating it in both the phylib and the ethernet code is desastrous. It must be clear everytime who owns a variable. Doing a

Quoted 8 lines

eth_current->carrier = CARRIER_UNKNOW;

in the ethernet code, and then:

edev->carrier = dev->link;

in the phy code is a recipe for spaghetti code.

so we need to do call net_carrier in phylib as done in the kernel the net framework mamange the carrier by itself

as example in wifi phy up does not mean carrier on

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox