summaryrefslogtreecommitdiff
path: root/net-wireless/compat-wireless/files/super_secret_patch.diff
blob: bb9b58d5eea445cc1999de78e2b5ac4ee96ecbec (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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
From: Benoit Papillault <benoit.papillault@free.fr>
Date: Thu, 8 Apr 2010 21:53:39 +0000 (+0200)
Subject: ath5k & ath9k: Add the ability to disable physical & virtual carrier sense.
X-Git-Url: http://git.popipo.fr/?p=rt2x00.git;a=commitdiff_plain;h=6e617aef04e78aa09fdaf029ff2095bda8509606

ath5k & ath9k: Add the ability to disable physical & virtual carrier sense.

This patch adds 2 debugfs file in ath5k and ath9k debugfs directory, called :
- physical_carrier_sense : when set to 1, physical carrier sense is disabled.
- virtual_carrier_sense  : when set to 1, virtual carrier sense is disabled

Carrier sense settings are restored after a hardware reset.
---

diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index ac67f02..1f90dde 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -1135,6 +1135,10 @@ struct ath5k_hw {
 	/* Software interrupt mask */
 	u8			ah_swi_mask;
 
+	/* Saved values of physical & virtual carrier sense */
+	int saved_phy_cs;
+	int saved_virt_cs;
+
 	/*
 	 * Function pointers
 	 */
@@ -1310,6 +1314,11 @@ extern unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah);
 /* TX power setup */
 extern int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, u8 ee_mode, u8 txpower);
 extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower);
+/* physical & virtual carrier sense get/set methods */
+int ath5k_hw_get_phy_cs(struct ath5k_hw *ah);
+void ath5k_hw_set_phy_cs(struct ath5k_hw *ah, int val);
+int ath5k_hw_get_virt_cs(struct ath5k_hw *ah);
+void ath5k_hw_set_virt_cs(struct ath5k_hw *ah, int val);
 
 /*
  * Functions used internaly
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 747508c..246c62d 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -363,6 +363,90 @@ static const struct file_operations fops_debug = {
 	.owner = THIS_MODULE,
 };
 
+static ssize_t read_file_phy_cs(struct file *file, char __user *user_buf,
+				size_t count, loff_t *ppos)
+{
+	struct ath5k_softc *sc = file->private_data;
+	struct ath5k_hw *ah = sc->ah;
+	char buf[32];
+	unsigned int len;
+	int val;
+
+	val = ath5k_hw_get_phy_cs(ah);
+	len = snprintf(buf, sizeof(buf), "%d\n", val);
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_phy_cs(struct file *file, const char __user *user_buf,
+				 size_t count, loff_t *ppos)
+{
+	struct ath5k_softc *sc = file->private_data;
+	struct ath5k_hw *ah = sc->ah;
+	unsigned long val;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EINVAL;
+
+	buf[len] = '\0';
+	if (strict_strtoul(buf, 0, &val))
+		return -EINVAL;
+
+	ath5k_hw_set_phy_cs(ah, val);
+	return count;
+}
+
+static const struct file_operations fops_phy_cs = {
+	.read = read_file_phy_cs,
+	.write = write_file_phy_cs,
+	.open = ath5k_debugfs_open,
+	.owner = THIS_MODULE
+};
+
+static ssize_t read_file_virt_cs(struct file *file, char __user *user_buf,
+				 size_t count, loff_t *ppos)
+{
+	struct ath5k_softc *sc = file->private_data;
+	struct ath5k_hw *ah = sc->ah;
+	char buf[32];
+	unsigned int len;
+	int val;
+
+	val = ath5k_hw_get_virt_cs(ah);
+	len = snprintf(buf, sizeof(buf), "%d\n",val);
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_virt_cs(struct file *file, const char __user *user_buf,
+				 size_t count, loff_t *ppos)
+{
+	struct ath5k_softc *sc = file->private_data;
+	struct ath5k_hw *ah = sc->ah;
+	unsigned long val;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EINVAL;
+
+	buf[len] = '\0';
+	if (strict_strtoul(buf, 0, &val))
+		return -EINVAL;
+
+	ath5k_hw_set_virt_cs(ah, val);
+
+	return count;
+}
+
+static const struct file_operations fops_virt_cs = {
+	.read = read_file_virt_cs,
+	.write = write_file_virt_cs,
+	.open = ath5k_debugfs_open,
+	.owner = THIS_MODULE
+};
 
 /* init */
 
