Netdev List
 help / color / mirror / Atom feed
* Re: [net-next PATCH v2] net: fix smatch warnings inside datagram_poll
From: David Miller @ 2013-04-02 21:01 UTC (permalink / raw)
  To: jacob.e.keller; +Cc: netdev
In-Reply-To: <20130402205539.26083.7462.stgit@jekeller-hub.jf.intel.com>

From: Jacob Keller <jacob.e.keller@intel.com>
Date: Tue,  2 Apr 2013 13:55:40 -0700

> Commit 7d4c04fc170087119727119074e72445f2bb192b ("net: add option to enable
> error queue packets waking select") has an issue due to operator precedence
> causing the bit-wise OR to bind to the sock_flags call instead of the result of
> the terniary conditional. This fixes the *_poll functions to work properly. The
> old code results in "mask |= POLLPRI" instead of what was intended, which is to
> only include POLLPRI when the socket option is enabled.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>

Much better, applied, thanks.

^ permalink raw reply

* [net-next PATCH v2] net: fix smatch warnings inside datagram_poll
From: Jacob Keller @ 2013-04-02 20:55 UTC (permalink / raw)
  To: netdev

Commit 7d4c04fc170087119727119074e72445f2bb192b ("net: add option to enable
error queue packets waking select") has an issue due to operator precedence
causing the bit-wise OR to bind to the sock_flags call instead of the result of
the terniary conditional. This fixes the *_poll functions to work properly. The
old code results in "mask |= POLLPRI" instead of what was intended, which is to
only include POLLPRI when the socket option is enabled.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 net/bluetooth/af_bluetooth.c |    2 +-
 net/core/datagram.c          |    2 +-
 net/iucv/af_iucv.c           |    2 +-
 net/nfc/llcp/sock.c          |    2 +-
 net/unix/af_unix.c           |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 409902f..fea778e 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -423,7 +423,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock,
 
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (sk->sk_shutdown & RCV_SHUTDOWN)
 		mask |= POLLRDHUP | POLLIN | POLLRDNORM;
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 36da5b6..ebba65d 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -750,7 +750,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
 	/* exceptional events? */
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (sk->sk_shutdown & RCV_SHUTDOWN)
 		mask |= POLLRDHUP | POLLIN | POLLRDNORM;
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index f0550a3..7dfb9ed 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1462,7 +1462,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
 
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (sk->sk_shutdown & RCV_SHUTDOWN)
 		mask |= POLLRDHUP;
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c
index 2d55e8a..6b32544 100644
--- a/net/nfc/llcp/sock.c
+++ b/net/nfc/llcp/sock.c
@@ -522,7 +522,7 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock,
 
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (!skb_queue_empty(&sk->sk_receive_queue))
 		mask |= POLLIN | POLLRDNORM;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index fb7a63f..2e4d900 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2197,7 +2197,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
 	/* exceptional events? */
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (sk->sk_shutdown & RCV_SHUTDOWN)
 		mask |= POLLRDHUP | POLLIN | POLLRDNORM;

^ permalink raw reply related

* RE: [net-next PATCH] net: fix smatch warnings inside datagram_poll
From: Keller, Jacob E @ 2013-04-02 20:46 UTC (permalink / raw)
  To: David Miller; +Cc: netdev@vger.kernel.org
In-Reply-To: <20130402.164025.2237059970586581339.davem@davemloft.net>

> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-
> owner@vger.kernel.org] On Behalf Of David Miller
> Sent: Tuesday, April 02, 2013 1:40 PM
> To: Keller, Jacob E
> Cc: netdev@vger.kernel.org
> Subject: Re: [net-next PATCH] net: fix smatch warnings inside
> datagram_poll
> 
> From: Jacob Keller <jacob.e.keller@intel.com>
> Date: Tue,  2 Apr 2013 13:34:15 -0700
> 
> > The code for commit 1218a2a1d233fd604a41e584163ec291418f8ea8
> actually turns out
> > to be incorrect.
> 
> This commit object SHA ID is not correct, it should be
> 7d4c04fc170087119727119074e72445f2bb192b.
> 
> Also, when referencing commits, always follow the SHA ID with the
> commit
> log message header line, enclosed in both parenthesis and double
> quotes.

Ok sorry about that. I will resend with correct format. Not sure how I had wrong commit ID.

Thanks

- Jake
 

^ permalink raw reply

* Re: [PATCH 0/5] Provide empty functions if OF_NET is not configured
From: David Miller @ 2013-04-02 20:44 UTC (permalink / raw)
  To: linux
  Cc: nicolas.ferre, grant.likely, rob.herring, david.daney, netdev,
	linux-kernel, devicetree-discuss
In-Reply-To: <1364931311-30603-1-git-send-email-linux@roeck-us.net>

From: Guenter Roeck <linux@roeck-us.net>
Date: Tue,  2 Apr 2013 12:35:06 -0700

> Provide empty functions for of_get_phy_mode() and of_get_mac_address()
> if OF_NET is not configured. Modify affected drivers to rely on the
> now available functions.

All applied, but please post your patches against the appropriate
tree.

In net-next, fec.c has been renamed to fec_main.c so I had to adjust
your patch so that it would apply correctly.

^ permalink raw reply

* Re: [net-next PATCH] net: fix smatch warnings inside datagram_poll
From: David Miller @ 2013-04-02 20:40 UTC (permalink / raw)
  To: jacob.e.keller; +Cc: netdev
In-Reply-To: <20130402203414.24602.6059.stgit@jekeller-hub.jf.intel.com>

From: Jacob Keller <jacob.e.keller@intel.com>
Date: Tue,  2 Apr 2013 13:34:15 -0700

> The code for commit 1218a2a1d233fd604a41e584163ec291418f8ea8 actually turns out
> to be incorrect.

This commit object SHA ID is not correct, it should be
7d4c04fc170087119727119074e72445f2bb192b.

Also, when referencing commits, always follow the SHA ID with the commit
log message header line, enclosed in both parenthesis and double quotes.

^ permalink raw reply

* [net-next PATCH] net: fix smatch warnings inside datagram_poll
From: Jacob Keller @ 2013-04-02 20:34 UTC (permalink / raw)
  To: netdev

The code for commit 1218a2a1d233fd604a41e584163ec291418f8ea8 actually turns out
to be incorrect. This fixes the *_poll functions to work properly. The old code
results in "mask |= POLLPRI" instead of what was intended, due to incorrect
assumption about operator precedence.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 net/bluetooth/af_bluetooth.c |    2 +-
 net/core/datagram.c          |    2 +-
 net/iucv/af_iucv.c           |    2 +-
 net/nfc/llcp/sock.c          |    2 +-
 net/unix/af_unix.c           |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 409902f..fea778e 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -423,7 +423,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock,
 
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (sk->sk_shutdown & RCV_SHUTDOWN)
 		mask |= POLLRDHUP | POLLIN | POLLRDNORM;
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 36da5b6..ebba65d 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -750,7 +750,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
 	/* exceptional events? */
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (sk->sk_shutdown & RCV_SHUTDOWN)
 		mask |= POLLRDHUP | POLLIN | POLLRDNORM;
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index f0550a3..7dfb9ed 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1462,7 +1462,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
 
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (sk->sk_shutdown & RCV_SHUTDOWN)
 		mask |= POLLRDHUP;
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c
index 2d55e8a..6b32544 100644
--- a/net/nfc/llcp/sock.c
+++ b/net/nfc/llcp/sock.c
@@ -522,7 +522,7 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock,
 
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (!skb_queue_empty(&sk->sk_receive_queue))
 		mask |= POLLIN | POLLRDNORM;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 2d2ccf8..b0dc7c2 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2198,7 +2198,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
 	/* exceptional events? */
 	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 		mask |= POLLERR |
-			sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
+			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
 	if (sk->sk_shutdown & RCV_SHUTDOWN)
 		mask |= POLLRDHUP | POLLIN | POLLRDNORM;

^ permalink raw reply related

* Re: [PATCH 1/6] mac802154: Immediately retry sending failed packets
From: Alan Ott @ 2013-04-02 20:28 UTC (permalink / raw)
  To: Alexander Smirnov
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller,
	linux-zigbee-devel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <CAJmB2rCr5ds11+iN=W5GCKsUgdfb57uKg+mH4NY4CWw6EFCTbg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 04/02/2013 03:11 PM, Alexander Smirnov wrote:
> 2013/4/2 Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org <mailto:alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>>
> 
>     When ops->xmit() fails, immediately retry. Previously the packet was
>     sent
>     to the back of the workqueue.
> 
>     Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org <mailto:alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>>
>     ---
>      net/mac802154/tx.c | 17 ++++++++---------
>      1 file changed, 8 insertions(+), 9 deletions(-)
> 
>     diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
>     index 4e09d07..fbf937c 100644
>     --- a/net/mac802154/tx.c
>     +++ b/net/mac802154/tx.c
>     @@ -59,19 +59,18 @@ static void mac802154_xmit_worker(struct
>     work_struct *work)
>                     }
>             }
> 
>     -       res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
>     +       do {
>     +               res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
>     +               if (res && ++xw->xmit_attempts >=
>     MAC802154_MAX_XMIT_ATTEMPTS) {
>     +                       pr_debug("transmission failed for %d times",
>     +                                MAC802154_MAX_XMIT_ATTEMPTS);
>     +                       break;
>     +               }
>     +       } while (res);
> 
>  
> 
> IIRC this 802.15.4 stack uses single-thread-work-queue and all RX/TX
> are performed by using it.

