blob: 17555fbeab1edc4cc923bafac62797a2161dfa31 [file] [log] [blame]
/******************************************************************************
*
* This file is provided under a dual license. When you use or
* distribute this software, you may choose to be licensed under
* version 2 of the GNU General Public License ("GPLv2 License")
* or BSD License.
*
* GPLv2 License
*
* Copyright(C) 2016 MediaTek Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See http://www.gnu.org/licenses/gpl-2.0.html for more details.
*
* BSD LICENSE
*
* Copyright(C) 2016 MediaTek Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
/*
** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/mgmt/cnm.h#1
*/
/*! \file "cnm.h"
* \brief
*/
#ifndef _CNM_H
#define _CNM_H
/*******************************************************************************
* C O M P I L E R F L A G S
********************************************************************************
*/
/*******************************************************************************
* E X T E R N A L R E F E R E N C E S
********************************************************************************
*/
/*******************************************************************************
* C O N S T A N T S
********************************************************************************
*/
#if CFG_SUPPORT_DBDC
#define DBDC_5G_WMM_INDEX 0
#define DBDC_2G_WMM_INDEX 1
#endif
#define MAX_HW_WMM_INDEX (HW_WMM_NUM - 1)
#define DEFAULT_HW_WMM_INDEX (MAX_HW_WMM_INDEX - 1)
/*******************************************************************************
* D A T A T Y P E S
********************************************************************************
*/
typedef enum _ENUM_CH_REQ_TYPE_T {
CH_REQ_TYPE_JOIN,
CH_REQ_TYPE_P2P_LISTEN,
CH_REQ_TYPE_OFFCHNL_TX,
CH_REQ_TYPE_GO_START_BSS,
#if (CFG_SUPPORT_DFS_MASTER == 1)
CH_REQ_TYPE_DFS_CAC,
#endif
CH_REQ_TYPE_NUM
} ENUM_CH_REQ_TYPE_T, *P_ENUM_CH_REQ_TYPE_T;
typedef struct _MSG_CH_REQ_T {
MSG_HDR_T rMsgHdr; /* Must be the first member */
UINT_8 ucBssIndex;
UINT_8 ucTokenID;
UINT_8 ucPrimaryChannel;
ENUM_CHNL_EXT_T eRfSco;
ENUM_BAND_T eRfBand;
ENUM_CHANNEL_WIDTH_T eRfChannelWidth; /* To support 80/160MHz bandwidth */
UINT_8 ucRfCenterFreqSeg1; /* To support 80/160MHz bandwidth */
UINT_8 ucRfCenterFreqSeg2; /* To support 80/160MHz bandwidth */
ENUM_CH_REQ_TYPE_T eReqType;
UINT_32 u4MaxInterval; /* In unit of ms */
ENUM_DBDC_BN_T eDBDCBand;
} MSG_CH_REQ_T, *P_MSG_CH_REQ_T;
typedef struct _MSG_CH_ABORT_T {
MSG_HDR_T rMsgHdr; /* Must be the first member */
UINT_8 ucBssIndex;
UINT_8 ucTokenID;
ENUM_DBDC_BN_T eDBDCBand;
} MSG_CH_ABORT_T, *P_MSG_CH_ABORT_T;
typedef struct _MSG_CH_GRANT_T {
MSG_HDR_T rMsgHdr; /* Must be the first member */
UINT_8 ucBssIndex;
UINT_8 ucTokenID;
UINT_8 ucPrimaryChannel;
ENUM_CHNL_EXT_T eRfSco;
ENUM_BAND_T eRfBand;
ENUM_CHANNEL_WIDTH_T eRfChannelWidth; /* To support 80/160MHz bandwidth */
UINT_8 ucRfCenterFreqSeg1; /* To support 80/160MHz bandwidth */
UINT_8 ucRfCenterFreqSeg2; /* To support 80/160MHz bandwidth */
ENUM_CH_REQ_TYPE_T eReqType;
UINT_32 u4GrantInterval; /* In unit of ms */
ENUM_DBDC_BN_T eDBDCBand;
} MSG_CH_GRANT_T, *P_MSG_CH_GRANT_T;
typedef struct _MSG_CH_REOCVER_T {
MSG_HDR_T rMsgHdr; /* Must be the first member */
UINT_8 ucBssIndex;
UINT_8 ucTokenID;
UINT_8 ucPrimaryChannel;
ENUM_CHNL_EXT_T eRfSco;
ENUM_BAND_T eRfBand;
ENUM_CHANNEL_WIDTH_T eRfChannelWidth; /* To support 80/160MHz bandwidth */
UINT_8 ucRfCenterFreqSeg1; /* To support 80/160MHz bandwidth */
UINT_8 ucRfCenterFreqSeg2; /* To support 80/160MHz bandwidth */
ENUM_CH_REQ_TYPE_T eReqType;
} MSG_CH_RECOVER_T, *P_MSG_CH_RECOVER_T;
typedef struct _CNM_INFO_T {
BOOLEAN fgChGranted;
UINT_8 ucBssIndex;
UINT_8 ucTokenID;
} CNM_INFO_T, *P_CNM_INFO_T;
#if CFG_ENABLE_WIFI_DIRECT
/* Moved from p2p_fsm.h */
typedef struct _DEVICE_TYPE_T {
UINT_16 u2CategoryId; /* Category ID */
UINT_8 aucOui[4]; /* OUI */
UINT_16 u2SubCategoryId; /* Sub Category ID */
} __KAL_ATTRIB_PACKED__ DEVICE_TYPE_T, *P_DEVICE_TYPE_T;
#endif
#if CFG_SUPPORT_DBDC
typedef struct _CNM_DBDC_CAP_T {
UINT_8 ucBssIndex;
UINT_8 ucNss;
UINT_8 ucWmmSetIndex;
} CNM_DBDC_CAP_T, *P_CNM_DBDC_CAP_T;
typedef enum _ENUM_CNM_DBDC_MODE_T {
DBDC_MODE_DISABLED, /* A/G traffic separate by WMM, but both WMM TRX on band 0, CANNOT enable DBDC */
DBDC_MODE_STATIC, /* A/G traffic separate by WMM, WMM0/1 TRX on band 0/1, CANNOT disable DBDC */
DBDC_MODE_DYNAMIC, /* Automatically enable/disable DBDC, setting just like static/disable mode */
DBDC_MODE_NUM
} ENUM_CNM_DBDC_MODE_T, *P_ENUM_CNM_DBDC_MODE_T;
typedef enum _ENUM_CNM_DBDC_SWITCH_MECHANISM_T { /* When DBDC available in dynamic DBDC */
DBDC_SWITCH_MECHANISM_LATENCY_MODE, /* Switch to DBDC when available (less latency) */
DBDC_SWITCH_MECHANISM_THROUGHPUT_MODE, /* Switch to DBDC when DBDC T-put > MCC T-put */
DBDC_SWITCH_MECHANISM_NUM
} ENUM_CNM_DBDC_SWITCH_MECHANISM_T, *P_ENUM_CNM_DBDC_SWITCH_MECHANISM_T;
#endif /*CFG_SUPPORT_DBDC*/
/*******************************************************************************
* P U B L I C D A T A
********************************************************************************
*/
/*******************************************************************************
* P R I V A T E D A T A
********************************************************************************
*/
/*******************************************************************************
* M A C R O S
********************************************************************************
*/
#define CNM_CH_GRANTED_FOR_BSS(_prAdapter, _ucBssIndex) \
((_prAdapter)->rCnmInfo.fgChGranted && \
(_prAdapter)->rCnmInfo.ucBssIndex == (_ucBssIndex))
/*******************************************************************************
* F U N C T I O N D E C L A R A T I O N S
********************************************************************************
*/
VOID cnmInit(P_ADAPTER_T prAdapter);
VOID cnmUninit(P_ADAPTER_T prAdapter);
VOID cnmChMngrRequestPrivilege(P_ADAPTER_T prAdapter, P_MSG_HDR_T prMsgHdr);
VOID cnmChMngrAbortPrivilege(P_ADAPTER_T prAdapter, P_MSG_HDR_T prMsgHdr);
VOID cnmChMngrHandleChEvent(P_ADAPTER_T prAdapter, P_WIFI_EVENT_T prEvent);
#if (CFG_SUPPORT_DFS_MASTER == 1)
VOID cnmRadarDetectEvent(P_ADAPTER_T prAdapter, P_WIFI_EVENT_T prEvent);
VOID cnmCsaDoneEvent(P_ADAPTER_T prAdapter, P_WIFI_EVENT_T prEvent);
#endif
BOOLEAN
cnmPreferredChannel(P_ADAPTER_T prAdapter, P_ENUM_BAND_T prBand, PUINT_8 pucPrimaryChannel, P_ENUM_CHNL_EXT_T prBssSCO);
BOOLEAN cnmAisInfraChannelFixed(P_ADAPTER_T prAdapter, P_ENUM_BAND_T prBand, PUINT_8 pucPrimaryChannel);
VOID cnmAisInfraConnectNotify(P_ADAPTER_T prAdapter);
BOOLEAN cnmAisIbssIsPermitted(P_ADAPTER_T prAdapter);
BOOLEAN cnmP2PIsPermitted(P_ADAPTER_T prAdapter);
BOOLEAN cnmBowIsPermitted(P_ADAPTER_T prAdapter);
BOOLEAN cnmBss40mBwPermitted(P_ADAPTER_T prAdapter, UINT_8 ucBssIndex);
BOOLEAN cnmBss80mBwPermitted(P_ADAPTER_T prAdapter, UINT_8 ucBssIndex);
UINT_8 cnmGetBssMaxBw(P_ADAPTER_T prAdapter, UINT_8 ucBssIndex);
UINT_8 cnmGetBssMaxBwToChnlBW(P_ADAPTER_T prAdapter, UINT_8 ucBssIndex);
P_BSS_INFO_T cnmGetBssInfoAndInit(P_ADAPTER_T prAdapter, ENUM_NETWORK_TYPE_T eNetworkType, BOOLEAN fgIsP2pDevice);
VOID cnmFreeBssInfo(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo);
#if CFG_SUPPORT_CHNL_CONFLICT_REVISE
BOOLEAN cnmAisDetectP2PChannel(P_ADAPTER_T prAdapter, P_ENUM_BAND_T prBand, PUINT_8 pucPrimaryChannel);
#endif
#if (CFG_HW_WMM_BY_BSS == 1)
UINT_8 cnmWmmIndexDecision(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo);
VOID cnmFreeWmmIndex(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo);
#endif
#if CFG_SUPPORT_DBDC
VOID cnmInitDbdcSetting(IN P_ADAPTER_T prAdapter);
VOID cnmUpdateDbdcSetting(IN P_ADAPTER_T prAdapter, IN BOOLEAN fgDbdcEn);
VOID cnmGetDbdcCapability(
IN P_ADAPTER_T prAdapter,
IN UINT_8 ucBssIndex,
IN ENUM_BAND_T eRfBand,
IN UINT_8 ucPrimaryChannel,
IN UINT_8 ucNss,
OUT P_CNM_DBDC_CAP_T prDbdcCap
);
VOID cnmDbdcEnableDecision(
IN P_ADAPTER_T prAdapter,
IN UINT_8 ucChangedBssIndex,
IN ENUM_BAND_T eRfBand
);
VOID cnmDbdcDisableDecision(IN P_ADAPTER_T prAdapter, IN UINT_8 ucChangedBssIndex);
VOID cnmDbdcDecision(IN P_ADAPTER_T prAdapter, IN ULONG plParamPtr);
#endif /*CFG_SUPPORT_DBDC*/
/*******************************************************************************
* F U N C T I O N S
********************************************************************************
*/
#ifndef _lint
/* We don't have to call following function to inspect the data structure.
* It will check automatically while at compile time.
* We'll need this to guarantee the same member order in different structures
* to simply handling effort in some functions.
*/
static __KAL_INLINE__ VOID cnmMsgDataTypeCheck(VOID)
{
DATA_STRUCT_INSPECTING_ASSERT(OFFSET_OF(MSG_CH_GRANT_T, rMsgHdr) == 0);
DATA_STRUCT_INSPECTING_ASSERT(OFFSET_OF(MSG_CH_GRANT_T, rMsgHdr) == OFFSET_OF(MSG_CH_RECOVER_T, rMsgHdr));
DATA_STRUCT_INSPECTING_ASSERT(OFFSET_OF(MSG_CH_GRANT_T, ucBssIndex) == OFFSET_OF(MSG_CH_RECOVER_T, ucBssIndex));
DATA_STRUCT_INSPECTING_ASSERT(OFFSET_OF(MSG_CH_GRANT_T, ucTokenID) == OFFSET_OF(MSG_CH_RECOVER_T, ucTokenID));
DATA_STRUCT_INSPECTING_ASSERT(OFFSET_OF(MSG_CH_GRANT_T, ucPrimaryChannel) ==
OFFSET_OF(MSG_CH_RECOVER_T, ucPrimaryChannel));
DATA_STRUCT_INSPECTING_ASSERT(OFFSET_OF(MSG_CH_GRANT_T, eRfSco) == OFFSET_OF(MSG_CH_RECOVER_T, eRfSco));
DATA_STRUCT_INSPECTING_ASSERT(OFFSET_OF(MSG_CH_GRANT_T, eRfBand) == OFFSET_OF(MSG_CH_RECOVER_T, eRfBand));
DATA_STRUCT_INSPECTING_ASSERT(OFFSET_OF(MSG_CH_GRANT_T, eReqType) == OFFSET_OF(MSG_CH_RECOVER_T, eReqType));
}
#endif /* _lint */
#endif /* _CNM_H */