aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2015-03-27 16:30:37 -0400
committerJohannes Berg <johannes.berg@intel.com>2015-04-01 14:44:34 -0400
commitba8c3d6f16a1f9305c23ac1d2fd3992508c5ac03 (patch)
treec03bbdf0affccbd1f3a4fd0c239e59bb44f28e99 /include/net
parentcef2fc1ce4326f7f24c3cf938b94a661fbe773e3 (diff)
mac80211: add an intermediate software queue implementation
This allows drivers to request per-vif and per-sta-tid queues from which they can pull frames. This makes it easier to keep the hardware queues short, and to improve fairness between clients and vifs. The task of scheduling packet transmission is left up to the driver - queueing is controlled by mac80211. Drivers can only dequeue packets by calling ieee80211_tx_dequeue. This makes it possible to add active queue management later without changing drivers using this code. This can also be used as a starting point to implement A-MSDU aggregation in a way that does not add artificially induced latency. Signed-off-by: Felix Fietkau <nbd@openwrt.org> [resolved minor context conflict, minor changes, endian annotations] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/mac80211.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 201bc68e0cff..3578da96b41a 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -84,6 +84,39 @@
84 * 84 *
85 */ 85 */
86 86
87/**
88 * DOC: mac80211 software tx queueing
89 *
90 * mac80211 provides an optional intermediate queueing implementation designed
91 * to allow the driver to keep hardware queues short and provide some fairness
92 * between different stations/interfaces.
93 * In this model, the driver pulls data frames from the mac80211 queue instead
94 * of letting mac80211 push them via drv_tx().
95 * Other frames (e.g. control or management) are still pushed using drv_tx().
96 *
97 * Drivers indicate that they use this model by implementing the .wake_tx_queue
98 * driver operation.
99 *
100 * Intermediate queues (struct ieee80211_txq) are kept per-sta per-tid, with a
101 * single per-vif queue for multicast data frames.
102 *
103 * The driver is expected to initialize its private per-queue data for stations
104 * and interfaces in the .add_interface and .sta_add ops.
105 *
106 * The driver can't access the queue directly. To dequeue a frame, it calls
107 * ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a queue, it
108 * calls the .wake_tx_queue driver op.
109 *
110 * For AP powersave TIM handling, the driver only needs to indicate if it has
111 * buffered packets in the driver specific data structures by calling
112 * ieee80211_sta_set_buffered(). For frames buffered in the ieee80211_txq
113 * struct, mac80211 sets the appropriate TIM PVB bits and calls
114 * .release_buffered_frames().
115 * In that callback the driver is therefore expected to release its own
116 * buffered frames and afterwards also frames from the ieee80211_txq (obtained
117 * via the usual ieee80211_tx_dequeue).
118 */
119
87struct device; 120struct device;
88 121
89/** 122/**
@@ -1306,6 +1339,7 @@ enum ieee80211_vif_flags {
1306 * monitor interface (if that is requested.) 1339 * monitor interface (if that is requested.)
1307 * @drv_priv: data area for driver use, will always be aligned to 1340 * @drv_priv: data area for driver use, will always be aligned to
1308 * sizeof(void *). 1341 * sizeof(void *).
1342 * @txq: the multicast data TX queue (if driver uses the TXQ abstraction)
1309 */ 1343 */
1310struct ieee80211_vif { 1344struct ieee80211_vif {
1311 enum nl80211_iftype type; 1345 enum nl80211_iftype type;
@@ -1317,6 +1351,8 @@ struct ieee80211_vif {
1317 u8 cab_queue; 1351 u8 cab_queue;
1318 u8 hw_queue[IEEE80211_NUM_ACS]; 1352 u8 hw_queue[IEEE80211_NUM_ACS];
1319 1353
1354 struct ieee80211_txq *txq;
1355
1320 struct ieee80211_chanctx_conf __rcu *chanctx_conf; 1356 struct ieee80211_chanctx_conf __rcu *chanctx_conf;
1321 1357
1322 u32 driver_flags; 1358 u32 driver_flags;
@@ -1575,6 +1611,7 @@ struct ieee80211_sta_rates {
1575 * @tdls_initiator: indicates the STA is an initiator of the TDLS link. Only 1611 * @tdls_initiator: indicates the STA is an initiator of the TDLS link. Only
1576 * valid if the STA is a TDLS peer in the first place. 1612 * valid if the STA is a TDLS peer in the first place.
1577 * @mfp: indicates whether the STA uses management frame protection or not. 1613 * @mfp: indicates whether the STA uses management frame protection or not.
1614 * @txq: per-TID data TX queues (if driver uses the TXQ abstraction)
1578 */ 1615 */
1579struct ieee80211_sta { 1616struct ieee80211_sta {
1580 u32 supp_rates[IEEE80211_NUM_BANDS]; 1617 u32 supp_rates[IEEE80211_NUM_BANDS];
@@ -1593,6 +1630,8 @@ struct ieee80211_sta {
1593 bool tdls_initiator; 1630 bool tdls_initiator;
1594 bool mfp; 1631 bool mfp;
1595 1632
1633 struct ieee80211_txq *txq[IEEE80211_NUM_TIDS];
1634
1596 /* must be last */ 1635 /* must be last */
1597 u8 drv_priv[0] __aligned(sizeof(void *)); 1636 u8 drv_priv[0] __aligned(sizeof(void *));
1598}; 1637};
@@ -1621,6 +1660,27 @@ struct ieee80211_tx_control {
1621}; 1660};
1622 1661
1623/** 1662/**
1663 * struct ieee80211_txq - Software intermediate tx queue
1664 *
1665 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
1666 * @sta: station table entry, %NULL for per-vif queue
1667 * @tid: the TID for this queue (unused for per-vif queue)
1668 * @ac: the AC for this queue
1669 *
1670 * The driver can obtain packets from this queue by calling
1671 * ieee80211_tx_dequeue().
1672 */
1673struct ieee80211_txq {
1674 struct ieee80211_vif *vif;
1675 struct ieee80211_sta *sta;
1676 u8 tid;
1677 u8 ac;
1678
1679 /* must be last */
1680 u8 drv_priv[0] __aligned(sizeof(void *));
1681};
1682
1683/**
1624 * enum ieee80211_hw_flags - hardware flags 1684 * enum ieee80211_hw_flags - hardware flags
1625 * 1685 *
1626 * These flags are used to indicate hardware capabilities to 1686 * These flags are used to indicate hardware capabilities to
@@ -1844,6 +1904,8 @@ enum ieee80211_hw_flags {
1844 * within &struct ieee80211_sta. 1904 * within &struct ieee80211_sta.
1845 * @chanctx_data_size: size (in bytes) of the drv_priv data area 1905 * @chanctx_data_size: size (in bytes) of the drv_priv data area
1846 * within &struct ieee80211_chanctx_conf. 1906 * within &struct ieee80211_chanctx_conf.
1907 * @txq_data_size: size (in bytes) of the drv_priv data area
1908 * within @struct ieee80211_txq.
1847 * 1909 *
1848 * @max_rates: maximum number of alternate rate retry stages the hw 1910 * @max_rates: maximum number of alternate rate retry stages the hw
1849 * can handle. 1911 * can handle.
@@ -1892,6 +1954,9 @@ enum ieee80211_hw_flags {
1892 * @n_cipher_schemes: a size of an array of cipher schemes definitions. 1954 * @n_cipher_schemes: a size of an array of cipher schemes definitions.
1893 * @cipher_schemes: a pointer to an array of cipher scheme definitions 1955 * @cipher_schemes: a pointer to an array of cipher scheme definitions
1894 * supported by HW. 1956 * supported by HW.
1957 *
1958 * @txq_ac_max_pending: maximum number of frames per AC pending in all txq
1959 * entries for a vif.
1895 */ 1960 */
1896struct ieee80211_hw { 1961struct ieee80211_hw {
1897 struct ieee80211_conf conf; 1962 struct ieee80211_conf conf;
@@ -1904,6 +1969,7 @@ struct ieee80211_hw {
1904 int vif_data_size; 1969 int vif_data_size;
1905 int sta_data_size; 1970 int sta_data_size;
1906 int chanctx_data_size; 1971 int chanctx_data_size;
1972 int txq_data_size;
1907 u16 queues; 1973 u16 queues;
1908 u16 max_listen_interval; 1974 u16 max_listen_interval;
1909 s8 max_signal; 1975 s8 max_signal;
@@ -1920,6 +1986,7 @@ struct ieee80211_hw {
1920 u8 uapsd_max_sp_len; 1986 u8 uapsd_max_sp_len;
1921 u8 n_cipher_schemes; 1987 u8 n_cipher_schemes;
1922 const struct ieee80211_cipher_scheme *cipher_schemes; 1988 const struct ieee80211_cipher_scheme *cipher_schemes;
1989 int txq_ac_max_pending;
1923}; 1990};
1924 1991
1925/** 1992/**
@@ -3082,6 +3149,8 @@ enum ieee80211_reconfig_type {
3082 * response template is provided, together with the location of the 3149 * response template is provided, together with the location of the
3083 * switch-timing IE within the template. The skb can only be used within 3150 * switch-timing IE within the template. The skb can only be used within
3084 * the function call. 3151 * the function call.
3152 *
3153 * @wake_tx_queue: Called when new packets have been added to the queue.
3085 */ 3154 */
3086struct ieee80211_ops { 3155struct ieee80211_ops {
3087 void (*tx)(struct ieee80211_hw *hw, 3156 void (*tx)(struct ieee80211_hw *hw,
@@ -3313,6 +3382,9 @@ struct ieee80211_ops {
3313 void (*tdls_recv_channel_switch)(struct ieee80211_hw *hw, 3382 void (*tdls_recv_channel_switch)(struct ieee80211_hw *hw,
3314 struct ieee80211_vif *vif, 3383 struct ieee80211_vif *vif,
3315 struct ieee80211_tdls_ch_sw_params *params); 3384 struct ieee80211_tdls_ch_sw_params *params);
3385
3386 void (*wake_tx_queue)(struct ieee80211_hw *hw,
3387 struct ieee80211_txq *txq);
3316}; 3388};
3317 3389
3318/** 3390/**
@@ -5334,4 +5406,15 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
5334 */ 5406 */
5335size_t ieee80211_ie_split(const u8 *ies, size_t ielen, 5407size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
5336 const u8 *ids, int n_ids, size_t offset); 5408 const u8 *ids, int n_ids, size_t offset);
5409
5410/**
5411 * ieee80211_tx_dequeue - dequeue a packet from a software tx queue
5412 *
5413 * @hw: pointer as obtained from ieee80211_alloc_hw()
5414 * @txq: pointer obtained from station or virtual interface
5415 *
5416 * Returns the skb if successful, %NULL if no frame was available.
5417 */
5418struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
5419 struct ieee80211_txq *txq);
5337#endif /* MAC80211_H */ 5420#endif /* MAC80211_H */