Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 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 <osdep_service.h> |
| 18 | #include <drv_types.h> |
| 19 | #include <recv_osdep.h> |
| 20 | #include <xmit_osdep.h> |
| 21 | #include <mlme_osdep.h> |
| 22 | #include <sta_info.h> |
Jes Sorensen | dbe9849 | 2014-05-16 10:04:13 +0200 | [diff] [blame] | 23 | #include <rtl8723a_hal.h> |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 24 | |
Jes Sorensen | 3cf7fa6 | 2014-06-26 10:20:50 +0200 | [diff] [blame] | 25 | static const u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
Jes Sorensen | 25f7190 | 2014-06-26 10:20:49 +0200 | [diff] [blame] | 26 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 27 | static void _rtw_init_stainfo(struct sta_info *psta) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 28 | { |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 29 | memset((u8 *)psta, 0, sizeof(struct sta_info)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 30 | spin_lock_init(&psta->lock); |
| 31 | INIT_LIST_HEAD(&psta->list); |
| 32 | INIT_LIST_HEAD(&psta->hash_list); |
| 33 | _rtw_init_queue23a(&psta->sleep_q); |
| 34 | psta->sleepq_len = 0; |
| 35 | _rtw_init_sta_xmit_priv23a(&psta->sta_xmitpriv); |
| 36 | _rtw_init_sta_recv_priv23a(&psta->sta_recvpriv); |
| 37 | #ifdef CONFIG_8723AU_AP_MODE |
| 38 | INIT_LIST_HEAD(&psta->asoc_list); |
| 39 | INIT_LIST_HEAD(&psta->auth_list); |
| 40 | psta->expire_to = 0; |
| 41 | psta->flags = 0; |
| 42 | psta->capability = 0; |
| 43 | psta->bpairwise_key_installed = false; |
| 44 | psta->nonerp_set = 0; |
| 45 | psta->no_short_slot_time_set = 0; |
| 46 | psta->no_short_preamble_set = 0; |
| 47 | psta->no_ht_gf_set = 0; |
| 48 | psta->no_ht_set = 0; |
| 49 | psta->ht_20mhz_set = 0; |
| 50 | psta->keep_alive_trycnt = 0; |
| 51 | #endif /* CONFIG_8723AU_AP_MODE */ |
| 52 | } |
| 53 | |
Jes Sorensen | 95ddd22 | 2014-05-16 10:04:38 +0200 | [diff] [blame] | 54 | int _rtw_init_sta_priv23a(struct sta_priv *pstapriv) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 55 | { |
Jes Sorensen | 2ad7c3d | 2014-05-09 15:03:48 +0200 | [diff] [blame] | 56 | int i; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 57 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 58 | spin_lock_init(&pstapriv->sta_hash_lock); |
| 59 | pstapriv->asoc_sta_count = 0; |
Jes Sorensen | 2ad7c3d | 2014-05-09 15:03:48 +0200 | [diff] [blame] | 60 | for (i = 0; i < NUM_STA; i++) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 61 | INIT_LIST_HEAD(&pstapriv->sta_hash[i]); |
Jes Sorensen | 2ad7c3d | 2014-05-09 15:03:48 +0200 | [diff] [blame] | 62 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 63 | #ifdef CONFIG_8723AU_AP_MODE |
| 64 | pstapriv->sta_dz_bitmap = 0; |
| 65 | pstapriv->tim_bitmap = 0; |
| 66 | INIT_LIST_HEAD(&pstapriv->asoc_list); |
| 67 | INIT_LIST_HEAD(&pstapriv->auth_list); |
| 68 | spin_lock_init(&pstapriv->asoc_list_lock); |
| 69 | spin_lock_init(&pstapriv->auth_list_lock); |
| 70 | pstapriv->asoc_list_cnt = 0; |
| 71 | pstapriv->auth_list_cnt = 0; |
| 72 | pstapriv->auth_to = 3; /* 3*2 = 6 sec */ |
| 73 | pstapriv->assoc_to = 3; |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 74 | /* pstapriv->expire_to = 900; 900*2 = 1800 sec = 30 min, |
| 75 | expire after no any traffic. */ |
| 76 | /* pstapriv->expire_to = 30; 30*2 = 60 sec = 1 min, |
| 77 | expire after no any traffic. */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 78 | pstapriv->expire_to = 3; /* 3*2 = 6 sec */ |
| 79 | pstapriv->max_num_sta = NUM_STA; |
| 80 | #endif |
| 81 | return _SUCCESS; |
| 82 | } |
| 83 | |
Jes Sorensen | 95ddd22 | 2014-05-16 10:04:38 +0200 | [diff] [blame] | 84 | int _rtw_free_sta_priv23a(struct sta_priv *pstapriv) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 85 | { |
Geliang Tang | e280d71 | 2016-02-18 22:19:29 +0800 | [diff] [blame] | 86 | struct list_head *phead; |
| 87 | struct sta_info *psta, *ptmp; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 88 | struct recv_reorder_ctrl *preorder_ctrl; |
Jes Sorensen | 95ddd22 | 2014-05-16 10:04:38 +0200 | [diff] [blame] | 89 | int index; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 90 | |
| 91 | if (pstapriv) { |
| 92 | /* delete all reordering_ctrl_timer */ |
| 93 | spin_lock_bh(&pstapriv->sta_hash_lock); |
| 94 | for (index = 0; index < NUM_STA; index++) { |
| 95 | phead = &pstapriv->sta_hash[index]; |
Geliang Tang | e280d71 | 2016-02-18 22:19:29 +0800 | [diff] [blame] | 96 | list_for_each_entry_safe(psta, ptmp, phead, hash_list) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 97 | int i; |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 98 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 99 | for (i = 0; i < 16 ; i++) { |
| 100 | preorder_ctrl = &psta->recvreorder_ctrl[i]; |
| 101 | del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 106 | /*===============================*/ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 107 | } |
| 108 | return _SUCCESS; |
| 109 | } |
| 110 | |
Jes Sorensen | 6e8bc71 | 2014-05-09 15:03:49 +0200 | [diff] [blame] | 111 | struct sta_info * |
Jes Sorensen | 3cf7fa6 | 2014-06-26 10:20:50 +0200 | [diff] [blame] | 112 | rtw_alloc_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr, gfp_t gfp) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 113 | { |
| 114 | struct list_head *phash_list; |
| 115 | struct sta_info *psta; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 116 | struct recv_reorder_ctrl *preorder_ctrl; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 117 | s32 index; |
| 118 | int i = 0; |
| 119 | u16 wRxSeqInitialValue = 0xffff; |
| 120 | |
Sachin Kamat | 8f17a38 | 2014-05-28 17:36:26 +0530 | [diff] [blame] | 121 | psta = kmalloc(sizeof(struct sta_info), gfp); |
Jes Sorensen | 2ad7c3d | 2014-05-09 15:03:48 +0200 | [diff] [blame] | 122 | if (!psta) |
| 123 | return NULL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 124 | |
| 125 | spin_lock_bh(&pstapriv->sta_hash_lock); |
| 126 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 127 | _rtw_init_stainfo(psta); |
| 128 | |
| 129 | psta->padapter = pstapriv->padapter; |
| 130 | |
Jes Sorensen | a6f4e0c | 2014-06-26 10:20:48 +0200 | [diff] [blame] | 131 | ether_addr_copy(psta->hwaddr, hwaddr); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 132 | |
| 133 | index = wifi_mac_hash(hwaddr); |
| 134 | |
| 135 | RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 136 | "rtw_alloc_stainfo23a: index = %x\n", index); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 137 | if (index >= NUM_STA) { |
| 138 | RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 139 | "ERROR => rtw_alloc_stainfo23a: index >= NUM_STA\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 140 | psta = NULL; |
| 141 | goto exit; |
| 142 | } |
| 143 | phash_list = &pstapriv->sta_hash[index]; |
| 144 | |
| 145 | list_add_tail(&psta->hash_list, phash_list); |
| 146 | |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 147 | pstapriv->asoc_sta_count++; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 148 | |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 149 | /* For the SMC router, the sequence number of first packet of WPS |
| 150 | handshake will be 0. */ |
| 151 | /* In this case, this packet will be dropped by recv_decache function |
| 152 | if we use the 0x00 as the default value for tid_rxseq variable. */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 153 | /* So, we initialize the tid_rxseq variable as the 0xffff. */ |
| 154 | |
| 155 | for (i = 0; i < 16; i++) |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 156 | memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], |
| 157 | &wRxSeqInitialValue, 2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 158 | |
| 159 | RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 160 | "alloc number_%d stainfo with hwaddr = %pM\n", |
| 161 | pstapriv->asoc_sta_count, hwaddr); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 162 | |
| 163 | init_addba_retry_timer23a(psta); |
| 164 | |
| 165 | /* for A-MPDU Rx reordering buffer control */ |
| 166 | for (i = 0; i < 16; i++) { |
| 167 | preorder_ctrl = &psta->recvreorder_ctrl[i]; |
| 168 | |
| 169 | preorder_ctrl->padapter = pstapriv->padapter; |
| 170 | |
| 171 | preorder_ctrl->enable = false; |
| 172 | |
| 173 | preorder_ctrl->indicate_seq = 0xffff; |
| 174 | preorder_ctrl->wend_b = 0xffff; |
| 175 | /* preorder_ctrl->wsize_b = (NR_RECVBUFF-2); */ |
| 176 | preorder_ctrl->wsize_b = 64;/* 64; */ |
| 177 | |
| 178 | _rtw_init_queue23a(&preorder_ctrl->pending_recvframe_queue); |
| 179 | |
| 180 | rtw_init_recv_timer23a(preorder_ctrl); |
| 181 | } |
| 182 | /* init for DM */ |
| 183 | psta->rssi_stat.UndecoratedSmoothedPWDB = (-1); |
| 184 | psta->rssi_stat.UndecoratedSmoothedCCK = (-1); |
| 185 | |
| 186 | /* init for the sequence number of received management frame */ |
| 187 | psta->RxMgmtFrameSeqNum = 0xffff; |
| 188 | exit: |
| 189 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 190 | return psta; |
| 191 | } |
| 192 | |
| 193 | /* using pstapriv->sta_hash_lock to protect */ |
Jes Sorensen | 95ddd22 | 2014-05-16 10:04:38 +0200 | [diff] [blame] | 194 | int rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 195 | { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 196 | struct recv_reorder_ctrl *preorder_ctrl; |
| 197 | struct sta_xmit_priv *pstaxmitpriv; |
| 198 | struct xmit_priv *pxmitpriv = &padapter->xmitpriv; |
| 199 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 200 | struct hw_xmit *phwxmit; |
| 201 | int i; |
| 202 | |
Bhaktipriya Shridhar | b747a1e | 2016-03-06 02:47:23 +0530 | [diff] [blame] | 203 | if (!psta) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 204 | goto exit; |
| 205 | |
| 206 | spin_lock_bh(&psta->lock); |
| 207 | psta->state &= ~_FW_LINKED; |
| 208 | spin_unlock_bh(&psta->lock); |
| 209 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 210 | pstaxmitpriv = &psta->sta_xmitpriv; |
| 211 | |
| 212 | spin_lock_bh(&pxmitpriv->lock); |
| 213 | |
| 214 | rtw_free_xmitframe_queue23a(pxmitpriv, &psta->sleep_q); |
| 215 | psta->sleepq_len = 0; |
| 216 | |
| 217 | /* vo */ |
| 218 | rtw_free_xmitframe_queue23a(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); |
| 219 | list_del_init(&pstaxmitpriv->vo_q.tx_pending); |
| 220 | phwxmit = pxmitpriv->hwxmits; |
| 221 | phwxmit->accnt -= pstaxmitpriv->vo_q.qcnt; |
| 222 | pstaxmitpriv->vo_q.qcnt = 0; |
| 223 | |
| 224 | /* vi */ |
| 225 | rtw_free_xmitframe_queue23a(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); |
| 226 | list_del_init(&pstaxmitpriv->vi_q.tx_pending); |
| 227 | phwxmit = pxmitpriv->hwxmits+1; |
| 228 | phwxmit->accnt -= pstaxmitpriv->vi_q.qcnt; |
| 229 | pstaxmitpriv->vi_q.qcnt = 0; |
| 230 | |
| 231 | /* be */ |
| 232 | rtw_free_xmitframe_queue23a(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); |
| 233 | list_del_init(&pstaxmitpriv->be_q.tx_pending); |
| 234 | phwxmit = pxmitpriv->hwxmits+2; |
| 235 | phwxmit->accnt -= pstaxmitpriv->be_q.qcnt; |
| 236 | pstaxmitpriv->be_q.qcnt = 0; |
| 237 | |
| 238 | /* bk */ |
| 239 | rtw_free_xmitframe_queue23a(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); |
| 240 | list_del_init(&pstaxmitpriv->bk_q.tx_pending); |
| 241 | phwxmit = pxmitpriv->hwxmits+3; |
| 242 | phwxmit->accnt -= pstaxmitpriv->bk_q.qcnt; |
| 243 | pstaxmitpriv->bk_q.qcnt = 0; |
| 244 | |
| 245 | spin_unlock_bh(&pxmitpriv->lock); |
| 246 | |
| 247 | list_del_init(&psta->hash_list); |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 248 | RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 249 | "free number_%d stainfo with hwaddr = %pM\n", |
| 250 | pstapriv->asoc_sta_count, psta->hwaddr); |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 251 | pstapriv->asoc_sta_count--; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 252 | |
| 253 | /* re-init sta_info; 20061114 will be init in alloc_stainfo */ |
| 254 | /* _rtw_init_sta_xmit_priv23a(&psta->sta_xmitpriv); */ |
| 255 | /* _rtw_init_sta_recv_priv23a(&psta->sta_recvpriv); */ |
| 256 | |
| 257 | del_timer_sync(&psta->addba_retry_timer); |
| 258 | |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 259 | /* for A-MPDU Rx reordering buffer control, |
| 260 | cancel reordering_ctrl_timer */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 261 | for (i = 0; i < 16; i++) { |
| 262 | struct list_head *phead, *plist; |
| 263 | struct recv_frame *prframe; |
| 264 | struct rtw_queue *ppending_recvframe_queue; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 265 | |
| 266 | preorder_ctrl = &psta->recvreorder_ctrl[i]; |
| 267 | |
| 268 | del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); |
| 269 | |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 270 | ppending_recvframe_queue = |
| 271 | &preorder_ctrl->pending_recvframe_queue; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 272 | |
| 273 | spin_lock_bh(&ppending_recvframe_queue->lock); |
| 274 | phead = get_list_head(ppending_recvframe_queue); |
| 275 | plist = phead->next; |
| 276 | |
| 277 | while (!list_empty(phead)) { |
| 278 | prframe = container_of(plist, struct recv_frame, list); |
| 279 | plist = plist->next; |
| 280 | list_del_init(&prframe->list); |
Jes Sorensen | c5779a0 | 2014-05-09 15:03:58 +0200 | [diff] [blame] | 281 | rtw_free_recvframe23a(prframe); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 282 | } |
| 283 | spin_unlock_bh(&ppending_recvframe_queue->lock); |
| 284 | } |
| 285 | if (!(psta->state & WIFI_AP_STATE)) |
Jes Sorensen | dbe9849 | 2014-05-16 10:04:13 +0200 | [diff] [blame] | 286 | rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, false); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 287 | #ifdef CONFIG_8723AU_AP_MODE |
| 288 | spin_lock_bh(&pstapriv->auth_list_lock); |
| 289 | if (!list_empty(&psta->auth_list)) { |
| 290 | list_del_init(&psta->auth_list); |
| 291 | pstapriv->auth_list_cnt--; |
| 292 | } |
| 293 | spin_unlock_bh(&pstapriv->auth_list_lock); |
| 294 | |
| 295 | psta->expire_to = 0; |
| 296 | |
| 297 | psta->sleepq_ac_len = 0; |
| 298 | psta->qos_info = 0; |
| 299 | |
| 300 | psta->max_sp_len = 0; |
| 301 | psta->uapsd_bk = 0; |
| 302 | psta->uapsd_be = 0; |
| 303 | psta->uapsd_vi = 0; |
| 304 | psta->uapsd_vo = 0; |
| 305 | |
| 306 | psta->has_legacy_ac = 0; |
| 307 | |
| 308 | pstapriv->sta_dz_bitmap &= ~CHKBIT(psta->aid); |
| 309 | pstapriv->tim_bitmap &= ~CHKBIT(psta->aid); |
| 310 | |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 311 | if ((psta->aid > 0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 312 | pstapriv->sta_aid[psta->aid - 1] = NULL; |
| 313 | psta->aid = 0; |
| 314 | } |
| 315 | #endif /* CONFIG_8723AU_AP_MODE */ |
Jes Sorensen | 2ad7c3d | 2014-05-09 15:03:48 +0200 | [diff] [blame] | 316 | |
| 317 | kfree(psta); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 318 | exit: |
| 319 | return _SUCCESS; |
| 320 | } |
| 321 | |
| 322 | /* free all stainfo which in sta_hash[all] */ |
| 323 | void rtw_free_all_stainfo23a(struct rtw_adapter *padapter) |
| 324 | { |
Geliang Tang | e280d71 | 2016-02-18 22:19:29 +0800 | [diff] [blame] | 325 | struct list_head *phead; |
| 326 | struct sta_info *psta, *ptmp; |
Jes Sorensen | b06106d | 2014-05-09 15:03:43 +0200 | [diff] [blame] | 327 | struct sta_priv *pstapriv = &padapter->stapriv; |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 328 | struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo23a(padapter); |
Jes Sorensen | b06106d | 2014-05-09 15:03:43 +0200 | [diff] [blame] | 329 | s32 index; |
| 330 | |
| 331 | if (pstapriv->asoc_sta_count == 1) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 332 | return; |
| 333 | |
| 334 | spin_lock_bh(&pstapriv->sta_hash_lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 335 | for (index = 0; index < NUM_STA; index++) { |
| 336 | phead = &pstapriv->sta_hash[index]; |
Geliang Tang | e280d71 | 2016-02-18 22:19:29 +0800 | [diff] [blame] | 337 | list_for_each_entry_safe(psta, ptmp, phead, hash_list) { |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 338 | if (pbcmc_stainfo != psta) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 339 | rtw_free_stainfo23a(padapter, psta); |
| 340 | } |
| 341 | } |
| 342 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 343 | } |
| 344 | |
| 345 | /* any station allocated can be searched by hash list */ |
Jes Sorensen | 0348dc74 | 2014-04-26 18:55:06 +0200 | [diff] [blame] | 346 | struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 347 | { |
Geliang Tang | e280d71 | 2016-02-18 22:19:29 +0800 | [diff] [blame] | 348 | struct list_head *phead; |
Geliang Tang | 400a30d | 2016-03-01 23:22:23 +0800 | [diff] [blame] | 349 | struct sta_info *pos, *psta = NULL; |
Geliang Tang | f0eba51 | 2016-02-18 22:19:31 +0800 | [diff] [blame] | 350 | u32 index; |
Jes Sorensen | 0348dc74 | 2014-04-26 18:55:06 +0200 | [diff] [blame] | 351 | const u8 *addr; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 352 | |
Bhaktipriya Shridhar | b747a1e | 2016-03-06 02:47:23 +0530 | [diff] [blame] | 353 | if (!hwaddr) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 354 | return NULL; |
| 355 | |
| 356 | if (is_multicast_ether_addr(hwaddr)) |
| 357 | addr = bc_addr; |
| 358 | else |
| 359 | addr = hwaddr; |
| 360 | |
| 361 | index = wifi_mac_hash(addr); |
| 362 | |
| 363 | spin_lock_bh(&pstapriv->sta_hash_lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 364 | phead = &pstapriv->sta_hash[index]; |
Geliang Tang | 400a30d | 2016-03-01 23:22:23 +0800 | [diff] [blame] | 365 | list_for_each_entry(pos, phead, hash_list) { |
| 366 | psta = pos; |
| 367 | |
Jes Sorensen | a6f4e0c | 2014-06-26 10:20:48 +0200 | [diff] [blame] | 368 | /* if found the matched address */ |
| 369 | if (ether_addr_equal(psta->hwaddr, addr)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 370 | break; |
Jes Sorensen | a6f4e0c | 2014-06-26 10:20:48 +0200 | [diff] [blame] | 371 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 372 | psta = NULL; |
| 373 | } |
| 374 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 375 | return psta; |
| 376 | } |
| 377 | |
Raphael Silva | 1d69fe8 | 2014-07-17 22:59:48 +0200 | [diff] [blame] | 378 | int rtw_init_bcmc_stainfo23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 379 | { |
| 380 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 381 | struct sta_info *psta; |
| 382 | struct tx_servq *ptxservq; |
Jes Sorensen | 95ddd22 | 2014-05-16 10:04:38 +0200 | [diff] [blame] | 383 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 384 | |
Jes Sorensen | 25f7190 | 2014-06-26 10:20:49 +0200 | [diff] [blame] | 385 | psta = rtw_alloc_stainfo23a(pstapriv, bc_addr, GFP_KERNEL); |
Bhaktipriya Shridhar | b747a1e | 2016-03-06 02:47:23 +0530 | [diff] [blame] | 386 | if (!psta) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 387 | res = _FAIL; |
| 388 | RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 389 | "rtw_alloc_stainfo23a fail\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 390 | return res; |
| 391 | } |
| 392 | /* default broadcast & multicast use macid 1 */ |
| 393 | psta->mac_id = 1; |
| 394 | |
| 395 | ptxservq = &psta->sta_xmitpriv.be_q; |
| 396 | return _SUCCESS; |
| 397 | } |
| 398 | |
| 399 | struct sta_info *rtw_get_bcmc_stainfo23a(struct rtw_adapter *padapter) |
| 400 | { |
| 401 | struct sta_info *psta; |
| 402 | struct sta_priv *pstapriv = &padapter->stapriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 403 | |
Jes Sorensen | 25f7190 | 2014-06-26 10:20:49 +0200 | [diff] [blame] | 404 | psta = rtw_get_stainfo23a(pstapriv, bc_addr); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 405 | return psta; |
| 406 | } |
| 407 | |
Jes Sorensen | 95ddd22 | 2014-05-16 10:04:38 +0200 | [diff] [blame] | 408 | bool rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 409 | { |
Jes Sorensen | 95ddd22 | 2014-05-16 10:04:38 +0200 | [diff] [blame] | 410 | bool res = true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 411 | #ifdef CONFIG_8723AU_AP_MODE |
Geliang Tang | e280d71 | 2016-02-18 22:19:29 +0800 | [diff] [blame] | 412 | struct list_head *phead; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 413 | struct rtw_wlan_acl_node *paclnode; |
Jes Sorensen | 95ddd22 | 2014-05-16 10:04:38 +0200 | [diff] [blame] | 414 | bool match = false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 415 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 416 | struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; |
| 417 | struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q; |
| 418 | |
| 419 | spin_lock_bh(&pacl_node_q->lock); |
| 420 | phead = get_list_head(pacl_node_q); |
Geliang Tang | e280d71 | 2016-02-18 22:19:29 +0800 | [diff] [blame] | 421 | list_for_each_entry(paclnode, phead, list) { |
Jes Sorensen | a6f4e0c | 2014-06-26 10:20:48 +0200 | [diff] [blame] | 422 | if (ether_addr_equal(paclnode->addr, mac_addr)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 423 | if (paclnode->valid) { |
| 424 | match = true; |
| 425 | break; |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | spin_unlock_bh(&pacl_node_q->lock); |
| 430 | |
| 431 | if (pacl_list->mode == 1)/* accept unless in deny list */ |
| 432 | res = (match) ? false : true; |
| 433 | else if (pacl_list->mode == 2)/* deny unless in accept list */ |
| 434 | res = (match) ? true : false; |
| 435 | else |
| 436 | res = true; |
| 437 | #endif |
| 438 | return res; |
| 439 | } |