blob: 253543d86b02d560087952be0da1d3101f234728 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 *
30 * This file lim_aid_mgmt.c contains the functions related to
31 * AID pool management like initialization, assignment etc.
32 * Author: Chandra Modumudi
33 * Date: 03/20/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38
39#include "cds_api.h"
40#include "wni_cfg.h"
41#include "ani_global.h"
42#include "cfg_api.h"
43#include "sir_params.h"
44#include "lim_utils.h"
45#include "lim_timer_utils.h"
46#ifdef WLAN_FEATURE_VOWIFI_11R
47#include "lim_ft_defs.h"
48#endif
49#include "lim_session.h"
50#include "lim_session_utils.h"
51
52#define LIM_START_PEER_IDX 1
53
54/**
55 * lim_init_peer_idxpool()
56 *
57 ***FUNCTION:
58 * This function is called while starting a BSS at AP
59 * to initialize AID pool. This may also be called while
60 * starting/joining an IBSS if 'Association' is allowed
61 * in IBSS.
62 *
63 ***LOGIC:
64 *
65 ***ASSUMPTIONS:
66 * NA
67 *
68 ***NOTE:
69 * NA
70 *
71 * @param pMac - Pointer to Global MAC structure
72 * @return None
73 */
74
75void lim_init_peer_idxpool(tpAniSirGlobal pMac, tpPESession pSessionEntry)
76{
77 uint8_t i;
78 uint8_t maxAssocSta = pMac->lim.gLimAssocStaLimit;
79
80 pSessionEntry->gpLimPeerIdxpool[0] = 0;
81
82#ifdef FEATURE_WLAN_TDLS
83 /* In station role, DPH_STA_HASH_INDEX_PEER (index 1) is reserved for peer */
84 /* station index corresponding to AP. Avoid choosing that index and get index */
85 /* starting from (DPH_STA_HASH_INDEX_PEER + 1) (index 2) for TDLS stations; */
86 if (LIM_IS_STA_ROLE(pSessionEntry)) {
87 pSessionEntry->freePeerIdxHead = DPH_STA_HASH_INDEX_PEER + 1;
88 } else
89#endif
90#ifdef QCA_IBSS_SUPPORT
91 if (LIM_IS_IBSS_ROLE(pSessionEntry)) {
92 pSessionEntry->freePeerIdxHead = LIM_START_PEER_IDX;
93 maxAssocSta = pMac->lim.gLimIbssStaLimit;
94 } else
95#endif
96 {
97 pSessionEntry->freePeerIdxHead = LIM_START_PEER_IDX;
98 }
99
100 for (i = pSessionEntry->freePeerIdxHead; i < maxAssocSta; i++) {
101 pSessionEntry->gpLimPeerIdxpool[i] = i + 1;
102 }
103 pSessionEntry->gpLimPeerIdxpool[i] = 0;
104
105 pSessionEntry->freePeerIdxTail = i;
106
107}
108
109/**
110 * lim_assign_peer_idx()
111 *
112 ***FUNCTION:
113 * This function is called to get a peer station index. This index is
114 * used during Association/Reassociation
115 * frame handling to assign association ID (aid) to a STA.
116 * In case of TDLS, this is used to assign a index into the Dph hash entry.
117 *
118 ***LOGIC:
119 *
120 ***ASSUMPTIONS:
121 * NA
122 *
123 ***NOTE:
124 *
125 * @param pMac - Pointer to Global MAC structure
126 * @return peerIdx - assigned peer Station IDx for STA
127 */
128
129uint16_t lim_assign_peer_idx(tpAniSirGlobal pMac, tpPESession pSessionEntry)
130{
131 uint16_t peerId;
132
133 /* make sure we haven't exceeded the configurable limit on associations */
134 /* This count is global to ensure that it doesnt exceed the hardware limits. */
135 if (pe_get_current_stas_count(pMac) >= pMac->lim.gLimAssocStaLimit) {
136 /* too many associations already active */
137 return 0;
138 }
139
140 /* return head of free list */
141
142 if (pSessionEntry->freePeerIdxHead) {
143 peerId = pSessionEntry->freePeerIdxHead;
144 pSessionEntry->freePeerIdxHead =
145 pSessionEntry->gpLimPeerIdxpool[pSessionEntry->
146 freePeerIdxHead];
147 if (pSessionEntry->freePeerIdxHead == 0)
148 pSessionEntry->freePeerIdxTail = 0;
149 pSessionEntry->gLimNumOfCurrentSTAs++;
150 return peerId;
151 }
152
153 return 0; /* no more free peer index */
154}
155
156/**
157 * lim_release_peer_idx()
158 *
159 ***FUNCTION:
160 * This function is called when a STA context is removed
161 * at AP (or at a STA in IBSS mode or TDLS) to return peer Index
162 * to free pool.
163 *
164 ***LOGIC:
165 *
166 ***ASSUMPTIONS:
167 * NA
168 *
169 ***NOTE:
170 *
171 * @param pMac - Pointer to Global MAC structure
172 * @param peerIdx - peer station index that need to return to free pool
173 *
174 * @return None
175 */
176
177void
178lim_release_peer_idx(tpAniSirGlobal pMac, uint16_t peerIdx,
179 tpPESession pSessionEntry)
180{
181 pSessionEntry->gLimNumOfCurrentSTAs--;
182
183 /* insert at tail of free list */
184 if (pSessionEntry->freePeerIdxTail) {
185 pSessionEntry->gpLimPeerIdxpool[pSessionEntry->
186 freePeerIdxTail] =
187 (uint8_t) peerIdx;
188 pSessionEntry->freePeerIdxTail = (uint8_t) peerIdx;
189 } else {
190 pSessionEntry->freePeerIdxTail =
191 pSessionEntry->freePeerIdxHead = (uint8_t) peerIdx;
192 }
193 pSessionEntry->gpLimPeerIdxpool[(uint8_t) peerIdx] = 0;
194}