0297e0cdfb215148410125578b886aa95a8086f8
[openwrt.git] / package / madwifi / patches / 350-performance.patch
1 Index: madwifi-trunk-r3314/ath/if_ath.c
2 ===================================================================
3 --- madwifi-trunk-r3314.orig/ath/if_ath.c       2008-04-17 18:17:28.000000000 +0200
4 +++ madwifi-trunk-r3314/ath/if_ath.c    2008-04-17 18:17:28.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-04-17 18:17:27.000000000 +0200
52 +++ madwifi-trunk-r3314/net80211/ieee80211_output.c     2008-04-17 18:18:04.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 @@ -615,100 +615,45 @@
63                 skb = skb_unshare(skb, GFP_ATOMIC);
64         }
65  
66 -#ifdef ATH_SUPERG_FF
67 -       if (isff) {
68 -               if (skb == NULL) {
69 +       if (skb_cloned(skb) ||
70 +               (need_headroom > skb_headroom(skb)) ||
71 +               (!isff && (need_tailroom > skb_tailroom(skb)))) {
72 +
73 +               if (pskb_expand_head(skb, need_headroom, need_tailroom, GFP_ATOMIC)) {
74                         IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
75 -                               "%s: cannot unshare for encapsulation\n",
76 -                               __func__);
77 +                               "%s: cannot expand storage (tail)\n", __func__);
78                         vap->iv_stats.is_tx_nobuf++;
79 -                       ieee80211_dev_kfree_skb(&skb2);
80 -
81 +                       ieee80211_dev_kfree_skb(&skb);
82                         return NULL;
83                 }
84 +       }
85  
86 -               /* first skb header */
87 -               if (skb_headroom(skb) < need_headroom) {
88 -                       struct sk_buff *tmp = skb;
89 -                       skb = skb_realloc_headroom(skb, need_headroom);
90 -                       if (skb == NULL) {
91 -                               IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
92 -                                       "%s: cannot expand storage (head1)\n",
93 -                                       __func__);
94 -                               vap->iv_stats.is_tx_nobuf++;
95 -                               ieee80211_dev_kfree_skb(&skb2);
96 -                               return NULL;
97 -                       } else
98 -                               ieee80211_skb_copy_noderef(tmp, skb);
99 -                       ieee80211_dev_kfree_skb(&tmp);
100 -                       /* NB: cb[] area was copied, but not next ptr. must do that
101 -                        *     prior to return on success. */
102 +#ifdef ATH_SUPERG_FF
103 +       if (isff) {
104 +               if (skb_shared(skb2)) {
105 +                       /* Take our own reference to the node in the clone */
106 +                       ieee80211_ref_node(SKB_CB(skb2)->ni);
107 +                       /* Unshare the node, decrementing users in the old skb */
108 +                       skb2 = skb_unshare(skb2, GFP_ATOMIC);
109                 }
110  
111 -               /* second skb with header and tail adjustments possible */
112 -               if (skb_tailroom(skb2) < need_tailroom) {
113 -                       int n = 0;
114 -                       if (inter_headroom > skb_headroom(skb2))
115 -                               n = inter_headroom - skb_headroom(skb2);
116 -                       if (pskb_expand_head(skb2, n,
117 -                           need_tailroom - skb_tailroom(skb2), GFP_ATOMIC)) {
118 -                               ieee80211_dev_kfree_skb(&skb2);
119 -                               IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
120 -                                       "%s: cannot expand storage (tail2)\n",
121 -                                       __func__);
122 -                               vap->iv_stats.is_tx_nobuf++;
123 -                               /* this shouldn't happen, but don't send first ff either */
124 -                               ieee80211_dev_kfree_skb(&skb);
125 -                       }
126 -               } else if (skb_headroom(skb2) < inter_headroom) {
127 -                       struct sk_buff *tmp = skb2;
128 +               if ((skb_cloned(skb2) ||
129 +                       (inter_headroom > skb_headroom(skb2)) ||
130 +                       (need_tailroom > skb_tailroom(skb2)))) {
131  
132 -                       skb2 = skb_realloc_headroom(skb2, inter_headroom);
133 -                       if (skb2 == NULL) {
134 +                       if (pskb_expand_head(skb2, inter_headroom,
135 +                               need_tailroom, GFP_ATOMIC)) {
136                                 IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
137 -                                       "%s: cannot expand storage (head2)\n",
138 -                                       __func__);
139 +                                       "%s: cannot expand storage (tail)\n", __func__);
140                                 vap->iv_stats.is_tx_nobuf++;
141 -                               /* this shouldn't happen, but don't send first ff either */
142                                 ieee80211_dev_kfree_skb(&skb);
143 -                               skb = NULL;
144 -                       } else
145 -                               ieee80211_skb_copy_noderef(tmp, skb);
146 -                       ieee80211_dev_kfree_skb(&tmp);
147 -               }
148 -               if (skb) {
149 -                       skb->next = skb2;
150 +                               ieee80211_dev_kfree_skb(&skb2);
151 +                               return NULL;
152 +                       }
153                 }
154 -               return skb;
155 +               skb->next = skb2;
156         }
157  #endif /* ATH_SUPERG_FF */
158 -       if (skb == NULL) {
159 -               IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
160 -                       "%s: cannot unshare for encapsulation\n", __func__);
161 -               vap->iv_stats.is_tx_nobuf++;
162 -       } else if (skb_tailroom(skb) < need_tailroom) {
163 -               int n = 0;
164 -               if (need_headroom > skb_headroom(skb))
165 -                       n = need_headroom - skb_headroom(skb);
166 -               if (pskb_expand_head(skb, n, need_tailroom - 
167 -                                       skb_tailroom(skb), GFP_ATOMIC)) {
168 -                       IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
169 -                               "%s: cannot expand storage (tail)\n", __func__);
170 -                       vap->iv_stats.is_tx_nobuf++;
171 -                       ieee80211_dev_kfree_skb(&skb);
172 -               }
173 -       } else if (skb_headroom(skb) < need_headroom) {
174 -               struct sk_buff *tmp = skb;
175 -               skb = skb_realloc_headroom(skb, need_headroom);
176 -               /* Increment reference count after copy */
177 -               if (skb == NULL) {
178 -                       IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
179 -                               "%s: cannot expand storage (head)\n", __func__);
180 -                       vap->iv_stats.is_tx_nobuf++;
181 -               } else
182 -                       ieee80211_skb_copy_noderef(tmp, skb);
183 -               ieee80211_dev_kfree_skb(&tmp);
184 -       }
185  
186         return skb;
187  }
188 Index: madwifi-trunk-r3314/net80211/ieee80211_input.c
189 ===================================================================
190 --- madwifi-trunk-r3314.orig/net80211/ieee80211_input.c 2008-04-17 18:17:28.000000000 +0200
191 +++ madwifi-trunk-r3314/net80211/ieee80211_input.c      2008-04-17 18:25:48.000000000 +0200
192 @@ -244,20 +244,6 @@
193                 vap->iv_stats.is_rx_tooshort++;
194                 goto out;
195         }
196 -       /* Clone the SKB... we assume somewhere in this driver that we 'own'
197 -        * the skbuff passed into hard start and we do a lot of messing with it
198 -        * but bridges under some cases will not clone for the first pass of skb
199 -        * to a bridge port, but will then clone for subsequent ones.  This is 
200 -        * odd behavior but it means that if we have trashed the skb we are given
201 -        * then other ports get clones of the residual garbage.
202 -        */
203 -       if ((skb2 = skb_copy(skb, GFP_ATOMIC)) == NULL) {
204 -               vap->iv_devstats.tx_dropped++;
205 -               goto out;
206 -       }
207 -       ieee80211_skb_copy_noderef(skb, skb2);
208 -       ieee80211_dev_kfree_skb(&skb);
209 -       skb = skb2;
210  
211         /*
212          * Bit of a cheat here, we use a pointer for a 3-address
213 @@ -738,7 +724,7 @@
214                         /* ether_type must be length as FF frames are always LLC/SNAP encap'd */ 
215                         frame_len = ntohs(eh_tmp->ether_type); 
216  
217 -                       skb1 = skb_copy(skb, GFP_ATOMIC);
218 +                       skb1 = skb_clone(skb, GFP_ATOMIC);
219                         if (skb1 == NULL)
220                                 goto err;
221                         ieee80211_skb_copy_noderef(skb, skb1);
222 @@ -1137,7 +1123,7 @@
223  
224                 if (ETHER_IS_MULTICAST(eh->ether_dhost) && !netif_queue_stopped(dev)) {
225                         /* Create a SKB for the BSS to send out. */
226 -                       skb1 = skb_copy(skb, GFP_ATOMIC);
227 +                       skb1 = skb_clone(skb, GFP_ATOMIC);
228                         if (skb1)
229                                 SKB_CB(skb1)->ni = ieee80211_ref_node(vap->iv_bss); 
230                 }