Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 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 | \file lim_session_utils.c |
| 31 | \brief implementation for lim Session Utility APIs |
| 32 | \author Sunit Bhatia |
| 33 | ========================================================================*/ |
| 34 | |
| 35 | /*-------------------------------------------------------------------------- |
| 36 | Include Files |
| 37 | ------------------------------------------------------------------------*/ |
| 38 | #include "ani_global.h" |
| 39 | #include "lim_debug.h" |
| 40 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 41 | #include "lim_ft_defs.h" |
| 42 | #endif |
| 43 | #include "lim_session.h" |
| 44 | #include "lim_session_utils.h" |
| 45 | #include "lim_utils.h" |
| 46 | |
| 47 | /** |
| 48 | * is_lim_session_off_channel() - checks if any other off channel session exists |
| 49 | * @mac_ctx: Global MAC context. |
| 50 | * @sessionId: PE session ID. |
| 51 | * |
| 52 | * Return: This function returns true if the session Id passed needs to be on |
| 53 | * a different channel than atleast one session already active. |
| 54 | **/ |
| 55 | uint8_t is_lim_session_off_channel(tpAniSirGlobal mac_ctx, uint8_t session_id) |
| 56 | { |
| 57 | uint8_t i; |
| 58 | |
| 59 | if (session_id >= mac_ctx->lim.maxBssId) { |
| 60 | lim_log(mac_ctx, LOGE, FL("Invalid session_id:%d"), session_id); |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | for (i = 0; i < mac_ctx->lim.maxBssId; i++) { |
| 65 | /* Skip the session_id that is to be joined. */ |
| 66 | if (i == session_id) |
| 67 | continue; |
| 68 | /* |
| 69 | * if another session is valid and it is on different channel |
| 70 | * then it is an off channel operation. |
| 71 | */ |
| 72 | if ((mac_ctx->lim.gpSession[i].valid) && |
| 73 | (mac_ctx->lim.gpSession[i].currentOperChannel != |
| 74 | mac_ctx->lim.gpSession[session_id].currentOperChannel)) |
| 75 | return true; |
| 76 | } |
| 77 | return false; |
| 78 | |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * lim_is_chan_switch_running() - check if channel switch is happening |
| 83 | * @mac_ctx: Global MAC context. |
| 84 | * |
| 85 | * Return: 1 - if channel switch is happening on any session. |
| 86 | * 0 - if channel switch is not happening. |
| 87 | **/ |
| 88 | uint8_t lim_is_chan_switch_running(tpAniSirGlobal mac_ctx) |
| 89 | { |
| 90 | uint8_t i; |
| 91 | |
| 92 | for (i = 0; i < mac_ctx->lim.maxBssId; i++) |
| 93 | if (mac_ctx->lim.gpSession[i].valid && |
| 94 | mac_ctx->lim.gpSession[i].gLimSpecMgmt.dot11hChanSwState |
| 95 | == eLIM_11H_CHANSW_RUNNING) |
| 96 | return 1; |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * lim_is_in_mcc() - check if device is in MCC |
| 102 | * @mac_ctx: Global MAC context. |
| 103 | * |
| 104 | * Return: true - if in MCC. |
| 105 | * false - Not in MCC |
| 106 | **/ |
| 107 | uint8_t lim_is_in_mcc(tpAniSirGlobal mac_ctx) |
| 108 | { |
| 109 | uint8_t i; |
| 110 | uint8_t chan = 0; |
| 111 | uint8_t curr_oper_channel = 0; |
| 112 | |
| 113 | for (i = 0; i < mac_ctx->lim.maxBssId; i++) { |
| 114 | /* |
| 115 | * if another session is valid and it is on different channel |
| 116 | * it is an off channel operation. |
| 117 | */ |
| 118 | if ((mac_ctx->lim.gpSession[i].valid)) { |
| 119 | curr_oper_channel = |
| 120 | mac_ctx->lim.gpSession[i].currentOperChannel; |
| 121 | if (chan == 0) |
| 122 | chan = curr_oper_channel; |
| 123 | else if (chan != curr_oper_channel) |
| 124 | return true; |
| 125 | } |
| 126 | } |
| 127 | return false; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * pe_get_current_stas_count() - Total stations associated on all sessions. |
| 132 | * @mac_ctx: Global MAC context. |
| 133 | * |
| 134 | * Return: true - Number of stations active on all sessions. |
| 135 | **/ |
| 136 | uint8_t pe_get_current_stas_count(tpAniSirGlobal mac_ctx) |
| 137 | { |
| 138 | uint8_t i; |
| 139 | uint8_t stacount = 0; |
| 140 | for (i = 0; i < mac_ctx->lim.maxBssId; i++) |
| 141 | if (mac_ctx->lim.gpSession[i].valid == true) |
| 142 | stacount += |
| 143 | mac_ctx->lim.gpSession[i].gLimNumOfCurrentSTAs; |
| 144 | return stacount; |
| 145 | } |