mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] tftp: add timeframe when remote server is retransmitting
       [not found] <1398846723-10241-1-git-send-email-y>
@ 2014-04-30  8:32 ` 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-04-30  8:32 ` [PATCH 3/3] net cpsw: check phy status on send and receive chf.fritz
  2 siblings, 1 reply; 7+ messages in thread
From: chf.fritz @ 2014-04-30  8:32 UTC (permalink / raw)
  To: barebox

From: Christoph Fritz <chf@fritzc.com>

If there's packet loss and the remote server needs to retransmit,
there is falsely no timeframe left because TIMEOUT (server wait time)
and TFTP_TIMEOUT (abort timer) are the same.

This patch increases TFTP_TIMEOUT.

See RFC2349 for more info: http://tools.ietf.org/html/rfc2349

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 fs/tftp.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/tftp.c b/fs/tftp.c
index 9cad18f..b1a213e 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -33,14 +33,16 @@
 #include <kfifo.h>
 #include <sizes.h>
 
-#define TFTP_PORT	69	/* Well known TFTP port #		*/
-#define TIMEOUT		5	/* Seconds to timeout for a lost pkt	*/
+#define TFTP_PORT	69	/* Well known TFTP port number */
+
+/* Seconds to wait before remote server is allowed to resend a lost packet */
+#define TIMEOUT		5
 
 /* After this time without a response from the server we will resend a packet */
 #define TFTP_RESEND_TIMEOUT	SECOND
 
 /* After this time without progress we will bail out */
