huge madwifi update (work in progress, disabled by default, compiles but breaks at...
[librecmc/librecmc.git] / package / madwifi / patches-r3776 / 309-performance.patch
1 Index: madwifi-trunk-r3776/ath/if_ath.c
2 ===================================================================
3 --- madwifi-trunk-r3776.orig/ath/if_ath.c       2008-07-17 02:23:00.000000000 +0200
4 +++ madwifi-trunk-r3776/ath/if_ath.c    2008-07-17 02:28:06.000000000 +0200
5 @@ -3334,7 +3334,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;
12         struct sk_buff *tskb;
13 @@ -3349,6 +3348,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_txq *txq = NULL;
21 Index: madwifi-trunk-r3776/net80211/ieee80211_output.c
22 ===================================================================
23 --- madwifi-trunk-r3776.orig/net80211/ieee80211_output.c        2008-07-17 00:21:29.000000000 +0200
24 +++ madwifi-trunk-r3776/net80211/ieee80211_output.c     2008-07-17 02:35:10.000000000 +0200
25 @@ -280,7 +280,7 @@
26          * normal vap. */
27         if (vap->iv_xrvap && (ni == vap->iv_bss) &&
28             vap->iv_xrvap->iv_sta_assoc) {
29 -               struct sk_buff *skb1 = skb_copy(skb, GFP_ATOMIC);
30 +               struct sk_buff *skb1 = skb_clone(skb, GFP_ATOMIC);
31                 if (skb1) {
32                         memset(SKB_CB(skb1), 0, sizeof(struct ieee80211_cb));
33  #ifdef IEEE80211_DEBUG_REFCNT
34 @@ -561,7 +561,7 @@
35         struct ieee80211_key *key, struct sk_buff *skb, int ismulticast)
36  {
37         /* XXX pre-calculate per node? */
38 -       int need_headroom = LLC_SNAPFRAMELEN + hdrsize + IEEE80211_ADDR_LEN;
39 +       int need_headroom = LLC_SNAPFRAMELEN + hdrsize;
40         int need_tailroom = 0;
41  #ifdef ATH_SUPERG_FF
42         int isff = ATH_FF_MAGIC_PRESENT(skb);
43 @@ -603,109 +603,56 @@
44                                 need_tailroom += cip->ic_miclen;
45         }
46  
47 -       if (skb_shared(skb)) {
48 -               /* Take our own reference to the node in the clone */
49 -               ieee80211_ref_node(SKB_NI(skb));
50 -               /* Unshare the node, decrementing users in the old skb */
51 -               skb = skb_unshare(skb, GFP_ATOMIC);
52 +       need_headroom -= skb_headroom(skb);
53 +       if (isff)
54 +               need_tailroom -= skb_tailroom(skb2);
55 +       else
56 +               need_tailroom -= skb_tailroom(skb);
57 +
58 +       if (need_headroom < 0)
59 +               need_headroom = 0;
60 +       if (need_tailroom < 0)
61 +               need_tailroom = 0;
62 +
63 +       if (skb_cloned(skb) || (need_headroom > 0) ||
64 +               (!isff && (need_tailroom > 0))) {
65 +
66 +               if (pskb_expand_head(skb, need_headroom, need_tailroom, GFP_ATOMIC)) {
67 +                       IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
68 +                               "%s: cannot expand storage (tail)\n", __func__);
69 +                       goto error;
70 +               }
71         }
72  
73  #ifdef ATH_SUPERG_FF
74         if (isff) {
75 -               if (skb == NULL) {
76 -                       IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
77 -                               "%s: cannot unshare for encapsulation\n",
78 -                               __func__);
79 -                       vap->iv_stats.is_tx_nobuf++;
80 -                       ieee80211_dev_kfree_skb(&skb2);
81 -
82 -                       return NULL;
83 -               }
84 +               inter_headroom -= skb_headroom(skb2);
85 +               if (inter_headroom < 0)
86 +                       inter_headroom = 0;
87 +               if ((skb_cloned(skb2) ||
88 +                       (inter_headroom > 0) || (need_tailroom > 0))) {
89  
90 -               /* first skb header */
91 -               if (skb_headroom(skb) < need_headroom) {
92 -                       struct sk_buff *tmp = skb;
93 -                       skb = skb_realloc_headroom(skb, need_headroom);
94 -                       if (skb == NULL) {
95 +                       if (pskb_expand_head(skb2, inter_headroom,
96 +                               need_tailroom, GFP_ATOMIC)) {
97                                 IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
98 -                                       "%s: cannot expand storage (head1)\n",
99 -                                       __func__);
100 -                               vap->iv_stats.is_tx_nobuf++;
101 -                               ieee80211_dev_kfree_skb(&skb2);
102 -                               return NULL;
103 -                       } else
104 -                               ieee80211_skb_copy_noderef(tmp, skb);
105 -                       ieee80211_dev_kfree_skb(&tmp);
106 -                       /* NB: cb[] area was copied, but not next ptr. must do that
107 -                        *     prior to return on success. */
108 -               }
109 -
110 -               /* second skb with header and tail adjustments possible */
111 -               if (skb_tailroom(skb2) < need_tailroom) {
112 -                       int n = 0;
113 -                       if (inter_headroom > skb_headroom(skb2))
114 -                               n = inter_headroom - skb_headroom(skb2);
115 -                       if (pskb_expand_head(skb2, n,
116 -                           need_tailroom - skb_tailroom(skb2), GFP_ATOMIC)) {
117 -                               ieee80211_dev_kfree_skb(&skb2);
118 -                               IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
119 -                                       "%s: cannot expand storage (tail2)\n",
120 -                                       __func__);
121 -                               vap->iv_stats.is_tx_nobuf++;
122 -                               /* this shouldn't happen, but don't send first ff either */
123 -                               ieee80211_dev_kfree_skb(&skb);
124 +                                       "%s: cannot expand storage (tail)\n", __func__);
125 +                               goto error;
126                         }
127 -               } else if (skb_headroom(skb2) < inter_headroom) {
128 -                       struct sk_buff *tmp = skb2;
129 -
130 -                       skb2 = skb_realloc_headroom(skb2, inter_headroom);
131 -                       if (skb2 == NULL) {
132 -                               IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
133 -                                       "%s: cannot expand storage (head2)\n",
134 -                                       __func__);
135 -                               vap->iv_stats.is_tx_nobuf++;
136 -                               /* this shouldn't happen, but don't send first ff either */
137 -                               ieee80211_dev_kfree_skb(&skb);
138 -                               skb = NULL;
139 -                       } else
140 -                               ieee80211_skb_copy_noderef(tmp, skb);
141 -                       ieee80211_dev_kfree_skb(&tmp);
142                 }
143 -               if (skb) {
144 -                       skb->next = skb2;
145 -               }
146 -               return skb;
147 +               skb->next = skb2;
148         }
149  #endif /* ATH_SUPERG_FF */
150 -       if (skb == NULL) {
151 -               IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
152 -                       "%s: cannot unshare for encapsulation\n", __func__);
153 -               vap->iv_stats.is_tx_nobuf++;
154 -       } else if (skb_tailroom(skb) < need_tailroom) {
155 -               int n = 0;
156 -               if (need_headroom > skb_headroom(skb))
157 -                       n = need_headroom - skb_headroom(skb);
158 -               if (pskb_expand_head(skb, n, need_tailroom - 
159 -                                       skb_tailroom(skb), GFP_ATOMIC)) {
160 -                       IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
161 -                               "%s: cannot expand storage (tail)\n", __func__);
162 -                       vap->iv_stats.is_tx_nobuf++;
163 -                       ieee80211_dev_kfree_skb(&skb);
164 -               }
165 -       } else if (skb_headroom(skb) < need_headroom) {
166 -               struct sk_buff *tmp = skb;
167 -               skb = skb_realloc_headroom(skb, need_headroom);
168 -               /* Increment reference count after copy */
169 -               if (skb == NULL) {
170 -                       IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
171 -                               "%s: cannot expand storage (head)\n", __func__);
172 -                       vap->iv_stats.is_tx_nobuf++;
173 -               } else
174 -                       ieee80211_skb_copy_noderef(tmp, skb);
175 -               ieee80211_dev_kfree_skb(&tmp);
176 -       }
177  
178         return skb;
179 +
180 +error:
181 +       vap->iv_stats.is_tx_nobuf++;
182 +       ieee80211_dev_kfree_skb(&skb);
183 +#ifdef ATH_SUPERG_FF
184 +       if (skb2)
185 +               ieee80211_dev_kfree_skb(&skb2);
186 +#endif
187 +       return NULL;
188  }
189  
190  #define        KEY_UNDEFINED(k)        ((k).wk_cipher == &ieee80211_cipher_none)
191 Index: madwifi-trunk-r3776/net80211/ieee80211_input.c
192 ===================================================================
193 --- madwifi-trunk-r3776.orig/net80211/ieee80211_input.c 2008-07-17 02:20:52.000000000 +0200
194 +++ madwifi-trunk-r3776/net80211/ieee80211_input.c      2008-07-17 02:30:28.000000000 +0200
195 @@ -713,7 +713,7 @@
196                         /* ether_type must be length as FF frames are always LLC/SNAP encap'd */ 
197                         frame_len = ntohs(eh_tmp->ether_type); 
198  
199 -                       skb1 = skb_copy(skb, GFP_ATOMIC);
200 +                       skb1 = skb_clone(skb, GFP_ATOMIC);
201                         if (skb1 == NULL)
202                                 goto err;
203                         ieee80211_skb_copy_noderef(skb, skb1);
204 @@ -1118,7 +1118,7 @@
205  
206                 if (ETHER_IS_MULTICAST(eh->ether_dhost) && !netif_queue_stopped(dev)) {
207                         /* Create a SKB for the BSS to send out. */
208 -                       skb1 = skb_copy(skb, GFP_ATOMIC);
209 +                       skb1 = skb_clone(skb, GFP_ATOMIC);
210                         if (skb1)
211                                 SKB_NI(skb1) = ieee80211_ref_node(vap->iv_bss); 
212                 }
213 @@ -2265,7 +2265,7 @@
214         if (filter_type && ((vap->app_filter & filter_type) == filter_type)) {
215                 struct sk_buff *skb1;
216  
217 -               skb1 = skb_copy(skb, GFP_ATOMIC);
218 +               skb1 = skb_clone(skb, GFP_ATOMIC);
219                 if (skb1 == NULL)
220                         return;
221                 /* We duplicate the reference after skb_copy */