ieee802154: fix checksum and monitor handling
Subsystems (5)
Alexander Aring
maintainercover ieee802154: fix checksum and monitor handling
This patch series fix checksum and monitor handling. The checksum handling is currently a little bit weird, because all driver drops the checksum while delivering. In monitor mode we want to see the received checksum. This patch series contains various patches to fix the checksum handling and add basic support for real monitor mode with promiscuous mode setting.
The checksum handling is now in some state which should work also for monitor interfaces. There exist a better way to add runtime changeable flags to handle crc calculation via hardware or software. Also flags like if the monitor interface receiving is with or without checksum. This is only to introduce some behaviour which should working.
Alexander Aring (17):
mac802154: main: remove unnecessary include
mac802154: remove tab after define
mac802154: add IEEE802154_HW_ARET hw flag
mac802154: add hardware address filter flag
mac802154: add support for promiscuous mode
at86rf230: add support for promiscuous mode
mac802154: separate omit tx/rx flags
mac802154: rx: remove unnecessary parameter
mac802154: rx: simplify crc receive handling
mac802154: rx: add software checksum filtering check
mac802154: rx: remove override pkt_type set to PACKET_HOST
mac802154: rx: use netif_receive_skb
mac802154: rx: add rx stats incrementation
mac802154: rx: monitor receive cleanup
mac802154: rx: add error handling after skb_clone
at86rf230: deliver with checksum
mac802154: add basic support for monitor
drivers/net/ieee802154/at86rf230.c | 35 +++++++++++++++++++-- drivers/net/ieee802154/cc2520.c | 3 +- drivers/net/ieee802154/mrf24j40.c | 3 +- include/net/mac802154.h | 40 ++++++++++++++++++------ net/mac802154/driver-ops.h | 13 ++++++++ net/mac802154/ieee802154_i.h | 1 + net/mac802154/iface.c | 12 ++++++- net/mac802154/main.c | 1 - net/mac802154/rx.c | 64 +++++++++++++++++++++----------------- net/mac802154/tx.c | 2 +- 10 files changed, 127 insertions(+), 47 deletions(-)
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 1/17 mac802154: main: remove unnecessary include
This patch removes an unnecessary include of driver-ops header file.
--- net/mac802154/main.c | 1 - 1 file changed, 1 deletion(-)
net/mac802154/main.c +0 -1
@@ -28,7 +28,6 @@#include <net/cfg802154.h> #include "ieee802154_i.h" -#include "driver-ops.h" static int mac802154_netdev_register (struct wpan_phy *phy,struct net_device *dev)
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 2/17 mac802154: remove tab after define
In reply to Alexander AringThis patch removes tabs after define in hardware flags declarations.
--- include/net/mac802154.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
include/net/mac802154.h +8 -8
@@ -74,22 +74,22 @@ struct ieee802154_hw {*/ /* Indicates that receiver omits FCS and xmitter will add FCS on it's own. */ -#define IEEE802154_HW_OMIT_CKSUM 0x00000001 +#define IEEE802154_HW_OMIT_CKSUM 0x00000001/* Indicates that receiver will autorespond with ACK frames. */ -#define IEEE802154_HW_AACK 0x00000002 +#define IEEE802154_HW_AACK 0x00000002/* Indicates that transceiver will support transmit power setting. */ -#define IEEE802154_HW_TXPOWER 0x00000004 +#define IEEE802154_HW_TXPOWER 0x00000004/* Indicates that transceiver will support listen before transmit. */ -#define IEEE802154_HW_LBT 0x00000008 +#define IEEE802154_HW_LBT 0x00000008/* Indicates that transceiver will support cca mode setting. */ -#define IEEE802154_HW_CCA_MODE 0x00000010 +#define IEEE802154_HW_CCA_MODE 0x00000010/* Indicates that transceiver will support cca ed level setting. */ -#define IEEE802154_HW_CCA_ED_LEVEL 0x00000020 +#define IEEE802154_HW_CCA_ED_LEVEL 0x00000020/* Indicates that transceiver will support csma (max_be, min_be, csma retries) * settings. */ -#define IEEE802154_HW_CSMA_PARAMS 0x00000040 +#define IEEE802154_HW_CSMA_PARAMS 0x00000040/* Indicates that transceiver will support ARET frame retries setting. */ -#define IEEE802154_HW_FRAME_RETRIES 0x00000080 +#define IEEE802154_HW_FRAME_RETRIES 0x00000080/* This groups the most common CSMA support fields into one. */ #define IEEE802154_HW_CSMA (IEEE802154_HW_CCA_MODE | \
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 3/17 mac802154: add IEEE802154_HW_ARET hw flag
In reply to Alexander AringThis patch adds a new IEEE802154_HW_ARET hardware flag for indicating that the transceiver supports ARET handling. Also remove the IEEE802154_HW_FRAME_RETRIES from IEEE802154_HW_CSMA flag. Frame retries handling is part of ARET.
--- drivers/net/ieee802154/at86rf230.c | 2 +- include/net/mac802154.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/ieee802154/at86rf230.c +1 -1
@@ -1387,7 +1387,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) lp->hw->extra_tx_headroom =0 ; lp->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK | -IEEE802154_HW_TXPOWER |IEEE802154_HW_CSMA ; +IEEE802154_HW_TXPOWER |IEEE802154_HW_ARET ;switch (part) {case 2 :
include/net/mac802154.h +4 -1
@@ -94,7 +94,10 @@ struct ieee802154_hw {/* This groups the most common CSMA support fields into one. */ #define IEEE802154_HW_CSMA (IEEE802154_HW_CCA_MODE | \ IEEE802154_HW_CCA_ED_LEVEL | \ - IEEE802154_HW_CSMA_PARAMS | \ + IEEE802154_HW_CSMA_PARAMS) + +/* This groups the most common ARET support fields into one. */ +#define IEEE802154_HW_ARET (IEEE802154_HW_CSMA | \ IEEE802154_HW_FRAME_RETRIES)/* struct ieee802154_ops - callbacks from mac802154 to the driver
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 4/17 mac802154: add hardware address filter flag
In reply to Alexander AringOverdue introduction for address filtering hardware flag. Furthermore we will check and set address filtering on interface up. This patch prepares that we can check if an transceiver supports address filtering option. Currently all mainline driver supports hardware address filtering.
--- drivers/net/ieee802154/at86rf230.c | 3 ++- drivers/net/ieee802154/cc2520.c | 3 ++- drivers/net/ieee802154/mrf24j40.c | 3 ++- include/net/mac802154.h | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-)
drivers/net/ieee802154/at86rf230.c +2 -1
@@ -1387,7 +1387,8 @@ at86rf230_detect_device(struct at86rf230_local *lp) lp->hw->extra_tx_headroom =0 ; lp->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK | -IEEE802154_HW_TXPOWER |IEEE802154_HW_ARET ; +IEEE802154_HW_TXPOWER |IEEE802154_HW_ARET | +IEEE802154_HW_AFILT ;switch (part) {case 2 :
drivers/net/ieee802154/cc2520.c +2 -1
@@ -654,7 +654,8 @@ static int cc2520_register(struct cc2520_private *priv)/* We do support only 2.4 Ghz */ priv->hw->phy->channels_supported[0 ] =0x7FFF800 ; - priv->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK ; + priv->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK | +IEEE802154_HW_AFILT ;dev_vdbg (&priv->spi->dev,"registered cc2520\n" ); ret =ieee802154_register_hw (priv->hw);
drivers/net/ieee802154/mrf24j40.c +2 -1
@@ -751,7 +751,8 @@ static int mrf24j40_probe(struct spi_device *spi) devrec->hw->priv = devrec; devrec->hw->parent = &devrec->spi->dev; devrec->hw->phy->channels_supported[0 ] =CHANNEL_MASK ; - devrec->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK ; + devrec->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK | +IEEE802154_HW_AFILT ;dev_dbg (printdev (devrec),"registered mrf24j40\n" ); ret =ieee802154_register_hw (devrec->hw);
include/net/mac802154.h +2 -0
@@ -90,6 +90,8 @@ struct ieee802154_hw {#define IEEE802154_HW_CSMA_PARAMS 0x00000040/* Indicates that transceiver will support ARET frame retries setting. */ #define IEEE802154_HW_FRAME_RETRIES 0x00000080 +/* Indicates that transceiver will support hardware address filter setting. */ +#define IEEE802154_HW_AFILT 0x00000100/* This groups the most common CSMA support fields into one. */ #define IEEE802154_HW_CSMA (IEEE802154_HW_CCA_MODE | \
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 5/17 mac802154: add support for promiscuous mode
In reply to Alexander AringThis patch adds a new driver operation to bring the transceiver into promiscuous mode.
--- include/net/mac802154.h | 7 +++++++ net/mac802154/driver-ops.h | 13 +++++++++++++ 2 files changed, 20 insertions(+)
include/net/mac802154.h +7 -0
@@ -92,6 +92,8 @@ struct ieee802154_hw {#define IEEE802154_HW_FRAME_RETRIES 0x00000080/* Indicates that transceiver will support hardware address filter setting. */ #define IEEE802154_HW_AFILT 0x00000100 +/* Indicates that transceiver will support promiscuous mode setting. */ +#define IEEE802154_HW_PROMISCUOUS 0x00000200/* This groups the most common CSMA support fields into one. */ #define IEEE802154_HW_CSMA (IEEE802154_HW_CCA_MODE | \
@@ -173,6 +175,9 @@ struct ieee802154_hw {* set_frame_retries * Sets the retransmission attempt limit. Called with pib_lock held. * Returns either zero, or negative errno. +* +* set_promiscuous_mode +* Enables or disable promiscuous mode. */ struct ieee802154_ops {struct module *owner;
@@ -197,6 +202,8 @@ struct ieee802154_ops { u8 min_be, u8 max_be, u8 retries);int (*set_frame_retries)(struct ieee802154_hw *hw,s8 retries); +int (*set_promiscuous_mode)(struct ieee802154_hw *hw, +const bool on); };/* Basic interface to register ieee802154 hwice */
net/mac802154/driver-ops.h +13 -0
@@ -210,4 +210,17 @@ static inline int drv_set_max_frame_retries(struct ieee802154_local *local, return local->ops->set_frame_retries(&local->hw, max_frame_retries); } +static inline int drv_set_promiscuous_mode (struct ieee802154_local *local, +const bool on) +{ +might_sleep (); + +if (!local->ops->set_promiscuous_mode) { +WARN_ON (1 ); +return -EOPNOTSUPP ; + } + +return local->ops->set_promiscuous_mode (&local->hw, on); +} +#endif /* __MAC802154_DRVIER_OPS */
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 6/17 at86rf230: add support for promiscuous mode
In reply to Alexander AringThis patch adds support for promiscuous mode setting for the at86rf230 driver.
--- drivers/net/ieee802154/at86rf230.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
drivers/net/ieee802154/at86rf230.c +29 -1
@@ -1211,6 +1211,33 @@ at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)return rc; } +static int +at86rf230_set_promiscuous_mode (struct ieee802154_hw *hw,const bool on) +{ +struct at86rf230_local *lp = hw->priv; +int rc; + +if (on) { + rc =at86rf230_write_subreg (lp,SR_AACK_DIS_ACK ,1 ); +if (rc <0 ) +return rc; + + rc =at86rf230_write_subreg (lp,SR_AACK_PROM_MODE ,1 ); +if (rc <0 ) +return rc; + }else { + rc =at86rf230_write_subreg (lp,SR_AACK_PROM_MODE ,0 ); +if (rc <0 ) +return rc; + + rc =at86rf230_write_subreg (lp,SR_AACK_DIS_ACK ,0 ); +if (rc <0 ) +return rc; + } + +return 0 ; +} +static const struct ieee802154_ops at86rf230_ops = { .owner =THIS_MODULE , .xmit_async = at86rf230_xmit,
@@ -1225,6 +1252,7 @@ static const struct ieee802154_ops at86rf230_ops = { .set_cca_ed_level = at86rf230_set_cca_ed_level, .set_csma_params = at86rf230_set_csma_params, .set_frame_retries = at86rf230_set_frame_retries, + .set_promiscuous_mode = at86rf230_set_promiscuous_mode, };static struct at86rf2xx_chip_data at86rf233_data = {
@@ -1388,7 +1416,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) lp->hw->extra_tx_headroom =0 ; lp->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK |IEEE802154_HW_TXPOWER |IEEE802154_HW_ARET | -IEEE802154_HW_AFILT ; +IEEE802154_HW_AFILT |IEEE802154_HW_PROMISCUOUS ;switch (part) {case 2 :
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 7/17 mac802154: separate omit tx/rx flags
In reply to Alexander AringThis patch splits the IEEE802154_HW_OMIT_CKSUM hardware flag into IEEE802154_HW_TX_OMIT_CKSUM and IEEE802154_HW_RX_OMIT_CKSUM. This is useful to deliver the received crc from the driver layer to the monitor interface. At the moment we can't do that without change the xmit handling.
The received checksum should be visible in monitor mode only.
--- include/net/mac802154.h | 10 ++++++++-- net/mac802154/rx.c | 2 +- net/mac802154/tx.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-)
include/net/mac802154.h +8 -2
@@ -73,8 +73,8 @@ struct ieee802154_hw {* however, so you are advised to review these flags carefully. */ -/* Indicates that receiver omits FCS and xmitter will add FCS on it's own. */ -#define IEEE802154_HW_OMIT_CKSUM 0x00000001 +/* Indicates that xmitter will add FCS on it's own. */ +#define IEEE802154_HW_TX_OMIT_CKSUM 0x00000001/* Indicates that receiver will autorespond with ACK frames. */ #define IEEE802154_HW_AACK 0x00000002/* Indicates that transceiver will support transmit power setting. */
@@ -94,6 +94,12 @@ struct ieee802154_hw {#define IEEE802154_HW_AFILT 0x00000100/* Indicates that transceiver will support promiscuous mode setting. */ #define IEEE802154_HW_PROMISCUOUS 0x00000200 +/* Indicates that receiver omits FCS. */ +#define IEEE802154_HW_RX_OMIT_CKSUM 0x00000400 + +/* Indicates that receiver omits FCS and xmitter will add FCS on it's own. */ +#define IEEE802154_HW_OMIT_CKSUM (IEEE802154_HW_TX_OMIT_CKSUM | \ + IEEE802154_HW_RX_OMIT_CKSUM)/* This groups the most common CSMA support fields into one. */ #define IEEE802154_HW_CSMA (IEEE802154_HW_CCA_MODE | \
net/mac802154/rx.c +1 -1
@@ -255,7 +255,7 @@ void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb)WARN_ON_ONCE (softirq_count () ==0 ); -if (!(local->hw.flags &IEEE802154_HW_OMIT_CKSUM )) { +if (!(local->hw.flags &IEEE802154_HW_RX_OMIT_CKSUM )) {u16 crc;if (skb->len <2 ) {
net/mac802154/tx.c +1 -1
@@ -83,7 +83,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)struct net_device *dev = skb->dev;int ret; -if (!(local->hw.flags &IEEE802154_HW_OMIT_CKSUM )) { +if (!(local->hw.flags &IEEE802154_HW_TX_OMIT_CKSUM )) {u16 crc =crc_ccitt (0 , skb->data, skb->len);put_unaligned_le16 (crc,skb_put (skb,2 ));
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 8/17 mac802154: rx: remove unnecessary parameter
In reply to Alexander AringThis patch removes a not used parameter in ieee802154_deliver_skb.
--- net/mac802154/rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/mac802154/rx.c +2 -2
@@ -29,7 +29,7 @@#include "ieee802154_i.h" -static int ieee802154_deliver_skb (struct net_device *dev,struct sk_buff *skb) +static int ieee802154_deliver_skb (struct sk_buff *skb) { skb->ip_summed =CHECKSUM_UNNECESSARY ; skb->protocol =htons (ETH_P_IEEE802154 );
@@ -103,7 +103,7 @@ ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata,switch (mac_cb (skb)->type) {case IEEE802154_FC_TYPE_DATA : -return ieee802154_deliver_skb (sdata->dev, skb); +return ieee802154_deliver_skb (skb);default :pr_warn ("ieee802154: bad frame received (type = %d)\n" ,mac_cb (skb)->type);
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 9/17 mac802154: rx: simplify crc receive handling
In reply to Alexander AringThis patch change the actual crc handling while receive. Currently the IEEE802154_HW_RX_OMIT_CKSUM flag is used to filter a frame with a bad crc. This patch changes the behaviour of IEEE802154_HW_RX_OMIT_CKSUM to add a crc while receiving for the monitor interface. After monitor receiving we remove the crc for frame parsing. This affect the driver layer because all drivers sets IEEE802154_HW_RX_OMIT_CKSUM and deliver without checksum.
--- net/mac802154/rx.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-)
net/mac802154/rx.c +12 -22
@@ -21,6 +21,7 @@#include <linux/module.h> #include <linux/netdevice.h> #include <linux/crc-ccitt.h> +#include <asm/unaligned.h> #include <net/mac802154.h> #include <net/ieee802154_netdev.h>
@@ -225,8 +226,6 @@ ieee802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb) {struct sk_buff *skb2;struct ieee802154_sub_if_data *sdata; -u16 crc =crc_ccitt (0 , skb->data, skb->len); -u8 *data;skb_reset_mac_header (skb); skb->ip_summed =CHECKSUM_UNNECESSARY ;
@@ -241,9 +240,6 @@ ieee802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb) skb2 =skb_clone (skb,GFP_ATOMIC ); skb2->dev = sdata->dev; skb2->pkt_type =PACKET_HOST ; - data =skb_put (skb2,2 ); - data[0 ] = crc &0xff ; - data[1 ] = crc >>8 ;netif_rx_ni (skb2); }
@@ -255,32 +251,26 @@ void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb)WARN_ON_ONCE (softirq_count () ==0 ); -if (!(local->hw.flags &IEEE802154_HW_RX_OMIT_CKSUM )) { -u16 crc; +/* TODO: When a transceiver omits the checksum here, we +* add an own calculated one. This is currently an ugly +* solution because the monitor needs a crc here. +*/ +if (local->hw.flags &IEEE802154_HW_RX_OMIT_CKSUM ) { +u16 crc =crc_ccitt (0 , skb->data, skb->len); -if (skb->len <2 ) { -pr_debug ("got invalid frame\n" ); - goto fail; - } - crc =crc_ccitt (0 , skb->data, skb->len); -if (crc) { -pr_debug ("CRC mismatch\n" ); - goto fail; - } -skb_trim (skb, skb->len -2 );/* CRC */ +put_unaligned_le16 (crc,skb_put (skb,2 )); }rcu_read_lock ();ieee802154_monitors_rx (local, skb); -__ieee802154_rx_handle_packet (local, skb); -rcu_read_unlock (); +/* remove crc */ +skb_trim (skb, skb->len -2 ); -return ; +__ieee802154_rx_handle_packet (local, skb); -fail: -kfree_skb (skb); +rcu_read_unlock (); }EXPORT_SYMBOL (ieee802154_rx);
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 10/17 mac802154: rx: add software checksum filtering check
In reply to Alexander AringThis patch adds a new hardware flag which indicate that the transceiver doesn't support check for bad checksum via hardware. Also add a handling of this while receive.
--- include/net/mac802154.h | 2 ++ net/mac802154/rx.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-)
include/net/mac802154.h +2 -0
@@ -96,6 +96,8 @@ struct ieee802154_hw {#define IEEE802154_HW_PROMISCUOUS 0x00000200/* Indicates that receiver omits FCS. */ #define IEEE802154_HW_RX_OMIT_CKSUM 0x00000400 +/* Indicates that receiver will not filter frames with bad checksum. */ +#define IEEE802154_HW_RX_DROP_BAD_CKSUM 0x00000800/* Indicates that receiver omits FCS and xmitter will add FCS on it's own. */ #define IEEE802154_HW_OMIT_CKSUM (IEEE802154_HW_TX_OMIT_CKSUM | \
net/mac802154/rx.c +13 -2
@@ -248,6 +248,7 @@ ieee802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb)void ieee802154_rx (struct ieee802154_hw *hw,struct sk_buff *skb) {struct ieee802154_local *local =hw_to_local (hw); +u16 crc;WARN_ON_ONCE (softirq_count () ==0 );
@@ -256,8 +257,7 @@ void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb)* solution because the monitor needs a crc here. */ if (local->hw.flags &IEEE802154_HW_RX_OMIT_CKSUM ) { -u16 crc =crc_ccitt (0 , skb->data, skb->len); - + crc =crc_ccitt (0 , skb->data, skb->len);put_unaligned_le16 (crc,skb_put (skb,2 )); }
@@ -265,6 +265,17 @@ void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb)ieee802154_monitors_rx (local, skb); +/* Check if transceiver doesn't validate the checksum. +* If not we validate the checksum here. +*/ +if (local->hw.flags &IEEE802154_HW_RX_DROP_BAD_CKSUM ) { + crc =crc_ccitt (0 , skb->data, skb->len); +if (crc) { +rcu_read_unlock (); +kfree_skb (skb); +return ; + } + }/* remove crc */ skb_trim (skb, skb->len -2 );
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 11/17 mac802154: rx: remove override pkt_type set to PACKET_HOST
In reply to Alexander AringThis patch removes pkt_type set to PACKET_HOST while monitor receiving. This should be PACKET_OTHERHOST on monitor mode which already set before.
--- net/mac802154/rx.c | 1 - 1 file changed, 1 deletion(-)
net/mac802154/rx.c +0 -1
@@ -239,7 +239,6 @@ ieee802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb) skb2 =skb_clone (skb,GFP_ATOMIC ); skb2->dev = sdata->dev; - skb2->pkt_type =PACKET_HOST ;netif_rx_ni (skb2); }
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 12/17 mac802154: rx: use netif_receive_skb
In reply to Alexander AringThis patch removes netif_rx_ni call. Instead we call netif_receive_skb, we can do that since commit c5c47e67bcd24638a059b1b5e9ec18c95f8634ca ("mac802154: rx: use tasklet instead workqueue").
--- net/mac802154/rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac802154/rx.c +1 -1
@@ -240,7 +240,7 @@ ieee802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb) skb2 =skb_clone (skb,GFP_ATOMIC ); skb2->dev = sdata->dev; -netif_rx_ni (skb2); +ieee802154_deliver_skb (skb2); } }
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 13/17 mac802154: rx: add rx stats incrementation
In reply to Alexander AringThis patch adds rx stats incrementation when the monitor interface recevied a frame.
--- net/mac802154/rx.c | 3 +++ 1 file changed, 3 insertions(+)
net/mac802154/rx.c +3 -0
@@ -241,6 +241,9 @@ ieee802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb) skb2->dev = sdata->dev;ieee802154_deliver_skb (skb2); + + sdata->dev->stats.rx_packets++; + sdata->dev->stats.rx_bytes += skb->len; } }
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 14/17 mac802154: rx: monitor receive cleanup
In reply to Alexander AringThis patch replace the !netif_running(sdata->dev) instead we doing a !ieee802154_sdata_running(sdata). Also move this in two separate if branches to compare with mac80211 code.
--- net/mac802154/rx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/mac802154/rx.c +4 -2
@@ -233,8 +233,10 @@ ieee802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb) skb->protocol =htons (ETH_P_IEEE802154 );list_for_each_entry_rcu (sdata, &local->interfaces, list) { -if (sdata->type !=IEEE802154_DEV_MONITOR || - !netif_running (sdata->dev)) +if (sdata->type !=IEEE802154_DEV_MONITOR ) +continue ; + +if (!ieee802154_sdata_running (sdata))continue ; skb2 =skb_clone (skb,GFP_ATOMIC );
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 15/17 mac802154: rx: add error handling after skb_clone
In reply to Alexander AringThis patch adds error handling after skb_clone and deliver only if skb_clone was successful.
--- net/mac802154/rx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/mac802154/rx.c +6 -5
@@ -240,12 +240,13 @@ ieee802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb)continue ; skb2 =skb_clone (skb,GFP_ATOMIC ); - skb2->dev = sdata->dev; +if (skb2) { + skb2->dev = sdata->dev; +ieee802154_deliver_skb (skb2); -ieee802154_deliver_skb (skb2); - - sdata->dev->stats.rx_packets++; - sdata->dev->stats.rx_bytes += skb->len; + sdata->dev->stats.rx_packets++; + sdata->dev->stats.rx_bytes += skb->len; + } } }
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 16/17 at86rf230: deliver with checksum
In reply to Alexander AringThis patch indicates that the at86rf230 driver deliver with checksum instead drop the crc before delivering.
--- drivers/net/ieee802154/at86rf230.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ieee802154/at86rf230.c +2 -2
@@ -819,7 +819,7 @@ at86rf230_rx_read_frame_complete(void *context) len =IEEE802154_MTU ; } -at86rf230_rx (lp, buf +2 , len -2 , buf[2 + len]); +at86rf230_rx (lp, buf +2 , len, buf[2 + len]); } static void
@@ -1414,7 +1414,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) } lp->hw->extra_tx_headroom =0 ; - lp->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK | + lp->hw->flags =IEEE802154_HW_TX_OMIT_CKSUM |IEEE802154_HW_AACK |IEEE802154_HW_TXPOWER |IEEE802154_HW_ARET |IEEE802154_HW_AFILT |IEEE802154_HW_PROMISCUOUS ;
Signature · 1 line
2.1.2
Alexander Aring
maintainerPATCH 17/17 mac802154: add basic support for monitor
In reply to Alexander AringThis patch adds basic support for monitor mode. Also change the open call that we set the transceiver mac setting on an interface up. Futher patches will add a better handling while interface up an interface.
--- net/mac802154/ieee802154_i.h | 1 + net/mac802154/iface.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
net/mac802154/ieee802154_i.h +1 -0
@@ -84,6 +84,7 @@ struct ieee802154_sub_if_data {__le16 pan_id;__le16 short_addr;__le64 extended_addr; +bool promisuous_mode;struct ieee802154_mac_params mac_params;
net/mac802154/iface.c +11 -1
@@ -196,6 +196,12 @@ static int mac802154_wpan_open(struct net_device *dev)mutex_lock (&phy->pib_lock); +if (local->hw.flags &IEEE802154_HW_PROMISCUOUS ) { + rc =drv_set_promiscuous_mode (local, sdata->promisuous_mode); +if (rc <0 ) + goto out; + } +if (local->hw.flags &IEEE802154_HW_TXPOWER ) { rc =drv_set_tx_power (local, sdata->mac_params.transmit_power);if (rc <0 )
@@ -382,7 +388,7 @@ static const struct net_device_ops mac802154_wpan_ops = { };static const struct net_device_ops mac802154_monitor_ops = { - .ndo_open = mac802154_slave_open, + .ndo_open = mac802154_wpan_open, .ndo_stop = mac802154_slave_close, .ndo_start_xmit = ieee802154_monitor_start_xmit, };
@@ -434,6 +440,8 @@ void mac802154_wpan_setup(struct net_device *dev) sdata->pan_id =cpu_to_le16 (IEEE802154_PANID_BROADCAST ); sdata->short_addr =cpu_to_le16 (IEEE802154_ADDR_BROADCAST ); + sdata->promisuous_mode = false; +mac802154_llsec_init (&sdata->sec); }
@@ -453,4 +461,6 @@ void mac802154_monitor_setup(struct net_device *dev) sdata =IEEE802154_DEV_TO_SUB_IF (dev); sdata->type =IEEE802154_DEV_MONITOR ; + + sdata->promisuous_mode = true; }
Signature · 1 line
2.1.2
Hi Alex,
Quoted 31 lines
This patch series fix checksum and monitor handling. The checksum handling is currently a little bit weird, because all driver drops the checksum while delivering. In monitor mode we want to see the received checksum. This patch series contains various patches to fix the checksum handling and add basic support for real monitor mode with promiscuous mode setting.
The checksum handling is now in some state which should work also for monitor interfaces. There exist a better way to add runtime changeable flags to handle crc calculation via hardware or software. Also flags like if the monitor interface receiving is with or without checksum. This is only to introduce some behaviour which should working.
Alexander Aring (17):
mac802154: main: remove unnecessary include
mac802154: remove tab after define
mac802154: addIEEE802154_HW_AREThw flag
mac802154: add hardware address filter flag
mac802154: add support for promiscuous mode
at86rf230: add support for promiscuous mode
mac802154: separate omit tx/rx flags
mac802154: rx: remove unnecessary parameter
mac802154: rx: simplify crc receive handling
mac802154: rx: add software checksum filtering check
mac802154: rx: remove overridepkt_typeset toPACKET_HOST
mac802154: rx: usenetif_receive_skb
mac802154: rx: add rx stats incrementation
mac802154: rx: monitor receive cleanup
mac802154: rx: add error handling afterskb_clone
at86rf230: deliver with checksum
mac802154: add basic support for monitor
Quoted 11 lines
drivers/net/ieee802154/at86rf230.c | 35 +++++++++++++++++++-- drivers/net/ieee802154/cc2520.c | 3 +- drivers/net/ieee802154/mrf24j40.c | 3 +- include/net/mac802154.h | 40 ++++++++++++++++++------ net/mac802154/driver-ops.h | 13 ++++++++ net/mac802154/ieee802154_i.h | 1 + net/mac802154/iface.c | 12 ++++++- net/mac802154/main.c | 1 - net/mac802154/rx.c | 64 +++++++++++++++++++++----------------- net/mac802154/tx.c | 2 +- 10 files changed, 127 insertions(+), 47 deletions(-)
all 17 patches have been applied to bluetooth-next tree.
Regards
Marcel