Hi Alexander,

Yes, that is true. As is currently implemented, the driver xmit()
functions are called from a workqueue and block until the packet is sent.


> Doing TX retry in the way you proposed -
> it's possible that you will block other packets pending in this
> queue.

Yes. Since sending data is a blocking operation, any time spent sending
(or re-sending) is blocking.

As it was before this patch series, with the buffer (workqueue) growing
arbitrarily large, doing retry by putting a packet at the end of the
workqueue was largely useless because by the time it came to retry it,
any state associated with it (with respect to fragmentation/reassembly)
had expired.

Keep in mind that with the netif stop/wake code, putting retries at the
end of the workqueue or doing them immediately is basically the same
thing, since the workqueue is no longer the packet queue (and will
ideally only have 0 or 1 packets in it). The workqueue (with these
patches) only serves to lift the driver xmit() calls out of atomic
context, allowing them to block.

However, it is easy to envision one process clogging up the works with
retries by sending many packets to an unavailable address.

What do you recommend doing here instead?

> Despite on Linux is already 'slow' system to provide
> real-time for specific 802.15.4 features, I think it's not a good
> idea to increase nodes communication latency.

With the transmit buffer length increased (and actually being used),
maybe the packets with realtime requirements can be given a higher
priority to deal with these requirements.

