summaryrefslogtreecommitdiffstats
path: root/package/madwifi/patches/329-new_napi.patch
blob: 182d83d9ccc699360f6e2128392c56ca5c2b5f48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
Index: madwifi-trunk-r3314/ath/if_ath.c
===================================================================
--- madwifi-trunk-r3314.orig/ath/if_ath.c	2008-01-31 04:25:11.617671781 +0100
+++ madwifi-trunk-r3314/ath/if_ath.c	2008-01-31 05:06:04.606254148 +0100
@@ -184,7 +184,11 @@
 	struct sk_buff *, int, int, u_int64_t);
 static void ath_setdefantenna(struct ath_softc *, u_int);
 static struct ath_txq *ath_txq_setup(struct ath_softc *, int, int);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+static int ath_rx_poll(struct napi_struct *napi, int budget);
+#else
 static int ath_rx_poll(struct net_device *dev, int *budget);
+#endif
 static int ath_hardstart(struct sk_buff *, struct net_device *);
 static int ath_mgtstart(struct ieee80211com *, struct sk_buff *);
 #ifdef ATH_SUPERG_COMP
@@ -374,6 +378,9 @@
 		u_int32_t new_clamped_maxtxpower);
 static u_int32_t ath_get_real_maxtxpower(struct ath_softc *sc);
 
+static void ath_poll_disable(struct net_device *dev);
+static void ath_poll_enable(struct net_device *dev);
+
 /* calibrate every 30 secs in steady state but check every second at first. */
 static int ath_calinterval = ATH_SHORT_CALINTERVAL;
 static int ath_countrycode = CTRY_DEFAULT;	/* country code */
@@ -818,8 +825,12 @@
 	dev->set_mac_address = ath_set_mac_address;
 	dev->change_mtu = ath_change_mtu;
 	dev->tx_queue_len = ATH_TXBUF - ATH_TXBUF_MGT_RESERVED;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+	netif_napi_add(dev, &sc->sc_napi, ath_rx_poll, 64);
+#else
 	dev->poll = ath_rx_poll;
 	dev->weight = 64;
+#endif
 #ifdef USE_HEADERLEN_RESV
 	dev->hard_header_len += sizeof(struct ieee80211_qosframe) +
 				sizeof(struct llc) +
@@ -2268,12 +2279,21 @@
 		if (status & (HAL_INT_RX | HAL_INT_RXPHY)) {
 			ath_uapsd_processtriggers(sc, hw_tsf);
 			sc->sc_isr &= ~HAL_INT_RX;
-			if (netif_rx_schedule_prep(dev)) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+			if (netif_rx_schedule_prep(dev, &sc->sc_napi))
+#else
+			if (netif_rx_schedule_prep(dev))
+#endif
+			{
 #ifndef ATH_PRECISE_TSF
 				sc->sc_imask &= ~HAL_INT_RX;
 				ath_hal_intrset(ah, sc->sc_imask);
 #endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+				__netif_rx_schedule(dev, &sc->sc_napi);
+#else
 				__netif_rx_schedule(dev);
+#endif
 			}
 		}
 		if (status & HAL_INT_TX) {
@@ -2557,6 +2577,9 @@
 		if (sc->sc_tx99 != NULL)
 			sc->sc_tx99->stop(sc->sc_tx99);
 #endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+		ath_poll_disable(dev);
+#endif
 		netif_stop_queue(dev);	/* XXX re-enabled by ath_newstate */
 		dev->flags &= ~IFF_RUNNING;	/* NB: avoid recursion */
 		ieee80211_stop_running(ic);	/* stop all VAPs */
@@ -4015,6 +4038,39 @@
 	return ath_keyset(sc, k, mac, vap->iv_bss);
 }
 
+static void ath_poll_disable(struct net_device *dev)
+{
+	struct ath_softc *sc = dev->priv;
+
+	/*
+	 * XXX Using in_softirq is not right since we might
+	 * be called from other soft irq contexts than
+	 * ath_rx_poll
+	 */
+	if (!in_softirq()) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+		napi_disable(&sc->sc_napi);
+#else
+		netif_poll_disable(dev);
+#endif
+	}
+}
+
+static void ath_poll_enable(struct net_device *dev)
+{
+	struct ath_softc *sc = dev->priv;
+
+	/* NB: see above */
+	if (!in_softirq()) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+		napi_enable(&sc->sc_napi);
+#else
+		netif_poll_enable(dev);
+#endif
+	}
+}
+
+
 /*
  * Block/unblock tx+rx processing while a key change is done.
  * We assume the caller serializes key management operations
@@ -4032,13 +4088,8 @@
 	 * When called from the rx tasklet we cannot use
 	 * tasklet_disable because it will block waiting
 	 * for us to complete execution.
-	 *
-	 * XXX Using in_softirq is not right since we might
-	 * be called from other soft irq contexts than
-	 * ath_rx_poll
 	 */
