blob: 1eac872623ce57c77c7d547fba7ba289f2709a4c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
6/*
Jeff Johnson295189b2012-06-20 16:38:30 -07007 * Airgo Networks, Inc proprietary. All rights reserved.
8 * This file limAIDmgmt.cc contains the functions related to
9 * AID pool management like initialization, assignment etc.
10 * Author: Chandra Modumudi
11 * Date: 03/20/02
12 * History:-
13 * Date Modified by Modification Information
14 * --------------------------------------------------------------------
15 */
16
17#include "palTypes.h"
18#include "wniCfgSta.h"
19#include "aniGlobal.h"
20#include "cfgApi.h"
21#include "sirParams.h"
22#include "limUtils.h"
23#include "limTimerUtils.h"
24#include "limSession.h"
Gopichand Nakkala777e6032012-12-31 16:39:21 -080025#include "limSessionUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070026
Gopichand Nakkala777e6032012-12-31 16:39:21 -080027#define LIM_START_PEER_IDX 1
Jeff Johnson295189b2012-06-20 16:38:30 -070028
29/**
Gopichand Nakkala777e6032012-12-31 16:39:21 -080030 * limInitPeerIdxpool()
Jeff Johnson295189b2012-06-20 16:38:30 -070031 *
32 *FUNCTION:
33 * This function is called while starting a BSS at AP
34 * to initialize AID pool. This may also be called while
35 * starting/joining an IBSS if 'Association' is allowed
36 * in IBSS.
37 *
38 *LOGIC:
39 *
40 *ASSUMPTIONS:
41 * NA
42 *
43 *NOTE:
44 * NA
45 *
46 * @param pMac - Pointer to Global MAC structure
47 * @return None
48 */
49
50void
Gopichand Nakkala777e6032012-12-31 16:39:21 -080051limInitPeerIdxpool(tpAniSirGlobal pMac,tpPESession pSessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070052{
53 tANI_U8 i;
54 tANI_U8 maxAssocSta = pMac->lim.gLimAssocStaLimit;
55
Gopichand Nakkala777e6032012-12-31 16:39:21 -080056 pSessionEntry->gpLimPeerIdxpool[0]=0;
Jeff Johnson295189b2012-06-20 16:38:30 -070057
Gopichand Nakkala777e6032012-12-31 16:39:21 -080058#ifdef FEATURE_WLAN_TDLS
59 //In station role, DPH_STA_HASH_INDEX_PEER (index 1) is reserved for peer
60 //station index corresponding to AP. Avoid choosing that index and get index
61 //starting from (DPH_STA_HASH_INDEX_PEER + 1) (index 2) for TDLS stations;
62 if (pSessionEntry->limSystemRole == eLIM_STA_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -070063 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -080064 pSessionEntry->freePeerIdxHead = DPH_STA_HASH_INDEX_PEER + 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070065 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -080066 else
67#endif
68 {
69 pSessionEntry->freePeerIdxHead=LIM_START_PEER_IDX;
70 }
Jeff Johnson295189b2012-06-20 16:38:30 -070071
Gopichand Nakkala777e6032012-12-31 16:39:21 -080072 for (i=pSessionEntry->freePeerIdxHead;i<maxAssocSta; i++)
73 {
74 pSessionEntry->gpLimPeerIdxpool[i] = i+1;
75 }
76 pSessionEntry->gpLimPeerIdxpool[i] = 0;
77
78 pSessionEntry->freePeerIdxTail=i;
Jeff Johnson295189b2012-06-20 16:38:30 -070079
80}
81
82
83/**
Gopichand Nakkala777e6032012-12-31 16:39:21 -080084 * limAssignPeerIdx()
Jeff Johnson295189b2012-06-20 16:38:30 -070085 *
86 *FUNCTION:
Gopichand Nakkala777e6032012-12-31 16:39:21 -080087 * This function is called to get a peer station index. This index is
88 * used during Association/Reassociation
Jeff Johnson295189b2012-06-20 16:38:30 -070089 * frame handling to assign association ID (aid) to a STA.
Gopichand Nakkala777e6032012-12-31 16:39:21 -080090 * In case of TDLS, this is used to assign a index into the Dph hash entry.
Jeff Johnson295189b2012-06-20 16:38:30 -070091 *
92 *LOGIC:
93 *
94 *ASSUMPTIONS:
95 * NA
96 *
97 *NOTE:
98 *
99 * @param pMac - Pointer to Global MAC structure
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800100 * @return peerIdx - assigned peer Station IDx for STA
Jeff Johnson295189b2012-06-20 16:38:30 -0700101 */
102
103tANI_U16
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800104limAssignPeerIdx(tpAniSirGlobal pMac, tpPESession pSessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -0700105{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800106 tANI_U16 peerId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108 // make sure we haven't exceeded the configurable limit on associations
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800109 // This count is global to ensure that it doesnt exceed the hardware limits.
110 if (peGetCurrentSTAsCount(pMac) >= pMac->lim.gLimAssocStaLimit)
Jeff Johnson295189b2012-06-20 16:38:30 -0700111 {
112 // too many associations already active
113 return 0;
114 }
115
116 /* return head of free list */
117
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800118 if (pSessionEntry->freePeerIdxHead)
Jeff Johnson295189b2012-06-20 16:38:30 -0700119 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800120 peerId=pSessionEntry->freePeerIdxHead;
121 pSessionEntry->freePeerIdxHead = pSessionEntry->gpLimPeerIdxpool[pSessionEntry->freePeerIdxHead];
122 if (pSessionEntry->freePeerIdxHead==0)
123 pSessionEntry->freePeerIdxTail=0;
124 pSessionEntry->gLimNumOfCurrentSTAs++;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700125 //PELOG2(limLog(pMac, LOG2,FL("Assign aid %d, numSta %d, head %d tail %d "),aid,pSessionEntry->gLimNumOfCurrentSTAs,pSessionEntry->freeAidHead,pSessionEntry->freeAidTail);)
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800126 return peerId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700127 }
128
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800129 return 0; /* no more free peer index */
Jeff Johnson295189b2012-06-20 16:38:30 -0700130}
131
132
133/**
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800134 * limReleasePeerIdx()
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 *
136 *FUNCTION:
137 * This function is called when a STA context is removed
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800138 * at AP (or at a STA in IBSS mode or TDLS) to return peer Index
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 * to free pool.
140 *
141 *LOGIC:
142 *
143 *ASSUMPTIONS:
144 * NA
145 *
146 *NOTE:
147 *
148 * @param pMac - Pointer to Global MAC structure
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800149 * @param peerIdx - peer station index that need to return to free pool
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 *
151 * @return None
152 */
153
154void
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800155limReleasePeerIdx(tpAniSirGlobal pMac, tANI_U16 peerIdx, tpPESession pSessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -0700156{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800157 pSessionEntry->gLimNumOfCurrentSTAs--;
Jeff Johnson295189b2012-06-20 16:38:30 -0700158
159 /* insert at tail of free list */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800160 if (pSessionEntry->freePeerIdxTail)
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800162 pSessionEntry->gpLimPeerIdxpool[pSessionEntry->freePeerIdxTail]=(tANI_U8)peerIdx;
163 pSessionEntry->freePeerIdxTail=(tANI_U8)peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 }
165 else
166 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800167 pSessionEntry->freePeerIdxTail=pSessionEntry->freePeerIdxHead=(tANI_U8)peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700168 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800169 pSessionEntry->gpLimPeerIdxpool[(tANI_U8)peerIdx]=0;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700170 //PELOG2(limLog(pMac, LOG2,FL("Release aid %d, numSta %d, head %d tail %d "),aid,pMac->lim.gLimNumOfCurrentSTAs,pMac->lim.freeAidHead,pMac->lim.freeAidTail);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700171
172}