* [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3
@ 2014-08-15 10:29 Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 01/12] mac802154: tx: move xmit callback to tx file Alexander Aring
` (11 more replies)
0 siblings, 12 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
Hi, this is the next series which do mainly a rework of xmit path. Also
dropping some kmalloc's from hotpath and remove the channel hopping feature.
We provide now async xmit and the the at86rf230 is the only one mainline driver
which supports that for now.
Next things are still frame parsing like 80211 and registration of phy's and
interfaces like 80211.
I need to look which is the best to work on the next series.
It's still available on [0], which is my working branch for the mac rework.
- Alex
[0] https://github.com/linux-wpan/linux-wpan-next/commits/wpan_rework_rfc
Alexander Aring (12):
mac802154: tx: move xmit callback to tx file
mac802154: make struct ieee802154_ops const
mac802154: add netdev qeue helpers
mac802154: tx: remove kmalloc in xmit hotpath
mac802154: tx: remove xmit channel context switch
mac802154: tx: add drv_xmit to driver-ops
mac802154: tx: fix error handling on xmit
mac802154: tx: add support for async xmit callback
at86rf230: asynchrous xmit handling
ieee802154: add valid frame length helper
at86rf230: use ieee802154_is_valid_frame_len
at86rf230: improve receive handling
drivers/net/ieee802154/at86rf230.c | 64 +++++++--------------
drivers/net/ieee802154/cc2520.c | 4 +-
drivers/net/ieee802154/mrf24j40.c | 4 +-
include/net/ieee802154.h | 10 +++-
include/net/mac802154.h | 15 ++++-
net/mac802154/Makefile | 2 +-
net/mac802154/driver-ops.h | 12 ++++
net/mac802154/ieee802154_i.h | 6 +-
net/mac802154/iface.c | 33 -----------
net/mac802154/main.c | 6 +-
net/mac802154/tx.c | 114 ++++++++++++++++++-------------------
net/mac802154/util.c | 55 ++++++++++++++++++
12 files changed, 177 insertions(+), 148 deletions(-)
create mode 100644 net/mac802154/util.c
--
2.0.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH wpan-next 01/12] mac802154: tx: move xmit callback to tx file
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 02/12] mac802154: make struct ieee802154_ops const Alexander Aring
` (10 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
This patch moves the mac802154_wpan_xmit function into the tx.c file.
Currently this callback is named wpan inidcates that this callback is
for WPAN (NODE) virtual interfaces.
In future this should be a generic function, we do a switch case over
interface type variable to make different interface type handling.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/mac802154/ieee802154_i.h | 4 +---
net/mac802154/iface.c | 33 ---------------------------------
net/mac802154/tx.c | 36 ++++++++++++++++++++++++++++++++++--
3 files changed, 35 insertions(+), 38 deletions(-)
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index fcb00a0..d6b961a 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -136,9 +136,7 @@ extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
void mac802154_wpan_setup(struct net_device *dev);
-
-netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
- u8 page, u8 chan);
+netdev_tx_t mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev);
/* MIB callbacks */
void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val);
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index 61fa188..59c5226 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -377,39 +377,6 @@ mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr)
return sizeof(*addr);
}
-static netdev_tx_t
-mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
-{
- struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
- u8 chan, page;
- int rc;
-
- spin_lock_bh(&sdata->mib_lock);
- chan = sdata->chan;
- page = sdata->page;
- spin_unlock_bh(&sdata->mib_lock);
-
- if (chan == MAC802154_CHAN_NONE ||
- page >= WPAN_NUM_PAGES ||
- chan >= WPAN_NUM_CHANNELS) {
- kfree_skb(skb);
- return NETDEV_TX_OK;
- }
-
- rc = mac802154_llsec_encrypt(&sdata->sec, skb);
- if (rc) {
- pr_warn("encryption failed: %i\n", rc);
- kfree_skb(skb);
- return NETDEV_TX_OK;
- }
-
- skb->skb_iif = dev->ifindex;
- dev->stats.tx_packets++;
- dev->stats.tx_bytes += skb->len;
-
- return mac802154_tx(sdata->local, skb, page, chan);
-}
-
static struct header_ops mac802154_header_ops = {
.create = mac802154_header_create,
.parse = mac802154_header_parse,
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 277ccd1..5f165ec 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -81,8 +81,8 @@ out:
kfree(xw);
}
-netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
- u8 page, u8 chan)
+static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
+ struct sk_buff *skb, u8 page, u8 chan)
{
struct xmit_work *work;
struct ieee802154_sub_if_data *sdata;
@@ -129,3 +129,35 @@ err_tx:
kfree_skb(skb);
return NETDEV_TX_OK;
}
+
+netdev_tx_t mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
+ u8 chan, page;
+ int rc;
+
+ spin_lock_bh(&sdata->mib_lock);
+ chan = sdata->chan;
+ page = sdata->page;
+ spin_unlock_bh(&sdata->mib_lock);
+
+ if (chan == MAC802154_CHAN_NONE ||
+ page >= WPAN_NUM_PAGES ||
+ chan >= WPAN_NUM_CHANNELS) {
+ kfree_skb(skb);
+ return NETDEV_TX_OK;
+ }
+
+ rc = mac802154_llsec_encrypt(&sdata->sec, skb);
+ if (rc) {
+ pr_warn("encryption failed: %i\n", rc);
+ kfree_skb(skb);
+ return NETDEV_TX_OK;
+ }
+
+ skb->skb_iif = dev->ifindex;
+ dev->stats.tx_packets++;
+ dev->stats.tx_bytes += skb->len;
+
+ return mac802154_tx(sdata->local, skb, page, chan);
+}
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 02/12] mac802154: make struct ieee802154_ops const
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 01/12] mac802154: tx: move xmit callback to tx file Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 03/12] mac802154: add netdev qeue helpers Alexander Aring
` (9 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
The ieee802154_ops should never be changed during runtime.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
drivers/net/ieee802154/at86rf230.c | 2 +-
drivers/net/ieee802154/cc2520.c | 2 +-
drivers/net/ieee802154/mrf24j40.c | 2 +-
include/net/mac802154.h | 2 +-
net/mac802154/ieee802154_i.h | 2 +-
net/mac802154/main.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index c2fc833..9a77b16 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1235,7 +1235,7 @@ at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
return rc;
}
-static struct ieee802154_ops at86rf230_ops = {
+static const struct ieee802154_ops at86rf230_ops = {
.owner = THIS_MODULE,
.xmit = at86rf230_xmit,
.ed = at86rf230_ed,
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index defd954..86bed88 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -631,7 +631,7 @@ cc2520_filter(struct ieee802154_hw *hw,
return 0;
}
-static struct ieee802154_ops cc2520_ops = {
+static const struct ieee802154_ops cc2520_ops = {
.owner = THIS_MODULE,
.start = cc2520_start,
.stop = cc2520_stop,
diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index 5189dad..a391b85 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -577,7 +577,7 @@ out:
return ret;
}
-static struct ieee802154_ops mrf24j40_ops = {
+static const struct ieee802154_ops mrf24j40_ops = {
.owner = THIS_MODULE,
.xmit = mrf24j40_tx,
.ed = mrf24j40_ed,
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 4666b98..311e595 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -186,7 +186,7 @@ struct ieee802154_ops {
/* Basic interface to register ieee802154 hwice */
struct ieee802154_hw *
-ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops);
+ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops);
void ieee802154_free_hw(struct ieee802154_hw *hw);
int ieee802154_register_hw(struct ieee802154_hw *hw);
void ieee802154_unregister_hw(struct ieee802154_hw *hw);
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index d6b961a..cb81f67 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -77,7 +77,7 @@ struct ieee802154_sub_if_data {
/* mac802154 device private data */
struct ieee802154_local {
struct ieee802154_hw hw;
- struct ieee802154_ops *ops;
+ const struct ieee802154_ops *ops;
/* ieee802154 phy */
struct wpan_phy *phy;
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 3740c76..0f4810f 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -182,7 +182,7 @@ static void ieee802154_tasklet_handler(unsigned long data)
}
struct ieee802154_hw *
-ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
+ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops)
{
struct wpan_phy *phy;
struct ieee802154_local *local;
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 03/12] mac802154: add netdev qeue helpers
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 01/12] mac802154: tx: move xmit callback to tx file Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 02/12] mac802154: make struct ieee802154_ops const Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 04/12] mac802154: tx: remove kmalloc in xmit hotpath Alexander Aring
` (8 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
This patch adds a new file net/mac802154/util.c which contains utility
functions for drivers, etc.
This file contains functions to start and stop queues for all virtual
interfaces, this is useful for asynchronous handling in driver level.
In future the ieee802154_xmit_complete function should be contain a
delay for interfame spacing time, for now we don't provide this
information inside the mac layer.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
include/net/mac802154.h | 4 ++++
net/mac802154/Makefile | 2 +-
net/mac802154/tx.c | 14 ++-----------
net/mac802154/util.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 62 insertions(+), 13 deletions(-)
create mode 100644 net/mac802154/util.c
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 311e595..fd3abbf 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -196,4 +196,8 @@ void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb,
void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb);
+void ieee802154_wake_queue(struct ieee802154_hw *hw);
+void ieee802154_stop_queue(struct ieee802154_hw *hw);
+void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb);
+
#endif /* NET_MAC802154_H */
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index d7030d4..2e497d0 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -1,5 +1,5 @@
obj-$(CONFIG_MAC802154) += mac802154.o
mac802154-objs := main.o rx.o tx.o mac_cmd.o mib.o \
- iface.o llsec.o
+ iface.o llsec.o util.o
ccflags-y += -D__CHECK_ENDIAN__
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 5f165ec..d99e4f5 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -45,7 +45,6 @@ struct xmit_work {
static void mac802154_xmit_worker(struct work_struct *work)
{
struct xmit_work *xw = container_of(work, struct xmit_work, work);
- struct ieee802154_sub_if_data *sdata;
int res;
mutex_lock(&xw->local->phy->pib_lock);
@@ -71,12 +70,7 @@ out:
mutex_unlock(&xw->local->phy->pib_lock);
/* Restart the netif queue on each sub_if_data object. */
- rcu_read_lock();
- list_for_each_entry_rcu(sdata, &xw->local->interfaces, list)
- netif_wake_queue(sdata->dev);
- rcu_read_unlock();
-
- dev_kfree_skb(xw->skb);
+ ieee802154_xmit_complete(&local->hw, skb);
kfree(xw);
}
@@ -85,7 +79,6 @@ static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
struct sk_buff *skb, u8 page, u8 chan)
{
struct xmit_work *work;
- struct ieee802154_sub_if_data *sdata;
if (!(local->phy->channels_supported[page] & (1 << chan))) {
WARN_ON(1);
@@ -110,10 +103,7 @@ static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
}
/* Stop the netif queue on each sub_if_data object. */
- rcu_read_lock();
- list_for_each_entry_rcu(sdata, &local->interfaces, list)
- netif_stop_queue(sdata->dev);
- rcu_read_unlock();
+ ieee802154_stop_queue(&local->hw);
INIT_WORK(&work->work, mac802154_xmit_worker);
work->skb = skb;
diff --git a/net/mac802154/util.c b/net/mac802154/util.c
new file mode 100644
index 0000000..117e4ef
--- /dev/null
+++ b/net/mac802154/util.c
@@ -0,0 +1,55 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Authors:
+ * Alexander Aring <aar@pengutronix.de>
+ *
+ * Based on: net/mac80211/util.c
+ */
+
+#include "ieee802154_i.h"
+
+void ieee802154_wake_queue(struct ieee802154_hw *hw)
+{
+ struct ieee802154_local *local = hw_to_local(hw);
+ struct ieee802154_sub_if_data *sdata;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(sdata, &local->interfaces, list) {
+ if (!sdata->dev)
+ continue;
+
+ netif_wake_queue(sdata->dev);
+ }
+ rcu_read_unlock();
+}
+EXPORT_SYMBOL(ieee802154_wake_queue);
+
+void ieee802154_stop_queue(struct ieee802154_hw *hw)
+{
+ struct ieee802154_local *local = hw_to_local(hw);
+ struct ieee802154_sub_if_data *sdata;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(sdata, &local->interfaces, list) {
+ if (!sdata->dev)
+ continue;
+
+ netif_stop_queue(sdata->dev);
+ }
+ rcu_read_unlock();
+}
+EXPORT_SYMBOL(ieee802154_stop_queue);
+
+void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb)
+{
+ ieee802154_wake_queue(hw);
+ consume_skb(skb);
+}
+EXPORT_SYMBOL(ieee802154_xmit_complete);
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 04/12] mac802154: tx: remove kmalloc in xmit hotpath
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
` (2 preceding siblings ...)
2014-08-15 10:29 ` [PATCH wpan-next 03/12] mac802154: add netdev qeue helpers Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 14:56 ` Phoebe Buckheister
2014-08-15 10:29 ` [PATCH wpan-next 05/12] mac802154: tx: remove xmit channel context switch Alexander Aring
` (7 subsequent siblings)
11 siblings, 1 reply; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
This patch removes the kmalloc allocation for workqueue data. This patch
replace the kmalloc and use the control block of skb. The control block
have enough space and isn't use by any other layer in this case.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/mac802154/tx.c | 51 ++++++++++++++++++++++++---------------------------
1 file changed, 24 insertions(+), 27 deletions(-)
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index d99e4f5..b6776ee 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -34,7 +34,7 @@
/* IEEE 802.15.4 transceivers can sleep during the xmit session, so process
* packets through the workqueue.
*/
-struct xmit_work {
+struct wpan_xmit_cb {
struct sk_buff *skb;
struct work_struct work;
struct ieee802154_local *local;
@@ -42,43 +42,46 @@ struct xmit_work {
u8 page;
};
+static struct wpan_xmit_cb *wpan_xmit_cb(struct sk_buff *skb)
+{
+ return (struct wpan_xmit_cb *)skb->cb;
+}
+
static void mac802154_xmit_worker(struct work_struct *work)
{
- struct xmit_work *xw = container_of(work, struct xmit_work, work);
+ struct wpan_xmit_cb *cb = container_of(work, struct wpan_xmit_cb, work);
+ struct ieee802154_local *local = cb->local;
+ struct sk_buff *skb = cb->skb;
int res;
- mutex_lock(&xw->local->phy->pib_lock);
- if (xw->local->phy->current_channel != xw->chan ||
- xw->local->phy->current_page != xw->page) {
- res = xw->local->ops->set_channel(&xw->local->hw,
- xw->page,
- xw->chan);
+ mutex_lock(&local->phy->pib_lock);
+ if (local->phy->current_channel != cb->chan ||
+ local->phy->current_page != cb->page) {
+ res = local->ops->set_channel(&local->hw, cb->page, cb->chan);
if (res) {
pr_debug("set_channel failed\n");
goto out;
}
- xw->local->phy->current_channel = xw->chan;
- xw->local->phy->current_page = xw->page;
+ local->phy->current_channel = cb->chan;
+ local->phy->current_page = cb->page;
}
- res = xw->local->ops->xmit(&xw->local->hw, xw->skb);
+ res = local->ops->xmit(&cb->local->hw, skb);
if (res)
pr_debug("transmission failed\n");
out:
- mutex_unlock(&xw->local->phy->pib_lock);
+ mutex_unlock(&local->phy->pib_lock);
/* Restart the netif queue on each sub_if_data object. */
ieee802154_xmit_complete(&local->hw, skb);
-
- kfree(xw);
}
static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
struct sk_buff *skb, u8 page, u8 chan)
{
- struct xmit_work *work;
+ struct wpan_xmit_cb *cb = wpan_xmit_cb(skb);
if (!(local->phy->channels_supported[page] & (1 << chan))) {
WARN_ON(1);
@@ -96,22 +99,16 @@ static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
if (skb_cow_head(skb, local->hw.extra_tx_headroom))
goto err_tx;
- work = kzalloc(sizeof(*work), GFP_ATOMIC);
- if (!work) {
- kfree_skb(skb);
- return NETDEV_TX_BUSY;
- }
-
/* Stop the netif queue on each sub_if_data object. */
ieee802154_stop_queue(&local->hw);
- INIT_WORK(&work->work, mac802154_xmit_worker);
- work->skb = skb;
- work->local = local;
- work->page = page;
- work->chan = chan;
+ INIT_WORK(&cb->work, mac802154_xmit_worker);
+ cb->skb = skb;
+ cb->local = local;
+ cb->page = page;
+ cb->chan = chan;
- queue_work(local->dev_workqueue, &work->work);
+ queue_work(local->dev_workqueue, &cb->work);
return NETDEV_TX_OK;
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 05/12] mac802154: tx: remove xmit channel context switch
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
` (3 preceding siblings ...)
2014-08-15 10:29 ` [PATCH wpan-next 04/12] mac802154: tx: remove kmalloc in xmit hotpath Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 06/12] mac802154: tx: add drv_xmit to driver-ops Alexander Aring
` (6 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
This patch removes the channel hoping feature before xmit. There are
several issues to provide a real channel hoping (timing requirements,
etc.). It's not very useful at the moment. In my opinion this was added
for support RF4CE and doing some userspace magic to do some channel hoping.
We don't have any known kernelspace protocol which really use this
featyre. We simply drop this feature now.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/mac802154/tx.c | 44 +++-----------------------------------------
1 file changed, 3 insertions(+), 41 deletions(-)
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index b6776ee..c748080 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -38,8 +38,6 @@ struct wpan_xmit_cb {
struct sk_buff *skb;
struct work_struct work;
struct ieee802154_local *local;
- u8 chan;
- u8 page;
};
static struct wpan_xmit_cb *wpan_xmit_cb(struct sk_buff *skb)
@@ -54,40 +52,19 @@ static void mac802154_xmit_worker(struct work_struct *work)
struct sk_buff *skb = cb->skb;
int res;
- mutex_lock(&local->phy->pib_lock);
- if (local->phy->current_channel != cb->chan ||
- local->phy->current_page != cb->page) {
- res = local->ops->set_channel(&local->hw, cb->page, cb->chan);
- if (res) {
- pr_debug("set_channel failed\n");
- goto out;
- }
-
- local->phy->current_channel = cb->chan;
- local->phy->current_page = cb->page;
- }
-
res = local->ops->xmit(&cb->local->hw, skb);
if (res)
pr_debug("transmission failed\n");
-out:
- mutex_unlock(&local->phy->pib_lock);
-
/* Restart the netif queue on each sub_if_data object. */
ieee802154_xmit_complete(&local->hw, skb);
}
-static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
- struct sk_buff *skb, u8 page, u8 chan)
+static netdev_tx_t
+mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
{
struct wpan_xmit_cb *cb = wpan_xmit_cb(skb);
- if (!(local->phy->channels_supported[page] & (1 << chan))) {
- WARN_ON(1);
- goto err_tx;
- }
-
if (!(local->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
u16 crc = crc_ccitt(0, skb->data, skb->len);
u8 *data = skb_put(skb, 2);
@@ -105,8 +82,6 @@ static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
INIT_WORK(&cb->work, mac802154_xmit_worker);
cb->skb = skb;
cb->local = local;
- cb->page = page;
- cb->chan = chan;
queue_work(local->dev_workqueue, &cb->work);
@@ -120,21 +95,8 @@ err_tx:
netdev_tx_t mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
- u8 chan, page;
int rc;
- spin_lock_bh(&sdata->mib_lock);
- chan = sdata->chan;
- page = sdata->page;
- spin_unlock_bh(&sdata->mib_lock);
-
- if (chan == MAC802154_CHAN_NONE ||
- page >= WPAN_NUM_PAGES ||
- chan >= WPAN_NUM_CHANNELS) {
- kfree_skb(skb);
- return NETDEV_TX_OK;
- }
-
rc = mac802154_llsec_encrypt(&sdata->sec, skb);
if (rc) {
pr_warn("encryption failed: %i\n", rc);
@@ -146,5 +108,5 @@ netdev_tx_t mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
dev->stats.tx_packets++;
dev->stats.tx_bytes += skb->len;
- return mac802154_tx(sdata->local, skb, page, chan);
+ return mac802154_tx(sdata->local, skb);
}
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 06/12] mac802154: tx: add drv_xmit to driver-ops
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
` (4 preceding siblings ...)
2014-08-15 10:29 ` [PATCH wpan-next 05/12] mac802154: tx: remove xmit channel context switch Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 07/12] mac802154: tx: fix error handling on xmit Alexander Aring
` (5 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
This patch adds a new helper for calling the xmit callback from
ieee802154_ops.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/mac802154/driver-ops.h | 6 ++++++
net/mac802154/tx.c | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h
index edaf75f..00298d6 100644
--- a/net/mac802154/driver-ops.h
+++ b/net/mac802154/driver-ops.h
@@ -5,6 +5,12 @@
#include "ieee802154_i.h"
+static inline int
+drv_xmit(struct ieee802154_local *local, struct sk_buff *skb)
+{
+ return local->ops->xmit(&local->hw, skb);
+}
+
static inline int drv_start(struct ieee802154_local *local)
{
might_sleep();
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index c748080..5dc32dd 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -30,6 +30,7 @@
#include <net/wpan-phy.h>
#include "ieee802154_i.h"
+#include "driver-ops.h"
/* IEEE 802.15.4 transceivers can sleep during the xmit session, so process
* packets through the workqueue.
@@ -52,7 +53,7 @@ static void mac802154_xmit_worker(struct work_struct *work)
struct sk_buff *skb = cb->skb;
int res;
- res = local->ops->xmit(&cb->local->hw, skb);
+ res = drv_xmit(local, skb);
if (res)
pr_debug("transmission failed\n");
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 07/12] mac802154: tx: fix error handling on xmit
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
` (5 preceding siblings ...)
2014-08-15 10:29 ` [PATCH wpan-next 06/12] mac802154: tx: add drv_xmit to driver-ops Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 08/12] mac802154: tx: add support for async xmit callback Alexander Aring
` (4 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
If error occur we should call kfree_skb instead of dev_kfree_skb or
consume_skb.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/mac802154/tx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 5dc32dd..cae6fb5 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -54,8 +54,12 @@ static void mac802154_xmit_worker(struct work_struct *work)
int res;
res = drv_xmit(local, skb);
- if (res)
+ if (res) {
pr_debug("transmission failed\n");
+ ieee802154_wake_queue(&local->hw);
+ kfree_skb(skb);
+ return;
+ }
/* Restart the netif queue on each sub_if_data object. */
ieee802154_xmit_complete(&local->hw, skb);
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 08/12] mac802154: tx: add support for async xmit callback
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
` (6 preceding siblings ...)
2014-08-15 10:29 ` [PATCH wpan-next 07/12] mac802154: tx: fix error handling on xmit Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 09/12] at86rf230: asynchrous xmit handling Alexander Aring
` (3 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
This patch renames the existsing xmit callback to xmit_sync and
introduce a asynchronous xmit handling. If ieee802154_ops doesn't
provide the async xmit callback, then we have a fallback to the
xmit_sync callback.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
drivers/net/ieee802154/at86rf230.c | 2 +-
drivers/net/ieee802154/cc2520.c | 2 +-
drivers/net/ieee802154/mrf24j40.c | 2 +-
include/net/mac802154.h | 9 +++++++++
net/mac802154/driver-ops.h | 6 ++++++
net/mac802154/main.c | 4 ++--
net/mac802154/tx.c | 14 +++++++++++++-
7 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 9a77b16..8886325 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1237,7 +1237,7 @@ at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
static const struct ieee802154_ops at86rf230_ops = {
.owner = THIS_MODULE,
- .xmit = at86rf230_xmit,
+ .xmit_sync = at86rf230_xmit,
.ed = at86rf230_ed,
.set_channel = at86rf230_channel,
.start = at86rf230_start,
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index 86bed88..9662570 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -635,7 +635,7 @@ static const struct ieee802154_ops cc2520_ops = {
.owner = THIS_MODULE,
.start = cc2520_start,
.stop = cc2520_stop,
- .xmit = cc2520_tx,
+ .xmit_sync = cc2520_tx,
.ed = cc2520_ed,
.set_channel = cc2520_set_channel,
.set_hw_addr_filt = cc2520_filter,
diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index a391b85..c52f4f8 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -579,7 +579,7 @@ out:
static const struct ieee802154_ops mrf24j40_ops = {
.owner = THIS_MODULE,
- .xmit = mrf24j40_tx,
+ .xmit_sync = mrf24j40_tx,
.ed = mrf24j40_ed,
.start = mrf24j40_start,
.stop = mrf24j40_stop,
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index fd3abbf..28c8921 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -112,6 +112,13 @@ struct ieee802154_hw {
* stop: Handler that 802.15.4 module calls for device cleanup.
* This function is called after the last interface is removed.
*
+ * xmit_sync:
+ * Handler that 802.15.4 module calls for each transmitted frame.
+ * skb cntains the buffer starting from the IEEE 802.15.4 header.
+ * The low-level driver should send the frame based on available
+ * configuration. This is called by a workqueue and useful for
+ * synchronous 802.15.4 drivers.
+ *
* xmit: Handler that 802.15.4 module calls for each transmitted frame.
* skb cntains the buffer starting from the IEEE 802.15.4 header.
* The low-level driver should send the frame based on available
@@ -164,6 +171,8 @@ struct ieee802154_ops {
struct module *owner;
int (*start)(struct ieee802154_hw *hw);
void (*stop)(struct ieee802154_hw *hw);
+ int (*xmit_sync)(struct ieee802154_hw *hw,
+ struct sk_buff *skb);
int (*xmit)(struct ieee802154_hw *hw,
struct sk_buff *skb);
int (*ed)(struct ieee802154_hw *hw, u8 *level);
diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h
index 00298d6..3890da4 100644
--- a/net/mac802154/driver-ops.h
+++ b/net/mac802154/driver-ops.h
@@ -11,6 +11,12 @@ drv_xmit(struct ieee802154_local *local, struct sk_buff *skb)
return local->ops->xmit(&local->hw, skb);
}
+static inline int
+drv_xmit_sync(struct ieee802154_local *local, struct sk_buff *skb)
+{
+ return local->ops->xmit_sync(&local->hw, skb);
+}
+
static inline int drv_start(struct ieee802154_local *local)
{
might_sleep();
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 0f4810f..2e5f39b 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -188,8 +188,8 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops)
struct ieee802154_local *local;
size_t priv_size;
- if (!ops || !ops->xmit || !ops->ed || !ops->start ||
- !ops->stop || !ops->set_channel) {
+ if (!ops || !(ops->xmit || ops->xmit_sync) || !ops->ed ||
+ !ops->start || !ops->stop || !ops->set_channel) {
pr_err("undefined IEEE802.15.4 device operations\n");
return NULL;
}
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index cae6fb5..45802a8 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -53,7 +53,7 @@ static void mac802154_xmit_worker(struct work_struct *work)
struct sk_buff *skb = cb->skb;
int res;
- res = drv_xmit(local, skb);
+ res = drv_xmit_sync(local, skb);
if (res) {
pr_debug("transmission failed\n");
ieee802154_wake_queue(&local->hw);
@@ -69,6 +69,7 @@ static netdev_tx_t
mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
{
struct wpan_xmit_cb *cb = wpan_xmit_cb(skb);
+ int ret;
if (!(local->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
u16 crc = crc_ccitt(0, skb->data, skb->len);
@@ -84,6 +85,17 @@ mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
/* Stop the netif queue on each sub_if_data object. */
ieee802154_stop_queue(&local->hw);
+ /* async is priority, otherwise sync is fallback */
+ if (local->ops->xmit) {
+ ret = drv_xmit(local, skb);
+ if (ret) {
+ ieee802154_wake_queue(&local->hw);
+ goto err_tx;
+ }
+
+ return NETDEV_TX_OK;
+ }
+
INIT_WORK(&cb->work, mac802154_xmit_worker);
cb->skb = skb;
cb->local = local;
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 09/12] at86rf230: asynchrous xmit handling
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
` (7 preceding siblings ...)
2014-08-15 10:29 ` [PATCH wpan-next 08/12] mac802154: tx: add support for async xmit callback Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 10/12] ieee802154: add valid frame length helper Alexander Aring
` (2 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
This patch change the sync xmit handling to an async xmit handling. The
driver was mostly prepared to do this step, all other drivers needs an
async spi handling to provide that.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
drivers/net/ieee802154/at86rf230.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 8886325..b245e57 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -92,7 +92,6 @@ struct at86rf230_local {
bool is_tx;
/* spinlock for is_tx protection */
spinlock_t lock;
- struct completion tx_complete;
struct sk_buff *tx_skb;
struct at86rf230_state_change tx;
};
@@ -452,6 +451,7 @@ at86rf230_async_error_recover(void *context)
struct at86rf230_local *lp = ctx->lp;
at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON, NULL);
+ ieee802154_wake_queue(lp->hw);
}
static void
@@ -701,8 +701,19 @@ at86rf230_tx_complete(void *context)
{
struct at86rf230_state_change *ctx = context;
struct at86rf230_local *lp = ctx->lp;
+ struct sk_buff *skb = lp->tx_skb;
+
+ /* Interfame spacing time, which is phy depend.
+ * TODO
+ * Move this handling in MAC 802.15.4 layer.
+ * This is currently a workaround to avoid fragmenation issues.
+ */
+ if (skb->len > 18)
+ usleep_range(lp->data->t_lifs, lp->data->t_lifs + 10);
+ else
+ usleep_range(lp->data->t_sifs, lp->data->t_sifs + 10);
- complete(&lp->tx_complete);
+ ieee802154_xmit_complete(lp->hw, skb);
}
static void
@@ -992,22 +1003,6 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
at86rf230_async_error(lp, ctx, rc);
return rc;
}
- rc = wait_for_completion_interruptible_timeout(&lp->tx_complete,
- msecs_to_jiffies(lp->data->t_tx_timeout));
- if (!rc) {
- at86rf230_async_error(lp, ctx, rc);
- return -ETIMEDOUT;
- }
-
- /* Interfame spacing time, which is phy depend.
- * TODO
- * Move this handling in MAC 802.15.4 layer.
- * This is currently a workaround to avoid fragmenation issues.
- */
- if (skb->len > 18)
- usleep_range(lp->data->t_lifs, lp->data->t_lifs + 10);
- else
- usleep_range(lp->data->t_sifs, lp->data->t_sifs + 10);
return 0;
}
@@ -1237,7 +1232,7 @@ at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
static const struct ieee802154_ops at86rf230_ops = {
.owner = THIS_MODULE,
- .xmit_sync = at86rf230_xmit,
+ .xmit = at86rf230_xmit,
.ed = at86rf230_ed,
.set_channel = at86rf230_channel,
.start = at86rf230_start,
@@ -1541,7 +1536,6 @@ static int at86rf230_probe(struct spi_device *spi)
goto free_dev;
spin_lock_init(&lp->lock);
- init_completion(&lp->tx_complete);
init_completion(&lp->state_complete);
spi_set_drvdata(spi, lp);
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 10/12] ieee802154: add valid frame length helper
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
` (8 preceding siblings ...)
2014-08-15 10:29 ` [PATCH wpan-next 09/12] at86rf230: asynchrous xmit handling Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 11/12] at86rf230: use ieee802154_is_valid_frame_len Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 12/12] at86rf230: improve receive handling Alexander Aring
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
This patch adds a generic valid frame length check function helper. This
is useful to check the length field after receiving. For example the
at86rf231 doesn't filter invalid frame length. Sometimes the CRC can be
also correct. If we get the lqi value with a invalid frame length the
kernel can be crash, because we dereference an invalid pointer.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
include/net/ieee802154.h | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/net/ieee802154.h b/include/net/ieee802154.h
index 0aa7122..185260b 100644
--- a/include/net/ieee802154.h
+++ b/include/net/ieee802154.h
@@ -28,6 +28,7 @@
#define NET_IEEE802154_H
#define IEEE802154_MTU 127
+#define IEEE802154_MIN_FRAME_SIZE 5
#define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */
#define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */
@@ -189,7 +190,12 @@ enum {
IEEE802154_SCAN_IN_PROGRESS = 0xfc,
};
+static inline bool ieee802154_is_valid_frame_len(const u8 len)
+{
+ if (unlikely(len > IEEE802154_MTU || len < IEEE802154_MIN_FRAME_SIZE))
+ return false;
-#endif
-
+ return true;
+}
+#endif
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 11/12] at86rf230: use ieee802154_is_valid_frame_len
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
` (9 preceding siblings ...)
2014-08-15 10:29 ` [PATCH wpan-next 10/12] ieee802154: add valid frame length helper Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 12/12] at86rf230: improve receive handling Alexander Aring
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
This patch use the ieee802154_is_valid_frame_len function to validate
the frame length. If the frame length is invalid we use the maximum
payload to receive also corrupted frames in monitor mode.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
drivers/net/ieee802154/at86rf230.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index b245e57..d4f31d9 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -782,26 +782,11 @@ at86rf230_tx_trac_status(void *context)
static void
at86rf230_rx(struct at86rf230_local *lp,
- const u8 *data, u8 len)
+ const u8 *data, const u8 len)
{
- u8 lqi;
struct sk_buff *skb;
u8 rx_local_buf[AT86RF2XX_MAX_BUF];
- if (len < 2)
- return;
-
- /* read full frame buffer and invalid lqi value to lowest
- * indicator if frame was is in a corrupted state.
- */
- if (len > IEEE802154_MTU) {
- lqi = 0;
- len = IEEE802154_MTU;
- dev_vdbg(&lp->spi->dev, "corrupted frame received\n");
- } else {
- lqi = data[len];
- }
-
memcpy(rx_local_buf, data, len);
enable_irq(lp->spi->irq);
@@ -816,7 +801,7 @@ at86rf230_rx(struct at86rf230_local *lp,
/* We do not put CRC into the frame */
skb_trim(skb, len - 2);
- ieee802154_rx_irqsafe(lp->hw, skb, lqi);
+ ieee802154_rx_irqsafe(lp->hw, skb, rx_local_buf[len]);
}
static void
@@ -825,7 +810,12 @@ at86rf230_rx_read_frame_complete(void *context)
struct at86rf230_state_change *ctx = context;
struct at86rf230_local *lp = ctx->lp;
const u8 *buf = lp->irq.buf;
- const u8 len = buf[1];
+ u8 len = buf[1];
+
+ if (!ieee802154_is_valid_frame_len(len)) {
+ dev_vdbg(&lp->spi->dev, "corrupted frame received\n");
+ len = IEEE802154_MTU;
+ }
at86rf230_rx(lp, buf + 2, len);
}
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wpan-next 12/12] at86rf230: improve receive handling
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
` (10 preceding siblings ...)
2014-08-15 10:29 ` [PATCH wpan-next 11/12] at86rf230: use ieee802154_is_valid_frame_len Alexander Aring
@ 2014-08-15 10:29 ` Alexander Aring
11 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 10:29 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
Current behaviour is copy frame inklusive CRC into skb, then remove the
CRC from the skb. This patch provide that we doesn't copy the CRC into
the skb. It's a slighty improving of this handling.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
drivers/net/ieee802154/at86rf230.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index d4f31d9..016a920 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -782,7 +782,7 @@ at86rf230_tx_trac_status(void *context)
static void
at86rf230_rx(struct at86rf230_local *lp,
- const u8 *data, const u8 len)
+ const u8 *data, const u8 len, const u8 lqi)
{
struct sk_buff *skb;
u8 rx_local_buf[AT86RF2XX_MAX_BUF];
@@ -797,11 +797,7 @@ at86rf230_rx(struct at86rf230_local *lp,
}
memcpy(skb_put(skb, len), rx_local_buf, len);
-
- /* We do not put CRC into the frame */
- skb_trim(skb, len - 2);
-
- ieee802154_rx_irqsafe(lp->hw, skb, rx_local_buf[len]);
+ ieee802154_rx_irqsafe(lp->hw, skb, lqi);
}
static void
@@ -817,7 +813,7 @@ at86rf230_rx_read_frame_complete(void *context)
len = IEEE802154_MTU;
}
- at86rf230_rx(lp, buf + 2, len);
+ at86rf230_rx(lp, buf + 2, len - 2, buf[2 + len]);
}
static int
--
2.0.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH wpan-next 04/12] mac802154: tx: remove kmalloc in xmit hotpath
2014-08-15 10:29 ` [PATCH wpan-next 04/12] mac802154: tx: remove kmalloc in xmit hotpath Alexander Aring
@ 2014-08-15 14:56 ` Phoebe Buckheister
2014-08-15 14:59 ` Alexander Aring
0 siblings, 1 reply; 15+ messages in thread
From: Phoebe Buckheister @ 2014-08-15 14:56 UTC (permalink / raw)
To: Alexander Aring; +Cc: linux-wpan
> This patch removes the kmalloc allocation for workqueue data. This patch
> replace the kmalloc and use the control block of skb. The control block
> have enough space and isn't use by any other layer in this case.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> net/mac802154/tx.c | 51
> ++++++++++++++++++++++++---------------------------
> 1 file changed, 24 insertions(+), 27 deletions(-)
>
> diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
> index d99e4f5..b6776ee 100644
> --- a/net/mac802154/tx.c
> +++ b/net/mac802154/tx.c
> @@ -34,7 +34,7 @@
> /* IEEE 802.15.4 transceivers can sleep during the xmit session, so
> process
> * packets through the workqueue.
> */
> -struct xmit_work {
> +struct wpan_xmit_cb {
> struct sk_buff *skb;
> struct work_struct work;
> struct ieee802154_local *local;
> @@ -42,43 +42,46 @@ struct xmit_work {
> u8 page;
> };
>
> +static struct wpan_xmit_cb *wpan_xmit_cb(struct sk_buff *skb)
> +{
Do add a BUILD_BUG_ON(sizeof(struct wpan_xmit_cb) > sizeof(skb->cb)) to
make sure the struct will *always* fit, even if we choose to resize it for
whatever reason.
> + return (struct wpan_xmit_cb *)skb->cb;
> +}
> +
> static void mac802154_xmit_worker(struct work_struct *work)
> {
> - struct xmit_work *xw = container_of(work, struct xmit_work, work);
> + struct wpan_xmit_cb *cb = container_of(work, struct wpan_xmit_cb, work);
> + struct ieee802154_local *local = cb->local;
> + struct sk_buff *skb = cb->skb;
> int res;
>
> - mutex_lock(&xw->local->phy->pib_lock);
> - if (xw->local->phy->current_channel != xw->chan ||
> - xw->local->phy->current_page != xw->page) {
> - res = xw->local->ops->set_channel(&xw->local->hw,
> - xw->page,
> - xw->chan);
> + mutex_lock(&local->phy->pib_lock);
> + if (local->phy->current_channel != cb->chan ||
> + local->phy->current_page != cb->page) {
> + res = local->ops->set_channel(&local->hw, cb->page, cb->chan);
> if (res) {
> pr_debug("set_channel failed\n");
> goto out;
> }
>
> - xw->local->phy->current_channel = xw->chan;
> - xw->local->phy->current_page = xw->page;
> + local->phy->current_channel = cb->chan;
> + local->phy->current_page = cb->page;
> }
>
> - res = xw->local->ops->xmit(&xw->local->hw, xw->skb);
> + res = local->ops->xmit(&cb->local->hw, skb);
> if (res)
> pr_debug("transmission failed\n");
>
> out:
> - mutex_unlock(&xw->local->phy->pib_lock);
> + mutex_unlock(&local->phy->pib_lock);
>
> /* Restart the netif queue on each sub_if_data object. */
> ieee802154_xmit_complete(&local->hw, skb);
> -
> - kfree(xw);
> }
>
> static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
> struct sk_buff *skb, u8 page, u8 chan)
> {
> - struct xmit_work *work;
> + struct wpan_xmit_cb *cb = wpan_xmit_cb(skb);
>
> if (!(local->phy->channels_supported[page] & (1 << chan))) {
> WARN_ON(1);
> @@ -96,22 +99,16 @@ static netdev_tx_t mac802154_tx(struct
> ieee802154_local *local,
> if (skb_cow_head(skb, local->hw.extra_tx_headroom))
> goto err_tx;
>
> - work = kzalloc(sizeof(*work), GFP_ATOMIC);
> - if (!work) {
> - kfree_skb(skb);
> - return NETDEV_TX_BUSY;
> - }
> -
> /* Stop the netif queue on each sub_if_data object. */
> ieee802154_stop_queue(&local->hw);
>
> - INIT_WORK(&work->work, mac802154_xmit_worker);
> - work->skb = skb;
> - work->local = local;
> - work->page = page;
> - work->chan = chan;
> + INIT_WORK(&cb->work, mac802154_xmit_worker);
> + cb->skb = skb;
> + cb->local = local;
> + cb->page = page;
> + cb->chan = chan;
>
> - queue_work(local->dev_workqueue, &work->work);
> + queue_work(local->dev_workqueue, &cb->work);
>
> return NETDEV_TX_OK;
>
> --
> 2.0.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH wpan-next 04/12] mac802154: tx: remove kmalloc in xmit hotpath
2014-08-15 14:56 ` Phoebe Buckheister
@ 2014-08-15 14:59 ` Alexander Aring
0 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2014-08-15 14:59 UTC (permalink / raw)
To: Phoebe Buckheister; +Cc: linux-wpan
On Fri, Aug 15, 2014 at 04:56:08PM +0200, Phoebe Buckheister wrote:
> > This patch removes the kmalloc allocation for workqueue data. This patch
> > replace the kmalloc and use the control block of skb. The control block
> > have enough space and isn't use by any other layer in this case.
> >
> > Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> > ---
> > net/mac802154/tx.c | 51
> > ++++++++++++++++++++++++---------------------------
> > 1 file changed, 24 insertions(+), 27 deletions(-)
> >
> > diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
> > index d99e4f5..b6776ee 100644
> > --- a/net/mac802154/tx.c
> > +++ b/net/mac802154/tx.c
> > @@ -34,7 +34,7 @@
> > /* IEEE 802.15.4 transceivers can sleep during the xmit session, so
> > process
> > * packets through the workqueue.
> > */
> > -struct xmit_work {
> > +struct wpan_xmit_cb {
> > struct sk_buff *skb;
> > struct work_struct work;
> > struct ieee802154_local *local;
> > @@ -42,43 +42,46 @@ struct xmit_work {
> > u8 page;
> > };
> >
> > +static struct wpan_xmit_cb *wpan_xmit_cb(struct sk_buff *skb)
> > +{
>
> Do add a BUILD_BUG_ON(sizeof(struct wpan_xmit_cb) > sizeof(skb->cb)) to
> make sure the struct will *always* fit, even if we choose to resize it for
> whatever reason.
Ok, thanks. I also add a inline to this function. Thanks.
- Alex
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2014-08-15 14:59 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-15 10:29 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 3 Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 01/12] mac802154: tx: move xmit callback to tx file Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 02/12] mac802154: make struct ieee802154_ops const Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 03/12] mac802154: add netdev qeue helpers Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 04/12] mac802154: tx: remove kmalloc in xmit hotpath Alexander Aring
2014-08-15 14:56 ` Phoebe Buckheister
2014-08-15 14:59 ` Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 05/12] mac802154: tx: remove xmit channel context switch Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 06/12] mac802154: tx: add drv_xmit to driver-ops Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 07/12] mac802154: tx: fix error handling on xmit Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 08/12] mac802154: tx: add support for async xmit callback Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 09/12] at86rf230: asynchrous xmit handling Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 10/12] ieee802154: add valid frame length helper Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 11/12] at86rf230: use ieee802154_is_valid_frame_len Alexander Aring
2014-08-15 10:29 ` [PATCH wpan-next 12/12] at86rf230: improve receive handling Alexander Aring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).