1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
20 #define _RTW_STA_MGT_C_
22 #include <drv_types.h>
24 #if defined (PLATFORM_LINUX) && defined (PLATFORM_WINDOWS)
26 #error "Shall be Linux or Windows, but not both!\n"
31 void _rtw_init_stainfo(struct sta_info *psta);
32 void _rtw_init_stainfo(struct sta_info *psta)
37 _rtw_memset((u8 *)psta, 0, sizeof (struct sta_info));
39 _rtw_spinlock_init(&psta->lock);
40 _rtw_init_listhead(&psta->list);
41 _rtw_init_listhead(&psta->hash_list);
42 //_rtw_init_listhead(&psta->asoc_list);
43 //_rtw_init_listhead(&psta->sleep_list);
44 //_rtw_init_listhead(&psta->wakeup_list);
46 _rtw_init_queue(&psta->sleep_q);
49 _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv);
50 _rtw_init_sta_recv_priv(&psta->sta_recvpriv);
54 _rtw_init_listhead(&psta->asoc_list);
56 _rtw_init_listhead(&psta->auth_list);
64 psta->bpairwise_key_installed = _FALSE;
67 #ifdef CONFIG_NATIVEAP_MLME
69 psta->no_short_slot_time_set = 0;
70 psta->no_short_preamble_set = 0;
71 psta->no_ht_gf_set = 0;
73 psta->ht_20mhz_set = 0;
76 #ifdef CONFIG_TX_MCAST2UNI
77 psta->under_exist_checking = 0;
78 #endif // CONFIG_TX_MCAST2UNI
80 psta->keep_alive_trycnt = 0;
82 #endif // CONFIG_AP_MODE
88 u32 _rtw_init_sta_priv(struct sta_priv *pstapriv)
90 struct sta_info *psta;
95 pstapriv->pallocated_stainfo_buf = rtw_zvmalloc (sizeof(struct sta_info) * NUM_STA+ 4);
97 if(!pstapriv->pallocated_stainfo_buf)
100 pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
101 ((SIZE_PTR)(pstapriv->pallocated_stainfo_buf ) & 3);
103 _rtw_init_queue(&pstapriv->free_sta_queue);
105 _rtw_spinlock_init(&pstapriv->sta_hash_lock);
107 //_rtw_init_queue(&pstapriv->asoc_q);
108 pstapriv->asoc_sta_count = 0;
109 _rtw_init_queue(&pstapriv->sleep_q);
110 _rtw_init_queue(&pstapriv->wakeup_q);
112 psta = (struct sta_info *)(pstapriv->pstainfo_buf);
115 for(i = 0; i < NUM_STA; i++)
117 _rtw_init_stainfo(psta);
119 _rtw_init_listhead(&(pstapriv->sta_hash[i]));
121 rtw_list_insert_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue));
128 #ifdef CONFIG_AP_MODE
130 pstapriv->sta_dz_bitmap = 0;
131 pstapriv->tim_bitmap = 0;
133 _rtw_init_listhead(&pstapriv->asoc_list);
134 _rtw_init_listhead(&pstapriv->auth_list);
135 _rtw_spinlock_init(&pstapriv->asoc_list_lock);
136 _rtw_spinlock_init(&pstapriv->auth_list_lock);
137 pstapriv->asoc_list_cnt = 0;
138 pstapriv->auth_list_cnt = 0;
140 pstapriv->auth_to = 3; // 3*2 = 6 sec
141 pstapriv->assoc_to = 3;
142 //pstapriv->expire_to = 900;// 900*2 = 1800 sec = 30 min, expire after no any traffic.
143 //pstapriv->expire_to = 30;// 30*2 = 60 sec = 1 min, expire after no any traffic.
144 #ifdef CONFIG_ACTIVE_KEEP_ALIVE_CHECK
145 pstapriv->expire_to = 3; // 3*2 = 6 sec
147 pstapriv->expire_to = 60;// 60*2 = 120 sec = 2 min, expire after no any traffic.
149 #ifdef CONFIG_ATMEL_RC_PATCH
150 _rtw_memset( pstapriv->atmel_rc_pattern, 0, ETH_ALEN);
152 pstapriv->max_num_sta = NUM_STA;
162 inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta)
164 int offset = (((u8 *)sta) - stapriv->pstainfo_buf)/sizeof(struct sta_info);
166 if (!stainfo_offset_valid(offset))
167 DBG_871X("%s invalid offset(%d), out of range!!!", __func__, offset);
172 inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset)
174 if (!stainfo_offset_valid(offset))
175 DBG_871X("%s invalid offset(%d), out of range!!!", __func__, offset);
177 return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info));
180 void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv);
181 void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv)
185 _rtw_spinlock_free(&psta_xmitpriv->lock);
187 _rtw_spinlock_free(&(psta_xmitpriv->be_q.sta_pending.lock));
188 _rtw_spinlock_free(&(psta_xmitpriv->bk_q.sta_pending.lock));
189 _rtw_spinlock_free(&(psta_xmitpriv->vi_q.sta_pending.lock));
190 _rtw_spinlock_free(&(psta_xmitpriv->vo_q.sta_pending.lock));
194 static void _rtw_free_sta_recv_priv_lock(struct sta_recv_priv *psta_recvpriv)
198 _rtw_spinlock_free(&psta_recvpriv->lock);
200 _rtw_spinlock_free(&(psta_recvpriv->defrag_q.lock));
206 void rtw_mfree_stainfo(struct sta_info *psta);
207 void rtw_mfree_stainfo(struct sta_info *psta)
211 if(&psta->lock != NULL)
212 _rtw_spinlock_free(&psta->lock);
214 _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv);
215 _rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv);
221 // this function is used to free the memory of lock || sema for all stainfos
222 void rtw_mfree_all_stainfo(struct sta_priv *pstapriv );
223 void rtw_mfree_all_stainfo(struct sta_priv *pstapriv )
226 _list *plist, *phead;
227 struct sta_info *psta = NULL;
231 _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL);
233 phead = get_list_head(&pstapriv->free_sta_queue);
234 plist = get_next(phead);
236 while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
238 psta = LIST_CONTAINOR(plist, struct sta_info ,list);
239 plist = get_next(plist);
241 rtw_mfree_stainfo(psta);
244 _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL);
250 void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv);
251 void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv)
253 #ifdef CONFIG_AP_MODE
254 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
257 rtw_mfree_all_stainfo(pstapriv); //be done before free sta_hash_lock
259 _rtw_spinlock_free(&pstapriv->free_sta_queue.lock);
261 _rtw_spinlock_free(&pstapriv->sta_hash_lock);
262 _rtw_spinlock_free(&pstapriv->wakeup_q.lock);
263 _rtw_spinlock_free(&pstapriv->sleep_q.lock);
265 #ifdef CONFIG_AP_MODE
266 _rtw_spinlock_free(&pstapriv->asoc_list_lock);
267 _rtw_spinlock_free(&pstapriv->auth_list_lock);
268 _rtw_spinlock_free(&pacl_list->acl_node_q.lock);
273 u32 _rtw_free_sta_priv(struct sta_priv *pstapriv)
276 _list *phead, *plist;
277 struct sta_info *psta = NULL;
278 struct recv_reorder_ctrl *preorder_ctrl;
284 /* delete all reordering_ctrl_timer */
285 _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL);
286 for(index = 0; index < NUM_STA; index++)
288 phead = &(pstapriv->sta_hash[index]);
289 plist = get_next(phead);
291 while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
294 psta = LIST_CONTAINOR(plist, struct sta_info ,hash_list);
295 plist = get_next(plist);
297 for(i=0; i < 16 ; i++)
299 preorder_ctrl = &psta->recvreorder_ctrl[i];
300 _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
304 _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL);
305 /*===============================*/
307 rtw_mfree_sta_priv_lock(pstapriv);
309 if(pstapriv->pallocated_stainfo_buf) {
310 rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info)*NUM_STA+4);
319 //struct sta_info *rtw_alloc_stainfo(_queue *pfree_sta_queue, unsigned char *hwaddr)
320 struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
326 struct sta_info *psta;
327 _queue *pfree_sta_queue;
328 struct recv_reorder_ctrl *preorder_ctrl;
330 u16 wRxSeqInitialValue = 0xffff;
334 pfree_sta_queue = &pstapriv->free_sta_queue;
336 //_enter_critical_bh(&(pfree_sta_queue->lock), &irqL);
337 _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL2);
338 if (_rtw_queue_empty(pfree_sta_queue) == _TRUE)
340 //_exit_critical_bh(&(pfree_sta_queue->lock), &irqL);
341 _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL2);
346 psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue), struct sta_info, list);
348 rtw_list_delete(&(psta->list));
350 //_exit_critical_bh(&(pfree_sta_queue->lock), &irqL);
354 _rtw_init_stainfo(psta);
356 psta->padapter = pstapriv->padapter;
358 _rtw_memcpy(psta->hwaddr, hwaddr, ETH_ALEN);
360 index = wifi_mac_hash(hwaddr);
362 RT_TRACE(_module_rtl871x_sta_mgt_c_,_drv_info_,("rtw_alloc_stainfo: index = %x", index));
364 if(index >= NUM_STA){
365 RT_TRACE(_module_rtl871x_sta_mgt_c_,_drv_err_,("ERROR=> rtw_alloc_stainfo: index >= NUM_STA"));
369 phash_list = &(pstapriv->sta_hash[index]);
371 //_enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL2);
373 rtw_list_insert_tail(&psta->hash_list, phash_list);
375 pstapriv->asoc_sta_count ++ ;
377 //_exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL2);
379 // Commented by Albert 2009/08/13
380 // For the SMC router, the sequence number of first packet of WPS handshake will be 0.
381 // 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.
382 // So, we initialize the tid_rxseq variable as the 0xffff.
384 for( i = 0; i < 16; i++ )
386 _rtw_memcpy( &psta->sta_recvpriv.rxcache.tid_rxseq[ i ], &wRxSeqInitialValue, 2 );
389 RT_TRACE(_module_rtl871x_sta_mgt_c_,_drv_info_,("alloc number_%d stainfo with hwaddr = %x %x %x %x %x %x \n",
390 pstapriv->asoc_sta_count , hwaddr[0], hwaddr[1], hwaddr[2],hwaddr[3],hwaddr[4],hwaddr[5]));
392 init_addba_retry_timer(pstapriv->padapter, psta);
395 rtw_init_tdls_timer(pstapriv->padapter, psta);
398 //for A-MPDU Rx reordering buffer control
399 for(i=0; i < 16 ; i++)
401 preorder_ctrl = &psta->recvreorder_ctrl[i];
403 preorder_ctrl->padapter = pstapriv->padapter;
405 preorder_ctrl->enable = _FALSE;
407 preorder_ctrl->indicate_seq = 0xffff;
409 DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d\n", __FUNCTION__, __LINE__,
410 preorder_ctrl->indicate_seq);
412 preorder_ctrl->wend_b= 0xffff;
413 //preorder_ctrl->wsize_b = (NR_RECVBUFF-2);
414 preorder_ctrl->wsize_b = 64;//64;
415 preorder_ctrl->ampdu_size = RX_AMPDU_SIZE_INVALID;
417 _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue);
419 rtw_init_recv_timer(preorder_ctrl);
424 psta->rssi_stat.UndecoratedSmoothedPWDB = (-1);
425 psta->rssi_stat.UndecoratedSmoothedCCK = (-1);
426 #ifdef CONFIG_ATMEL_RC_PATCH
427 psta->flag_atmel_rc = 0;
429 /* init for the sequence number of received management frame */
430 psta->RxMgmtFrameSeqNum = 0xffff;
432 //alloc mac id for non-bc/mc station,
433 rtw_alloc_macid(pstapriv->padapter, psta);
439 _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL2);
449 // using pstapriv->sta_hash_lock to protect
450 u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta)
454 _queue *pfree_sta_queue;
455 struct recv_reorder_ctrl *preorder_ctrl;
456 struct sta_xmit_priv *pstaxmitpriv;
457 struct xmit_priv *pxmitpriv= &padapter->xmitpriv;
458 struct sta_priv *pstapriv = &padapter->stapriv;
459 struct hw_xmit *phwxmit;
467 _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL0);
468 rtw_list_delete(&psta->hash_list);
469 RT_TRACE(_module_rtl871x_sta_mgt_c_,_drv_err_,("\n free number_%d stainfo with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x \n",pstapriv->asoc_sta_count , psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2],psta->hwaddr[3],psta->hwaddr[4],psta->hwaddr[5]));
470 pstapriv->asoc_sta_count --;
471 _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL0);
474 _enter_critical_bh(&psta->lock, &irqL0);
475 psta->state &= ~_FW_LINKED;
476 _exit_critical_bh(&psta->lock, &irqL0);
478 pfree_sta_queue = &pstapriv->free_sta_queue;
481 pstaxmitpriv = &psta->sta_xmitpriv;
483 //rtw_list_delete(&psta->sleep_list);
485 //rtw_list_delete(&psta->wakeup_list);
487 _enter_critical_bh(&pxmitpriv->lock, &irqL0);
489 rtw_free_xmitframe_queue(pxmitpriv, &psta->sleep_q);
490 psta->sleepq_len = 0;
493 //_enter_critical_bh(&(pxmitpriv->vo_pending.lock), &irqL0);
494 rtw_free_xmitframe_queue( pxmitpriv, &pstaxmitpriv->vo_q.sta_pending);
495 rtw_list_delete(&(pstaxmitpriv->vo_q.tx_pending));
496 phwxmit = pxmitpriv->hwxmits;
497 phwxmit->accnt -= pstaxmitpriv->vo_q.qcnt;
498 pending_qcnt[0] = pstaxmitpriv->vo_q.qcnt;
499 pstaxmitpriv->vo_q.qcnt = 0;
500 //_exit_critical_bh(&(pxmitpriv->vo_pending.lock), &irqL0);
503 //_enter_critical_bh(&(pxmitpriv->vi_pending.lock), &irqL0);
504 rtw_free_xmitframe_queue( pxmitpriv, &pstaxmitpriv->vi_q.sta_pending);
505 rtw_list_delete(&(pstaxmitpriv->vi_q.tx_pending));
506 phwxmit = pxmitpriv->hwxmits+1;
507 phwxmit->accnt -= pstaxmitpriv->vi_q.qcnt;
508 pending_qcnt[1] = pstaxmitpriv->vi_q.qcnt;
509 pstaxmitpriv->vi_q.qcnt = 0;
510 //_exit_critical_bh(&(pxmitpriv->vi_pending.lock), &irqL0);
513 //_enter_critical_bh(&(pxmitpriv->be_pending.lock), &irqL0);
514 rtw_free_xmitframe_queue( pxmitpriv, &pstaxmitpriv->be_q.sta_pending);
515 rtw_list_delete(&(pstaxmitpriv->be_q.tx_pending));
516 phwxmit = pxmitpriv->hwxmits+2;
517 phwxmit->accnt -= pstaxmitpriv->be_q.qcnt;
518 pending_qcnt[2] = pstaxmitpriv->be_q.qcnt;
519 pstaxmitpriv->be_q.qcnt = 0;
520 //_exit_critical_bh(&(pxmitpriv->be_pending.lock), &irqL0);
523 //_enter_critical_bh(&(pxmitpriv->bk_pending.lock), &irqL0);
524 rtw_free_xmitframe_queue( pxmitpriv, &pstaxmitpriv->bk_q.sta_pending);
525 rtw_list_delete(&(pstaxmitpriv->bk_q.tx_pending));
526 phwxmit = pxmitpriv->hwxmits+3;
527 phwxmit->accnt -= pstaxmitpriv->bk_q.qcnt;
528 pending_qcnt[3] = pstaxmitpriv->bk_q.qcnt;
529 pstaxmitpriv->bk_q.qcnt = 0;
530 //_exit_critical_bh(&(pxmitpriv->bk_pending.lock), &irqL0);
532 rtw_os_wake_queue_at_free_stainfo(padapter, pending_qcnt);
534 _exit_critical_bh(&pxmitpriv->lock, &irqL0);
537 // re-init sta_info; 20061114 // will be init in alloc_stainfo
538 //_rtw_init_sta_xmit_priv(&psta->sta_xmitpriv);
539 //_rtw_init_sta_recv_priv(&psta->sta_recvpriv);
541 _cancel_timer_ex(&psta->addba_retry_timer);
544 psta->tdls_sta_state = TDLS_STATE_NONE;
545 rtw_free_tdls_timer(psta);
548 //for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer
549 for(i=0; i < 16 ; i++)
552 _list *phead, *plist;
553 union recv_frame *prframe;
554 _queue *ppending_recvframe_queue;
555 _queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
557 preorder_ctrl = &psta->recvreorder_ctrl[i];
559 _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
562 ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
564 _enter_critical_bh(&ppending_recvframe_queue->lock, &irqL);
566 phead = get_list_head(ppending_recvframe_queue);
567 plist = get_next(phead);
569 while(!rtw_is_list_empty(phead))
571 prframe = LIST_CONTAINOR(plist, union recv_frame, u);
573 plist = get_next(plist);
575 rtw_list_delete(&(prframe->u.hdr.list));
577 rtw_free_recvframe(prframe, pfree_recv_queue);
580 _exit_critical_bh(&ppending_recvframe_queue->lock, &irqL);
584 if (!(psta->state & WIFI_AP_STATE))
585 rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, _FALSE);
588 //release mac id for non-bc/mc station,
589 rtw_release_macid(pstapriv->padapter, psta);
591 #ifdef CONFIG_AP_MODE
594 _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL0);
595 rtw_list_delete(&psta->asoc_list);
596 _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL0);
598 _enter_critical_bh(&pstapriv->auth_list_lock, &irqL0);
599 if (!rtw_is_list_empty(&psta->auth_list)) {
600 rtw_list_delete(&psta->auth_list);
601 pstapriv->auth_list_cnt--;
603 _exit_critical_bh(&pstapriv->auth_list_lock, &irqL0);
606 #ifdef CONFIG_ATMEL_RC_PATCH
607 psta->flag_atmel_rc = 0;
609 psta->sleepq_ac_len = 0;
612 psta->max_sp_len = 0;
618 psta->has_legacy_ac = 0;
620 #ifdef CONFIG_NATIVEAP_MLME
622 pstapriv->sta_dz_bitmap &=~BIT(psta->aid);
623 pstapriv->tim_bitmap &=~BIT(psta->aid);
625 //rtw_indicate_sta_disassoc_event(padapter, psta);
627 if ((psta->aid >0)&&(pstapriv->sta_aid[psta->aid - 1] == psta))
629 pstapriv->sta_aid[psta->aid - 1] = NULL;
633 #endif // CONFIG_NATIVEAP_MLME
635 #ifdef CONFIG_TX_MCAST2UNI
636 psta->under_exist_checking = 0;
637 #endif // CONFIG_TX_MCAST2UNI
639 #endif // CONFIG_AP_MODE
641 _rtw_spinlock_free(&psta->lock);
643 //_enter_critical_bh(&(pfree_sta_queue->lock), &irqL0);
644 _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL0);
645 rtw_list_insert_tail(&psta->list, get_list_head(pfree_sta_queue));
646 _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL0);
647 //_exit_critical_bh(&(pfree_sta_queue->lock), &irqL0);
657 // free all stainfo which in sta_hash[all]
658 void rtw_free_all_stainfo(_adapter *padapter)
661 _list *plist, *phead;
663 struct sta_info *psta = NULL;
664 struct sta_priv *pstapriv = &padapter->stapriv;
665 struct sta_info* pbcmc_stainfo =rtw_get_bcmc_stainfo( padapter);
667 char free_sta_list[NUM_STA];
672 if(pstapriv->asoc_sta_count==1)
675 _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL);
677 for(index=0; index< NUM_STA; index++)
679 phead = &(pstapriv->sta_hash[index]);
680 plist = get_next(phead);
682 while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
684 psta = LIST_CONTAINOR(plist, struct sta_info ,hash_list);
686 plist = get_next(plist);
688 if(pbcmc_stainfo!=psta)
690 rtw_list_delete(&psta->hash_list);
691 //rtw_free_stainfo(padapter , psta);
692 stainfo_offset = rtw_stainfo_offset(pstapriv, psta);
693 if (stainfo_offset_valid(stainfo_offset)) {
694 free_sta_list[free_sta_num++] = stainfo_offset;
701 _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL);
704 for (index = 0; index < free_sta_num; index++)
706 psta = rtw_get_stainfo_by_offset(pstapriv, free_sta_list[index]);
707 rtw_free_stainfo(padapter , psta);
716 /* any station allocated can be searched by hash list */
717 struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
722 _list *plist, *phead;
724 struct sta_info *psta = NULL;
730 u8 bc_addr[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
746 index = wifi_mac_hash(addr);
748 _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL);
750 phead = &(pstapriv->sta_hash[index]);
751 plist = get_next(phead);
754 while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
757 psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
759 if ((_rtw_memcmp(psta->hwaddr, addr, ETH_ALEN))== _TRUE)
760 { // if found the matched address
764 plist = get_next(plist);
767 _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL);
773 u32 rtw_init_bcmc_stainfo(_adapter* padapter)
776 struct sta_info *psta;
777 struct tx_servq *ptxservq;
779 NDIS_802_11_MAC_ADDRESS bcast_addr= {0xff,0xff,0xff,0xff,0xff,0xff};
781 struct sta_priv *pstapriv = &padapter->stapriv;
782 //_queue *pstapending = &padapter->xmitpriv.bm_pending;
786 psta = rtw_alloc_stainfo(pstapriv, bcast_addr);
790 RT_TRACE(_module_rtl871x_sta_mgt_c_,_drv_err_,("rtw_alloc_stainfo fail"));
794 ptxservq= &(psta->sta_xmitpriv.be_q);
797 _enter_critical(&pstapending->lock, &irqL0);
799 if (rtw_is_list_empty(&ptxservq->tx_pending))
800 rtw_list_insert_tail(&ptxservq->tx_pending, get_list_head(pstapending));
802 _exit_critical(&pstapending->lock, &irqL0);
812 struct sta_info* rtw_get_bcmc_stainfo(_adapter* padapter)
814 struct sta_info *psta;
815 struct sta_priv *pstapriv = &padapter->stapriv;
816 u8 bc_addr[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
818 psta = rtw_get_stainfo(pstapriv, bc_addr);
824 u8 rtw_access_ctrl(_adapter *padapter, u8 *mac_addr)
827 #ifdef CONFIG_AP_MODE
829 _list *plist, *phead;
830 struct rtw_wlan_acl_node *paclnode;
832 struct sta_priv *pstapriv = &padapter->stapriv;
833 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
834 _queue *pacl_node_q =&pacl_list->acl_node_q;
836 _enter_critical_bh(&(pacl_node_q->lock), &irqL);
837 phead = get_list_head(pacl_node_q);
838 plist = get_next(phead);
839 while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
841 paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list);
842 plist = get_next(plist);
844 if(_rtw_memcmp(paclnode->addr, mac_addr, ETH_ALEN))
846 if(paclnode->valid == _TRUE)
853 _exit_critical_bh(&(pacl_node_q->lock), &irqL);
856 if(pacl_list->mode == 1)//accept unless in deny list
858 res = (match == _TRUE) ? _FALSE:_TRUE;
860 else if(pacl_list->mode == 2)//deny unless in accept list
862 res = (match == _TRUE) ? _TRUE:_FALSE;