-
Notifications
You must be signed in to change notification settings - Fork 0
/
athnusb2.patch
2194 lines (1986 loc) · 67.4 KB
/
athnusb2.patch
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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/sys/dev/cardbus/if_athn_cardbus.c b/sys/dev/cardbus/if_athn_cardbus.c
index bf97a520fd..a3eece51d1 100644
--- a/sys/dev/cardbus/if_athn_cardbus.c
+++ b/sys/dev/cardbus/if_athn_cardbus.c
@@ -49,6 +49,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_athn_cardbus.c,v 1.3 2022/09/25 17:33:19 thorpej
#include <net80211/ieee80211_radiotap.h>
#include <net80211/ieee80211_regdomain.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
@@ -132,7 +134,7 @@ athn_cardbus_attach(device_t parent, device_t self, void *aux)
{
struct athn_cardbus_softc *csc = device_private(self);
struct athn_softc *sc = &csc->csc_sc;
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = &sc->sc_real_ic;
struct cardbus_attach_args *ca = aux;
cardbus_devfunc_t ct = ca->ca_ct;
bus_addr_t base;
diff --git a/sys/dev/ic/arn5008.c b/sys/dev/ic/arn5008.c
index dcfc3524a3..841038df61 100644
--- a/sys/dev/ic/arn5008.c
+++ b/sys/dev/ic/arn5008.c
@@ -60,6 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: arn5008.c,v 1.19 2022/03/18 23:32:24 riastradh Exp $
#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
@@ -163,7 +165,7 @@ PUBLIC int
ar5008_attach(struct athn_softc *sc)
{
struct athn_ops *ops = &sc->sc_ops;
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct ar_base_eep_header *base;
uint8_t eep_ver, kc_entries_log;
int error;
@@ -728,7 +730,7 @@ ar5008_rx_radiotap(struct athn_softc *sc, struct mbuf *m,
struct ar_rx_desc *ds)
{
struct athn_rx_radiotap_header *tap = &sc->sc_rxtap;
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
uint64_t tsf;
uint32_t tstamp;
uint8_t rate;
@@ -788,7 +790,7 @@ ar5008_rx_radiotap(struct athn_softc *sc, struct mbuf *m,
static __inline int
ar5008_rx_process(struct athn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct athn_rxq *rxq = &sc->sc_rxq[0];
struct athn_rx_buf *bf, *nbf;
struct ar_rx_desc *ds;
@@ -1097,7 +1099,7 @@ ar5008_tx_intr(struct athn_softc *sc)
Static int
ar5008_swba_intr(struct athn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct athn_tx_buf *bf = sc->sc_bcnbuf;
struct ieee80211_frame *wh;
struct ieee80211vap *vap;
@@ -1756,7 +1758,7 @@ ar5008_synth_delay(struct athn_softc *sc)
uint32_t synth_delay;
synth_delay = MS(AR_READ(sc, AR_PHY_RX_DELAY), AR_PHY_RX_DELAY_DELAY);
- if (sc->sc_ic.ic_curmode == IEEE80211_MODE_11B)
+ if (sc->sc_ic->ic_curmode == IEEE80211_MODE_11B)
synth_delay = (synth_delay * 4) / 22;
else
synth_delay = synth_delay / 10; /* in 100ns steps */
diff --git a/sys/dev/ic/arn5416.c b/sys/dev/ic/arn5416.c
index 93b9de9b29..aac14cfd1f 100644
--- a/sys/dev/ic/arn5416.c
+++ b/sys/dev/ic/arn5416.c
@@ -60,6 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: arn5416.c,v 1.3 2022/09/25 18:43:32 thorpej Exp $");
#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
diff --git a/sys/dev/ic/arn9003.c b/sys/dev/ic/arn9003.c
index 7e5ed0fb0e..625feb9c4c 100644
--- a/sys/dev/ic/arn9003.c
+++ b/sys/dev/ic/arn9003.c
@@ -61,6 +61,8 @@ __KERNEL_RCSID(0, "$NetBSD: arn9003.c,v 1.15 2020/01/29 14:09:58 thorpej Exp $")
#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
#include <dev/ic/arn9003reg.h>
@@ -870,7 +872,7 @@ ar9003_rx_radiotap(struct athn_softc *sc, struct mbuf *m,
struct ar_rx_status *ds)
{
struct athn_rx_radiotap_header *tap = &sc->sc_rxtap;
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
uint64_t tsf;
uint32_t tstamp;
uint8_t rate;
@@ -927,7 +929,7 @@ ar9003_rx_radiotap(struct athn_softc *sc, struct mbuf *m,
Static int
ar9003_rx_process(struct athn_softc *sc, int qid)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct ifnet *ifp;
struct athn_rxq *rxq = &sc->sc_rxq[qid];
struct athn_rx_buf *bf;
@@ -1231,7 +1233,7 @@ ar9003_tx_intr(struct athn_softc *sc)
Static int
ar9003_swba_intr(struct athn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct athn_tx_buf *bf = sc->sc_bcnbuf;
struct ieee80211_frame *wh;
struct ieee80211vap *vap;
@@ -1924,7 +1926,7 @@ ar9003_synth_delay(struct athn_softc *sc)
uint32_t synth_delay;
synth_delay = MS(AR_READ(sc, AR_PHY_RX_DELAY), AR_PHY_RX_DELAY_DELAY);
- if (sc->sc_ic.ic_curmode == IEEE80211_MODE_11B)
+ if (sc->sc_ic->ic_curmode == IEEE80211_MODE_11B)
synth_delay = (synth_delay * 4) / 22;
else
synth_delay = synth_delay / 10; /* in 100ns steps */
@@ -2781,7 +2783,7 @@ Static int
ar9003_paprd_tx_tone(struct athn_softc *sc)
{
#define TONE_LEN 1800
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct ieee80211_frame *wh;
struct ieee80211_node *ni;
struct mbuf *m;
diff --git a/sys/dev/ic/arn9280.c b/sys/dev/ic/arn9280.c
index 11d3873e73..b0a83b737a 100644
--- a/sys/dev/ic/arn9280.c
+++ b/sys/dev/ic/arn9280.c
@@ -60,6 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: arn9280.c,v 1.3 2022/09/25 18:43:32 thorpej Exp $");
#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
diff --git a/sys/dev/ic/arn9285.c b/sys/dev/ic/arn9285.c
index 818cfcd90c..279942373a 100644
--- a/sys/dev/ic/arn9285.c
+++ b/sys/dev/ic/arn9285.c
@@ -64,6 +64,8 @@ __KERNEL_RCSID(0, "$NetBSD: arn9285.c,v 1.5 2022/09/25 18:43:32 thorpej Exp $");
#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
#include <dev/ic/arn9285.h>
diff --git a/sys/dev/ic/arn9287.c b/sys/dev/ic/arn9287.c
index af461d1228..33f8dbb717 100644
--- a/sys/dev/ic/arn9287.c
+++ b/sys/dev/ic/arn9287.c
@@ -60,6 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: arn9287.c,v 1.4 2022/09/25 18:43:32 thorpej Exp $");
#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
diff --git a/sys/dev/ic/arn9380.c b/sys/dev/ic/arn9380.c
index 80c23bd69b..ddea8e8c62 100644
--- a/sys/dev/ic/arn9380.c
+++ b/sys/dev/ic/arn9380.c
@@ -57,6 +57,8 @@ __KERNEL_RCSID(0, "$NetBSD: arn9380.c,v 1.4 2022/09/25 18:43:32 thorpej Exp $");
#include <net80211/ieee80211_radiotap.h>
#include <net80211/ieee80211_regdomain.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
@@ -131,7 +133,7 @@ ar9380_attach(struct athn_softc *sc)
Static void
ar9380_setup(struct athn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct ar9380_eeprom *eep = sc->sc_eep;
struct ar9380_base_eep_hdr *base = &eep->baseEepHeader;
uint8_t type;
diff --git a/sys/dev/ic/athn.c b/sys/dev/ic/athn.c
index ab033a665d..a8d150a32d 100644
--- a/sys/dev/ic/athn.c
+++ b/sys/dev/ic/athn.c
@@ -65,6 +65,8 @@ __KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.26 2022/03/18 23:32:24 riastradh Exp $");
#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
#include <dev/ic/arn5008.h>
@@ -154,9 +156,15 @@ struct athn_vap {
PUBLIC int
athn_attach(struct athn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic;
int error;
+ if (sc->sc_ic == NULL) {
+ ic = &sc->sc_real_ic;
+ sc->sc_ic = ic;
+ } else {
+ ic = sc->sc_ic;
+ }
ic->ic_softc = sc;
/* Read hardware revision. */
@@ -348,14 +356,17 @@ athn_attach(struct athn_softc *sc)
ieee80211_ifattach(ic);
- ic->ic_parent = athn_parent;
+ if (!(sc->sc_flags & ATHN_FLAG_USB))
+ ic->ic_parent = athn_parent;
ic->ic_node_alloc = athn_node_alloc;
ic->ic_newassoc = athn_newassoc;
ic->ic_getradiocaps = athn_get_radiocaps;
ic->ic_vap_create = athn_vap_create;
ic->ic_vap_delete = athn_vap_delete;
- ic->ic_transmit = athn_transmit;
- ic->ic_raw_xmit = sc->sc_ops.tx;
+ if (!(sc->sc_flags & ATHN_FLAG_USB)) {
+ ic->ic_transmit = athn_transmit;
+ ic->ic_raw_xmit = sc->sc_ops.tx;
+ }
ic->ic_update_mcast = athn_set_multi;
ic->ic_scan_start = athn_scan_start;
ic->ic_scan_end = athn_scan_end;
@@ -408,7 +419,7 @@ athn_detach(struct athn_softc *sc)
/* XXX How do we detach from bpf?
bpf_detach(if*p);
*/
- ieee80211_ifdetach(&sc->sc_ic);
+ ieee80211_ifdetach(sc->sc_ic);
/* XXX
if_detach(if*p);
*/
@@ -425,7 +436,7 @@ athn_detach(struct athn_softc *sc)
Static void
athn_get_chanlist(struct athn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
uint8_t chan;
size_t i;
@@ -453,7 +464,7 @@ athn_get_chanlist(struct athn_softc *sc)
PUBLIC void
athn_rx_start(struct athn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
uint32_t rfilt;
/* Setup Rx DMA descriptors. */
@@ -927,7 +938,7 @@ athn_set_chan(struct athn_softc *sc, struct ieee80211_channel *curchan,
ops->rf_bus_release(sc);
/* Write delta slope coeffs for modes where OFDM may be used. */
- if (sc->sc_ic.ic_curmode != IEEE80211_MODE_11B)
+ if (sc->sc_ic->ic_curmode != IEEE80211_MODE_11B)
ops->set_delta_slope(sc, curchan, extchan);
ops->spur_mitigate(sc, curchan, extchan);
@@ -1283,7 +1294,7 @@ athn_calib_to(void *arg)
{
struct athn_softc *sc = arg;
struct athn_ops *ops = &sc->sc_ops;
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
int s;
s = splnet();
@@ -1410,7 +1421,7 @@ athn_ani_ofdm_err_trigger(struct athn_softc *sc)
}
#ifndef IEEE80211_STA_ONLY
- if (sc->sc_ic.ic_opmode == IEEE80211_M_HOSTAP) {
+ if (sc->sc_ic->ic_opmode == IEEE80211_M_HOSTAP) {
if (ani->firstep_level < 2) {
ani->firstep_level++;
ops->set_firstep_level(sc, ani->firstep_level);
@@ -1446,7 +1457,7 @@ athn_ani_ofdm_err_trigger(struct athn_softc *sc)
ani->firstep_level++;
ops->set_firstep_level(sc, ani->firstep_level);
}
- } else if (sc->sc_ic.ic_curmode != IEEE80211_MODE_11A) {
+ } else if (sc->sc_ic->ic_curmode != IEEE80211_MODE_11A) {
/*
* Beacon RSSI is low, if in b/g mode, turn off OFDM weak
* signal detection and zero first step level to maximize
@@ -1480,7 +1491,7 @@ athn_ani_cck_err_trigger(struct athn_softc *sc)
}
#ifndef IEEE80211_STA_ONLY
- if (sc->sc_ic.ic_opmode == IEEE80211_M_HOSTAP) {
+ if (sc->sc_ic->ic_opmode == IEEE80211_M_HOSTAP) {
if (ani->firstep_level < 2) {
ani->firstep_level++;
ops->set_firstep_level(sc, ani->firstep_level);
@@ -1498,7 +1509,7 @@ athn_ani_cck_err_trigger(struct athn_softc *sc)
ani->firstep_level++;
ops->set_firstep_level(sc, ani->firstep_level);
}
- } else if (sc->sc_ic.ic_curmode != IEEE80211_MODE_11A) {
+ } else if (sc->sc_ic->ic_curmode != IEEE80211_MODE_11A) {
/*
* Beacon RSSI is low, zero first step level to maximize
* CCK sensitivity.
@@ -1520,7 +1531,7 @@ athn_ani_lower_immunity(struct athn_softc *sc)
int32_t rssi;
#ifndef IEEE80211_STA_ONLY
- if (sc->sc_ic.ic_opmode == IEEE80211_M_HOSTAP) {
+ if (sc->sc_ic->ic_opmode == IEEE80211_M_HOSTAP) {
if (ani->firstep_level > 0) {
ani->firstep_level--;
ops->set_firstep_level(sc, ani->firstep_level);
@@ -2058,7 +2069,7 @@ athn_set_opmode(struct athn_softc *sc)
{
uint32_t reg;
- switch (sc->sc_ic.ic_opmode) {
+ switch (sc->sc_ic->ic_opmode) {
#ifndef IEEE80211_STA_ONLY
case IEEE80211_M_HOSTAP:
reg = AR_READ(sc, AR_STA_ID1);
@@ -2173,7 +2184,7 @@ PUBLIC int
athn_hw_reset(struct athn_softc *sc, struct ieee80211_channel *curchan,
struct ieee80211_channel *extchan, int init)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct athn_ops *ops = &sc->sc_ops;
uint32_t reg, def_ant, sta_id1, cfg_led, tsflo, tsfhi;
int i, error;
@@ -2440,7 +2451,7 @@ athn_newassoc(struct ieee80211_node *ni, int isnew)
// athn_media_change(struct ifnet *i*fp)
// {
// struct athn_softc *sc = i*fp->if_softc;
-// struct ieee80211com *ic = &sc->sc_ic;
+// struct ieee80211com *ic = sc->sc_ic;
// uint8_t rate, ridx;
// int error;
@@ -2615,7 +2626,7 @@ athn_updateedca(struct ieee80211com *ic)
Static int
athn_clock_rate(struct athn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
int clockrate; /* MHz. */
if (ic->ic_curmode == IEEE80211_MODE_11A) {
@@ -2709,7 +2720,7 @@ athn_watchdog(void *arg)
/* see athn_init, no need to call athn_stop here */
/* athn_stop(ifp, 0); */
(void)athn_init(sc);
- ieee80211_stat_add(&sc->sc_ic.ic_oerrors, 1);
+ ieee80211_stat_add(&sc->sc_ic->ic_oerrors, 1);
return;
}
callout_schedule(&sc->sc_watchdog_to, hz);
@@ -2775,7 +2786,7 @@ athn_set_multi(struct ieee80211com *ic)
// athn_ioctl(struct ifnet *i*fp, u_long cmd, void *data)
// {
// struct athn_softc *sc = i*fp->if_softc;
-// struct ieee80211com *ic = &sc->sc_ic;
+// struct ieee80211com *ic = sc->sc_ic;
// int s, error = 0;
// s = splnet();
@@ -2847,7 +2858,7 @@ Static int
athn_init(struct athn_softc *sc)
{
struct athn_ops *ops = &sc->sc_ops;
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct ieee80211_channel *curchan, *extchan;
size_t i;
int error;
@@ -2956,7 +2967,7 @@ athn_init(struct athn_softc *sc)
PUBLIC void
athn_stop(struct athn_softc *sc, int disable)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = sc->sc_ic;
struct ieee80211vap *nvap;
int qid;
diff --git a/sys/dev/ic/athnvar.h b/sys/dev/ic/athnvar.h
index 1d589b155b..409c79e5b1 100644
--- a/sys/dev/ic/athnvar.h
+++ b/sys/dev/ic/athnvar.h
@@ -452,10 +452,23 @@ struct athn_ops {
};
struct athn_softc {
+ union {
+ /*
+ * Probably a better alternative: Only ic here, uw at the
+ * beginning of athn_usb_softc. Then always use usc->usc_sc
+ * instead of casting with ATHN_SOFTC.
+ *
+ * Probably the best alternative: Don't use athn_softc for USB.
+ * Make a smaller struct with common data, or exclusively for
+ * the methods in athn_ops. sc_ic as before.
+ */
+ struct ieee80211com sc_real_ic;
+ struct usbwifi sc_uw;
+ };
device_t sc_dev;
device_suspensor_t sc_suspensor;
pmf_qual_t sc_qual;
- struct ieee80211com sc_ic;
+ struct ieee80211com *sc_ic;
struct ethercom sc_ec;
#define sc_if sc_ec.ec_if
struct ifaltq sc_sendq;
diff --git a/sys/dev/pci/if_athn_pci.c b/sys/dev/pci/if_athn_pci.c
index 6fc8dd4435..40a15fbe9d 100644
--- a/sys/dev/pci/if_athn_pci.c
+++ b/sys/dev/pci/if_athn_pci.c
@@ -47,6 +47,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_athn_pci.c,v 1.14 2022/09/25 17:52:25 thorpej Exp
#include <net80211/ieee80211_amrr.h>
#include <net80211/ieee80211_radiotap.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
@@ -127,7 +129,7 @@ athn_pci_attach(device_t parent, device_t self, void *aux)
{
struct athn_pci_softc *psc = device_private(self);
struct athn_softc *sc = &psc->psc_sc;
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = &sc->sc_real_ic;
struct pci_attach_args *pa = aux;
const char *intrstr;
pcireg_t memtype, reg;
@@ -268,7 +270,7 @@ athn_pci_activate(device_t self, enum devact act)
switch (act) {
case DVACT_DEACTIVATE:
- if_deactivate(TAILQ_FIRST(&(sc->sc_ic.ic_vaps))->iv_ifp);
+ if_deactivate(TAILQ_FIRST(&(sc->sc_ic->ic_vaps))->iv_ifp);
break;
}
return 0;
diff --git a/sys/dev/usb/if_athn_usb.c b/sys/dev/usb/if_athn_usb.c
index 42d60d0f50..90d8935b9e 100644
--- a/sys/dev/usb/if_athn_usb.c
+++ b/sys/dev/usb/if_athn_usb.c
@@ -70,6 +70,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.38 2020/03/14 02:35:33 christos Ex
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbwifi.h>
+
#include <dev/ic/athnreg.h>
#include <dev/ic/athnvar.h>
#include <dev/ic/arn9285.h>
@@ -78,27 +80,24 @@ __KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.38 2020/03/14 02:35:33 christos Ex
#define ATHN_USB_SOFTC(sc) ((struct athn_usb_softc *)(sc))
#define ATHN_USB_NODE(ni) ((struct athn_usb_node *)(ni))
-#define IS_UP_AND_RUNNING(ifp) \
- (((ifp)->if_flags & IFF_UP) && ((ifp)->if_flags & IFF_RUNNING))
-
#define athn_usb_wmi_cmd(sc, cmd_id) \
athn_usb_wmi_xcmd(sc, cmd_id, NULL, 0, NULL)
-Static int athn_usb_activate(device_t, enum devact);
+//Static int athn_usb_activate(device_t, enum devact);
Static int athn_usb_detach(device_t, int);
Static int athn_usb_match(device_t, cfdata_t, void *);
Static void athn_usb_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(athn_usb, sizeof(struct athn_usb_softc), athn_usb_match,
- athn_usb_attach, athn_usb_detach, athn_usb_activate);
+ athn_usb_attach, athn_usb_detach, usbwifi_activate);
-Static int athn_usb_alloc_rx_list(struct athn_usb_softc *);
Static int athn_usb_alloc_tx_cmd(struct athn_usb_softc *);
Static int athn_usb_alloc_tx_msg(struct athn_usb_softc *);
-Static int athn_usb_alloc_tx_list(struct athn_usb_softc *);
Static void athn_usb_attachhook(device_t);
+#ifdef notyet
Static void athn_usb_bcneof(struct usbd_xfer *, void *,
usbd_status);
+#endif
Static void athn_usb_abort_pipes(struct athn_usb_softc *);
Static void athn_usb_close_pipes(struct athn_usb_softc *);
Static int athn_usb_create_hw_node(struct athn_usb_softc *,
@@ -107,58 +106,54 @@ Static int athn_usb_create_node(struct athn_usb_softc *,
struct ieee80211_node *);
Static void athn_usb_do_async(struct athn_usb_softc *,
void (*)(struct athn_usb_softc *, void *), void *, int);
-Static void athn_usb_free_rx_list(struct athn_usb_softc *);
Static void athn_usb_free_tx_cmd(struct athn_usb_softc *);
Static void athn_usb_free_tx_msg(struct athn_usb_softc *);
-Static void athn_usb_free_tx_list(struct athn_usb_softc *);
Static int athn_usb_htc_connect_svc(struct athn_usb_softc *, uint16_t,
uint8_t, uint8_t, uint8_t *);
Static int athn_usb_htc_msg(struct athn_usb_softc *, uint16_t, void *,
int);
Static int athn_usb_htc_setup(struct athn_usb_softc *);
-Static int athn_usb_init(struct ifnet *);
-Static int athn_usb_init_locked(struct ifnet *);
-Static void athn_usb_intr(struct usbd_xfer *, void *,
- usbd_status);
-Static int athn_usb_ioctl(struct ifnet *, u_long, void *);
+//Static int athn_usb_init(struct athn_usb_softc *);
+Static int athn_usb_init_locked(struct usbwifi *);
+Static void athn_usb_intr(struct usbwifi *, usbd_status, uint32_t);
Static int athn_usb_load_firmware(struct athn_usb_softc *);
Static const struct athn_usb_type *
athn_usb_lookup(int, int);
-Static int athn_usb_media_change(struct ifnet *);
+//Static int athn_usb_media_change(struct ifnet *);
Static void athn_usb_newassoc(struct ieee80211_node *, int);
Static void athn_usb_newassoc_cb(struct athn_usb_softc *, void *);
-Static int athn_usb_newstate(struct ieee80211com *, enum ieee80211_state,
- int);
-Static void athn_usb_newstate_cb(struct athn_usb_softc *, void *);
+//Static int athn_usb_newstate(struct ieee80211com *, enum ieee80211_state,
+// int);
+//Static void athn_usb_newstate_cb(struct athn_usb_softc *, void *);
Static void athn_usb_node_cleanup(struct ieee80211_node *);
Static void athn_usb_node_cleanup_cb(struct athn_usb_softc *, void *);
-Static int athn_usb_open_pipes(struct athn_usb_softc *);
+Static int athn_usb_configure_pipes(struct athn_usb_softc *);
Static uint32_t athn_usb_read(struct athn_softc *, uint32_t);
Static int athn_usb_remove_hw_node(struct athn_usb_softc *, uint8_t *);
Static void athn_usb_rx_enable(struct athn_softc *);
Static void athn_usb_rx_frame(struct athn_usb_softc *, struct mbuf *);
-Static void athn_usb_rx_radiotap(struct athn_softc *, struct mbuf *,
- struct ar_rx_status *);
+//Static void athn_usb_rx_radiotap(struct athn_softc *, struct mbuf *,
+// struct ar_rx_status *);
Static void athn_usb_rx_wmi_ctrl(struct athn_usb_softc *, uint8_t *, size_t);
-Static void athn_usb_rxeof(struct usbd_xfer *, void *,
- usbd_status);
-Static void athn_usb_start(struct ifnet *);
-//Static void athn_usb_start_locked(struct ifnet *);
-Static void athn_usb_stop(struct ifnet *, int disable);
-Static void athn_usb_stop_locked(struct ifnet *);
+Static void athn_usb_rx_loop(struct usbwifi *, struct usbwifi_chain *,
+ uint32_t);
+Static void athn_usb_stop(struct athn_usb_softc *, int disable);
+Static void athn_usb_stop_locked(struct usbwifi *);
+#ifdef notyet
Static void athn_usb_swba(struct athn_usb_softc *);
-Static int athn_usb_switch_chan(struct athn_softc *,
- struct ieee80211_channel *, struct ieee80211_channel *);
+#endif
+//Static int athn_usb_switch_chan(struct athn_softc *,
+// struct ieee80211_channel *, struct ieee80211_channel *);
Static void athn_usb_task(void *);
-Static int athn_usb_tx(struct athn_softc *, struct mbuf *,
- struct ieee80211_node *, struct athn_usb_tx_data *);
-Static void athn_usb_txeof(struct usbd_xfer *, void *,
- usbd_status);
+Static unsigned athn_usb_tx_prepare(struct usbwifi *, struct usbwifi_chain *,
+ uint8_t qid);
+//Static void athn_usb_txeof(struct usbd_xfer *, void *,
+// usbd_status);
Static void athn_usb_updateslot(struct ieee80211com *);
Static void athn_usb_updateslot_cb(struct athn_usb_softc *, void *);
Static void athn_usb_wait_async(struct athn_usb_softc *);
Static int athn_usb_wait_msg(struct athn_usb_softc *);
-Static void athn_usb_watchdog(struct ifnet *);
+//Static void athn_usb_watchdog(struct ifnet *);
Static int athn_usb_wmi_xcmd(struct athn_usb_softc *, uint16_t, void *,
int, void *);
Static void athn_usb_wmieof(struct usbd_xfer *, void *,
@@ -194,6 +189,14 @@ Static void athn_usb_set_key_cb(struct athn_usb_softc *, void *);
#endif /* notyet */
/************************************************************************/
+static const struct usbwifi_ops athn_usb_ops = {
+ .uwo_stop = athn_usb_stop_locked,
+ .uwo_init = athn_usb_init_locked,
+ .uwo_rx_loop = athn_usb_rx_loop,
+ .uwo_tx_prepare = athn_usb_tx_prepare,
+ .uwo_intr = athn_usb_intr
+};
+
struct athn_usb_type {
struct usb_devno devno;
u_int flags;
@@ -253,7 +256,16 @@ athn_usb_attach(device_t parent, device_t self, void *aux)
sc = &usc->usc_sc;
uaa = aux;
sc->sc_dev = self;
- usc->usc_udev = uaa->uaa_device;
+ sc->sc_ic = usbwifi_ic(&usc->usc_uw);
+ usc->usc_uw.uw_sc = usc;
+ usc->usc_uw.uw_dev = self;
+ usc->usc_uw.uw_udev = uaa->uaa_device;
+ usc->usc_uw.uw_ops = &athn_usb_ops;
+ usc->usc_uw.uw_rx_bufsz = ATHN_USB_RXBUFSZ;
+ usc->usc_uw.uw_tx_bufsz = ATHN_USB_TXBUFSZ;
+ usc->usc_uw.uw_rx_list_cnt = ATHN_USB_RX_LIST_COUNT;
+ usc->usc_uw.uw_tx_list_cnt = ATHN_USB_TX_LIST_COUNT;
+ usbwifi_attach(&usc->usc_uw);
aprint_naive("\n");
aprint_normal("\n");
@@ -274,7 +286,7 @@ athn_usb_attach(device_t parent, device_t self, void *aux)
sc->sc_ops.write = athn_usb_write;
sc->sc_ops.write_barrier = athn_usb_write_barrier;
- mutex_init(&usc->usc_lock, MUTEX_DEFAULT, IPL_NONE);
+ //mutex_init(&usc->usc_lock, MUTEX_DEFAULT, IPL_NONE);
cv_init(&usc->usc_wmi_cv, "athnwmi");
cv_init(&usc->usc_htc_cv, "athnhtc");
@@ -290,21 +302,21 @@ athn_usb_attach(device_t parent, device_t self, void *aux)
usb_init_task(&usc->usc_task, athn_usb_task, usc, 0);
- if (usbd_set_config_no(usc->usc_udev, 1, 0) != 0) {
+ if (usbd_set_config_no(usc->usc_uw.uw_udev, 1, 0) != 0) {
aprint_error_dev(sc->sc_dev,
"could not set configuration no\n");
goto fail;
}
/* Get the first interface handle. */
- error = usbd_device2interface_handle(usc->usc_udev, 0, &usc->usc_iface);
+ error = usbd_device2interface_handle(usc->usc_uw.uw_udev, 0, &usc->usc_uw.uw_iface);
if (error != 0) {
aprint_error_dev(sc->sc_dev,
"could not get interface handle\n");
goto fail;
}
- if (athn_usb_open_pipes(usc) != 0)
+ if (athn_usb_configure_pipes(usc) != 0)
goto fail;
/* Allocate xfer for firmware commands. */
@@ -315,17 +327,9 @@ athn_usb_attach(device_t parent, device_t self, void *aux)
if (athn_usb_alloc_tx_msg(usc) != 0)
goto fail;
- /* Allocate Tx/Rx buffers. */
- error = athn_usb_alloc_rx_list(usc);
- if (error != 0)
- goto fail;
- error = athn_usb_alloc_tx_list(usc);
- if (error != 0)
- goto fail;
-
config_mountroot(self, athn_usb_attachhook);
- usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, usc->usc_udev, sc->sc_dev);
+ //usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, usc->usc_uw.uw_udev, sc->sc_dev);
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
@@ -337,12 +341,10 @@ athn_usb_attach(device_t parent, device_t self, void *aux)
/* Free Tx/Rx buffers. */
athn_usb_abort_pipes(usc);
- athn_usb_free_tx_list(usc);
- athn_usb_free_rx_list(usc);
athn_usb_free_tx_cmd(usc);
athn_usb_free_tx_msg(usc);
athn_usb_close_pipes(usc);
- usb_rem_task_wait(usc->usc_udev, &usc->usc_task, USB_TASKQ_DRIVER,
+ usb_rem_task_wait(usc->usc_uw.uw_udev, &usc->usc_task, USB_TASKQ_DRIVER,
NULL);
cv_destroy(&usc->usc_cmd_cv);
@@ -350,12 +352,13 @@ athn_usb_attach(device_t parent, device_t self, void *aux)
cv_destroy(&usc->usc_wmi_cv);
cv_destroy(&usc->usc_htc_cv);
- mutex_destroy(&usc->usc_lock);
+ //mutex_destroy(&usc->usc_lock);
mutex_destroy(&usc->usc_cmd_mtx);
mutex_destroy(&usc->usc_msg_mtx);
mutex_destroy(&usc->usc_tx_mtx);
mutex_destroy(&usc->usc_task_mtx);
+ usbwifi_detach(usc->usc_dev, 0);
}
Static void
@@ -371,13 +374,10 @@ athn_usb_node_cleanup_cb(struct athn_usb_softc *usc, void *arg)
Static void
athn_usb_node_cleanup(struct ieee80211_node *ni)
{
- struct athn_usb_softc *usc;
- struct ieee80211com *ic;
+ struct ieee80211com *ic = ni->ni_ic;
+ struct athn_usb_softc *usc = ATHN_USB_SOFTC(ic->ic_softc);
uint8_t sta_index;
- usc = ATHN_USB_SOFTC(TAILQ_FIRST(&(ni->ni_ic->ic_vaps))->iv_ifp->if_softc);
- ic = &ATHN_SOFTC(usc)->sc_ic;
-
DPRINTFN(DBG_FN, usc, "\n");
if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
@@ -395,12 +395,11 @@ athn_usb_attachhook(device_t arg)
struct athn_usb_softc *usc = device_private(arg);
struct athn_softc *sc = &usc->usc_sc;
struct athn_ops *ops = &sc->sc_ops;
- struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ieee80211com *ic = usbwifi_ic(&usc->usc_uw);
size_t i;
int error;
- if (usc->usc_dying)
+ if (usbwifi_isdying(&usc->usc_uw))
return;
DPRINTFN(DBG_FN, usc, "\n");
@@ -418,18 +417,17 @@ athn_usb_attachhook(device_t arg)
if (error != 0)
return;
+ /* XXX uw_ac2idx all 0 */
+
/* We're now ready to attach the bus agnostic driver. */
- TAILQ_FIRST(&(ic->ic_vaps))->iv_ifp = ifp;
ic->ic_updateslot = athn_usb_updateslot;
sc->sc_max_aid = AR_USB_MAX_STA; /* Firmware is limited to 8 STA */
- sc->sc_media_change = athn_usb_media_change;
+ //sc->sc_media_change = athn_usb_media_change;
/* Override some operations for USB. */
- ifp->if_init = athn_usb_init;
- ifp->if_stop = athn_usb_stop;
- ifp->if_ioctl = athn_usb_ioctl;
- ifp->if_start = athn_usb_start;
- ifp->if_watchdog = athn_usb_watchdog;
+ //ic->ic_parent = athn_usb_parent;
+ //ic->ic_transmit = athn_usb_transmit;
+ //ic->ic_raw_xmit = athn_usb_raw_xmit;
error = athn_attach(sc);
if (error != 0) {
@@ -437,6 +435,10 @@ athn_usb_attachhook(device_t arg)
}
usc->usc_athn_attached = 1;
+ usbwifi_ic_attach(&usc->usc_uw, sc->sc_ntxchains, sc->sc_nrxchains,
+ usc->usc_ntxpipes, usc->usc_nrxpipes,
+ IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
+
/* hooks for HostAP association and disassociation */
ic->ic_newassoc = athn_usb_newassoc;
usc->usc_node_cleanup = ic->ic_node_cleanup;
@@ -469,7 +471,7 @@ athn_usb_attachhook(device_t arg)
/* Configure LED. */
athn_led_init(sc);
- ieee80211_announce(ic);
+ usbwifi_attach_finalize(&usc->usc_uw);
}
Static int
@@ -486,10 +488,6 @@ athn_usb_detach(device_t self, int flags)
pmf_device_deregister(self);
- mutex_enter(&usc->usc_lock);
- usc->usc_dying = 1;
- mutex_exit(&usc->usc_lock);
-
mutex_enter(&usc->usc_cmd_mtx);
while (usc->usc_wmiactive) {
error = cv_timedwait(&usc->usc_wmi_cv, &usc->usc_cmd_mtx, hz);
@@ -514,8 +512,8 @@ athn_usb_detach(device_t self, int flags)
athn_usb_wait_async(usc);
- athn_usb_stop(&sc->sc_if, 0);
- usb_rem_task_wait(usc->usc_udev, &usc->usc_task, USB_TASKQ_DRIVER,
+ athn_usb_stop(usc, 0);
+ usb_rem_task_wait(usc->usc_uw.uw_udev, &usc->usc_task, USB_TASKQ_DRIVER,
NULL);
/* Abort Tx/Rx pipes. */
@@ -527,8 +525,6 @@ athn_usb_detach(device_t self, int flags)
}
/* Free Tx/Rx buffers. */
- athn_usb_free_rx_list(usc);
- athn_usb_free_tx_list(usc);
athn_usb_free_tx_cmd(usc);
athn_usb_free_tx_msg(usc);
@@ -545,12 +541,14 @@ athn_usb_detach(device_t self, int flags)
cv_destroy(&usc->usc_msg_cv);
cv_destroy(&usc->usc_wmi_cv);
- mutex_destroy(&usc->usc_lock);
+ //mutex_destroy(&usc->usc_lock);
- usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, usc->usc_udev, sc->sc_dev);
+ //usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, usc->usc_uw.uw_udev, sc->sc_dev);
+ usbwifi_detach(usc->usc_dev, 0);
return 0;
}
+#if 0
Static int
athn_usb_activate(device_t self, enum devact act)
{
@@ -561,23 +559,27 @@ athn_usb_activate(device_t self, enum devact act)
switch (act) {
case DVACT_DEACTIVATE:
- if_deactivate(TAILQ_FIRST(&(sc->sc_ic.ic_vaps))->iv_ifp);
- usc->usc_dying = 1;
+ if_deactivate(TAILQ_FIRST(&(usbwifi_ic(&usc->usc_uw)->ic_vaps))->iv_ifp);
return 0;
default:
return EOPNOTSUPP;
}
}
+#endif
Static int
-athn_usb_open_pipes(struct athn_usb_softc *usc)
+athn_usb_configure_pipes(struct athn_usb_softc *usc)
{
+ struct usbwifi *uw = &usc->usc_uw;
+ struct usbwifi_intr *uwi;
usb_endpoint_descriptor_t *ed;
int error;
DPRINTFN(DBG_FN, usc, "\n");
- error = usbd_open_pipe(usc->usc_iface, AR_PIPE_TX_DATA, 0,
+ /* XXX Can there be more? */
+#if 0
+ error = usbd_open_pipe(usc->usc_uw.uw_iface, AR_PIPE_TX_DATA, 0,
&usc->usc_tx_data_pipe);
if (error != 0) {
aprint_error_dev(usc->usc_dev,
@@ -585,7 +587,7 @@ athn_usb_open_pipes(struct athn_usb_softc *usc)
goto fail;
}
- error = usbd_open_pipe(usc->usc_iface, AR_PIPE_RX_DATA, 0,
+ error = usbd_open_pipe(usc->usc_uw.uw_iface, AR_PIPE_RX_DATA, 0,
&usc->usc_rx_data_pipe);
if (error != 0) {
aprint_error_dev(usc->usc_dev,
@@ -593,7 +595,7 @@ athn_usb_open_pipes(struct athn_usb_softc *usc)
goto fail;
}
- ed = usbd_get_endpoint_descriptor(usc->usc_iface, AR_PIPE_RX_INTR);
+ ed = usbd_get_endpoint_descriptor(usc->usc_uw.uw_iface, AR_PIPE_RX_INTR);
if (ed == NULL) {
aprint_error_dev(usc->usc_dev,
"could not retrieve Rx intr pipe descriptor\n");
@@ -607,7 +609,7 @@ athn_usb_open_pipes(struct athn_usb_softc *usc)
}
usc->usc_ibuf = kmem_alloc(usc->usc_ibufsize, KM_SLEEP);
- error = usbd_open_pipe_intr(usc->usc_iface, AR_PIPE_RX_INTR,
+ error = usbd_open_pipe_intr(usc->usc_uw.uw_iface, AR_PIPE_RX_INTR,
USBD_SHORT_XFER_OK, &usc->usc_rx_intr_pipe, usc, usc->usc_ibuf,
usc->usc_ibufsize, athn_usb_intr, USBD_DEFAULT_INTERVAL);
if (error != 0) {
@@ -615,13 +617,40 @@ athn_usb_open_pipes(struct athn_usb_softc *usc)
"could not open Rx intr pipe\n");
goto fail;
}
- error = usbd_open_pipe(usc->usc_iface, AR_PIPE_TX_INTR, 0,
+#endif
+ error = usbd_open_pipe(usc->usc_uw.uw_iface, AR_PIPE_TX_INTR, 0,
&usc->usc_tx_intr_pipe);
if (error != 0) {
aprint_error_dev(usc->usc_dev,
"could not open Tx intr pipe\n");
+ return error;
+ }
+
+ usc->usc_ntxpipes = 1;
+ usc->usc_nrxpipes = 2;
+ uw->uw_ed[0] = AR_PIPE_TX_DATA;
+ uw->uw_ed[1] = AR_PIPE_RX_DATA;
+ uw->uw_ed[2] = AR_PIPE_RX_INTR;
+
+ ed = usbd_get_endpoint_descriptor(usc->usc_uw.uw_iface, AR_PIPE_RX_INTR);
+ if (ed == NULL) {
+ aprint_error_dev(usc->usc_dev,
+ "could not retrieve Rx intr pipe descriptor\n");
goto fail;
}
+ usc->usc_ibufsize = UGETW(ed->wMaxPacketSize);
+ if (usc->usc_ibufsize == 0) {
+ aprint_error_dev(usc->usc_dev,
+ "invalid Rx intr pipe descriptor\n");
+ goto fail;
+ }
+ usc->usc_ibuf = kmem_alloc(usc->usc_ibufsize, KM_SLEEP);
+ uwi = kmem_zalloc(sizeof(*uwi), KM_SLEEP);
+ uwi->uwi_buf = usc->usc_ibuf;
+ uwi->uwi_bufsz = usc->usc_ibufsize;
+ uwi->uwi_interval = USBD_DEFAULT_INTERVAL;
+ uwi->uwi_index = 2;
+ uw->uw_intr = uwi;
return 0;
fail:
athn_usb_abort_pipes(usc);
@@ -646,14 +675,8 @@ athn_usb_abort_pipes(struct athn_usb_softc *usc)
{
DPRINTFN(DBG_FN, usc, "\n");
- if (usc->usc_tx_data_pipe != NULL)
- usbd_abort_pipe(usc->usc_tx_data_pipe);
- if (usc->usc_rx_data_pipe != NULL)
- usbd_abort_pipe(usc->usc_rx_data_pipe);
if (usc->usc_tx_intr_pipe != NULL)
usbd_abort_pipe(usc->usc_tx_intr_pipe);
- if (usc->usc_rx_intr_pipe != NULL)
- usbd_abort_pipe(usc->usc_rx_intr_pipe);
}
Static void
@@ -663,115 +686,12 @@ athn_usb_close_pipes(struct athn_usb_softc *usc)
DPRINTFN(DBG_FN, usc, "\n");
- athn_usb_kill_pipe(&usc->usc_tx_data_pipe);
- athn_usb_kill_pipe(&usc->usc_rx_data_pipe);
athn_usb_kill_pipe(&usc->usc_tx_intr_pipe);
- athn_usb_kill_pipe(&usc->usc_rx_intr_pipe);
+ /* Move elsewhere? */
ibuf = atomic_swap_ptr(&usc->usc_ibuf, NULL);
if (ibuf != NULL)
kmem_free(ibuf, usc->usc_ibufsize);
-}
-
-Static int
-athn_usb_alloc_rx_list(struct athn_usb_softc *usc)
-{
- struct athn_usb_rx_data *data;
- size_t i;
- int error = 0;
-
- DPRINTFN(DBG_FN, usc, "\n");
-
- for (i = 0; i < ATHN_USB_RX_LIST_COUNT; i++) {
- data = &usc->usc_rx_data[i];
-
- data->sc = usc; /* Backpointer for callbacks. */
-
- error = usbd_create_xfer(usc->usc_rx_data_pipe,
- ATHN_USB_RXBUFSZ, 0, 0, &data->xfer);
- if (error) {
- aprint_error_dev(usc->usc_dev,
- "could not allocate xfer\n");