Alan.

> 
> 
>      out:
>             mutex_unlock(&xw->priv->phy->pib_lock);
> 
>     -       if (res) {
>     -               if (xw->xmit_attempts++ < MAC802154_MAX_XMIT_ATTEMPTS) {
>     -                       queue_work(xw->priv->dev_workqueue, &xw->work);
>     -                       return;
>     -               } else
>     -                       pr_debug("transmission failed for %d times",
>     -                                MAC802154_MAX_XMIT_ATTEMPTS);
>     -       }
> 
>             dev_kfree_skb(xw->skb);
> 
>     --
>     1.7.11.2
> 
> 


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

^ permalink raw reply

* WSN 2013 call for papers
From: Alexander Smirnov @ 2013-04-02 19:39 UTC (permalink / raw)
  To: open list:NETWORKING [GENERAL],
	linux-wireless-u79uwXL29TY76Z2rM5mHXA, linux-zigbee-devel,
	Michal Hodoň


[-- Attachment #1.1: Type: text/plain, Size: 243 bytes --]

*Dear colleagues,

*
*I'd like to invite you to International Conference on Innovative Network
and Applications (iNetSApp) which will take place in Krakow in September
8-11, 2013.

*
*Please find the detailed agenda in attachments.

*
*Alex
*

[-- Attachment #1.2: Type: text/html, Size: 348 bytes --]

[-- Attachment #2: WSN2013_CALL FOR PAPERS.pdf --]
[-- Type: application/pdf, Size: 195666 bytes --]

[-- Attachment #3: Type: text/plain, Size: 351 bytes --]

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

[-- Attachment #4: Type: text/plain, Size: 213 bytes --]

_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

^ permalink raw reply

* [PATCH 5/5] net/nxp/lpc_eth: Drop ifdef CONFIG_OF_NET
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
  To: David S. Miller, Nicolas Ferre, Grant Likely
  Cc: David Daney, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Guenter Roeck
In-Reply-To: <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>

Since of_get_mac_address() is now declared even if CONFIG_OF_NET
is not configured, the ifdef is no longer necessary and can be
removed.

Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
---
 drivers/net/ethernet/nxp/lpc_eth.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index efa29b7..99276d7 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1434,13 +1434,11 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
 	/* Get MAC address from current HW setting (POR state is all zeros) */
 	__lpc_get_mac(pldat, ndev->dev_addr);
 
-#ifdef CONFIG_OF_NET
 	if (!is_valid_ether_addr(ndev->dev_addr)) {
 		const char *macaddr = of_get_mac_address(pdev->dev.of_node);
 		if (macaddr)
 			memcpy(ndev->dev_addr, macaddr, ETH_ALEN);
 	}
-#endif
 	if (!is_valid_ether_addr(ndev->dev_addr))
 		eth_hw_addr_random(ndev);
 
-- 
1.7.9.7

^ permalink raw reply related

* [PATCH 4/5] net/freescale/fec: Simplify OF dependencies
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
  To: David S. Miller, Nicolas Ferre, Grant Likely
  Cc: David Daney, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Guenter Roeck
In-Reply-To: <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>

Since of_get_mac_address() is now defined even if CONFIG_OF_NET
is not configured, the ifdef around the code calling it is no longer
necessary and can be removed.

Similar, since of_get_phy_mode() is now defined as dummy function
if OF_NET is not configured, it is no longer necessary to provide
an OF dependent function as front-end. Also, the function depends
on OF_NET, not on OF, so the conditional code was not correct anyway.
Drop the front-end function and call of_get_phy_mode() directly.

Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
---
 drivers/net/ethernet/freescale/fec.c |   19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 911d025..d374a94 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -868,7 +868,6 @@ static void fec_get_mac(struct net_device *ndev)
 	 */
 	iap = macaddr;
 
-#ifdef CONFIG_OF
 	/*
 	 * 2) from device tree data
 	 */
@@ -880,7 +879,6 @@ static void fec_get_mac(struct net_device *ndev)
 				iap = (unsigned char *) mac;
 		}
 	}
-#endif
 
 	/*
 	 * 3) from flash or fuse (via platform data)
@@ -1666,16 +1664,6 @@ static int fec_enet_init(struct net_device *ndev)
 }
 
 #ifdef CONFIG_OF
-static int fec_get_phy_mode_dt(struct platform_device *pdev)
-{
-	struct device_node *np = pdev->dev.of_node;
-
-	if (np)
-		return of_get_phy_mode(np);
-
-	return -ENODEV;
-}
-
 static void fec_reset_phy(struct platform_device *pdev)
 {
 	int err, phy_reset;
@@ -1704,11 +1692,6 @@ static void fec_reset_phy(struct platform_device *pdev)
 	gpio_set_value(phy_reset, 1);
 }
 #else /* CONFIG_OF */
-static int fec_get_phy_mode_dt(struct platform_device *pdev)
-{
-	return -ENODEV;
-}
-
 static void fec_reset_phy(struct platform_device *pdev)
 {
 	/*
@@ -1773,7 +1756,7 @@ fec_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ndev);
 
-	ret = fec_get_phy_mode_dt(pdev);
+	ret = of_get_phy_mode(pdev->dev.of_node);
 	if (ret < 0) {
 		pdata = pdev->dev.platform_data;
 		if (pdata)
-- 
1.7.9.7

^ permalink raw reply related

* [PATCH 3/5] net/cadence/macb: Simplify OF dependencies
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
  To: David S. Miller, Nicolas Ferre, Grant Likely
  Cc: David Daney, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Guenter Roeck
In-Reply-To: <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>

With of_get_mac_address() and of_get_phy_mode() now defined as dummy
functions if OF_NET is not configured, it is no longer necessary to
provide OF dependent functions as front-end. Also, the two functions
depend on OF_NET, not on OF, so the conditional code was not correct
anyway.

Drop the front-end functions and call of_get_mac_address() and
of_get_phy_mode() directly instead.

Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
---
 drivers/net/ethernet/cadence/macb.c |   43 +++++------------------------------
 1 file changed, 6 insertions(+), 37 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 7903943..b2a9d20 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1472,41 +1472,7 @@ static const struct of_device_id macb_dt_ids[] = {
 	{ .compatible = "cdns,gem" },
 	{ /* sentinel */ }
 };
-
 MODULE_DEVICE_TABLE(of, macb_dt_ids);
-
-static int macb_get_phy_mode_dt(struct platform_device *pdev)
-{
-	struct device_node *np = pdev->dev.of_node;
-
-	if (np)
-		return of_get_phy_mode(np);
-
-	return -ENODEV;
-}
-
-static int macb_get_hwaddr_dt(struct macb *bp)
-{
-	struct device_node *np = bp->pdev->dev.of_node;
-	if (np) {
-		const char *mac = of_get_mac_address(np);
-		if (mac) {
-			memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
-			return 0;
-		}
-	}
-
-	return -ENODEV;
-}
-#else
-static int macb_get_phy_mode_dt(struct platform_device *pdev)
-{
-	return -ENODEV;
-}
-static int macb_get_hwaddr_dt(struct macb *bp)
-{
-	return -ENODEV;
-}
 #endif
 
 static int __init macb_probe(struct platform_device *pdev)
@@ -1519,6 +1485,7 @@ static int __init macb_probe(struct platform_device *pdev)
 	u32 config;
 	int err = -ENXIO;
 	struct pinctrl *pinctrl;
+	const char *mac;
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!regs) {
@@ -1592,11 +1559,13 @@ static int __init macb_probe(struct platform_device *pdev)
 	config |= macb_dbw(bp);
 	macb_writel(bp, NCFGR, config);
 
-	err = macb_get_hwaddr_dt(bp);
-	if (err < 0)
+	mac = of_get_mac_address(pdev->dev.of_node);
+	if (mac)
+		memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
+	else
 		macb_get_hwaddr(bp);
 
-	err = macb_get_phy_mode_dt(pdev);
+	err = of_get_phy_mode(pdev->dev.of_node);
 	if (err < 0) {
 		pdata = pdev->dev.platform_data;
 		if (pdata && pdata->is_rmii)
-- 
1.7.9.7

^ permalink raw reply related

* [PATCH 2/5] net/cadence/at91_ether: Simplify OF dependencies
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
  To: David S. Miller, Nicolas Ferre, Grant Likely
  Cc: Rob Herring, David Daney, netdev, linux-kernel,
	devicetree-discuss, Guenter Roeck
In-Reply-To: <1364931311-30603-1-git-send-email-linux@roeck-us.net>

With of_get_mac_address() and of_get_phy_mode() now defined as dummy
functions if OF_NET is not configured, it is no longer necessary to
provide OF dependent functions as front-end. Also, the two functions
depend on OF_NET, not on OF, so the conditional code was not correct
anyway.

Drop the front-end functions and call of_get_mac_address() and
of_get_phy_mode() directly instead.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/net/ethernet/cadence/at91_ether.c |   44 ++++-------------------------
 1 file changed, 6 insertions(+), 38 deletions(-)

diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 3becdb2..50565cb 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -303,42 +303,7 @@ static const struct of_device_id at91ether_dt_ids[] = {
 	{ .compatible = "cdns,emac" },
 	{ /* sentinel */ }
 };
-
 MODULE_DEVICE_TABLE(of, at91ether_dt_ids);
-
-static int at91ether_get_phy_mode_dt(struct platform_device *pdev)
-{
-	struct device_node *np = pdev->dev.of_node;
-
-	if (np)
-		return of_get_phy_mode(np);
-
-	return -ENODEV;
-}
-
-static int at91ether_get_hwaddr_dt(struct macb *bp)
-{
-	struct device_node *np = bp->pdev->dev.of_node;
-
-	if (np) {
-		const char *mac = of_get_mac_address(np);
-		if (mac) {
-			memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
-			return 0;
-		}
-	}
-
-	return -ENODEV;
-}
-#else
-static int at91ether_get_phy_mode_dt(struct platform_device *pdev)
-{
-	return -ENODEV;
-}
-static int at91ether_get_hwaddr_dt(struct macb *bp)
-{
-	return -ENODEV;
-}
 #endif
 
 /* Detect MAC & PHY and perform ethernet interface initialization */
@@ -352,6 +317,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
 	struct macb *lp;
 	int res;
 	u32 reg;
+	const char *mac;
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!regs)
@@ -403,11 +369,13 @@ static int __init at91ether_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, dev);
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
-	res = at91ether_get_hwaddr_dt(lp);
-	if (res < 0)
+	mac = of_get_mac_address(pdev->dev.of_node);
+	if (mac)
+		memcpy(lp->dev->dev_addr, mac, ETH_ALEN);
+	else
 		macb_get_hwaddr(lp);
 
-	res = at91ether_get_phy_mode_dt(pdev);
+	res = of_get_phy_mode(pdev->dev.of_node);
 	if (res < 0) {
 		if (board_data && board_data->is_rmii)
 			lp->phy_interface = PHY_INTERFACE_MODE_RMII;
-- 
1.7.9.7

^ permalink raw reply related

* [PATCH 1/5] of_net.h: Provide empty functions if OF_NET is not configured
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
  To: David S. Miller, Nicolas Ferre, Grant Likely
  Cc: David Daney, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Guenter Roeck
In-Reply-To: <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>

of_get_mac_address() and of_get_phy_mode() are only provided if OF_NET
is configured. While most callers check for the define, not all do, and those
who do require #ifdef around the code. For those who don't, the missing check
can result in errors such as

arch/powerpc/sysdev/tsi108_dev.c:107:3: error: implicit declaration of
	function 'of_get_mac_address' [-Werror=implicit-function-declaration]
arch/powerpc/sysdev/mv64x60_dev.c:253:2: error: implicit declaration of
	function 'of_get_mac_address' [-Werror=implicit-function-declaration]

Provide empty functions if OF_NET is not configured.
This is safe because all callers do check the return values.

Cc: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Acked-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
---
 include/linux/of_net.h |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index f474641..61bf53b 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -11,6 +11,16 @@
 #include <linux/of.h>
 extern const int of_get_phy_mode(struct device_node *np);
 extern const void *of_get_mac_address(struct device_node *np);
+#else
+static inline const int of_get_phy_mode(struct device_node *np)
+{
+	return -ENODEV;
+}
+
+static inline const void *of_get_mac_address(struct device_node *np)
+{
+	return NULL;
+}
 #endif
 
 #endif /* __LINUX_OF_NET_H */
-- 
1.7.9.7

^ permalink raw reply related

* [PATCH 0/5] Provide empty functions if OF_NET is not configured
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
  To: David S. Miller, Nicolas Ferre, Grant Likely
  Cc: Rob Herring, David Daney, netdev, linux-kernel,
	devicetree-discuss, Guenter Roeck

Provide empty functions for of_get_phy_mode() and of_get_mac_address()
if OF_NET is not configured. Modify affected drivers to rely on the
now available functions.

----------------------------------------------------------------
Guenter Roeck (5):
      of_net.h: Provide dummy functions if OF_NET is not configured
      net/cadence/at91_ether: Simplify OF dependencies
      net/cadence/macb: Simplify OF dependencies
      net/freescale/fec: Simplify OF dependencies
      net/nxp/lpc_eth: Drop ifdef CONFIG_OF_NET

 drivers/net/ethernet/cadence/at91_ether.c |   44 ++++-------------------------
 drivers/net/ethernet/cadence/macb.c       |   43 ++++------------------------
 drivers/net/ethernet/freescale/fec.c      |   19 +------------
 drivers/net/ethernet/nxp/lpc_eth.c        |    2 --
 include/linux/of_net.h                    |   10 +++++++
 5 files changed, 23 insertions(+), 95 deletions(-)

^ permalink raw reply

* Re: [PATCH 5/6] 6lowpan: handle dev_queue_xmit error code properly
From: Alan Ott @ 2013-04-02 19:30 UTC (permalink / raw)
  To: Alexander Smirnov
  Cc: open list:NETWORKING [GENERAL], David S. Miller,
	linux-zigbee-devel
In-Reply-To: <CAJmB2rB+9-gLV=SVvr4JUc2swjmTaWxD0gYM5VLw8PL1d455JA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1649 bytes --]

On 04/02/2013 03:21 PM, Alexander Smirnov wrote:
>
>
>
> 2013/4/2 Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org <mailto:alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>>
>
>     dev_queue_xmit() can return positive error codes, so check for
>     nonzero.
>
>     Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org <mailto:alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>>
>     ---
>      net/ieee802154/6lowpan.c | 2 +-
>      1 file changed, 1 insertion(+), 1 deletion(-)
>
>     diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
>     index e1b4580..a68c792 100644
>     --- a/net/ieee802154/6lowpan.c
>     +++ b/net/ieee802154/6lowpan.c
>     @@ -1139,7 +1139,7 @@ static netdev_tx_t lowpan_xmit(struct
>     sk_buff *skb, struct net_device *dev)
>      error:
>             dev_kfree_skb(skb);
>      out:
>     -       if (err < 0)
>     +       if (err)
>
> lets say ok....
>
>                     pr_debug("ERROR: xmit failed\n");
>
>             return (err < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK);
>
> but here you still checks for negative error only, why?

That's fixed in the next patch (6/6). Maybe 5/6 and 6/6 should be
squashed? It's the same fundamental problem, but with different
implications (as described in the commit messages). 5/6 is about the
error (debug) message being not shown all the times it needs to be, and
6/6 is about returning the correct error code to the higher layer[1].

Alan.

[1] I'm never sure, given "make a patch do one thing only," where to
draw the line between having fewer patches which are larger, and having
more smaller patches which are easier to understand.


[-- Attachment #1.2: Type: text/html, Size: 3250 bytes --]

[-- Attachment #2: Type: text/plain, Size: 351 bytes --]

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

[-- Attachment #3: Type: text/plain, Size: 213 bytes --]

_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

^ permalink raw reply

* Re: [PATCH 6/6] 6lowpan: return the dev_queue_xmit() return value from lowpan_xmit()
From: Alexander Smirnov @ 2013-04-02 19:27 UTC (permalink / raw)
  To: Alan Ott
  Cc: open list:NETWORKING [GENERAL], David S. Miller,
	linux-zigbee-devel
In-Reply-To: <1364928481-1813-7-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1055 bytes --]

2013/4/2 Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>

> dev_queue_xmit() will return a positive value if the packet could not be
> queued, often because the real network device (in our case the mac802154
> wpan device) has its queue stopped.  lowpan_xmit() should return that value
> to the higher layer so the higher layer will retry sending the packet.
>
> Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
> ---
>  net/ieee802154/6lowpan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
> index a68c792..55e1fd5 100644
> --- a/net/ieee802154/6lowpan.c
> +++ b/net/ieee802154/6lowpan.c
> @@ -1142,7 +1142,7 @@ out:
>         if (err)
>                 pr_debug("ERROR: xmit failed\n");
>
> -       return (err < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK);
> +       return (err < 0) ? NET_XMIT_DROP : err;
>  }
>
>  static struct wpan_phy *lowpan_get_phy(const struct net_device *dev)
> --
> 1.7.11.2
>
> this patch should be a part of previous one.

[-- Attachment #1.2: Type: text/html, Size: 1585 bytes --]

[-- Attachment #2: Type: text/plain, Size: 351 bytes --]

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

[-- Attachment #3: Type: text/plain, Size: 213 bytes --]

_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

^ permalink raw reply

* Re: [PATCH 5/6] 6lowpan: handle dev_queue_xmit error code properly
From: Alexander Smirnov @ 2013-04-02 19:21 UTC (permalink / raw)
  To: Alan Ott
  Cc: open list:NETWORKING [GENERAL], David S. Miller,
	linux-zigbee-devel
In-Reply-To: <1364928481-1813-6-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 876 bytes --]

2013/4/2 Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>

> dev_queue_xmit() can return positive error codes, so check for nonzero.
>
> Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
> ---
>  net/ieee802154/6lowpan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
> index e1b4580..a68c792 100644
> --- a/net/ieee802154/6lowpan.c
> +++ b/net/ieee802154/6lowpan.c
> @@ -1139,7 +1139,7 @@ static netdev_tx_t lowpan_xmit(struct sk_buff *skb,
> struct net_device *dev)
>  error:
>         dev_kfree_skb(skb);
>  out:
> -       if (err < 0)
> +       if (err)
>
lets say ok....

>                 pr_debug("ERROR: xmit failed\n");
>
>         return (err < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK);
>
but here you still checks for negative error only, why?

> --
> 1.7.11.2
>
>

[-- Attachment #1.2: Type: text/html, Size: 1620 bytes --]

[-- Attachment #2: Type: text/plain, Size: 351 bytes --]

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

[-- Attachment #3: Type: text/plain, Size: 213 bytes --]

_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

^ permalink raw reply

* Re: [PATCH 1/6] mac802154: Immediately retry sending failed packets
From: Alexander Smirnov @ 2013-04-02 19:11 UTC (permalink / raw)
  To: Alan Ott
  Cc: open list:NETWORKING [GENERAL], David S. Miller,
	linux-zigbee-devel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1364928481-1813-2-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1944 bytes --]

2013/4/2 Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>

> When ops->xmit() fails, immediately retry. Previously the packet was sent
> to the back of the workqueue.
>
> Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
> ---
>  net/mac802154/tx.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
> index 4e09d07..fbf937c 100644
> --- a/net/mac802154/tx.c
> +++ b/net/mac802154/tx.c
> @@ -59,19 +59,18 @@ static void mac802154_xmit_worker(struct work_struct
> *work)
>                 }
>         }
>
> -       res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
> +       do {
> +               res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
> +               if (res && ++xw->xmit_attempts >=
> MAC802154_MAX_XMIT_ATTEMPTS) {
> +                       pr_debug("transmission failed for %d times",
> +                                MAC802154_MAX_XMIT_ATTEMPTS);
> +                       break;
> +               }
> +       } while (res);
>


> IIRC this 802.15.4 stack uses single-thread-work-queue and all RX/TX are
> performed by using it. Doing TX retry in the way you proposed - it's
> possible that you will block other packets pending in this queue. Despite
> on Linux is already 'slow' system to provide real-time for specific
> 802.15.4 features, I think it's not a good idea to increase nodes
> communication latency.
>
>
>  out:
>         mutex_unlock(&xw->priv->phy->pib_lock);
>
> -       if (res) {
> -               if (xw->xmit_attempts++ < MAC802154_MAX_XMIT_ATTEMPTS) {
> -                       queue_work(xw->priv->dev_workqueue, &xw->work);
> -                       return;
> -               } else
> -                       pr_debug("transmission failed for %d times",
> -                                MAC802154_MAX_XMIT_ATTEMPTS);
> -       }
>
>         dev_kfree_skb(xw->skb);
>
> --
> 1.7.11.2
>
>

[-- Attachment #1.2: Type: text/html, Size: 2844 bytes --]

[-- Attachment #2: Type: text/plain, Size: 351 bytes --]

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

[-- Attachment #3: Type: text/plain, Size: 213 bytes --]

_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

^ permalink raw reply

* [PATCH 6/6] 6lowpan: return the dev_queue_xmit() return value from lowpan_xmit()
From: Alan Ott @ 2013-04-02 18:48 UTC (permalink / raw)
  To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller
  Cc: Alan Ott, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1364928481-1813-1-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>

dev_queue_xmit() will return a positive value if the packet could not be
queued, often because the real network device (in our case the mac802154
wpan device) has its queue stopped.  lowpan_xmit() should return that value
to the higher layer so the higher layer will retry sending the packet.

Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
---
 net/ieee802154/6lowpan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index a68c792..55e1fd5 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1142,7 +1142,7 @@ out:
 	if (err)
 		pr_debug("ERROR: xmit failed\n");
 
-	return (err < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK);
+	return (err < 0) ? NET_XMIT_DROP : err;
 }
 
 static struct wpan_phy *lowpan_get_phy(const struct net_device *dev)
-- 
1.7.11.2


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

^ permalink raw reply related

* [PATCH 5/6] 6lowpan: handle dev_queue_xmit error code properly
From: Alan Ott @ 2013-04-02 18:48 UTC (permalink / raw)
  To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller
  Cc: Alan Ott, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1364928481-1813-1-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>

dev_queue_xmit() can return positive error codes, so check for nonzero.

Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
---
 net/ieee802154/6lowpan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index e1b4580..a68c792 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1139,7 +1139,7 @@ static netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
 error:
 	dev_kfree_skb(skb);
 out:
-	if (err < 0)
+	if (err)
 		pr_debug("ERROR: xmit failed\n");
 
 	return (err < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK);
-- 
1.7.11.2


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

^ permalink raw reply related

* [PATCH 4/6] mac802154: Increase tx_buffer_len
From: Alan Ott @ 2013-04-02 18:47 UTC (permalink / raw)
  To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller
  Cc: Alan Ott, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1364928481-1813-1-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>

Increase the buffer length from 10 to 300 packets. Consider that traffic on
mac802154 devices will often be 6LoWPAN, and a full-length (1280 octet)
IPv6 packet will fragment into 15 6LoWPAN fragments (because the MTU of
IEEE 802.15.4 is 127).  A 300-packet queue is really 20 full-length IPv6
packets.

With a queue length of 10, an entire IPv6 packet was unable to get queued
at one time, causing fragments to be dropped, and making reassembly
impossible.

Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
---
 net/mac802154/wpan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index 7d3f659..2ca2f4d 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -360,7 +360,7 @@ void mac802154_wpan_setup(struct net_device *dev)
 	dev->header_ops		= &mac802154_header_ops;
 	dev->needed_tailroom	= 2; /* FCS */
 	dev->mtu		= IEEE802154_MTU;
-	dev->tx_queue_len	= 10;
+	dev->tx_queue_len	= 300;
 	dev->type		= ARPHRD_IEEE802154;
 	dev->flags		= IFF_NOARP | IFF_BROADCAST;
 	dev->watchdog_timeo	= 0;
-- 
1.7.11.2


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

^ permalink raw reply related

* [PATCH 3/6] mac802154: Use netif flow control
From: Alan Ott @ 2013-04-02 18:47 UTC (permalink / raw)
  To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller
  Cc: Alan Ott, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1364928481-1813-1-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>

Use netif_stop_queue() and netif_wake_queue() to control the flow of
packets to mac802154 devices.  Since many IEEE 802.15.4 devices have no
output buffer, and since the mac802154 xmit() function is designed to
block, netif_stop_queue() is called after each packet.

Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
---
 net/mac802154/tx.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index a248246..fe3e02c 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -25,6 +25,7 @@
 #include <linux/if_arp.h>
 #include <linux/crc-ccitt.h>
 
+#include <net/ieee802154_netdev.h>
 #include <net/mac802154.h>
 #include <net/wpan-phy.h>
 
@@ -45,6 +46,7 @@ static void mac802154_xmit_worker(struct work_struct *work)
 {
 	struct xmit_work *xw = container_of(work, struct xmit_work, work);
 	u8 xmit_attempts = 0;
+	struct mac802154_sub_if_data *sdata;
 	int res;
 
 	mutex_lock(&xw->priv->phy->pib_lock);
@@ -71,6 +73,12 @@ static void mac802154_xmit_worker(struct work_struct *work)
 out:
 	mutex_unlock(&xw->priv->phy->pib_lock);
 
+	/* Restart the netif queue on each sub_if_data object. */
+	rcu_read_lock();
+	list_for_each_entry_rcu(sdata, &xw->priv->slaves, list) {
+		netif_wake_queue(sdata->dev);
+	}
+	rcu_read_unlock();
 
 	dev_kfree_skb(xw->skb);
 
@@ -81,6 +89,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
 			 u8 page, u8 chan)
 {
 	struct xmit_work *work;
+	struct mac802154_sub_if_data *sdata;
 
 	if (!(priv->phy->channels_supported[page] & (1 << chan))) {
 		WARN_ON(1);
@@ -108,6 +117,13 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
 		return NETDEV_TX_BUSY;
 	}
 
+	/* Stop the netif queue on each sub_if_data object. */
+	rcu_read_lock();
+	list_for_each_entry_rcu(sdata, &priv->slaves, list) {
+		netif_stop_queue(sdata->dev);
+	}
+	rcu_read_unlock();
+
 	INIT_WORK(&work->work, mac802154_xmit_worker);
 	work->skb = skb;
 	work->priv = priv;
-- 
1.7.11.2


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

^ permalink raw reply related

* [PATCH 2/6] mac802154: Move xmit_attemps to stack
From: Alan Ott @ 2013-04-02 18:47 UTC (permalink / raw)
  To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller
  Cc: Alan Ott, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1364928481-1813-1-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>

There's no reason to have it in the work struct anymore.

Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
---
 net/mac802154/tx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index fbf937c..a248246 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -39,12 +39,12 @@ struct xmit_work {
 	struct mac802154_priv *priv;
 	u8 chan;
 	u8 page;
-	u8 xmit_attempts;
 };
 
 static void mac802154_xmit_worker(struct work_struct *work)
 {
 	struct xmit_work *xw = container_of(work, struct xmit_work, work);
+	u8 xmit_attempts = 0;
 	int res;
 
 	mutex_lock(&xw->priv->phy->pib_lock);
@@ -61,7 +61,7 @@ static void mac802154_xmit_worker(struct work_struct *work)
 
 	do {
 		res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
-		if (res && ++xw->xmit_attempts >= MAC802154_MAX_XMIT_ATTEMPTS) {
+		if (res && ++xmit_attempts >= MAC802154_MAX_XMIT_ATTEMPTS) {
 			pr_debug("transmission failed for %d times",
 				 MAC802154_MAX_XMIT_ATTEMPTS);
 			break;
@@ -113,7 +113,6 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
 	work->priv = priv;
 	work->page = page;
 	work->chan = chan;
-	work->xmit_attempts = 0;
 
 	queue_work(priv->dev_workqueue, &work->work);
 
-- 
1.7.11.2


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

^ permalink raw reply related

* [PATCH 1/6] mac802154: Immediately retry sending failed packets
From: Alan Ott @ 2013-04-02 18:47 UTC (permalink / raw)
  To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller
  Cc: Alan Ott, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1364928481-1813-1-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>

When ops->xmit() fails, immediately retry. Previously the packet was sent
to the back of the workqueue.

Signed-off-by: Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
---
 net/mac802154/tx.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 4e09d07..fbf937c 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -59,19 +59,18 @@ static void mac802154_xmit_worker(struct work_struct *work)
 		}
 	}
 
-	res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
+	do {
+		res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
+		if (res && ++xw->xmit_attempts >= MAC802154_MAX_XMIT_ATTEMPTS) {
+			pr_debug("transmission failed for %d times",
+				 MAC802154_MAX_XMIT_ATTEMPTS);
+			break;
+		}
+	} while (res);
 
 out:
 	mutex_unlock(&xw->priv->phy->pib_lock);
 
-	if (res) {
-		if (xw->xmit_attempts++ < MAC802154_MAX_XMIT_ATTEMPTS) {
-			queue_work(xw->priv->dev_workqueue, &xw->work);
-			return;
-		} else
-			pr_debug("transmission failed for %d times",
-				 MAC802154_MAX_XMIT_ATTEMPTS);
-	}
 
 	dev_kfree_skb(xw->skb);
 
-- 
1.7.11.2


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

^ permalink raw reply related

* [PATCH 0/6] 802.15.4 and 6LoWPAN Buffering Fixes
From: Alan Ott @ 2013-04-02 18:47 UTC (permalink / raw)
  To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller
  Cc: Alan Ott, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

These patches fix an issue in the 802.15.4 code where the output buffer
(which prior to this patchset is just a workqueue) can grow to an arbitrary
size.  This is basically fixed as follows:

1. Use netif_stop_queue() and netif_wake_queue() to stop and start the
transmit queue, preventing packets from piling up without bound on the
mac802154 workqueue.

2.  Increase the default tx_buffer_len for mac802154 (wpan) devices from 10
to 300, enabling Qdisc to work properly on the transmit queue.

Additionally the following related issues are fixed:

1. Handle dev_queue_xmit() return values properly in the 6LoWPAN code (and
return the proper errors to the higher layers).  This will cause the higher
layers to retry later if the mac802154 queue is full.

2. Fix the retry of transmit failures in mac802154.

Alan Ott (6):
  mac802154: Immediately retry sending failed packets
  mac802154: Move xmit_attemps to stack
  mac802154: Use netif flow control
  mac802154: Increase tx_buffer_len
  6lowpan: handle dev_queue_xmit error code properly
  6lowpan: return the dev_queue_xmit() return value from lowpan_xmit()

 net/ieee802154/6lowpan.c |  4 ++--
 net/mac802154/tx.c       | 34 ++++++++++++++++++++++++----------
 net/mac802154/wpan.c     |  2 +-
 3 files changed, 27 insertions(+), 13 deletions(-)

-- 
1.7.11.2


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html

^ permalink raw reply


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