From 0ca54f6c5fd4ce58aa044d1fc7f00d7f6cf2801c Mon Sep 17 00:00:00 2001 From: Marek Puzyniak Date: Wed, 10 Apr 2013 13:19:13 +0200 Subject: mac80211: provide SSID in IBSS mode Some drivers need SSID in AP and IBSS mode. AP SSID is provided through BSS_CHANGED_SSID notification. There was no easy way to do the same for IBSS. In IBSS mode SSID is known but was not stored in BSS configuration. Extend the AP-mode functionality to also work in IBSS mode. Signed-off-by: Marek Puzyniak Signed-off-by: Johannes Berg --- include/net/mac80211.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/net') diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 64faf015dd1..0dde213dd3b 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -209,7 +209,7 @@ struct ieee80211_chanctx_conf { * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note * that it is only ever disabled for station mode. * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. - * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode) + * @BSS_CHANGED_SSID: SSID changed for this BSS (AP and IBSS mode) * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode) * @BSS_CHANGED_PS: PS changed for this BSS (STA mode) * @BSS_CHANGED_TXPOWER: TX power setting changed for this interface @@ -326,7 +326,7 @@ enum ieee80211_rssi_event { * your driver/device needs to do. * @ps: power-save mode (STA only). This flag is NOT affected by * offchannel/dynamic_ps operations. - * @ssid: The SSID of the current vif. Only valid in AP-mode. + * @ssid: The SSID of the current vif. Valid in AP and IBSS mode. * @ssid_len: Length of SSID given in @ssid. * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode. * @txpower: TX power in dBm -- cgit v1.2.3 From 1ce3e82b0eb472161313183be0033e46d5c4bbaf Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 1 Aug 2012 17:00:55 +0200 Subject: cfg80211: add ieee80211_operating_class_to_band This function converts a (global only!) operating class to an internal band identifier. This will be needed for extended channel switch support. Signed-off-by: Johannes Berg --- include/net/cfg80211.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/net') diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 57870b64697..dff96d8cafc 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4024,6 +4024,17 @@ bool cfg80211_reg_can_beacon(struct wiphy *wiphy, void cfg80211_ch_switch_notify(struct net_device *dev, struct cfg80211_chan_def *chandef); +/** + * ieee80211_operating_class_to_band - convert operating class to band + * + * @operating_class: the operating class to convert + * @band: band pointer to fill + * + * Returns %true if the conversion was successful, %false otherwise. + */ +bool ieee80211_operating_class_to_band(u8 operating_class, + enum ieee80211_band *band); + /* * cfg80211_tdls_oper_request - request userspace to perform TDLS operation * @dev: the device on which the operation is requested -- cgit v1.2.3 From 85220d71bf3ca1ba9129e0744247ae5f61bec559 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 25 Mar 2013 18:29:27 +0100 Subject: mac80211: support secondary channel offset in CSA Add support for the secondary channel offset IE in channel switch announcements. This is necessary for proper handling of CSA on HT access points. For this to work it is also necessary to convert everything here to use chandef structs instead of just channels. The driver updates aren't really correct though. In particular, the TI wl18xx driver update can't possibly be right since it just ignores the new channel width for lack of firmware API. Signed-off-by: Johannes Berg --- include/net/mac80211.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/net') diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 0dde213dd3b..9ff10b33b71 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1017,13 +1017,13 @@ struct ieee80211_conf { * the driver passed into mac80211. * @block_tx: Indicates whether transmission must be blocked before the * scheduled channel switch, as indicated by the AP. - * @channel: the new channel to switch to + * @chandef: the new channel to switch to * @count: the number of TBTT's until the channel switch event */ struct ieee80211_channel_switch { u64 timestamp; bool block_tx; - struct ieee80211_channel *channel; + struct cfg80211_chan_def chandef; u8 count; }; -- cgit v1.2.3 From 6bc8312f95f982c0a6f26e87d0a6c299a697ed53 Mon Sep 17 00:00:00 2001 From: Karl Beldan Date: Mon, 15 Apr 2013 17:09:29 +0200 Subject: mac80211: VHT off-by-one NSS The number of VHT spatial streams (NSS) is found in: - s8 ieee80211_tx_rate.rate.idx[6:4] (tx - filled by rate control) - u8 ieee80211_rx_status.vht_nss (rx - filled by driver) Tx discriminates valid rates indexes with the sign bit and encodes NSS starting from 0 to 7 (note this matches some hw encodings e.g IWLMVM). Rx does not have the same constraints, and encodes NSS starting from 1 to 8 (note this matches what wireshark expects in the radiotap header). To handle ieee80211_tx_rate.rate.idx[6:4] ieee80211_rate_set_vht() and ieee80211_rate_get_vht_nss() assume their nss parameter and return value respectively runs from 0 to 7. ATM, there are only 2 users of these: cfg.c:sta_set_rate_info_t() and iwlwifi/mvm/tx.c:iwl_mvm_hwrate_to_tx_control(), but both assume nss runs from 1 to 8. This patch fixes this inconsistency by making ieee80211_rate_set_vht() and ieee80211_rate_get_vht_nss() handle an nss running from 1 to 8. Signed-off-by: Karl Beldan Signed-off-by: Johannes Berg --- include/net/mac80211.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/net') diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 9ff10b33b71..bc5d8184c48 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -601,8 +601,8 @@ static inline void ieee80211_rate_set_vht(struct ieee80211_tx_rate *rate, u8 mcs, u8 nss) { WARN_ON(mcs & ~0xF); - WARN_ON(nss & ~0x7); - rate->idx = (nss << 4) | mcs; + WARN_ON((nss - 1) & ~0x7); + rate->idx = ((nss - 1) << 4) | mcs; } static inline u8 @@ -614,7 +614,7 @@ ieee80211_rate_get_vht_mcs(const struct ieee80211_tx_rate *rate) static inline u8 ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate) { - return rate->idx >> 4; + return (rate->idx >> 4) + 1; } /** -- cgit v1.2.3 From 2ffbe6d333664a089f17b13aa79eefe38f794bb7 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 16 Apr 2013 13:38:42 +0200 Subject: mac80211: fix and optimize MCS mask handling Currently the code always copies the configured MCS mask (even if it is set to default), but only uses it if legacy rates were also masked out. Fix this by adding a flag that tracks whether the configured MCS mask is set to default or not. Optimize the code further by storing a pointer to the configured rate mask in txrc instead of using memcpy. Signed-off-by: Felix Fietkau Signed-off-by: Johannes Berg --- include/net/mac80211.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/net') diff --git a/include/net/mac80211.h b/include/net/mac80211.h index bc5d8184c48..05dbb978850 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -4107,7 +4107,7 @@ void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn); * (deprecated; this will be removed once drivers get updated to use * rate_idx_mask) * @rate_idx_mask: user-requested (legacy) rate mask - * @rate_idx_mcs_mask: user-requested MCS rate mask + * @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use) * @bss: whether this frame is sent out in AP or IBSS mode */ struct ieee80211_tx_rate_control { @@ -4119,7 +4119,7 @@ struct ieee80211_tx_rate_control { bool rts, short_preamble; u8 max_rate_idx; u32 rate_idx_mask; - u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN]; + u8 *rate_idx_mcs_mask; bool bss; }; -- cgit v1.2.3 From 991fec091061b901e4fdcc8af4fd25d24a5a7bab Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 16 Apr 2013 13:38:43 +0200 Subject: mac80211: fix CTS protection handling The rates[0] CTS and RTS flags are only set after rate control has been called, so minstrel cannot use them to for setting the number of retries. This patch adds two new flags to explicitly indicate RTS/CTS use. Signed-off-by: Felix Fietkau Signed-off-by: Johannes Berg --- include/net/mac80211.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/net') diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 05dbb978850..4f693a5c54d 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -655,7 +655,9 @@ struct ieee80211_tx_info { struct ieee80211_tx_rate rates[ IEEE80211_TX_MAX_RATES]; s8 rts_cts_rate_idx; - /* 3 bytes free */ + u8 use_rts:1; + u8 use_cts_prot:1; + /* 2 bytes free */ }; /* only needed before rate control */ unsigned long jiffies; -- cgit v1.2.3 From 908f8d07e9774c2476e0683f6a0ce50562a2da45 Mon Sep 17 00:00:00 2001 From: Alexander Bondar Date: Sun, 7 Apr 2013 09:53:30 +0300 Subject: mac80211: indicate admission control in TX queue parameters Some driver implementations need to know whether mandatory admission control is required by the AP for some ACs. Add a parameter to the TX queue parameters indicating this. As there's currently no support for admission control in mac80211's AP implementation, it's only ever set for the client implementation. Signed-off-by: Alexander Bondar Signed-off-by: Johannes Berg --- include/net/mac80211.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/net') diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 4f693a5c54d..b77d57a070e 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -128,6 +128,7 @@ enum ieee80211_ac_numbers { * 2^n-1 in the range 1..32767] * @cw_max: maximum contention window [like @cw_min] * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled + * @acm: is mandatory admission control required for the access category * @uapsd: is U-APSD mode enabled for the queue */ struct ieee80211_tx_queue_params { @@ -135,6 +136,7 @@ struct ieee80211_tx_queue_params { u16 cw_min; u16 cw_max; u8 aifs; + bool acm; bool uapsd; }; -- cgit v1.2.3 From 5de17984898c5758fc6ebe08eccea9f4b6548914 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 18 Apr 2013 15:49:00 +0200 Subject: cfg80211: introduce critical protocol indication from user-space Some protocols need a more reliable connection to complete successful in reasonable time. This patch adds a user-space API to indicate the wireless driver that a critical protocol is about to commence and when it is done, using nl80211 primitives NL80211_CMD_CRIT_PROTOCOL_START and NL80211_CRIT_PROTOCOL_STOP. There can be only on critical protocol session started per registered cfg80211 device. The driver can support this by implementing the cfg80211 callbacks .crit_proto_start() and .crit_proto_stop(). Examples of protocols that can benefit from this are DHCP, EAPOL, APIPA. Exactly how the link can/should be made more reliable is up to the driver. Things to consider are avoid scanning, no multi-channel operations, and alter coexistence schemes. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: Johannes Berg --- include/net/cfg80211.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include/net') diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index dff96d8cafc..26b5b692c22 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -2002,6 +2002,12 @@ struct cfg80211_update_ft_ies_params { * @update_ft_ies: Provide updated Fast BSS Transition information to the * driver. If the SME is in the driver/firmware, this information can be * used in building Authentication and Reassociation Request frames. + * + * @crit_proto_start: Indicates a critical protocol needs more link reliability + * for a given duration (milliseconds). The protocol is provided so the + * driver can take the most appropriate actions. + * @crit_proto_stop: Indicates critical protocol no longer needs increased link + * reliability. This operation can not fail. */ struct cfg80211_ops { int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); @@ -2231,6 +2237,12 @@ struct cfg80211_ops { struct cfg80211_chan_def *chandef); int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie); + int (*crit_proto_start)(struct wiphy *wiphy, + struct wireless_dev *wdev, + enum nl80211_crit_proto_id protocol, + u16 duration); + void (*crit_proto_stop)(struct wiphy *wiphy, + struct wireless_dev *wdev); }; /* @@ -4137,6 +4149,17 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev, struct cfg80211_wowlan_wakeup *wakeup, gfp_t gfp); +/** + * cfg80211_crit_proto_stopped() - indicate critical protocol stopped by driver. + * + * @wdev: the wireless device for which critical protocol is stopped. + * + * This function can be called by the driver to indicate it has reverted + * operation back to normal. One reason could be that the duration given + * by .crit_proto_start() has expired. + */ +void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp); + /* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */ -- cgit v1.2.3 From 0d528d85c519b755b6f4e1bafa3a39984370e1c1 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 22 Apr 2013 16:14:41 +0200 Subject: mac80211: improve the rate control API Allow rate control modules to pass a rate selection table to mac80211 and the driver. This allows drivers to fetch the most recent rate selection from the sta pointer for already buffered frames. This allows rate control to respond faster to sudden link changes and it is also a step towards adding minstrel_ht support to drivers like iwlwifi. When a driver sets IEEE80211_HW_SUPPORTS_RC_TABLE, mac80211 will not fill info->control.rates with rates from the rate table (to preserve explicit overrides by the rate control module). The driver then explicitly calls ieee80211_get_tx_rates to merge overrides from info->control.rates with defaults from the sta rate table. Signed-off-by: Felix Fietkau Signed-off-by: Johannes Berg --- include/net/mac80211.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'include/net') diff --git a/include/net/mac80211.h b/include/net/mac80211.h index b77d57a070e..04c2d4670dc 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -563,6 +563,9 @@ enum mac80211_rate_control_flags { /* maximum number of rate stages */ #define IEEE80211_TX_MAX_RATES 4 +/* maximum number of rate table entries */ +#define IEEE80211_TX_RATE_TABLE_SIZE 4 + /** * struct ieee80211_tx_rate - rate selection/status * @@ -659,6 +662,8 @@ struct ieee80211_tx_info { s8 rts_cts_rate_idx; u8 use_rts:1; u8 use_cts_prot:1; + u8 short_preamble:1; + u8 skip_table:1; /* 2 bytes free */ }; /* only needed before rate control */ @@ -680,6 +685,8 @@ struct ieee80211_tx_info { struct { struct ieee80211_tx_rate driver_rates[ IEEE80211_TX_MAX_RATES]; + u8 pad[4]; + void *rate_driver_data[ IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)]; }; @@ -1224,6 +1231,24 @@ enum ieee80211_sta_rx_bandwidth { IEEE80211_STA_RX_BW_160, }; +/** + * struct ieee80211_sta_rates - station rate selection table + * + * @rcu_head: RCU head used for freeing the table on update + * @rates: transmit rates/flags to be used by default. + * Overriding entries per-packet is possible by using cb tx control. + */ +struct ieee80211_sta_rates { + struct rcu_head rcu_head; + struct { + s8 idx; + u8 count; + u8 count_cts; + u8 count_rts; + u16 flags; + } rate[IEEE80211_TX_RATE_TABLE_SIZE]; +}; + /** * struct ieee80211_sta - station table entry * @@ -1251,6 +1276,7 @@ enum ieee80211_sta_rx_bandwidth { * notifications and capabilities. The value is only valid after * the station moves to associated state. * @smps_mode: current SMPS mode (off, static or dynamic) + * @tx_rates: rate control selection table */ struct ieee80211_sta { u32 supp_rates[IEEE80211_NUM_BANDS]; @@ -1264,6 +1290,7 @@ struct ieee80211_sta { u8 rx_nss; enum ieee80211_sta_rx_bandwidth bandwidth; enum ieee80211_smps_mode smps_mode; + struct ieee80211_sta_rates __rcu *rates; /* must be last */ u8 drv_priv[0] __aligned(sizeof(void *)); @@ -1419,6 +1446,9 @@ struct ieee80211_tx_control { * for different virtual interfaces. See the doc section on HW queue * control for more details. * + * @IEEE80211_HW_SUPPORTS_RC_TABLE: The driver supports using a rate + * selection table provided by the rate control algorithm. + * * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any * P2P Interface. This will be honoured even if more than one interface * is supported. @@ -1451,6 +1481,7 @@ enum ieee80211_hw_flags { IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21, IEEE80211_HW_AP_LINK_PS = 1<<22, IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23, + IEEE80211_HW_SUPPORTS_RC_TABLE = 1<<24, IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25, IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26, }; @@ -3136,6 +3167,25 @@ static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta, void ieee80211_sta_set_buffered(struct ieee80211_sta *sta, u8 tid, bool buffered); +/** + * ieee80211_get_tx_rates - get the selected transmit rates for a packet + * + * Call this function in a driver with per-packet rate selection support + * to combine the rate info in the packet tx info with the most recent + * rate selection table for the station entry. + * + * @vif: &struct ieee80211_vif pointer from the add_interface callback. + * @sta: the receiver station to which this packet is sent. + * @skb: the frame to be transmitted. + * @dest: buffer for extracted rate/retry information + * @max_rates: maximum number of rates to fetch + */ +void ieee80211_get_tx_rates(struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct sk_buff *skb, + struct ieee80211_tx_rate *dest, + int max_rates); + /** * ieee80211_tx_status - transmit status callback * @@ -4212,6 +4262,22 @@ bool rate_usable_index_exists(struct ieee80211_supported_band *sband, return false; } +/** + * rate_control_set_rates - pass the sta rate selection to mac80211/driver + * + * When not doing a rate control probe to test rates, rate control should pass + * its rate selection to mac80211. If the driver supports receiving a station + * rate table, it will use it to ensure that frames are always sent based on + * the most recent rate control module decision. + * + * @hw: pointer as obtained from ieee80211_alloc_hw() + * @pubsta: &struct ieee80211_sta pointer to the target destination. + * @rates: new tx rate set to be used for this station. + */ +int rate_control_set_rates(struct ieee80211_hw *hw, + struct ieee80211_sta *pubsta, + struct ieee80211_sta_rates *rates); + int ieee80211_rate_control_register(struct rate_control_ops *ops); void ieee80211_rate_control_unregister(struct rate_control_ops *ops); -- cgit v1.2.3