net: mac802154: move receive parameters above start
Subsystems (3)
RFC 1/2 net: mac802154: move receive parameters above start
This patch moves all receive parameters above the drv_start() functionality to make it accessibile in the drv_start() function.
--- net/mac802154/driver-ops.h | 190 ++++++++++++++++++------------------- 1 file changed, 95 insertions(+), 95 deletions(-)
net/mac802154/driver-ops.h +95 -95
@@ -24,203 +24,221 @@ 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) +static inline int drv_set_pan_id (struct ieee802154_local *local,__le16 pan_id) { +struct ieee802154_hw_addr_filt filt;int ret;might_sleep (); -trace_802154_drv_start (local); - local->started = true; -smp_mb (); - ret = local->ops->start (&local->hw); +if (!local->ops->set_hw_addr_filt) { +WARN_ON (1 ); +return -EOPNOTSUPP ; + } + + filt.pan_id = pan_id; + +trace_802154_drv_set_pan_id (local, pan_id); + ret = local->ops->set_hw_addr_filt (&local->hw, &filt, +IEEE802154_AFILT_PANID_CHANGED );trace_802154_drv_return_int (local, ret);return ret; } -static inline void drv_stop (struct ieee802154_local *local) +static inline int +drv_set_extended_addr (struct ieee802154_local *local,__le64 extended_addr) { -might_sleep (); +struct ieee802154_hw_addr_filt filt; +int ret; -trace_802154_drv_stop (local); - local->ops->stop (&local->hw); -trace_802154_drv_return_void (local); +might_sleep (); -/* sync away all work on the tasklet before clearing started */ -tasklet_disable (&local->tasklet); -tasklet_enable (&local->tasklet); +if (!local->ops->set_hw_addr_filt) { +WARN_ON (1 ); +return -EOPNOTSUPP ; + } -barrier (); + filt.ieee_addr = extended_addr; - local->started = false; +trace_802154_drv_set_extended_addr (local, extended_addr); + ret = local->ops->set_hw_addr_filt (&local->hw, &filt, +IEEE802154_AFILT_IEEEADDR_CHANGED ); +trace_802154_drv_return_int (local, ret); +return ret; }static inline int -drv_set_channel (struct ieee802154_local *local,u8 page,u8 channel) +drv_set_short_addr (struct ieee802154_local *local,__le16 short_addr) { +struct ieee802154_hw_addr_filt filt;int ret;might_sleep (); -trace_802154_drv_set_channel (local, page, channel); - ret = local->ops->set_channel (&local->hw, page, channel); +if (!local->ops->set_hw_addr_filt) { +WARN_ON (1 ); +return -EOPNOTSUPP ; + } + + filt.short_addr = short_addr; + +trace_802154_drv_set_short_addr (local, short_addr); + ret = local->ops->set_hw_addr_filt (&local->hw, &filt, +IEEE802154_AFILT_SADDR_CHANGED );trace_802154_drv_return_int (local, ret);return ret; } -static inline int drv_set_tx_power (struct ieee802154_local *local,s32 mbm) +static inline int +drv_set_pan_coord (struct ieee802154_local *local,bool is_coord) { +struct ieee802154_hw_addr_filt filt;int ret;might_sleep (); -if (!local->ops->set_txpower) { +if (!local->ops->set_hw_addr_filt) {WARN_ON (1 );return -EOPNOTSUPP ; } -trace_802154_drv_set_tx_power (local, mbm); - ret = local->ops->set_txpower (&local->hw, mbm); + filt.pan_coord = is_coord; + +trace_802154_drv_set_pan_coord (local, is_coord); + ret = local->ops->set_hw_addr_filt (&local->hw, &filt, +IEEE802154_AFILT_PANC_CHANGED );trace_802154_drv_return_int (local, ret);return ret; } -static inline int drv_set_cca_mode (struct ieee802154_local *local, -const struct wpan_phy_cca *cca) +static inline int +drv_set_promiscuous_mode (struct ieee802154_local *local,bool on) {int ret;might_sleep (); -if (!local->ops->set_cca_mode) { +if (!local->ops->set_promiscuous_mode) {WARN_ON (1 );return -EOPNOTSUPP ; } -trace_802154_drv_set_cca_mode (local, cca); - ret = local->ops->set_cca_mode (&local->hw, cca); +trace_802154_drv_set_promiscuous_mode (local, on); + ret = local->ops->set_promiscuous_mode (&local->hw, on);trace_802154_drv_return_int (local, ret);return ret; } -static inline int drv_set_lbt_mode (struct ieee802154_local *local,bool mode) +static inline int drv_start (struct ieee802154_local *local) {int ret;might_sleep (); -if (!local->ops->set_lbt) { -WARN_ON (1 ); -return -EOPNOTSUPP ; - } - -trace_802154_drv_set_lbt_mode (local, mode); - ret = local->ops->set_lbt (&local->hw, mode); +trace_802154_drv_start (local); + local->started = true; +smp_mb (); + ret = local->ops->start (&local->hw);trace_802154_drv_return_int (local, ret);return ret; } +static inline void drv_stop (struct ieee802154_local *local) +{ +might_sleep (); + +trace_802154_drv_stop (local); + local->ops->stop (&local->hw); +trace_802154_drv_return_void (local); + +/* sync away all work on the tasklet before clearing started */ +tasklet_disable (&local->tasklet); +tasklet_enable (&local->tasklet); + +barrier (); + + local->started = false; +} +static inline int -drv_set_cca_ed_level (struct ieee802154_local *local,s32 mbm) +drv_set_channel (struct ieee802154_local *local,u8 page,u8 channel) {int ret;might_sleep (); -if (!local->ops->set_cca_ed_level) { -WARN_ON (1 ); -return -EOPNOTSUPP ; - } - -trace_802154_drv_set_cca_ed_level (local, mbm); - ret = local->ops->set_cca_ed_level (&local->hw, mbm); +trace_802154_drv_set_channel (local, page, channel); + ret = local->ops->set_channel (&local->hw, page, channel);trace_802154_drv_return_int (local, ret);return ret; } -static inline int drv_set_pan_id (struct ieee802154_local *local,__le16 pan_id) +static inline int drv_set_tx_power (struct ieee802154_local *local,s32 mbm) { -struct ieee802154_hw_addr_filt filt;int ret;might_sleep (); -if (!local->ops->set_hw_addr_filt) { +if (!local->ops->set_txpower) {WARN_ON (1 );return -EOPNOTSUPP ; } - filt.pan_id = pan_id; - -trace_802154_drv_set_pan_id (local, pan_id); - ret = local->ops->set_hw_addr_filt (&local->hw, &filt, -IEEE802154_AFILT_PANID_CHANGED ); +trace_802154_drv_set_tx_power (local, mbm); + ret = local->ops->set_txpower (&local->hw, mbm);trace_802154_drv_return_int (local, ret);return ret; } -static inline int -drv_set_extended_addr (struct ieee802154_local *local,__le64 extended_addr) +static inline int drv_set_cca_mode (struct ieee802154_local *local, +const struct wpan_phy_cca *cca) { -struct ieee802154_hw_addr_filt filt;int ret;might_sleep (); -if (!local->ops->set_hw_addr_filt) { +if (!local->ops->set_cca_mode) {WARN_ON (1 );return -EOPNOTSUPP ; } - filt.ieee_addr = extended_addr; - -trace_802154_drv_set_extended_addr (local, extended_addr); - ret = local->ops->set_hw_addr_filt (&local->hw, &filt, -IEEE802154_AFILT_IEEEADDR_CHANGED ); +trace_802154_drv_set_cca_mode (local, cca); + ret = local->ops->set_cca_mode (&local->hw, cca);trace_802154_drv_return_int (local, ret);return ret; } -static inline int -drv_set_short_addr (struct ieee802154_local *local,__le16 short_addr) +static inline int drv_set_lbt_mode (struct ieee802154_local *local,bool mode) { -struct ieee802154_hw_addr_filt filt;int ret;might_sleep (); -if (!local->ops->set_hw_addr_filt) { +if (!local->ops->set_lbt) {WARN_ON (1 );return -EOPNOTSUPP ; } - filt.short_addr = short_addr; - -trace_802154_drv_set_short_addr (local, short_addr); - ret = local->ops->set_hw_addr_filt (&local->hw, &filt, -IEEE802154_AFILT_SADDR_CHANGED ); +trace_802154_drv_set_lbt_mode (local, mode); + ret = local->ops->set_lbt (&local->hw, mode);trace_802154_drv_return_int (local, ret);return ret; }static inline int -drv_set_pan_coord (struct ieee802154_local *local,bool is_coord) +drv_set_cca_ed_level (struct ieee802154_local *local,s32 mbm) { -struct ieee802154_hw_addr_filt filt;int ret;might_sleep (); -if (!local->ops->set_hw_addr_filt) { +if (!local->ops->set_cca_ed_level) {WARN_ON (1 );return -EOPNOTSUPP ; } - filt.pan_coord = is_coord; - -trace_802154_drv_set_pan_coord (local, is_coord); - ret = local->ops->set_hw_addr_filt (&local->hw, &filt, -IEEE802154_AFILT_PANC_CHANGED ); +trace_802154_drv_set_cca_ed_level (local, mbm); + ret = local->ops->set_cca_ed_level (&local->hw, mbm);trace_802154_drv_return_int (local, ret);return ret; }
@@ -264,22 +282,4 @@ drv_set_max_frame_retries(struct ieee802154_local *local, s8 max_frame_retries) return ret; } -static inline int -drv_set_promiscuous_mode (struct ieee802154_local *local,bool on) -{ -int ret; - -might_sleep (); - -if (!local->ops->set_promiscuous_mode) { -WARN_ON (1 ); -return -EOPNOTSUPP ; - } - -trace_802154_drv_set_promiscuous_mode (local, on); - ret = local->ops->set_promiscuous_mode (&local->hw, on); -trace_802154_drv_return_int (local, ret); -return ret; -} -#endif /* __MAC802154_DRIVER_OPS */
Signature · 1 line
2.31.1
RFC 2/2 net: mac802154: set filter at drv_start()
The current filtering level is set on the first interface up on a wpan phy. If we support scan functionality we need to change the filtering level on the fly on an operational phy and switching back again.
This patch will move the receive mode parameter e.g. address filter and promiscuous mode to the drv_start() functionality to allow changing the receive mode on an operational phy not on first ifup only. In future this should be handled on driver layer because each hardware has it's own way to enter a specific filtering level. However this should offer to switch to mode IEEE802154_FILTERING_NONE and back to IEEE802154_FILTERING_4_FRAME_FIELDS.
Only IEEE802154_FILTERING_4_FRAME_FIELDS and IEEE802154_FILTERING_NONE are somewhat supported by current hardware. All other filtering levels can be supported in future but will end in IEEE802154_FILTERING_NONE as the receive part can kind of "emulate" those receive paths by doing additional filtering routines.
---
RFC as code snippet as requested to somehow deal with the current driver-ops and switching between filters with address filtering (AACK on) and non-address filtering (AACK off) which is necessary for scanning in this case it will be NONE because that's what we currently support and I hope it can useful for scanning receive mode.
drivers/net/ieee802154/mac802154_hwsim.c | 4 ++ include/net/cfg802154.h | 6 +- net/mac802154/cfg.c | 3 +- net/mac802154/driver-ops.h | 74 +++++++++++++++++++++++- net/mac802154/ieee802154_i.h | 4 ++ net/mac802154/iface.c | 46 +++++---------- net/mac802154/rx.c | 7 ++- 7 files changed, 108 insertions(+), 36 deletions(-)
drivers/net/ieee802154/mac802154_hwsim.c +4 -0
@@ -148,6 +148,10 @@ static int hwsim_hw_start(struct ieee802154_hw *hw)struct hwsim_phy *phy = hw->priv; phy->suspended = false; +/* TODO implement IEEE802154_FILTERING_4_FRAME_FIELDS in hwsim +* receive handling for now let it run as it is before pkt_type +* will do filtering. +*/ return 0 ; }
include/net/cfg802154.h +3 -3
@@ -223,7 +223,9 @@ struct wpan_phy {atomic_t hold_txs;wait_queue_head_t sync_txq; -/* Current filtering level on reception */ +/* Current filtering level on reception. +* Only allowed to be changed if phy is not operational. +*/ unsigned long filtering;char priv[]__aligned(NETDEV_ALIGN) ;
@@ -377,8 +379,6 @@ struct wpan_dev {bool lbt; -bool promiscuous_mode; -/* fallback for acknowledgment bit setting */ bool ackreq; };
net/mac802154/cfg.c +2 -1
@@ -67,7 +67,8 @@ static int ieee802154_resume(struct wpan_phy *wpan_phy) goto wake_up;/* restart hardware */ - ret =drv_start (local); + ret =drv_start (local, local->phy->filtering, + &local->addr_filt);if (ret)return ret;
net/mac802154/driver-ops.h +73 -1
85 lines not on this page · raw message
net/mac802154/ieee802154_i.h +4 -0
@@ -26,6 +26,8 @@ struct ieee802154_local {struct ieee802154_hw hw;const struct ieee802154_ops *ops; +/* hardware address filter */ +struct ieee802154_hw_addr_filt addr_filt;/* ieee802154 phy */ struct wpan_phy *phy;
@@ -82,6 +84,8 @@ struct ieee802154_sub_if_data {struct ieee802154_local *local;struct net_device *dev; +enum ieee802154_filtering_level required_filtering; +unsigned long state;char name[IFNAMSIZ ];
net/mac802154/iface.c +16 -30
87 lines not on this page · raw message
net/mac802154/rx.c +6 -1
@@ -271,7 +271,12 @@ void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *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 ) { +/* TODO do whatever you want here if necessary to filter by +* check on IEEE802154_FILTERING_NONE. And upcomming receive +* path in which state the phy is e.g. scanning. +*/ +if (local->hw.flags &IEEE802154_HW_RX_DROP_BAD_CKSUM || + local->phy->filtering ==IEEE802154_FILTERING_NONE ) { crc =crc_ccitt (0 , skb->data, skb->len);if (crc) {rcu_read_unlock ();
Signature · 1 line
2.31.1
Alexander Aring
AppliedRe: [RFC wpan-next 2/2] net: mac802154: set filter at drv_start()
Hi,
Quoted 19 lines · Alexander Aring
The current filtering level is set on the first interface up on a wpan phy. If we support scan functionality we need to change the filtering level on the fly on an operational phy and switching back again.
This patch will move the receive mode parameter e.g. address filter and promiscuous mode to the
drv_start()functionality to allow changing the receive mode on an operational phy not on first ifup only. In future this should be handled on driver layer because each hardware has it's own way to enter a specific filtering level. However this should offer to switch to modeIEEE802154_FILTERING_NONEand back toIEEE802154_FILTERING_4_FRAME_FIELDS.Only
IEEE802154_FILTERING_4_FRAME_FIELDSandIEEE802154_FILTERING_NONEare somewhat supported by current hardware. All other filtering levels can be supported in future but will end inIEEE802154_FILTERING_NONEas the receive part can kind of "emulate" those receive paths by doing additional filtering routines.
Quoted 9 lines
Signed-off-by Alexander Aring <[email protected]>---
RFC as code snippet as requested to somehow deal with the current driver-ops and switching between filters with address filtering (AACK on) and non-address filtering (AACK off) which is necessary for scanning in this case it will be NONE because that's what we currently support and I hope it can useful for scanning receive mode.
based on wpan-next/master with:
[PATCH wpan-next v2 01/11] net: mac802154: Introduce filtering levels
applied.
- Alex
Miquel Raynal
maintainerRe: [RFC wpan-next 2/2] net: mac802154: set filter at drv_start()
Hi Alexander,
[email protected] wrote on Sun, 4 Sep 2022 21:10:55 -0400:
Quoted 32 lines
Hi,
Quoted 19 lines · Alexander Aring
The current filtering level is set on the first interface up on a wpan phy. If we support scan functionality we need to change the filtering level on the fly on an operational phy and switching back again.
This patch will move the receive mode parameter e.g. address filter and promiscuous mode to the
drv_start()functionality to allow changing the receive mode on an operational phy not on first ifup only. In future this should be handled on driver layer because each hardware has it's own way to enter a specific filtering level. However this should offer to switch to modeIEEE802154_FILTERING_NONEand back toIEEE802154_FILTERING_4_FRAME_FIELDS.Only
IEEE802154_FILTERING_4_FRAME_FIELDSandIEEE802154_FILTERING_NONEare somewhat supported by current hardware. All other filtering levels can be supported in future but will end inIEEE802154_FILTERING_NONEas the receive part can kind of "emulate" those receive paths by doing additional filtering routines.Quoted 9 lines
Signed-off-by Alexander Aring <[email protected]>---
RFC as code snippet as requested to somehow deal with the current driver-ops and switching between filters with address filtering (AACK on) and non-address filtering (AACK off) which is necessary for scanning in this case it will be NONE because that's what we currently support and I hope it can useful for scanning receive mode.
Quoted 5 lines
based on wpan-next/master with:
[PATCH wpan-next v2 01/11] net: mac802154: Introduce filtering levels
applied.
Excellent! That was very helpful. I think I've found a nice way to use those filtering levels, it's not something that we need for the scan to work so I've queued those patches later, but in the end you were right, it's much better than the ->promiscuous callback alone.
I've integrated your patches, let me come up with a final submission, no worries about the v2, please just check v3 which will be much more interesting.
Thanks,
Miquèl