GNU Linux-libre 4.14.313-gnu1
[releases.git] / drivers / staging / rtl8723bs / core / rtw_sta_mgt.c
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  ******************************************************************************/
15 #define _RTW_STA_MGT_C_
16
17 #include <drv_types.h>
18 #include <rtw_debug.h>
19
20 void _rtw_init_stainfo(struct sta_info *psta);
21 void _rtw_init_stainfo(struct sta_info *psta)
22 {
23         memset((u8 *)psta, 0, sizeof(struct sta_info));
24
25         spin_lock_init(&psta->lock);
26         INIT_LIST_HEAD(&psta->list);
27         INIT_LIST_HEAD(&psta->hash_list);
28         /* INIT_LIST_HEAD(&psta->asoc_list); */
29         /* INIT_LIST_HEAD(&psta->sleep_list); */
30         /* INIT_LIST_HEAD(&psta->wakeup_list); */
31
32         _rtw_init_queue(&psta->sleep_q);
33         psta->sleepq_len = 0;
34
35         _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv);
36         _rtw_init_sta_recv_priv(&psta->sta_recvpriv);
37
38         INIT_LIST_HEAD(&psta->asoc_list);
39
40         INIT_LIST_HEAD(&psta->auth_list);
41
42         psta->expire_to = 0;
43
44         psta->flags = 0;
45
46         psta->capability = 0;
47
48         psta->bpairwise_key_installed = false;
49
50         psta->nonerp_set = 0;
51         psta->no_short_slot_time_set = 0;
52         psta->no_short_preamble_set = 0;
53         psta->no_ht_gf_set = 0;
54         psta->no_ht_set = 0;
55         psta->ht_20mhz_set = 0;
56
57         psta->under_exist_checking = 0;
58
59         psta->keep_alive_trycnt = 0;
60 }
61
62 u32 _rtw_init_sta_priv(struct   sta_priv *pstapriv)
63 {
64         struct sta_info *psta;
65         s32 i;
66
67         pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA+4);
68
69         if (!pstapriv->pallocated_stainfo_buf)
70                 return _FAIL;
71
72         pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
73                 ((SIZE_PTR)(pstapriv->pallocated_stainfo_buf) & 3);
74
75         _rtw_init_queue(&pstapriv->free_sta_queue);
76
77         spin_lock_init(&pstapriv->sta_hash_lock);
78
79         /* _rtw_init_queue(&pstapriv->asoc_q); */
80         pstapriv->asoc_sta_count = 0;
81         _rtw_init_queue(&pstapriv->sleep_q);
82         _rtw_init_queue(&pstapriv->wakeup_q);
83
84         psta = (struct sta_info *)(pstapriv->pstainfo_buf);
85
86
87         for (i = 0; i < NUM_STA; i++) {
88                 _rtw_init_stainfo(psta);
89
90                 INIT_LIST_HEAD(&(pstapriv->sta_hash[i]));
91
92                 list_add_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue));
93
94                 psta++;
95         }
96
97         pstapriv->sta_dz_bitmap = 0;
98         pstapriv->tim_bitmap = 0;
99
100         INIT_LIST_HEAD(&pstapriv->asoc_list);
101         INIT_LIST_HEAD(&pstapriv->auth_list);
102         spin_lock_init(&pstapriv->asoc_list_lock);
103         spin_lock_init(&pstapriv->auth_list_lock);
104         pstapriv->asoc_list_cnt = 0;
105         pstapriv->auth_list_cnt = 0;
106
107         pstapriv->auth_to = 3; /*  3*2 = 6 sec */
108         pstapriv->assoc_to = 3;
109         pstapriv->expire_to = 3; /*  3*2 = 6 sec */
110         pstapriv->max_num_sta = NUM_STA;
111         return _SUCCESS;
112 }
113
114 inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta)
115 {
116         int offset = (((u8 *)sta) - stapriv->pstainfo_buf)/sizeof(struct sta_info);
117
118         if (!stainfo_offset_valid(offset))
119                 DBG_871X("%s invalid offset(%d), out of range!!!", __func__, offset);
120
121         return offset;
122 }
123
124 inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset)
125 {
126         if (!stainfo_offset_valid(offset))
127                 DBG_871X("%s invalid offset(%d), out of range!!!", __func__, offset);
128
129         return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info));
130 }
131
132 /*  this function is used to free the memory of lock || sema for all stainfos */
133 void kfree_all_stainfo(struct sta_priv *pstapriv);
134 void kfree_all_stainfo(struct sta_priv *pstapriv)
135 {
136         struct list_head        *plist, *phead;
137         struct sta_info *psta = NULL;
138
139         spin_lock_bh(&pstapriv->sta_hash_lock);
140
141         phead = get_list_head(&pstapriv->free_sta_queue);
142         plist = get_next(phead);
143
144         while (phead != plist) {
145                 psta = LIST_CONTAINOR(plist, struct sta_info, list);
146                 plist = get_next(plist);
147         }
148
149         spin_unlock_bh(&pstapriv->sta_hash_lock);
150 }
151
152 void kfree_sta_priv_lock(struct sta_priv *pstapriv);
153 void kfree_sta_priv_lock(struct sta_priv *pstapriv)
154 {
155          kfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */
156 }
157
158 u32 _rtw_free_sta_priv(struct   sta_priv *pstapriv)
159 {
160         struct list_head        *phead, *plist;
161         struct sta_info *psta = NULL;
162         struct recv_reorder_ctrl *preorder_ctrl;
163         int     index;
164
165         if (pstapriv) {
166
167                 /*delete all reordering_ctrl_timer              */
168                 spin_lock_bh(&pstapriv->sta_hash_lock);
169                 for (index = 0; index < NUM_STA; index++) {
170                         phead = &(pstapriv->sta_hash[index]);
171                         plist = get_next(phead);
172
173                         while (phead != plist) {
174                                 int i;
175                                 psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
176                                 plist = get_next(plist);
177
178                                 for (i = 0; i < 16 ; i++) {
179                                         preorder_ctrl = &psta->recvreorder_ctrl[i];
180                                         del_timer_sync(&preorder_ctrl->reordering_ctrl_timer);
181                                 }
182                         }
183                 }
184                 spin_unlock_bh(&pstapriv->sta_hash_lock);
185                 /*===============================*/
186
187                 kfree_sta_priv_lock(pstapriv);
188
189                 if (pstapriv->pallocated_stainfo_buf)
190                         vfree(pstapriv->pallocated_stainfo_buf);
191
192         }
193         return _SUCCESS;
194 }
195
196 /* struct       sta_info *rtw_alloc_stainfo(_queue *pfree_sta_queue, unsigned char *hwaddr) */
197 struct  sta_info *rtw_alloc_stainfo(struct      sta_priv *pstapriv, u8 *hwaddr)
198 {
199         uint tmp_aid;
200         s32     index;
201         struct list_head        *phash_list;
202         struct sta_info *psta;
203         struct __queue *pfree_sta_queue;
204         struct recv_reorder_ctrl *preorder_ctrl;
205         int i = 0;
206         u16  wRxSeqInitialValue = 0xffff;
207
208         pfree_sta_queue = &pstapriv->free_sta_queue;
209
210         /* spin_lock_bh(&(pfree_sta_queue->lock)); */
211         spin_lock_bh(&(pstapriv->sta_hash_lock));
212         if (list_empty(&pfree_sta_queue->queue)) {
213                 /* spin_unlock_bh(&(pfree_sta_queue->lock)); */
214                 spin_unlock_bh(&(pstapriv->sta_hash_lock));
215                 psta = NULL;
216                 return psta;
217         } else{
218                 psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue), struct sta_info, list);
219
220                 list_del_init(&(psta->list));
221
222                 /* spin_unlock_bh(&(pfree_sta_queue->lock)); */
223
224                 tmp_aid = psta->aid;
225
226                 _rtw_init_stainfo(psta);
227
228                 psta->padapter = pstapriv->padapter;
229
230                 memcpy(psta->hwaddr, hwaddr, ETH_ALEN);
231
232                 index = wifi_mac_hash(hwaddr);
233
234                 RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("rtw_alloc_stainfo: index  = %x", index));
235
236                 if (index >= NUM_STA) {
237                         RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("ERROR => rtw_alloc_stainfo: index >= NUM_STA"));
238                         spin_unlock_bh(&(pstapriv->sta_hash_lock));
239                         psta = NULL;
240                         goto exit;
241                 }
242                 phash_list = &(pstapriv->sta_hash[index]);
243
244                 /* spin_lock_bh(&(pstapriv->sta_hash_lock)); */
245
246                 list_add_tail(&psta->hash_list, phash_list);
247
248                 pstapriv->asoc_sta_count++;
249
250                 /* spin_unlock_bh(&(pstapriv->sta_hash_lock)); */
251
252 /*  Commented by Albert 2009/08/13 */
253 /*  For the SMC router, the sequence number of first packet of WPS handshake will be 0. */
254 /*  In this case, this packet will be dropped by recv_decache function if we use the 0x00 as the default value for tid_rxseq variable. */
255 /*  So, we initialize the tid_rxseq variable as the 0xffff. */
256
257                 for (i = 0; i < 16; i++) {
258                         memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2);
259                 }
260
261                 RT_TRACE(
262                         _module_rtl871x_sta_mgt_c_,
263                         _drv_info_, (
264                                 "alloc number_%d stainfo  with hwaddr = %x %x %x %x %x %x \n",
265                                 pstapriv->asoc_sta_count,
266                                 hwaddr[0],
267                                 hwaddr[1],
268                                 hwaddr[2],
269                                 hwaddr[3],
270                                 hwaddr[4],
271                                 hwaddr[5]
272                         )
273                 );
274
275                 init_addba_retry_timer(pstapriv->padapter, psta);
276
277                 /* for A-MPDU Rx reordering buffer control */
278                 for (i = 0; i < 16 ; i++) {
279                         preorder_ctrl = &psta->recvreorder_ctrl[i];
280
281                         preorder_ctrl->padapter = pstapriv->padapter;
282
283                         preorder_ctrl->enable = false;
284
285                         preorder_ctrl->indicate_seq = 0xffff;
286                         #ifdef DBG_RX_SEQ
287                         DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d\n", __func__, __LINE__,
288                                 preorder_ctrl->indicate_seq);
289                         #endif
290                         preorder_ctrl->wend_b = 0xffff;
291                         /* preorder_ctrl->wsize_b = (NR_RECVBUFF-2); */
292                         preorder_ctrl->wsize_b = 64;/* 64; */
293
294                         _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue);
295
296                         rtw_init_recv_timer(preorder_ctrl);
297                 }
298
299
300                 /* init for DM */
301                 psta->rssi_stat.UndecoratedSmoothedPWDB = (-1);
302                 psta->rssi_stat.UndecoratedSmoothedCCK = (-1);
303
304                 /* init for the sequence number of received management frame */
305                 psta->RxMgmtFrameSeqNum = 0xffff;
306                 spin_unlock_bh(&(pstapriv->sta_hash_lock));
307                 /* alloc mac id for non-bc/mc station, */
308                 rtw_alloc_macid(pstapriv->padapter, psta);
309
310         }
311
312 exit:
313
314
315         return psta;
316 }
317
318 /*  using pstapriv->sta_hash_lock to protect */
319 u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta)
320 {
321         int i;
322         struct __queue *pfree_sta_queue;
323         struct recv_reorder_ctrl *preorder_ctrl;
324         struct  sta_xmit_priv *pstaxmitpriv;
325         struct  xmit_priv *pxmitpriv = &padapter->xmitpriv;
326         struct  sta_priv *pstapriv = &padapter->stapriv;
327         struct hw_xmit *phwxmit;
328
329         if (psta == NULL)
330                 goto exit;
331
332
333         spin_lock_bh(&psta->lock);
334         psta->state &= ~_FW_LINKED;
335         spin_unlock_bh(&psta->lock);
336
337         pfree_sta_queue = &pstapriv->free_sta_queue;
338
339
340         pstaxmitpriv = &psta->sta_xmitpriv;
341
342         /* list_del_init(&psta->sleep_list); */
343
344         /* list_del_init(&psta->wakeup_list); */
345
346         spin_lock_bh(&pxmitpriv->lock);
347
348         rtw_free_xmitframe_queue(pxmitpriv, &psta->sleep_q);
349         psta->sleepq_len = 0;
350
351         /* vo */
352         /* spin_lock_bh(&(pxmitpriv->vo_pending.lock)); */
353         rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending);
354         list_del_init(&(pstaxmitpriv->vo_q.tx_pending));
355         phwxmit = pxmitpriv->hwxmits;
356         phwxmit->accnt -= pstaxmitpriv->vo_q.qcnt;
357         pstaxmitpriv->vo_q.qcnt = 0;
358         /* spin_unlock_bh(&(pxmitpriv->vo_pending.lock)); */
359
360         /* vi */
361         /* spin_lock_bh(&(pxmitpriv->vi_pending.lock)); */
362         rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending);
363         list_del_init(&(pstaxmitpriv->vi_q.tx_pending));
364         phwxmit = pxmitpriv->hwxmits+1;
365         phwxmit->accnt -= pstaxmitpriv->vi_q.qcnt;
366         pstaxmitpriv->vi_q.qcnt = 0;
367         /* spin_unlock_bh(&(pxmitpriv->vi_pending.lock)); */
368
369         /* be */
370         /* spin_lock_bh(&(pxmitpriv->be_pending.lock)); */
371         rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending);
372         list_del_init(&(pstaxmitpriv->be_q.tx_pending));
373         phwxmit = pxmitpriv->hwxmits+2;
374         phwxmit->accnt -= pstaxmitpriv->be_q.qcnt;
375         pstaxmitpriv->be_q.qcnt = 0;
376         /* spin_unlock_bh(&(pxmitpriv->be_pending.lock)); */
377
378         /* bk */
379         /* spin_lock_bh(&(pxmitpriv->bk_pending.lock)); */
380         rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending);
381         list_del_init(&(pstaxmitpriv->bk_q.tx_pending));
382         phwxmit = pxmitpriv->hwxmits+3;
383         phwxmit->accnt -= pstaxmitpriv->bk_q.qcnt;
384         pstaxmitpriv->bk_q.qcnt = 0;
385         /* spin_unlock_bh(&(pxmitpriv->bk_pending.lock)); */
386
387         spin_unlock_bh(&pxmitpriv->lock);
388
389         list_del_init(&psta->hash_list);
390         RT_TRACE(
391                 _module_rtl871x_sta_mgt_c_,
392                 _drv_err_, (
393                         "\n free number_%d stainfo  with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x \n",
394                         pstapriv->asoc_sta_count,
395                         psta->hwaddr[0],
396                         psta->hwaddr[1],
397                         psta->hwaddr[2],
398                         psta->hwaddr[3],
399                         psta->hwaddr[4],
400                         psta->hwaddr[5]
401                 )
402         );
403         pstapriv->asoc_sta_count--;
404
405
406         /*  re-init sta_info; 20061114 will be init in alloc_stainfo */
407         /* _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); */
408         /* _rtw_init_sta_recv_priv(&psta->sta_recvpriv); */
409
410         del_timer_sync(&psta->addba_retry_timer);
411
412         /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */
413         for (i = 0; i < 16 ; i++) {
414                 struct list_head        *phead, *plist;
415                 union recv_frame *prframe;
416                 struct __queue *ppending_recvframe_queue;
417                 struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
418
419                 preorder_ctrl = &psta->recvreorder_ctrl[i];
420
421                 del_timer_sync(&preorder_ctrl->reordering_ctrl_timer);
422
423
424                 ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
425
426                 spin_lock_bh(&ppending_recvframe_queue->lock);
427
428                 phead =         get_list_head(ppending_recvframe_queue);
429                 plist = get_next(phead);
430
431                 while (!list_empty(phead)) {
432                         prframe = LIST_CONTAINOR(plist, union recv_frame, u);
433
434                         plist = get_next(plist);
435
436                         list_del_init(&(prframe->u.hdr.list));
437
438                         rtw_free_recvframe(prframe, pfree_recv_queue);
439                 }
440
441                 spin_unlock_bh(&ppending_recvframe_queue->lock);
442
443         }
444
445         if (!(psta->state & WIFI_AP_STATE))
446                 rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, false);
447
448
449         /* release mac id for non-bc/mc station, */
450         rtw_release_macid(pstapriv->padapter, psta);
451
452 /*
453         spin_lock_bh(&pstapriv->asoc_list_lock);
454         list_del_init(&psta->asoc_list);
455         spin_unlock_bh(&pstapriv->asoc_list_lock);
456 */
457         spin_lock_bh(&pstapriv->auth_list_lock);
458         if (!list_empty(&psta->auth_list)) {
459                 list_del_init(&psta->auth_list);
460                 pstapriv->auth_list_cnt--;
461         }
462         spin_unlock_bh(&pstapriv->auth_list_lock);
463
464         psta->expire_to = 0;
465         psta->sleepq_ac_len = 0;
466         psta->qos_info = 0;
467
468         psta->max_sp_len = 0;
469         psta->uapsd_bk = 0;
470         psta->uapsd_be = 0;
471         psta->uapsd_vi = 0;
472         psta->uapsd_vo = 0;
473
474         psta->has_legacy_ac = 0;
475
476         pstapriv->sta_dz_bitmap &= ~BIT(psta->aid);
477         pstapriv->tim_bitmap &= ~BIT(psta->aid);
478
479         if ((psta->aid > 0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) {
480                 pstapriv->sta_aid[psta->aid - 1] = NULL;
481                 psta->aid = 0;
482         }
483
484         psta->under_exist_checking = 0;
485
486         /* spin_lock_bh(&(pfree_sta_queue->lock)); */
487         list_add_tail(&psta->list, get_list_head(pfree_sta_queue));
488         /* spin_unlock_bh(&(pfree_sta_queue->lock)); */
489
490 exit:
491         return _SUCCESS;
492 }
493
494 /*  free all stainfo which in sta_hash[all] */
495 void rtw_free_all_stainfo(struct adapter *padapter)
496 {
497         struct list_head        *plist, *phead;
498         s32     index;
499         struct sta_info *psta = NULL;
500         struct  sta_priv *pstapriv = &padapter->stapriv;
501         struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter);
502
503         if (pstapriv->asoc_sta_count == 1)
504                 return;
505
506         spin_lock_bh(&pstapriv->sta_hash_lock);
507
508         for (index = 0; index < NUM_STA; index++) {
509                 phead = &(pstapriv->sta_hash[index]);
510                 plist = get_next(phead);
511
512                 while (phead != plist) {
513                         psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
514
515                         plist = get_next(plist);
516
517                         if (pbcmc_stainfo != psta)
518                                 rtw_free_stainfo(padapter, psta);
519
520                 }
521         }
522
523         spin_unlock_bh(&pstapriv->sta_hash_lock);
524 }
525
526 /* any station allocated can be searched by hash list */
527 struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
528 {
529         struct list_head        *plist, *phead;
530         struct sta_info *psta = NULL;
531         u32 index;
532         u8 *addr;
533         u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
534
535         if (hwaddr == NULL)
536                 return NULL;
537
538         if (IS_MCAST(hwaddr))
539                 addr = bc_addr;
540         else
541                 addr = hwaddr;
542
543         index = wifi_mac_hash(addr);
544
545         spin_lock_bh(&pstapriv->sta_hash_lock);
546
547         phead = &(pstapriv->sta_hash[index]);
548         plist = get_next(phead);
549
550
551         while (phead != plist) {
552
553                 psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
554
555                 if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)))
556                  /*  if found the matched address */
557                         break;
558
559                 psta = NULL;
560                 plist = get_next(plist);
561         }
562
563         spin_unlock_bh(&pstapriv->sta_hash_lock);
564         return psta;
565 }
566
567 u32 rtw_init_bcmc_stainfo(struct adapter *padapter)
568 {
569
570         struct sta_info *psta;
571         struct tx_servq *ptxservq;
572         u32 res = _SUCCESS;
573         NDIS_802_11_MAC_ADDRESS bcast_addr = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
574
575         struct  sta_priv *pstapriv = &padapter->stapriv;
576         /* struct __queue       *pstapending = &padapter->xmitpriv.bm_pending; */
577
578         psta = rtw_alloc_stainfo(pstapriv, bcast_addr);
579
580         if (psta == NULL) {
581                 res = _FAIL;
582                 RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("rtw_alloc_stainfo fail"));
583                 goto exit;
584         }
585
586         /*  default broadcast & multicast use macid 1 */
587         psta->mac_id = 1;
588
589         ptxservq = &(psta->sta_xmitpriv.be_q);
590 exit:
591         return _SUCCESS;
592 }
593
594
595 struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter)
596 {
597         struct sta_info *psta;
598         struct sta_priv *pstapriv = &padapter->stapriv;
599         u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
600
601         psta = rtw_get_stainfo(pstapriv, bc_addr);
602         return psta;
603 }
604
605 u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
606 {
607         u8 res = true;
608         struct list_head        *plist, *phead;
609         struct rtw_wlan_acl_node *paclnode;
610         u8 match = false;
611         struct sta_priv *pstapriv = &padapter->stapriv;
612         struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
613         struct __queue  *pacl_node_q = &pacl_list->acl_node_q;
614
615         spin_lock_bh(&(pacl_node_q->lock));
616         phead = get_list_head(pacl_node_q);
617         plist = get_next(phead);
618         while (phead != plist) {
619                 paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list);
620                 plist = get_next(plist);
621
622                 if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN))
623                         if (paclnode->valid == true) {
624                                 match = true;
625                                 break;
626                         }
627
628         }
629         spin_unlock_bh(&(pacl_node_q->lock));
630
631
632         if (pacl_list->mode == 1) /* accept unless in deny list */
633                 res = (match == true) ?  false:true;
634
635         else if (pacl_list->mode == 2)/* deny unless in accept list */
636                 res = (match == true) ?  true:false;
637         else
638                  res = true;
639
640         return res;
641 }