-	if (!in_softirq())
-		netif_poll_disable(dev);
+	ath_poll_disable(dev);
 	netif_stop_queue(dev);
 }
 
@@ -4050,8 +4101,7 @@
 
 	DPRINTF(sc, ATH_DEBUG_KEYCACHE, "End\n");
 	netif_wake_queue(dev);
-	if (!in_softirq())		/* NB: see above */
-		netif_poll_enable(dev);
+	ath_poll_enable(dev);
 }
 
 /*
@@ -6359,24 +6409,34 @@
 }
 
 static int
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+ath_rx_poll(struct napi_struct *napi, int budget)
+#else
 ath_rx_poll(struct net_device *dev, int *budget)
+#endif
 {
 #define	PA2DESC(_sc, _pa) \
 	((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
 		((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
-	struct ath_buf *bf;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+	struct ath_softc *sc = container_of(napi, struct ath_softc, sc_napi);
+	struct net_device *dev = sc->sc_dev;
+	u_int rx_limit = budget;
+#else
 	struct ath_softc *sc = dev->priv;
+	u_int rx_limit = dev->quota;
+#endif
 	struct ieee80211com *ic = &sc->sc_ic;
 	struct ath_hal *ah = sc ? sc->sc_ah : NULL;
 	struct ath_desc *ds;
 	struct ath_rx_status *rs;
 	struct sk_buff *skb = NULL;
 	struct ieee80211_node *ni;
+	struct ath_buf *bf;
 	unsigned int len;
 	int type;
 	u_int phyerr;
 	u_int processed = 0, early_stop = 0;
-	u_int rx_limit = dev->quota;
 	u_int mic_fail = 0;
 
 	DPRINTF(sc, ATH_DEBUG_RX_PROC, "invoked\n");
@@ -6405,7 +6465,9 @@
 			break;
 		}
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
 		processed++;
+#endif
 		if (rx_limit-- < 0) {
 			early_stop = 1;
 			break;
@@ -6675,8 +6737,6 @@
 			goto process_rx_again;
 		}
 #endif
-		netif_rx_complete(dev);
-
 #ifndef ATH_PRECISE_TSF
 		sc->sc_imask |= HAL_INT_RX;
 		ath_hal_intrset(ah, sc->sc_imask);
@@ -6684,11 +6744,17 @@
 #endif
 	}
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+	netif_rx_complete(dev, napi);
+#else
+	netif_rx_complete(dev);
 	*budget -= processed;
+#endif
 
 	/* rx signal state monitoring, only necessary/applicable for sta mode */
 	if (sc->sc_opmode == HAL_M_STA)
 		ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
+
 	return early_stop;
 #undef PA2DESC
 }
@@ -10395,9 +10461,9 @@
 	dev->mtu = mtu;
 	if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
 		/* NB: the rx buffers may need to be reallocated */
-		netif_poll_disable(dev);
+		ath_poll_disable(dev);
 		error = ath_reset(dev);
-		netif_poll_enable(dev);
+		ath_poll_enable(dev);
 	}
 	ATH_UNLOCK(sc);
 
Index: madwifi-trunk-r3314/ath/if_athvar.h
===================================================================
--- madwifi-trunk-r3314.orig/ath/if_athvar.h	2008-01-31 04:25:14.001807644 +0100
+++ madwifi-trunk-r3314/ath/if_athvar.h	2008-01-31 04:32:31.858759693 +0100
@@ -620,6 +620,9 @@
 struct ath_softc {
 	struct ieee80211com sc_ic;		/* NB: must be first */
 	struct net_device *sc_dev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+	struct napi_struct sc_napi;
+#endif
 	void __iomem *sc_iobase;		/* address of the device */
 	struct semaphore sc_lock;		/* dev-level lock */
 	struct net_device_stats	sc_devstats;	/* device statistics */