-#define TFTP_TIMEOUT		(TIMEOUT * SECOND)
+#define TFTP_TIMEOUT		((TIMEOUT * 3) * SECOND)
 
 /*
  *	TFTP operations.
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/3] net cpsw: fix rx stability under heavy network load
       [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-04-30  8:32 ` 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
  2 siblings, 1 reply; 7+ messages in thread
From: chf.fritz @ 2014-04-30  8:32 UTC (permalink / raw)
  To: barebox

From: Christoph Fritz <chf.fritz@googlemail.com>

RX DMA Head Descriptor Pointer can get 0 when there is a lot of traffic,
which results in a timeout error. A good way to provoke this error is by
sending lots of ARP requests. This patch makes sure that the RX DMA Head
Descriptor Pointer is set.

The origin driver, from which this is derived, already contains this fix.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 drivers/net/cpsw.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 52adf50..ec3263d 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -741,8 +741,13 @@ static int cpdma_process(struct cpsw_priv *priv, struct cpdma_chan *chan,
 	if (buffer)
 		*buffer = (void *)readl(&desc->sw_buffer);
 
-	if (status & CPDMA_DESC_OWNER)
+	if (status & CPDMA_DESC_OWNER) {
+		if (readl(chan->hdp) == 0) {
+			if (readl(&desc->hw_mode) & CPDMA_DESC_OWNER)
+				writel((u32)desc, chan->hdp);
+		}
 		return -EBUSY;
+	}
 
 	chan->head = (void *)readl(&desc->hw_next);
 
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/3] net cpsw: check phy status on send and receive
       [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-04-30  8:32 ` [PATCH 2/3] net cpsw: fix rx stability under heavy network load chf.fritz
@ 2014-04-30  8:32 ` chf.fritz
  2014-05-05  7:22   ` Sascha Hauer
  2 siblings, 1 reply; 7+ messages in thread
From: chf.fritz @ 2014-04-30  8:32 UTC (permalink / raw)
  To: barebox

From: Christoph Fritz <chf.fritz@googlemail.com>

This patch adds phy status checks on cpsw_send() and cpsw_recv().
This is derived from upstream.

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

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

* Re: [PATCH 1/3] tftp: add timeframe when remote server is retransmitting
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2014-05-05  7:20 UTC (permalink / raw)
  To: chf.fritz; +Cc: barebox

Hi Christoph,

On Wed, Apr 30, 2014 at 10:32:01AM +0200, chf.fritz@googlemail.com wrote:
> From: Christoph Fritz <chf@fritzc.com>
> 
> If there's packet loss and the remote server needs to retransmit,
> there is falsely no timeframe left because TIMEOUT (server wait time)
> and TFTP_TIMEOUT (abort timer) are the same.
> 
> This patch increases TFTP_TIMEOUT.
> 
> See RFC2349 for more info: http://tools.ietf.org/html/rfc2349
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>

Applied, thanks

Sascha

> ---
>  fs/tftp.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/tftp.c b/fs/tftp.c
> index 9cad18f..b1a213e 100644
> --- a/fs/tftp.c
> +++ b/fs/tftp.c
> @@ -33,14 +33,16 @@
>  #include <kfifo.h>
>  #include <sizes.h>
>  
> -#define TFTP_PORT	69	/* Well known TFTP port #		*/
> -#define TIMEOUT		5	/* Seconds to timeout for a lost pkt	*/
> +#define TFTP_PORT	69	/* Well known TFTP port number */
> +
> +/* Seconds to wait before remote server is allowed to resend a lost packet */
> +#define TIMEOUT		5
>  
>  /* After this time without a response from the server we will resend a packet */
>  #define TFTP_RESEND_TIMEOUT	SECOND
>  
>  /* After this time without progress we will bail out */
> -#define TFTP_TIMEOUT		(TIMEOUT * SECOND)
> +#define TFTP_TIMEOUT		((TIMEOUT * 3) * SECOND)
>  
>  /*
>   *	TFTP operations.
> -- 
> 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

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

* Re: [PATCH 2/3] net cpsw: fix rx stability under heavy network load
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2014-05-05  7:21 UTC (permalink / raw)
  To: chf.fritz; +Cc: barebox

On Wed, Apr 30, 2014 at 10:32:02AM +0200, chf.fritz@googlemail.com wrote:
> From: Christoph Fritz <chf.fritz@googlemail.com>
> 
> RX DMA Head Descriptor Pointer can get 0 when there is a lot of traffic,
> which results in a timeout error. A good way to provoke this error is by
> sending lots of ARP requests. This patch makes sure that the RX DMA Head
> Descriptor Pointer is set.
> 
> The origin driver, from which this is derived, already contains this fix.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>

Nice fix, thanks. I also stumbled upon this.

Applied

Sascha

> ---
>  drivers/net/cpsw.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
> index 52adf50..ec3263d 100644
> --- a/drivers/net/cpsw.c
> +++ b/drivers/net/cpsw.c
> @@ -741,8 +741,13 @@ static int cpdma_process(struct cpsw_priv *priv, struct cpdma_chan *chan,
>  	if (buffer)
>  		*buffer = (void *)readl(&desc->sw_buffer);
>  
> -	if (status & CPDMA_DESC_OWNER)
> +	if (status & CPDMA_DESC_OWNER) {
> +		if (readl(chan->hdp) == 0) {
> +			if (readl(&desc->hw_mode) & CPDMA_DESC_OWNER)
> +				writel((u32)desc, chan->hdp);
> +		}
>  		return -EBUSY;
> +	}
>  
>  	chan->head = (void *)readl(&desc->hw_next);
>  
> -- 
> 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

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

* Re: [PATCH 3/3] net cpsw: check phy status on send and receive
  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
  2014-05-05  8:36     ` Christoph Fritz
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2014-05-05  7:22 UTC (permalink / raw)
  To: chf.fritz; +Cc: barebox

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

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

* Re: [PATCH 3/3] net cpsw: check phy status on send and receive
  2014-05-05  7:22   ` Sascha Hauer
@ 2014-05-05  8:36     ` Christoph Fritz
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Fritz @ 2014-05-05  8:36 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Mon, 2014-05-05 at 09:22 +0200, Sascha Hauer wrote:
> 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?

I have no test to proof necessity. I'm fine dropping this patch.

 Thanks
  -- Christoph


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-05-05  8:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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
2014-05-05  8:36     ` Christoph Fritz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox