-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathathn-progress.patch
2606 lines (2412 loc) · 72.3 KB
/
athn-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_athn_cardbus.c
--- a/sys/dev/cardbus/if_athn_cardbus.c Sun Jul 30 21:50:13 2023 -0700
+++ b/sys/dev/cardbus/if_athn_cardbus.c Wed Aug 02 16:31:26 2023 +1200
@@ -179,7 +179,7 @@
if (pmf_device_register(self,
athn_cardbus_suspend, athn_cardbus_resume)) {
- pmf_class_network_register(self, &sc->sc_if);
+ /* 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/arn5008.c
--- a/sys/dev/ic/arn5008.c Sun Jul 30 21:50:13 2023 -0700
+++ b/sys/dev/ic/arn5008.c Wed Aug 02 16:31:26 2023 +1200
@@ -56,8 +56,8 @@
#include <net80211/ieee80211_netbsd.h>
#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_amrr.h>
#include <net80211/ieee80211_radiotap.h>
+#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
#include <dev/ic/athnreg.h>
@@ -118,8 +118,8 @@
Static void ar5008_set_spur_immunity_level(struct athn_softc *, int);
Static void ar5008_swap_rom(struct athn_softc *);
Static int ar5008_swba_intr(struct athn_softc *);
-Static int ar5008_tx(struct athn_softc *, struct mbuf *,
- struct ieee80211_node *, int);
+Static int ar5008_tx(struct ieee80211_node *, struct mbuf *,
+ const struct ieee80211_bpf_params *);
Static int ar5008_tx_alloc(struct athn_softc *);
Static void ar5008_tx_free(struct athn_softc *);
Static void ar5008_tx_intr(struct athn_softc *);
@@ -789,14 +789,15 @@
ar5008_rx_process(struct athn_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
struct athn_rxq *rxq = &sc->sc_rxq[0];
struct athn_rx_buf *bf, *nbf;
struct ar_rx_desc *ds;
struct ieee80211_frame *wh;
struct ieee80211_node *ni;
struct mbuf *m, *m1;
- u_int32_t rstamp;
+ struct ifnet *ifp;
+ /* XXX Do we need rstamp? */
+ //u_int32_t rstamp;
int error, len, rssi, s;
bf = SIMPLEQ_FIRST(&rxq->head);
@@ -806,6 +807,19 @@
}
ds = bf->bf_desc;
+ /* XXX refactored dma syncs. I think the old code was incorrect */
+ bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, ATHN_RXBUFSZ,
+ BUS_DMASYNC_POSTREAD);
+
+ m = bf->bf_m;
+ /* Grab a reference to the source node. */
+ wh = mtod(m, struct ieee80211_frame *);
+ ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
+ if (ni)
+ ifp = ni->ni_vap->iv_ifp;
+ else
+ ifp = NULL;
+
if (!(ds->ds_status8 & AR_RXS8_DONE)) {
/*
* On some parts, the status words can get corrupted
@@ -824,16 +838,20 @@
/* HW will not "move" RXDP in this case, so do it. */
AR_WRITE(sc, AR_RXDP, nbf->bf_daddr);
AR_WRITE_BARRIER(sc);
- if_statinc(ifp, if_ierrors);
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
+ bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, ATHN_RXBUFSZ,
+ BUS_DMASYNC_PREREAD);
return EBUSY;
}
if (__predict_false(ds->ds_status1 & AR_RXS1_MORE)) {
/* Drop frames that span multiple Rx descriptors. */
DPRINTFN(DBG_RX, sc, "dropping split frame\n");
- if_statinc(ifp, if_ierrors);
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
if (!(ds->ds_status8 & AR_RXS8_FRAME_OK)) {
@@ -848,36 +866,39 @@
DPRINTFN(DBG_RX, sc, "Michael MIC failure\n");
len = MS(ds->ds_status1, AR_RXS1_DATA_LEN);
- m = bf->bf_m;
- m_set_rcvif(m, ifp);
+ if (ifp)
+ m_set_rcvif(m, ifp);
m->m_pkthdr.len = m->m_len = len;
wh = mtod(m, struct ieee80211_frame *);
/* Report Michael MIC failures to net80211. */
- ieee80211_notify_michael_failure(ic, wh, 0 /* XXX: keyix */);
+ if (ni)
+ ieee80211_notify_michael_failure(ni->ni_vap, wh, 0 /* XXX: keyix */);
}
- if_statinc(ifp, if_ierrors);
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
len = MS(ds->ds_status1, AR_RXS1_DATA_LEN);
if (__predict_false(len < (int)IEEE80211_MIN_LEN || len > ATHN_RXBUFSZ)) {
DPRINTFN(DBG_RX, sc, "corrupted descriptor length=%d\n", len);
- if_statinc(ifp, if_ierrors);
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
/* Allocate a new Rx buffer. */
m1 = MCLGETI(NULL, M_DONTWAIT, NULL, ATHN_RXBUFSZ);
if (__predict_false(m1 == NULL)) {
- ic->ic_stats.is_rx_nobuf++;
- if_statinc(ifp, if_ierrors);
+ /* XXX */
+ //ic->ic_stats.is_rx_nobuf++;
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
- /* Sync and unmap the old Rx buffer. */
- bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, ATHN_RXBUFSZ,
- BUS_DMASYNC_POSTREAD);
+ /* Unmap the old Rx buffer. */
bus_dmamap_unload(sc->sc_dmat, bf->bf_map);
/* Map the new Rx buffer. */
@@ -891,28 +912,25 @@
mtod(bf->bf_m, void *), ATHN_RXBUFSZ, NULL,
BUS_DMA_NOWAIT | BUS_DMA_READ);
KASSERT(error != 0);
- if_statinc(ifp, if_ierrors);
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
- bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, ATHN_RXBUFSZ,
- BUS_DMASYNC_PREREAD);
-
/* Write physical address of new Rx buffer. */
ds->ds_data = bf->bf_map->dm_segs[0].ds_addr;
- m = bf->bf_m;
bf->bf_m = m1;
/* Finalize mbuf. */
- m_set_rcvif(m, ifp);
+ if (ifp)
+ m_set_rcvif(m, ifp);
m->m_pkthdr.len = m->m_len = len;
s = splnet();
- /* Grab a reference to the source node. */
+ /* Get the packet again since length has changed */
wh = mtod(m, struct ieee80211_frame *);
- ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
/* Remove any HW padding after the 802.11 header. */
if (!(wh->i_fc[0] & IEEE80211_FC0_TYPE_CTL)) {
@@ -930,15 +948,20 @@
/* Send the frame to the 802.11 layer. */
rssi = MS(ds->ds_status4, AR_RXS4_RSSI_COMBINED);
- rstamp = ds->ds_status2;
- ieee80211_input(ic, m, ni, rssi, rstamp);
-
- /* Node is no longer needed. */
- ieee80211_free_node(ni);
+ /* XXX */
+ //rstamp = ds->ds_status2;
+
+ ieee80211_rx_enqueue(ic, m, rssi);
splx(s);
skip:
+
+ if (ni)
+ ieee80211_free_node(ni);
+
+ bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, ATHN_RXBUFSZ,
+ BUS_DMASYNC_PREREAD);
/* Unlink this descriptor from head. */
SIMPLEQ_REMOVE_HEAD(&rxq->head, bf_list);
memset(&ds->ds_status0, 0, 36); /* XXX Really needed? */
@@ -970,16 +993,18 @@
Static int
ar5008_tx_process(struct athn_softc *sc, int qid)
{
- struct ifnet *ifp = &sc->sc_if;
struct athn_txq *txq = &sc->sc_txq[qid];
- struct athn_node *an;
+ struct ieee80211_ratectl_tx_status txs;
+ struct ieee80211_node *ni;
struct athn_tx_buf *bf;
struct ar_tx_desc *ds;
- uint8_t failcnt;
+ struct ifnet *ifp = NULL;
bf = SIMPLEQ_FIRST(&txq->head);
if (bf == NULL)
return ENOENT;
+ if (bf->bf_ni)
+ ifp = bf->bf_ni->ni_vap->iv_ifp;
/* Get descriptor of last DMA segment. */
ds = &((struct ar_tx_desc *)bf->bf_descs)[bf->bf_map->dm_nsegs - 1];
@@ -987,33 +1012,39 @@
return EBUSY;
SIMPLEQ_REMOVE_HEAD(&txq->head, bf_list);
- if_statinc(ifp, if_opackets);
sc->sc_tx_timer = 0;
- if (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES)
+ if (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES && ifp)
if_statinc(ifp, if_oerrors);
if (ds->ds_status1 & AR_TXS1_UNDERRUN)
athn_inc_tx_trigger_level(sc);
- an = (struct athn_node *)bf->bf_ni;
+ ni = bf->bf_ni;
+
+ /* Update rate control statistics. */
+ txs.flags =
+ IEEE80211_RATECTL_STATUS_SHORT_RETRY |
+ IEEE80211_RATECTL_STATUS_LONG_RETRY;
+ if (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES)
+ /* XXX Short or long? */
+ txs.status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
+ else
+ txs.status = IEEE80211_RATECTL_TX_SUCCESS;
/*
* NB: the data fail count contains the number of un-acked tries
* for the final series used. We must add the number of tries for
* each series that was fully processed.
*/
- failcnt = MS(ds->ds_status1, AR_TXS1_DATA_FAIL_CNT);
- /* NB: Assume two tries per series. */
- failcnt += MS(ds->ds_status9, AR_TXS9_FINAL_IDX) * 2;
-
- /* Update rate control statistics. */
- an->amn.amn_txcnt++;
- if (failcnt > 0)
- an->amn.amn_retrycnt++;
+ /* XXX Old code only increments amn_retrycnt once? */
+ txs.short_retries = MS(ds->ds_status1, AR_TXS1_DATA_FAIL_CNT);
+ /* NB: Assume two tries per series. Should this still be done? */
+ txs.long_retries = MS(ds->ds_status9, AR_TXS9_FINAL_IDX) * 2;
+ ieee80211_ratectl_tx_complete(ni, &txs);
DPRINTFN(DBG_TX, sc, "Tx done qid=%d status1=%d fail count=%d\n",
- qid, ds->ds_status1, failcnt);
+ qid, ds->ds_status1, txs.short_retries + txs.long_retries);
bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, bf->bf_map->dm_mapsize,
BUS_DMASYNC_POSTWRITE);
@@ -1032,7 +1063,6 @@
Static void
ar5008_tx_intr(struct athn_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
uint16_t mask = 0;
uint32_t reg;
int qid, s;
@@ -1053,8 +1083,8 @@
while (ar5008_tx_process(sc, qid) == 0);
}
if (!SIMPLEQ_EMPTY(&sc->sc_txbufs)) {
- ifp->if_flags &= ~IFF_OACTIVE;
- ifp->if_start(ifp); /* in softint */
+ sc->sc_flags &= ~ATHN_FLAG_TX_BUSY;
+ athn_start(sc); /* XXX safe to just call athn_start? */
}
splx(s);
@@ -1068,26 +1098,28 @@
ar5008_swba_intr(struct athn_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
- struct ieee80211_node *ni = ic->ic_bss;
struct athn_tx_buf *bf = sc->sc_bcnbuf;
struct ieee80211_frame *wh;
- struct ieee80211_beacon_offsets bo;
+ struct ieee80211vap *vap;
struct ar_tx_desc *ds;
struct mbuf *m;
uint8_t ridx, hwrate;
int error, totlen;
+ /* XXX When we add multi vap support this will need
+ to be done for all vaps which require beacons */
+ vap = TAILQ_FIRST(&ic->ic_vaps);
+
#if notyet
if (ic->ic_tim_mcast_pending &&
IF_IS_EMPTY(&ni->ni_savedq) &&
SIMPLEQ_EMPTY(&sc->sc_txq[ATHN_QID_CAB].head))
ic->ic_tim_mcast_pending = 0;
#endif
- if (ic->ic_dtim_count == 0)
- ic->ic_dtim_count = ic->ic_dtim_period - 1;
+ if (vap->iv_dtim_count == 0)
+ vap->iv_dtim_count = vap->iv_dtim_period - 1;
else
- ic->ic_dtim_count--;
+ vap->iv_dtim_count--;
/* Make sure previous beacon has been sent. */
if (athn_tx_pending(sc, ATHN_QID_BEACON)) {
@@ -1095,15 +1127,15 @@
return EBUSY;
}
/* Get new beacon. */
- m = ieee80211_beacon_alloc(ic, ic->ic_bss, &bo);
+ m = ieee80211_beacon_alloc(vap->iv_bss);
if (__predict_false(m == NULL))
return ENOBUFS;
/* Assign sequence number. */
/* XXX: use non-QoS tid? */
wh = mtod(m, struct ieee80211_frame *);
*(uint16_t *)&wh->i_seq[0] =
- htole16(ic->ic_bss->ni_txseqs[0] << IEEE80211_SEQ_SEQ_SHIFT);
- ic->ic_bss->ni_txseqs[0]++;
+ htole16(vap->iv_bss->ni_txseqs[0] << IEEE80211_SEQ_SEQ_SHIFT);
+ vap->iv_bss->ni_txseqs[0]++;
/* Unmap and free old beacon if any. */
if (__predict_true(bf->bf_m != NULL)) {
@@ -1158,25 +1190,32 @@
AR_WRITE(sc, AR_QTXDP(ATHN_QID_BEACON), bf->bf_daddr);
- for(;;) {
- if (SIMPLEQ_EMPTY(&sc->sc_txbufs))
- break;
-
- IF_DEQUEUE(&ni->ni_savedq, m);
- if (m == NULL)
- break;
- if (!IF_IS_EMPTY(&ni->ni_savedq)) {
- /* more queued frames, set the more data bit */
- wh = mtod(m, struct ieee80211_frame *);
- wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA;
- }
-
- if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) {
- ieee80211_free_node(ni);
- if_statinc(ifp, if_oerrors);
- break;
- }
- }
+ /* XXX Fairly certain sure we no longer need this, power save queue
+ appears to be handled by 802.11 layer */
+
+ /* XXX We need to add an ifq to the softc for sending multicast and
+ * broadcast frames in the cab q */
+
+
+ /* for(;;) { */
+ /* if (SIMPLEQ_EMPTY(&sc->sc_txbufs)) */
+ /* break; */
+
+ /* IF_DEQUEUE(&ni->ni_savedq, m); */
+ /* if (m == NULL) */
+ /* break; */
+ /* if (!IF_IS_EMPTY(&ni->ni_savedq)) { */
+ /* /\* more queued frames, set the more data bit *\/ */
+ /* wh = mtod(m, struct ieee80211_frame *); */
+ /* wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; */
+ /* } */
+
+ /* if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) { */
+ /* ieee80211_free_node(ni); */
+ /* if_statinc(ifp, if_oerrors); */
+ /* break; */
+ /* } */
+ /* } */
/* Kick Tx. */
AR_WRITE(sc, AR_Q_TXE, 1 << ATHN_QID_BEACON);
@@ -1305,12 +1344,14 @@
}
Static int
-ar5008_tx(struct athn_softc *sc, struct mbuf *m, struct ieee80211_node *ni,
- int txflags)
+ar5008_tx(struct ieee80211_node *ni, struct mbuf *m,
+ const struct ieee80211_bpf_params *params)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = ni->ni_ic;
+ struct athn_softc *sc = ic->ic_softc;
struct ieee80211_key *k = NULL;
struct ieee80211_frame *wh;
+ struct ieee80211vap *vap = ni->ni_vap;
struct athn_series series[4];
struct ar_tx_desc *ds, *lastds;
struct athn_txq *txq;
@@ -1348,7 +1389,7 @@
type = AR_FRAME_TYPE_NORMAL;
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
- k = ieee80211_crypto_encap(ic, ni, m);
+ k = ieee80211_crypto_encap(ni, m);
if (k == NULL)
return ENOBUFS;
@@ -1375,10 +1416,20 @@
qos = 0;
qid = ATHN_QID_PSPOLL;
}
+ /* XXX Must come up with alternative for detecting CAB frames
+ * From what the data sheet says, it seems there are different
+ * qualifiers for what counts as a cab frame depending on our
+ * mode:
+ * 1. Host mode - CAB frames are multicast frames or broadcast frames (when at least 1 station is sleeping)
+ * This is the condition used by FreeBSD:
+ * if (ismcast && sc_cabq_enable && (vap->iv_ps_sta || avp->av_mcastq.axq_depth)
+ * 2. IBSS mode - CAB frames are ATIM and their associated data frames
+
else if (txflags & ATHN_TXFLAG_CAB) {
qos = 0;
qid = ATHN_QID_CAB;
}
+ */
else {
qos = 0;
qid = ATHN_QID_AC_BE;
@@ -1394,13 +1445,15 @@
(ic->ic_curmode == IEEE80211_MODE_11A) ?
ATHN_RIDX_OFDM6 : ATHN_RIDX_CCK1;
}
+#ifdef notyet
else if (ic->ic_fixed_rate != -1) {
/* Use same fixed rate for all tries. */
ridx[0] = ridx[1] = ridx[2] = ridx[3] =
sc->sc_fixed_ridx;
}
+#endif
else {
- int txrate = ni->ni_txrate;
+ int txrate = an->txrate;
/* Use fallback table of the node. */
for (i = 0; i < 4; i++) {
ridx[i] = an->ridx[txrate];
@@ -1467,7 +1520,10 @@
}
bf->bf_m = m;
bf->bf_ni = ni;
+
+ /* XXX see above comment regarding cabq
bf->bf_txflags = txflags;
+ */
wh = mtod(m, struct ieee80211_frame *);
@@ -1486,7 +1542,7 @@
ds->ds_ctl1 = SM(AR_TXC1_FRAME_TYPE, type);
if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
- (hasqos && (qos & IEEE80211_QOS_ACKPOLICY_MASK) ==
+ (hasqos && (qos & IEEE80211_QOS_ACKPOLICY) ==
IEEE80211_QOS_ACKPOLICY_NOACK))
ds->ds_ctl1 |= AR_TXC1_NO_ACK;
#if notyet
@@ -1528,7 +1584,7 @@
/* Check if frame must be protected using RTS/CTS or CTS-to-self. */
if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
/* NB: Group frames are sent using CCK in 802.11b/g. */
- if (totlen > ic->ic_rtsthreshold) {
+ if (totlen > vap->iv_rtsthreshold) {
ds->ds_ctl0 |= AR_TXC0_RTS_ENABLE;
}
else if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
diff -r f00ade18273e sys/dev/ic/arn5416.c
--- a/sys/dev/ic/arn5416.c Sun Jul 30 21:50:13 2023 -0700
+++ b/sys/dev/ic/arn5416.c Wed Aug 02 16:31:26 2023 +1200
@@ -56,8 +56,8 @@
#include <net80211/ieee80211_netbsd.h>
#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_amrr.h>
#include <net80211/ieee80211_radiotap.h>
+#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
#include <dev/ic/athnreg.h>
diff -r f00ade18273e sys/dev/ic/arn9003.c
--- a/sys/dev/ic/arn9003.c Sun Jul 30 21:50:13 2023 -0700
+++ b/sys/dev/ic/arn9003.c Wed Aug 02 16:31:26 2023 +1200
@@ -57,8 +57,8 @@
#include <net80211/ieee80211_netbsd.h>
#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_amrr.h>
#include <net80211/ieee80211_radiotap.h>
+#include <net80211/ieee80211_ratectl.h>
#include <net80211/ieee80211_regdomain.h>
#include <dev/ic/athnreg.h>
@@ -70,8 +70,6 @@
Static void ar9003_calib_iq(struct athn_softc *);
Static int ar9003_calib_tx_iq(struct athn_softc *);
-Static int ar9003_compute_predistortion(struct athn_softc *,
- const uint32_t *, const uint32_t *);
Static void ar9003_disable_ofdm_weak_signal(struct athn_softc *);
Static void ar9003_disable_phy(struct athn_softc *);
Static int ar9003_dma_alloc(struct athn_softc *);
@@ -80,10 +78,7 @@
Static void ar9003_do_noisefloor_calib(struct athn_softc *);
Static void ar9003_enable_antenna_diversity(struct athn_softc *);
Static void ar9003_enable_ofdm_weak_signal(struct athn_softc *);
-Static void ar9003_enable_predistorter(struct athn_softc *, int);
Static int ar9003_find_rom(struct athn_softc *);
-Static void ar9003_force_txgain(struct athn_softc *, uint32_t);
-Static int ar9003_get_desired_txgain(struct athn_softc *, int, int);
Static int ar9003_get_iq_corr(struct athn_softc *, int32_t[], int32_t[]);
Static void ar9003_gpio_config_input(struct athn_softc *, int);
Static void ar9003_gpio_config_output(struct athn_softc *, int, int);
@@ -96,9 +91,6 @@
Static int ar9003_intr_status(struct athn_softc *);
Static int ar9003_intr(struct athn_softc *);
Static void ar9003_next_calib(struct athn_softc *);
-Static void ar9003_paprd_enable(struct athn_softc *);
-Static int ar9003_paprd_tx_tone(struct athn_softc *);
-Static void ar9003_paprd_tx_tone_done(struct athn_softc *);
Static int ar9003_read_eep_data(struct athn_softc *, uint32_t, void *,
int);
Static int ar9003_read_eep_word(struct athn_softc *, uint32_t,
@@ -135,10 +127,9 @@
struct ieee80211_channel *);
Static void ar9003_set_rxchains(struct athn_softc *);
Static void ar9003_set_spur_immunity_level(struct athn_softc *, int);
-Static void ar9003_set_training_gain(struct athn_softc *, int);
Static int ar9003_swba_intr(struct athn_softc *);
-Static int ar9003_tx(struct athn_softc *, struct mbuf *,
- struct ieee80211_node *, int);
+Static int ar9003_tx(struct ieee80211_node *, struct mbuf *,
+ const struct ieee80211_bpf_params *);
Static int ar9003_tx_alloc(struct athn_softc *);
Static void ar9003_tx_free(struct athn_softc *);
Static void ar9003_tx_intr(struct athn_softc *);
@@ -937,7 +928,7 @@
ar9003_rx_process(struct athn_softc *sc, int qid)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp;
struct athn_rxq *rxq = &sc->sc_rxq[qid];
struct athn_rx_buf *bf;
struct ar_rx_status *ds;
@@ -945,7 +936,6 @@
struct ieee80211_node *ni;
struct mbuf *m, *m1;
size_t len;
- u_int32_t rstamp;
int error, rssi, s;
bf = SIMPLEQ_FIRST(&rxq->head);
@@ -960,6 +950,15 @@
if (!(ds->ds_status1 & AR_RXS1_DONE))
return EBUSY;
+ m = bf->bf_m;
+ /* Grab a reference to the source node. */
+ wh = mtod(m, struct ieee80211_frame *);
+ ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
+ if (ni)
+ ifp = ni->ni_vap->iv_ifp;
+ else
+ ifp = NULL;
+
/* Check that it is a valid Rx status descriptor. */
if ((ds->ds_info & (AR_RXI_DESC_ID_M | AR_RXI_DESC_TX |
AR_RXI_CTRL_STAT)) != SM(AR_RXI_DESC_ID, AR_VENDOR_ATHEROS))
@@ -978,16 +977,17 @@
/* Report Michael MIC failures to net80211. */
len = MS(ds->ds_status2, AR_RXS2_DATA_LEN);
- m = bf->bf_m;
- m_set_rcvif(m, ifp);
+ if (ifp)
+ m_set_rcvif(m, ifp);
m->m_data = (void *)&ds[1];
m->m_pkthdr.len = m->m_len = len;
wh = mtod(m, struct ieee80211_frame *);
- ieee80211_notify_michael_failure(ic, wh,
- 0 /* XXX: keyix */);
+ if (ni)
+ ieee80211_notify_michael_failure(ni->ni_vap, wh, 0 /* XXX: keyix */);
}
- if_statinc(ifp, if_ierrors);
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
@@ -996,15 +996,18 @@
len > ATHN_RXBUFSZ - sizeof(*ds))) {
DPRINTFN(DBG_RX, sc, "corrupted descriptor length=%zd\n",
len);
- if_statinc(ifp, if_ierrors);
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
/* Allocate a new Rx buffer. */
m1 = MCLGETI(NULL, M_DONTWAIT, NULL, ATHN_RXBUFSZ);
if (__predict_false(m1 == NULL)) {
- ic->ic_stats.is_rx_nobuf++;
- if_statinc(ifp, if_ierrors);
+ /* XXX */
+ //ic->ic_stats.is_rx_nobuf++;
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
@@ -1023,26 +1026,26 @@
BUS_DMA_NOWAIT | BUS_DMA_READ);
KASSERT(error != 0);
bf->bf_daddr = bf->bf_map->dm_segs[0].ds_addr;
- if_statinc(ifp, if_ierrors);
+ if (ifp)
+ if_statinc(ifp, if_ierrors);
goto skip;
}
bf->bf_desc = mtod(m1, struct ar_rx_status *);
bf->bf_daddr = bf->bf_map->dm_segs[0].ds_addr;
- m = bf->bf_m;
bf->bf_m = m1;
/* Finalize mbuf. */
- m_set_rcvif(m, ifp);
+ if (ifp)
+ m_set_rcvif(m, ifp);
/* Strip Rx status descriptor from head. */
m->m_data = (void *)&ds[1];
m->m_pkthdr.len = m->m_len = len;
s = splnet();
- /* Grab a reference to the source node. */
+ /* Get the packet again sice the length has changed. */
wh = mtod(m, struct ieee80211_frame *);
- ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
/* Remove any HW padding after the 802.11 header. */
if (!(wh->i_fc[0] & IEEE80211_FC0_TYPE_CTL)) {
@@ -1059,8 +1062,9 @@
/* Send the frame to the 802.11 layer. */
rssi = MS(ds->ds_status5, AR_RXS5_RSSI_COMBINED);
- rstamp = ds->ds_status3;
- ieee80211_input(ic, m, ni, rssi, rstamp);
+ /* XXX */
+ //rstamp = ds->ds_status3;
+ ieee80211_rx_enqueue(ic, m, rssi);
/* Node is no longer needed. */
ieee80211_free_node(ni);
@@ -1068,6 +1072,10 @@
splx(s);
skip:
+
+ if (ni)
+ ieee80211_free_node(ni);
+
/* Unlink this descriptor from head. */
SIMPLEQ_REMOVE_HEAD(&rxq->head, bf_list);
memset(bf->bf_desc, 0, sizeof(*ds));
@@ -1100,12 +1108,13 @@
Static int
ar9003_tx_process(struct athn_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = NULL;
+ struct ieee80211_ratectl_tx_status txs;
struct athn_txq *txq;
- struct athn_node *an;
+ struct ieee80211_node *ni;
struct athn_tx_buf *bf;
struct ar_tx_status *ds;
- uint8_t qid, failcnt;
+ uint8_t qid;
ds = &((struct ar_tx_status *)sc->sc_txsring)[sc->sc_txscur];
if (!(ds->ds_status8 & AR_TXS8_DONE))
@@ -1128,38 +1137,49 @@
memset(ds, 0, sizeof(*ds));
return 0;
}
+
+ if (bf->bf_ni)
+ ifp = bf->bf_ni->ni_vap->iv_ifp;
+
SIMPLEQ_REMOVE_HEAD(&txq->head, bf_list);
- if_statinc(ifp, if_opackets);
sc->sc_tx_timer = 0;
- if (ds->ds_status3 & AR_TXS3_EXCESSIVE_RETRIES)
+ if (ds->ds_status3 & AR_TXS3_EXCESSIVE_RETRIES && ifp)
if_statinc(ifp, if_oerrors);
if (ds->ds_status3 & AR_TXS3_UNDERRUN)
athn_inc_tx_trigger_level(sc);
+ /* XXX Is paprd used? */
/* Wakeup PA predistortion state machine. */
- if (bf->bf_txflags & ATHN_TXFLAG_PAPRD)
- ar9003_paprd_tx_tone_done(sc);
-
- an = (struct athn_node *)bf->bf_ni;
+ // if (bf->bf_txflags & ATHN_TXFLAG_PAPRD)
+ // ar9003_paprd_tx_tone_done(sc);
+
+ ni = bf->bf_ni;
+
+ /* Update rate control statistics. */
+ txs.flags =
+ IEEE80211_RATECTL_STATUS_SHORT_RETRY |
+ IEEE80211_RATECTL_STATUS_LONG_RETRY;
+ if (ds->ds_status3 & AR_TXS3_EXCESSIVE_RETRIES)
+ /* XXX Short or long? */
+ txs.status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
+ else
+ txs.status = IEEE80211_RATECTL_TX_SUCCESS;
/*
* NB: the data fail count contains the number of un-acked tries
* for the final series used. We must add the number of tries for
* each series that was fully processed.
*/
- failcnt = MS(ds->ds_status3, AR_TXS3_DATA_FAIL_CNT);
- /* NB: Assume two tries per series. */
- failcnt += MS(ds->ds_status8, AR_TXS8_FINAL_IDX) * 2;
-
- /* Update rate control statistics. */
- an->amn.amn_txcnt++;
- if (failcnt > 0)
- an->amn.amn_retrycnt++;
+ /* XXX Old code only increments amn_retrycnt once? */
+ txs.short_retries = MS(ds->ds_status3, AR_TXS3_DATA_FAIL_CNT);
+ /* NB: Assume two tries per series. Should this still be done? */
+ txs.long_retries = MS(ds->ds_status8, AR_TXS8_FINAL_IDX) * 2;
+ ieee80211_ratectl_tx_complete(ni, &txs);
DPRINTFN(DBG_TX, sc, "Tx done qid=%d status3=%d fail count=%d\n",
- qid, ds->ds_status3, failcnt);
+ qid, ds->ds_status3, txs.short_retries + txs.long_retries);
/* Reset Tx status descriptor. */
memset(ds, 0, sizeof(*ds));
@@ -1189,7 +1209,6 @@
Static void
ar9003_tx_intr(struct athn_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
int s;
s = splnet();
@@ -1198,8 +1217,8 @@
continue;
if (!SIMPLEQ_EMPTY(&sc->sc_txbufs)) {
- ifp->if_flags &= ~IFF_OACTIVE;
- ifp->if_start(ifp); /* in softint */
+ sc->sc_flags &= ~ATHN_FLAG_TX_BUSY;
+ athn_start(sc);
}
splx(s);
@@ -1213,27 +1232,29 @@
ar9003_swba_intr(struct athn_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
- struct ieee80211_node *ni = ic->ic_bss;
struct athn_tx_buf *bf = sc->sc_bcnbuf;
struct ieee80211_frame *wh;
- struct ieee80211_beacon_offsets bo;
+ struct ieee80211vap *vap;
struct ar_tx_desc *ds;
struct mbuf *m;
uint32_t sum;
uint8_t ridx, hwrate;
int error, totlen;
+ /* XXX When we add multi vap support this will need
+ to be done for all vaps which require beacons */
+ vap = TAILQ_FIRST(&ic->ic_vaps);
+
#if notyet
if (ic->ic_tim_mcast_pending &&
IF_IS_EMPTY(&ni->ni_savedq) &&
SIMPLEQ_EMPTY(&sc->sc_txq[ATHN_QID_CAB].head))
ic->ic_tim_mcast_pending = 0;
#endif
- if (ic->ic_dtim_count == 0)
- ic->ic_dtim_count = ic->ic_dtim_period - 1;
+ if (vap->iv_dtim_count == 0)
+ vap->iv_dtim_count = vap->iv_dtim_period - 1;
else
- ic->ic_dtim_count--;
+ vap->iv_dtim_count--;
/* Make sure previous beacon has been sent. */
if (athn_tx_pending(sc, ATHN_QID_BEACON)) {
@@ -1241,15 +1262,15 @@
return EBUSY;
}
/* Get new beacon. */
- m = ieee80211_beacon_alloc(ic, ic->ic_bss, &bo);
+ m = ieee80211_beacon_alloc(vap->iv_bss);
if (__predict_false(m == NULL))
return ENOBUFS;
/* Assign sequence number. */
/* XXX: use non-QoS tid? */
wh = mtod(m, struct ieee80211_frame *);
*(uint16_t *)&wh->i_seq[0] =
- htole16(ic->ic_bss->ni_txseqs[0] << IEEE80211_SEQ_SEQ_SHIFT);
- ic->ic_bss->ni_txseqs[0]++;
+ htole16(vap->iv_bss->ni_txseqs[0] << IEEE80211_SEQ_SEQ_SHIFT);
+ vap->iv_bss->ni_txseqs[0]++;
/* Unmap and free old beacon if any. */
if (__predict_true(bf->bf_m != NULL)) {
@@ -1316,25 +1337,31 @@
AR_WRITE(sc, AR_QTXDP(ATHN_QID_BEACON), bf->bf_daddr);
- for(;;) {
- if (SIMPLEQ_EMPTY(&sc->sc_txbufs))
- break;
-
- IF_DEQUEUE(&ni->ni_savedq, m);
- if (m == NULL)
- break;
- if (!IF_IS_EMPTY(&ni->ni_savedq)) {
- /* more queued frames, set the more data bit */
- wh = mtod(m, struct ieee80211_frame *);
- wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA;
- }
-
- if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) {
- ieee80211_free_node(ni);
- if_statinc(ifp, if_oerrors);
- break;
- }
- }
+ /* XXX Fairly certain sure we no longer need this, power save queue
+ appears to be handled by 802.11 layer */
+
+ /* XXX We need to add an ifq to the softc for sending multicast and
+ broadcast frames in the cab q */
+
+ /* for(;;) { */
+ /* if (SIMPLEQ_EMPTY(&sc->sc_txbufs)) */
+ /* break; */
+
+ /* IF_DEQUEUE(&ni->ni_savedq, m); */
+ /* if (m == NULL) */
+ /* break; */
+ /* if (!IF_IS_EMPTY(&ni->ni_savedq)) { */
+ /* /\* more queued frames, set the more data bit *\/ */
+ /* wh = mtod(m, struct ieee80211_frame *); */
+ /* wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; */
+ /* } */
+
+ /* if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) { */
+ /* ieee80211_free_node(ni); */
+ /* if_statinc(ifp, if_oerrors); */
+ /* break; */
+ /* } */
+ /* } */
/* Kick Tx. */
AR_WRITE(sc, AR_Q_TXE, 1 << ATHN_QID_BEACON);
@@ -1457,12 +1484,14 @@
}
Static int
-ar9003_tx(struct athn_softc *sc, struct mbuf *m, struct ieee80211_node *ni,
- int txflags)
+ar9003_tx(struct ieee80211_node *ni, struct mbuf *m,
+ const struct ieee80211_bpf_params *params)
{
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211com *ic = ni->ni_ic;
struct ieee80211_key *k = NULL;
struct ieee80211_frame *wh;
+ struct ieee80211vap *vap = ni->ni_vap;
+ struct athn_softc *sc = ic->ic_softc;
struct athn_series series[4];
struct ar_tx_desc *ds;
struct athn_txq *txq;
@@ -1501,7 +1530,7 @@
type = AR_FRAME_TYPE_NORMAL;
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
- k = ieee80211_crypto_encap(ic, ni, m);
+ k = ieee80211_crypto_encap(ni, m);
if (k == NULL)
return ENOBUFS;
@@ -1528,10 +1557,20 @@
qos = 0;
qid = ATHN_QID_PSPOLL;
}
+ /* XXX Must come up with alternative for detecting CAB frames
+ * From what the data sheet says, it seems there are different
+ * qualifiers for what counts as a cab frame depending on our
+ * mode:
+ * 1. Host mode - CAB frames are multicast frames or broadcast frames (when at least 1 station is sleeping)
+ * This is the condition used by FreeBSD:
+ * if (ismcast && sc_cabq_enable && (vap->iv_ps_sta || avp->av_mcastq.axq_depth)
+ * 2. IBSS mode - CAB frames are ATIM and their associated data frames
+
else if (txflags & ATHN_TXFLAG_CAB) {
qos = 0;
qid = ATHN_QID_CAB;
}
+ */
else {
qos = 0;
qid = ATHN_QID_AC_BE;
@@ -1547,13 +1586,16 @@
(ic->ic_curmode == IEEE80211_MODE_11A) ?
ATHN_RIDX_OFDM6 : ATHN_RIDX_CCK1;
}
+ /* XXX */
+#ifdef notyet
else if (ic->ic_fixed_rate != -1) {
/* Use same fixed rate for all tries. */
ridx[0] = ridx[1] = ridx[2] = ridx[3] =
sc->sc_fixed_ridx;
}
+#endif
else {
- int txrate = ni->ni_txrate;
+ int txrate = an->txrate;
/* Use fallback table of the node. */
for (i = 0; i < 4; i++) {
ridx[i] = an->ridx[txrate];
@@ -1620,7 +1662,9 @@
}
bf->bf_m = m;
bf->bf_ni = ni;
- bf->bf_txflags = txflags;
+ /* XXX see above comment regarding cabq
+ bf->bf_txflags = txflags;
+ */
wh = mtod(m, struct ieee80211_frame *);
@@ -1643,7 +1687,7 @@
ds->ds_ctl12 = SM(AR_TXC12_FRAME_TYPE, type);
if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
- (hasqos && (qos & IEEE80211_QOS_ACKPOLICY_MASK) ==
+ (hasqos && (qos & IEEE80211_QOS_ACKPOLICY) ==
IEEE80211_QOS_ACKPOLICY_NOACK))
ds->ds_ctl12 |= AR_TXC12_NO_ACK;
@@ -1688,7 +1732,7 @@
/* Check if frame must be protected using RTS/CTS or CTS-to-self. */
if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
/* NB: Group frames are sent using CCK in 802.11b/g. */
- if (totlen > ic->ic_rtsthreshold) {