blob: d5c48a56d4aca7b63c892d5f20670f2177eba610 [file] [log] [blame]
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
* 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 the GNU General Public License for
* more details.
*
******************************************************************************/
#include <drv_types.h>
#include <rtl8723a_hal.h>
#include <usb_ops_linux.h>
#define DIS_PS_RX_BCN
u32 BTCoexDbgLevel = _bt_dbg_off_;
#define RTPRINT(_Comp, _Level, Fmt)\
do {\
if ((BTCoexDbgLevel == _bt_dbg_on_)) {\
printk Fmt;\
} \
} while (0)
#define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr)\
if ((BTCoexDbgLevel == _bt_dbg_on_)) {\
u32 __i; \
u8 *ptr = (u8 *)_Ptr; \
printk printstr; \
printk(" "); \
for (__i = 0; __i < 6; __i++) \
printk("%02X%s", ptr[__i], (__i == 5)?"":"-"); \
printk("\n"); \
}
#define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen)\
if ((BTCoexDbgLevel == _bt_dbg_on_)) {\
u32 __i; \
u8 *ptr = (u8 *)_HexData; \
printk(_TitleString); \
for (__i = 0; __i < (u32)_HexDataLen; __i++) { \
printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" ");\
if (((__i + 1) % 16) == 0) \
printk("\n"); \
} \
printk("\n"); \
}
/* Added by Annie, 2005-11-22. */
#define MAX_STR_LEN 64
/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */
#define PRINTABLE(_ch) (_ch >= ' ' && _ch <= '~')
#define RT_PRINT_STR(_Comp, _Level, _TitleString, _Ptr, _Len) \
{ \
u32 __i; \
u8 buffer[MAX_STR_LEN]; \
u32 length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1);\
memset(buffer, 0, MAX_STR_LEN); \
memcpy(buffer, (u8 *)_Ptr, length); \
for (__i = 0; __i < length; __i++) { \
if (!PRINTABLE(buffer[__i])) \
buffer[__i] = '?'; \
} \
buffer[length] = '\0'; \
printk(_TitleString); \
printk(": %d, <%s>\n", _Len, buffer); \
}
#define DCMD_Printf(...)
#define RT_ASSERT(...)
#define GetDefaultAdapter(padapter) padapter
#define PlatformZeroMemory(ptr, sz) memset(ptr, 0, sz)
#define PlatformProcessHCICommands(...)
#define PlatformTxBTQueuedPackets(...)
#define PlatformIndicateBTACLData(...) (RT_STATUS_SUCCESS)
#define PlatformAcquireSpinLock(padapter, type)
#define PlatformReleaseSpinLock(padapter, type)
#define GET_UNDECORATED_AVERAGE_RSSI(padapter) \
(GET_HAL_DATA(padapter)->dmpriv.EntryMinUndecoratedSmoothedPWDB)
#define RT_RF_CHANGE_SOURCE u32
enum {
RT_JOIN_INFRA = 1,
RT_JOIN_IBSS = 2,
RT_START_IBSS = 3,
RT_NO_ACTION = 4,
};
/* power saving */
/* ===== Below this line is sync from SD7 driver COMMOM/BT.c ===== */
static u8 BT_Operation(struct rtw_adapter *padapter)
{
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt;
if (pBtMgnt->BtOperationOn)
return true;
else
return false;
}
static u8 BT_IsLegalChannel(struct rtw_adapter *padapter, u8 channel)
{
struct rt_channel_info *pChanneList = NULL;
u8 channelLen, i;
pChanneList = padapter->mlmeextpriv.channel_set;
channelLen = padapter->mlmeextpriv.max_chan_nums;
for (i = 0; i < channelLen; i++) {
RTPRINT(FIOCTL, IOCTL_STATE,
("Check if chnl(%d) in channel plan contains bt target chnl(%d) for BT connection\n",
pChanneList[i].ChannelNum, channel));
if ((channel == pChanneList[i].ChannelNum) ||
(channel == pChanneList[i].ChannelNum + 2))
return channel;
}
return 0;
}
void BT_SignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8 *rssi_bt)
{
BTDM_SignalCompensation(padapter, rssi_wifi, rssi_bt);
}
void rtl8723a_BT_wifiscan_notify(struct rtw_adapter *padapter, u8 scanType)
{
BTHCI_WifiScanNotify(padapter, scanType);
BTDM_CheckAntSelMode(padapter);
BTDM_WifiScanNotify(padapter, scanType);
}
void rtl8723a_BT_wifiassociate_notify(struct rtw_adapter *padapter, u8 action)
{
/* action : */
/* true = associate start */
/* false = associate finished */
if (action)
BTDM_CheckAntSelMode(padapter);
BTDM_WifiAssociateNotify(padapter, action);
}
void BT_HaltProcess(struct rtw_adapter *padapter)
{
BTDM_ForHalt(padapter);
}
/* ===== End of sync from SD7 driver COMMOM/BT.c ===== */
#define i64fmt "ll"
#define UINT64_C(v) (v)
#define FillOctetString(_os, _octet, _len) \
(_os).Octet = (u8 *)(_octet); \
(_os).Length = (_len);
static enum rt_status PlatformIndicateBTEvent(
struct rtw_adapter *padapter,
void *pEvntData,
u32 dataLen
)
{
enum rt_status rt_status = RT_STATUS_FAILURE;
RTPRINT(FIOCTL, IOCTL_BT_EVENT_DETAIL, ("BT event start, %d bytes data to Transferred!!\n", dataLen));
RTPRINT_DATA(FIOCTL, IOCTL_BT_EVENT_DETAIL, "To transfer Hex Data :\n",
pEvntData, dataLen);
BT_EventParse(padapter, pEvntData, dataLen);
printk(KERN_WARNING "%s: Linux has no way to report BT event!!\n", __func__);
RTPRINT(FIOCTL, IOCTL_BT_EVENT_DETAIL, ("BT event end, %s\n",
(rt_status == RT_STATUS_SUCCESS) ? "SUCCESS" : "FAIL"));
return rt_status;
}
/* ===== Below this line is sync from SD7 driver COMMOM/bt_hci.c ===== */
static u8 bthci_GetLocalChannel(struct rtw_adapter *padapter)
{
return padapter->mlmeextpriv.cur_channel;
}
static u8 bthci_GetCurrentEntryNum(struct rtw_adapter *padapter, u8 PhyHandle)
{
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
u8 i;
for (i = 0; i < MAX_BT_ASOC_ENTRY_NUM; i++) {
if ((pBTInfo->BtAsocEntry[i].bUsed) &&
(pBTInfo->BtAsocEntry[i].PhyLinkCmdData.BtPhyLinkhandle == PhyHandle))
return i;
}
return 0xFF;
}
static void bthci_DecideBTChannel(struct rtw_adapter *padapter, u8 EntryNum)
{
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
struct mlme_priv *pmlmepriv;
struct bt_30info *pBTInfo;
struct bt_mgnt *pBtMgnt;
struct bt_hci_info *pBtHciInfo;
struct chnl_txpower_triple *pTriple_subband = NULL;
struct common_triple *pTriple;
u8 i, j, localchnl, firstRemoteLegalChnlInTriplet = 0;
u8 regulatory_skipLen = 0;
u8 subbandTripletCnt = 0;
pmlmepriv = &padapter->mlmepriv;
pBTInfo = GET_BT_INFO(padapter);
pBtMgnt = &pBTInfo->BtMgnt;
pBtHciInfo = &pBTInfo->BtHciInfo;
pBtMgnt->CheckChnlIsSuit = true;
localchnl = bthci_GetLocalChannel(padapter);
pTriple = (struct common_triple *)
&pBtHciInfo->BTPreChnllist[COUNTRY_STR_LEN];
/* contains country string, len is 3 */
for (i = 0; i < (pBtHciInfo->BtPreChnlListLen-COUNTRY_STR_LEN); i += 3, pTriple++) {
/* */
/* check every triplet, an triplet may be */
/* regulatory extension identifier or sub-band triplet */
/* */
if (pTriple->byte_1st == 0xc9) {
/* Regulatory Extension Identifier, skip it */
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO),
("Find Regulatory ID, regulatory class = %d\n", pTriple->byte_2nd));
regulatory_skipLen += 3;
pTriple_subband = NULL;
continue;
} else { /* Sub-band triplet */
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Find Sub-band triplet \n"));
subbandTripletCnt++;
pTriple_subband = (struct chnl_txpower_triple *)pTriple;
/* if remote first legal channel not found, then find first remote channel */
/* and it's legal for our channel plan. */
/* search the sub-band triplet and find if remote channel is legal to our channel plan. */
for (j = pTriple_subband->FirstChnl; j < (pTriple_subband->FirstChnl+pTriple_subband->NumChnls); j++) {
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), (" Check if chnl(%d) is legal\n", j));
if (BT_IsLegalChannel(padapter, j)) {
/* remote channel is legal for our channel plan. */
firstRemoteLegalChnlInTriplet = j;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO),
("Find first remote legal channel : %d\n",
firstRemoteLegalChnlInTriplet));
/* If we find a remote legal channel in the sub-band triplet */
/* and only BT connection is established(local not connect to any AP or IBSS), */
/* then we just switch channel to remote channel. */
if (!(check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_ADHOC_STATE|WIFI_AP_STATE) ||
BTHCI_HsConnectionEstablished(padapter))) {
pBtMgnt->BTChannel = firstRemoteLegalChnlInTriplet;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Remote legal channel (%d) is selected, Local not connect to any!!\n", pBtMgnt->BTChannel));
return;
} else {
if ((localchnl >= firstRemoteLegalChnlInTriplet) &&
(localchnl < (pTriple_subband->FirstChnl+pTriple_subband->NumChnls))) {
pBtMgnt->BTChannel = localchnl;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Local channel (%d) is selected, wifi or BT connection exists\n", pBtMgnt->BTChannel));
return;
}
}
break;
}
}
}
}
if (subbandTripletCnt) {
/* if any preferred channel triplet exists */
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("There are %d sub band triplet exists, ", subbandTripletCnt));
if (firstRemoteLegalChnlInTriplet == 0) {
/* no legal channel is found, reject the connection. */
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("no legal channel is found!!\n"));
} else {
/* Remote Legal channel is found but not match to local */
/* wifi connection exists), so reject the connection. */
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO),
("Remote Legal channel is found but not match to local(wifi connection exists)!!\n"));
}
pBtMgnt->CheckChnlIsSuit = false;
} else {
/* There are not any preferred channel triplet exists */
/* Use current legal channel as the bt channel. */
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("No sub band triplet exists!!\n"));
}
pBtMgnt->BTChannel = localchnl;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Local channel (%d) is selected!!\n", pBtMgnt->BTChannel));
}
/* Success:return true */
/* Fail:return false */
static u8 bthci_GetAssocInfo(struct rtw_adapter *padapter, u8 EntryNum)
{
struct bt_30info *pBTInfo;
struct bt_hci_info *pBtHciInfo;
u8 tempBuf[256];
u8 i = 0;
u8 BaseMemoryShift = 0;
u16 TotalLen = 0;
struct amp_assoc_structure *pAmpAsoc;
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("GetAssocInfo start\n"));
pBTInfo = GET_BT_INFO(padapter);
pBtHciInfo = &pBTInfo->BtHciInfo;
if (pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.LenSoFar == 0) {
if (pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.AMPAssocRemLen < (MAX_AMP_ASSOC_FRAG_LEN))
TotalLen = pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.AMPAssocRemLen;
else if (pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.AMPAssocRemLen == (MAX_AMP_ASSOC_FRAG_LEN))
TotalLen = MAX_AMP_ASSOC_FRAG_LEN;
} else if (pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.LenSoFar > 0)
TotalLen = pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.LenSoFar;
while ((pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.LenSoFar >= BaseMemoryShift) || TotalLen > BaseMemoryShift) {
RTPRINT(FIOCTL, IOCTL_BT_HCICMD_DETAIL, ("GetAssocInfo, TotalLen =%d, BaseMemoryShift =%d\n", TotalLen, BaseMemoryShift));
memcpy(tempBuf,
(u8 *)pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.AMPAssocfragment+BaseMemoryShift,
TotalLen-BaseMemoryShift);
RTPRINT_DATA(FIOCTL, IOCTL_BT_HCICMD_DETAIL, "GetAssocInfo :\n",
tempBuf, TotalLen-BaseMemoryShift);
pAmpAsoc = (struct amp_assoc_structure *)tempBuf;
le16_to_cpus(&pAmpAsoc->Length);
BaseMemoryShift += 3 + pAmpAsoc->Length;
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("TypeID = 0x%x, ", pAmpAsoc->TypeID));
RTPRINT_DATA(FIOCTL, IOCTL_BT_HCICMD, "Hex Data: \n", pAmpAsoc->Data, pAmpAsoc->Length);
switch (pAmpAsoc->TypeID) {
case AMP_MAC_ADDR:
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("==> AMP_MAC_ADDR\n"));
if (pAmpAsoc->Length > 6)
return false;
memcpy(pBTInfo->BtAsocEntry[EntryNum].BTRemoteMACAddr, pAmpAsoc->Data, 6);
RTPRINT_ADDR(FIOCTL, IOCTL_BT_HCICMD, ("Remote Mac address \n"), pBTInfo->BtAsocEntry[EntryNum].BTRemoteMACAddr);
break;
case AMP_PREFERRED_CHANNEL_LIST:
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("==> AMP_PREFERRED_CHANNEL_LIST\n"));
pBtHciInfo->BtPreChnlListLen = pAmpAsoc->Length;
memcpy(pBtHciInfo->BTPreChnllist,
pAmpAsoc->Data,
pBtHciInfo->BtPreChnlListLen);
RTPRINT_DATA(FIOCTL, IOCTL_BT_HCICMD, "Preferred channel list : \n", pBtHciInfo->BTPreChnllist, pBtHciInfo->BtPreChnlListLen);
bthci_DecideBTChannel(padapter, EntryNum);
break;
case AMP_CONNECTED_CHANNEL:
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("==> AMP_CONNECTED_CHANNEL\n"));
pBtHciInfo->BTConnectChnlListLen = pAmpAsoc->Length;
memcpy(pBtHciInfo->BTConnectChnllist,
pAmpAsoc->Data,
pBtHciInfo->BTConnectChnlListLen);
break;
case AMP_80211_PAL_CAP_LIST:
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("==> AMP_80211_PAL_CAP_LIST\n"));
pBTInfo->BtAsocEntry[EntryNum].BTCapability = *(u32 *)(pAmpAsoc->Data);
if (pBTInfo->BtAsocEntry[EntryNum].BTCapability & 0x00000001) {
/* TODO: */
/* Signifies PAL capable of utilizing received activity reports. */
}
if (pBTInfo->BtAsocEntry[EntryNum].BTCapability & 0x00000002) {
/* TODO: */
/* Signifies PAL is capable of utilizing scheduling information received in an activity reports. */
}
break;
case AMP_80211_PAL_VISION:
pBtHciInfo->BTPalVersion = *(u8 *)(pAmpAsoc->Data);
pBtHciInfo->BTPalCompanyID = *(u16 *)(((u8 *)(pAmpAsoc->Data))+1);
pBtHciInfo->BTPalsubversion = *(u16 *)(((u8 *)(pAmpAsoc->Data))+3);
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("==> AMP_80211_PAL_VISION PalVersion 0x%x, PalCompanyID 0x%x, Palsubversion 0x%x\n",
pBtHciInfo->BTPalVersion,
pBtHciInfo->BTPalCompanyID,
pBtHciInfo->BTPalsubversion));
break;
default:
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("==> Unsupport TypeID !!\n"));
break;
}
i++;
}
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("GetAssocInfo end\n"));
return true;
}
static u8 bthci_AddEntry(struct rtw_adapter *padapter)
{
struct bt_30info *pBTInfo;
struct bt_mgnt *pBtMgnt;
u8 i;
pBTInfo = GET_BT_INFO(padapter);
pBtMgnt = &pBTInfo->BtMgnt;
for (i = 0; i < MAX_BT_ASOC_ENTRY_NUM; i++) {
if (pBTInfo->BtAsocEntry[i].bUsed == false) {
pBTInfo->BtAsocEntry[i].bUsed = true;
pBtMgnt->CurrentConnectEntryNum = i;
break;
}
}
if (i == MAX_BT_ASOC_ENTRY_NUM) {
RTPRINT(FIOCTL, IOCTL_STATE, ("bthci_AddEntry(), Add entry fail!!\n"));
return false;
}
return true;
}
static u8 bthci_DiscardTxPackets(struct rtw_adapter *padapter, u16 LLH)
{
return false;
}
static u8
bthci_CheckLogLinkBehavior(
struct rtw_adapter *padapter,
struct hci_flow_spec TxFlowSpec
)
{
u8 ID = TxFlowSpec.Identifier;
u8 ServiceType = TxFlowSpec.ServiceType;
u16 MaxSDUSize = TxFlowSpec.MaximumSDUSize;
u32 SDUInterArrivatime = TxFlowSpec.SDUInterArrivalTime;
u8 match = false;
switch (ID) {
case 1:
if (ServiceType == BT_LL_BE) {
match = true;
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Logical Link Type = TX best effort flowspec\n"));
} else if ((ServiceType == BT_LL_GU) && (MaxSDUSize == 0xffff)) {
match = true;
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Logical Link Type = RX guaranteed latency flowspec\n"));
} else if ((ServiceType == BT_LL_GU) && (MaxSDUSize == 2500)) {
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Logical Link Type = RX guaranteed Large latency flowspec\n"));
}
break;
case 2:
if (ServiceType == BT_LL_BE) {
match = true;
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Logical Link Type = RX best effort flowspec\n"));
}
break;
case 3:
if ((ServiceType == BT_LL_GU) && (MaxSDUSize == 1492)) {
match = true;
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Logical Link Type = TX guaranteed latency flowspec\n"));
} else if ((ServiceType == BT_LL_GU) && (MaxSDUSize == 2500)) {
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Logical Link Type = TX guaranteed Large latency flowspec\n"));
}
break;
case 4:
if (ServiceType == BT_LL_BE) {
if ((SDUInterArrivatime == 0xffffffff) && (ServiceType == BT_LL_BE) && (MaxSDUSize == 1492)) {
match = true;
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Logical Link Type = TX/RX aggregated best effort flowspec\n"));
}
} else if (ServiceType == BT_LL_GU) {
if (SDUInterArrivatime == 100) {
match = true;
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Logical Link Type = TX/RX guaranteed bandwidth flowspec\n"));
}
}
break;
default:
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Logical Link Type = Unknow Type !!!!!!!!\n"));
break;
}
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO),
("ID = 0x%x, ServiceType = 0x%x, MaximumSDUSize = 0x%x, SDUInterArrivalTime = 0x%x, AccessLatency = 0x%x, FlushTimeout = 0x%x\n",
TxFlowSpec.Identifier, TxFlowSpec.ServiceType, MaxSDUSize,
SDUInterArrivatime, TxFlowSpec.AccessLatency, TxFlowSpec.FlushTimeout));
return match;
}
static u16 bthci_AssocMACAddr(struct rtw_adapter *padapter, void *pbuf)
{
struct amp_assoc_structure *pAssoStrc = (struct amp_assoc_structure *)pbuf;
pAssoStrc->TypeID = AMP_MAC_ADDR;
pAssoStrc->Length = 0x06;
memcpy(&pAssoStrc->Data[0], padapter->eeprompriv.mac_addr, 6);
RTPRINT_DATA(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO),
("AssocMACAddr : \n"), pAssoStrc, pAssoStrc->Length+3);
return pAssoStrc->Length + 3;
}
static u16
bthci_PALCapabilities(
struct rtw_adapter *padapter,
void *pbuf
)
{
struct amp_assoc_structure *pAssoStrc = (struct amp_assoc_structure *)pbuf;
pAssoStrc->TypeID = AMP_80211_PAL_CAP_LIST;
pAssoStrc->Length = 0x04;
pAssoStrc->Data[0] = 0x00;
pAssoStrc->Data[1] = 0x00;
RTPRINT_DATA(FIOCTL, IOCTL_BT_HCICMD_DETAIL, ("PALCapabilities:\n"), pAssoStrc, pAssoStrc->Length+3);
RTPRINT(FIOCTL, IOCTL_BT_LOGO, ("PALCapabilities \n"));
RTPRINT(FIOCTL, IOCTL_BT_LOGO, (" TypeID = 0x%x,\n Length = 0x%x,\n Content = 0x0000\n",
pAssoStrc->TypeID,
pAssoStrc->Length));
return pAssoStrc->Length + 3;
}
static u16 bthci_AssocPreferredChannelList(struct rtw_adapter *padapter,
void *pbuf, u8 EntryNum)
{
struct bt_30info *pBTInfo;
struct amp_assoc_structure *pAssoStrc;
struct amp_pref_chnl_regulatory *pReg;
struct chnl_txpower_triple *pTriple;
char ctrString[3] = {'X', 'X', 'X'};
u32 len = 0;
u8 preferredChnl;
pBTInfo = GET_BT_INFO(padapter);
pAssoStrc = (struct amp_assoc_structure *)pbuf;
pReg = (struct amp_pref_chnl_regulatory *)&pAssoStrc->Data[3];
preferredChnl = bthci_GetLocalChannel(padapter);
pAssoStrc->TypeID = AMP_PREFERRED_CHANNEL_LIST;
/* locale unknown */
memcpy(&pAssoStrc->Data[0], &ctrString[0], 3);
pReg->reXId = 201;
pReg->regulatoryClass = 254;
pReg->coverageClass = 0;
len += 6;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD | IOCTL_BT_LOGO), ("PREFERRED_CHNL_LIST\n"));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD | IOCTL_BT_LOGO), ("XXX, 201, 254, 0\n"));
/* at the following, chnl 1~11 should be contained */
pTriple = (struct chnl_txpower_triple *)&pAssoStrc->Data[len];
/* (1) if any wifi or bt HS connection exists */
if ((pBTInfo->BtAsocEntry[EntryNum].AMPRole == AMP_BTAP_CREATOR) ||
(check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE |
WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE |
WIFI_AP_STATE)) ||
BTHCI_HsConnectionEstablished(padapter)) {
pTriple->FirstChnl = preferredChnl;
pTriple->NumChnls = 1;
pTriple->MaxTxPowerInDbm = 20;
len += 3;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD | IOCTL_BT_LOGO), ("First Channel = %d, Channel Num = %d, MaxDbm = %d\n",
pTriple->FirstChnl,
pTriple->NumChnls,
pTriple->MaxTxPowerInDbm));
}
pAssoStrc->Length = (u16)len;
RTPRINT_DATA(FIOCTL, IOCTL_BT_HCICMD, ("AssocPreferredChannelList : \n"), pAssoStrc, pAssoStrc->Length+3);
return pAssoStrc->Length + 3;
}
static u16 bthci_AssocPALVer(struct rtw_adapter *padapter, void *pbuf)
{
struct amp_assoc_structure *pAssoStrc = (struct amp_assoc_structure *)pbuf;
u8 *pu1Tmp;
u16 *pu2Tmp;
pAssoStrc->TypeID = AMP_80211_PAL_VISION;
pAssoStrc->Length = 0x5;
pu1Tmp = &pAssoStrc->Data[0];
*pu1Tmp = 0x1; /* PAL Version */
pu2Tmp = (u16 *)&pAssoStrc->Data[1];
*pu2Tmp = 0x5D; /* SIG Company identifier of 802.11 PAL vendor */
pu2Tmp = (u16 *)&pAssoStrc->Data[3];
*pu2Tmp = 0x1; /* PAL Sub-version specifier */
RTPRINT_DATA(FIOCTL, IOCTL_BT_HCICMD_DETAIL, ("AssocPALVer : \n"), pAssoStrc, pAssoStrc->Length+3);
RTPRINT(FIOCTL, IOCTL_BT_LOGO, ("AssocPALVer \n"));
RTPRINT(FIOCTL, IOCTL_BT_LOGO, (" TypeID = 0x%x,\n Length = 0x%x,\n PAL Version = 0x01,\n PAL vendor = 0x01,\n PAL Sub-version specifier = 0x01\n",
pAssoStrc->TypeID,
pAssoStrc->Length));
return pAssoStrc->Length + 3;
}
static u8 bthci_CheckRfStateBeforeConnect(struct rtw_adapter *padapter)
{
struct bt_30info *pBTInfo;
enum rt_rf_power_state RfState;
pBTInfo = GET_BT_INFO(padapter);
RfState = padapter->pwrctrlpriv.rf_pwrstate;
if (RfState != rf_on) {
mod_timer(&pBTInfo->BTPsDisableTimer,
jiffies + msecs_to_jiffies(50));
return false;
}
return true;
}
static void bthci_ResponderStartToScan(struct rtw_adapter *padapter)
{
}
static u8 bthci_PhyLinkConnectionInProgress(struct rtw_adapter *padapter, u8 PhyLinkHandle)
{
struct bt_30info *pBTInfo;
struct bt_mgnt *pBtMgnt;
pBTInfo = GET_BT_INFO(padapter);
pBtMgnt = &pBTInfo->BtMgnt;
if (pBtMgnt->bPhyLinkInProgress &&
(pBtMgnt->BtCurrentPhyLinkhandle == PhyLinkHandle))
return true;
return false;
}
static void bthci_ResetFlowSpec(struct rtw_adapter *padapter, u8 EntryNum, u8 index)
{
struct bt_30info *pBTinfo;
pBTinfo = GET_BT_INFO(padapter);
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].BtLogLinkhandle = 0;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].BtPhyLinkhandle = 0;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].bLLCompleteEventIsSet = false;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].bLLCancelCMDIsSetandComplete = false;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].BtTxFlowSpecID = 0;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].TxPacketCount = 0;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Tx_Flow_Spec.Identifier = 0x01;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Tx_Flow_Spec.ServiceType = SERVICE_BEST_EFFORT;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Tx_Flow_Spec.MaximumSDUSize = 0xffff;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Tx_Flow_Spec.SDUInterArrivalTime = 0xffffffff;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Tx_Flow_Spec.AccessLatency = 0xffffffff;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Tx_Flow_Spec.FlushTimeout = 0xffffffff;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Rx_Flow_Spec.Identifier = 0x01;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Rx_Flow_Spec.ServiceType = SERVICE_BEST_EFFORT;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Rx_Flow_Spec.MaximumSDUSize = 0xffff;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Rx_Flow_Spec.SDUInterArrivalTime = 0xffffffff;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Rx_Flow_Spec.AccessLatency = 0xffffffff;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[index].Rx_Flow_Spec.FlushTimeout = 0xffffffff;
}
static void bthci_ResetEntry(struct rtw_adapter *padapter, u8 EntryNum)
{
struct bt_30info *pBTinfo;
struct bt_mgnt *pBtMgnt;
u8 j;
pBTinfo = GET_BT_INFO(padapter);
pBtMgnt = &pBTinfo->BtMgnt;
pBTinfo->BtAsocEntry[EntryNum].bUsed = false;
pBTinfo->BtAsocEntry[EntryNum].BtCurrentState = HCI_STATE_DISCONNECTED;
pBTinfo->BtAsocEntry[EntryNum].BtNextState = HCI_STATE_DISCONNECTED;
pBTinfo->BtAsocEntry[EntryNum].AmpAsocCmdData.AMPAssocRemLen = 0;
pBTinfo->BtAsocEntry[EntryNum].AmpAsocCmdData.BtPhyLinkhandle = 0;
if (pBTinfo->BtAsocEntry[EntryNum].AmpAsocCmdData.AMPAssocfragment != NULL)
memset(pBTinfo->BtAsocEntry[EntryNum].AmpAsocCmdData.AMPAssocfragment, 0, TOTAL_ALLOCIATE_ASSOC_LEN);
pBTinfo->BtAsocEntry[EntryNum].AmpAsocCmdData.LenSoFar = 0;
pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKeyType = 0;
pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle = 0;
memset(pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKey, 0,
pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKeyLen);
pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKeyLen = 0;
/* 0x640; 0.625ms*1600 = 1000ms, 0.625ms*16000 = 10000ms */
pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.LinkSuperversionTimeout = 0x3e80;
pBTinfo->BtAsocEntry[EntryNum].AMPRole = AMP_BTAP_NONE;
pBTinfo->BtAsocEntry[EntryNum].mAssoc = false;
pBTinfo->BtAsocEntry[EntryNum].b4waySuccess = false;
/* Reset BT WPA */
pBTinfo->BtAsocEntry[EntryNum].KeyReplayCounter = 0;
pBTinfo->BtAsocEntry[EntryNum].BTWPAAuthState = STATE_WPA_AUTH_UNINITIALIZED;
pBTinfo->BtAsocEntry[EntryNum].bSendSupervisionPacket = false;
pBTinfo->BtAsocEntry[EntryNum].NoRxPktCnt = 0;
pBTinfo->BtAsocEntry[EntryNum].ShortRangeMode = 0;
pBTinfo->BtAsocEntry[EntryNum].rxSuvpPktCnt = 0;
for (j = 0; j < MAX_LOGICAL_LINK_NUM; j++)
bthci_ResetFlowSpec(padapter, EntryNum, j);
pBtMgnt->BTAuthCount = 0;
pBtMgnt->BTAsocCount = 0;
pBtMgnt->BTCurrentConnectType = BT_DISCONNECT;
pBtMgnt->BTReceiveConnectPkt = BT_DISCONNECT;
HALBT_RemoveKey(padapter, EntryNum);
}
static void bthci_RemoveEntryByEntryNum(struct rtw_adapter *padapter, u8 EntryNum)
{
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt;
bthci_ResetEntry(padapter, EntryNum);
if (pBtMgnt->CurrentBTConnectionCnt > 0)
pBtMgnt->CurrentBTConnectionCnt--;
RTPRINT(FIOCTL, IOCTL_STATE, ("[BT Flag], CurrentBTConnectionCnt = %d!!\n",
pBtMgnt->CurrentBTConnectionCnt));
if (pBtMgnt->CurrentBTConnectionCnt > 0) {
pBtMgnt->BtOperationOn = true;
} else {
pBtMgnt->BtOperationOn = false;
RTPRINT(FIOCTL, IOCTL_STATE, ("[BT Flag], Bt Operation OFF!!\n"));
}
if (!pBtMgnt->BtOperationOn) {
del_timer_sync(&pBTInfo->BTHCIDiscardAclDataTimer);
del_timer_sync(&pBTInfo->BTBeaconTimer);
pBtMgnt->bStartSendSupervisionPkt = false;
}
}
static u8
bthci_CommandCompleteHeader(
u8 *pbuf,
u16 OGF,
u16 OCF,
enum hci_status status
)
{
struct packet_irp_hcievent_data *PPacketIrpEvent = (struct packet_irp_hcievent_data *)pbuf;
u8 NumHCI_Comm = 0x1;
PPacketIrpEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE;
PPacketIrpEvent->Data[0] = NumHCI_Comm; /* packet # */
PPacketIrpEvent->Data[1] = HCIOPCODELOW(OCF, OGF);
PPacketIrpEvent->Data[2] = HCIOPCODEHIGHT(OCF, OGF);
if (OGF == OGF_EXTENSION) {
if (OCF == HCI_SET_RSSI_VALUE) {
RTPRINT(FIOCTL, (IOCTL_BT_EVENT_PERIODICAL),
("[BT event], CommandComplete, Num_HCI_Comm = 0x%x, Opcode = 0x%02x%02x, status = 0x%x, OGF = 0x%x, OCF = 0x%x\n",
NumHCI_Comm, (HCIOPCODEHIGHT(OCF, OGF)), (HCIOPCODELOW(OCF, OGF)), status, OGF, OCF));
} else {
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_EXT),
("[BT event], CommandComplete, Num_HCI_Comm = 0x%x, Opcode = 0x%02x%02x, status = 0x%x, OGF = 0x%x, OCF = 0x%x\n",
NumHCI_Comm, (HCIOPCODEHIGHT(OCF, OGF)), (HCIOPCODELOW(OCF, OGF)), status, OGF, OCF));
}
} else {
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO),
("[BT event], CommandComplete, Num_HCI_Comm = 0x%x, Opcode = 0x%02x%02x, status = 0x%x, OGF = 0x%x, OCF = 0x%x\n",
NumHCI_Comm, (HCIOPCODEHIGHT(OCF, OGF)), (HCIOPCODELOW(OCF, OGF)), status, OGF, OCF));
}
return 3;
}
static u8 bthci_ExtensionEventHeaderRtk(u8 *pbuf, u8 extensionEvent)
{
struct packet_irp_hcievent_data *PPacketIrpEvent = (struct packet_irp_hcievent_data *)pbuf;
PPacketIrpEvent->EventCode = HCI_EVENT_EXTENSION_RTK;
PPacketIrpEvent->Data[0] = extensionEvent; /* extension event code */
return 1;
}
static enum rt_status
bthci_IndicateEvent(
struct rtw_adapter *padapter,
void *pEvntData,
u32 dataLen
)
{
enum rt_status rt_status;
rt_status = PlatformIndicateBTEvent(padapter, pEvntData, dataLen);
return rt_status;
}
static void
bthci_EventWriteRemoteAmpAssoc(
struct rtw_adapter *padapter,
enum hci_status status,
u8 PLHandle
)
{
u8 localBuf[TmpLocalBufSize] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
PlatformZeroMemory(&localBuf[0], TmpLocalBufSize);
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_STATUS_PARAMETERS,
HCI_WRITE_REMOTE_AMP_ASSOC,
status);
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("PhyLinkHandle = 0x%x, status = %d\n", PLHandle, status));
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
pRetPar[1] = PLHandle;
len += 2;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
}
static void
bthci_EventEnhancedFlushComplete(
struct rtw_adapter *padapter,
u16 LLH
)
{
u8 localBuf[4] = "";
struct packet_irp_hcievent_data *PPacketIrpEvent;
RTPRINT(FIOCTL, IOCTL_BT_EVENT, ("EventEnhancedFlushComplete, LLH = 0x%x\n", LLH));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_ENHANCED_FLUSH_COMPLETE;
PPacketIrpEvent->Length = 2;
/* Logical link handle */
PPacketIrpEvent->Data[0] = TWOBYTE_LOWBYTE(LLH);
PPacketIrpEvent->Data[1] = TWOBYTE_HIGHTBYTE(LLH);
bthci_IndicateEvent(padapter, PPacketIrpEvent, 4);
}
static void
bthci_EventShortRangeModeChangeComplete(
struct rtw_adapter *padapter,
enum hci_status HciStatus,
u8 ShortRangeState,
u8 EntryNum
)
{
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[5] = "";
struct packet_irp_hcievent_data *PPacketIrpEvent;
if (!(pBtHciInfo->BTEventMaskPage2 & EMP2_HCI_EVENT_SHORT_RANGE_MODE_CHANGE_COMPLETE)) {
RTPRINT(FIOCTL, IOCTL_BT_EVENT,
("[BT event], Short Range Mode Change Complete, Ignore to send this event due to event mask page 2\n"));
return;
}
RTPRINT(FIOCTL, IOCTL_BT_EVENT, ("[BT event], Short Range Mode Change Complete, Status = %d\n , PLH = 0x%x\n, Short_Range_Mode_State = 0x%x\n",
HciStatus, pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle, ShortRangeState));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_SHORT_RANGE_MODE_CHANGE_COMPLETE;
PPacketIrpEvent->Length = 3;
PPacketIrpEvent->Data[0] = HciStatus;
PPacketIrpEvent->Data[1] = pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle;
PPacketIrpEvent->Data[2] = ShortRangeState;
bthci_IndicateEvent(padapter, PPacketIrpEvent, 5);
}
static void bthci_EventSendFlowSpecModifyComplete(struct rtw_adapter *padapter,
enum hci_status HciStatus,
u16 logicHandle)
{
u8 localBuf[5] = "";
struct packet_irp_hcievent_data *PPacketIrpEvent;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
if (!(pBtHciInfo->BTEventMaskPage2 & EMP2_HCI_EVENT_FLOW_SPEC_MODIFY_COMPLETE)) {
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO),
("[BT event], Flow Spec Modify Complete, Ignore to send this event due to event mask page 2\n"));
return;
}
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO),
("[BT event], Flow Spec Modify Complete, status = 0x%x, LLH = 0x%x\n", HciStatus, logicHandle));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_FLOW_SPEC_MODIFY_COMPLETE;
PPacketIrpEvent->Length = 3;
PPacketIrpEvent->Data[0] = HciStatus;
/* Logical link handle */
PPacketIrpEvent->Data[1] = TWOBYTE_LOWBYTE(logicHandle);
PPacketIrpEvent->Data[2] = TWOBYTE_HIGHTBYTE(logicHandle);
bthci_IndicateEvent(padapter, PPacketIrpEvent, 5);
}
static void
bthci_EventExtWifiScanNotify(
struct rtw_adapter *padapter,
u8 scanType
)
{
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt;
u8 len = 0;
u8 localBuf[7] = "";
u8 *pRetPar;
u8 *pu1Temp;
struct packet_irp_hcievent_data *PPacketIrpEvent;
if (!pBtMgnt->BtOperationOn)
return;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_ExtensionEventHeaderRtk(&localBuf[0], HCI_EVENT_EXT_WIFI_SCAN_NOTIFY);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pu1Temp = (u8 *)&pRetPar[0];
*pu1Temp = scanType;
len += 1;
PPacketIrpEvent->Length = len;
if (bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2) == RT_STATUS_SUCCESS) {
RTPRINT(FIOCTL, IOCTL_BT_EVENT, ("[BT event], Wifi scan notify, scan type = %d\n",
scanType));
}
}
static void
bthci_EventAMPReceiverReport(
struct rtw_adapter *padapter,
u8 Reason
)
{
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
if (pBtHciInfo->bTestNeedReport) {
u8 localBuf[20] = "";
u32 *pu4Temp;
u16 *pu2Temp;
struct packet_irp_hcievent_data *PPacketIrpEvent;
RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), (" HCI_EVENT_AMP_RECEIVER_REPORT\n"));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_AMP_RECEIVER_REPORT;
PPacketIrpEvent->Length = 2;
PPacketIrpEvent->Data[0] = pBtHciInfo->TestCtrType;
PPacketIrpEvent->Data[1] = Reason;
pu4Temp = (u32 *)&PPacketIrpEvent->Data[2];
*pu4Temp = pBtHciInfo->TestEventType;
pu2Temp = (u16 *)&PPacketIrpEvent->Data[6];
*pu2Temp = pBtHciInfo->TestNumOfFrame;
pu2Temp = (u16 *)&PPacketIrpEvent->Data[8];
*pu2Temp = pBtHciInfo->TestNumOfErrFrame;
pu4Temp = (u32 *)&PPacketIrpEvent->Data[10];
*pu4Temp = pBtHciInfo->TestNumOfBits;
pu4Temp = (u32 *)&PPacketIrpEvent->Data[14];
*pu4Temp = pBtHciInfo->TestNumOfErrBits;
bthci_IndicateEvent(padapter, PPacketIrpEvent, 20);
/* Return to Idel state with RX and TX off. */
}
pBtHciInfo->TestNumOfFrame = 0x00;
}
static void
bthci_EventChannelSelected(
struct rtw_adapter *padapter,
u8 EntryNum
)
{
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[3] = "";
struct packet_irp_hcievent_data *PPacketIrpEvent;
if (!(pBtHciInfo->BTEventMaskPage2 & EMP2_HCI_EVENT_CHANNEL_SELECT)) {
RTPRINT(FIOCTL, IOCTL_BT_EVENT,
("[BT event], Channel Selected, Ignore to send this event due to event mask page 2\n"));
return;
}
RTPRINT(FIOCTL, IOCTL_BT_EVENT|IOCTL_STATE,
("[BT event], Channel Selected, PhyLinkHandle %d\n",
pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_CHANNEL_SELECT;
PPacketIrpEvent->Length = 1;
PPacketIrpEvent->Data[0] = pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle;
bthci_IndicateEvent(padapter, PPacketIrpEvent, 3);
}
static void
bthci_EventDisconnectPhyLinkComplete(
struct rtw_adapter *padapter,
enum hci_status HciStatus,
enum hci_status Reason,
u8 EntryNum
)
{
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[5] = "";
struct packet_irp_hcievent_data *PPacketIrpEvent;
if (!(pBtHciInfo->BTEventMaskPage2 & EMP2_HCI_EVENT_DISCONNECT_PHY_LINK_COMPLETE)) {
RTPRINT(FIOCTL, IOCTL_BT_EVENT,
("[BT event], Disconnect Physical Link Complete, Ignore to send this event due to event mask page 2\n"));
return;
}
RTPRINT(FIOCTL, IOCTL_BT_EVENT,
("[BT event], Disconnect Physical Link Complete, Status = 0x%x, PLH = 0x%x Reason = 0x%x\n",
HciStatus, pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle, Reason));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_DISCONNECT_PHY_LINK_COMPLETE;
PPacketIrpEvent->Length = 3;
PPacketIrpEvent->Data[0] = HciStatus;
PPacketIrpEvent->Data[1] = pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle;
PPacketIrpEvent->Data[2] = Reason;
bthci_IndicateEvent(padapter, PPacketIrpEvent, 5);
}
static void
bthci_EventPhysicalLinkComplete(
struct rtw_adapter *padapter,
enum hci_status HciStatus,
u8 EntryNum,
u8 PLHandle
)
{
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt;
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
struct bt_dgb *pBtDbg = &pBTInfo->BtDbg;
u8 localBuf[4] = "";
struct packet_irp_hcievent_data *PPacketIrpEvent;
u8 PL_handle;
pBtMgnt->bPhyLinkInProgress = false;
pBtDbg->dbgHciInfo.hciCmdPhyLinkStatus = HciStatus;
if (!(pBtHciInfo->BTEventMaskPage2 & EMP2_HCI_EVENT_PHY_LINK_COMPLETE)) {
RTPRINT(FIOCTL, IOCTL_BT_EVENT,
("[BT event], Physical Link Complete, Ignore to send this event due to event mask page 2\n"));
return;
}
if (EntryNum == 0xff) {
/* connection not started yet, just use the input physical link handle to response. */
PL_handle = PLHandle;
} else {
/* connection is under progress, use the phy link handle we recorded. */
PL_handle = pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle;
pBTInfo->BtAsocEntry[EntryNum].bNeedPhysLinkCompleteEvent = false;
}
RTPRINT(FIOCTL, IOCTL_BT_EVENT, ("[BT event], Physical Link Complete, Status = 0x%x PhyLinkHandle = 0x%x\n", HciStatus,
PL_handle));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_PHY_LINK_COMPLETE;
PPacketIrpEvent->Length = 2;
PPacketIrpEvent->Data[0] = HciStatus;
PPacketIrpEvent->Data[1] = PL_handle;
bthci_IndicateEvent(padapter, PPacketIrpEvent, 4);
}
static void
bthci_EventCommandStatus(
struct rtw_adapter *padapter,
u8 OGF,
u16 OCF,
enum hci_status HciStatus
)
{
u8 localBuf[6] = "";
struct packet_irp_hcievent_data *PPacketIrpEvent;
u8 Num_Hci_Comm = 0x1;
RTPRINT(FIOCTL, IOCTL_BT_EVENT,
("[BT event], CommandStatus, Opcode = 0x%02x%02x, OGF = 0x%x, OCF = 0x%x, Status = 0x%x, Num_HCI_COMM = 0x%x\n",
(HCIOPCODEHIGHT(OCF, OGF)), (HCIOPCODELOW(OCF, OGF)), OGF, OCF, HciStatus, Num_Hci_Comm));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_COMMAND_STATUS;
PPacketIrpEvent->Length = 4;
PPacketIrpEvent->Data[0] = HciStatus; /* current pending */
PPacketIrpEvent->Data[1] = Num_Hci_Comm; /* packet # */
PPacketIrpEvent->Data[2] = HCIOPCODELOW(OCF, OGF);
PPacketIrpEvent->Data[3] = HCIOPCODEHIGHT(OCF, OGF);
bthci_IndicateEvent(padapter, PPacketIrpEvent, 6);
}
static void
bthci_EventLogicalLinkComplete(
struct rtw_adapter *padapter,
enum hci_status HciStatus,
u8 PhyLinkHandle,
u16 LogLinkHandle,
u8 LogLinkIndex,
u8 EntryNum
)
{
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[7] = "";
struct packet_irp_hcievent_data *PPacketIrpEvent;
if (!(pBtHciInfo->BTEventMaskPage2 & EMP2_HCI_EVENT_LOGICAL_LINK_COMPLETE)) {
RTPRINT(FIOCTL, IOCTL_BT_EVENT,
("[BT event], Logical Link Complete, Ignore to send this event due to event mask page 2\n"));
return;
}
RTPRINT(FIOCTL, IOCTL_BT_EVENT, ("[BT event], Logical Link Complete, PhyLinkHandle = 0x%x, LogLinkHandle = 0x%x, Status = 0x%x\n",
PhyLinkHandle, LogLinkHandle, HciStatus));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_LOGICAL_LINK_COMPLETE;
PPacketIrpEvent->Length = 5;
PPacketIrpEvent->Data[0] = HciStatus;/* status code */
/* Logical link handle */
PPacketIrpEvent->Data[1] = TWOBYTE_LOWBYTE(LogLinkHandle);
PPacketIrpEvent->Data[2] = TWOBYTE_HIGHTBYTE(LogLinkHandle);
/* Physical link handle */
PPacketIrpEvent->Data[3] = TWOBYTE_LOWBYTE(PhyLinkHandle);
/* corresponding Tx flow spec ID */
if (HciStatus == HCI_STATUS_SUCCESS) {
PPacketIrpEvent->Data[4] =
pBTInfo->BtAsocEntry[EntryNum].LogLinkCmdData[LogLinkIndex].Tx_Flow_Spec.Identifier;
} else {
PPacketIrpEvent->Data[4] = 0x0;
}
bthci_IndicateEvent(padapter, PPacketIrpEvent, 7);
}
static void
bthci_EventDisconnectLogicalLinkComplete(
struct rtw_adapter *padapter,
enum hci_status HciStatus,
u16 LogLinkHandle,
enum hci_status Reason
)
{
u8 localBuf[6] = "";
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
struct packet_irp_hcievent_data *PPacketIrpEvent;
if (!(pBtHciInfo->BTEventMaskPage2 & EMP2_HCI_EVENT_DISCONNECT_LOGICAL_LINK_COMPLETE)) {
RTPRINT(FIOCTL, IOCTL_BT_EVENT, ("[BT event], Disconnect Logical Link Complete, Ignore to send this event due to event mask page 2\n"));
return;
}
RTPRINT(FIOCTL, IOCTL_BT_EVENT, ("[BT event], Disconnect Logical Link Complete, Status = 0x%x, LLH = 0x%x Reason = 0x%x\n", HciStatus, LogLinkHandle, Reason));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_DISCONNECT_LOGICAL_LINK_COMPLETE;
PPacketIrpEvent->Length = 4;
PPacketIrpEvent->Data[0] = HciStatus;
/* Logical link handle */
PPacketIrpEvent->Data[1] = TWOBYTE_LOWBYTE(LogLinkHandle);
PPacketIrpEvent->Data[2] = TWOBYTE_HIGHTBYTE(LogLinkHandle);
/* Disconnect reason */
PPacketIrpEvent->Data[3] = Reason;
bthci_IndicateEvent(padapter, PPacketIrpEvent, 6);
}
static void
bthci_EventFlushOccurred(
struct rtw_adapter *padapter,
u16 LogLinkHandle
)
{
u8 localBuf[4] = "";
struct packet_irp_hcievent_data *PPacketIrpEvent;
RTPRINT(FIOCTL, IOCTL_BT_EVENT, ("bthci_EventFlushOccurred(), LLH = 0x%x\n", LogLinkHandle));
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
PPacketIrpEvent->EventCode = HCI_EVENT_FLUSH_OCCRUED;
PPacketIrpEvent->Length = 2;
/* Logical link handle */
PPacketIrpEvent->Data[0] = TWOBYTE_LOWBYTE(LogLinkHandle);
PPacketIrpEvent->Data[1] = TWOBYTE_HIGHTBYTE(LogLinkHandle);
bthci_IndicateEvent(padapter, PPacketIrpEvent, 4);
}
static enum hci_status
bthci_BuildPhysicalLink(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd,
u16 OCF
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt;
u8 EntryNum, PLH;
/* Send HCI Command status event to AMP. */
bthci_EventCommandStatus(padapter,
LINK_CONTROL_COMMANDS,
OCF,
HCI_STATUS_SUCCESS);
PLH = *((u8 *)pHciCmd->Data);
/* Check if resource or bt connection is under progress, if yes, reject the link creation. */
if (!bthci_AddEntry(padapter)) {
status = HCI_STATUS_CONNECT_RJT_LIMIT_RESOURCE;
bthci_EventPhysicalLinkComplete(padapter, status, INVALID_ENTRY_NUM, PLH);
return status;
}
EntryNum = pBtMgnt->CurrentConnectEntryNum;
pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle = PLH;
pBtMgnt->BtCurrentPhyLinkhandle = PLH;
if (pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.AMPAssocfragment == NULL) {
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Create/Accept PhysicalLink, AMP controller is busy\n"));
status = HCI_STATUS_CONTROLLER_BUSY;
bthci_EventPhysicalLinkComplete(padapter, status, INVALID_ENTRY_NUM, PLH);
return status;
}
/* Record Key and the info */
pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKeyLen = (*((u8 *)pHciCmd->Data+1));
pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKeyType = (*((u8 *)pHciCmd->Data+2));
memcpy(pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKey,
(((u8 *)pHciCmd->Data+3)), pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKeyLen);
memcpy(pBTInfo->BtAsocEntry[EntryNum].PMK, pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKey, PMK_LEN);
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("BuildPhysicalLink, EntryNum = %d, PLH = 0x%x KeyLen = 0x%x, KeyType = 0x%x\n",
EntryNum, pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle,
pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKeyLen,
pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKeyType));
RTPRINT_DATA(FIOCTL, (IOCTL_BT_LOGO|IOCTL_BT_HCICMD), ("BtAMPKey\n"), pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKey,
pBTInfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtAMPKeyLen);
RTPRINT_DATA(FIOCTL, (IOCTL_BT_LOGO|IOCTL_BT_HCICMD), ("PMK\n"), pBTInfo->BtAsocEntry[EntryNum].PMK,
PMK_LEN);
if (OCF == HCI_CREATE_PHYSICAL_LINK) {
/* These macros require braces */
BTHCI_SM_WITH_INFO(padapter, HCI_STATE_DISCONNECTED, STATE_CMD_CREATE_PHY_LINK, EntryNum);
} else if (OCF == HCI_ACCEPT_PHYSICAL_LINK) {
BTHCI_SM_WITH_INFO(padapter, HCI_STATE_DISCONNECTED, STATE_CMD_ACCEPT_PHY_LINK, EntryNum);
}
return status;
}
static void
bthci_BuildLogicalLink(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd,
u16 OCF
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTinfo = GET_BT_INFO(padapter);
struct bt_mgnt *pBtMgnt = &pBTinfo->BtMgnt;
u8 PhyLinkHandle, EntryNum;
static u16 AssignLogHandle = 1;
struct hci_flow_spec TxFlowSpec;
struct hci_flow_spec RxFlowSpec;
u32 MaxSDUSize, ArriveTime, Bandwidth;
PhyLinkHandle = *((u8 *)pHciCmd->Data);
EntryNum = bthci_GetCurrentEntryNum(padapter, PhyLinkHandle);
memcpy(&TxFlowSpec,
&pHciCmd->Data[1], sizeof(struct hci_flow_spec));
memcpy(&RxFlowSpec,
&pHciCmd->Data[17], sizeof(struct hci_flow_spec));
MaxSDUSize = TxFlowSpec.MaximumSDUSize;
ArriveTime = TxFlowSpec.SDUInterArrivalTime;
if (bthci_CheckLogLinkBehavior(padapter, TxFlowSpec) && bthci_CheckLogLinkBehavior(padapter, RxFlowSpec))
Bandwidth = BTTOTALBANDWIDTH;
else if (MaxSDUSize == 0xffff && ArriveTime == 0xffffffff)
Bandwidth = BTTOTALBANDWIDTH;
else
Bandwidth = MaxSDUSize*8*1000/(ArriveTime+244);
RTPRINT(FIOCTL, IOCTL_BT_HCICMD,
("BuildLogicalLink, PhyLinkHandle = 0x%x, MaximumSDUSize = 0x%x, SDUInterArrivalTime = 0x%x, Bandwidth = 0x%x\n",
PhyLinkHandle, MaxSDUSize, ArriveTime, Bandwidth));
if (EntryNum == 0xff) {
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("Invalid Physical Link handle = 0x%x, status = HCI_STATUS_UNKNOW_CONNECT_ID, return\n", PhyLinkHandle));
status = HCI_STATUS_UNKNOW_CONNECT_ID;
/* When we receive Create/Accept logical link command, we should send command status event first. */
bthci_EventCommandStatus(padapter,
LINK_CONTROL_COMMANDS,
OCF,
status);
return;
}
if (!pBtMgnt->bLogLinkInProgress) {
if (bthci_PhyLinkConnectionInProgress(padapter, PhyLinkHandle)) {
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("Physical link connection in progress, status = HCI_STATUS_CMD_DISALLOW, return\n"));
status = HCI_STATUS_CMD_DISALLOW;
pBtMgnt->bPhyLinkInProgressStartLL = true;
/* When we receive Create/Accept logical link command, we should send command status event first. */
bthci_EventCommandStatus(padapter,
LINK_CONTROL_COMMANDS,
OCF,
status);
return;
}
if (Bandwidth > BTTOTALBANDWIDTH) {
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("status = HCI_STATUS_QOS_REJECT, Bandwidth = 0x%x, return\n", Bandwidth));
status = HCI_STATUS_QOS_REJECT;
/* When we receive Create/Accept logical link command, we should send command status event first. */
bthci_EventCommandStatus(padapter,
LINK_CONTROL_COMMANDS,
OCF,
status);
} else {
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("status = HCI_STATUS_SUCCESS\n"));
status = HCI_STATUS_SUCCESS;
/* When we receive Create/Accept logical link command, we should send command status event first. */
bthci_EventCommandStatus(padapter,
LINK_CONTROL_COMMANDS,
OCF,
status);
}
if (pBTinfo->BtAsocEntry[EntryNum].BtCurrentState != HCI_STATE_CONNECTED) {
bthci_EventLogicalLinkComplete(padapter,
HCI_STATUS_CMD_DISALLOW, 0, 0, 0, EntryNum);
} else {
u8 i, find = 0;
pBtMgnt->bLogLinkInProgress = true;
/* find an unused logical link index and copy the data */
for (i = 0; i < MAX_LOGICAL_LINK_NUM; i++) {
if (pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].BtLogLinkhandle == 0) {
enum hci_status LogCompEventstatus = HCI_STATUS_SUCCESS;
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].BtPhyLinkhandle = *((u8 *)pHciCmd->Data);
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].BtLogLinkhandle = AssignLogHandle;
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("BuildLogicalLink, EntryNum = %d, physical link handle = 0x%x, logical link handle = 0x%x\n",
EntryNum, pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle,
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].BtLogLinkhandle));
memcpy(&pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].Tx_Flow_Spec,
&TxFlowSpec, sizeof(struct hci_flow_spec));
memcpy(&pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].Rx_Flow_Spec,
&RxFlowSpec, sizeof(struct hci_flow_spec));
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].bLLCompleteEventIsSet = false;
if (pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].bLLCancelCMDIsSetandComplete)
LogCompEventstatus = HCI_STATUS_UNKNOW_CONNECT_ID;
bthci_EventLogicalLinkComplete(padapter,
LogCompEventstatus,
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].BtPhyLinkhandle,
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].BtLogLinkhandle, i, EntryNum);
pBTinfo->BtAsocEntry[EntryNum].LogLinkCmdData[i].bLLCompleteEventIsSet = true;
find = 1;
pBtMgnt->BtCurrentLogLinkhandle = AssignLogHandle;
AssignLogHandle++;
break;
}
}
if (!find) {
bthci_EventLogicalLinkComplete(padapter,
HCI_STATUS_CONNECT_RJT_LIMIT_RESOURCE, 0, 0, 0, EntryNum);
}
pBtMgnt->bLogLinkInProgress = false;
}
} else {
bthci_EventLogicalLinkComplete(padapter,
HCI_STATUS_CONTROLLER_BUSY, 0, 0, 0, EntryNum);
}
}
static void
bthci_StartBeaconAndConnect(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd,
u8 CurrentAssocNum
)
{
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt;
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("StartBeaconAndConnect, CurrentAssocNum =%d, AMPRole =%d\n",
CurrentAssocNum,
pBTInfo->BtAsocEntry[CurrentAssocNum].AMPRole));
if (!pBtMgnt->CheckChnlIsSuit) {
bthci_EventPhysicalLinkComplete(padapter, HCI_STATUS_CONNECT_REJ_NOT_SUIT_CHNL_FOUND, CurrentAssocNum, INVALID_PL_HANDLE);
bthci_RemoveEntryByEntryNum(padapter, CurrentAssocNum);
return;
}
if (pBTInfo->BtAsocEntry[CurrentAssocNum].AMPRole == AMP_BTAP_CREATOR) {
snprintf((char *)pBTInfo->BtAsocEntry[CurrentAssocNum].BTSsidBuf, 32, "AMP-%02x-%02x-%02x-%02x-%02x-%02x",
padapter->eeprompriv.mac_addr[0],
padapter->eeprompriv.mac_addr[1],
padapter->eeprompriv.mac_addr[2],
padapter->eeprompriv.mac_addr[3],
padapter->eeprompriv.mac_addr[4],
padapter->eeprompriv.mac_addr[5]);
} else if (pBTInfo->BtAsocEntry[CurrentAssocNum].AMPRole == AMP_BTAP_JOINER) {
snprintf((char *)pBTInfo->BtAsocEntry[CurrentAssocNum].BTSsidBuf, 32, "AMP-%02x-%02x-%02x-%02x-%02x-%02x",
pBTInfo->BtAsocEntry[CurrentAssocNum].BTRemoteMACAddr[0],
pBTInfo->BtAsocEntry[CurrentAssocNum].BTRemoteMACAddr[1],
pBTInfo->BtAsocEntry[CurrentAssocNum].BTRemoteMACAddr[2],
pBTInfo->BtAsocEntry[CurrentAssocNum].BTRemoteMACAddr[3],
pBTInfo->BtAsocEntry[CurrentAssocNum].BTRemoteMACAddr[4],
pBTInfo->BtAsocEntry[CurrentAssocNum].BTRemoteMACAddr[5]);
}
FillOctetString(pBTInfo->BtAsocEntry[CurrentAssocNum].BTSsid, pBTInfo->BtAsocEntry[CurrentAssocNum].BTSsidBuf, 21);
pBTInfo->BtAsocEntry[CurrentAssocNum].BTSsid.Length = 21;
/* To avoid set the start ap or connect twice, or the original connection will be disconnected. */
if (!pBtMgnt->bBTConnectInProgress) {
pBtMgnt->bBTConnectInProgress = true;
RTPRINT(FIOCTL, IOCTL_STATE, ("[BT Flag], BT Connect in progress ON!!\n"));
BTHCI_SM_WITH_INFO(padapter, HCI_STATE_STARTING, STATE_CMD_MAC_START_COMPLETE, CurrentAssocNum);
/* 20100325 Joseph: Check RF ON/OFF. */
/* If RF OFF, it reschedule connecting operation after 50ms. */
if (!bthci_CheckRfStateBeforeConnect(padapter))
return;
if (pBTInfo->BtAsocEntry[CurrentAssocNum].AMPRole == AMP_BTAP_CREATOR) {
/* These macros need braces */
BTHCI_SM_WITH_INFO(padapter, HCI_STATE_CONNECTING, STATE_CMD_MAC_CONNECT_COMPLETE, CurrentAssocNum);
} else if (pBTInfo->BtAsocEntry[CurrentAssocNum].AMPRole == AMP_BTAP_JOINER) {
bthci_ResponderStartToScan(padapter);
}
}
RT_PRINT_STR(_module_rtl871x_mlme_c_, _drv_notice_,
"StartBeaconAndConnect, SSID:\n",
pBTInfo->BtAsocEntry[pBtMgnt->CurrentConnectEntryNum].BTSsid.Octet,
pBTInfo->BtAsocEntry[pBtMgnt->CurrentConnectEntryNum].BTSsid.Length);
}
static void bthci_ResetBtMgnt(struct bt_mgnt *pBtMgnt)
{
pBtMgnt->BtOperationOn = false;
pBtMgnt->bBTConnectInProgress = false;
pBtMgnt->bLogLinkInProgress = false;
pBtMgnt->bPhyLinkInProgress = false;
pBtMgnt->bPhyLinkInProgressStartLL = false;
pBtMgnt->DisconnectEntryNum = 0xff;
pBtMgnt->bStartSendSupervisionPkt = false;
pBtMgnt->JoinerNeedSendAuth = false;
pBtMgnt->CurrentBTConnectionCnt = 0;
pBtMgnt->BTCurrentConnectType = BT_DISCONNECT;
pBtMgnt->BTReceiveConnectPkt = BT_DISCONNECT;
pBtMgnt->BTAuthCount = 0;
pBtMgnt->btLogoTest = 0;
}
static void bthci_ResetBtHciInfo(struct bt_hci_info *pBtHciInfo)
{
pBtHciInfo->BTEventMask = 0;
pBtHciInfo->BTEventMaskPage2 = 0;
pBtHciInfo->ConnAcceptTimeout = 10000;
pBtHciInfo->PageTimeout = 0x30;
pBtHciInfo->LocationDomainAware = 0x0;
pBtHciInfo->LocationDomain = 0x5858;
pBtHciInfo->LocationDomainOptions = 0x58;
pBtHciInfo->LocationOptions = 0x0;
pBtHciInfo->FlowControlMode = 0x1; /* 0:Packet based data flow control mode(BR/EDR), 1: Data block based data flow control mode(AMP). */
pBtHciInfo->enFlush_LLH = 0;
pBtHciInfo->FLTO_LLH = 0;
/* Test command only */
pBtHciInfo->bTestIsEnd = true;
pBtHciInfo->bInTestMode = false;
pBtHciInfo->bTestNeedReport = false;
pBtHciInfo->TestScenario = 0xff;
pBtHciInfo->TestReportInterval = 0x01;
pBtHciInfo->TestCtrType = 0x5d;
pBtHciInfo->TestEventType = 0x00;
pBtHciInfo->TestNumOfFrame = 0;
pBtHciInfo->TestNumOfErrFrame = 0;
pBtHciInfo->TestNumOfBits = 0;
pBtHciInfo->TestNumOfErrBits = 0;
}
static void bthci_ResetBtSec(struct rtw_adapter *padapter, struct bt_security *pBtSec)
{
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
/* Set BT used HW or SW encrypt !! */
if (GET_HAL_DATA(padapter)->bBTMode)
pBtSec->bUsedHwEncrypt = true;
else
pBtSec->bUsedHwEncrypt = false;
RT_TRACE(_module_rtl871x_security_c_, _drv_info_,
"%s: bUsedHwEncrypt =%d\n", __func__, pBtSec->bUsedHwEncrypt);
pBtSec->RSNIE.Octet = pBtSec->RSNIEBuf;
}
static void bthci_ResetBtExtInfo(struct bt_mgnt *pBtMgnt)
{
u8 i;
for (i = 0; i < MAX_BT_ASOC_ENTRY_NUM; i++) {
pBtMgnt->ExtConfig.linkInfo[i].ConnectHandle = 0;
pBtMgnt->ExtConfig.linkInfo[i].IncomingTrafficMode = 0;
pBtMgnt->ExtConfig.linkInfo[i].OutgoingTrafficMode = 0;
pBtMgnt->ExtConfig.linkInfo[i].BTProfile = BT_PROFILE_NONE;
pBtMgnt->ExtConfig.linkInfo[i].BTCoreSpec = BT_SPEC_2_1_EDR;
pBtMgnt->ExtConfig.linkInfo[i].BT_RSSI = 0;
pBtMgnt->ExtConfig.linkInfo[i].TrafficProfile = BT_PROFILE_NONE;
pBtMgnt->ExtConfig.linkInfo[i].linkRole = BT_LINK_MASTER;
}
pBtMgnt->ExtConfig.CurrentConnectHandle = 0;
pBtMgnt->ExtConfig.CurrentIncomingTrafficMode = 0;
pBtMgnt->ExtConfig.CurrentOutgoingTrafficMode = 0;
pBtMgnt->ExtConfig.MIN_BT_RSSI = 0;
pBtMgnt->ExtConfig.NumberOfHandle = 0;
pBtMgnt->ExtConfig.NumberOfSCO = 0;
pBtMgnt->ExtConfig.CurrentBTStatus = 0;
pBtMgnt->ExtConfig.HCIExtensionVer = 0;
pBtMgnt->ExtConfig.bManualControl = false;
pBtMgnt->ExtConfig.bBTBusy = false;
pBtMgnt->ExtConfig.bBTA2DPBusy = false;
}
static enum hci_status bthci_CmdReset(struct rtw_adapter *_padapter, u8 bNeedSendEvent)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct rtw_adapter *padapter;
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
struct bt_30info *pBTInfo;
struct bt_mgnt *pBtMgnt;
struct bt_hci_info *pBtHciInfo;
struct bt_security *pBtSec;
struct bt_dgb *pBtDbg;
u8 i;
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("bthci_CmdReset()\n"));
padapter = GetDefaultAdapter(_padapter);
pBTInfo = GET_BT_INFO(padapter);
pBtMgnt = &pBTInfo->BtMgnt;
pBtHciInfo = &pBTInfo->BtHciInfo;
pBtSec = &pBTInfo->BtSec;
pBtDbg = &pBTInfo->BtDbg;
pBTInfo->padapter = padapter;
for (i = 0; i < MAX_BT_ASOC_ENTRY_NUM; i++)
bthci_ResetEntry(padapter, i);
bthci_ResetBtMgnt(pBtMgnt);
bthci_ResetBtHciInfo(pBtHciInfo);
bthci_ResetBtSec(padapter, pBtSec);
pBtMgnt->BTChannel = BT_Default_Chnl;
pBtMgnt->CheckChnlIsSuit = true;
pBTInfo->BTBeaconTmrOn = false;
pBtMgnt->bCreateSpportQos = true;
del_timer_sync(&pBTInfo->BTHCIDiscardAclDataTimer);
del_timer_sync(&pBTInfo->BTBeaconTimer);
HALBT_SetRtsCtsNoLenLimit(padapter);
/* */
/* Maybe we need to take care Group != AES case !! */
/* now we Pairwise and Group all used AES !! */
bthci_ResetBtExtInfo(pBtMgnt);
/* send command complete event here when all data are received. */
if (bNeedSendEvent) {
u8 localBuf[6] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_RESET,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
len += 1;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
}
return status;
}
static enum hci_status
bthci_CmdWriteRemoteAMPAssoc(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_dgb *pBtDbg = &pBTInfo->BtDbg;
u8 CurrentAssocNum;
u8 PhyLinkHandle;
pBtDbg->dbgHciInfo.hciCmdCntWriteRemoteAmpAssoc++;
PhyLinkHandle = *((u8 *)pHciCmd->Data);
CurrentAssocNum = bthci_GetCurrentEntryNum(padapter, PhyLinkHandle);
if (CurrentAssocNum == 0xff) {
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("WriteRemoteAMPAssoc, No such Handle in the Entry\n"));
status = HCI_STATUS_UNKNOW_CONNECT_ID;
bthci_EventWriteRemoteAmpAssoc(padapter, status, PhyLinkHandle);
return status;
}
if (pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.AMPAssocfragment == NULL) {
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("WriteRemoteAMPAssoc, AMP controller is busy\n"));
status = HCI_STATUS_CONTROLLER_BUSY;
bthci_EventWriteRemoteAmpAssoc(padapter, status, PhyLinkHandle);
return status;
}
pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.BtPhyLinkhandle = PhyLinkHandle;/* u8 *)pHciCmd->Data); */
pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.LenSoFar = *((u16 *)((u8 *)pHciCmd->Data+1));
pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.AMPAssocRemLen = *((u16 *)((u8 *)pHciCmd->Data+3));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("WriteRemoteAMPAssoc, LenSoFar = 0x%x, AssocRemLen = 0x%x\n",
pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.LenSoFar,
pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.AMPAssocRemLen));
RTPRINT_DATA(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO),
("WriteRemoteAMPAssoc fragment \n"),
pHciCmd->Data,
pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.AMPAssocRemLen+5);
if ((pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.AMPAssocRemLen) > MAX_AMP_ASSOC_FRAG_LEN) {
memcpy(((u8 *)pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.AMPAssocfragment+(pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.LenSoFar*(sizeof(u8)))),
(u8 *)pHciCmd->Data+5,
MAX_AMP_ASSOC_FRAG_LEN);
} else {
memcpy((u8 *)(pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.AMPAssocfragment)+(pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.LenSoFar*(sizeof(u8))),
((u8 *)pHciCmd->Data+5),
(pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.AMPAssocRemLen));
RTPRINT_DATA(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), "WriteRemoteAMPAssoc :\n",
pHciCmd->Data+5, pBTInfo->BtAsocEntry[CurrentAssocNum].AmpAsocCmdData.AMPAssocRemLen);
if (!bthci_GetAssocInfo(padapter, CurrentAssocNum))
status = HCI_STATUS_INVALID_HCI_CMD_PARA_VALUE;
bthci_EventWriteRemoteAmpAssoc(padapter, status, PhyLinkHandle);
bthci_StartBeaconAndConnect(padapter, pHciCmd, CurrentAssocNum);
}
return status;
}
/* 7.3.13 */
static enum hci_status bthci_CmdReadConnectionAcceptTimeout(struct rtw_adapter *padapter)
{
enum hci_status status = HCI_STATUS_SUCCESS;
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[8] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u16 *pu2Temp;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_READ_CONNECTION_ACCEPT_TIMEOUT,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
pu2Temp = (u16 *)&pRetPar[1]; /* Conn_Accept_Timeout */
*pu2Temp = pBtHciInfo->ConnAcceptTimeout;
len += 3;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
/* 7.3.14 */
static enum hci_status
bthci_CmdWriteConnectionAcceptTimeout(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u16 *pu2Temp;
u8 localBuf[6] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
pu2Temp = (u16 *)&pHciCmd->Data[0];
pBtHciInfo->ConnAcceptTimeout = *pu2Temp;
RTPRINT(FIOCTL, IOCTL_BT_HCICMD_DETAIL, ("ConnAcceptTimeout = 0x%x",
pBtHciInfo->ConnAcceptTimeout));
/* send command complete event here when all data are received. */
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
len += 1;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdReadPageTimeout(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[8] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u16 *pu2Temp;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_READ_PAGE_TIMEOUT,
status);
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("Read PageTimeout = 0x%x\n", pBtHciInfo->PageTimeout));
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
pu2Temp = (u16 *)&pRetPar[1]; /* Page_Timeout */
*pu2Temp = pBtHciInfo->PageTimeout;
len += 3;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdWritePageTimeout(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u16 *pu2Temp;
pu2Temp = (u16 *)&pHciCmd->Data[0];
pBtHciInfo->PageTimeout = *pu2Temp;
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("Write PageTimeout = 0x%x\n",
pBtHciInfo->PageTimeout));
/* send command complete event here when all data are received. */
{
u8 localBuf[6] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_WRITE_PAGE_TIMEOUT,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
len += 1;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
}
return status;
}
static enum hci_status
bthci_CmdReadLinkSupervisionTimeout(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTinfo = GET_BT_INFO(padapter);
u8 physicalLinkHandle, EntryNum;
physicalLinkHandle = *((u8 *)pHciCmd->Data);
EntryNum = bthci_GetCurrentEntryNum(padapter, physicalLinkHandle);
if (EntryNum == 0xff) {
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("ReadLinkSupervisionTimeout, No such Handle in the Entry\n"));
status = HCI_STATUS_UNKNOW_CONNECT_ID;
return status;
}
if (pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle != physicalLinkHandle)
status = HCI_STATUS_UNKNOW_CONNECT_ID;
{
u8 localBuf[10] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u16 *pu2Temp;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_READ_LINK_SUPERVISION_TIMEOUT,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status;
pRetPar[1] = pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle;
pRetPar[2] = 0;
pu2Temp = (u16 *)&pRetPar[3]; /* Conn_Accept_Timeout */
*pu2Temp = pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.LinkSuperversionTimeout;
len += 5;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
}
return status;
}
static enum hci_status
bthci_CmdWriteLinkSupervisionTimeout(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTinfo = GET_BT_INFO(padapter);
u8 physicalLinkHandle, EntryNum;
physicalLinkHandle = *((u8 *)pHciCmd->Data);
EntryNum = bthci_GetCurrentEntryNum(padapter, physicalLinkHandle);
if (EntryNum == 0xff) {
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("WriteLinkSupervisionTimeout, No such Handle in the Entry\n"));
status = HCI_STATUS_UNKNOW_CONNECT_ID;
} else {
if (pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle != physicalLinkHandle) {
status = HCI_STATUS_UNKNOW_CONNECT_ID;
} else {
pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.LinkSuperversionTimeout = *((u16 *)(((u8 *)pHciCmd->Data)+2));
RTPRINT(FIOCTL, IOCTL_STATE, ("BT Write LinkSuperversionTimeout[%d] = 0x%x\n",
EntryNum, pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.LinkSuperversionTimeout));
}
}
{
u8 localBuf[8] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_WRITE_LINK_SUPERVISION_TIMEOUT,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status;
pRetPar[1] = pBTinfo->BtAsocEntry[EntryNum].PhyLinkCmdData.BtPhyLinkhandle;
pRetPar[2] = 0;
len += 3;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
}
return status;
}
static enum hci_status
bthci_CmdEnhancedFlush(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTinfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTinfo->BtHciInfo;
u16 logicHandle;
u8 Packet_Type;
logicHandle = *((u16 *)&pHciCmd->Data[0]);
Packet_Type = pHciCmd->Data[2];
if (Packet_Type != 0)
status = HCI_STATUS_INVALID_HCI_CMD_PARA_VALUE;
else
pBtHciInfo->enFlush_LLH = logicHandle;
if (bthci_DiscardTxPackets(padapter, pBtHciInfo->enFlush_LLH))
bthci_EventFlushOccurred(padapter, pBtHciInfo->enFlush_LLH);
/* should send command status event */
bthci_EventCommandStatus(padapter,
OGF_SET_EVENT_MASK_COMMAND,
HCI_ENHANCED_FLUSH,
status);
if (pBtHciInfo->enFlush_LLH) {
bthci_EventEnhancedFlushComplete(padapter, pBtHciInfo->enFlush_LLH);
pBtHciInfo->enFlush_LLH = 0;
}
return status;
}
static enum hci_status
bthci_CmdReadLogicalLinkAcceptTimeout(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[8] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u16 *pu2Temp;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status;
pu2Temp = (u16 *)&pRetPar[1]; /* Conn_Accept_Timeout */
*pu2Temp = pBtHciInfo->LogicalAcceptTimeout;
len += 3;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdWriteLogicalLinkAcceptTimeout(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[6] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
pBtHciInfo->LogicalAcceptTimeout = *((u16 *)pHciCmd->Data);
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status;
len += 1;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdSetEventMask(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 *pu8Temp;
u8 localBuf[6] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
pu8Temp = (u8 *)&pHciCmd->Data[0];
pBtHciInfo->BTEventMask = *pu8Temp;
RTPRINT(FIOCTL, IOCTL_BT_HCICMD_DETAIL, ("BTEventMask = 0x%"i64fmt"x\n",
pBtHciInfo->BTEventMask));
/* send command complete event here when all data are received. */
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_SET_EVENT_MASK,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
len += 1;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
/* 7.3.69 */
static enum hci_status
bthci_CmdSetEventMaskPage2(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 *pu8Temp;
u8 localBuf[6] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
pu8Temp = (u8 *)&pHciCmd->Data[0];
pBtHciInfo->BTEventMaskPage2 = *pu8Temp;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("BTEventMaskPage2 = 0x%"i64fmt"x\n",
pBtHciInfo->BTEventMaskPage2));
/* send command complete event here when all data are received. */
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_SET_EVENT_MASK_PAGE_2,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
len += 1;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdReadLocationData(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[12] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u16 *pu2Temp;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_READ_LOCATION_DATA,
status);
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("DomainAware = 0x%x\n", pBtHciInfo->LocationDomainAware));
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("Domain = 0x%x\n", pBtHciInfo->LocationDomain));
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("DomainOptions = 0x%x\n", pBtHciInfo->LocationDomainOptions));
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("Options = 0x%x\n", pBtHciInfo->LocationOptions));
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status;
pRetPar[1] = pBtHciInfo->LocationDomainAware; /* 0x0; Location_Domain_Aware */
pu2Temp = (u16 *)&pRetPar[2]; /* Location_Domain */
*pu2Temp = pBtHciInfo->LocationDomain; /* 0x5858; */
pRetPar[4] = pBtHciInfo->LocationDomainOptions; /* 0x58; Location_Domain_Options */
pRetPar[5] = pBtHciInfo->LocationOptions; /* 0x0; Location_Options */
len += 6;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdWriteLocationData(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u16 *pu2Temp;
u8 localBuf[6] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
pBtHciInfo->LocationDomainAware = pHciCmd->Data[0];
pu2Temp = (u16 *)&pHciCmd->Data[1];
pBtHciInfo->LocationDomain = *pu2Temp;
pBtHciInfo->LocationDomainOptions = pHciCmd->Data[3];
pBtHciInfo->LocationOptions = pHciCmd->Data[4];
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("DomainAware = 0x%x\n", pBtHciInfo->LocationDomainAware));
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("Domain = 0x%x\n", pBtHciInfo->LocationDomain));
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("DomainOptions = 0x%x\n", pBtHciInfo->LocationDomainOptions));
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("Options = 0x%x\n", pBtHciInfo->LocationOptions));
/* send command complete event here when all data are received. */
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_WRITE_LOCATION_DATA,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
len += 1;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdReadFlowControlMode(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[7] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_READ_FLOW_CONTROL_MODE,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status;
pRetPar[1] = pBtHciInfo->FlowControlMode; /* Flow Control Mode */
len += 2;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdWriteFlowControlMode(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[6] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
pBtHciInfo->FlowControlMode = pHciCmd->Data[0];
/* send command complete event here when all data are received. */
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_WRITE_FLOW_CONTROL_MODE,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
len += 1;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdReadBestEffortFlushTimeout(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTinfo = GET_BT_INFO(padapter);
u16 i, j, logicHandle;
u32 BestEffortFlushTimeout = 0xffffffff;
u8 find = 0;
logicHandle = *((u16 *)pHciCmd->Data);
/* find an matched logical link index and copy the data */
for (j = 0; j < MAX_BT_ASOC_ENTRY_NUM; j++) {
for (i = 0; i < MAX_LOGICAL_LINK_NUM; i++) {
if (pBTinfo->BtAsocEntry[j].LogLinkCmdData[i].BtLogLinkhandle == logicHandle) {
BestEffortFlushTimeout = pBTinfo->BtAsocEntry[j].LogLinkCmdData[i].BestEffortFlushTimeout;
find = 1;
break;
}
}
}
if (!find)
status = HCI_STATUS_UNKNOW_CONNECT_ID;
{
u8 localBuf[10] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u32 *pu4Temp;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_READ_BEST_EFFORT_FLUSH_TIMEOUT,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status;
pu4Temp = (u32 *)&pRetPar[1]; /* Best_Effort_Flush_Timeout */
*pu4Temp = BestEffortFlushTimeout;
len += 5;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
}
return status;
}
static enum hci_status
bthci_CmdWriteBestEffortFlushTimeout(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTinfo = GET_BT_INFO(padapter);
u16 i, j, logicHandle;
u32 BestEffortFlushTimeout = 0xffffffff;
u8 find = 0;
logicHandle = *((u16 *)pHciCmd->Data);
BestEffortFlushTimeout = *((u32 *)(pHciCmd->Data+1));
/* find an matched logical link index and copy the data */
for (j = 0; j < MAX_BT_ASOC_ENTRY_NUM; j++) {
for (i = 0; i < MAX_LOGICAL_LINK_NUM; i++) {
if (pBTinfo->BtAsocEntry[j].LogLinkCmdData[i].BtLogLinkhandle == logicHandle) {
pBTinfo->BtAsocEntry[j].LogLinkCmdData[i].BestEffortFlushTimeout = BestEffortFlushTimeout;
find = 1;
break;
}
}
}
if (!find)
status = HCI_STATUS_UNKNOW_CONNECT_ID;
{
u8 localBuf[6] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_SET_EVENT_MASK_COMMAND,
HCI_WRITE_BEST_EFFORT_FLUSH_TIMEOUT,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status;
len += 1;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
}
return status;
}
static enum hci_status
bthci_CmdShortRangeMode(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
u8 PhyLinkHandle, EntryNum, ShortRangeMode;
PhyLinkHandle = pHciCmd->Data[0];
ShortRangeMode = pHciCmd->Data[1];
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("PLH = 0x%x, Short_Range_Mode = 0x%x\n", PhyLinkHandle, ShortRangeMode));
EntryNum = bthci_GetCurrentEntryNum(padapter, PhyLinkHandle);
if (EntryNum != 0xff) {
pBTInfo->BtAsocEntry[EntryNum].ShortRangeMode = ShortRangeMode;
} else {
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("No such PLH(0x%x)\n", PhyLinkHandle));
status = HCI_STATUS_UNKNOW_CONNECT_ID;
}
bthci_EventCommandStatus(padapter,
OGF_SET_EVENT_MASK_COMMAND,
HCI_SHORT_RANGE_MODE,
status);
bthci_EventShortRangeModeChangeComplete(padapter, status, ShortRangeMode, EntryNum);
return status;
}
static enum hci_status bthci_CmdReadLocalSupportedCommands(struct rtw_adapter *padapter)
{
enum hci_status status = HCI_STATUS_SUCCESS;
u8 localBuf[TmpLocalBufSize] = "";
u8 *pRetPar, *pSupportedCmds;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
/* send command complete event here when all data are received. */
PlatformZeroMemory(&localBuf[0], TmpLocalBufSize);
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_INFORMATIONAL_PARAMETERS,
HCI_READ_LOCAL_SUPPORTED_COMMANDS,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
len += 1;
pSupportedCmds = &pRetPar[1];
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[5]= 0xc0\nBit [6]= Set Event Mask, [7]= Reset\n"));
pSupportedCmds[5] = 0xc0;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[6]= 0x01\nBit [0]= Set Event Filter\n"));
pSupportedCmds[6] = 0x01;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[7]= 0x0c\nBit [2]= Read Connection Accept Timeout, [3]= Write Connection Accept Timeout\n"));
pSupportedCmds[7] = 0x0c;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[10]= 0x80\nBit [7]= Host Number Of Completed Packets\n"));
pSupportedCmds[10] = 0x80;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[11]= 0x03\nBit [0]= Read Link Supervision Timeout, [1]= Write Link Supervision Timeout\n"));
pSupportedCmds[11] = 0x03;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[14]= 0xa8\nBit [3]= Read Local Version Information, [5]= Read Local Supported Features, [7]= Read Buffer Size\n"));
pSupportedCmds[14] = 0xa8;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[15]= 0x1c\nBit [2]= Read Failed Contact Count, [3]= Reset Failed Contact Count, [4]= Get Link Quality\n"));
pSupportedCmds[15] = 0x1c;
/* pSupportedCmds[16] = 0x04; */
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[19]= 0x40\nBit [6]= Enhanced Flush\n"));
pSupportedCmds[19] = 0x40;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[21]= 0xff\nBit [0]= Create Physical Link, [1]= Accept Physical Link, [2]= Disconnect Physical Link, [3]= Create Logical Link\n"));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), (" [4]= Accept Logical Link, [5]= Disconnect Logical Link, [6]= Logical Link Cancel, [7]= Flow Spec Modify\n"));
pSupportedCmds[21] = 0xff;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[22]= 0xff\nBit [0]= Read Logical Link Accept Timeout, [1]= Write Logical Link Accept Timeout, [2]= Set Event Mask Page 2, [3]= Read Location Data\n"));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), (" [4]= Write Location Data, [5]= Read Local AMP Info, [6]= Read Local AMP_ASSOC, [7]= Write Remote AMP_ASSOC\n"));
pSupportedCmds[22] = 0xff;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[23]= 0x07\nBit [0]= Read Flow Control Mode, [1]= Write Flow Control Mode, [2]= Read Data Block Size\n"));
pSupportedCmds[23] = 0x07;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD|IOCTL_BT_LOGO), ("Octet[24]= 0x1c\nBit [2]= Read Best Effort Flush Timeout, [3]= Write Best Effort Flush Timeout, [4]= Short Range Mode\n"));
pSupportedCmds[24] = 0x1c;
len += 64;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status bthci_CmdReadLocalSupportedFeatures(struct rtw_adapter *padapter)
{
enum hci_status status = HCI_STATUS_SUCCESS;
u8 localBuf[TmpLocalBufSize] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
/* send command complete event here when all data are received. */
PlatformZeroMemory(&localBuf[0], TmpLocalBufSize);
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_INFORMATIONAL_PARAMETERS,
HCI_READ_LOCAL_SUPPORTED_FEATURES,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
len += 9;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status bthci_CmdReadLocalAMPAssoc(struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt;
struct bt_dgb *pBtDbg = &pBTInfo->BtDbg;
u8 PhyLinkHandle, EntryNum;
pBtDbg->dbgHciInfo.hciCmdCntReadLocalAmpAssoc++;
PhyLinkHandle = *((u8 *)pHciCmd->Data);
EntryNum = bthci_GetCurrentEntryNum(padapter, PhyLinkHandle);
if ((EntryNum == 0xff) && PhyLinkHandle != 0) {
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("ReadLocalAMPAssoc, EntryNum = %d !!!!!, physical link handle = 0x%x\n",
EntryNum, PhyLinkHandle));
status = HCI_STATUS_UNKNOW_CONNECT_ID;
} else if (pBtMgnt->bPhyLinkInProgressStartLL) {
status = HCI_STATUS_UNKNOW_CONNECT_ID;
pBtMgnt->bPhyLinkInProgressStartLL = false;
} else {
pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.BtPhyLinkhandle = *((u8 *)pHciCmd->Data);
pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.LenSoFar = *((u16 *)((u8 *)pHciCmd->Data+1));
pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.MaxRemoteASSOCLen = *((u16 *)((u8 *)pHciCmd->Data+3));
RTPRINT(FIOCTL, IOCTL_BT_HCICMD_DETAIL, ("ReadLocalAMPAssoc, LenSoFar =%d, MaxRemoteASSOCLen =%d\n",
pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.LenSoFar,
pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.MaxRemoteASSOCLen));
}
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("ReadLocalAMPAssoc, EntryNum = %d !!!!!, physical link handle = 0x%x, LengthSoFar = %x \n",
EntryNum, PhyLinkHandle, pBTInfo->BtAsocEntry[EntryNum].AmpAsocCmdData.LenSoFar));
/* send command complete event here when all data are received. */
{
struct packet_irp_hcievent_data *PPacketIrpEvent;
/* PVOID buffer = padapter->IrpHCILocalbuf.Ptr; */
u8 localBuf[TmpLocalBufSize] = "";
u16 *pRemainLen;
u32 totalLen = 0;
u16 typeLen = 0, remainLen = 0, ret_index = 0;
u8 *pRetPar;
PlatformZeroMemory(&localBuf[0], TmpLocalBufSize);
/* PPacketIrpEvent = (struct packet_irp_hcievent_data *)(buffer); */
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
totalLen += bthci_CommandCompleteHeader(&localBuf[0],
OGF_STATUS_PARAMETERS,
HCI_READ_LOCAL_AMP_ASSOC,
status);
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("ReadLocalAMPAssoc, Remaining_Len =%d \n", remainLen));
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[totalLen];
pRetPar[0] = status; /* status */
pRetPar[1] = *((u8 *)pHciCmd->Data);
pRemainLen = (u16 *)&pRetPar[2]; /* AMP_ASSOC_Remaining_Length */
totalLen += 4; /* 0]~[3] */
ret_index = 4;
typeLen = bthci_AssocMACAddr(padapter, &pRetPar[ret_index]);
totalLen += typeLen;
remainLen += typeLen;
ret_index += typeLen;
typeLen = bthci_AssocPreferredChannelList(padapter, &pRetPar[ret_index], EntryNum);
totalLen += typeLen;
remainLen += typeLen;
ret_index += typeLen;
typeLen = bthci_PALCapabilities(padapter, &pRetPar[ret_index]);
totalLen += typeLen;
remainLen += typeLen;
ret_index += typeLen;
typeLen = bthci_AssocPALVer(padapter, &pRetPar[ret_index]);
totalLen += typeLen;
remainLen += typeLen;
PPacketIrpEvent->Length = (u8)totalLen;
*pRemainLen = remainLen; /* AMP_ASSOC_Remaining_Length */
RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("ReadLocalAMPAssoc, Remaining_Len =%d \n", remainLen));
RTPRINT_DATA(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("AMP_ASSOC_fragment : \n"), PPacketIrpEvent->Data, totalLen);
bthci_IndicateEvent(padapter, PPacketIrpEvent, totalLen+2);
}
return status;
}
static enum hci_status bthci_CmdReadFailedContactCounter(struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd)
{
enum hci_status status = HCI_STATUS_SUCCESS;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u8 localBuf[TmpLocalBufSize] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u16 handle;
handle = *((u16 *)pHciCmd->Data);
/* send command complete event here when all data are received. */
PlatformZeroMemory(&localBuf[0], TmpLocalBufSize);
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_STATUS_PARAMETERS,
HCI_READ_FAILED_CONTACT_COUNTER,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
pRetPar[1] = TWOBYTE_LOWBYTE(handle);
pRetPar[2] = TWOBYTE_HIGHTBYTE(handle);
pRetPar[3] = TWOBYTE_LOWBYTE(pBtHciInfo->FailContactCount);
pRetPar[4] = TWOBYTE_HIGHTBYTE(pBtHciInfo->FailContactCount);
len += 5;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
static enum hci_status
bthci_CmdResetFailedContactCounter(
struct rtw_adapter *padapter,
struct packet_irp_hcicmd_data *pHciCmd
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
u16 handle;
u8 localBuf[TmpLocalBufSize] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
handle = *((u16 *)pHciCmd->Data);
pBtHciInfo->FailContactCount = 0;
/* send command complete event here when all data are received. */
PlatformZeroMemory(&localBuf[0], TmpLocalBufSize);
/* PPacketIrpEvent = (struct packet_irp_hcievent_data *)(buffer); */
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_STATUS_PARAMETERS,
HCI_RESET_FAILED_CONTACT_COUNTER,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
pRetPar[1] = TWOBYTE_LOWBYTE(handle);
pRetPar[2] = TWOBYTE_HIGHTBYTE(handle);
len += 3;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
/* */
/* BT 3.0+HS [Vol 2] 7.4.1 */
/* */
static enum hci_status
bthci_CmdReadLocalVersionInformation(
struct rtw_adapter *padapter
)
{
enum hci_status status = HCI_STATUS_SUCCESS;
/* send command complete event here when all data are received. */
u8 localBuf[TmpLocalBufSize] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u16 *pu2Temp;
PlatformZeroMemory(&localBuf[0], TmpLocalBufSize);
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_INFORMATIONAL_PARAMETERS,
HCI_READ_LOCAL_VERSION_INFORMATION,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = status; /* status */
pRetPar[1] = 0x05; /* HCI_Version */
pu2Temp = (u16 *)&pRetPar[2]; /* HCI_Revision */
*pu2Temp = 0x0001;
pRetPar[4] = 0x05; /* LMP/PAL_Version */
pu2Temp = (u16 *)&pRetPar[5]; /* Manufacturer_Name */
*pu2Temp = 0x005d;
pu2Temp = (u16 *)&pRetPar[7]; /* LMP/PAL_Subversion */
*pu2Temp = 0x0001;
len += 9;
PPacketIrpEvent->Length = len;
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("LOCAL_VERSION_INFORMATION\n"));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("Status %x\n", status));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("HCI_Version = 0x05\n"));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("HCI_Revision = 0x0001\n"));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("LMP/PAL_Version = 0x05\n"));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("Manufacturer_Name = 0x0001\n"));
RTPRINT(FIOCTL, (IOCTL_BT_HCICMD_DETAIL|IOCTL_BT_LOGO), ("LMP/PAL_Subversion = 0x0001\n"));
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
/* 7.4.7 */
static enum hci_status bthci_CmdReadDataBlockSize(struct rtw_adapter *padapter)
{
enum hci_status status = HCI_STATUS_SUCCESS;
u8 localBuf[TmpLocalBufSize] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u16 *pu2Temp;
PlatformZeroMemory(&localBuf[0], TmpLocalBufSize);
PPacketIrpEvent = (struct packet_irp_hcievent_data *)(&localBuf[0]);
len += bthci_CommandCompleteHeader(&localBuf[0],
OGF_INFORMATIONAL_PARAMETERS,
HCI_READ_DATA_BLOCK_SIZE,
status);
/* Return parameters starts from here */
pRetPar = &PPacketIrpEvent->Data[len];
pRetPar[0] = HCI_STATUS_SUCCESS; /* status */
pu2Temp = (u16 *)&pRetPar[1]; /* Max_ACL_Data_Packet_Length */
*pu2Temp = Max80211PALPDUSize;
pu2Temp = (u16 *)&pRetPar[3]; /* Data_Block_Length */
*pu2Temp = Max80211PALPDUSize;
pu2Temp = (u16 *)&pRetPar[5]; /* Total_Num_Data_Blocks */
*pu2Temp = BTTotalDataBlockNum;
len += 7;
PPacketIrpEvent->Length = len;
bthci_IndicateEvent(padapter, PPacketIrpEvent, len+2);
return status;
}
/* 7.4.5 */
static enum hci_status bthci_CmdReadBufferSize(struct rtw_adapter *padapter)
{
enum hci_status status = HCI_STATUS_SUCCESS;
u8 localBuf[TmpLocalBufSize] = "";
u8 *pRetPar;
u8 len = 0;
struct packet_irp_hcievent_data *PPacketIrpEvent;
u16 *pu2Temp;