hc
2024-08-16 62c46c9150c4afde7e5b25436263fddf79d66f0b
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
/*
 * Copyright (C) 2016 Spreadtrum Communications Inc.
 *
 * Authors:
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
 
#ifndef __SPRDWL_TCP_ACK_H__
#define __SPRDWL_TCP_ACK_H__
 
#include "msg.h"
 
#define SPRDWL_TCP_ACK_NUM  32
#define SPRDWL_TCP_ACK_EXIT_VAL        0x800
#define SPRDWL_TCP_ACK_DROP_CNT        24
 
#define SPRDWL_ACK_OLD_TIME    4000
#define SPRDWL_U32_BEFORE(a, b)    ((__s32)((__u32)a - (__u32)b) <= 0)
 
#define MAX_TCP_ACK 200
/*min window size in KB, it's 256KB*/
#define MIN_WIN 256
#define SIZE_KB 1024
 
extern unsigned int tcp_ack_drop_cnt;
struct sprdwl_tcp_ack_msg {
   u16 source;
   u16 dest;
   s32 saddr;
   s32 daddr;
   u32 seq;
   u16 win;
};
 
struct sprdwl_tcp_ack_info {
   int ack_info_num;
   int busy;
   int drop_cnt;
   int psh_flag;
   u32 psh_seq;
   u16 win_scale;
   /* seqlock for ack info */
   seqlock_t seqlock;
   unsigned long last_time;
   unsigned long timeout;
   struct timer_list timer;
   struct sprdwl_msg_buf *msgbuf;
   struct sprdwl_msg_buf *in_send_msg;
   struct sprdwl_tcp_ack_msg ack_msg;
};
 
struct sprdwl_tcp_ack_manage {
   /* 1 filter */
   atomic_t enable;
   int max_num;
   int free_index;
   unsigned long last_time;
   unsigned long timeout;
   atomic_t max_drop_cnt;
   /* lock for tcp ack alloc and free */
   spinlock_t lock;
   struct sprdwl_priv *priv;
   struct sprdwl_tcp_ack_info ack_info[SPRDWL_TCP_ACK_NUM];
   /*size in KB*/
   unsigned int ack_winsize;
};
 
void sprdwl_tcp_ack_init(struct sprdwl_priv *priv);
void sprdwl_tcp_ack_deinit(struct sprdwl_priv *priv);
void sprdwl_filter_rx_tcp_ack(struct sprdwl_priv *priv,
                 unsigned char *buf, unsigned int plen);
/* return val: 0 for not fileter, 1 for fileter */
int sprdwl_filter_send_tcp_ack(struct sprdwl_priv *priv,
                  struct sprdwl_msg_buf *msgbuf,
                  unsigned char *buf, unsigned int plen);
void enable_tcp_ack_delay(char *buf, unsigned char offset);
void adjust_tcp_ack_delay(char *buf, unsigned char offset);
void sprdwl_move_tcpack_msg(struct sprdwl_priv *priv,
               struct sprdwl_msg_buf *msg);
void adjust_tcp_ack_delay_win(char *buf, unsigned char offset);
#endif