OSDN Git Service

Get rid of counter
authorJakub Pawlowski <jpawlowski@google.com>
Tue, 23 Feb 2016 22:58:43 +0000 (14:58 -0800)
committerJakub Pawlowski <jpawlowski@google.com>
Wed, 24 Feb 2016 00:17:21 +0000 (16:17 -0800)
This patch removes counter. We were never using those values,
except for increasing them.

Bug: 27324326
Change-Id: I3122a36fa0435a36a8401792267cb5ebff5ab269

14 files changed:
btcore/Android.mk
btcore/BUILD.gn
btcore/include/counter.h [deleted file]
btcore/src/counter.c [deleted file]
btcore/test/counter_test.cpp [deleted file]
main/bte_main.c
stack/hcic/hcicmds.c
stack/l2cap/l2c_api.c
stack/l2cap/l2c_link.c
stack/l2cap/l2c_main.c
stack/l2cap/l2c_utils.c
stack/rfcomm/port_api.c
stack/rfcomm/rfc_l2cap_if.c
stack/rfcomm/rfc_ts_frames.c

index a8997c8..1366997 100644 (file)
@@ -22,7 +22,6 @@ LOCAL_PATH := $(call my-dir)
 # ========================================================
 btcoreCommonSrc := \
     src/bdaddr.c \
-    src/counter.c \
     src/device_class.c \
     src/hal_util.c \
     src/module.c \
@@ -32,7 +31,6 @@ btcoreCommonSrc := \
 
 btcoreCommonTestSrc := \
     ./test/bdaddr_test.cpp \
-    ./test/counter_test.cpp \
     ./test/device_class_test.cpp \
     ./test/property_test.cpp \
     ./test/uuid_test.cpp \
