mac80211: add helper functions for tracking P2P NoA state
PATCH v2 1/1 mac80211: add helper functions for tracking P2P NoA state
--- include/net/mac80211.h | 45 +++++++++++++++++ net/mac80211/util.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+)
include/net/mac80211.h +45 -0
@@ -4625,4 +4625,49 @@ bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct sk_buff *skb, int band, struct ieee80211_sta **sta); +/** +* struct ieee80211_noa_data - holds temporary data for tracking P2P NoA state +* +* @next_tsf: TSF timestamp of the next absent state change +* @has_next_tsf: next absent state change event pending +* +* @absent: descriptor bitmask, set if GO is currently absent +* +* private: +* +* @count: count fields from the NoA descriptors +* @desc: adjusted data from the NoA +*/ +struct ieee80211_noa_data { +u32 next_tsf; +bool has_next_tsf; + +u8 absent; + +u8 count[IEEE80211_P2P_NOA_DESC_MAX ]; +struct { +u32 start; +u32 duration; +u32 interval; + } desc[IEEE80211_P2P_NOA_DESC_MAX ]; +}; + +/** +* ieee80211_parse_p2p_noa - initialize NoA tracking data from P2P IE +* +* @attr: P2P NoA IE +* @data: NoA tracking data +* @tsf: current TSF timestamp +*/ +int ieee80211_parse_p2p_noa (const struct ieee80211_p2p_noa_attr *attr, +struct ieee80211_noa_data *data,u32 tsf); + +/** +* ieee80211_update_p2p_noa - get next pending P2P GO absent state change +* +* @data: NoA tracking data +* @tsf: current TSF timestamp +*/ +void ieee80211_update_p2p_noa (struct ieee80211_noa_data *data,u32 tsf); +#endif /* MAC80211_H */
net/mac80211/util.c +135 -0
138 lines not on this page · raw message
Signature · 1 line
1.8.3.4 (Apple Git-47)
Johannes Berg
maintainernet/mac80211/util.c int ieee80211_cs_headroom(struct ieee80211_local *local, · line 2623
Quoted 13 lines · Felix Fietkau
net/mac80211/util.c +13
-0+static u32 +ieee80211_get_noa_absent_time (struct ieee80211_noa_data *data,u32 tsf) +{ +s32 offset =0 ; +int tries =0 ; + +ieee80211_extend_absent_time (data, tsf, &offset); +do { +if (!ieee80211_extend_absent_time (data, tsf, &offset)) +break ; + + tries++; + }while (tries <5 );
What's "tries < 5"?
johannes
Quoted 17 lines · Johannes Berg
net/mac80211/util.c int ieee80211_cs_headroom(struct ieee80211_local *local, · line 2623
Quoted 13 lines · Felix Fietkau
net/mac80211/util.c +13
-0+static u32 +ieee80211_get_noa_absent_time (struct ieee80211_noa_data *data,u32 tsf) +{ +s32 offset =0 ; +int tries =0 ; + +ieee80211_extend_absent_time (data, tsf, &offset); +do { +if (!ieee80211_extend_absent_time (data, tsf, &offset)) +break ; + + tries++; + }while (tries <5 );What's "tries < 5"?
Arbitrary value. It tries to merge up to 5 intervals of each NoA descriptor. I can't let it try forever because that can easily make it run into an infinite loop if the combination of the NoA descriptors doesn't leave any presence time inbetween.
- Felix
Johannes Berg
maintainerinclude/net/mac80211.h bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw, · line 4663
Quoted 9 lines · Felix Fietkau
include/net/mac80211.h +9
-0+/** +* ieee80211_parse_p2p_noa - initialize NoA tracking data from P2P IE +* +* @attr: P2P NoA IE +* @data: NoA tracking data +* @tsf: current TSF timestamp +*/ +int ieee80211_parse_p2p_noa (const struct ieee80211_p2p_noa_attr *attr, +struct ieee80211_noa_data *data,u32 tsf);
Since the return value isn't some sort of negative error, I think it'd be worthwhile to document it.
johannes