All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: ethoc: Misc improvements
@ 2016-12-04 20:40 Florian Fainelli
  2016-12-04 20:40 ` [PATCH net-next 1/3] net: ethoc: Account for duplex changes Florian Fainelli
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Florian Fainelli @ 2016-12-04 20:40 UTC (permalink / raw)
  To: netdev; +Cc: tremyfr, tklauser, davem, thierry.reding, andrew,
	Florian Fainelli

Hi all,

This patch series fixes/improves a few things:

- implement a proper PHYLIB adjust_link callback to set the duplex mode
  accordingly
- do not open code the fetching of a MAC address in OF/DT environments
- demote an error message that occurs more frequently than expected in low
  CPU/memory/bandwidth environments

Tested on a Cirrus Logic EP93xx / TS7300 board.

Florian Fainelli (3):
  net: ethoc: Account for duplex changes
  net: ethoc: Utilize of_get_mac_address()
  net: ethoc: Demote packet dropped error message to debug

 drivers/net/ethernet/ethoc.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 5 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH net-next 1/3] net: ethoc: Account for duplex changes
  2016-12-04 20:40 [PATCH net-next 0/3] net: ethoc: Misc improvements Florian Fainelli
@ 2016-12-04 20:40 ` Florian Fainelli
  2016-12-05  7:20   ` Tobias Klauser
  2016-12-05  8:00   ` Thierry Reding
  2016-12-04 20:40 ` [PATCH net-next 2/3] net: ethoc: Utilize of_get_mac_address() Florian Fainelli
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Florian Fainelli @ 2016-12-04 20:40 UTC (permalink / raw)
  To: netdev; +Cc: tremyfr, tklauser, davem, thierry.reding, andrew,
	Florian Fainelli

ethoc_mdio_poll() which is our PHYLIB adjust_link callback does nothing,
we should at least react to duplex changes and change MODER accordingly.
Speed changes is not a problem, since the OpenCores Ethernet core seems
to be reacting okay without us telling it.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/ethoc.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 6456c180114b..877c02a36c85 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -221,6 +221,9 @@ struct ethoc {
 	struct mii_bus *mdio;
 	struct clk *clk;
 	s8 phy_id;
+
+	int old_link;
+	int old_duplex;
 };
 
 /**
@@ -667,6 +670,32 @@ static int ethoc_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
 
 static void ethoc_mdio_poll(struct net_device *dev)
 {
+	struct ethoc *priv = netdev_priv(dev);
+	struct phy_device *phydev = dev->phydev;
+	bool changed = false;
+	u32 mode;
+
+	if (priv->old_link != phydev->link) {
+		changed = true;
+		priv->old_link = phydev->link;
+	}
+
+	if (priv->old_duplex != phydev->duplex) {
+		changed = true;
+		priv->old_duplex = phydev->duplex;
+	}
+
+	if (!changed)
+		return;
+
+	mode = ethoc_read(priv, MODER);
+	if (phydev->duplex == DUPLEX_FULL)
+		mode |= MODER_FULLD;
+	else
+		mode &= ~MODER_FULLD;
+	ethoc_write(priv, MODER, mode);
+
+	phy_print_status(phydev);
 }
 
 static int ethoc_mdio_probe(struct net_device *dev)
@@ -685,6 +714,9 @@ static int ethoc_mdio_probe(struct net_device *dev)
 		return -ENXIO;
 	}
 
+	priv->old_duplex = -1;
+	priv->old_link = -1;
+
 	err = phy_connect_direct(dev, phy, ethoc_mdio_poll,
 				 PHY_INTERFACE_MODE_GMII);
 	if (err) {
@@ -721,6 +753,9 @@ static int ethoc_open(struct net_device *dev)
 		netif_start_queue(dev);
 	}
 
+	priv->old_link = -1;
+	priv->old_duplex = -1;
+
 	phy_start(dev->phydev);
 	napi_enable(&priv->napi);
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 2/3] net: ethoc: Utilize of_get_mac_address()
  2016-12-04 20:40 [PATCH net-next 0/3] net: ethoc: Misc improvements Florian Fainelli
  2016-12-04 20:40 ` [PATCH net-next 1/3] net: ethoc: Account for duplex changes Florian Fainelli