index 356115e..c0ebd8e 100644 (file)
@@ -17,7 +17,6 @@
 static_library("btcore") {
   sources = [
     "src/bdaddr.c",
-    "src/counter.c",
     "src/device_class.c",
     "src/hal_util.c",
     "src/module.c",
@@ -35,7 +34,6 @@ executable("net_test_btcore") {
   testonly = true
   sources = [
     "test/bdaddr_test.cpp",
-    "test/counter_test.cpp",
     "test/device_class_test.cpp",
     "test/property_test.cpp",
     "test/uuid_test.cpp",
diff --git a/btcore/include/counter.h b/btcore/include/counter.h
deleted file mode 100644 (file)
index 10e384f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 2014 Google, Inc.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#pragma once
-
-#include <stdbool.h>
-#include <stdint.h>
-
-static const char COUNTER_MODULE[] = "counter_module";
-
-typedef int64_t counter_data_t;
-
-// Used to iterate across all counters.
-typedef bool (*counter_iter_cb)(const char *name, counter_data_t val, void *context);
-
-// Mutators.
-void counter_set(const char *name, counter_data_t val);
-void counter_add(const char *name, counter_data_t val);
-
-// Iteration.
-bool counter_foreach(counter_iter_cb, void *context);
diff --git a/btcore/src/counter.c b/btcore/src/counter.c
deleted file mode 100644 (file)
index 79e0ca4..0000000
+++ /dev/null
@@ -1,420 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 2014 Google, Inc.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#define LOG_TAG "bt_core_counter"
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <stdarg.h>
-#include <stdatomic.h>
-#include <string.h>
-#include <sys/eventfd.h>
-
-#include "btcore/include/counter.h"
-#include "btcore/include/module.h"
-#include "osi/include/allocator.h"
-#include "osi/include/hash_functions.h"
-#include "osi/include/hash_map.h"
-#include "osi/include/list.h"
-#include "osi/include/log.h"
-#include "osi/include/osi.h"
-#include "osi/include/socket.h"
-#include "osi/include/thread.h"
-
-typedef int (*handler_t)(socket_t * socket);
-
-typedef struct counter_t {
-  _Atomic(int64_t) val;
-} counter_t;
-
-typedef struct hash_element_t {
-  const char *key;
-  counter_t *val;
-} hash_element_t;
-
-typedef struct counter_data_cb_t {
-  counter_iter_cb counter_iter_cb;
-  void *user_context;
-} counter_data_cb_t;
-
-typedef struct {
-  socket_t *socket;
-  uint8_t buffer[256];
-  size_t buffer_size;
-} client_t;
-
-typedef struct {
-  const char *name;
-  const char *help;
-  handler_t handler;
-} command_t;
-
-// Counter core
-static hash_map_t *hash_map_counter_;
-static pthread_mutex_t hash_map_lock_;
-static int counter_cnt_;
-
-// Counter port access
-static socket_t *listen_socket_;
-static thread_t *thread_;
-static list_t *clients_;
-
-static void accept_ready(socket_t *socket, void *context);
-static void read_ready(socket_t *socket, void *context);
-static void client_free(void *ptr);
-static const command_t *find_command(const char *name);
-static void output(socket_t *socket, const char* format, ...);
-
-// Commands
-static int help(socket_t *socket);
-static int show(socket_t *socket);
-static int set(socket_t *socket);
-static int quit(socket_t *socket);
-
-static const command_t commands[] = {
-  { "help", "<command> - show help text for <command>", help},
-  { "quit", "<command> - Quit and exit", quit},
-  { "set", "<counter> - Set something", set},
-  { "show", "<counter> - Show counters", show},
-};
-
-static counter_t *counter_new_(counter_data_t initial_val);
-static void counter_free_(counter_t *counter);
-
-static hash_element_t *hash_element_new_(void);
-// NOTE: The parameter datatype is void in order to satisfy the hash
-// data free function signature
-static void hash_element_free_(void *data);
-
-static struct counter_t *name_to_counter_(const char *name);
-static bool counter_foreach_cb_(hash_map_entry_t *hash_map_entry, void *context);
-
-static bool counter_socket_open(void);
-static void counter_socket_close(void);
-
-static const int COUNTER_NUM_BUCKETS = 53;
-
-// TODO(cmanton) Friendly interface, but may remove for automation
-const char *WELCOME = "Welcome to counters\n";
-const char *PROMPT = "\n> ";
-const char *GOODBYE = "Quitting... Bye !!";
-
-// TODO(cmanton) Develop port strategy; or multiplex all bt across single port
-static const port_t LISTEN_PORT = 8879;
-
-static future_t *counter_init(void) {
-  assert(hash_map_counter_ == NULL);
-  pthread_mutex_init(&hash_map_lock_, NULL);
-  hash_map_counter_ = hash_map_new(COUNTER_NUM_BUCKETS, hash_function_string,
-      NULL, hash_element_free_, NULL);
-  if (hash_map_counter_ == NULL) {
-    LOG_ERROR(LOG_TAG, "%s unable to allocate resources", __func__);
-    return future_new_immediate(FUTURE_FAIL);
-  }
-
-  if (!counter_socket_open()) {
-    LOG_ERROR(LOG_TAG, "%s unable to open counter port", __func__);
-    return future_new_immediate(FUTURE_FAIL);
-  }
-  return future_new_immediate(FUTURE_SUCCESS);
-}
-
-static future_t *counter_clean_up(void) {
-  counter_socket_close();
-  hash_map_free(hash_map_counter_);
-  pthread_mutex_destroy(&hash_map_lock_);
-  hash_map_counter_ = NULL;
-  return future_new_immediate(FUTURE_SUCCESS);
-}
-
-EXPORT_SYMBOL module_t counter_module = {
-  .name = COUNTER_MODULE,
-  .init = counter_init,
-  .start_up = NULL,
-  .shut_down = NULL,
-  .clean_up = counter_clean_up,
-  .dependencies = {NULL},
-};
-
-void counter_set(const char *name, counter_data_t val) {
-  assert(name != NULL);
-  counter_t *counter = name_to_counter_(name);
-  if (counter)
-    atomic_store(&counter->val, val);
-}
-
-void counter_add(const char *name, counter_data_t val) {
-  assert(name != NULL);
-  counter_t *counter = name_to_counter_(name);
-  if (counter) {
-    atomic_fetch_add(&counter->val, val);
-  }
-}
-
-bool counter_foreach(counter_iter_cb cb, void *context) {
-  assert(cb != NULL);
-  counter_data_cb_t counter_cb_data = {
-    cb,
-    context
-  };
-
-  hash_map_foreach(hash_map_counter_, counter_foreach_cb_, &counter_cb_data);
-  return true;
-}
-
-static counter_t *counter_new_(counter_data_t initial_val) {
-  counter_t *counter = (counter_t *)osi_calloc(sizeof(counter_t));
-
-  atomic_store(&counter->val, initial_val);
-  return counter;
-}
-
-static void counter_free_(counter_t *counter) {
-  osi_free(counter);
-}
-
-static hash_element_t *hash_element_new_(void) {
-  return (hash_element_t *)osi_calloc(sizeof(hash_element_t));
-}
-
-static void hash_element_free_(void *data) {
-  hash_element_t *hash_element = (hash_element_t *)data;
-  // We don't own the key
-  counter_free_(hash_element->val);
-  osi_free(hash_element);
-}
-
-// Returns a counter from the |hash_map_counter_|.  Creates
-// a new one if not found and inserts into |hash_map_counter_|.
-// Returns NULL upon memory allocation failure.
-static counter_t *name_to_counter_(const char *name) {
-  assert(hash_map_counter_ != NULL);
-  if (hash_map_has_key(hash_map_counter_, name))
-    return (counter_t *)hash_map_get(hash_map_counter_, name);
-
-  pthread_mutex_lock(&hash_map_lock_);
-  // On the uncommon path double check to make sure that another thread has
-  // not already created this counter
-  counter_t *counter = (counter_t *)hash_map_get(hash_map_counter_, name);
-  if (counter)
-    goto exit;
-
-  counter = counter_new_(0);
-  if (!counter) {
-    LOG_ERROR(LOG_TAG, "%s unable to create new counter name:%s", __func__, name);
-    goto exit;
-  }
-
-  hash_element_t *element = hash_element_new_();
-  if (!element) {
-    LOG_ERROR(LOG_TAG, "%s unable to create counter element name:%s", __func__, name);
-    counter_free_(counter);
-    counter = NULL;
-    goto exit;
-  }
-
-  element->key = name;
-  element->val = counter;
-  if (!hash_map_set(hash_map_counter_, name, counter)) {
-    LOG_ERROR(LOG_TAG, "%s unable to set new counter into hash map name:%s", __func__, name);
-    hash_element_free_(element);
-    counter_free_(counter);
-    counter = NULL;
-  }
-
- exit:;
-  pthread_mutex_unlock(&hash_map_lock_);
-  return counter;
-}
-
-static bool counter_foreach_cb_(hash_map_entry_t *hash_map_entry, void *context) {
-  assert(hash_map_entry != NULL);
-  const char *key = (const char *)hash_map_entry->key;
-  counter_data_t data = *(counter_data_t *)hash_map_entry->data;
-  counter_data_cb_t *counter_cb_data = (counter_data_cb_t *)context;
-  counter_cb_data->counter_iter_cb(key, data, counter_cb_data->user_context);
-  return true;
-}
-
-static bool counter_socket_open(void) {
-#if (!defined(BT_NET_DEBUG) || (BT_NET_DEBUG != TRUE))
-  return true;          // Disable using network sockets for security reasons
-#endif
-
-  assert(listen_socket_ == NULL);
-  assert(thread_ == NULL);
-  assert(clients_ == NULL);
-
-  clients_ = list_new(client_free);
-  if (!clients_) {
-    LOG_ERROR(LOG_TAG, "%s unable to create counter clients list", __func__);
-    goto error;
-  }
-
-  thread_ = thread_new("counter_socket");
-  if (!thread_) {
-    LOG_ERROR(LOG_TAG, "%s unable to create counter thread", __func__);
-    goto error;
-  }
-
-  listen_socket_ = socket_new();
-  if (!listen_socket_) {
-    LOG_ERROR(LOG_TAG, "%s unable to create listen socket", __func__);
-    goto error;
-  }
-
-  if (!socket_listen(listen_socket_, LISTEN_PORT)) {
-    LOG_ERROR(LOG_TAG, "%s unable to setup listen socket", __func__);
-    goto error;
-  }
-
-  LOG_INFO(LOG_TAG, "%s opened counter server socket", __func__);
-  socket_register(listen_socket_, thread_get_reactor(thread_), NULL, accept_ready, NULL);
-  return true;
-
-error:;
-  counter_socket_close();
-  return false;
-}
-
-static void counter_socket_close(void) {
-#if (!defined(BT_NET_DEBUG) || (BT_NET_DEBUG != TRUE))
-  return;               // Disable using network sockets for security reasons
-#endif
-
-  socket_free(listen_socket_);
-  thread_free(thread_);
-  list_free(clients_);
-
-  listen_socket_ = NULL;
-  thread_ = NULL;
-  clients_ = NULL;
-
-  LOG_INFO(LOG_TAG, "%s closed counter server socket", __func__);
-}
-
-static bool monitor_counter_iter_cb(const char *name, counter_data_t val, void *context) {
-  socket_t *socket = (socket_t *)context;
-  output(socket, "counter:%s val:%lld\n", name, val);
-  return true;
-}
-
-static void client_free(void *ptr) {
-  if (!ptr)
-    return;
-
-  client_t *client = (client_t *)ptr;
-  socket_free(client->socket);
-  osi_free(client);
-}
-
-static void accept_ready(socket_t *socket, UNUSED_ATTR void *context) {
-  assert(socket != NULL);
-  assert(socket == listen_socket_);
-
-  LOG_INFO(LOG_TAG, "%s accepted OSI monitor socket", __func__);
-  socket = socket_accept(socket);
-  if (!socket)
-    return;
-
-  client_t *client = (client_t *)osi_calloc(sizeof(client_t));
-  client->socket = socket;
-
-  if (!list_append(clients_, client)) {
-    LOG_ERROR(LOG_TAG, "%s unable to add client to list", __func__);
-    client_free(client);
-    return;
-  }
-
-  socket_register(socket, thread_get_reactor(thread_), client, read_ready, NULL);
-
-  output(socket, WELCOME);
-  output(socket, PROMPT);
-}
-
-static void read_ready(socket_t *socket, void *context) {
-  assert(socket != NULL);
-
-  client_t *client = (client_t *)context;
-
-  ssize_t ret = socket_read(socket, client->buffer + client->buffer_size, sizeof(client->buffer) - client->buffer_size);
-  if (ret == 0 || (ret == -1 && ret != EWOULDBLOCK && ret != EAGAIN)) {
-    list_remove(clients_, client);
-    return;
-  }
-
-  // Replace newline with end of string termination
-  // TODO(cmanton) Need proper semantics
-  for (size_t i = ret - 1; i > 0; --i) {
-    if (client->buffer[i] < 16)
-      *(client->buffer + i) = 0;
-    else
-      break;
-  }
-
-  const command_t *command = find_command((const char *)client->buffer);
-  if (!command) {
-    output(socket, "unable to find command %s\n", client->buffer);
-  } else {
-    int rc = command->handler(socket);
-    if (rc == 1) {
-      output(socket, GOODBYE);
-      socket_free(socket);
-      return;
-    }
-  }
-  output(socket, PROMPT);
-}
-
-static void output(socket_t *socket, const char* format, ...) {
-  char dest[4096];
-  va_list argptr;
-  va_start(argptr, format);
-  vsprintf(dest, format, argptr);
-  va_end(argptr);
-  socket_write(socket, dest, strlen(dest));
-}
-
-static int help(UNUSED_ATTR socket_t *socket) {
-  output(socket, "help command unimplemented\n");
-  return 0;
-}
-
-static int quit(UNUSED_ATTR socket_t *socket) {
-  return 1;
-}
-
-static int set(UNUSED_ATTR socket_t *socket) {
-  output(socket, "set command unimplemented\n");
-  return 0;
-}
-
-static int show(socket_t *socket) {
-  output(socket, "counter count registered:%d\n", counter_cnt_);
-  counter_foreach(monitor_counter_iter_cb, (void *)socket);
-  return 0;
-}
-
-static const command_t *find_command(const char *name) {
-  for  (size_t i = 0; i < ARRAY_SIZE(commands); ++i)
-    if (!strcmp(commands[i].name, name))
-      return &commands[i];
-  return NULL;
-}
diff --git a/btcore/test/counter_test.cpp b/btcore/test/counter_test.cpp
deleted file mode 100644 (file)
index 063dc24..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 2014 Google, Inc.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#include <gtest/gtest.h>
-#include "osi/test/AllocationTestHarness.h"
-
-extern "C" {
-#include "btcore/include/counter.h"
-#include "btcore/include/module.h"
-
-extern module_t counter_module;
-}  // "C"
-
-static const uint64_t COUNTER_TEST_TEN = 10;
-
-typedef struct mycounter_t {
-  const char *name;
-  uint64_t val;
-  bool found;
-} mycounter_t;
-
-static bool counter_iter(const char *name, counter_data_t val, void *context) {
-  mycounter_t *mycounter = (mycounter_t *)context;
-  if (!strcmp(name, mycounter->name)) {
-    mycounter->val = val;
-    mycounter->found = true;
-    return false;
-  }
-  return true;
-}
-
-static bool find_val(const char *name, uint64_t *val) {
-  mycounter_t mycounter;
-
-  mycounter.val = 0;
-  mycounter.name = name;
-  mycounter.found = false;
-  counter_foreach(counter_iter, &mycounter);
-  *val = mycounter.val;
-  if (mycounter.found)
-    return true;
-  return false;
-}
-
-class CounterTest : public AllocationTestHarness {
-  protected:
-    virtual void SetUp() {
-      counter_module.init();
-    }
-
-    virtual void TearDown() {
-      counter_module.clean_up();
-    }
-};
-
-TEST_F(CounterTest, counter_no_exist) {
-  uint64_t val;
-
-  EXPECT_FALSE(find_val("one.two.three", &val));
-}
-
-TEST_F(CounterTest, counter_inc_dec) {
-  uint64_t val;
-
-  counter_add("one.two.three", 1);
-
-  EXPECT_TRUE(find_val("one.two.three", &val));
-  EXPECT_EQ((uint64_t)1, val);
-
-  counter_add("one.two.three", 1);
-  EXPECT_TRUE(find_val("one.two.three", &val));
-  EXPECT_EQ((uint64_t)2, val);
-
-  counter_add("one.two.three", -1);
-  EXPECT_TRUE(find_val("one.two.three", &val));
-  EXPECT_EQ((uint64_t)1, val);
-}
-
-TEST_F(CounterTest, counter_get_set) {
-  uint64_t val;
-
-  counter_set("one.two.three", COUNTER_TEST_TEN);
-  EXPECT_TRUE(find_val("one.two.three", &val));
-  EXPECT_EQ(COUNTER_TEST_TEN, val);
-
-  EXPECT_FALSE(find_val("foo.bar", &val));
-}
index b870b5e..33266e7 100644 (file)
@@ -38,7 +38,6 @@
 #include "bt_hci_bdroid.h"
 #include "bt_utils.h"
 #include "bta_api.h"
-#include "btcore/include/counter.h"
 #include "btcore/include/module.h"
 #include "bte.h"
 #include "btif_common.h"
@@ -100,7 +99,6 @@ fixed_queue_t *btu_hci_msg_queue;
 ******************************************************************************/
 void bte_main_boot_entry(void)
 {
-    module_init(get_module(COUNTER_MODULE));
     module_init(get_module(INTEROP_MODULE));
 
     hci = hci_layer_get_interface();
@@ -139,7 +137,6 @@ void bte_main_shutdown()
     module_clean_up(get_module(STACK_CONFIG_MODULE));
 
     module_clean_up(get_module(INTEROP_MODULE));
-    module_clean_up(get_module(COUNTER_MODULE));
 }
 
 /******************************************************************************
@@ -258,8 +255,6 @@ void bte_main_hci_send (BT_HDR *p_msg, UINT16 event)
 
     p_msg->event = event;
 
-    counter_add("main.tx.packets", 1);
-    counter_add("main.tx.bytes", p_msg->len);
 
     if((sub_event == LOCAL_BR_EDR_CONTROLLER_ID) || \
        (sub_event == LOCAL_BLE_CONTROLLER_ID))
index 77a1007..34fce49 100644 (file)
@@ -24,7 +24,6 @@
  ******************************************************************************/
 
 #include "bt_target.h"
-#include "btcore/include/counter.h"
 #include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
@@ -205,7 +204,6 @@ BOOLEAN btsnd_hcic_accept_conn (BD_ADDR dest, UINT8 role)
     BDADDR_TO_STREAM (pp, dest);
     UINT8_TO_STREAM  (pp, role);
 
-    counter_add("hci.conn.accept", 1);
 
     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
     return (TRUE);
@@ -225,7 +223,6 @@ BOOLEAN btsnd_hcic_reject_conn (BD_ADDR dest, UINT8 reason)
     BDADDR_TO_STREAM (pp, dest);
     UINT8_TO_STREAM (pp, reason);
 
-    counter_add("hci.conn.reject", 1);
 
     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
     return (TRUE);
index f827836..60e1b66 100644 (file)
@@ -30,7 +30,6 @@
 #include <string.h>
 
 #include "bt_types.h"
-#include "btcore/include/counter.h"
 #include "btm_api.h"
 #include "btu.h"
 #include "bt_common.h"
@@ -243,7 +242,6 @@ UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_ERTM_INFO *p_e
     tL2C_CCB        *p_ccb;
     tL2C_RCB        *p_rcb;
 
-    counter_add("l2cap.conn.req", 1);
     L2CAP_TRACE_API ("L2CA_ErtmConnectReq()  PSM: 0x%04x  BDA: %08x%04x  p_ertm_info: 0x%08x allowed:0x%x preferred:%d", psm,
                       (p_bd_addr[0]<<24)+(p_bd_addr[1]<<16)+(p_bd_addr[2]<<8)+p_bd_addr[3],
                       (p_bd_addr[4]<<8)+p_bd_addr[5], p_ertm_info,
@@ -403,7 +401,6 @@ BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 re
     tL2C_LCB        *p_lcb;
     tL2C_CCB        *p_ccb;
 
-    counter_add("l2cap.conn.rsp", 1);
     L2CAP_TRACE_API ("L2CA_ErtmConnectRsp()  CID: 0x%04x  Result: %d  Status: %d  BDA: %08x%04x  p_ertm_info:0x%08x",
                       lcid, result, status,
                       (p_bd_addr[0]<<24)+(p_bd_addr[1]<<16)+(p_bd_addr[2]<<8)+p_bd_addr[3],
@@ -487,7 +484,6 @@ BOOLEAN L2CA_ConfigReq (UINT16 cid, tL2CAP_CFG_INFO *p_cfg)
 {
     tL2C_CCB        *p_ccb;
 
-    counter_add("l2cap.cfg.req", 1);
     L2CAP_TRACE_API ("L2CA_ConfigReq()  CID 0x%04x: fcr_present:%d (mode %d) mtu_present:%d (%d)",
         cid, p_cfg->fcr_present, p_cfg->fcr.mode, p_cfg->mtu_present, p_cfg->mtu);
 
@@ -538,7 +534,6 @@ BOOLEAN L2CA_ConfigRsp (UINT16 cid, tL2CAP_CFG_INFO *p_cfg)
 {
     tL2C_CCB        *p_ccb;
 
-    counter_add("l2cap.cfg.rsp", 1);
     L2CAP_TRACE_API ("L2CA_ConfigRsp()  CID: 0x%04x  Result: %d MTU present:%d Flush TO:%d FCR:%d FCS:%d",
         cid, p_cfg->result, p_cfg->mtu_present, p_cfg->flush_to_present, p_cfg->fcr_present, p_cfg->fcs_present);
 
@@ -582,7 +577,6 @@ BOOLEAN L2CA_DisconnectReq (UINT16 cid)
 {
     tL2C_CCB        *p_ccb;
 
-    counter_add("l2cap.disconn.req", 1);
     L2CAP_TRACE_API ("L2CA_DisconnectReq()  CID: 0x%04x", cid);
 
     /* Find the channel control block. We don't know the link it is on. */
@@ -611,7 +605,6 @@ BOOLEAN L2CA_DisconnectRsp (UINT16 cid)
 {
     tL2C_CCB        *p_ccb;
 
-    counter_add("l2cap.disconn.rsp", 1);
     L2CAP_TRACE_API ("L2CA_DisconnectRsp()  CID: 0x%04x", cid);
 
     /* Find the channel control block. We don't know the link it is on. */
index ebbe50b..238b731 100644 (file)
@@ -29,7 +29,6 @@
 #include <stdio.h>
 
 #include "device/include/controller.h"
-#include "btcore/include/counter.h"
 #include "bt_common.h"
 #include "bt_types.h"
 #include "bt_utils.h"
@@ -101,7 +100,6 @@ BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr)
                 p_lcb->link_role = l2cu_get_conn_role(p_lcb);
         }
 
-        counter_add("l2cap.conn.accept", 1);
 
         /* Tell the other side we accept the connection */
         btsnd_hcic_accept_conn (bd_addr, p_lcb->link_role);
@@ -125,7 +123,6 @@ BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr)
         else
             p_lcb->link_role = l2cu_get_conn_role(p_lcb);
 
-        counter_add("l2cap.conn.accept", 1);
         btsnd_hcic_accept_conn (bd_addr, p_lcb->link_role);
 
         p_lcb->link_state = LST_CONNECTING;
@@ -134,7 +131,6 @@ BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr)
     else if (p_lcb->link_state == LST_DISCONNECTING)
     {
         /* In disconnecting state, reject the connection. */
-        counter_add("l2cap.conn.reject.disconn", 1);
         btsnd_hcic_reject_conn (bd_addr, HCI_ERR_HOST_REJECT_DEVICE);
     }
     else
@@ -142,7 +138,6 @@ BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr)
         L2CAP_TRACE_ERROR("L2CAP got conn_req while connected (state:%d). Reject it",
                 p_lcb->link_state);
         /* Reject the connection with ACL Connection Already exist reason */
-        counter_add("l2cap.conn.reject.exists", 1);
         btsnd_hcic_reject_conn (bd_addr, HCI_ERR_CONNECTION_EXISTS);
     }
     return (FALSE);
@@ -198,7 +193,6 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda)
     {
         /* Connected OK. Change state to connected */
         p_lcb->link_state = LST_CONNECTED;
-        counter_add("l2cap.conn.ok", 1);
 
         /* Get the peer information if the l2cap flow-control/rtrans is supported */
         l2cu_send_peer_info_req (p_lcb, L2CAP_EXTENDED_FEATURES_INFO_TYPE);
index 50f5248..223ed0b 100644 (file)
@@ -29,7 +29,6 @@
 #include <string.h>
 
 #include "bt_target.h"
-#include "btcore/include/counter.h"
 #include "btm_int.h"
 #include "btu.h"
 #include "device/include/controller.h"
@@ -106,8 +105,6 @@ void l2c_bcst_msg( BT_HDR *p_buf, UINT16 psm )
 
     if (p_buf->len <= controller_get_interface()->get_acl_packet_size_classic())
     {
-        counter_add("l2cap.ch2.tx.bytes", p_buf->len);
-        counter_add("l2cap.ch2.tx.pkts", 1);
 
         bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL);
     }
@@ -236,15 +233,11 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
     /* Send the data through the channel state machine */
     if (rcv_cid == L2CAP_SIGNALLING_CID)
     {
-        counter_add("l2cap.sig.rx.bytes", l2cap_len);
-        counter_add("l2cap.sig.rx.pkts", 1);
         process_l2cap_cmd (p_lcb, p, l2cap_len);
         osi_free(p_msg);
     }
     else if (rcv_cid == L2CAP_CONNECTIONLESS_CID)
     {
-        counter_add("l2cap.ch2.rx.bytes", l2cap_len);
-        counter_add("l2cap.ch2.rx.pkts", 1);
         /* process_connectionless_data (p_lcb); */
         STREAM_TO_UINT16 (psm, p);
         L2CAP_TRACE_DEBUG( "GOT CONNECTIONLESS DATA PSM:%d", psm ) ;
@@ -262,8 +255,6 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
 #if (BLE_INCLUDED == TRUE)
     else if (rcv_cid == L2CAP_BLE_SIGNALLING_CID)
     {
-        counter_add("l2cap.ble.rx.bytes", l2cap_len);
-        counter_add("l2cap.ble.rx.pkts", 1);
         l2cble_process_sig_cmd (p_lcb, p, l2cap_len);
         osi_free(p_msg);
     }
@@ -272,8 +263,6 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
     else if ((rcv_cid >= L2CAP_FIRST_FIXED_CHNL) && (rcv_cid <= L2CAP_LAST_FIXED_CHNL) &&
              (l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb != NULL) )
     {
-        counter_add("l2cap.fix.rx.bytes", l2cap_len);
-        counter_add("l2cap.fix.rx.pkts", 1);
         /* If no CCB for this channel, allocate one */
         if (p_lcb &&
             /* only process fixed channel data when link is open or wait for data indication */
@@ -295,8 +284,6 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
 
     else
     {
-        counter_add("l2cap.dyn.rx.bytes", l2cap_len);
-        counter_add("l2cap.dyn.rx.pkts", 1);
         if (p_ccb == NULL)
             osi_free(p_msg);
         else
@@ -993,8 +980,6 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags)
         return (L2CAP_DW_FAILED);
     }
 
-    counter_add("l2cap.dyn.tx.bytes", p_data->len);
-    counter_add("l2cap.dyn.tx.pkts", 1);
 
     l2c_csm_execute (p_ccb, L2CEVT_L2CA_DATA_WRITE, p_data);
 
index 7470717..e849bf6 100644 (file)
@@ -27,7 +27,6 @@
 #include <stdio.h>
 
 #include "device/include/controller.h"
-#include "btcore/include/counter.h"
 #include "bt_common.h"
 #include "bt_types.h"
 #include "hcimsgs.h"
@@ -376,16 +375,12 @@ BT_HDR *l2cu_build_header (tL2C_LCB *p_lcb, UINT16 len, UINT8 cmd, UINT8 id)
 #if (BLE_INCLUDED == TRUE)
     if (p_lcb->transport == BT_TRANSPORT_LE)
     {
-        counter_add("l2cap.ble.tx.bytes", p_buf->len);
-        counter_add("l2cap.ble.tx.pkts", 1);
 
         UINT16_TO_STREAM (p, L2CAP_BLE_SIGNALLING_CID);
     }
     else
 #endif
     {
-        counter_add("l2cap.sig.tx.bytes", p_buf->len);
-        counter_add("l2cap.sig.tx.pkts", 1);
         UINT16_TO_STREAM (p, L2CAP_SIGNALLING_CID);
     }
 
index f06a8d9..6470486 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <string.h>
 
-#include "btcore/include/counter.h"
 #include "osi/include/log.h"
 #include "osi/include/mutex.h"
 
@@ -120,7 +119,6 @@ int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn, BOOLEAN is_server,
     tRFC_MCB   *p_mcb = port_find_mcb (bd_addr);
     UINT16     rfcomm_mtu;
 
-    counter_add("rfcomm.conn.created", 1);
 
     RFCOMM_TRACE_API ("RFCOMM_CreateConnection()  BDA: %02x-%02x-%02x-%02x-%02x-%02x",
                        bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]);
@@ -246,7 +244,6 @@ int RFCOMM_RemoveConnection (UINT16 handle)
 {
     tPORT      *p_port;
 
-    counter_add("rfcomm.conn.destroyed", 1);
 
     RFCOMM_TRACE_API ("RFCOMM_RemoveConnection() handle:%d", handle);
 
index 182ee5d..319dc41 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <stddef.h>
 #include "bt_target.h"
-#include "btcore/include/counter.h"
 
 #include "osi/include/time.h"
 #include "bt_common.h"
@@ -368,8 +367,6 @@ void RFCOMM_BufDataInd (UINT16 lcid, BT_HDR *p_buf)
 
     if (event == RFC_EVENT_UIH)
     {
-        counter_add("rfcomm.rx.frames", 1);
-        counter_add("rfcomm.rx.bytes", p_buf->len);
 
         if (p_buf->len > 0)
             rfc_port_sm_execute (p_port, event, p_buf);
index ffb495a..ebe3799 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <stddef.h>
 #include "bt_target.h"
-#include "btcore/include/counter.h"
 #include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
@@ -206,8 +205,6 @@ void rfc_send_buf_uih (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf)
     }
     else
     {
-        counter_add("rfcomm.tx.frames", 1);
-        counter_add("rfcomm.tx.bytes", p_buf->len);
         L2CA_DataWrite (p_mcb->lcid, p_buf);
     }
 }