mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: chf.fritz@googlemail.com
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 3/3] net cpsw: check phy status on send and receive
Date: Mon, 5 May 2014 09:22:33 +0200	[thread overview]
Message-ID: <20140505072233.GT5858@pengutronix.de> (raw)
In-Reply-To: <5360b51b.c62a980a.05b6.526e@mx.google.com>

On Wed, Apr 30, 2014 at 10:32:03AM +0200, chf.fritz@googlemail.com wrote:
> From: Christoph Fritz <chf.fritz@googlemail.com>
> 
> This patch adds phy status checks on cpsw_send() and cpsw_recv().
> This is derived from upstream.

What's the motivation for this? We already call phy_update_status every
5 seconds which then calls phy_device->adjust_link. Isn't this enough?

Sascha

> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> ---
>  drivers/net/cpsw.c |   24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
> index ec3263d..9e7b320 100644
> --- a/drivers/net/cpsw.c
> +++ b/drivers/net/cpsw.c
> @@ -229,6 +229,9 @@ struct cpsw_priv {
>  	struct cpdma_chan		rx_chan, tx_chan;
>  
>  	struct cpsw_slave		*slaves;
> +
> +	u32				mdio_link;
> +	u32				phy_mask;
>  };
>  
>  static int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits)
> @@ -608,14 +611,28 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave,
>  static int cpsw_update_link(struct cpsw_slave *slave, struct cpsw_priv *priv)
>  {
>  	int link = 0;
> +	struct cpsw_mdio_regs *mdio_regs = priv->mdio_regs;
>  
>  	dev_dbg(priv->dev, "* %s\n", __func__);
>  
>  	cpsw_slave_update_link(slave, priv, &link);
>  
> +	priv->mdio_link = readl(&mdio_regs->link);
>  	return link;
>  }
>  
> +static int cpsw_check_link(struct cpsw_priv *priv)
> +{
> +	u32 link = 0;
> +	struct cpsw_mdio_regs *mdio_regs = priv->mdio_regs;
> +
> +	link = readl(&mdio_regs->link) & priv->phy_mask;
> +	if ((link) && (link == priv->mdio_link))
> +		return 1;
> +
> +	return cpsw_update_link(&priv->slaves[0], priv);
> +}
> +
>  static void cpsw_adjust_link(struct eth_device *edev)
>  {
>  	struct cpsw_slave *slave = edev->priv;
> @@ -657,6 +674,8 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv)
>  
>  	/* add broadcast address */
>  	cpsw_ale_add_mcast(priv, ethbdaddr, 1 << slave_port);
> +
> +	priv->phy_mask |= 1 << slave->phy_id;
>  }
>  
>  static struct cpdma_desc *cpdma_desc_alloc(struct cpsw_priv *priv)
> @@ -874,6 +893,9 @@ static int cpsw_send(struct eth_device *edev, void *packet, int length)
>  
>  	dev_dbg(priv->dev, "* %s\n", __func__);
>  
> +	if (!cpsw_check_link(priv))
> +		return -EIO;
> +
>  	/* first reap completed packets */
>  	while (cpdma_process(priv, &priv->tx_chan, &buffer, &len) >= 0);
>  
> @@ -893,6 +915,8 @@ static int cpsw_recv(struct eth_device *edev)
>  	void *buffer;
>  	int len;
>  
> +	cpsw_check_link(priv);
> +
>  	while (cpdma_process(priv, &priv->rx_chan, &buffer, &len) >= 0) {
>  		dma_inv_range((ulong)buffer, (ulong)buffer + len);
>  		net_receive(buffer, len);
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-05-05  7:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1398846723-10241-1-git-send-email-y>
2014-04-30  8:32 ` [PATCH 1/3] tftp: add timeframe when remote server is retransmitting chf.fritz
2014-05-05  7:20   ` Sascha Hauer
2014-04-30  8:32 ` [PATCH 2/3] net cpsw: fix rx stability under heavy network load chf.fritz
2014-05-05  7:21   ` Sascha Hauer
2014-04-30  8:32 ` [PATCH 3/3] net cpsw: check phy status on send and receive chf.fritz
2014-05-05  7:22   ` Sascha Hauer [this message]
2014-05-05  8:36     ` Christoph Fritz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140505072233.GT5858@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=chf.fritz@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox