29 #define _RTL871X_RECV_C_
32 #include <linux/slab.h>
33 #include <linux/if_ether.h>
45 static const u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37};
48 static const u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3};
51 static const u8 bridge_tunnel_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
54 static const u8 rfc1042_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
89 _init_listhead(&(precvframe->
u.
list));
90 list_insert_tail(&(precvframe->
u.
list),
93 precvframe->
u.
hdr.adapter = padapter;
115 if (_queue_empty(pfree_recv_queue) ==
true)
118 phead = get_list_head(pfree_recv_queue);
121 list_delete(&precvframe->
u.
hdr.list);
122 padapter = precvframe->
u.
hdr.adapter;
123 if (padapter !=
NULL) {
129 spin_unlock_irqrestore(&pfree_recv_queue->
lock, irqL);
142 struct __queue *pfree_recv_queue)
147 spin_lock(&pframequeue->
lock);
148 phead = get_list_head(pframequeue);
150 while (end_of_queue_search(phead, plist) ==
false) {
155 spin_unlock(&pframequeue->
lock);
174 if (stainfo !=
NULL) {
175 if (IS_MCAST(prxattrib->
ra)) {
176 iv = precvframe->
u.
hdr.rx_data +
180 6) & 0x3)) - 1].skey[0];
186 datalen = precvframe->
u.
hdr.len - prxattrib->
hdrlen -
188 pframe = precvframe->
u.
hdr.rx_data;
189 payload = pframe + prxattrib->
hdrlen +
193 (
unsigned char)prxattrib->
priority);
196 for (i = 0; i < 8; i++) {
197 if (miccode[i] != *(pframemic + i))
200 if (bmic_err ==
true) {
203 (
u8)IS_MCAST(prxattrib->
ra));
208 false) && (IS_MCAST(prxattrib->
ra) ==
212 recvframe_pull_tail(precvframe, 8);
224 union recv_frame *return_packet = precv_frame;
245 return return_packet;
260 ptr = get_recvframe_data(precv_frame);
261 pfhdr = &precv_frame->
u.
hdr;
262 psta_addr = pfhdr->
attrib.ta;
269 prtnframe = precv_frame;
271 ptr = ptr + pfhdr->
attrib.hdrlen +
273 memcpy(ðer_type, ptr, 2);
274 ether_type =
ntohs((
unsigned short)ether_type);
275 if (ether_type == 0x888e)
276 prtnframe = precv_frame;
280 &adapter->
recvpriv.free_recv_queue);
287 prtnframe = precv_frame;
289 if (ether_type == 0x888e) {
291 prtnframe = precv_frame;
295 prtnframe = precv_frame;
304 (precv_frame->
u.
hdr.attrib.frag_num & 0xf);
308 if (seq_ctrl == prxcache->
tid_rxseq[tid])
323 u8 *mybssid = get_bssid(pmlmepriv);
326 sint bmcast = IS_MCAST(pattrib->
dst);
335 if (is_zero_ether_addr(pattrib->
bssid) ||
336 is_zero_ether_addr(mybssid) ||
339 sta_addr = pattrib->
src;
345 sta_addr = pattrib->
bssid;
346 }
else if (check_fwstate(pmlmepriv,
WIFI_AP_STATE) ==
true) {
350 if (!IS_MCAST(pattrib->
bssid))
357 sta_addr = pattrib->
src;
359 }
else if (check_fwstate(pmlmepriv,
WIFI_MP_STATE) ==
true) {
374 adapter->
mppriv.rx_pktloss++;
384 u8 *ptr = precv_frame->
u.
hdr.rx_data;
388 u8 *mybssid = get_bssid(pmlmepriv);
390 sint bmcast = IS_MCAST(pattrib->
dst);
393 && (check_fwstate(pmlmepriv,
_FW_LINKED) ==
true)) {
400 WIFI_QOS_DATA_TYPE) {
413 if (is_zero_ether_addr(pattrib->
bssid) ||
414 is_zero_ether_addr(mybssid) ||
423 }
else if ((check_fwstate(pmlmepriv,
WIFI_MP_STATE) ==
true) &&
424 (check_fwstate(pmlmepriv,
_FW_LINKED) ==
true)) {
446 unsigned char *mybssid = get_bssid(pmlmepriv);
461 static sint validate_recv_ctrl_frame(
struct _adapter *adapter,
467 static sint validate_recv_mgnt_frame(
struct _adapter *adapter,
474 static sint validate_recv_data_frame(
struct _adapter *adapter,
481 u8 *ptr = precv_frame->
u.
hdr.rx_data;
488 pbssid = get_hdr_bssid(ptr);
498 res = sta2sta_data_frame(adapter, precv_frame, &psta);
503 res = ap2sta_data_frame(adapter, precv_frame, &psta);
508 res = sta2ap_data_frame(adapter, precv_frame, &psta);
522 precv_frame->
u.
hdr.psta = psta;
525 if (pattrib->
qos == 1) {
537 precv_frame->
u.
hdr.preorder_ctrl =
541 if (recv_decache(precv_frame, bretry, &psta->
sta_recvpriv.rxcache) ==
547 IS_MCAST(pattrib->
ra));
568 u8 *ptr = precv_frame->
u.
hdr.rx_data;
586 retval = validate_recv_mgnt_frame(adapter, precv_frame);
589 retval = validate_recv_ctrl_frame(adapter, precv_frame);
592 pattrib->
qos = (subtype &
BIT(7)) ? 1 : 0;
593 retval = validate_recv_data_frame(adapter, precv_frame);
614 u8 *ptr = get_recvframe_data(precvframe);
618 recvframe_pull_tail(precvframe, pattrib->
icv_len);
624 (
memcmp(psnap_type, (
void *)SNAP_ETH_TYPE_IPX, 2)) &&
625 (
memcmp(psnap_type, (
void *)SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
636 len = precvframe->
u.
hdr.len - rmv_len;
643 ptr = recvframe_pull(precvframe, (rmv_len -
644 sizeof(
struct ethhdr) + 2) - 24);
645 memcpy(ptr, get_rxmem(precvframe), 24);
648 ptr = recvframe_pull(precvframe, (rmv_len -
649 sizeof(
struct ethhdr) + (bsnaphdr ? 2 : 0)));
655 memcpy(ptr + 12, &len, 2);
669 struct __queue *pfree_recv_queue, *ppending_recv_queue;
673 padapter = precvframe->
u.
hdr.adapter;
680 phead = precvframe->
u.
hdr.rx_head;
681 pdata = precvframe->
u.
hdr.rx_data;
682 ptail = precvframe->
u.
hdr.rx_tail;
683 pend = precvframe->
u.
hdr.rx_end;
690 goto _recv_entry_drop;
693 precvframe->
u.
hdr.rx_data);