@@ -393,6 +477,14 @@ ath5k_debug_init_device(struct ath5k_softc *sc)
 
 	sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR,
 				sc->debug.debugfs_phydir, sc, &fops_reset);
+
+	sc->debug.debugfs_phy_cs = debugfs_create_file("physical_carrier_sense",
+				S_IRUSR|S_IWUSR,
+				sc->debug.debugfs_phydir, sc, &fops_phy_cs);
+
+	sc->debug.debugfs_virt_cs = debugfs_create_file("virtual_carrier_sense",
+				S_IRUSR|S_IWUSR,
+				sc->debug.debugfs_phydir, sc, &fops_virt_cs);
 }
 
 void
@@ -404,6 +496,8 @@ ath5k_debug_finish(void)
 void
 ath5k_debug_finish_device(struct ath5k_softc *sc)
 {
+	debugfs_remove(sc->debug.debugfs_virt_cs);
+	debugfs_remove(sc->debug.debugfs_phy_cs);
 	debugfs_remove(sc->debug.debugfs_debug);
 	debugfs_remove(sc->debug.debugfs_registers);
 	debugfs_remove(sc->debug.debugfs_beacon);
diff --git a/drivers/net/wireless/ath/ath5k/debug.h b/drivers/net/wireless/ath/ath5k/debug.h
index 66f69f0..070226c 100644
--- a/drivers/net/wireless/ath/ath5k/debug.h
+++ b/drivers/net/wireless/ath/ath5k/debug.h
@@ -74,6 +74,8 @@ struct ath5k_dbg_info {
 	struct dentry		*debugfs_registers;
 	struct dentry		*debugfs_beacon;
 	struct dentry		*debugfs_reset;
+	struct dentry		*debugfs_phy_cs;
+	struct dentry		*debugfs_virt_cs;
 };
 
 /**
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index eff3323..4604e8f 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -3145,3 +3145,41 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
 }
 
 #undef _ATH5K_PHY
+int ath5k_hw_get_phy_cs(struct ath5k_hw *ah)
+{
+	u32 regval;
+
+	regval = ath5k_hw_reg_read(ah, AR5K_DIAG_SW);
+	return !!(regval & AR5K_DIAG_SW_RX_CLEAR_HIGH);
+}
+
+void ath5k_hw_set_phy_cs(struct ath5k_hw *ah, int val)
+{
+	if (val)
+		AR5K_REG_ENABLE_BITS(ah, AR5K_DIAG_SW,
+				     AR5K_DIAG_SW_RX_CLEAR_HIGH);
+	else
+		AR5K_REG_DISABLE_BITS(ah, AR5K_DIAG_SW,
+				      AR5K_DIAG_SW_RX_CLEAR_HIGH);
+	ah->saved_phy_cs = val;
+}
+
+int ath5k_hw_get_virt_cs(struct ath5k_hw *ah)
+{
+	u32 regval; 
+
+	regval = ath5k_hw_reg_read(ah, AR5K_DIAG_SW);
+	return !!(regval & AR5K_DIAG_SW_IGNORE_CARR_SENSE);
+}
+
+void ath5k_hw_set_virt_cs(struct ath5k_hw *ah, int val)
+{
+	if (val)
+		AR5K_REG_ENABLE_BITS(ah, AR5K_DIAG_SW,
+				     AR5K_DIAG_SW_IGNORE_CARR_SENSE);
+	else
+		AR5K_REG_DISABLE_BITS(ah, AR5K_DIAG_SW,
+				      AR5K_DIAG_SW_IGNORE_CARR_SENSE);
+	ah->saved_virt_cs = val;
+}
+
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index cbf28e3..7d337f3 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -1386,6 +1386,9 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
 	 */
 	AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
 	ath5k_hw_reset_tsf(ah);
+
+	ath5k_hw_set_phy_cs(ah, ah->saved_phy_cs);
+	ath5k_hw_set_virt_cs(ah, ah->saved_virt_cs);
 	return 0;
 }
 
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 42d2a50..a65d9fc 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -699,6 +699,75 @@ static const struct file_operations fops_recv = {
 	.owner = THIS_MODULE
 };
 
