1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _RTL871X_RECV_H_ |
3 | #define _RTL871X_RECV_H_ |
4 | |
5 | #include "osdep_service.h" |
6 | #include "drv_types.h" |
7 | |
8 | #define NR_RECVFRAME 256 |
9 | |
10 | #define RXFRAME_ALIGN 8 |
11 | #define RXFRAME_ALIGN_SZ (1 << RXFRAME_ALIGN) |
12 | |
13 | #define MAX_SUBFRAME_COUNT 64 |
14 | |
15 | /* for Rx reordering buffer control */ |
16 | struct recv_reorder_ctrl { |
17 | struct _adapter *padapter; |
18 | u16 indicate_seq; /* =wstart_b, init_value=0xffff */ |
19 | u16 wend_b; |
20 | u8 wsize_b; |
21 | struct __queue pending_recvframe_queue; |
22 | struct timer_list reordering_ctrl_timer; |
23 | }; |
24 | |
25 | struct stainfo_rxcache { |
26 | u16 tid_rxseq[16]; |
27 | }; |
28 | |
29 | #define 100 |
30 | #define PHY_LINKQUALITY_SLID_WIN_MAX 20 |
31 | |
32 | struct { |
33 | u32 [100]; /* array to store values */ |
34 | u32 ; /* index to current array to store */ |
35 | u32 ; /* num of valid elements */ |
36 | u32 ; /* sum of valid elements */ |
37 | }; |
38 | |
39 | struct rx_pkt_attrib { |
40 | u8 amsdu; |
41 | u8 order; |
42 | u8 qos; |
43 | u8 to_fr_ds; |
44 | u8 frag_num; |
45 | u16 seq_num; |
46 | u8 pw_save; |
47 | u8 mfrag; |
48 | u8 mdata; |
49 | u8 privacy; /* in frame_ctrl field */ |
50 | u8 bdecrypted; |
51 | int hdrlen; /* the WLAN Header Len */ |
52 | int encrypt; /* 0 no encrypt. != 0 encrypt algorithm */ |
53 | int iv_len; |
54 | int icv_len; |
55 | int priority; |
56 | int ack_policy; |
57 | u8 crc_err; |
58 | u8 dst[ETH_ALEN]; |
59 | u8 src[ETH_ALEN]; |
60 | u8 ta[ETH_ALEN]; |
61 | u8 ra[ETH_ALEN]; |
62 | u8 bssid[ETH_ALEN]; |
63 | u8 tcpchk_valid; /* 0: invalid, 1: valid */ |
64 | u8 ip_chkrpt; /* 0: incorrect, 1: correct */ |
65 | u8 tcp_chkrpt; /* 0: incorrect, 1: correct */ |
66 | u8 signal_qual; |
67 | s8 rx_mimo_signal_qual[2]; |
68 | u8 mcs_rate; |
69 | u8 htc; |
70 | u8 signal_strength; |
71 | }; |
72 | |
73 | /* |
74 | * accesser of recv_priv: recv_entry(dispatch / passive level); |
75 | * recv_thread(passive) ; returnpkt(dispatch) |
76 | * ; halt(passive) ; |
77 | * |
78 | * using enter_critical section to protect |
79 | */ |
80 | struct recv_priv { |
81 | spinlock_t lock; |
82 | struct __queue free_recv_queue; |
83 | struct __queue recv_pending_queue; |
84 | u8 *pallocated_frame_buf; |
85 | u8 *precv_frame_buf; |
86 | uint free_recvframe_cnt; |
87 | struct _adapter *adapter; |
88 | uint rx_bytes; |
89 | uint rx_pkts; |
90 | uint rx_drop; |
91 | uint rx_icv_err; |
92 | uint rx_largepacket_crcerr; |
93 | uint rx_smallpacket_crcerr; |
94 | uint rx_middlepacket_crcerr; |
95 | u8 rx_pending_cnt; |
96 | uint ff_hwaddr; |
97 | struct tasklet_struct recv_tasklet; |
98 | struct sk_buff_head free_recv_skb_queue; |
99 | struct sk_buff_head rx_skb_queue; |
100 | u8 *pallocated_recv_buf; |
101 | u8 *precv_buf; /* 4 alignment */ |
102 | struct __queue free_recv_buf_queue; |
103 | u32 free_recv_buf_queue_cnt; |
104 | /* For the phy information */ |
105 | s8 ; |
106 | u8 signal; |
107 | u8 noise; |
108 | u8 ; |
109 | struct smooth_rssi_data signal_qual_data; |
110 | struct smooth_rssi_data signal_strength_data; |
111 | }; |
112 | |
113 | struct sta_recv_priv { |
114 | spinlock_t lock; |
115 | sint option; |
116 | struct __queue defrag_q; /* keeping the fragment frame until defrag */ |
117 | struct stainfo_rxcache rxcache; |
118 | uint sta_rx_bytes; |
119 | uint sta_rx_pkts; |
120 | uint sta_rx_fail; |
121 | }; |
122 | |
123 | #include "rtl8712_recv.h" |
124 | |
125 | /* get a free recv_frame from pfree_recv_queue */ |
126 | union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue); |
127 | void r8712_free_recvframe(union recv_frame *precvframe, |
128 | struct __queue *pfree_recv_queue); |
129 | void r8712_free_recvframe_queue(struct __queue *pframequeue, |
130 | struct __queue *pfree_recv_queue); |
131 | int r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe); |
132 | int recv_func(struct _adapter *padapter, void *pcontext); |
133 | |
134 | static inline u8 *get_rxmem(union recv_frame *precvframe) |
135 | { |
136 | /* always return rx_head... */ |
137 | if (!precvframe) |
138 | return NULL; |
139 | return precvframe->u.hdr.rx_head; |
140 | } |
141 | |
142 | static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz) |
143 | { |
144 | /* used for extract sz bytes from rx_data, update rx_data and return |
145 | * the updated rx_data to the caller |
146 | */ |
147 | if (!precvframe) |
148 | return NULL; |
149 | precvframe->u.hdr.rx_data += sz; |
150 | if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) { |
151 | precvframe->u.hdr.rx_data -= sz; |
152 | return NULL; |
153 | } |
154 | precvframe->u.hdr.len -= sz; |
155 | return precvframe->u.hdr.rx_data; |
156 | } |
157 | |
158 | static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz) |
159 | { |
160 | /* used for append sz bytes from ptr to rx_tail, update rx_tail and |
161 | * return the updated rx_tail to the caller |
162 | * after putting, rx_tail must be still larger than rx_end. |
163 | */ |
164 | if (!precvframe) |
165 | return NULL; |
166 | precvframe->u.hdr.rx_tail += sz; |
167 | if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) { |
168 | precvframe->u.hdr.rx_tail -= sz; |
169 | return NULL; |
170 | } |
171 | precvframe->u.hdr.len += sz; |
172 | return precvframe->u.hdr.rx_tail; |
173 | } |
174 | |
175 | static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz) |
176 | { |
177 | /* rmv data from rx_tail (by yitsen) |
178 | * used for extract sz bytes from rx_end, update rx_end and return the |
179 | * updated rx_end to the caller |
180 | * after pulling, rx_end must be still larger than rx_data. |
181 | */ |
182 | if (!precvframe) |
183 | return NULL; |
184 | precvframe->u.hdr.rx_tail -= sz; |
185 | if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) { |
186 | precvframe->u.hdr.rx_tail += sz; |
187 | return NULL; |
188 | } |
189 | precvframe->u.hdr.len -= sz; |
190 | return precvframe->u.hdr.rx_tail; |
191 | } |
192 | |
193 | struct sta_info; |
194 | |
195 | void _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv); |
196 | sint r8712_recvframe_chkmic(struct _adapter *adapter, |
197 | union recv_frame *precvframe); |
198 | union recv_frame *r8712_decryptor(struct _adapter *adapter, |
199 | union recv_frame *precv_frame); |
200 | union recv_frame *r8712_recvframe_chk_defrag(struct _adapter *adapter, |
201 | union recv_frame *precv_frame); |
202 | int r8712_validate_recv_frame(struct _adapter *adapter, |
203 | union recv_frame *precv_frame); |
204 | union recv_frame *r8712_portctrl(struct _adapter *adapter, |
205 | union recv_frame *precv_frame); |
206 | |
207 | #endif |
208 | |
209 | |