-
Notifications
You must be signed in to change notification settings - Fork 0
/
ath-progress.patch
3410 lines (3229 loc) · 101 KB
/
ath-progress.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 -r f00ade18273e sys/dev/cardbus/if_ath_cardbus.c
--- a/sys/dev/cardbus/if_ath_cardbus.c Sun Jul 30 21:50:13 2023 -0700
+++ b/sys/dev/cardbus/if_ath_cardbus.c Wed Aug 02 16:29:51 2023 +1200
@@ -193,7 +193,6 @@
if (pmf_device_register(self,
ath_cardbus_suspend, ath_cardbus_resume)) {
- pmf_class_network_register(self, &sc->sc_if);
pmf_device_suspend(self, &sc->sc_qual);
} else
aprint_error_dev(self, "couldn't establish power handler\n");
diff -r f00ade18273e sys/dev/ic/ath.c
--- a/sys/dev/ic/ath.c Sun Jul 30 21:50:13 2023 -0700
+++ b/sys/dev/ic/ath.c Wed Aug 02 16:29:51 2023 +1200
@@ -122,48 +122,53 @@
#define HTOAH32(x) (x)
#endif
-static int ath_ifinit(struct ifnet *);
+static struct ieee80211vap *ath_vap_create(struct ieee80211com *,
+ const char [IFNAMSIZ], int, enum ieee80211_opmode, int,
+ const uint8_t [IEEE80211_ADDR_LEN],
+ const uint8_t [IEEE80211_ADDR_LEN]);
+static void ath_vap_delete(struct ieee80211vap *);
+static void ath_parent(struct ieee80211com *);
static int ath_init(struct ath_softc *);
-static void ath_stop_locked(struct ifnet *, int);
-static void ath_stop(struct ifnet *, int);
-static void ath_start(struct ifnet *);
-static int ath_media_change(struct ifnet *);
-static void ath_watchdog(struct ifnet *);
-static int ath_ioctl(struct ifnet *, u_long, void *);
+static void ath_stop_locked(struct ath_softc *, int);
+static void ath_stop(struct ath_softc *, int);
+static void ath_start(struct ath_softc *);
+static int ath_transmit(struct ieee80211com *, struct mbuf *);
+static int ath_raw_xmit(struct ieee80211_node *, struct mbuf *,
+ const struct ieee80211_bpf_params *);
+static void ath_update_mcast(struct ieee80211com *);
+static void ath_watchdog(void *);
static void ath_fatal_proc(void *, int);
static void ath_rxorn_proc(void *, int);
static void ath_bmiss_proc(void *, int);
static void ath_radar_proc(void *, int);
-static int ath_key_alloc(struct ieee80211com *,
- const struct ieee80211_key *,
+static int ath_key_alloc(struct ieee80211vap *, struct ieee80211_key *,
ieee80211_keyix *, ieee80211_keyix *);
-static int ath_key_delete(struct ieee80211com *,
+static int ath_key_delete(struct ieee80211vap *,
const struct ieee80211_key *);
-static int ath_key_set(struct ieee80211com *, const struct ieee80211_key *,
- const u_int8_t mac[IEEE80211_ADDR_LEN]);
-static void ath_key_update_begin(struct ieee80211com *);
-static void ath_key_update_end(struct ieee80211com *);
+static int ath_key_set(struct ieee80211vap *, const struct ieee80211_key *);
+static void ath_key_update_begin(struct ieee80211vap *);
+static void ath_key_update_end(struct ieee80211vap *);
static void ath_mode_init(struct ath_softc *);
static void ath_setslottime(struct ath_softc *);
-static void ath_updateslot(struct ifnet *);
+static void ath_updateslot(struct ieee80211com *);
static int ath_beaconq_setup(struct ath_hal *);
static int ath_beacon_alloc(struct ath_softc *, struct ieee80211_node *);
static void ath_beacon_setup(struct ath_softc *, struct ath_buf *);
static void ath_beacon_proc(void *, int);
static void ath_bstuck_proc(void *, int);
static void ath_beacon_free(struct ath_softc *);
-static void ath_beacon_config(struct ath_softc *);
+static void ath_beacon_config(struct ieee80211vap *);
static void ath_descdma_cleanup(struct ath_softc *sc,
struct ath_descdma *, ath_bufhead *);
static int ath_desc_alloc(struct ath_softc *);
static void ath_desc_free(struct ath_softc *);
-static struct ieee80211_node *ath_node_alloc(struct ieee80211_node_table *);
+static struct ieee80211_node *ath_node_alloc(struct ieee80211vap *,
+ const uint8_t [IEEE80211_ADDR_LEN]);
static void ath_node_free(struct ieee80211_node *);
-static u_int8_t ath_node_getrssi(const struct ieee80211_node *);
static int ath_rxbuf_init(struct ath_softc *, struct ath_buf *);
-static void ath_recv_mgmt(struct ieee80211com *ic, struct mbuf *m,
- struct ieee80211_node *ni,
- int subtype, int rssi, u_int32_t rstamp);
+static void ath_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m,
+ int subtype, const struct ieee80211_rx_stats *,
+ int rssi, int nf);
static void ath_setdefantenna(struct ath_softc *, u_int);
static void ath_rx_proc(void *, int);
static struct ath_txq *ath_txq_setup(struct ath_softc*, int qtype, int subtype);
@@ -183,11 +188,14 @@
static void ath_chan_change(struct ath_softc *, struct ieee80211_channel *);
static void ath_next_scan(void *);
static void ath_calibrate(void *);
-static int ath_newstate(struct ieee80211com *, enum ieee80211_state, int);
+static void ath_scan_start(struct ieee80211com *);
+static void ath_scan_end(struct ieee80211com *);
+static void ath_set_channel(struct ieee80211com *);
+static int ath_newstate(struct ieee80211vap *, enum ieee80211_state, int);
static void ath_setup_stationkey(struct ieee80211_node *);
static void ath_newassoc(struct ieee80211_node *, int);
-static int ath_getchannels(struct ath_softc *, u_int cc,
- HAL_BOOL outdoor, HAL_BOOL xchanmode);
+static void ath_get_radiocaps(struct ieee80211com *, int, int *,
+ struct ieee80211_channel []);
static void ath_led_event(struct ath_softc *, int);
static void ath_update_txpow(struct ath_softc *);
static void ath_freetx(struct mbuf *);
@@ -196,7 +204,9 @@
static int ath_rate_setup(struct ath_softc *, u_int mode);
static void ath_setcurmode(struct ath_softc *, enum ieee80211_phymode);
+#if 0
static void ath_bpfattach(struct ath_softc *);
+#endif
static void ath_announce(struct ath_softc *);
#ifdef __NetBSD__
@@ -252,9 +262,7 @@
ATH_DEBUG_ANY = 0xffffffff
};
#define IFF_DUMPPKTS(sc, m) \
- ((sc->sc_debug & (m)) || \
- (sc->sc_if.if_flags & (IFF_DEBUG | IFF_LINK2)) \
- == (IFF_DEBUG | IFF_LINK2))
+ (sc->sc_debug & (m))
#define DPRINTF(sc, m, fmt, ...) do { \
if (sc->sc_debug & (m)) \
printf(fmt, __VA_ARGS__); \
@@ -266,19 +274,17 @@
static void ath_printrxbuf(struct ath_buf *bf, int);
static void ath_printtxbuf(struct ath_buf *bf, int);
#else
-#define IFF_DUMPPKTS(sc, m) \
- ((sc->sc_if.if_flags & (IFF_DEBUG | IFF_LINK2)) \
- == (IFF_DEBUG | IFF_LINK2))
+#define IFF_DUMPPKTS(sc, m) false
#define DPRINTF(m, fmt, ...)
#define KEYPRINTF(sc, k, ix, mac)
#endif
MALLOC_DEFINE(M_ATHDEV, "athdev", "ath driver dma buffers");
+
int
ath_attach(u_int16_t devid, struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = NULL;
HAL_STATUS status;
@@ -288,17 +294,21 @@
pmf_self_suspensor_init(sc->sc_dev, &sc->sc_suspensor, &sc->sc_qual);
- memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
+ IFQ_SET_MAXLEN(&sc->sc_sendq, IFQ_MAXLEN);
+ IFQ_LOCK_INIT(&sc->sc_sendq);
+
+ ic->ic_softc = sc;
+ ic->ic_name = device_xname(sc->sc_dev);
ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, &status);
if (ah == NULL) {
- if_printf(ifp, "unable to attach hardware; HAL status %u\n",
- status);
+ device_printf(sc->sc_dev,
+ "unable to attach hardware; HAL status %u\n", status);
error = ENXIO;
goto bad;
}
if (ah->ah_abi != HAL_ABI_VERSION) {
- if_printf(ifp, "HAL ABI mismatch detected "
+ device_printf(sc->sc_dev, "HAL ABI mismatch detected "
"(HAL:0x%x != driver:0x%x)\n",
ah->ah_abi, HAL_ABI_VERSION);
error = ENXIO;
@@ -332,7 +342,8 @@
*/
sc->sc_keymax = ath_hal_keycachesize(ah);
if (sc->sc_keymax > ATH_KEYMAX) {
- if_printf(ifp, "Warning, using only %u of %u key cache slots\n",
+ device_printf(sc->sc_dev,
+ "Warning, using only %u of %u key cache slots\n",
ATH_KEYMAX, sc->sc_keymax);
sc->sc_keymax = ATH_KEYMAX;
}
@@ -361,10 +372,8 @@
* is resposible for filtering this list based on settings
* like the phy mode.
*/
- error = ath_getchannels(sc, ath_countrycode,
- ath_outdoor, ath_xchanmode);
- if (error != 0)
- goto bad;
+ ath_get_radiocaps(ic, IEEE80211_CHAN_MAX,
+ &ic->ic_nchans, ic->ic_channels);
/*
* Setup rate tables for all potential media types.
@@ -382,7 +391,8 @@
*/
error = ath_desc_alloc(sc);
if (error != 0) {
- if_printf(ifp, "failed to allocate descriptors: %d\n", error);
+ device_printf(sc->sc_dev,
+ "failed to allocate descriptors: %d\n", error);
goto bad;
}
ATH_CALLOUT_INIT(&sc->sc_scan_ch, debug_mpsafenet ? CALLOUT_MPSAFE : 0);
@@ -390,15 +400,16 @@
#if 0
ATH_CALLOUT_INIT(&sc->sc_dfs_ch, CALLOUT_MPSAFE);
#endif
+ ATH_CALLOUT_INIT(&sc->sc_watchdog_ch, CALLOUT_MPSAFE);
ATH_TXBUF_LOCK_INIT(sc);
- TASK_INIT(&sc->sc_rxtask, 0, ath_rx_proc, sc);
- TASK_INIT(&sc->sc_rxorntask, 0, ath_rxorn_proc, sc);
- TASK_INIT(&sc->sc_fataltask, 0, ath_fatal_proc, sc);
- TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc);
- TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc);
- TASK_INIT(&sc->sc_radartask, 0, ath_radar_proc, sc);
+ ATH_TASK_INIT(&sc->sc_rxtask, 0, ath_rx_proc, sc);
+ ATH_TASK_INIT(&sc->sc_rxorntask, 0, ath_rxorn_proc, sc);
+ ATH_TASK_INIT(&sc->sc_fataltask, 0, ath_fatal_proc, sc);
+ ATH_TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc);
+ ATH_TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc);
+ ATH_TASK_INIT(&sc->sc_radartask, 0, ath_radar_proc, sc);
/*
* Allocate hardware transmit queues: one queue for
@@ -410,19 +421,21 @@
*/
sc->sc_bhalq = ath_beaconq_setup(ah);
if (sc->sc_bhalq == (u_int) -1) {
- if_printf(ifp, "unable to setup a beacon xmit queue!\n");
+ device_printf(sc->sc_dev,
+ "unable to setup a beacon xmit queue!\n");
error = EIO;
goto bad2;
}
sc->sc_cabq = ath_txq_setup(sc, HAL_TX_QUEUE_CAB, 0);
if (sc->sc_cabq == NULL) {
- if_printf(ifp, "unable to setup CAB xmit queue!\n");
+ device_printf(sc->sc_dev, "unable to setup CAB xmit queue!\n");
error = EIO;
goto bad2;
}
/* NB: insure BK queue is the lowest priority h/w queue */
if (!ath_tx_setup(sc, WME_AC_BK, HAL_WME_AC_BK)) {
- if_printf(ifp, "unable to setup xmit queue for %s traffic!\n",
+ device_printf(sc->sc_dev,
+ "unable to setup xmit queue for %s traffic!\n",
ieee80211_wme_acnames[WME_AC_BK]);
error = EIO;
goto bad2;
@@ -453,13 +466,13 @@
*/
switch (sc->sc_txqsetup &~ (1<<sc->sc_cabq->axq_qnum)) {
case 0x01:
- TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0, sc);
+ ATH_TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0, sc);
break;
case 0x0f:
- TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0123, sc);
+ ATH_TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0123, sc);
break;
default:
- TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc, sc);
+ ATH_TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc, sc);
break;
}
@@ -481,6 +494,7 @@
sc->sc_ledon = 0; /* low true */
sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */
ATH_CALLOUT_INIT(&sc->sc_ledtimer, CALLOUT_MPSAFE);
+
/*
* Auto-enable soft led processing for IBM cards and for
* 5211 minipci cards. Users can also manually enable/disable
@@ -493,25 +507,11 @@
ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon);
}
- ifp->if_softc = sc;
- ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
- ifp->if_start = ath_start;
- ifp->if_stop = ath_stop;
- ifp->if_watchdog = ath_watchdog;
- ifp->if_ioctl = ath_ioctl;
- ifp->if_init = ath_ifinit;
- IFQ_SET_READY(&ifp->if_snd);
-
- ic->ic_ifp = ifp;
- ic->ic_reset = ath_reset;
- ic->ic_newassoc = ath_newassoc;
- ic->ic_updateslot = ath_updateslot;
- ic->ic_wme.wme_update = ath_wme_update;
- /* XXX not right but it's not used anywhere important */
ic->ic_phytype = IEEE80211_T_OFDM;
ic->ic_opmode = IEEE80211_M_STA;
ic->ic_caps =
- IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
+ IEEE80211_C_STA
+ | IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
| IEEE80211_C_HOSTAP /* hostap mode */
| IEEE80211_C_MONITOR /* monitor mode */
| IEEE80211_C_SHPREAMBLE /* short preamble supported */
@@ -519,26 +519,27 @@
| IEEE80211_C_WPA /* capable of WPA1+WPA2 */
| IEEE80211_C_TXFRAG /* handle tx frags */
;
+
/*
* Query the hal to figure out h/w crypto support.
*/
if (ath_hal_ciphersupported(ah, HAL_CIPHER_WEP))
- ic->ic_caps |= IEEE80211_C_WEP;
+ ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP;
if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_OCB))
- ic->ic_caps |= IEEE80211_C_AES;
+ ic->ic_cryptocaps |= IEEE80211_CRYPTO_AES_OCB;
if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_CCM))
- ic->ic_caps |= IEEE80211_C_AES_CCM;
+ ic->ic_cryptocaps |= IEEE80211_CRYPTO_AES_CCM;
if (ath_hal_ciphersupported(ah, HAL_CIPHER_CKIP))
- ic->ic_caps |= IEEE80211_C_CKIP;
+ ic->ic_cryptocaps |= IEEE80211_CRYPTO_CKIP;
if (ath_hal_ciphersupported(ah, HAL_CIPHER_TKIP)) {
- ic->ic_caps |= IEEE80211_C_TKIP;
+ ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIP;
/*
* Check if h/w does the MIC and/or whether the
* separate key cache entries are required to
* handle both tx+rx MIC keys.
*/
if (ath_hal_ciphersupported(ah, HAL_CIPHER_MIC))
- ic->ic_caps |= IEEE80211_C_TKIPMIC;
+ ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIPMIC;
/*
* If the h/w supports storing tx+rx MIC keys
@@ -554,10 +555,13 @@
* in software by the net80211 layer.
*/
if (ath_hal_haswmetkipmic(ah))
- ic->ic_caps |= IEEE80211_C_WME_TKIPMIC;
+ sc->sc_flags |= ATH_WMETKIPMIC;
}
+ ic->ic_cryptocaps = 0; /* XXX doesn't work otherwise */
+
sc->sc_hasclrkey = ath_hal_ciphersupported(ah, HAL_CIPHER_CLR);
sc->sc_mcastkey = ath_hal_getmcastkeysearch(ah);
+
/*
* Mark key cache slots associated with global keys
* as in use. If we knew TKIP was not to be used we
@@ -610,32 +614,28 @@
sc->sc_hasveol = ath_hal_hasveol(ah);
/* get mac address from hardware */
- ath_hal_getmac(ah, ic->ic_myaddr);
-
- if_attach(ifp);
+ ath_hal_getmac(ah, ic->ic_macaddr);
+
/* call MI attach routine. */
ieee80211_ifattach(ic);
+
/* override default methods */
+ ic->ic_vap_create = ath_vap_create;
+ ic->ic_vap_delete = ath_vap_delete;
+ ic->ic_parent = ath_parent;
+ ic->ic_transmit = ath_transmit;
+ ic->ic_raw_xmit = ath_raw_xmit;
+ ic->ic_newassoc = ath_newassoc;
+ ic->ic_updateslot = ath_updateslot;
+ ic->ic_update_mcast = ath_update_mcast;
+ ic->ic_wme.wme_update = ath_wme_update;
ic->ic_node_alloc = ath_node_alloc;
sc->sc_node_free = ic->ic_node_free;
ic->ic_node_free = ath_node_free;
- ic->ic_node_getrssi = ath_node_getrssi;
- sc->sc_recv_mgmt = ic->ic_recv_mgmt;
- ic->ic_recv_mgmt = ath_recv_mgmt;
- sc->sc_newstate = ic->ic_newstate;
- ic->ic_newstate = ath_newstate;
- ic->ic_crypto.cs_max_keyix = sc->sc_keymax;
- ic->ic_crypto.cs_key_alloc = ath_key_alloc;
- ic->ic_crypto.cs_key_delete = ath_key_delete;
- ic->ic_crypto.cs_key_set = ath_key_set;
- ic->ic_crypto.cs_key_update_begin = ath_key_update_begin;
- ic->ic_crypto.cs_key_update_end = ath_key_update_end;
- /* complete initialization */
- ieee80211_media_init(ic, ath_media_change, ieee80211_media_status);
-
- ath_bpfattach(sc);
-
- sc->sc_flags |= ATH_ATTACHED;
+ ic->ic_scan_start = ath_scan_start;
+ ic->ic_scan_end = ath_scan_end;
+ ic->ic_set_channel = ath_set_channel;
+ ic->ic_getradiocaps = ath_get_radiocaps;
/*
* Setup dynamic sysctl's now that country code and
@@ -656,21 +656,80 @@
return error;
}
+static struct ieee80211vap *
+ath_vap_create(struct ieee80211com *ic,
+ const char name[IFNAMSIZ], int unit, enum ieee80211_opmode opmode,
+ int flags, const uint8_t bssid[IEEE80211_ADDR_LEN],
+ const uint8_t macaddr[IEEE80211_ADDR_LEN])
+{
+ struct ath_vap *avp;
+ struct ieee80211vap *vap;
+ avp = kmem_zalloc(sizeof(*avp), KM_SLEEP);
+ vap = &avp->av_vap;
+ if (ieee80211_vap_setup(ic, vap, name, unit, opmode,
+ flags | IEEE80211_CLONE_NOBEACONS, bssid) != 0) {
+ kmem_free(vap, sizeof(*vap));
+ return NULL;
+ }
+
+ vap->iv_ifp->if_percpuq = if_percpuq_create(vap->iv_ifp);
+
+ /* h/w crypto support */
+ vap->iv_key_alloc = ath_key_alloc;
+ vap->iv_key_delete = ath_key_delete;
+ vap->iv_key_set = ath_key_set;
+ vap->iv_key_update_begin = ath_key_update_begin;
+ vap->iv_key_update_end = ath_key_update_end;
+
+ /* override various methods */
+ avp->av_newstate = vap->iv_newstate;
+ vap->iv_newstate = ath_newstate;
+ avp->av_recv_mgmt = vap->iv_recv_mgmt;
+ vap->iv_recv_mgmt = ath_recv_mgmt;
+
+ ieee80211_vap_attach(vap, ieee80211_media_change,
+ ieee80211_media_status, macaddr);
+ ic->ic_opmode = opmode;
+ return vap;
+}
+
+static void
+ath_vap_delete(struct ieee80211vap *vap)
+{
+ struct ath_vap *avp = ATH_VAP(vap);
+
+ bpf_detach(vap->iv_ifp);
+ ieee80211_vap_detach(vap);
+ kmem_free(avp, sizeof(*avp));
+}
+
+
+static void
+ath_parent(struct ieee80211com *ic)
+{
+ struct ath_softc *sc = ic->ic_softc;
+ bool startall = false;
+
+ if (ic->ic_nrunning > 0) {
+ ath_init(sc);
+ startall = true;
+ } else if (ic->ic_nrunning == 0)
+ ath_stop(sc, 0);
+ if (startall) ieee80211_start_all(ic);
+}
+
+
int
ath_detach(struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
int s;
if ((sc->sc_flags & ATH_ATTACHED) == 0)
return (0);
- DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
- __func__, ifp->if_flags);
-
s = splnet();
- ath_stop(ifp, 1);
- bpf_detach(ifp);
+ ath_stop(sc, 1);
+ /* bpf_detach(ifp); */
/*
* NB: the order of these is important:
* o call the 802.11 layer before detaching the hal to
@@ -693,7 +752,6 @@
ath_tx_cleanup(sc);
sysctl_teardown(&sc->sc_sysctllog);
ath_hal_detach(sc->sc_ah);
- if_detach(ifp);
splx(s);
return 0;
@@ -716,6 +774,20 @@
#endif
}
+static HAL_OPMODE
+ath_convert_opmode(enum ieee80211_opmode opmode)
+{
+ switch (opmode) {
+ case IEEE80211_M_IBSS: return HAL_M_IBSS;
+ case IEEE80211_M_STA: return HAL_M_STA;
+ case IEEE80211_M_HOSTAP: return HAL_M_HOSTAP;
+ case IEEE80211_M_MONITOR: return HAL_M_MONITOR;
+ default:
+ KASSERTMSG(false, "unsupported operating mode %u", opmode);
+ return 0;
+ }
+}
+
bool
ath_resume(struct ath_softc *sc)
{
@@ -727,7 +799,8 @@
#if notyet
ath_hal_setpower(ah, HAL_PM_AWAKE);
#else
- ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, HAL_M_IBSS, &status);
+ ath_hal_reset(ah, ath_convert_opmode(ic->ic_opmode),
+ &sc->sc_curchan, HAL_M_IBSS, &status);
#endif
/*
@@ -757,7 +830,6 @@
ath_intr(void *arg)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
struct ath_hal *ah = sc->sc_ah;
HAL_INT status = 0;
@@ -773,6 +845,7 @@
if (!ath_hal_intrpend(ah)) /* shared irq, not for us */
return 0;
+#if 0
if ((ifp->if_flags & (IFF_RUNNING |IFF_UP)) != (IFF_RUNNING |IFF_UP)) {
DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags 0x%x\n",
__func__, ifp->if_flags);
@@ -780,6 +853,7 @@
ath_hal_intrset(ah, 0); /* disable further intr's */
return 1; /* XXX */
}
+#endif
/*
* Figure out the reason(s) for the interrupt. Note
* that the hal returns a pseudo-ISR that may include
@@ -874,16 +948,15 @@
ath_fatal_proc(void *arg, int pending)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
#ifdef __NetBSD__
int s;
#endif
- if_printf(ifp, "hardware error; resetting\n");
+ device_printf(sc->sc_dev, "hardware error; resetting\n");
#ifdef __NetBSD__
s = splnet();
#endif
- ath_reset(ifp);
+ ath_reset(sc);
#ifdef __NetBSD__
splx(s);
#endif
@@ -893,16 +966,15 @@
ath_rxorn_proc(void *arg, int pending)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
#ifdef __NetBSD__
int s;
#endif
- if_printf(ifp, "rx FIFO overrun; resetting\n");
+ device_printf(sc->sc_dev, "rx FIFO overrun; resetting\n");
#ifdef __NetBSD__
s = splnet();
#endif
- ath_reset(ifp);
+ ath_reset(sc);
#ifdef __NetBSD__
splx(s);
#endif
@@ -916,31 +988,9 @@
NET_LOCK_GIANT_FUNC_INIT();
DPRINTF(sc, ATH_DEBUG_ANY, "%s: pending %u\n", __func__, pending);
- KASSERTMSG(ic->ic_opmode == IEEE80211_M_STA,
- "unexpect operating mode %u", ic->ic_opmode);
- if (ic->ic_state == IEEE80211_S_RUN) {
- u_int64_t lastrx = sc->sc_lastrx;
- u_int64_t tsf = ath_hal_gettsf64(sc->sc_ah);
-
- DPRINTF(sc, ATH_DEBUG_BEACON,
- "%s: tsf %" PRIu64 " lastrx %" PRId64
- " (%" PRIu64 ") bmiss %u\n",
- __func__, tsf, tsf - lastrx, lastrx,
- ic->ic_bmisstimeout*1024);
- /*
- * Workaround phantom bmiss interrupts by sanity-checking
- * the time of our last rx'd frame. If it is within the
- * beacon miss interval then ignore the interrupt. If it's
- * truly a bmiss we'll get another interrupt soon and that'll
- * be dispatched up for processing.
- */
- if (tsf - lastrx > ic->ic_bmisstimeout*1024) {
- NET_LOCK_GIANT();
- ieee80211_beacon_miss(ic);
- NET_UNLOCK_GIANT();
- } else
- sc->sc_stats.ast_bmiss_phantom++;
- }
+ NET_LOCK_GIANT();
+ ieee80211_beacon_miss(ic);
+ NET_UNLOCK_GIANT();
}
static void
@@ -948,12 +998,11 @@
{
#if 0
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
struct ath_hal *ah = sc->sc_ah;
HAL_CHANNEL hchan;
if (ath_hal_procdfs(ah, &hchan)) {
- if_printf(ifp, "radar detected on channel %u/0x%x/0x%x\n",
+ device_printf(sc->sc_dev, "radar detected on channel %u/0x%x/0x%x\n",
hchan.channel, hchan.channelFlags, hchan.privFlags);
/*
* Initiate channel change.
@@ -976,7 +1025,7 @@
CHANNEL_ST, /* IEEE80211_MODE_TURBO_A */
CHANNEL_108G /* IEEE80211_MODE_TURBO_G */
};
- enum ieee80211_phymode mode = ieee80211_chan2mode(ic, chan);
+ enum ieee80211_phymode mode = ieee80211_chan2mode(chan);
KASSERTMSG(mode < N(modeflags), "unexpected phy mode %u", mode);
KASSERTMSG(modeflags[mode] != 0, "mode %u undefined", mode);
@@ -984,28 +1033,20 @@
#undef N
}
-static int
-ath_ifinit(struct ifnet *ifp)
-{
- struct ath_softc *sc = (struct ath_softc *)ifp->if_softc;
-
- return ath_init(sc);
-}
-
static void
ath_settkipmic(struct ath_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
- if ((ic->ic_caps & IEEE80211_C_TKIP) &&
- !(ic->ic_caps & IEEE80211_C_WME_TKIPMIC)) {
+ if ((ic->ic_cryptocaps & IEEE80211_CRYPTO_TKIP) &&
+ !(sc->sc_flags & ATH_WMETKIPMIC)) {
if (ic->ic_flags & IEEE80211_F_WME) {
(void)ath_hal_settkipmic(ah, AH_FALSE);
- ic->ic_caps &= ~IEEE80211_C_TKIPMIC;
+ ic->ic_cryptocaps &= ~IEEE80211_CRYPTO_TKIPMIC;
} else {
(void)ath_hal_settkipmic(ah, AH_TRUE);
- ic->ic_caps |= IEEE80211_C_TKIPMIC;
+ ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIPMIC;
}
}
}
@@ -1013,15 +1054,11 @@
static int
ath_init(struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
HAL_STATUS status;
int error = 0, s;
- DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags 0x%x\n",
- __func__, ifp->if_flags);
-
if (device_is_active(sc->sc_dev)) {
s = splnet();
} else if (!pmf_device_subtree_resume(sc->sc_dev, &sc->sc_qual) ||
@@ -1034,7 +1071,7 @@
* Stop anything previously setup. This is safe
* whether this is the first time through or not.
*/
- ath_stop_locked(ifp, 0);
+ ath_stop_locked(sc, 0);
/*
* The basic interface to setting the hardware in a good
@@ -1046,8 +1083,9 @@
ath_settkipmic(sc);
sc->sc_curchan.channel = ic->ic_curchan->ic_freq;
sc->sc_curchan.channelFlags = ath_chan2flags(ic, ic->ic_curchan);
- if (!ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, AH_FALSE, &status)) {
- if_printf(ifp, "unable to reset hardware; hal status %u\n",
+ if (!ath_hal_reset(ah, ath_convert_opmode(ic->ic_opmode),
+ &sc->sc_curchan, AH_FALSE, &status)) {
+ device_printf(sc->sc_dev, "unable to reset hardware; hal status %u\n",
status);
error = EIO;
goto done;
@@ -1074,7 +1112,7 @@
* here except setup the interrupt mask.
*/
if ((error = ath_startrecv(sc)) != 0) {
- if_printf(ifp, "unable to start recv logic\n");
+ device_printf(sc->sc_dev, "unable to start recv logic\n");
goto done;
}
@@ -1092,9 +1130,6 @@
sc->sc_imask |= HAL_INT_MIB;
ath_hal_intrset(ah, sc->sc_imask);
- ifp->if_flags |= IFF_RUNNING;
- ic->ic_state = IEEE80211_S_INIT;
-
/*
* The hardware should be ready to go now so it's safe
* to kick the 802.11 state machine as it's likely to
@@ -1106,91 +1141,77 @@
sc->sc_tx99->start(sc->sc_tx99);
else
#endif
- if (ic->ic_opmode != IEEE80211_M_MONITOR) {
- if (ic->ic_roaming != IEEE80211_ROAMING_MANUAL)
- ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
- } else
- ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
done:
splx(s);
return error;
}
static void
-ath_stop_locked(struct ifnet *ifp, int disable)
+ath_stop_locked(struct ath_softc *sc, int disable)
{
- struct ath_softc *sc = ifp->if_softc;
- struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
- DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid %d if_flags 0x%x\n",
- __func__, !device_is_enabled(sc->sc_dev), ifp->if_flags);
/* KASSERT() IPL_NET */
- if (ifp->if_flags & IFF_RUNNING) {
- /*
- * Shutdown the hardware and driver:
- * reset 802.11 state machine
- * turn off timers
- * disable interrupts
- * turn off the radio
- * clear transmit machinery
- * clear receive machinery
- * drain and release tx queues
- * reclaim beacon resources
- * power down hardware
- *
- * Note that some of this work is not possible if the
- * hardware is gone (invalid).
- */
+ /*
+ * Shutdown the hardware and driver:
+ * reset 802.11 state machine
+ * turn off timers
+ * disable interrupts
+ * turn off the radio
+ * clear transmit machinery
+ * clear receive machinery
+ * drain and release tx queues
+ * reclaim beacon resources
+ * power down hardware
+ *
+ * Note that some of this work is not possible if the
+ * hardware is gone (invalid).
+ */
#ifdef ATH_TX99_DIAG
- if (sc->sc_tx99 != NULL)
- sc->sc_tx99->stop(sc->sc_tx99);
+ if (sc->sc_tx99 != NULL)
+ sc->sc_tx99->stop(sc->sc_tx99);
#endif
- ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
- ifp->if_flags &= ~IFF_RUNNING;
- ifp->if_timer = 0;
- if (device_is_enabled(sc->sc_dev)) {
- if (sc->sc_softled) {
- callout_stop(&sc->sc_ledtimer);
- ath_hal_gpioset(ah, sc->sc_ledpin,
+ if (device_is_enabled(sc->sc_dev)) {
+ callout_stop(&sc->sc_watchdog_ch);
+ if (sc->sc_softled) {
+ callout_stop(&sc->sc_ledtimer);
+ ath_hal_gpioset(ah, sc->sc_ledpin,
!sc->sc_ledon);
- sc->sc_blinking = 0;
- }
- ath_hal_intrset(ah, 0);
+ sc->sc_blinking = 0;
}
- ath_draintxq(sc);
- if (device_is_enabled(sc->sc_dev)) {
- ath_stoprecv(sc);
- ath_hal_phydisable(ah);
- } else
- sc->sc_rxlink = NULL;
- IF_PURGE(&ifp->if_snd);
- ath_beacon_free(sc);
+ ath_hal_intrset(ah, 0);
}
+ ath_draintxq(sc);
+ if (device_is_enabled(sc->sc_dev)) {
+ ath_stoprecv(sc);
+ ath_hal_phydisable(ah);
+ } else
+ sc->sc_rxlink = NULL;
+ ath_beacon_free(sc);
if (disable)
pmf_device_suspend(sc->sc_dev, &sc->sc_qual);
}
static void
-ath_stop(struct ifnet *ifp, int disable)
+ath_stop(struct ath_softc *sc, int disable)
{
int s;
s = splnet();
- ath_stop_locked(ifp, disable);
+ ath_stop_locked(sc, disable);
splx(s);
}
static void
ath_restore_diversity(struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
struct ath_hal *ah = sc->sc_ah;
if (!ath_hal_setdiversity(sc->sc_ah, sc->sc_diversity) ||
sc->sc_diversity != ath_hal_getdiversity(ah)) {
- if_printf(ifp, "could not restore diversity setting %d\n",
+ device_printf(sc->sc_dev,
+ "could not restore diversity setting %d\n",
sc->sc_diversity);
sc->sc_diversity = ath_hal_getdiversity(ah);
}
@@ -1204,9 +1225,8 @@
* to reset or reload hardware state.
*/
int
-ath_reset(struct ifnet *ifp)
+ath_reset(struct ath_softc *sc)
{
- struct ath_softc *sc = ifp->if_softc;
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
struct ieee80211_channel *c;
@@ -1225,26 +1245,30 @@
ath_stoprecv(sc); /* stop recv side */
ath_settkipmic(sc); /* configure TKIP MIC handling */
/* NB: indicate channel change so we do a full reset */
- if (!ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, AH_TRUE, &status))
- if_printf(ifp, "%s: unable to reset hardware; hal status %u\n",
+ if (!ath_hal_reset(ah, ath_convert_opmode(ic->ic_opmode),
+ &sc->sc_curchan, AH_TRUE, &status))
+ device_printf(sc->sc_dev, "%s: unable to reset hardware; hal status %u\n",
__func__, status);
ath_update_txpow(sc); /* update tx power state */
ath_restore_diversity(sc);
sc->sc_calinterval = 1;
sc->sc_caltries = 0;
if (ath_startrecv(sc) != 0) /* restart recv */
- if_printf(ifp, "%s: unable to start recv logic\n", __func__);
+ device_printf(sc->sc_dev, "%s: unable to start recv logic\n", __func__);
/*
* We may be doing a reset in response to an ioctl
* that changes the channel so update any state that
* might change as a result.
*/
ath_chan_change(sc, c);
+#if 0
+ /* XXX */
if (ic->ic_state == IEEE80211_S_RUN)
ath_beacon_config(sc); /* restart beacons */
+#endif
ath_hal_intrset(ah, sc->sc_imask);
- ath_start(ifp); /* restart xmit */
+ ath_start(sc); /* restart xmit */
return 0;
}
@@ -1264,7 +1288,7 @@
while ((bf = STAILQ_FIRST(frags)) != NULL) {
STAILQ_REMOVE_HEAD(frags, bf_list);
STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
+ sc->sc_flags &= ~ATH_OACTIVE;
ieee80211_node_decref(ni);
}
}
@@ -1287,7 +1311,7 @@
if (bf == NULL) { /* out of buffers, cleanup */
DPRINTF(sc, ATH_DEBUG_XMIT, "%s: out of xmit buffers\n",
__func__);
- sc->sc_if.if_flags |= IFF_OACTIVE;
+ sc->sc_flags |= ATH_OACTIVE;
ath_txfrag_cleanup(sc, frags, ni);
break;
}
@@ -1301,22 +1325,13 @@
}
static void
-ath_start(struct ifnet *ifp)
+ath_start(struct ath_softc *sc)
{
- struct ath_softc *sc = ifp->if_softc;
- struct ath_hal *ah = sc->sc_ah;
- struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211_node *ni;
struct ath_buf *bf;
struct mbuf *m, *next;
- struct ieee80211_frame *wh;
- struct ether_header *eh;
ath_bufhead frags;
- if ((ifp->if_flags & IFF_RUNNING) == 0 ||
- !device_is_active(sc->sc_dev))
- return;
-
if (sc->sc_flags & ATH_KEY_UPDATING)
return;
@@ -1333,136 +1348,51 @@
DPRINTF(sc, ATH_DEBUG_XMIT, "%s: out of xmit buffers\n",
__func__);
sc->sc_stats.ast_tx_qstop++;
- ifp->if_flags |= IFF_OACTIVE;
+ sc->sc_flags |= ATH_OACTIVE;
+ break;
+ }
+
+ IFQ_DEQUEUE(&sc->sc_sendq, m);
+ if (m == NULL) {
+ ATH_TXBUF_LOCK(sc);
+ STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);
+ ATH_TXBUF_UNLOCK(sc);
break;
}
+ STAILQ_INIT(&frags);
/*
- * Poll the management queue for frames; they
- * have priority over normal data frames.
+ * Hack! The referenced node pointer is in the
+ * rcvif field of the packet header. This is
+ * placed there by ieee80211_vap_pkt_send_dest
+ * because we need to hold the reference with the
+ * frame and there's no other way (other than
+ * packet tags which we consider too expensive to
+ * use) to pass it along.
*/
- IF_DEQUEUE(&ic->ic_mgtq, m);
- if (m == NULL) {
- /*
- * No data frames go out unless we're associated.
- */
- if (ic->ic_state != IEEE80211_S_RUN) {
- DPRINTF(sc, ATH_DEBUG_XMIT,
- "%s: discard data packet, state %s\n",
- __func__,
- ieee80211_state_name[ic->ic_state]);
- sc->sc_stats.ast_tx_discard++;
- ATH_TXBUF_LOCK(sc);
- STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);