+static ssize_t write_file_phy_cs(struct file *file, const char __user *user_buf,
+				 size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	unsigned long val;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EINVAL;
+
+	buf[len] = '\0';
+	if (strict_strtoul(buf, 0, &val))
+		return -EINVAL;
+
+	ath9k_hw_set_phy_cs(sc->sc_ah, val);
+
+	return count;
+}
+
+static const struct file_operations fops_phy_cs = {
+	.read = read_file_phy_cs,
+	.write = write_file_phy_cs,
+	.open = ath9k_debugfs_open,
+	.owner = THIS_MODULE
+};
+
+static ssize_t read_file_virt_cs(struct file *file, char __user *user_buf,
+				 size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	char buf[32];
+	unsigned int len;
+	int val;
+
+	val = ath9k_hw_get_virt_cs(sc->sc_ah);
+	len = snprintf(buf, sizeof(buf), "%d\n", val);
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_virt_cs(struct file *file, const char __user *user_buf,
+				 size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	unsigned long val;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EINVAL;
+
+	buf[len] = '\0';
+	if (strict_strtoul(buf, 0, &val))
+		return -EINVAL;
+
+	ath9k_hw_set_virt_cs(sc->sc_ah, val);
+
+	return count;
+}
+
+static const struct file_operations fops_virt_cs = {
+	.read = read_file_virt_cs,
+	.write = write_file_virt_cs,
+	.open = ath9k_debugfs_open,
+	.owner = THIS_MODULE
+};
+
 int ath9k_init_debug(struct ath_hw *ah)
 {
 	struct ath_common *common = ath9k_hw_common(ah);
@@ -758,6 +827,20 @@ int ath9k_init_debug(struct ath_hw *ah)
 	if (!sc->debug.debugfs_recv)
 		goto err;
 
+	sc->debug.debugfs_phy_cs = debugfs_create_file("physical_carrier_sense",
+						       S_IRUSR|S_IWUSR,
+						       sc->debug.debugfs_phy,
+						       sc, &fops_phy_cs);
+	if (!sc->debug.debugfs_phy_cs)
+		goto err;
+
+	sc->debug.debugfs_virt_cs = debugfs_create_file("virtual_carrier_sense",
+							S_IRUSR|S_IWUSR,
+							sc->debug.debugfs_phy,
+							sc, &fops_virt_cs);
+	if (!sc->debug.debugfs_virt_cs)
+		goto err;
+
 	return 0;
 err:
 	ath9k_exit_debug(ah);
@@ -769,6 +852,8 @@ void ath9k_exit_debug(struct ath_hw *ah)
 	struct ath_common *common = ath9k_hw_common(ah);
 	struct ath_softc *sc = (struct ath_softc *) common->priv;
 
+	debugfs_remove(sc->debug.debugfs_virt_cs);
+	debugfs_remove(sc->debug.debugfs_phy_cs);
 	debugfs_remove(sc->debug.debugfs_recv);
 	debugfs_remove(sc->debug.debugfs_xmit);
 	debugfs_remove(sc->debug.debugfs_wiphy);
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index 86780e6..d86bbe5 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -156,6 +156,8 @@ struct ath9k_debug {
 	struct dentry *debugfs_wiphy;
 	struct dentry *debugfs_xmit;
 	struct dentry *debugfs_recv;
+	struct dentry *debugfs_phy_cs;
+	struct dentry *debugfs_virt_cs;
 	struct ath_stats stats;
 };
 
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 2e767cf..aef52aa 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -954,6 +954,10 @@ int ath9k_hw_init(struct ath_hw *ah)
 
 	common->state = ATH_HW_INITIALIZED;
 
+	/* Initially, physical and virtual carrier sense are enabled */
+	ah->saved_phy_cs = 0;
+	ah->saved_virt_cs = 0;
+
 	return 0;
 }
 
@@ -1913,6 +1917,44 @@ static void ath9k_enable_rfkill(struct ath_hw *ah)
 	REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB);
 }
 
