Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2014-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 | #include <cds_get_bin.h> |
| 29 | #include <cds_api.h> |
| 30 | #include <cds_sched.h> |
| 31 | #include <wlan_hdd_misc.h> |
| 32 | #include <wlan_hdd_main.h> |
| 33 | |
| 34 | tCDF_CON_MODE cds_get_conparam(void) |
| 35 | { |
| 36 | tCDF_CON_MODE con_mode; |
| 37 | con_mode = hdd_get_conparam(); |
| 38 | return con_mode; |
| 39 | } |
| 40 | |
| 41 | bool cds_concurrent_open_sessions_running(void) |
| 42 | { |
| 43 | uint8_t i = 0; |
| 44 | uint8_t j = 0; |
| 45 | hdd_context_t *pHddCtx; |
| 46 | |
| 47 | pHddCtx = cds_get_context(CDF_MODULE_ID_HDD); |
| 48 | if (NULL != pHddCtx) { |
| 49 | for (i = 0; i < CDF_MAX_NO_OF_MODE; i++) { |
| 50 | j += pHddCtx->no_of_open_sessions[i]; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return j > 1; |
| 55 | } |
| 56 | |
| 57 | #ifdef WLAN_FEATURE_MBSSID |
| 58 | bool cds_concurrent_beaconing_sessions_running(void) |
| 59 | { |
| 60 | uint8_t i = 0; |
| 61 | hdd_context_t *pHddCtx; |
| 62 | |
| 63 | pHddCtx = cds_get_context(CDF_MODULE_ID_HDD); |
| 64 | if (NULL != pHddCtx) { |
| 65 | i = pHddCtx->no_of_open_sessions[CDF_SAP_MODE] + |
| 66 | pHddCtx->no_of_open_sessions[CDF_P2P_GO_MODE] + |
| 67 | pHddCtx->no_of_open_sessions[CDF_IBSS_MODE]; |
| 68 | } |
| 69 | return i > 1; |
| 70 | } |
| 71 | #endif |
| 72 | |
| 73 | /**--------------------------------------------------------------------------- |
| 74 | * |
| 75 | * \brief cds_max_concurrent_connections_reached() |
| 76 | * |
| 77 | * This function checks for presence of concurrency where more than |
| 78 | * one connection exists and it returns true if the max concurrency is |
| 79 | * reached. |
| 80 | * |
| 81 | * Example: |
| 82 | * STA + STA (wlan0 and wlan1 are connected) - returns true |
| 83 | * STA + STA (wlan0 connected and wlan1 disconnected) - returns false |
| 84 | * DUT with P2P-GO + P2P-CLIENT connection) - returns true |
| 85 | * |
| 86 | * \param - None |
| 87 | * |
| 88 | * \return - true or false |
| 89 | * |
| 90 | * --------------------------------------------------------------------------*/ |
| 91 | bool cds_max_concurrent_connections_reached(void) |
| 92 | { |
| 93 | uint8_t i = 0, j = 0; |
| 94 | hdd_context_t *pHddCtx; |
| 95 | |
| 96 | pHddCtx = cds_get_context(CDF_MODULE_ID_HDD); |
| 97 | if (NULL != pHddCtx) { |
| 98 | for (i = 0; i < CDF_MAX_NO_OF_MODE; i++) |
| 99 | j += pHddCtx->no_of_active_sessions[i]; |
| 100 | return j > |
| 101 | (pHddCtx->config-> |
| 102 | gMaxConcurrentActiveSessions - 1); |
| 103 | } |
| 104 | |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | void cds_clear_concurrent_session_count(void) |
| 109 | { |
| 110 | uint8_t i = 0; |
| 111 | hdd_context_t *pHddCtx; |
| 112 | |
| 113 | pHddCtx = cds_get_context(CDF_MODULE_ID_HDD); |
| 114 | if (NULL != pHddCtx) { |
| 115 | for (i = 0; i < CDF_MAX_NO_OF_MODE; i++) |
| 116 | pHddCtx->no_of_active_sessions[i] = 0; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | /**--------------------------------------------------------------------------- |
| 121 | * |
| 122 | * \brief cds_is_multiple_active_sta_sessions() |
| 123 | * |
| 124 | * This function checks for presence of multiple active sta connections |
| 125 | * and it returns true if the more than 1 active sta connection exists. |
| 126 | * |
| 127 | * \param - None |
| 128 | * |
| 129 | * \return - true or false |
| 130 | * |
| 131 | * --------------------------------------------------------------------------*/ |
| 132 | bool cds_is_multiple_active_sta_sessions(void) |
| 133 | { |
| 134 | hdd_context_t *pHddCtx; |
| 135 | uint8_t j = 0; |
| 136 | |
| 137 | pHddCtx = cds_get_context(CDF_MODULE_ID_HDD); |
| 138 | if (NULL != pHddCtx) |
| 139 | j = pHddCtx->no_of_active_sessions[CDF_STA_MODE]; |
| 140 | |
| 141 | return j > 1; |
| 142 | } |
| 143 | |
| 144 | /**--------------------------------------------------------------------------- |
| 145 | * |
| 146 | * \brief cds_is_sta_active_connection_exists() |
| 147 | * |
| 148 | * This function checks for the presence of active sta connection |
| 149 | * and it returns true if exists. |
| 150 | * |
| 151 | * \param - None |
| 152 | * |
| 153 | * \return - true or false |
| 154 | * |
| 155 | * --------------------------------------------------------------------------*/ |
| 156 | bool cds_is_sta_active_connection_exists(void) |
| 157 | { |
| 158 | hdd_context_t *pHddCtx; |
| 159 | uint8_t j = 0; |
| 160 | |
| 161 | pHddCtx = cds_get_context(CDF_MODULE_ID_HDD); |
| 162 | if (NULL != pHddCtx) |
| 163 | j = pHddCtx->no_of_active_sessions[CDF_STA_MODE]; |
| 164 | |
| 165 | return j ? true : false; |
| 166 | } |