diff options
author | Sai Aitharaju <saia@codeaurora.org> | 2015-06-19 09:14:00 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:22:03 -0600 |
commit | aed499437ab3e91f8be017f44dcedd4a2d5dc222 (patch) | |
tree | 6914bc0eb90d25c5dd496e705fb7dc94f01c2167 | |
parent | 08de637744f925731db794f1010e7fc3638ebd29 (diff) | |
download | android_system_bt-aed499437ab3e91f8be017f44dcedd4a2d5dc222.tar.gz android_system_bt-aed499437ab3e91f8be017f44dcedd4a2d5dc222.tar.bz2 android_system_bt-aed499437ab3e91f8be017f44dcedd4a2d5dc222.zip |
QLogKit: Enable FW Logging and Set Stack Trace Level
- Enables FW Logging during BT On and disables
the FW Logging during BT Off in userdebug
builds only.
- Provides an interface to set trace level for
all the stack layers of bluedroid.
CRs-Fixed: 866285
Change-Id: Ib12d220e0aa4845d04b05b7fbea079d30c308004
-rw-r--r-- | Android.mk | 4 | ||||
-rw-r--r-- | bta/dm/bta_dm_act.c | 6 | ||||
-rw-r--r-- | btif/src/bluetooth.c | 5 | ||||
-rw-r--r-- | btif/src/btif_stack_log.c | 63 | ||||
-rwxr-xr-x | device/src/controller.c | 6 | ||||
-rw-r--r-- | include/bt_trace.h | 1 | ||||
-rw-r--r-- | include/logging.h | 45 | ||||
-rw-r--r-- | main/Android.mk | 3 | ||||
-rw-r--r-- | main/bte_logmsg.c | 42 | ||||
-rw-r--r-- | stack/include/hcidefs.h | 2 |
10 files changed, 174 insertions, 3 deletions
diff --git a/Android.mk b/Android.mk index 3ddffce66..26c23e887 100644 --- a/Android.mk +++ b/Android.mk @@ -9,6 +9,10 @@ else bdroid_CFLAGS += -DHAS_NO_BDROID_BUILDCFG endif +ifeq ($(TARGET_BUILD_VARIANT),userdebug) +bdroid_CFLAGS += -DQLOGKIT_USERDEBUG +endif + ifneq ($(BOARD_BLUETOOTH_BDROID_HCILP_INCLUDED),) bdroid_CFLAGS += -DHCILP_INCLUDED=$(BOARD_BLUETOOTH_BDROID_HCILP_INCLUDED) endif diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c index 964d031e5..b5db01307 100644 --- a/bta/dm/bta_dm_act.c +++ b/bta/dm/bta_dm_act.c @@ -431,6 +431,12 @@ void bta_dm_disable (tBTA_DM_MSG *p_data) BTM_BleClearBgConnDev(); #endif +#ifdef QLOGKIT_USERDEBUG + /* Disable SOC Logging */ + UINT8 param[5] = {0x10,0x02,0x00,0x00,0x01}; + BTM_VendorSpecificCommand(HCI_VS_HOST_LOG_OPCODE,5,param,NULL); +#endif + if(BTM_GetNumAclLinks()==0) { #if (defined(BTA_DISABLE_DELAY) && BTA_DISABLE_DELAY > 0) diff --git a/btif/src/bluetooth.c b/btif/src/bluetooth.c index 5b1bd2ef8..e881eb4ba 100644 --- a/btif/src/bluetooth.c +++ b/btif/src/bluetooth.c @@ -67,6 +67,7 @@ #if TEST_APP_INTERFACE == TRUE #include <bt_testapp.h> #endif +#include <logging.h> /************************************************************************************ ** Constants & Macros @@ -127,6 +128,7 @@ extern const btl2cap_interface_t *btif_l2cap_get_interface(void); extern const btrfcomm_interface_t *btif_rfcomm_get_interface(void); extern const btmcap_interface_t *btif_mcap_get_interface(void); #endif +extern const btstacklog_interface_t *btif_stack_log_interface(void); /************************************************************************************ ** Functions @@ -363,6 +365,9 @@ static const void* get_profile_interface (const char *profile_id) if (is_profile(profile_id, BT_PROFILE_SOCKETS_ID)) return btif_sock_get_interface(); + if (is_profile(profile_id, "LOG_ID")) + return btif_stack_log_interface(); + if (is_profile(profile_id, BT_PROFILE_PAN_ID)) return btif_pan_get_interface(); diff --git a/btif/src/btif_stack_log.c b/btif/src/btif_stack_log.c new file mode 100644 index 000000000..40612b38a --- /dev/null +++ b/btif/src/btif_stack_log.c @@ -0,0 +1,63 @@ +/********************************************************************* +* +* Copyright (c) 2015, The Linux Foundation. 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 Linux Foundation 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 "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 OWNER 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. +* +************************************************************************/ + +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <hardware/bluetooth.h> + +#define LOG_TAG "STACK_LOG" + +#include "btif_api.h" +#include "bt_types.h" +#include "bt_trace.h" +#include "logging.h" + + +static void setLog( const char* log_layer, UINT16 log_level); + +static const btstacklog_interface_t btstacklogInterface = { + sizeof(btstacklog_interface_t), + setLog, +}; + +const btstacklog_interface_t *btif_stack_log_interface( void ) +{ + BTIF_TRACE_DEBUG("%s", __FUNCTION__); + return &btstacklogInterface; +} + +static void setLog( const char* log_layer, UINT16 log_level) +{ + BTA_setStackLog( log_layer, log_level); +} + diff --git a/device/src/controller.c b/device/src/controller.c index e90b4132d..da739cd7f 100755 --- a/device/src/controller.c +++ b/device/src/controller.c @@ -109,6 +109,12 @@ static future_t *start_up(void) { packet_parser->parse_generic_command_complete(response); + #ifdef QLOGKIT_USERDEBUG + /* Enable SOC Logging */ + UINT8 param[5] = {0x10,0x03,0x00,0x00,0x01}; + BTM_VendorSpecificCommand(HCI_VS_HOST_LOG_OPCODE,5,param,NULL); + #endif + // Read the local version info off the controller next, including // information such as manufacturer and supported HCI version response = AWAIT_COMMAND(packet_factory->make_read_local_version_info()); diff --git a/include/bt_trace.h b/include/bt_trace.h index 2d2db0b05..c945285c6 100644 --- a/include/bt_trace.h +++ b/include/bt_trace.h @@ -124,6 +124,7 @@ static const char BTE_LOGMSG_MODULE[] = "bte_logmsg_module"; #define BTTRC_PARAM_UINT8 1 #define BTTRC_PARAM_UINT16 2 #define BTTRC_PARAM_UINT32 3 +extern void BTA_setStackLog( const char* log_layer, int log_level); /* Enables or disables verbose trace information. */ #ifndef BT_TRACE_VERBOSE diff --git a/include/logging.h b/include/logging.h new file mode 100644 index 000000000..bd70b39ba --- /dev/null +++ b/include/logging.h @@ -0,0 +1,45 @@ +/********************************************************************* +* +* Copyright (c) 2015, The Linux Foundation. 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 Linux Foundation 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 "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 OWNER 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. +* +************************************************************************/ + +#include <stdio.h> +#include "bt_types.h" + +__BEGIN_DECLS + +typedef struct { + + size_t size; + void (*setLog)( const char *log_layer, UINT16 log_level); +} btstacklog_interface_t; + +__END_DECLS + diff --git a/main/Android.mk b/main/Android.mk index e31ceee97..9db0dc214 100644 --- a/main/Android.mk +++ b/main/Android.mk @@ -58,7 +58,8 @@ LOCAL_SRC_FILES += \ ../btif/src/stack_manager.c \ ../btif/src/btif_rfcomm.c \ ../btif/src/btif_mcap.c \ - ../btif/src/btif_l2cap.c + ../btif/src/btif_l2cap.c \ + ../btif/src/btif_stack_log.c ifeq ($(BOARD_USES_WIPOWER), true) LOCAL_SRC_FILES += \ diff --git a/main/bte_logmsg.c b/main/bte_logmsg.c index 4456e0900..6bb15320e 100644 --- a/main/bte_logmsg.c +++ b/main/bte_logmsg.c @@ -268,12 +268,10 @@ static future_t *init(void) { LOG_INFO("[bttrc] using compile default trace settings"); return NULL; } - load_levels_from_config(stack_config->get_all()); return NULL; } - const module_t bte_logmsg_module = { .name = BTE_LOGMSG_MODULE, .init = init, @@ -285,3 +283,43 @@ const module_t bte_logmsg_module = { NULL } }; + +/******************************************************************************** + ** + ** Function Name: BTA_setStackLog + ** + ** Purpose: Set the trace level of the different layers of stack + based on the stack layer and level as input + ** + ** Input Parameters: const char* log_layer, int log_level + Example : TRC_HCI, 5 + ** + ** Returns: void + ** + *********************************************************************************/ + +void BTA_setStackLog( const char* log_layer, int log_level) +{ + const tBTTRC_FUNC_MAP *p_f_map; + int new_level = 0; + int layer_found = 0; + p_f_map = &bttrc_set_level_map[0]; + + while ( 0 != p_f_map->layer_id_start ) + { + + if( (NULL != p_f_map->p_f) && !strcmp( p_f_map->trc_name, log_layer)) + { + new_level = p_f_map->p_f(log_level); + LOG_INFO("BTA_setStackLog: New trace level set for layer %s is %d", log_layer, new_level); + layer_found = 1; + break; + } + p_f_map++; + } + + if ( layer_found == 0 ) + { + LOG_INFO("BTA_setStackLog: Unable to set Layer %s with level %d. Layer not found", log_layer, log_level); + } +} diff --git a/stack/include/hcidefs.h b/stack/include/hcidefs.h index 7f2fb5778..41dc936c0 100644 --- a/stack/include/hcidefs.h +++ b/stack/include/hcidefs.h @@ -366,6 +366,8 @@ /* Extended BLE Scan parameters OCF */ #define HCI_BLE_EXTENDED_SCAN_PARAMS_OCF (0x0160 | HCI_GRP_VENDOR_SPECIFIC) +/* SOC Logging OCF */ +#define HCI_VS_HOST_LOG_OPCODE (0x0017 | HCI_GRP_VENDOR_SPECIFIC) /* VOIP Network Wifi OCF */ #define HCI_VSC_VOIP_NETWORK_WIFI_OCF (0x001C | HCI_GRP_VENDOR_SPECIFIC) |