+int ath9k_hw_get_phy_cs(struct ath_hw *ah)
+{
+	u32 regval;
+
+	regval = REG_READ(ah, AR_DIAG_SW);
+	return !!(regval & AR_DIAG_FORCE_RX_CLEAR);
+}
+EXPORT_SYMBOL(ath9k_hw_get_phy_cs);
+
+void ath9k_hw_set_phy_cs(struct ath_hw *ah, int val)
+{
+	if (val)
+		REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_RX_CLEAR);
+	else
+		REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_RX_CLEAR);
+	ah->saved_phy_cs = val;
+}
+EXPORT_SYMBOL(ath9k_hw_set_phy_cs);
+
+int ath9k_hw_get_virt_cs(struct ath_hw *ah)
+{
+	u32 regval;
+
+	regval = REG_READ(ah, AR_DIAG_SW);
+	return !!(regval & AR_DIAG_IGNORE_VIRT_CS);
+}
+EXPORT_SYMBOL(ath9k_hw_get_virt_cs);
+
+void ath9k_hw_set_virt_cs(struct ath_hw *ah, int val)
+{
+	if (val)
+		REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_IGNORE_VIRT_CS);
+	else
+		REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_IGNORE_VIRT_CS);
+	ah->saved_virt_cs = val;
+}
+EXPORT_SYMBOL(ath9k_hw_set_virt_cs);
+
 int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
 		    bool bChannelChange)
 {
@@ -2142,6 +2184,9 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
 	if (ah->btcoex_hw.enabled)
 		ath9k_hw_btcoex_enable(ah);
 
+	ath9k_hw_set_phy_cs(ah, ah->saved_phy_cs);
+	ath9k_hw_set_virt_cs(ah, ah->saved_virt_cs);
+
 	return 0;
 }
 EXPORT_SYMBOL(ath9k_hw_reset);
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index dbbf7ca..2c1dac4 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -602,6 +602,10 @@ struct ath_hw {
 	u32 intr_gen_timer_trigger;
 	u32 intr_gen_timer_thresh;
 	struct ath_gen_timer_table hw_gen_timers;
+
+	/* Saved values of physical & virtual carrier sense */
+	int saved_phy_cs;
+	int saved_virt_cs;
 };
 
 static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
@@ -618,6 +622,10 @@ static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah)
 const char *ath9k_hw_probe(u16 vendorid, u16 devid);
 void ath9k_hw_deinit(struct ath_hw *ah);
 int ath9k_hw_init(struct ath_hw *ah);
+int ath9k_hw_get_phy_cs(struct ath_hw *ah);
+void ath9k_hw_set_phy_cs(struct ath_hw *ah, int val);
+int ath9k_hw_get_virt_cs(struct ath_hw *ah);
+void ath9k_hw_set_virt_cs(struct ath_hw *ah, int val);
 int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
 		   bool bChannelChange);
 int ath9k_hw_fill_cap_info(struct ath_hw *ah);