@ 2016-12-04 20:40 ` Florian Fainelli
  2016-12-05  7:20   ` Tobias Klauser
  2016-12-05  8:00   ` Thierry Reding
  2016-12-04 20:40 ` [PATCH net-next 3/3] net: ethoc: Demote packet dropped error message to debug Florian Fainelli
  2016-12-05 20:30 ` [PATCH net-next 0/3] net: ethoc: Misc improvements David Miller
  3 siblings, 2 replies; 11+ messages in thread
From: Florian Fainelli @ 2016-12-04 20:40 UTC (permalink / raw)
  To: netdev; +Cc: tremyfr, tklauser, davem, thierry.reding, andrew,
	Florian Fainelli

Do not open code getting the MAC address exclusively from the
"local-mac-address" property, but instead use of_get_mac_address() which
looks up the MAC address using the 3 typical property names.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/ethoc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 877c02a36c85..8d0cb5ce87ee 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -23,6 +23,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/of.h>
+#include <linux/of_net.h>
 #include <linux/module.h>
 #include <net/ethoc.h>
 
@@ -1158,11 +1159,9 @@ static int ethoc_probe(struct platform_device *pdev)
 		memcpy(netdev->dev_addr, pdata->hwaddr, IFHWADDRLEN);
 		priv->phy_id = pdata->phy_id;
 	} else {
-		const uint8_t *mac;
+		const void *mac;
 
-		mac = of_get_property(pdev->dev.of_node,
-				      "local-mac-address",
-				      NULL);
+		mac = of_get_mac_address(pdev->dev.of_node);
 		if (mac)
 			memcpy(netdev->dev_addr, mac, IFHWADDRLEN);
 		priv->phy_id = -1;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 3/3] net: ethoc: Demote packet dropped error message to debug
  2016-12-04 20:40 [PATCH net-next 0/3] net: ethoc: Misc improvements Florian Fainelli
  2016-12-04 20:40 ` [PATCH net-next 1/3] net: ethoc: Account for duplex changes Florian Fainelli
  2016-12-04 20:40 ` [PATCH net-next 2/3] net: ethoc: Utilize of_get_mac_address() Florian Fainelli
@ 2016-12-04 20:40 ` Florian Fainelli
  2016-12-05  7:21   ` Tobias Klauser
  2016-12-05  8:00   ` Thierry Reding
  2016-12-05 20:30 ` [PATCH net-next 0/3] net: ethoc: Misc improvements David Miller
  3 siblings, 2 replies; 11+ messages in thread
From: Florian Fainelli @ 2016-12-04 20:40 UTC (permalink / raw)
  To: netdev; +Cc: tremyfr, tklauser, davem, thierry.reding, andrew,
	Florian Fainelli

Spamming the console with: net eth1: packet dropped can happen
fairly frequently if the adapter is busy transmitting, demote the
message to a debug print.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/ethoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 8d0cb5ce87ee..45abc81f6f55 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -576,7 +576,7 @@ static irqreturn_t ethoc_interrupt(int irq, void *dev_id)
 
 	/* We always handle the dropped packet interrupt */
 	if (pending & INT_MASK_BUSY) {
-		dev_err(&dev->dev, "packet dropped\n");
+		dev_dbg(&dev->dev, "packet dropped\n");
 		dev->stats.rx_dropped++;
 	}
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 1/3] net: ethoc: Account for duplex changes
  2016-12-04 20:40 ` [PATCH net-next 1/3] net: ethoc: Account for duplex changes Florian Fainelli
@ 2016-12-05  7:20   ` Tobias Klauser
  2016-12-05  8:00   ` Thierry Reding
  1 sibling, 0 replies; 11+ messages in thread
From: Tobias Klauser @ 2016-12-05  7:20 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, tremyfr, davem, thierry.reding, andrew

On 2016-12-04 at 21:40:28 +0100, Florian Fainelli <f.fainelli@gmail.com> wrote:
> ethoc_mdio_poll() which is our PHYLIB adjust_link callback does nothing,
> we should at least react to duplex changes and change MODER accordingly.
> Speed changes is not a problem, since the OpenCores Ethernet core seems
> to be reacting okay without us telling it.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Reviewed-by: Tobias Klauser <tklauser@distanz.ch>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/3] net: ethoc: Utilize of_get_mac_address()
  2016-12-04 20:40 ` [PATCH net-next 2/3] net: ethoc: Utilize of_get_mac_address() Florian Fainelli
@ 2016-12-05  7:20   ` Tobias Klauser
  2016-12-05  8:00   ` Thierry Reding
  1 sibling, 0 replies; 11+ messages in thread
From: Tobias Klauser @ 2016-12-05  7:20 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, tremyfr, davem, thierry.reding, andrew

On 2016-12-04 at 21:40:29 +0100, Florian Fainelli <f.fainelli@gmail.com> wrote:
> Do not open code getting the MAC address exclusively from the
> "local-mac-address" property, but instead use of_get_mac_address() which
> looks up the MAC address using the 3 typical property names.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Reviewed-by: Tobias Klauser <tklauser@distanz.ch>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 3/3] net: ethoc: Demote packet dropped error message to debug
  2016-12-04 20:40 ` [PATCH net-next 3/3] net: ethoc: Demote packet dropped error message to debug Florian Fainelli
@ 2016-12-05  7:21   ` Tobias Klauser
  2016-12-05  8:00   ` Thierry Reding
  1 sibling, 0 replies; 11+ messages in thread
From: Tobias Klauser @ 2016-12-05  7:21 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, tremyfr, davem, thierry.reding, andrew

