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