-
Notifications
You must be signed in to change notification settings - Fork 10
/
dhd_linux_rx.c
1711 lines (1528 loc) · 46.6 KB
/
dhd_linux_rx.c
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
/*
* Broadcom Dongle Host Driver (DHD),
* Linux-specific network interface for receive(rx) path
*
* Copyright (C) 2022, Broadcom.
*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to you
* under the terms of the GNU General Public License version 2 (the "GPL"),
* available at http://www.broadcom.com/licenses/GPLv2.php, with the
* following added to such license:
*
* As a special exception, the copyright holders of this software give you
* permission to link this software with independent modules, and to copy and
* distribute the resulting executable under terms of your choice, provided that
* you also meet, for each linked independent module, the terms and conditions of
* the license of that module. An independent module is a module which is not
* derived from this software. The special exception does not apply to any
* modifications of the software.
*
*
* <<Broadcom-WL-IPTag/Open:>>
*
* $Id$
*/
#include <typedefs.h>
#include <linuxver.h>
#include <osl.h>
#ifdef SHOW_LOGTRACE
#include <linux/syscalls.h>
#include <event_log.h>
#endif /* SHOW_LOGTRACE */
#ifdef PCIE_FULL_DONGLE
#include <bcmmsgbuf.h>
#endif /* PCIE_FULL_DONGLE */
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/rtnetlink.h>
#include <linux/etherdevice.h>
#include <linux/random.h>
#include <linux/spinlock.h>
#include <linux/ethtool.h>
#include <linux/fcntl.h>
#include <linux/fs.h>
#include <linux/ip.h>
#include <linux/reboot.h>
#include <linux/notifier.h>
#include <linux/irq.h>
#if defined(CONFIG_TIZEN)
#include <linux/net_stat_tizen.h>
#endif /* CONFIG_TIZEN */
#include <net/addrconf.h>
#include <net/ndisc.h>
#ifdef ENABLE_ADAPTIVE_SCHED
#include <linux/cpufreq.h>
#endif /* ENABLE_ADAPTIVE_SCHED */
#include <linux/rtc.h>
#include <linux/namei.h>
#include <asm/uaccess.h>
#include <asm/unaligned.h>
#include <dhd_linux_priv.h>
#include <epivers.h>
#include <bcmutils.h>
#include <bcmendian.h>
#include <bcmdevs.h>
#include <bcmdevs_legacy.h> /* need to still support chips no longer in trunk firmware */
#include <bcmiov.h>
#include <bcmstdlib_s.h>
#include <ethernet.h>
#include <bcmevent.h>
#include <vlan.h>
#include <802.3.h>
#include <dhd_linux_wq.h>
#include <dhd.h>
#include <dhd_linux.h>
#include <dhd_linux_pktdump.h>
#ifdef DHD_WET
#include <dhd_wet.h>
#endif /* DHD_WET */
#ifdef PCIE_FULL_DONGLE
#include <dhd_flowring.h>
#endif
#include <dhd_bus.h>
#include <dhd_proto.h>
#include <dhd_dbg.h>
#include <dhd_dbg_ring.h>
#include <dhd_debug.h>
#if defined(WL_CFG80211)
#include <wl_cfg80211.h>
#ifdef WL_BAM
#include <wl_bam.h>
#endif /* WL_BAM */
#endif /* WL_CFG80211 */
#ifdef PNO_SUPPORT
#include <dhd_pno.h>
#endif
#ifdef RTT_SUPPORT
#include <dhd_rtt.h>
#endif
#include <dhd_linux_sock_qos.h>
#ifdef CONFIG_COMPAT
#include <linux/compat.h>
#endif
#ifdef DHD_WMF
#include <dhd_wmf_linux.h>
#endif /* DHD_WMF */
#ifdef DHD_L2_FILTER
#include <bcmicmp.h>
#include <bcm_l2_filter.h>
#include <dhd_l2_filter.h>
#endif /* DHD_L2_FILTER */
#ifdef DHD_PSTA
#include <dhd_psta.h>
#endif /* DHD_PSTA */
#ifdef AMPDU_VO_ENABLE
/* XXX: Enabling VO AMPDU to reduce FER */
#include <802.1d.h>
#endif /* AMPDU_VO_ENABLE */
#if defined(DHDTCPACK_SUPPRESS) || defined(DHDTCPSYNC_FLOOD_BLK)
#include <dhd_ip.h>
#endif /* DHDTCPACK_SUPPRESS || DHDTCPSYNC_FLOOD_BLK */
#include <dhd_daemon.h>
#ifdef DHD_PKT_LOGGING
#include <dhd_pktlog.h>
#endif /* DHD_PKT_LOGGING */
#ifdef DHD_4WAYM4_FAIL_DISCONNECT
#include <eapol.h>
#endif /* DHD_4WAYM4_FAIL_DISCONNECT */
#ifdef ENABLE_DHD_GRO
#include <net/sch_generic.h>
#endif /* ENABLE_DHD_GRO */
#ifdef FIX_CPU_MIN_CLOCK
#include <linux/pm_qos.h>
#endif /* FIX_CPU_MIN_CLOCK */
#ifdef PROP_TXSTATUS
#include <wlfc_proto.h>
#include <dhd_wlfc.h>
#endif
#if defined(OEM_ANDROID)
#include <wl_android.h>
#endif
#include <dhd_config.h>
/* RX frame thread priority */
int dhd_rxf_prio = CUSTOM_RXF_PRIO_SETTING;
module_param(dhd_rxf_prio, int, 0);
/* Request scheduling of the bus rx frame */
static void dhd_os_rxflock(dhd_pub_t *pub);
static void dhd_os_rxfunlock(dhd_pub_t *pub);
static int dhd_wl_host_event(dhd_info_t *dhd, int ifidx, void *pktdata, uint16 pktlen,
wl_event_msg_t *event_ptr, void **data_ptr);
static inline int dhd_rxf_enqueue(dhd_pub_t *dhdp, void* skb)
{
uint32 store_idx;
uint32 sent_idx;
if (!skb) {
DHD_ERROR(("dhd_rxf_enqueue: NULL skb!!!\n"));
return BCME_ERROR;
}
dhd_os_rxflock(dhdp);
store_idx = dhdp->store_idx;
sent_idx = dhdp->sent_idx;
if (dhdp->skbbuf[store_idx] != NULL) {
/* Make sure the previous packets are processed */
dhd_os_rxfunlock(dhdp);
#ifdef RXF_DEQUEUE_ON_BUSY
DHD_TRACE(("dhd_rxf_enqueue: pktbuf not consumed %p, store idx %d sent idx %d\n",
skb, store_idx, sent_idx));
return BCME_BUSY;
#else /* RXF_DEQUEUE_ON_BUSY */
DHD_ERROR(("dhd_rxf_enqueue: pktbuf not consumed %p, store idx %d sent idx %d\n",
skb, store_idx, sent_idx));
/* removed msleep here, should use wait_event_timeout if we
* want to give rx frame thread a chance to run
*/
#if defined(WAIT_DEQUEUE)
OSL_SLEEP(1);
#endif
return BCME_ERROR;
#endif /* RXF_DEQUEUE_ON_BUSY */
}
DHD_TRACE(("dhd_rxf_enqueue: Store SKB %p. idx %d -> %d\n",
skb, store_idx, (store_idx + 1) & (MAXSKBPEND - 1)));
dhdp->skbbuf[store_idx] = skb;
dhdp->store_idx = (store_idx + 1) & (MAXSKBPEND - 1);
dhd_os_rxfunlock(dhdp);
return BCME_OK;
}
static inline void* dhd_rxf_dequeue(dhd_pub_t *dhdp)
{
uint32 store_idx;
uint32 sent_idx;
void *skb;
dhd_os_rxflock(dhdp);
store_idx = dhdp->store_idx;
sent_idx = dhdp->sent_idx;
skb = dhdp->skbbuf[sent_idx];
if (skb == NULL) {
dhd_os_rxfunlock(dhdp);
DHD_ERROR(("dhd_rxf_dequeue: Dequeued packet is NULL, store idx %d sent idx %d\n",
store_idx, sent_idx));
return NULL;
}
dhdp->skbbuf[sent_idx] = NULL;
dhdp->sent_idx = (sent_idx + 1) & (MAXSKBPEND - 1);
DHD_TRACE(("dhd_rxf_dequeue: netif_rx_ni(%p), sent idx %d\n",
skb, sent_idx));
dhd_os_rxfunlock(dhdp);
return skb;
}
#if (defined(DHD_WET) || defined(DHD_MCAST_REGEN) || defined(DHD_L2_FILTER))
static void
dhd_update_rx_pkt_chainable_state(dhd_pub_t* dhdp, uint32 idx)
{
dhd_info_t *dhd = dhdp->info;
dhd_if_t *ifp;
ASSERT(idx < DHD_MAX_IFS);
ifp = dhd->iflist[idx];
if (
#ifdef DHD_L2_FILTER
(ifp->block_ping) ||
#endif
#ifdef DHD_WET
(dhd->wet_mode) ||
#endif
#ifdef DHD_MCAST_REGEN
(ifp->mcast_regen_bss_enable) ||
#endif
FALSE) {
ifp->rx_pkt_chainable = FALSE;
}
}
#endif /* DHD_WET || DHD_MCAST_REGEN || DHD_L2_FILTER */
#ifdef DHD_PCIE_NATIVE_RUNTIMEPM
void dhd_rx_wq_wakeup(struct work_struct *ptr)
{
struct dhd_rx_tx_work *work;
struct dhd_pub * pub;
work = container_of(ptr, struct dhd_rx_tx_work, work);
pub = work->pub;
DHD_RPM(("%s: ENTER. \n", __FUNCTION__));
if (atomic_read(&pub->block_bus) || pub->busstate == DHD_BUS_DOWN) {
return;
}
DHD_OS_WAKE_LOCK(pub);
if (pm_runtime_get_sync(dhd_bus_to_dev(pub->bus)) >= 0) {
// do nothing but wakeup the bus.
pm_runtime_mark_last_busy(dhd_bus_to_dev(pub->bus));
pm_runtime_put_autosuspend(dhd_bus_to_dev(pub->bus));
}
DHD_OS_WAKE_UNLOCK(pub);
kfree(work);
}
#endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
#ifdef DHD_WMF
bool
dhd_is_rxthread_enabled(dhd_pub_t *dhdp)
{
dhd_info_t *dhd = dhdp->info;
return dhd->rxthread_enabled;
}
#endif /* DHD_WMF */
/** Called when a frame is received by the dongle on interface 'ifidx' */
void
dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *pktbuf, int numpkt, uint8 chan)
{
dhd_info_t *dhd = (dhd_info_t *)dhdp->info;
struct sk_buff *skb;
uchar *eth;
uint len;
void *data, *pnext = NULL;
int i;
dhd_if_t *ifp;
wl_event_msg_t event;
#if defined(OEM_ANDROID)
int tout_rx = 0;
int tout_ctrl = 0;
#endif /* OEM_ANDROID */
void *skbhead = NULL;
void *skbprev = NULL;
uint16 protocol;
unsigned char *dump_data;
#ifdef DHD_MCAST_REGEN
uint8 interface_role;
if_flow_lkup_t *if_flow_lkup;
unsigned long flags;
#endif
#ifdef DHD_WAKE_STATUS
wake_counts_t *wcp = NULL;
#endif /* DHD_WAKE_STATUS */
int pkt_wake = 0;
#ifdef ENABLE_DHD_GRO
bool dhd_gro_enable = TRUE;
struct Qdisc *qdisc = NULL;
#endif /* ENABLE_DHD_GRO */
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
BCM_REFERENCE(dump_data);
BCM_REFERENCE(pkt_wake);
#ifdef DHD_TPUT_PATCH
if (dhdp->conf->pktsetsum)
PKTSETSUMGOOD(pktbuf, TRUE);
#endif
#ifdef ENABLE_DHD_GRO
if (ifidx < DHD_MAX_IFS) {
ifp = dhd->iflist[ifidx];
if (ifp && ifp->net->qdisc) {
if (ifp->net->qdisc->ops->cl_ops) {
dhd_gro_enable = FALSE;
DHD_TRACE(("%s: disable sw gro becasue of"
" qdisc tx traffic control\n", __FUNCTION__));
}
if (dev_ingress_queue(ifp->net)) {
qdisc = dev_ingress_queue(ifp->net)->qdisc_sleeping;
if (qdisc != NULL && (qdisc->flags & TCQ_F_INGRESS)) {
#ifdef CONFIG_NET_CLS_ACT
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
if (ifp->net->miniq_ingress != NULL)
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0))
if (ifp->net->ingress_cl_list != NULL)
#endif /* LINUX_VERSION >= 4.2.0 */
{
dhd_gro_enable = FALSE;
DHD_TRACE(("%s: disable sw gro because of"
" qdisc rx traffic control\n", __FUNCTION__));
}
#endif /* CONFIG_NET_CLS_ACT */
}
}
}
}
#ifdef DHD_GRO_ENABLE_HOST_CTRL
if (!dhdp->permitted_gro && dhd_gro_enable) {
dhd_gro_enable = FALSE;
}
#endif /* DHD_GRO_ENABLE_HOST_CTRL */
#endif /* ENABLE_DHD_GRO */
for (i = 0; pktbuf && i < numpkt; i++, pktbuf = pnext) {
struct ether_header *eh;
pnext = PKTNEXT(dhdp->osh, pktbuf);
PKTSETNEXT(dhdp->osh, pktbuf, NULL);
/* info ring "debug" data, which is not a 802.3 frame, is sent/hacked with a
* special ifidx of DHD_DUMMY_INFO_IF. This is just internal to dhd to get the data
* from dhd_msgbuf.c:dhd_prot_infobuf_cmplt_process() to here (dhd_rx_frame).
*/
if (ifidx == DHD_DUMMY_INFO_IF) {
/* Event msg printing is called from dhd_rx_frame which is in Tasklet
* context in case of PCIe FD, in case of other bus this will be from
* DPC context. If we get bunch of events from Dongle then printing all
* of them from Tasklet/DPC context that too in data path is costly.
* Also in the new Dongle SW(4359, 4355 onwards) console prints too come as
* events with type WLC_E_TRACE.
* We'll print this console logs from the WorkQueue context by enqueing SKB
* here and Dequeuing will be done in WorkQueue and will be freed only if
* logtrace_pkt_sendup is TRUE
*/
#ifdef SHOW_LOGTRACE
dhd_event_logtrace_enqueue(dhdp, ifidx, pktbuf);
#else /* !SHOW_LOGTRACE */
/* If SHOW_LOGTRACE not defined and ifidx is DHD_DUMMY_INFO_IF,
* free the PKT here itself
*/
PKTFREE_CTRLBUF(dhdp->osh, pktbuf, FALSE);
#endif /* SHOW_LOGTRACE */
continue;
}
eh = (struct ether_header *)PKTDATA(dhdp->osh, pktbuf);
/* Check if dhd_stop is in progress */
if (dhdp->stop_in_progress) {
DHD_ERROR_RLMT(("%s: dhd_stop in progress ignore received packet\n",
__FUNCTION__));
RX_PKTFREE(dhdp->osh, eh->ether_type, pktbuf, FALSE);
continue;
}
#ifdef DHD_WAKE_STATUS
/* Get pkt_wake and clear it */
#if defined(BCMPCIE)
pkt_wake = dhd_bus_set_get_bus_wake_pkt_dump(dhdp, 0);
#elif defined(BCMSDIO)
pkt_wake = dhd_bus_set_get_bus_wake(dhdp, 0);
#endif /* BCMPCIE */
#ifdef BCMDBUS
wcp = NULL;
#else
wcp = dhd_bus_get_wakecount(dhdp);
#endif /* BCMDBUS */
if (wcp == NULL) {
/* If wakeinfo count buffer is null do not update wake count values */
pkt_wake = 0;
}
#endif /* DHD_WAKE_STATUS */
if (dhd->pub.tput_data.tput_test_running &&
dhd->pub.tput_data.direction == TPUT_DIR_RX &&
ntoh16(eh->ether_type) == ETHER_TYPE_IP) {
dhd_tput_test_rx(dhdp, pktbuf);
PKTFREE(dhd->pub.osh, pktbuf, FALSE);
continue;
}
if (ifidx >= DHD_MAX_IFS) {
DHD_ERROR(("%s: ifidx(%d) Out of bound. drop packet\n",
__FUNCTION__, ifidx));
RX_PKTFREE(dhdp->osh, eh->ether_type, pktbuf, FALSE);
continue;
}
ifp = dhd->iflist[ifidx];
if (ifp == NULL) {
DHD_ERROR_RLMT(("%s: ifp is NULL. drop packet\n",
__FUNCTION__));
RX_PKTFREE(dhdp->osh, eh->ether_type, pktbuf, FALSE);
continue;
}
/* Dropping only data packets before registering net device to avoid kernel panic */
#ifndef PROP_TXSTATUS_VSDB
if ((!ifp->net || ifp->net->reg_state != NETREG_REGISTERED) &&
(ntoh16(eh->ether_type) != ETHER_TYPE_BRCM))
#else
if ((!ifp->net || ifp->net->reg_state != NETREG_REGISTERED || !dhd->pub.up) &&
(ntoh16(eh->ether_type) != ETHER_TYPE_BRCM))
#endif /* PROP_TXSTATUS_VSDB */
{
DHD_ERROR(("%s: net device is NOT registered yet. drop packet\n",
__FUNCTION__));
PKTCFREE(dhdp->osh, pktbuf, FALSE);
continue;
}
#ifdef PROP_TXSTATUS
if (dhd_wlfc_is_header_only_pkt(dhdp, pktbuf)) {
/* WLFC may send header only packet when
there is an urgent message but no packet to
piggy-back on
*/
PKTCFREE(dhdp->osh, pktbuf, FALSE);
continue;
}
#endif
#ifdef DHD_L2_FILTER
/* If block_ping is enabled drop the ping packet */
if (ifp->block_ping) {
if (bcm_l2_filter_block_ping(dhdp->osh, pktbuf) == BCME_OK) {
PKTCFREE(dhdp->osh, pktbuf, FALSE);
continue;
}
}
if (ifp->grat_arp && DHD_IF_ROLE_STA(dhdp, ifidx)) {
if (bcm_l2_filter_gratuitous_arp(dhdp->osh, pktbuf) == BCME_OK) {
PKTCFREE(dhdp->osh, pktbuf, FALSE);
continue;
}
}
if (ifp->parp_enable && DHD_IF_ROLE_AP(dhdp, ifidx)) {
int ret = dhd_l2_filter_pkt_handle(dhdp, ifidx, pktbuf, FALSE);
/* Drop the packets if l2 filter has processed it already
* otherwise continue with the normal path
*/
if (ret == BCME_OK) {
PKTCFREE(dhdp->osh, pktbuf, TRUE);
continue;
}
}
if (ifp->block_tdls) {
if (bcm_l2_filter_block_tdls(dhdp->osh, pktbuf) == BCME_OK) {
PKTCFREE(dhdp->osh, pktbuf, FALSE);
continue;
}
}
#endif /* DHD_L2_FILTER */
#ifdef DHD_MCAST_REGEN
DHD_FLOWID_LOCK(dhdp->flowid_lock, flags);
if_flow_lkup = (if_flow_lkup_t *)dhdp->if_flow_lkup;
ASSERT(if_flow_lkup);
interface_role = if_flow_lkup[ifidx].role;
DHD_FLOWID_UNLOCK(dhdp->flowid_lock, flags);
if (ifp->mcast_regen_bss_enable && (interface_role != WLC_E_IF_ROLE_WDS) &&
!DHD_IF_ROLE_AP(dhdp, ifidx) &&
ETHER_ISUCAST(eh->ether_dhost)) {
if (dhd_mcast_reverse_translation(eh) == BCME_OK) {
#ifdef DHD_PSTA
/* Change bsscfg to primary bsscfg for unicast-multicast packets */
if ((dhd_get_psta_mode(dhdp) == DHD_MODE_PSTA) ||
(dhd_get_psta_mode(dhdp) == DHD_MODE_PSR)) {
if (ifidx != 0) {
/* Let the primary in PSTA interface handle this
* frame after unicast to Multicast conversion
*/
ifp = dhd_get_ifp(dhdp, 0);
ASSERT(ifp);
}
}
}
#endif /* PSTA */
}
#endif /* MCAST_REGEN */
#ifdef DHD_WMF
/* WMF processing for multicast packets */
if (ifp->wmf.wmf_enable && (ETHER_ISMULTI(eh->ether_dhost))) {
dhd_sta_t *sta;
int ret;
sta = dhd_find_sta(dhdp, ifidx, (void *)eh->ether_shost);
ret = dhd_wmf_packets_handle(dhdp, pktbuf, sta, ifidx, 1);
switch (ret) {
case WMF_TAKEN:
/* The packet is taken by WMF. Continue to next iteration */
continue;
case WMF_DROP:
/* Packet DROP decision by WMF. Toss it */
DHD_ERROR(("%s: WMF decides to drop packet\n",
__FUNCTION__));
PKTCFREE(dhdp->osh, pktbuf, FALSE);
continue;
default:
/* Continue the transmit path */
break;
}
}
#endif /* DHD_WMF */
#ifdef DHDTCPSYNC_FLOOD_BLK
if (dhd_tcpdata_get_flag(dhdp, pktbuf) == FLAG_SYNC) {
int delta_sec;
int delta_sync;
int sync_per_sec;
u64 curr_time = DIV_U64_BY_U32(OSL_LOCALTIME_NS(), NSEC_PER_SEC);
ifp->tsync_rcvd ++;
delta_sync = ifp->tsync_rcvd - ifp->tsyncack_txed;
delta_sec = curr_time - ifp->last_sync;
if (delta_sec > 1) {
sync_per_sec = delta_sync/delta_sec;
if (sync_per_sec > TCP_SYNC_FLOOD_LIMIT) {
schedule_work(&ifp->blk_tsfl_work);
DHD_ERROR(("ifx %d TCP SYNC Flood attack suspected! "
"sync recvied %d pkt/sec \n",
ifidx, sync_per_sec));
ifp->tsync_per_sec = sync_per_sec;
}
dhd_reset_tcpsync_info_by_ifp(ifp);
}
}
#endif /* DHDTCPSYNC_FLOOD_BLK */
#ifdef DHDTCPACK_SUPPRESS
dhd_tcpdata_info_get(dhdp, pktbuf);
#endif
skb = PKTTONATIVE(dhdp->osh, pktbuf);
ASSERT(ifp);
skb->dev = ifp->net;
#ifdef DHD_WET
/* wet related packet proto manipulation should be done in DHD
* since dongle doesn't have complete payload
*/
if (WET_ENABLED(&dhd->pub) && (dhd_wet_recv_proc(dhd->pub.wet_info,
pktbuf) < 0)) {
DHD_INFO(("%s:%s: wet recv proc failed\n",
__FUNCTION__, dhd_ifname(dhdp, ifidx)));
}
#endif /* DHD_WET */
#ifdef DHD_PSTA
if (PSR_ENABLED(dhdp) &&
#ifdef BCM_ROUTER_DHD
!(ifp->primsta_dwds) &&
#endif /* BCM_ROUTER_DHD */
(dhd_psta_proc(dhdp, ifidx, &pktbuf, FALSE) < 0)) {
DHD_ERROR(("%s:%s: psta recv proc failed\n", __FUNCTION__,
dhd_ifname(dhdp, ifidx)));
}
#endif /* DHD_PSTA */
#if defined(BCM_ROUTER_DHD)
/* XXX Use WOFA for both dhdap and dhdap-atlas router. */
/* XXX dhd_sendpkt verify pkt accounting (TO/FRM NATIVE) and PKTCFREE */
if (DHD_IF_ROLE_AP(dhdp, ifidx) && (!ifp->ap_isolate)) {
eh = (struct ether_header *)PKTDATA(dhdp->osh, pktbuf);
if (ETHER_ISUCAST(eh->ether_dhost)) {
if (dhd_find_sta(dhdp, ifidx, (void *)eh->ether_dhost)) {
dhd_sendpkt(dhdp, ifidx, pktbuf);
continue;
}
} else {
void *npkt;
#if defined(HNDCTF)
if (PKTISCHAINED(pktbuf)) { /* XXX WAR */
DHD_ERROR(("Error: %s():%d Chained non unicast pkt<%p>\n",
__FUNCTION__, __LINE__, pktbuf));
PKTFRMNATIVE(dhdp->osh, pktbuf);
PKTCFREE(dhdp->osh, pktbuf, FALSE);
continue;
}
#endif /* HNDCTF */
if ((ntoh16(eh->ether_type) != ETHER_TYPE_IAPP_L2_UPDATE) &&
((npkt = PKTDUP(dhdp->osh, pktbuf)) != NULL))
dhd_sendpkt(dhdp, ifidx, npkt);
}
}
#if defined(HNDCTF)
/* try cut thru' before sending up */
if (dhd_ctf_forward(dhd, skb, &pnext) == BCME_OK) {
continue;
}
#endif /* HNDCTF */
#else /* !BCM_ROUTER_DHD */
#ifdef PCIE_FULL_DONGLE
if ((DHD_IF_ROLE_AP(dhdp, ifidx) || DHD_IF_ROLE_P2PGO(dhdp, ifidx)) &&
(!ifp->ap_isolate)) {
eh = (struct ether_header *)PKTDATA(dhdp->osh, pktbuf);
if (ETHER_ISUCAST(eh->ether_dhost)) {
if (dhd_find_sta(dhdp, ifidx, (void *)eh->ether_dhost)) {
dhdp->rx_forward++; /* Local count */
dhd_sendpkt(dhdp, ifidx, pktbuf);
continue;
}
} else {
if ((ntoh16(eh->ether_type) != ETHER_TYPE_IAPP_L2_UPDATE)) {
void *npktbuf = NULL;
/*
* If host_sfhllc_supported enabled, do skb_copy as SFHLLC
* header will be inserted during Tx, due to which network
* stack will not decode the Rx packet.
* Else PKTDUP(skb_clone) is enough.
*/
if (dhdp->host_sfhllc_supported) {
npktbuf = skb_copy(skb, GFP_ATOMIC);
} else {
npktbuf = PKTDUP(dhdp->osh, pktbuf);
}
if (npktbuf != NULL) {
dhdp->rx_forward++; /* Local count */
dhd_sendpkt(dhdp, ifidx, npktbuf);
}
}
}
}
#endif /* PCIE_FULL_DONGLE */
#endif /* BCM_ROUTER_DHD */
#ifdef DHD_POST_EAPOL_M1_AFTER_ROAM_EVT
if (IS_STA_IFACE(ndev_to_wdev(ifp->net)) &&
(ifp->recv_reassoc_evt == TRUE) && (ifp->post_roam_evt == FALSE) &&
(dhd_is_4way_msg((char *)(skb->data)) == EAPOL_4WAY_M1)) {
DHD_ERROR(("%s: Reassoc is in progress. "
"Drop EAPOL M1 frame\n", __FUNCTION__));
PKTFREE(dhdp->osh, pktbuf, FALSE);
continue;
}
#endif /* DHD_POST_EAPOL_M1_AFTER_ROAM_EVT */
#ifdef WLEASYMESH
if ((dhdp->conf->fw_type == FW_TYPE_EZMESH) &&
(ntoh16(eh->ether_type) != ETHER_TYPE_BRCM)) {
uint16 * da = (uint16 *)(eh->ether_dhost);
ASSERT(ISALIGNED(da, 2));
/* XXX: Special handling for 1905 messages
* if DA matches with configured 1905 AL MAC addresses
* bypass fwder and foward it to linux stack
*/
if (ntoh16(eh->ether_type) == ETHER_TYPE_1905_1) {
if (!eacmp(da, ifp->_1905_al_ucast) || !eacmp(da, ifp->_1905_al_mcast)) {
//skb->fwr_flood = 0;
} else {
//skb->fwr_flood = 1;
}
}
}
#endif /* WLEASYMESH */
/* Get the protocol, maintain skb around eth_type_trans()
* The main reason for this hack is for the limitation of
* Linux 2.4 where 'eth_type_trans' uses the 'net->hard_header_len'
* to perform skb_pull inside vs ETH_HLEN. Since to avoid
* coping of the packet coming from the network stack to add
* BDC, Hardware header etc, during network interface registration
* we set the 'net->hard_header_len' to ETH_HLEN + extra space required
* for BDC, Hardware header etc. and not just the ETH_HLEN
*/
eth = skb->data;
len = skb->len;
dump_data = skb->data;
protocol = (skb->data[12] << 8) | skb->data[13];
if (protocol == ETHER_TYPE_802_1X) {
DBG_EVENT_LOG(dhdp, WIFI_EVENT_DRIVER_EAPOL_FRAME_RECEIVED);
#if defined(WL_CFG80211) && defined(WL_WPS_SYNC)
wl_handle_wps_states(ifp->net, dump_data, len, FALSE);
#endif /* WL_CFG80211 && WL_WPS_SYNC */
#ifdef DHD_4WAYM4_FAIL_DISCONNECT
if (dhd_is_4way_msg((uint8 *)(skb->data)) == EAPOL_4WAY_M3) {
OSL_ATOMIC_SET(dhdp->osh, &ifp->m4state, M3_RXED);
}
#endif /* DHD_4WAYM4_FAIL_DISCONNECT */
#ifdef EAPOL_RESEND
wl_ext_release_eapol_txpkt(dhdp, ifidx, TRUE);
#endif /* EAPOL_RESEND */
}
dhd_handle_pktdata(dhdp, ifidx, skb, dump_data, FALSE,
len, NULL, NULL, NULL, FALSE, pkt_wake, TRUE);
#if defined(DHD_WAKE_STATUS) && defined(DHD_WAKEPKT_DUMP)
if (pkt_wake) {
DHD_ERROR(("##### dhdpcie_host_wake caused by packets\n"));
dhd_prhex("[wakepkt_dump]", (char*)dump_data, MIN(len, 64), DHD_RPM_VAL);
DHD_ERROR(("config check in_suspend: %d\n", dhdp->in_suspend));
#ifdef ARP_OFFLOAD_SUPPORT
DHD_ERROR(("arp hmac_update:%d \n", dhdp->hmac_updated));
#endif /* ARP_OFFLOAD_SUPPORT */
#if defined(DHD_WAKEPKT_SET_MARK) && defined(CONFIG_NF_CONNTRACK_MARK)
PKTMARK(skb) |= 0x80000000;
#endif /* DHD_WAKEPKT_SET_MARK && CONFIG_NF_CONNTRACK_MARK */
}
#endif /* DHD_WAKE_STATUS && DHD_WAKEPKT_DUMP */
skb->protocol = eth_type_trans(skb, skb->dev);
if (skb->pkt_type == PACKET_MULTICAST) {
dhd->pub.rx_multicast++;
ifp->stats.multicast++;
}
skb->data = eth;
skb->len = len;
/* TODO: XXX: re-look into dropped packets. */
DHD_DBG_PKT_MON_RX(dhdp, skb, FRAME_TYPE_ETHERNET_II);
/* Strip header, count, deliver upward */
skb_pull(skb, ETH_HLEN);
#ifdef ENABLE_WAKEUP_PKT_DUMP
if (dhd_mmc_wake) {
DHD_INFO(("wake_pkt %s(%d)\n", __FUNCTION__, __LINE__));
prhex("wake_pkt", (char*) eth, MIN(len, 64));
update_wake_pkt_info(skb);
DHD_ERROR(("wake_pkt %s(%d), raw_info=0x%016llx\n",
__FUNCTION__, __LINE__, temp_raw))
#ifdef CONFIG_IRQ_HISTORY
add_irq_history(0, "WIFI");
#endif
dhd_mmc_wake = FALSE;
}
#endif /* ENABLE_WAKEUP_PKT_DUMP */
/* Process special event packets and then discard them */
/* XXX Decide on a better way to fit this in */
memset(&event, 0, sizeof(event));
if (ntoh16(skb->protocol) == ETHER_TYPE_BRCM) {
bcm_event_msg_u_t evu;
int ret_event, event_type;
void *pkt_data = skb_mac_header(skb);
ret_event = wl_host_event_get_data(pkt_data, len, &evu);
if (ret_event != BCME_OK) {
DHD_ERROR(("%s: wl_host_event_get_data err = %d\n",
__FUNCTION__, ret_event));
PKTFREE_CTRLBUF(dhdp->osh, pktbuf, FALSE);
continue;
}
memcpy(&event, &evu.event, sizeof(wl_event_msg_t));
event_type = ntoh32_ua((void *)&event.event_type);
#ifdef SHOW_LOGTRACE
/* Event msg printing is called from dhd_rx_frame which is in Tasklet
* context in case of PCIe FD, in case of other bus this will be from
* DPC context. If we get bunch of events from Dongle then printing all
* of them from Tasklet/DPC context that too in data path is costly.
* Also in the new Dongle SW(4359, 4355 onwards) console prints too come as
* events with type WLC_E_TRACE.
* We'll print this console logs from the WorkQueue context by enqueing SKB
* here and Dequeuing will be done in WorkQueue and will be freed only if
* logtrace_pkt_sendup is true
*/
if (event_type == WLC_E_TRACE) {
DHD_TRACE(("%s: WLC_E_TRACE\n", __FUNCTION__));
dhd_event_logtrace_enqueue(dhdp, ifidx, pktbuf);
continue;
}
#endif /* SHOW_LOGTRACE */
ret_event = dhd_wl_host_event(dhd, ifidx, pkt_data, len, &event, &data);
wl_event_to_host_order(&event);
#if defined(OEM_ANDROID)
if (!tout_ctrl)
tout_ctrl = DHD_PACKET_TIMEOUT_MS;
#endif /* OEM_ANDROID */
#if (defined(OEM_ANDROID) && defined(PNO_SUPPORT))
if (event_type == WLC_E_PFN_NET_FOUND) {
/* enforce custom wake lock to garantee that Kernel not suspended */
tout_ctrl = CUSTOM_PNO_EVENT_LOCK_xTIME * DHD_PACKET_TIMEOUT_MS;
}
#endif /* PNO_SUPPORT */
if (numpkt != 1) {
DHD_TRACE(("%s: Got BRCM event packet in a chained packet.\n",
__FUNCTION__));
}
#ifdef DHD_WAKE_STATUS
if (unlikely(pkt_wake)) {
#ifdef DHD_WAKE_EVENT_STATUS
if (event.event_type < WLC_E_LAST) {
#ifdef CUSTOM_WAKE_REASON_STATS
if (wcp->rc_event_idx == MAX_WAKE_REASON_STATS) {
wcp->rc_event_idx = 0;
}
DHD_ERROR(("[pkt_wake] event id %u = %s\n",
event.event_type,
bcmevent_get_name(event.event_type)));
wcp->rc_event[wcp->rc_event_idx] = event.event_type;
wcp->rc_event_idx++;
#else
wcp->rc_event[event.event_type]++;
#endif /* CUSTOM_WAKE_REASON_STATS */
wcp->rcwake++;
pkt_wake = 0;
}
#endif /* DHD_WAKE_EVENT_STATUS */
}
#endif /* DHD_WAKE_STATUS */
/* For delete virtual interface event, wl_host_event returns positive
* i/f index, do not proceed. just free the pkt.
*/
if ((event_type == WLC_E_IF) && (ret_event > 0)) {
DHD_ERROR(("%s: interface is deleted. Free event packet\n",
__FUNCTION__));
PKTFREE_CTRLBUF(dhdp->osh, pktbuf, FALSE);
continue;
}
/*
* For the event packets, there is a possibility
* of ifidx getting modifed.Thus update the ifp
* once again.
*/
ASSERT(ifidx < DHD_MAX_IFS);
ifp = dhd->iflist[ifidx];
#ifndef PROP_TXSTATUS_VSDB
if (!(ifp && ifp->net && (ifp->net->reg_state == NETREG_REGISTERED)))
#else
if (!(ifp && ifp->net && (ifp->net->reg_state == NETREG_REGISTERED) &&
dhd->pub.up))
#endif /* PROP_TXSTATUS_VSDB */
{
DHD_ERROR(("%s: net device is NOT registered. drop event packet\n",
__FUNCTION__));
PKTFREE_CTRLBUF(dhdp->osh, pktbuf, FALSE);
continue;
}
#ifdef SENDPROB
if (dhdp->wl_event_enabled ||
(dhdp->recv_probereq && (event.event_type == WLC_E_PROBREQ_MSG)))
#else
if (dhdp->wl_event_enabled)
#endif
{
#ifdef DHD_USE_STATIC_CTRLBUF
/* If event bufs are allocated via static buf pool
* and wl events are enabled, make a copy, free the
* local one and send the copy up.
*/
struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
/* Copy event and send it up */
PKTFREE_STATIC(dhdp->osh, pktbuf, FALSE);
if (nskb) {
skb = nskb;
} else {
DHD_ERROR(("skb clone failed. dropping event.\n"));
continue;
}
#endif /* DHD_USE_STATIC_CTRLBUF */
} else {
/* If event enabled not explictly set, drop events */
PKTFREE_CTRLBUF(dhdp->osh, pktbuf, FALSE);
continue;
}
} else {
#if defined(OEM_ANDROID)
tout_rx = DHD_PACKET_TIMEOUT_MS;
/* Override rx wakelock timeout to give hostapd enough time
* to process retry or error handling for handshake
*/
if (IS_AP_IFACE(ndev_to_wdev(ifp->net)) &&
ntoh16(skb->protocol) == ETHER_TYPE_802_1X) {
if (dhd_is_4way_msg(dump_data) == EAPOL_4WAY_M2) {
tout_rx = DHD_HANDSHAKE_TIMEOUT_MS;
}
}
#endif /* OEM_ANDROID */
#ifdef PROP_TXSTATUS
dhd_wlfc_save_rxpath_ac_time(dhdp, (uint8)PKTPRIO(skb));
#endif /* PROP_TXSTATUS */
#ifdef DHD_WAKE_STATUS
if (unlikely(pkt_wake)) {
wcp->rxwake++;
#ifdef DHD_WAKE_RX_STATUS
if (ntoh16(skb->protocol) == ETHER_TYPE_ARP) /* ARP */
wcp->rx_arp++;
if (ntoh16(skb->protocol) == ETHER_TYPE_IP) {
struct iphdr *ipheader = NULL;
ipheader = (struct iphdr*)(skb->data);
if (ipheader && ipheader->protocol == IPPROTO_ICMP) {
wcp->rx_icmp++;
}
}
if (dump_data[0] == 0xFF) { /* Broadcast */
wcp->rx_bcast++;
} else if (dump_data[0] & 0x01) { /* Multicast */
wcp->rx_mcast++;
if (ntoh16(skb->protocol) == ETHER_TYPE_IPV6) {
wcp->rx_multi_ipv6++;
if ((skb->len > ETHER_ICMP6_HEADER) &&
(dump_data[ETHER_ICMP6_HEADER] == IPPROTO_ICMPV6)) {
wcp->rx_icmpv6++;
if (skb->len > ETHER_ICMPV6_TYPE) {
switch (dump_data[ETHER_ICMPV6_TYPE]) {
case NDISC_ROUTER_ADVERTISEMENT:
wcp->rx_icmpv6_ra++;
break;
case NDISC_NEIGHBOUR_ADVERTISEMENT:
wcp->rx_icmpv6_na++;
break;
case NDISC_NEIGHBOUR_SOLICITATION:
wcp->rx_icmpv6_ns++;
break;