add performance improvement for madwifi on low-memory systems
[openwrt/svn-archive/archive.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 02:56:31.000000000 +0200
4 +++ madwifi-trunk-r3314/ath/if_ath.c 2008-04-17 03:20: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 02:56:30.000000000 +0200
52 +++ madwifi-trunk-r3314/net80211/ieee80211_output.c 2008-04-17 04:29:06.000000000 +0200
53 @@ -615,100 +615,45 @@
54 skb = skb_unshare(skb, GFP_ATOMIC);
55 }
56
57 -#ifdef ATH_SUPERG_FF
58 - if (isff) {
59 - if (skb == NULL) {
60 + if (skb_cloned(skb) ||
61 + (need_headroom > skb_headroom(skb)) ||
62 + (!isff && (need_tailroom > skb_tailroom(skb)))) {
63 +
64 + if (pskb_expand_head(skb, need_headroom, need_tailroom, GFP_ATOMIC)) {
65 IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
66 - "%s: cannot unshare for encapsulation\n",
67 - __func__);
68 + "%s: cannot expand storage (tail)\n", __func__);
69 vap->iv_stats.is_tx_nobuf++;
70 - ieee80211_dev_kfree_skb(&skb2);
71 -
72 + ieee80211_dev_kfree_skb(&skb);
73 return NULL;
74 }
75 + }
76
77 - /* first skb header */
78 - if (skb_headroom(skb) < need_headroom) {
79 - struct sk_buff *tmp = skb;
80 - skb = skb_realloc_headroom(skb, need_headroom);
81 - if (skb == NULL) {
82 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
83 - "%s: cannot expand storage (head1)\n",
84 - __func__);
85 - vap->iv_stats.is_tx_nobuf++;
86 - ieee80211_dev_kfree_skb(&skb2);
87 - return NULL;
88 - } else
89 - ieee80211_skb_copy_noderef(tmp, skb);
90 - ieee80211_dev_kfree_skb(&tmp);
91 - /* NB: cb[] area was copied, but not next ptr. must do that
92 - * prior to return on success. */
93 +#ifdef ATH_SUPERG_FF
94 + if (isff) {
95 + if (skb_shared(skb2)) {
96 + /* Take our own reference to the node in the clone */
97 + ieee80211_ref_node(SKB_CB(skb2)->ni);
98 + /* Unshare the node, decrementing users in the old skb */
99 + skb2 = skb_unshare(skb2, GFP_ATOMIC);
100 }
101
102 - /* second skb with header and tail adjustments possible */
103 - if (skb_tailroom(skb2) < need_tailroom) {
104 - int n = 0;
105 - if (inter_headroom > skb_headroom(skb2))
106 - n = inter_headroom - skb_headroom(skb2);
107 - if (pskb_expand_head(skb2, n,
108 - need_tailroom - skb_tailroom(skb2), GFP_ATOMIC)) {
109 - ieee80211_dev_kfree_skb(&skb2);
110 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
111 - "%s: cannot expand storage (tail2)\n",
112 - __func__);
113 - vap->iv_stats.is_tx_nobuf++;
114 - /* this shouldn't happen, but don't send first ff either */
115 - ieee80211_dev_kfree_skb(&skb);
116 - }
117 - } else if (skb_headroom(skb2) < inter_headroom) {
118 - struct sk_buff *tmp = skb2;
119 + if ((skb_cloned(skb2) ||
120 + (inter_headroom > skb_headroom(skb2)) ||
121 + (need_tailroom > skb_tailroom(skb2)))) {
122
123 - skb2 = skb_realloc_headroom(skb2, inter_headroom);
124 - if (skb2 == NULL) {
125 + if (pskb_expand_head(skb2, inter_headroom,
126 + need_tailroom, GFP_ATOMIC)) {
127 IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
128 - "%s: cannot expand storage (head2)\n",
129 - __func__);
130 + "%s: cannot expand storage (tail)\n", __func__);
131 vap->iv_stats.is_tx_nobuf++;
132 - /* this shouldn't happen, but don't send first ff either */
133 ieee80211_dev_kfree_skb(&skb);
134 - skb = NULL;
135 - } else
136 - ieee80211_skb_copy_noderef(tmp, skb);
137 - ieee80211_dev_kfree_skb(&tmp);
138 - }
139 - if (skb) {
140 - skb->next = skb2;
141 + ieee80211_dev_kfree_skb(&skb2);
142 + return NULL;
143 + }
144 }
145 - return skb;
146 + skb->next = skb2;
147 }
148 #endif /* ATH_SUPERG_FF */
149 - if (skb == NULL) {
150 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
151 - "%s: cannot unshare for encapsulation\n", __func__);
152 - vap->iv_stats.is_tx_nobuf++;
153 - } else if (skb_tailroom(skb) < need_tailroom) {
154 - int n = 0;
155 - if (need_headroom > skb_headroom(skb))
156 - n = need_headroom - skb_headroom(skb);
157 - if (pskb_expand_head(skb, n, need_tailroom -
158 - skb_tailroom(skb), GFP_ATOMIC)) {
159 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
160 - "%s: cannot expand storage (tail)\n", __func__);
161 - vap->iv_stats.is_tx_nobuf++;
162 - ieee80211_dev_kfree_skb(&skb);
163 - }
164 - } else if (skb_headroom(skb) < need_headroom) {
165 - struct sk_buff *tmp = skb;
166 - skb = skb_realloc_headroom(skb, need_headroom);
167 - /* Increment reference count after copy */
168 - if (skb == NULL) {
169 - IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
170 - "%s: cannot expand storage (head)\n", __func__);
171 - vap->iv_stats.is_tx_nobuf++;
172 - } else
173 - ieee80211_skb_copy_noderef(tmp, skb);
174 - ieee80211_dev_kfree_skb(&tmp);
175 - }
176
177 return skb;
178 }