Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2012-2013 Qualcomm Atheros, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * Qualcomm Atheros Confidential and Proprietary. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 5 | */ |
| 6 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7 | * 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 Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 25 | #include "limSessionUtils.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 26 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 27 | #define LIM_START_PEER_IDX 1 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 30 | * limInitPeerIdxpool() |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | * |
| 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 | |
| 50 | void |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 51 | limInitPeerIdxpool(tpAniSirGlobal pMac,tpPESession pSessionEntry) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 52 | { |
| 53 | tANI_U8 i; |
| 54 | tANI_U8 maxAssocSta = pMac->lim.gLimAssocStaLimit; |
| 55 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 56 | pSessionEntry->gpLimPeerIdxpool[0]=0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 57 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 58 | #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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 63 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 64 | pSessionEntry->freePeerIdxHead = DPH_STA_HASH_INDEX_PEER + 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 65 | } |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 66 | else |
| 67 | #endif |
| 68 | { |
| 69 | pSessionEntry->freePeerIdxHead=LIM_START_PEER_IDX; |
| 70 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 71 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 72 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 79 | |
| 80 | } |
| 81 | |
| 82 | |
| 83 | /** |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 84 | * limAssignPeerIdx() |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 85 | * |
| 86 | *FUNCTION: |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 87 | * This function is called to get a peer station index. This index is |
| 88 | * used during Association/Reassociation |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 89 | * frame handling to assign association ID (aid) to a STA. |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 90 | * In case of TDLS, this is used to assign a index into the Dph hash entry. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 91 | * |
| 92 | *LOGIC: |
| 93 | * |
| 94 | *ASSUMPTIONS: |
| 95 | * NA |
| 96 | * |
| 97 | *NOTE: |
| 98 | * |
| 99 | * @param pMac - Pointer to Global MAC structure |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 100 | * @return peerIdx - assigned peer Station IDx for STA |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 101 | */ |
| 102 | |
| 103 | tANI_U16 |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 104 | limAssignPeerIdx(tpAniSirGlobal pMac, tpPESession pSessionEntry) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 105 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 106 | tANI_U16 peerId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 107 | |
| 108 | // make sure we haven't exceeded the configurable limit on associations |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 109 | // This count is global to ensure that it doesnt exceed the hardware limits. |
| 110 | if (peGetCurrentSTAsCount(pMac) >= pMac->lim.gLimAssocStaLimit) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 111 | { |
| 112 | // too many associations already active |
| 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | /* return head of free list */ |
| 117 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 118 | if (pSessionEntry->freePeerIdxHead) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 119 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 120 | peerId=pSessionEntry->freePeerIdxHead; |
| 121 | pSessionEntry->freePeerIdxHead = pSessionEntry->gpLimPeerIdxpool[pSessionEntry->freePeerIdxHead]; |
| 122 | if (pSessionEntry->freePeerIdxHead==0) |
| 123 | pSessionEntry->freePeerIdxTail=0; |
| 124 | pSessionEntry->gLimNumOfCurrentSTAs++; |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 125 | //PELOG2(limLog(pMac, LOG2,FL("Assign aid %d, numSta %d, head %d tail %d "),aid,pSessionEntry->gLimNumOfCurrentSTAs,pSessionEntry->freeAidHead,pSessionEntry->freeAidTail);) |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 126 | return peerId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 129 | return 0; /* no more free peer index */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | |
| 133 | /** |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 134 | * limReleasePeerIdx() |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 135 | * |
| 136 | *FUNCTION: |
| 137 | * This function is called when a STA context is removed |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 138 | * at AP (or at a STA in IBSS mode or TDLS) to return peer Index |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 139 | * to free pool. |
| 140 | * |
| 141 | *LOGIC: |
| 142 | * |
| 143 | *ASSUMPTIONS: |
| 144 | * NA |
| 145 | * |
| 146 | *NOTE: |
| 147 | * |
| 148 | * @param pMac - Pointer to Global MAC structure |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 149 | * @param peerIdx - peer station index that need to return to free pool |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 150 | * |
| 151 | * @return None |
| 152 | */ |
| 153 | |
| 154 | void |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 155 | limReleasePeerIdx(tpAniSirGlobal pMac, tANI_U16 peerIdx, tpPESession pSessionEntry) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 156 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 157 | pSessionEntry->gLimNumOfCurrentSTAs--; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 158 | |
| 159 | /* insert at tail of free list */ |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 160 | if (pSessionEntry->freePeerIdxTail) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 161 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 162 | pSessionEntry->gpLimPeerIdxpool[pSessionEntry->freePeerIdxTail]=(tANI_U8)peerIdx; |
| 163 | pSessionEntry->freePeerIdxTail=(tANI_U8)peerIdx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 164 | } |
| 165 | else |
| 166 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 167 | pSessionEntry->freePeerIdxTail=pSessionEntry->freePeerIdxHead=(tANI_U8)peerIdx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 168 | } |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 169 | pSessionEntry->gpLimPeerIdxpool[(tANI_U8)peerIdx]=0; |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 170 | //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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 171 | |
| 172 | } |