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