add function names to quilt-generated patch files to make patches more readable
[openwrt/staging/chunkeey.git] / package / mac80211 / patches / 210-mrr.patch
1 This patch adjusts the rate control API to allow multi-rate retry
2 if supported by the driver. The ieee80211_hw struct specifies how
3 many alternate rate selections the driver supports.
4
5 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
6
7 --- a/include/net/mac80211.h
8 +++ b/include/net/mac80211.h
9 @@ -292,6 +292,20 @@
10 #define IEEE80211_TX_INFO_DRIVER_DATA_PTRS \
11 (IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *))
12
13 +/* maximum number of alternate rate retry stages */
14 +#define IEEE80211_TX_MAX_ALTRATE 3
15 +
16 +/**
17 + * struct ieee80211_tx_altrate - alternate rate selection/status
18 + *
19 + * @rate_idx: rate index to attempt to send with
20 + * @limit: number of retries before fallback
21 + */
22 +struct ieee80211_tx_altrate {
23 + s8 rate_idx;
24 + u8 limit;
25 +};
26 +
27 /**
28 * struct ieee80211_tx_info - skb transmit information
29 *
30 @@ -335,12 +349,14 @@
31 struct ieee80211_key_conf *hw_key;
32 struct ieee80211_sta *sta;
33 unsigned long jiffies;
34 - s8 rts_cts_rate_idx, alt_retry_rate_idx;
35 + s8 rts_cts_rate_idx;
36 u8 retry_limit;
37 + struct ieee80211_tx_altrate retries[IEEE80211_TX_MAX_ALTRATE];
38 } control;
39 struct {
40 u64 ampdu_ack_map;
41 int ack_signal;
42 + struct ieee80211_tx_altrate retries[IEEE80211_TX_MAX_ALTRATE + 1];
43 u8 retry_count;
44 bool excessive_retries;
45 u8 ampdu_ack_len;
46 @@ -828,6 +844,9 @@
47 * within &struct ieee80211_vif.
48 * @sta_data_size: size (in bytes) of the drv_priv data area
49 * within &struct ieee80211_sta.
50 + *
51 + * @max_altrates: maximum number of alternate rate retry stages
52 + * @max_altrate_tries: maximum number of tries for each stage
53 */
54 struct ieee80211_hw {
55 struct ieee80211_conf conf;
56 @@ -844,6 +863,8 @@
57 u16 ampdu_queues;
58 u16 max_listen_interval;
59 s8 max_signal;
60 + u8 max_altrates;
61 + u8 max_altrate_tries;
62 };
63
64 struct ieee80211_hw *wiphy_to_hw(struct wiphy *wiphy);
65 @@ -900,11 +921,11 @@
66
67 static inline struct ieee80211_rate *
68 ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
69 - const struct ieee80211_tx_info *c)
70 + const struct ieee80211_tx_info *c, int idx)
71 {
72 - if (c->control.alt_retry_rate_idx < 0)
73 + if (c->control.retries[idx].rate_idx < 0)
74 return NULL;
75 - return &hw->wiphy->bands[c->band]->bitrates[c->control.alt_retry_rate_idx];
76 + return &hw->wiphy->bands[c->band]->bitrates[c->control.retries[idx].rate_idx];
77 }
78
79 /**
80 --- a/drivers/net/wireless/b43/xmit.c
81 +++ b/drivers/net/wireless/b43/xmit.c
82 @@ -208,7 +208,7 @@
83 txrate = ieee80211_get_tx_rate(dev->wl->hw, info);
84 rate = txrate ? txrate->hw_value : B43_CCK_RATE_1MB;
85 rate_ofdm = b43_is_ofdm_rate(rate);
86 - fbrate = ieee80211_get_alt_retry_rate(dev->wl->hw, info) ? : txrate;
87 + fbrate = ieee80211_get_alt_retry_rate(dev->wl->hw, info, 0) ? : txrate;
88 rate_fb = fbrate->hw_value;
89 rate_fb_ofdm = b43_is_ofdm_rate(rate_fb);
90
91 --- a/drivers/net/wireless/b43legacy/xmit.c
92 +++ b/drivers/net/wireless/b43legacy/xmit.c
93 @@ -210,7 +210,7 @@
94
95 rate = tx_rate->hw_value;
96 rate_ofdm = b43legacy_is_ofdm_rate(rate);
97 - rate_fb = ieee80211_get_alt_retry_rate(dev->wl->hw, info) ? : tx_rate;
98 + rate_fb = ieee80211_get_alt_retry_rate(dev->wl->hw, info, 0) ? : tx_rate;
99 rate_fb_ofdm = b43legacy_is_ofdm_rate(rate_fb->hw_value);
100
101 txhdr->mac_frame_ctl = wlhdr->frame_control;
102 --- a/drivers/net/wireless/rtl8180_dev.c
103 +++ b/drivers/net/wireless/rtl8180_dev.c
104 @@ -292,8 +292,8 @@
105 entry->plcp_len = cpu_to_le16(plcp_len);
106 entry->tx_buf = cpu_to_le32(mapping);
107 entry->frame_len = cpu_to_le32(skb->len);
108 - entry->flags2 = info->control.alt_retry_rate_idx >= 0 ?
109 - ieee80211_get_alt_retry_rate(dev, info)->bitrate << 4 : 0;
110 + entry->flags2 = info->control.retries[0].rate_idx >= 0 ?
111 + ieee80211_get_alt_retry_rate(dev, info, 0)->bitrate << 4 : 0;
112 entry->retry_limit = info->control.retry_limit;
113 entry->flags = cpu_to_le32(tx_flags);
114 __skb_queue_tail(&ring->queue, skb);
115 @@ -855,6 +855,7 @@
116 priv = dev->priv;
117 priv->pdev = pdev;
118
119 + dev->max_altrates = 1;
120 SET_IEEE80211_DEV(dev, &pdev->dev);
121 pci_set_drvdata(pdev, dev);
122
123 --- a/net/mac80211/tx.c
124 +++ b/net/mac80211/tx.c
125 @@ -454,15 +454,16 @@
126 if (unlikely(rsel.probe_idx >= 0)) {
127 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
128 tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG;
129 - info->control.alt_retry_rate_idx = tx->rate_idx;
130 + info->control.retries[0].rate_idx = tx->rate_idx;
131 + info->control.retries[0].limit = tx->local->hw.max_altrate_tries;
132 tx->rate_idx = rsel.probe_idx;
133 - } else
134 - info->control.alt_retry_rate_idx = -1;
135 + } else if (info->control.retries[0].limit == 0)
136 + info->control.retries[0].rate_idx = -1;
137
138 if (unlikely(tx->rate_idx < 0))
139 return TX_DROP;
140 } else
141 - info->control.alt_retry_rate_idx = -1;
142 + info->control.retries[0].rate_idx = -1;
143
144 if (tx->sdata->bss_conf.use_cts_prot &&
145 (tx->flags & IEEE80211_TX_FRAGMENTED) && (rsel.nonerp_idx >= 0)) {
146 @@ -521,7 +522,7 @@
147 * frames.
148 * TODO: The last fragment could still use multiple retry
149 * rates. */
150 - info->control.alt_retry_rate_idx = -1;
151 + info->control.retries[0].rate_idx = -1;
152 }
153
154 /* Use CTS protection for unicast frames sent using extended rates if
155 @@ -551,7 +552,7 @@
156 int idx;
157
158 /* Do not use multiple retry rates when using RTS/CTS */
159 - info->control.alt_retry_rate_idx = -1;
160 + info->control.retries[0].rate_idx = -1;
161
162 /* Use min(data rate, max base rate) as CTS/RTS rate */
163 rate = &sband->bitrates[tx->rate_idx];
164 --- a/drivers/net/wireless/b43/main.c
165 +++ b/drivers/net/wireless/b43/main.c
166 @@ -4588,6 +4588,7 @@
167 BIT(NL80211_IFTYPE_ADHOC);
168
169 hw->queues = b43_modparam_qos ? 4 : 1;
170 + hw->max_altrates = 1;
171 SET_IEEE80211_DEV(hw, dev->dev);
172 if (is_valid_ether_addr(sprom->et1mac))
173 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);
174 --- a/drivers/net/wireless/b43legacy/main.c
175 +++ b/drivers/net/wireless/b43legacy/main.c
176 @@ -3710,6 +3710,7 @@
177 BIT(NL80211_IFTYPE_WDS) |
178 BIT(NL80211_IFTYPE_ADHOC);
179 hw->queues = 1; /* FIXME: hardware has more queues */
180 + hw->max_altrates = 1;
181 SET_IEEE80211_DEV(hw, dev->dev);
182 if (is_valid_ether_addr(sprom->et1mac))
183 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);