54b30ac0058bf3499bfb3ab4ba6cb4ebd7ea3a01
[openwrt/svn-archive/archive.git] / package / madwifi / patches / 342-performance.patch
1 Index: madwifi-trunk-r3314/ath/if_ath.c
2 ===================================================================
3 --- madwifi-trunk-r3314.orig/ath/if_ath.c 2008-06-01 02:04:25.000000000 +0200
4 +++ madwifi-trunk-r3314/ath/if_ath.c 2008-06-01 02:04:25.000000000 +0200
5 @@ -3237,7 +3237,6 @@
6 struct ath_softc *sc = dev->priv;
7 struct ieee80211_node *ni = NULL;
8 struct ath_buf *bf = NULL;
9 - struct ether_header *eh;
10 ath_bufhead bf_head;
11 struct ath_buf *tbf, *tempbf;
12 struct sk_buff *tskb;
13 @@ -3249,6 +3248,7 @@
14 */
15 int requeue = 0;
16 #ifdef ATH_SUPERG_FF
17 + struct ether_header *eh;
18 unsigned int pktlen;
19 struct ieee80211com *ic = &sc->sc_ic;
20 struct ath_node *an;
21 @@ -3314,27 +3314,9 @@
22 requeue = 1;
23 goto hardstart_fail;
24 }
25 -#endif
26
27 - /* If the skb data is shared, we will copy it so we can strip padding
28 - * without affecting any other bridge ports. */
29 - if (skb_cloned(skb)) {
30 - /* Remember the original SKB so we can free up our references */
31 - struct sk_buff *skb_new;
32 - skb_new = skb_copy(skb, GFP_ATOMIC);
33 - if (skb_new == NULL) {
34 - DPRINTF(sc, ATH_DEBUG_XMIT,
35 - "Dropping; skb_copy failure.\n");
36 - /* No free RAM, do not requeue! */
37 - goto hardstart_fail;
38 - }
39 - ieee80211_skb_copy_noderef(skb, skb_new);
40 - ieee80211_dev_kfree_skb(&skb);
41 - skb = skb_new;
42 - }
43 eh = (struct ether_header *)skb->data;
44
45 -#ifdef ATH_SUPERG_FF
46 /* NB: use this lock to protect an->an_tx_ffbuf (and txq->axq_stageq)
47 * in athff_can_aggregate() call too. */
48 ATH_TXQ_LOCK_IRQ(txq);
49 Index: madwifi-trunk-r3314/net80211/ieee80211_output.c
50 ===================================================================
51 --- madwifi-trunk-r3314.orig/net80211/ieee80211_output.c 2008-06-01 02:04:24.000000000 +0200
52 +++ madwifi-trunk-r3314/net80211/ieee80211_output.c 2008-06-01 02:04:25.000000000 +0200
53 @@ -283,7 +283,7 @@
54 * normal vap. */
55 if (vap->iv_xrvap && (ni == vap->iv_bss) &&
56 vap->iv_xrvap->iv_sta_assoc) {
57 - struct sk_buff *skb1 = skb_copy(skb, GFP_ATOMIC);
58 + struct sk_buff *skb1 = skb_clone(skb, GFP_ATOMIC);
59 if (skb1) {
60 memset(SKB_CB(skb1), 0, sizeof(struct ieee80211_cb));
61 #ifdef IEEE80211_DEBUG_REFCNT
62 @@ -566,7 +566,7 @@
63 struct ieee80211_key *key, struct sk_buff *skb, int ismulticast)
64 {
65 /* XXX pre-calculate per node? */
66 - int need_headroom = LLC_SNAPFRAMELEN + hdrsize + IEEE80211_ADDR_LEN;
67 + int need_headroom = LLC_SNAPFRAMELEN + hdrsize;
68 int need_tailroom = 0;
69 #ifdef ATH_SUPERG_FF
70 int isff = ATH_FF_MAGIC_PRESENT(skb);
71 @@ -608,109 +608,56 @@
72 need_tailroom += cip->ic_miclen;
73 }
74
75 - if (skb_shared(skb)) {
76 - /* Take our own reference to the node in the clone */
77 - ieee80211_ref_node(SKB_CB(skb)->ni);
78 - /* Unshare the node, decrementing users in the old skb */
79 - skb = skb_unshare(skb, GFP_ATOMIC);
80 + need_headroom -= skb_headroom(skb);
81 + if (isff)
82 + need_tailroom -= skb_tailroom(skb2);
83 + else
84 + need_tailroom -= skb_tailroom(skb);
85 +
86 + if (need_headroom < 0)
87 + need_headroom = 0;
88 + if (need_tailroom < 0)
89 + need_tailroom = 0;
90 +
91 + if (skb_cloned(skb) || (need_headroom > 0) ||
92 + (!isff && (need_tailroom > 0))) {
93 +
94 + if (pskb_expand_head(skb, need_headroom, need_tailroom, GFP_ATOMIC)) {
95 + IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
96 + "%s: cannot expand storage (tail)\n", __func__);
97 + goto error;
98 + }
99 }
100
101 #ifdef ATH_SUPERG_FF
102 if (isff) {
103 - if (skb == NULL) {
104 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
105 - "%s: cannot unshare for encapsulation\n",
106 - __func__);
107 - vap->iv_stats.is_tx_nobuf++;
108 - ieee80211_dev_kfree_skb(&skb2);
109 -
110 - return NULL;
111 - }
112 + inter_headroom -= skb_headroom(skb2);
113 + if (inter_headroom < 0)
114 + inter_headroom = 0;
115 + if ((skb_cloned(skb2) ||
116 + (inter_headroom > 0) || (need_tailroom > 0))) {
117
118 - /* first skb header */
119 - if (skb_headroom(skb) < need_headroom) {
120 - struct sk_buff *tmp = skb;
121 - skb = skb_realloc_headroom(skb, need_headroom);
122 - if (skb == NULL) {
123 + if (pskb_expand_head(skb2, inter_headroom,
124 + need_tailroom, GFP_ATOMIC)) {
125 IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
126 - "%s: cannot expand storage (head1)\n",
127 - __func__);
128 - vap->iv_stats.is_tx_nobuf++;
129 - ieee80211_dev_kfree_skb(&skb2);
130 - return NULL;
131 - } else
132 - ieee80211_skb_copy_noderef(tmp, skb);
133 - ieee80211_dev_kfree_skb(&tmp);
134 - /* NB: cb[] area was copied, but not next ptr. must do that
135 - * prior to return on success. */
136 - }
137 -
138 - /* second skb with header and tail adjustments possible */
139 - if (skb_tailroom(skb2) < need_tailroom) {
140 - int n = 0;
141 - if (inter_headroom > skb_headroom(skb2))
142 - n = inter_headroom - skb_headroom(skb2);
143 - if (pskb_expand_head(skb2, n,
144 - need_tailroom - skb_tailroom(skb2), GFP_ATOMIC)) {
145 - ieee80211_dev_kfree_skb(&skb2);
146 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
147 - "%s: cannot expand storage (tail2)\n",
148 - __func__);
149 - vap->iv_stats.is_tx_nobuf++;
150 - /* this shouldn't happen, but don't send first ff either */
151 - ieee80211_dev_kfree_skb(&skb);
152 + "%s: cannot expand storage (tail)\n", __func__);
153 + goto error;
154 }
155 - } else if (skb_headroom(skb2) < inter_headroom) {
156 - struct sk_buff *tmp = skb2;
157 -
158 - skb2 = skb_realloc_headroom(skb2, inter_headroom);
159 - if (skb2 == NULL) {
160 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
161 - "%s: cannot expand storage (head2)\n",
162 - __func__);
163 - vap->iv_stats.is_tx_nobuf++;
164 - /* this shouldn't happen, but don't send first ff either */
165 - ieee80211_dev_kfree_skb(&skb);
166 - skb = NULL;
167 - } else
168 - ieee80211_skb_copy_noderef(tmp, skb);
169 - ieee80211_dev_kfree_skb(&tmp);
170 }
171 - if (skb) {
172 - skb->next = skb2;
173 - }
174 - return skb;
175 + skb->next = skb2;
176 }
177 #endif /* ATH_SUPERG_FF */
178 - if (skb == NULL) {
179 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
180 - "%s: cannot unshare for encapsulation\n", __func__);
181 - vap->iv_stats.is_tx_nobuf++;
182 - } else if (skb_tailroom(skb) < need_tailroom) {
183 - int n = 0;
184 - if (need_headroom > skb_headroom(skb))
185 - n = need_headroom - skb_headroom(skb);
186 - if (pskb_expand_head(skb, n, need_tailroom -
187 - skb_tailroom(skb), GFP_ATOMIC)) {
188 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
189 - "%s: cannot expand storage (tail)\n", __func__);
190 - vap->iv_stats.is_tx_nobuf++;
191 - ieee80211_dev_kfree_skb(&skb);
192 - }
193 - } else if (skb_headroom(skb) < need_headroom) {
194 - struct sk_buff *tmp = skb;
195 - skb = skb_realloc_headroom(skb, need_headroom);
196 - /* Increment reference count after copy */
197 - if (skb == NULL) {
198 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
199 - "%s: cannot expand storage (head)\n", __func__);
200 - vap->iv_stats.is_tx_nobuf++;
201 - } else
202 - ieee80211_skb_copy_noderef(tmp, skb);
203 - ieee80211_dev_kfree_skb(&tmp);
204 - }
205
206 return skb;
207 +
208 +error:
209 + vap->iv_stats.is_tx_nobuf++;
210 + ieee80211_dev_kfree_skb(&skb);
211 +#ifdef ATH_SUPERG_FF
212 + if (skb2)
213 + ieee80211_dev_kfree_skb(&skb2);
214 +#endif
215 + return NULL;
216 }
217
218 #define KEY_UNDEFINED(k) ((k).wk_cipher == &ieee80211_cipher_none)
219 Index: madwifi-trunk-r3314/net80211/ieee80211_input.c
220 ===================================================================
221 --- madwifi-trunk-r3314.orig/net80211/ieee80211_input.c 2008-06-01 02:04:25.000000000 +0200
222 +++ madwifi-trunk-r3314/net80211/ieee80211_input.c 2008-06-01 02:04:33.000000000 +0200
223 @@ -204,7 +204,6 @@
224 struct ieee80211_frame *wh;
225 struct ieee80211_key *key;
226 struct ether_header *eh;
227 - struct sk_buff *skb2;
228 #ifdef ATH_SUPERG_FF
229 struct llc *llc;
230 #endif
231 @@ -244,20 +243,6 @@
232 vap->iv_stats.is_rx_tooshort++;
233 goto out;
234 }
235 - /* Clone the SKB... we assume somewhere in this driver that we 'own'
236 - * the skbuff passed into hard start and we do a lot of messing with it
237 - * but bridges under some cases will not clone for the first pass of skb
238 - * to a bridge port, but will then clone for subsequent ones. This is
239 - * odd behavior but it means that if we have trashed the skb we are given
240 - * then other ports get clones of the residual garbage.
241 - */
242 - if ((skb2 = skb_copy(skb, GFP_ATOMIC)) == NULL) {
243 - vap->iv_devstats.tx_dropped++;
244 - goto out;
245 - }
246 - ieee80211_skb_copy_noderef(skb, skb2);
247 - ieee80211_dev_kfree_skb(&skb);
248 - skb = skb2;
249
250 /*
251 * Bit of a cheat here, we use a pointer for a 3-address
252 @@ -738,7 +723,7 @@
253 /* ether_type must be length as FF frames are always LLC/SNAP encap'd */
254 frame_len = ntohs(eh_tmp->ether_type);
255
256 - skb1 = skb_copy(skb, GFP_ATOMIC);
257 + skb1 = skb_clone(skb, GFP_ATOMIC);
258 if (skb1 == NULL)
259 goto err;
260 ieee80211_skb_copy_noderef(skb, skb1);
261 @@ -1137,7 +1122,7 @@
262
263 if (ETHER_IS_MULTICAST(eh->ether_dhost) && !netif_queue_stopped(dev)) {
264 /* Create a SKB for the BSS to send out. */
265 - skb1 = skb_copy(skb, GFP_ATOMIC);
266 + skb1 = skb_clone(skb, GFP_ATOMIC);
267 if (skb1)
268 SKB_CB(skb1)->ni = ieee80211_ref_node(vap->iv_bss);
269 }