On 2016-12-04 at 21:40:30 +0100, Florian Fainelli <f.fainelli@gmail.com> wrote:
> Spamming the console with: net eth1: packet dropped can happen
> fairly frequently if the adapter is busy transmitting, demote the
> message to a debug print.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Reviewed-by: Tobias Klauser <tklauser@distanz.ch>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 1/3] net: ethoc: Account for duplex changes
  2016-12-04 20:40 ` [PATCH net-next 1/3] net: ethoc: Account for duplex changes Florian Fainelli
  2016-12-05  7:20   ` Tobias Klauser
@ 2016-12-05  8:00   ` Thierry Reding
  1 sibling, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2016-12-05  8:00 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, tremyfr, tklauser, davem, andrew

[-- Attachment #1: Type: text/plain, Size: 575 bytes --]

On Sun, Dec 04, 2016 at 12:40:28PM -0800, Florian Fainelli wrote:
> ethoc_mdio_poll() which is our PHYLIB adjust_link callback does nothing,
> we should at least react to duplex changes and change MODER accordingly.
> Speed changes is not a problem, since the OpenCores Ethernet core seems
> to be reacting okay without us telling it.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/net/ethernet/ethoc.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)

Acked-by: Thierry Reding <thierry.reding@gmail.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/3] net: ethoc: Utilize of_get_mac_address()
  2016-12-04 20:40 ` [PATCH net-next 2/3] net: ethoc: Utilize of_get_mac_address() Florian Fainelli
  2016-12-05  7:20   ` Tobias Klauser
@ 2016-12-05  8:00   ` Thierry Reding
  1 sibling, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2016-12-05  8:00 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, tremyfr, tklauser, davem, andrew

[-- Attachment #1: Type: text/plain, Size: 493 bytes --]

On Sun, Dec 04, 2016 at 12:40:29PM -0800, Florian Fainelli wrote:
> Do not open code getting the MAC address exclusively from the
> "local-mac-address" property, but instead use of_get_mac_address() which
> looks up the MAC address using the 3 typical property names.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/net/ethernet/ethoc.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

Acked-by: Thierry Reding <thierry.reding@gmail.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 3/3] net: ethoc: Demote packet dropped error message to debug
  2016-12-04 20:40 ` [PATCH net-next 3/3] net: ethoc: Demote packet dropped error message to debug Florian Fainelli
  2016-12-05  7:21   ` Tobias Klauser
@ 2016-12-05  8:00   ` Thierry Reding
  1 sibling, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2016-12-05  8:00 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, tremyfr, tklauser, davem, andrew

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

On Sun, Dec 04, 2016 at 12:40:30PM -0800, Florian Fainelli wrote:
> Spamming the console with: net eth1: packet dropped can happen
> fairly frequently if the adapter is busy transmitting, demote the
> message to a debug print.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/net/ethernet/ethoc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Thierry Reding <thierry.reding@gmail.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 0/3] net: ethoc: Misc improvements
  2016-12-04 20:40 [PATCH net-next 0/3] net: ethoc: Misc improvements Florian Fainelli
                   ` (2 preceding siblings ...)
  2016-12-04 20:40 ` [PATCH net-next 3/3] net: ethoc: Demote packet dropped error message to debug Florian Fainelli
@ 2016-12-05 20:30 ` David Miller
  3 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2016-12-05 20:30 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, tremyfr, tklauser, thierry.reding, andrew

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Sun,  4 Dec 2016 12:40:27 -0800

> This patch series fixes/improves a few things:
> 
> - implement a proper PHYLIB adjust_link callback to set the duplex mode
>   accordingly
> - do not open code the fetching of a MAC address in OF/DT environments
> - demote an error message that occurs more frequently than expected in low
>   CPU/memory/bandwidth environments
> 
> Tested on a Cirrus Logic EP93xx / TS7300 board.

Series applied, thanks Florian.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-12-05 20:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-04 20:40 [PATCH net-next 0/3] net: ethoc: Misc improvements Florian Fainelli
2016-12-04 20:40 ` [PATCH net-next 1/3] net: ethoc: Account for duplex changes Florian Fainelli
2016-12-05  7:20   ` Tobias Klauser
2016-12-05  8:00   ` Thierry Reding
2016-12-04 20:40 ` [PATCH net-next 2/3] net: ethoc: Utilize of_get_mac_address() Florian Fainelli
2016-12-05  7:20   ` Tobias Klauser
2016-12-05  8:00   ` Thierry Reding
2016-12-04 20:40 ` [PATCH net-next 3/3] net: ethoc: Demote packet dropped error message to debug Florian Fainelli
2016-12-05  7:21   ` Tobias Klauser
2016-12-05  8:00   ` Thierry Reding
2016-12-05 20:30 ` [PATCH net-next 0/3] net: ethoc: Misc improvements David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.