nl80211: add support for BSS coloring
PATCH 1/3 nl80211: add support for BSS coloring
Add the required functionality to nl80211 that we require to notify about color collisions, triggering the color change and notifying when it is completed.
--- include/net/cfg80211.h | 64 ++++++++++++++ include/uapi/linux/nl80211.h | 43 +++++++++ net/wireless/nl80211.c | 164 +++++++++++++++++++++++++++++++++++ net/wireless/rdev-ops.h | 12 +++ net/wireless/trace.h | 60 +++++++++++++ 5 files changed, 343 insertions(+)
include/net/cfg80211.h +64 -0
@@ -1155,6 +1155,27 @@ struct cfg80211_csa_settings {u8 count; }; +/** +* struct cfg80211_cca_settings - color change settings +* +* Used for color change +* +* @beacon_cca: beacon data while performing the change +* @counter_offsets_beacon: offsets of the counters within the beacon (tail) +* @counter_offsets_presp: offsets of the counters within the probe response +* @beacon_after: beacon data to be used after the change +* @count: number of beacons until the change +* @color: the color that we will have after th change +*/ +struct cfg80211_cca_settings { +struct cfg80211_beacon_data beacon_cca; +u16 counter_offset_beacon; +u16 counter_offset_presp; +struct cfg80211_beacon_data beacon_after; +u8 count; +u8 color; +}; +#define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10/**
@@ -3795,6 +3816,7 @@ struct mgmt_frame_regs {* This callback may sleep. * @reset_tid_config: Reset TID specific configuration for the peer, for the * given TIDs. This callback may sleep. +* @color_change: initiate a color change (with CCA). */ struct cfg80211_ops {int (*suspend)(struct wiphy *wiphy,struct cfg80211_wowlan *wow);
@@ -4123,6 +4145,9 @@ struct cfg80211_ops { struct cfg80211_tid_config *tid_conf);int (*reset_tid_config)(struct wiphy *wiphy,struct net_device *dev,const u8 *peer,u8 tids); +int (*color_change)(struct wiphy *wiphy, +struct net_device *dev, +struct cfg80211_cca_settings *params); };/*
@@ -4172,6 +4197,7 @@ struct cfg80211_ops {* @WIPHY_FLAG_HAS_STATIC_WEP: The device supports static WEP key installation * before connection. * @WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK: The device supports bigger kek and kck keys +* @WIPHY_FLAG_SUPPORTS_BSS_COLOR: Device supports BSS coloring */ enum wiphy_flags {WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK =BIT (0 ),
@@ -4198,6 +4224,7 @@ enum wiphy_flags {WIPHY_FLAG_SUPPORTS_5_10_MHZ =BIT (22 ),WIPHY_FLAG_HAS_CHANNEL_SWITCH =BIT (23 ),WIPHY_FLAG_HAS_STATIC_WEP =BIT (24 ), + WIPHY_FLAG_SUPPORTS_BSS_COLOR = BIT(25), };/**
@@ -7881,4 +7908,41 @@ void cfg80211_update_owe_info_event(struct net_device *netdev,struct cfg80211_update_owe_info *owe_info, gfp_t gfp); +/** +* cfg80211_obss_color_collision_notify - notify about bss color collisions +* @dev: network device +* @color_bitmap: representations of the colors that the local BSS is aware of +*/ +void cfg80211_obss_color_collision_notify (struct net_device *dev, +u64 color_bitmap); + +/* +* cfg80211_color_change_started_notify - notify color change start +* @dev: the device on which the color is switched +* @count: the number of TBTTs until the color change happens +* +* Inform the userspace about the color change that has just +* started. +*/ +void cfg80211_color_change_started_notify (struct net_device *dev, +u8 count); + +/* +* cfg80211_color_change_aborted_notify - notify color change abort +* @dev: the device on which the color is switched +* +* Inform the userspace about the color change that has just +* started. +*/ +void cfg80211_color_change_aborted_notify (struct net_device *dev); + +/* +* cfg80211_color_change_notify - notify color change completion +* @dev: the device on which the color was switched +* +* Inform the userspace about the color change that has just +* completed. +*/ +void cfg80211_color_change_notify (struct net_device *dev); +#endif /* __NET_CFG80211_H */
include/uapi/linux/nl80211.h +43 -0
67 lines not on this page · raw message
net/wireless/nl80211.c +164 -0
188 lines not on this page · raw message
net/wireless/rdev-ops.h +12 -0
@@ -1356,4 +1356,16 @@ static inline int rdev_reset_tid_config(struct cfg80211_registered_device *rdev, return ret; } +static inline int rdev_color_change (struct cfg80211_registered_device *rdev, +struct net_device *dev, +struct cfg80211_cca_settings *params) +{ +int ret; + +trace_rdev_color_change (&rdev->wiphy, dev, params); + ret = rdev->ops->color_change (&rdev->wiphy, dev, params); +trace_rdev_return_int (&rdev->wiphy, ret); +return ret; +} +#endif /* __CFG80211_RDEV_OPS */
net/wireless/trace.h +60 -0
66 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/3 mac80211: add support for BSS coloring
The CCA (color change announcement) is very similar to how CSA works where we have an IE that includes a counter. When the counter hits 0, the new color is applied via an updated beacon.
This patch makes the CSA counter functionality reusable, rather than implementing it again. This also allows for future reuse incase support for other counter IEs gets added.
--- include/net/mac80211.h | 58 ++++++++++ net/mac80211/cfg.c | 222 +++++++++++++++++++++++++++++++++++-- net/mac80211/ieee80211_i.h | 15 +++ net/mac80211/iface.c | 3 + net/mac80211/tx.c | 128 +++++++++++++++++---- 5 files changed, 399 insertions(+), 27 deletions(-)
include/net/mac80211.h +58 -0
@@ -1642,6 +1642,10 @@ enum ieee80211_vif_flags {* @txq: the multicast data TX queue (if driver uses the TXQ abstraction) * @txqs_stopped: per AC flag to indicate that intermediate TXQs are stopped, * protected by fq->lock. +* @cca_active: marks whether a color change is going on. Internally it is +* write-protected by sdata_lock and local->mtx so holding either is fine +* for read access. +* @cca_color: the color that we will have after the change. */ struct ieee80211_vif {enum nl80211_iftype type;
@@ -1669,6 +1673,9 @@ struct ieee80211_vif {bool txqs_stopped[IEEE80211_NUM_ACS ]; +bool cca_active; +u8 cca_color; +/* must be last */ u8 drv_priv[]__aligned(sizeof(void *)) ; };
@@ -4737,6 +4744,11 @@ void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets);#define IEEE80211_MAX_CSA_COUNTERS_NUM 2 +enum mac80211_counter { +MAC80211_COUNTER_CSA =0 , +MAC80211_COUNTER_CCA , +}; +/** * struct ieee80211_mutable_offsets - mutable beacon offsets * @tim_offset: position of TIM element
@@ -4744,12 +4756,15 @@ void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets);* @csa_counter_offs: array of IEEE80211_MAX_CSA_COUNTERS_NUM offsets * to CSA counters. This array can contain zero values which * should be ignored. +* @cca_counter_off: offset to the cca counter. zero values should be +* ignored. */ struct ieee80211_mutable_offsets {u16 tim_offset;u16 tim_length;u16 csa_counter_offs[IEEE80211_MAX_CSA_COUNTERS_NUM ]; +u16 cca_counter_off; };/**
@@ -4862,6 +4877,38 @@ void ieee80211_csa_finish(struct ieee80211_vif *vif);*/ bool ieee80211_csa_is_complete (struct ieee80211_vif *vif); +/** +* ieee80211_cca_update_counter - request mac80211 to decrement the cca counter +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* +* The cca counter should be updated after each beacon transmission. +* This function is called implicitly when +* ieee80211_beacon_get/ieee80211_beacon_get_tim are called, however if the +* beacon frames are generated by the device, the driver should call this +* function after each beacon transmission to sync mac80211's cca counters. +* +* Return: new csa counter value +*/ + +u8 ieee80211_cca_update_counter (struct ieee80211_vif *vif); + +/** +* ieee80211_cca_finish - notify mac80211 about color change +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* +* After a color change announcement was scheduled and the counter in this +* announcement hits 1, this function must be called by the driver to +* notify mac80211 that the color can be changed +*/ +void ieee80211_cca_finish (struct ieee80211_vif *vif); + +/** +* ieee80211_cca_is_complete - find out if counters reached 1 +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* +* This function returns whether the color change counters reached zero. +*/ +bool ieee80211_cca_is_complete (struct ieee80211_vif *vif);/** * ieee80211_proberesp_get - retrieve a Probe Response template
@@ -6558,4 +6605,15 @@ u32 ieee80211_calc_tx_airtime(struct ieee80211_hw *hw,*/ bool ieee80211_set_hw_80211_encap (struct ieee80211_vif *vif,bool enable); +/** +* ieeee80211_obss_color_collision_notify notify userland about a BSS color +* collision. +* +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* @color_bitmap: a 64 bit bitmap representing the colors that the local BSS is +* aware of. +*/ +void +ieeee80211_obss_color_collision_notify (struct ieee80211_vif *vif, +u64 color_bitmap);#endif /* MAC80211_H */
net/mac80211/cfg.c +214 -8
304 lines not on this page · raw message
net/mac80211/ieee80211_i.h +15 -0
@@ -256,12 +256,21 @@ struct ieee80211_csa_settings {u8 count; }; +struct ieee80211_cca_settings { +u16 counter_offset_beacon; +u16 counter_offset_presp; + +u8 count; +}; +struct beacon_data {u8 *head, *tail;int head_len, tail_len;struct ieee80211_meshconf_ie *meshconf;u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM ];u8 csa_current_counter; +u16 cca_counter_offset; +u8 cca_current_counter;struct rcu_head rcu_head; };
@@ -269,6 +278,7 @@ struct probe_resp {struct rcu_head rcu_head;int len;u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM ]; +u16 cca_counter_offset;u8 data[]; };
@@ -924,6 +934,8 @@ struct ieee80211_sub_if_data {bool csa_block_tx;/* write-protected by sdata_lock and local->mtx */ struct cfg80211_chan_def csa_chandef; +struct work_struct cca_finalize_work; +struct list_head assigned_chanctx_list;/* protected by chanctx_mtx */ struct list_head reserved_chanctx_list;/* protected by chanctx_mtx */
@@ -1738,6 +1750,9 @@ void ieee80211_csa_finalize_work(struct work_struct *work);int ieee80211_channel_switch (struct wiphy *wiphy,struct net_device *dev,struct cfg80211_csa_settings *params); +/* color change handling */ +void ieee80211_cca_finalize_work (struct work_struct *work); +/* interface handling */ #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \ NETIF_F_HW_CSUM | NETIF_F_SG | \
net/mac80211/iface.c +3 -0
@@ -912,6 +912,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, GFP_KERNEL); } +cancel_work_sync (&sdata->cca_finalize_work); +/* APs need special treatment */ if (sdata->vif.type ==NL80211_IFTYPE_AP ) {struct ieee80211_sub_if_data *vlan, *tmpsdata;
@@ -1489,6 +1491,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,INIT_WORK (&sdata->work, ieee80211_iface_work);INIT_WORK (&sdata->recalc_smps, ieee80211_recalc_smps_work);INIT_WORK (&sdata->csa_finalize_work, ieee80211_csa_finalize_work); +INIT_WORK (&sdata->cca_finalize_work, ieee80211_cca_finalize_work);INIT_LIST_HEAD (&sdata->assigned_chanctx_list);INIT_LIST_HEAD (&sdata->reserved_chanctx_list);
net/mac80211/tx.c +109 -19
209 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 3/3 ath11k: add support for BSS coloring
In reply to John CrispinWhenever the MAC detects a color collision or any of its associated station detects one the FW will send out an event. Add the code to parse and handle this event. and pass the data up to mac80211.
The FW does not provide an offload future such as the one used for CSA. The CCA process is hence triggered via the beacon offload tx completion events sent out by the FW.
--- drivers/net/wireless/ath/ath11k/mac.c | 18 ++++++++ drivers/net/wireless/ath/ath11k/mac.h | 1 + drivers/net/wireless/ath/ath11k/wmi.c | 60 +++++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/wmi.h | 14 +++++++ 4 files changed, 93 insertions(+)
drivers/net/wireless/ath/ath11k/mac.c +18 -0
@@ -802,6 +802,22 @@ static int ath11k_mac_setup_bcn_tmpl(struct ath11k_vif *arvif)return ret; } +void ath11k_mac_bcn_tx_event (struct ath11k_vif *arvif) +{ +struct ieee80211_vif *vif = arvif->vif; + +if (!vif->cca_active) +return ; + +if (ieee80211_cca_is_complete (vif)) { +ieee80211_cca_finish (vif); +return ; + } + +ieee80211_cca_update_counter (vif); +ath11k_mac_setup_bcn_tmpl (arvif); +} +static void ath11k_control_beaconing (struct ath11k_vif *arvif,struct ieee80211_bss_conf *info) {
@@ -6043,6 +6059,8 @@ static int __ath11k_mac_register(struct ath11k *ar) ar->hw->wiphy->features |=NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE |NL80211_FEATURE_AP_SCAN ; + ar->hw->wiphy->flags |=WIPHY_FLAG_SUPPORTS_BSS_COLOR ; + ar->max_num_stations =TARGET_NUM_STATIONS ; ar->max_num_peers =TARGET_NUM_PEERS_PDEV ;
drivers/net/wireless/ath/ath11k/mac.h +1 -0
@@ -146,4 +146,5 @@ int ath11k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx);u8 ath11k_mac_bw_to_mac80211_bw (u8 bw);enum ath11k_supported_bw ath11k_mac_mac80211_bw_to_ath11k_bw (enum rate_info_bw bw);enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type (u32 cipher); +void ath11k_mac_bcn_tx_event (struct ath11k_vif *arvif);#endif
drivers/net/wireless/ath/ath11k/wmi.c +60 -0
90 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/wmi.h +14 -0
@@ -733,6 +733,7 @@ enum wmi_tlv_event_id {WMI_MDNS_STATS_EVENTID =WMI_TLV_CMD (WMI_GRP_MDNS_OFL ),WMI_SAP_OFL_ADD_STA_EVENTID =WMI_TLV_CMD (WMI_GRP_SAP_OFL ),WMI_SAP_OFL_DEL_STA_EVENTID , +WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID =WMI_EVT_GRP_START_ID (WMI_GRP_OBSS_OFL ),WMI_OCB_SET_CONFIG_RESP_EVENTID =WMI_TLV_CMD (WMI_GRP_OCB ),WMI_OCB_GET_TSF_TIMER_RESP_EVENTID , WMI_DCC_GET_STATS_RESP_EVENTID,
@@ -4744,6 +4745,13 @@ struct wmi_obss_spatial_reuse_params_cmd {#define ATH11K_BSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS 10000#define ATH11K_BSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS 5000 +enum wmi_bss_color_collision { +WMI_BSS_COLOR_COLLISION_DISABLE =0 , +WMI_BSS_COLOR_COLLISION_DETECTION , +WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY , +WMI_BSS_COLOR_FREE_SLOT_AVAILABLE , +}; +struct wmi_obss_color_collision_cfg_params_cmd {u32 tlv_header;u32 vdev_id;
@@ -4761,6 +4769,12 @@ struct wmi_bss_color_change_enable_params_cmd {u32 enable; } __packed; +struct wmi_obss_color_collision_event { +u32 vdev_id; +u32 evt_type; +u64 obss_color_bitmap; +} __packed; +#define ATH11K_IPV4_TH_SEED_SIZE 5#define ATH11K_IPV6_TH_SEED_SIZE 11
Signature · 1 line
2.25.1
Re: [PATCH 3/3] ath11k: add support for BSS coloring
Quoted 9 lines · John Crispin
Whenever the MAC detects a color collision or any of its associated station detects one the FW will send out an event. Add the code to parse and handle this event. and pass the data up to mac80211.
The FW does not provide an offload future such as the one used for CSA. The CCA process is hence triggered via the beacon offload tx completion events sent out by the FW.
Signed-off-by John Crispin <[email protected]>
On what hardware and firmware did you test this? I'll add that to the commit log.
drivers/net/wireless/ath/ath11k/wmi.c int ath11k_wmi_send_bss_color_change_enable_cmd(struct ath11k *ar, u32 vdev_id, · line 3080
Quoted 7 lines
drivers/net/wireless/ath/ath11k/wmi.c +7
-0+if (ev->obss_color_bitmap &BIT (arvif->vif->bss_conf.he_bss_color.color)) { +/* FW sometime sends out stray events. Ignore them if our color is free */ +ieeee80211_obss_color_collision_notify (arvif->vif, ev->obss_color_bitmap); + +ath11k_info (ab,"OBSS color collision detected vdev:%d, event:%d, bitmap:%08llx\n" , + ev->vdev_id, ev->evt_type, ev->obss_color_bitmap); + }
Is this really something so important that we should print it to the log? What should the user do after seeing this warning?
And warnings should be printed with ath11k_warn(), but maybe this should be a debug message?
Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH 3/3] ath11k: add support for BSS coloring
In reply to John CrispinQuoted 8 lines · John Crispin
Whenever the MAC detects a color collision or any of its associated station detects one the FW will send out an event. Add the code to parse and handle this event. and pass the data up to mac80211.
The FW does not provide an offload future such as the one used for CSA. The CCA process is hence triggered via the beacon offload tx completion events sent out by the FW.
[...]
Quoted 21 lines
(quoted diff) +2
-0+static void +ath11k_wmi_obss_color_collision_event(struct ath11k_base *ab, struct
sk_buff*skb)drivers/net/wireless/ath/ath11k/wmi.c +17
-0+{ +const void **tb; +const struct wmi_obss_color_collision_event *ev; +struct ath11k_vif *arvif; +int ret; + + tb =ath11k_wmi_tlv_parse_alloc (ab, skb->data, skb->len,GFP_ATOMIC ); +if (IS_ERR (tb)) { + ret =PTR_ERR (tb); +ath11k_warn (ab,"failed to parse tlv: %d\n" , ret); +return ; + } + + ev = tb[WMI_TAG_OBSS_COLOR_COLLISION_EVT ]; +if (!ev) { +ath11k_warn (ab,"failed to fetch obss color collision ev" ); + goto exit;
drivers/net/wireless/ath/ath11k/wmi.c int ath11k_wmi_send_bss_color_change_enable_cmd(struct ath11k *ar, u32 vdev_id, · line 3068
Quoted 10 lines
drivers/net/wireless/ath/ath11k/wmi.c +10
-0+ } + + arvif =ath11k_mac_get_arvif_by_vdev_id (ab, ev->vdev_id); +switch (ev->evt_type) { +case WMI_BSS_COLOR_COLLISION_DETECTION : +break ; +case WMI_BSS_COLOR_COLLISION_DISABLE : +case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY : +case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE : +return ;
tb should be freed here.
-Rajkumar