hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/dhd_ip.c
....@@ -1,15 +1,16 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * IP Packet Parser Module.
43 *
5
- * Copyright (C) 1999-2019, Broadcom Corporation
6
- *
4
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
5
+ *
6
+ * Copyright (C) 1999-2017, Broadcom Corporation
7
+ *
78 * Unless you and Broadcom execute a separate written software license
89 * agreement governing use of this software, this software is licensed to you
910 * under the terms of the GNU General Public License version 2 (the "GPL"),
1011 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1112 * following added to such license:
12
- *
13
+ *
1314 * As a special exception, the copyright holders of this software give you
1415 * permission to link this software with independent modules, and to copy and
1516 * distribute the resulting executable under terms of your choice, provided that
....@@ -17,7 +18,7 @@
1718 * the license of that module. An independent module is a module which is not
1819 * derived from this software. The special exception does not apply to any
1920 * modifications of the software.
20
- *
21
+ *
2122 * Notwithstanding the above, under no circumstances may you combine this
2223 * software in any way with any other Broadcom software provided under a license
2324 * other than the GPL, without Broadcom's express prior written consent.
....@@ -25,26 +26,26 @@
2526 *
2627 * <<Broadcom-WL-IPTag/Open:>>
2728 *
28
- * $Id: dhd_ip.c 709309 2019-01-17 09:04:00Z $
29
+ * $Id: dhd_ip.c 700444 2017-05-19 06:38:00Z $
2930 */
3031 #include <typedefs.h>
3132 #include <osl.h>
3233
33
-#include <proto/ethernet.h>
34
-#include <proto/vlan.h>
35
-#include <proto/802.3.h>
36
-#include <proto/bcmip.h>
34
+#include <ethernet.h>
35
+#include <vlan.h>
36
+#include <802.3.h>
37
+#include <bcmip.h>
3738 #include <bcmendian.h>
3839
3940 #include <dhd_dbg.h>
4041
4142 #include <dhd_ip.h>
4243
43
-#ifdef DHDTCPACK_SUPPRESS
44
+#if defined(DHDTCPACK_SUPPRESS) || defined(DHDTCPSYNC_FLOOD_BLK)
4445 #include <dhd_bus.h>
4546 #include <dhd_proto.h>
46
-#include <proto/bcmtcp.h>
47
-#endif /* DHDTCPACK_SUPPRESS */
47
+#include <bcmtcp.h>
48
+#endif /* DHDTCPACK_SUPPRESS || DHDTCPSYNC_FLOOD_BLK */
4849
4950 /* special values */
5051 /* 802.3 llc/snap header */
....@@ -128,7 +129,15 @@
128129 int ifidx;
129130 uint8 supp_cnt;
130131 dhd_pub_t *dhdp;
131
- struct timer_list timer;
132
+#ifndef TCPACK_SUPPRESS_HOLD_HRT
133
+ timer_list_compat_t timer;
134
+#else
135
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 1, 21))
136
+ struct tasklet_hrtimer timer;
137
+#else
138
+ struct hrtimer timer;
139
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 1, 21) */
140
+#endif /* TCPACK_SUPPRESS_HOLD_HRT */
132141 } tcpack_info_t;
133142
134143 typedef struct _tdata_psh_info_t {
....@@ -182,7 +191,7 @@
182191 tcpack_sup_mod->tdata_psh_info_free = tdata_psh_info;
183192 #ifdef DHDTCPACK_SUP_DBG
184193 tcpack_sup_mod->psh_info_enq_num++;
185
-#endif
194
+#endif // endif
186195 }
187196
188197 static tdata_psh_info_t*
....@@ -290,44 +299,54 @@
290299 }
291300 #endif /* BCMSDIO */
292301
293
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
294
-static void dhd_tcpack_send(struct timer_list *t)
295
-{
296
- tcpack_info_t *cur_tbl = from_timer(cur_tbl, t, timer);
297
-#else
302
+#ifdef BCMPCIE
303
+#ifndef TCPACK_SUPPRESS_HOLD_HRT
298304 static void dhd_tcpack_send(ulong data)
305
+#else
306
+static enum hrtimer_restart dhd_tcpack_send(struct hrtimer *timer)
307
+#endif /* TCPACK_SUPPRESS_HOLD_HRT */
299308 {
300
- tcpack_info_t *cur_tbl = (tcpack_info_t *)data;
301
-#endif
302309 tcpack_sup_module_t *tcpack_sup_mod;
310
+ tcpack_info_t *cur_tbl;
303311 dhd_pub_t *dhdp;
304312 int ifidx;
305313 void* pkt;
306314 unsigned long flags;
307315
316
+#ifndef TCPACK_SUPPRESS_HOLD_HRT
317
+ cur_tbl = (tcpack_info_t *)data;
318
+#else
319
+ cur_tbl = container_of(timer, tcpack_info_t, timer.timer);
320
+#endif /* TCPACK_SUPPRESS_HOLD_HRT */
321
+
308322 if (!cur_tbl) {
309
- return;
323
+ goto done;
310324 }
311325
312326 dhdp = cur_tbl->dhdp;
313327 if (!dhdp) {
314
- return;
328
+ goto done;
315329 }
316330
317331 flags = dhd_os_tcpacklock(dhdp);
332
+
333
+ if (unlikely(dhdp->tcpack_sup_mode != TCPACK_SUP_HOLD)) {
334
+ dhd_os_tcpackunlock(dhdp, flags);
335
+ goto done;
336
+ }
318337
319338 tcpack_sup_mod = dhdp->tcpack_sup_module;
320339 if (!tcpack_sup_mod) {
321340 DHD_ERROR(("%s %d: tcpack suppress module NULL!!\n",
322341 __FUNCTION__, __LINE__));
323342 dhd_os_tcpackunlock(dhdp, flags);
324
- return;
343
+ goto done;
325344 }
326345 pkt = cur_tbl->pkt_in_q;
327346 ifidx = cur_tbl->ifidx;
328347 if (!pkt) {
329348 dhd_os_tcpackunlock(dhdp, flags);
330
- return;
349
+ goto done;
331350 }
332351 cur_tbl->pkt_in_q = NULL;
333352 cur_tbl->pkt_ether_hdr = NULL;
....@@ -341,99 +360,169 @@
341360 dhd_os_tcpackunlock(dhdp, flags);
342361
343362 dhd_sendpkt(dhdp, ifidx, pkt);
363
+
364
+done:
365
+#ifndef TCPACK_SUPPRESS_HOLD_HRT
366
+ return;
367
+#else
368
+ return HRTIMER_NORESTART;
369
+#endif /* TCPACK_SUPPRESS_HOLD_HRT */
344370 }
371
+#endif /* BCMPCIE */
345372
346373 int dhd_tcpack_suppress_set(dhd_pub_t *dhdp, uint8 mode)
347374 {
348375 int ret = BCME_OK;
349376 unsigned long flags;
377
+ tcpack_sup_module_t *tcpack_sup_module;
378
+ uint8 invalid_mode = FALSE;
379
+ int prev_mode;
380
+ int i = 0;
350381
351382 flags = dhd_os_tcpacklock(dhdp);
383
+ tcpack_sup_module = dhdp->tcpack_sup_module;
384
+ prev_mode = dhdp->tcpack_sup_mode;
352385
353
- if (dhdp->tcpack_sup_mode == mode) {
386
+ if (prev_mode == mode) {
354387 DHD_ERROR(("%s %d: already set to %d\n", __FUNCTION__, __LINE__, mode));
355388 goto exit;
356389 }
357390
358
- if (mode >= TCPACK_SUP_LAST_MODE ||
359
-#ifndef BCMSDIO
360
- mode == TCPACK_SUP_DELAYTX ||
361
-#endif /* !BCMSDIO */
362
- FALSE) {
363
- DHD_ERROR(("%s %d: Invalid mode %d\n", __FUNCTION__, __LINE__, mode));
391
+ invalid_mode |= (mode >= TCPACK_SUP_LAST_MODE);
392
+#ifdef BCMSDIO
393
+ invalid_mode |= (mode == TCPACK_SUP_HOLD);
394
+#endif /* BCMSDIO */
395
+#ifdef BCMPCIE
396
+ invalid_mode |= ((mode == TCPACK_SUP_REPLACE) || (mode == TCPACK_SUP_DELAYTX));
397
+#endif /* BCMPCIE */
398
+
399
+ if (invalid_mode) {
400
+ DHD_ERROR(("%s %d: Invalid TCP ACK Suppress mode %d\n",
401
+ __FUNCTION__, __LINE__, mode));
364402 ret = BCME_BADARG;
365403 goto exit;
366404 }
367405
368
- DHD_TRACE(("%s: %d -> %d\n",
406
+ DHD_TRACE(("%s: TCP ACK Suppress mode %d -> mode %d\n",
369407 __FUNCTION__, dhdp->tcpack_sup_mode, mode));
370408
409
+ /* Pre-process routines to change a new mode as per previous mode */
410
+ switch (prev_mode) {
411
+ case TCPACK_SUP_OFF:
412
+ if (tcpack_sup_module == NULL) {
413
+ tcpack_sup_module = MALLOC(dhdp->osh, sizeof(tcpack_sup_module_t));
414
+ if (tcpack_sup_module == NULL) {
415
+ DHD_ERROR(("%s[%d]: Failed to allocate the new memory for "
416
+ "tcpack_sup_module\n", __FUNCTION__, __LINE__));
417
+ dhdp->tcpack_sup_mode = TCPACK_SUP_OFF;
418
+ ret = BCME_NOMEM;
419
+ goto exit;
420
+ }
421
+ dhdp->tcpack_sup_module = tcpack_sup_module;
422
+ }
423
+ bzero(tcpack_sup_module, sizeof(tcpack_sup_module_t));
424
+ break;
371425 #ifdef BCMSDIO
372
- /* Old tcpack_sup_mode is TCPACK_SUP_DELAYTX */
373
- if (dhdp->tcpack_sup_mode == TCPACK_SUP_DELAYTX) {
374
- tcpack_sup_module_t *tcpack_sup_mod = dhdp->tcpack_sup_module;
375
- /* We won't need tdata_psh_info pool and tcpddata_info_tbl anymore */
376
- _tdata_psh_info_pool_deinit(dhdp, tcpack_sup_mod);
377
- tcpack_sup_mod->tcpdata_info_cnt = 0;
378
- bzero(tcpack_sup_mod->tcpdata_info_tbl,
379
- sizeof(tcpdata_info_t) * TCPDATA_INFO_MAXNUM);
380
- /* For half duplex bus interface, tx precedes rx by default */
381
- if (dhdp->bus)
382
- dhd_bus_set_dotxinrx(dhdp->bus, TRUE);
383
- }
426
+ case TCPACK_SUP_DELAYTX:
427
+ if (tcpack_sup_module) {
428
+ /* We won't need tdata_psh_info pool and
429
+ * tcpddata_info_tbl anymore
430
+ */
431
+ _tdata_psh_info_pool_deinit(dhdp, tcpack_sup_module);
432
+ tcpack_sup_module->tcpdata_info_cnt = 0;
433
+ bzero(tcpack_sup_module->tcpdata_info_tbl,
434
+ sizeof(tcpdata_info_t) * TCPDATA_INFO_MAXNUM);
435
+ }
436
+
437
+ /* For half duplex bus interface, tx precedes rx by default */
438
+ if (dhdp->bus) {
439
+ dhd_bus_set_dotxinrx(dhdp->bus, TRUE);
440
+ }
441
+
442
+ if (tcpack_sup_module == NULL) {
443
+ DHD_ERROR(("%s[%d]: tcpack_sup_module should not be NULL\n",
444
+ __FUNCTION__, __LINE__));
445
+ dhdp->tcpack_sup_mode = TCPACK_SUP_OFF;
446
+ goto exit;
447
+ }
448
+ break;
384449 #endif /* BCMSDIO */
450
+ }
451
+
452
+ /* Update a new mode */
385453 dhdp->tcpack_sup_mode = mode;
386454
387
- if (mode == TCPACK_SUP_OFF) {
388
- ASSERT(dhdp->tcpack_sup_module != NULL);
389
- /* Clean up timer/data structure for any remaining/pending packet or timer. */
390
- dhd_tcpack_info_tbl_clean(dhdp);
391
- MFREE(dhdp->osh, dhdp->tcpack_sup_module, sizeof(tcpack_sup_module_t));
392
- dhdp->tcpack_sup_module = NULL;
393
- goto exit;
394
- }
395
-
396
- if (dhdp->tcpack_sup_module == NULL) {
397
- tcpack_sup_module_t *tcpack_sup_mod =
398
- MALLOC(dhdp->osh, sizeof(tcpack_sup_module_t));
399
- if (tcpack_sup_mod == NULL) {
400
- DHD_ERROR(("%s %d: No MEM\n", __FUNCTION__, __LINE__));
401
- dhdp->tcpack_sup_mode = TCPACK_SUP_OFF;
402
- ret = BCME_NOMEM;
403
- goto exit;
404
- }
405
- bzero(tcpack_sup_mod, sizeof(tcpack_sup_module_t));
406
- dhdp->tcpack_sup_module = tcpack_sup_mod;
407
- }
408
-
409
-#ifdef BCMSDIO
410
- if (mode == TCPACK_SUP_DELAYTX) {
411
- ret = _tdata_psh_info_pool_init(dhdp, dhdp->tcpack_sup_module);
412
- if (ret != BCME_OK)
413
- DHD_ERROR(("%s %d: pool init fail with %d\n", __FUNCTION__, __LINE__, ret));
414
- else if (dhdp->bus)
415
- dhd_bus_set_dotxinrx(dhdp->bus, FALSE);
416
- }
417
-#endif /* BCMSDIO */
418
-
419
- if (mode == TCPACK_SUP_HOLD) {
420
- int i;
421
- tcpack_sup_module_t *tcpack_sup_mod =
422
- (tcpack_sup_module_t *)dhdp->tcpack_sup_module;
423
- dhdp->tcpack_sup_ratio = CUSTOM_TCPACK_SUPP_RATIO;
424
- dhdp->tcpack_sup_delay = CUSTOM_TCPACK_DELAY_TIME;
425
- for (i = 0; i < TCPACK_INFO_MAXNUM; i++)
426
- {
427
- tcpack_sup_mod->tcpack_info_tbl[i].dhdp = dhdp;
428
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
429
- timer_setup((struct timer_list *)&tcpack_sup_mod->tcpack_info_tbl[i].timer, dhd_tcpack_send, 0);
455
+ /* Process for a new mode */
456
+ switch (mode) {
457
+ case TCPACK_SUP_OFF:
458
+ ASSERT(tcpack_sup_module != NULL);
459
+ /* Clean up timer/data structure for
460
+ * any remaining/pending packet or timer.
461
+ */
462
+ if (tcpack_sup_module) {
463
+ /* Check if previous mode is TCAPACK_SUP_HOLD */
464
+ if (prev_mode == TCPACK_SUP_HOLD) {
465
+ for (i = 0; i < TCPACK_INFO_MAXNUM; i++) {
466
+ tcpack_info_t *tcpack_info_tbl =
467
+ &tcpack_sup_module->tcpack_info_tbl[i];
468
+#ifndef TCPACK_SUPPRESS_HOLD_HRT
469
+ del_timer(&tcpack_info_tbl->timer);
430470 #else
431
- init_timer(&tcpack_sup_mod->tcpack_info_tbl[i].timer);
432
- tcpack_sup_mod->tcpack_info_tbl[i].timer.data =
433
- (ulong)&tcpack_sup_mod->tcpack_info_tbl[i];
434
- tcpack_sup_mod->tcpack_info_tbl[i].timer.function = dhd_tcpack_send;
435
-#endif
436
- }
471
+ hrtimer_cancel(&tcpack_info_tbl->timer.timer);
472
+#endif /* TCPACK_SUPPRESS_HOLD_HRT */
473
+ if (tcpack_info_tbl->pkt_in_q) {
474
+ PKTFREE(dhdp->osh,
475
+ tcpack_info_tbl->pkt_in_q, TRUE);
476
+ tcpack_info_tbl->pkt_in_q = NULL;
477
+ }
478
+ }
479
+ }
480
+ MFREE(dhdp->osh, tcpack_sup_module, sizeof(tcpack_sup_module_t));
481
+ dhdp->tcpack_sup_module = NULL;
482
+ } else {
483
+ DHD_ERROR(("%s[%d]: tcpack_sup_module should not be NULL\n",
484
+ __FUNCTION__, __LINE__));
485
+ }
486
+ break;
487
+#ifdef BCMSDIO
488
+ case TCPACK_SUP_REPLACE:
489
+ /* There is nothing to configure for this mode */
490
+ break;
491
+ case TCPACK_SUP_DELAYTX:
492
+ ret = _tdata_psh_info_pool_init(dhdp, tcpack_sup_module);
493
+ if (ret != BCME_OK) {
494
+ DHD_ERROR(("%s %d: pool init fail with %d\n",
495
+ __FUNCTION__, __LINE__, ret));
496
+ break;
497
+ }
498
+ if (dhdp->bus) {
499
+ dhd_bus_set_dotxinrx(dhdp->bus, FALSE);
500
+ }
501
+ break;
502
+#endif /* BCMSDIO */
503
+#ifdef BCMPCIE
504
+ case TCPACK_SUP_HOLD:
505
+ dhdp->tcpack_sup_ratio = CUSTOM_TCPACK_SUPP_RATIO;
506
+ dhdp->tcpack_sup_delay = CUSTOM_TCPACK_DELAY_TIME;
507
+ for (i = 0; i < TCPACK_INFO_MAXNUM; i++) {
508
+ tcpack_info_t *tcpack_info_tbl =
509
+ &tcpack_sup_module->tcpack_info_tbl[i];
510
+ tcpack_info_tbl->dhdp = dhdp;
511
+#ifndef TCPACK_SUPPRESS_HOLD_HRT
512
+ init_timer_compat(&tcpack_info_tbl->timer,
513
+ dhd_tcpack_send, tcpack_info_tbl);
514
+#else
515
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 1, 21))
516
+ tasklet_hrtimer_init(&tcpack_info_tbl->timer,
517
+ dhd_tcpack_send, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
518
+#else
519
+ hrtimer_init(&tcpack_info_tbl->timer, CLOCK_MONOTONIC,
520
+ HRTIMER_MODE_REL_SOFT);
521
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 1, 21) */
522
+#endif /* TCPACK_SUPPRESS_HOLD_HRT */
523
+ }
524
+ break;
525
+#endif /* BCMPCIE */
437526 }
438527
439528 exit:
....@@ -480,7 +569,11 @@
480569
481570 if (dhdp->tcpack_sup_mode == TCPACK_SUP_HOLD) {
482571 for (i = 0; i < TCPACK_INFO_MAXNUM; i++) {
572
+#ifndef TCPACK_SUPPRESS_HOLD_HRT
483573 del_timer_sync(&tcpack_sup_mod->tcpack_info_tbl[i].timer);
574
+#else
575
+ hrtimer_cancel(&tcpack_sup_mod->tcpack_info_tbl[i].timer.timer);
576
+#endif /* TCPACK_SUPPRESS_HOLD_HRT */
484577 }
485578 }
486579
....@@ -649,7 +742,6 @@
649742 bool ret = FALSE;
650743 bool set_dotxinrx = TRUE;
651744 unsigned long flags;
652
-
653745
654746 if (dhdp->tcpack_sup_mode == TCPACK_SUP_OFF)
655747 goto exit;
....@@ -1193,7 +1285,7 @@
11931285 for (i = 0; i < TCPACK_INFO_MAXNUM; i++) {
11941286 void *oldpkt; /* TCPACK packet that is already in txq or DelayQ */
11951287 uint8 *old_ether_hdr, *old_ip_hdr, *old_tcp_hdr;
1196
- uint32 old_ip_hdr_len, old_tcp_hdr_len;
1288
+ uint32 old_ip_hdr_len;
11971289 uint32 old_tcpack_num; /* TCP ACK number of old TCPACK packet in Q */
11981290
11991291 if ((oldpkt = tcpack_info_tbl[i].pkt_in_q) == NULL) {
....@@ -1215,7 +1307,6 @@
12151307 old_ip_hdr = old_ether_hdr + ETHER_HDR_LEN;
12161308 old_ip_hdr_len = IPV4_HLEN(old_ip_hdr);
12171309 old_tcp_hdr = old_ip_hdr + old_ip_hdr_len;
1218
- old_tcp_hdr_len = 4 * TCP_HDRLEN(old_tcp_hdr[TCP_HLEN_OFFSET]);
12191310
12201311 DHD_TRACE(("%s %d: oldpkt %p[%d], IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR
12211312 " TCP port %d %d\n", __FUNCTION__, __LINE__, oldpkt, i,
....@@ -1254,7 +1345,11 @@
12541345 dhd_os_tcpackunlock(dhdp, flags);
12551346
12561347 if (!hold) {
1348
+#ifndef TCPACK_SUPPRESS_HOLD_HRT
12571349 del_timer_sync(&tcpack_info_tbl[i].timer);
1350
+#else
1351
+ hrtimer_cancel(&tcpack_sup_mod->tcpack_info_tbl[i].timer.timer);
1352
+#endif /* TCPACK_SUPPRESS_HOLD_HRT */
12581353 }
12591354 goto exit;
12601355 }
....@@ -1271,8 +1366,18 @@
12711366 tcpack_info_tbl[free_slot].pkt_ether_hdr = new_ether_hdr;
12721367 tcpack_info_tbl[free_slot].ifidx = ifidx;
12731368 tcpack_info_tbl[free_slot].supp_cnt = 1;
1369
+#ifndef TCPACK_SUPPRESS_HOLD_HRT
12741370 mod_timer(&tcpack_sup_mod->tcpack_info_tbl[free_slot].timer,
12751371 jiffies + msecs_to_jiffies(dhdp->tcpack_sup_delay));
1372
+#else
1373
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 1, 21)
1374
+ tasklet_hrtimer_start(&tcpack_sup_mod->tcpack_info_tbl[free_slot].timer,
1375
+ ktime_set(0, dhdp->tcpack_sup_delay*1000000), HRTIMER_MODE_REL);
1376
+#else
1377
+ hrtimer_start(&tcpack_sup_mod->tcpack_info_tbl[free_slot].timer,
1378
+ ktime_set(0, dhdp->tcpack_sup_delay*1000000), HRTIMER_MODE_REL_SOFT);
1379
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) */
1380
+#endif /* TCPACK_SUPPRESS_HOLD_HRT */
12761381 tcpack_sup_mod->tcpack_info_cnt++;
12771382 } else {
12781383 DHD_TRACE(("%s %d: No empty tcp ack info tbl\n",
....@@ -1284,3 +1389,54 @@
12841389 return hold;
12851390 }
12861391 #endif /* DHDTCPACK_SUPPRESS */
1392
+
1393
+#ifdef DHDTCPSYNC_FLOOD_BLK
1394
+tcp_hdr_flag_t
1395
+dhd_tcpdata_get_flag(dhd_pub_t *dhdp, void *pkt)
1396
+{
1397
+ uint8 *ether_hdr; /* Ethernet header of the new packet */
1398
+ uint16 ether_type; /* Ethernet type of the new packet */
1399
+ uint8 *ip_hdr; /* IP header of the new packet */
1400
+ uint8 *tcp_hdr; /* TCP header of the new packet */
1401
+ uint32 ip_hdr_len; /* IP header length of the new packet */
1402
+ uint32 cur_framelen;
1403
+ uint8 flags;
1404
+
1405
+ ether_hdr = PKTDATA(dhdp->osh, pkt);
1406
+ cur_framelen = PKTLEN(dhdp->osh, pkt);
1407
+
1408
+ ether_type = ether_hdr[12] << 8 | ether_hdr[13];
1409
+
1410
+ if (ether_type != ETHER_TYPE_IP) {
1411
+ DHD_TRACE(("%s %d: Not a IP packet 0x%x\n",
1412
+ __FUNCTION__, __LINE__, ether_type));
1413
+ return FLAG_OTHERS;
1414
+ }
1415
+
1416
+ ip_hdr = ether_hdr + ETHER_HDR_LEN;
1417
+ cur_framelen -= ETHER_HDR_LEN;
1418
+
1419
+ if (cur_framelen < IPV4_MIN_HEADER_LEN) {
1420
+ return FLAG_OTHERS;
1421
+ }
1422
+
1423
+ ip_hdr_len = IPV4_HLEN(ip_hdr);
1424
+ if (IP_VER(ip_hdr) != IP_VER_4 || IPV4_PROT(ip_hdr) != IP_PROT_TCP) {
1425
+ DHD_TRACE(("%s %d: Not IPv4 nor TCP! ip ver %d, prot %d\n",
1426
+ __FUNCTION__, __LINE__, IP_VER(ip_hdr), IPV4_PROT(ip_hdr)));
1427
+ return FLAG_OTHERS;
1428
+ }
1429
+
1430
+ tcp_hdr = ip_hdr + ip_hdr_len;
1431
+
1432
+ flags = (uint8)tcp_hdr[TCP_FLAGS_OFFSET];
1433
+
1434
+ if (flags & TCP_FLAG_SYN) {
1435
+ if (flags & TCP_FLAG_ACK) {
1436
+ return FLAG_SYNCACK;
1437
+ }
1438
+ return FLAG_SYNC;
1439
+ }
1440
+ return FLAG_OTHERS;
1441
+}
1442
+#endif /* DHDTCPSYNC_FLOOD_BLK */