You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/07/13 20:55:57 UTC

[44/50] [abbrv] incubator-mynewt-core git commit: Nimble: rename g_hci_cmd_pool --> g_hci_evt_pool

Nimble: rename g_hci_cmd_pool --> g_hci_evt_pool

This pool is only used for events; it is no longer used for commands.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/895e8037
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/895e8037
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/895e8037

Branch: refs/heads/develop
Commit: 895e8037c7fb8b412f770622e93e24e5c308788b
Parents: a1e0613
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Jul 12 17:49:26 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Jul 13 12:11:36 2016 -0700

----------------------------------------------------------------------
 apps/blehci/src/main.c                      | 16 ++++++++--------
 net/nimble/controller/src/ble_ll_conn_hci.c |  8 ++++----
 net/nimble/controller/src/ble_ll_hci.c      |  2 +-
 net/nimble/controller/src/ble_ll_hci_ev.c   | 14 +++++++-------
 net/nimble/controller/src/ble_ll_scan.c     |  2 +-
 net/nimble/host/include/host/host_hci.h     |  1 +
 net/nimble/host/src/ble_hs.c                | 18 +++++++++---------
 net/nimble/host/src/host_hci.c              |  4 ++--
 net/nimble/host/src/host_hci_cmd.c          |  8 +++++++-
 net/nimble/host/src/test/ble_hs_test.c      |  2 +-
 net/nimble/host/src/test/ble_hs_test_util.c |  2 +-
 net/nimble/include/nimble/ble.h             |  2 +-
 12 files changed, 43 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/apps/blehci/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blehci/src/main.c b/apps/blehci/src/main.c
index f0736b7..09fb456 100755
--- a/apps/blehci/src/main.c
+++ b/apps/blehci/src/main.c
@@ -53,8 +53,8 @@ uint8_t g_random_addr[BLE_DEV_ADDR_LEN] = { 0 };
 
 #define HCI_MAX_BUFS        (5)
 
-#define HCI_CMD_BUF_SIZE    (260)
-struct os_mempool g_hci_cmd_pool;
+#define HCI_EVT_BUF_SIZE    (260)
+struct os_mempool g_hci_evt_pool;
 static void *hci_cmd_buf;
 
 #define HCI_OS_EVENT_BUF_SIZE   (sizeof(struct os_event))
@@ -143,7 +143,7 @@ ble_hci_transport_ctlr_event_send(uint8_t *hci_ev)
     if (!ev) {
         os_error_t err;
 
-        err = os_memblock_put(&g_hci_cmd_pool, hci_ev);
+        err = os_memblock_put(&g_hci_evt_pool, hci_ev);
         assert(err == OS_OK);
 
         return -1;
@@ -218,7 +218,7 @@ uart_tx_char(void *arg)
         rc = hci.rx_evt.data[hci.rx_evt.cur++];
 
         if (hci.rx_evt.cur == hci.rx_evt.len) {
-            os_memblock_put(&g_hci_cmd_pool, hci.rx_evt.data);
+            os_memblock_put(&g_hci_evt_pool, hci.rx_evt.data);
             hci.rx_type = H4_NONE;
         }
 
@@ -244,7 +244,7 @@ uart_rx_pkt_type(uint8_t data)
 
     switch (hci.tx_type) {
     case H4_CMD:
-        hci.tx_cmd.data = os_memblock_get(&g_hci_cmd_pool);
+        hci.tx_cmd.data = os_memblock_get(&g_hci_evt_pool);
         hci.tx_cmd.len = 0;
         hci.tx_cmd.cur = 0;
         break;
@@ -276,7 +276,7 @@ uart_rx_cmd(uint8_t data)
     if (hci.tx_cmd.cur == hci.tx_cmd.len) {
         rc = ble_hci_transport_host_cmd_send(hci.tx_cmd.data);
         if (rc != 0) {
-            os_memblock_put(&g_hci_cmd_pool, hci.tx_cmd.data);
+            os_memblock_put(&g_hci_evt_pool, hci.tx_cmd.data);
         }
         hci.tx_type = H4_NONE;
     }
@@ -366,11 +366,11 @@ main(void)
     rc = ble_ll_init(BLE_LL_TASK_PRI, MBUF_NUM_MBUFS, BLE_MBUF_PAYLOAD_SIZE);
     assert(rc == 0);
 
-    hci_cmd_buf = malloc(OS_MEMPOOL_BYTES(HCI_MAX_BUFS, HCI_CMD_BUF_SIZE));
+    hci_cmd_buf = malloc(OS_MEMPOOL_BYTES(HCI_MAX_BUFS, HCI_EVT_BUF_SIZE));
     assert(hci_cmd_buf != NULL);
 
     /* Create memory pool of command buffers */
-    rc = os_mempool_init(&g_hci_cmd_pool, HCI_MAX_BUFS, HCI_CMD_BUF_SIZE,
+    rc = os_mempool_init(&g_hci_evt_pool, HCI_MAX_BUFS, HCI_EVT_BUF_SIZE,
                          hci_cmd_buf, "HCICmdPool");
     assert(rc == 0);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/controller/src/ble_ll_conn_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_hci.c b/net/nimble/controller/src/ble_ll_conn_hci.c
index e1bc978..1d6102e 100644
--- a/net/nimble/controller/src/ble_ll_conn_hci.c
+++ b/net/nimble/controller/src/ble_ll_conn_hci.c
@@ -140,7 +140,7 @@ ble_ll_conn_comp_event_send(struct ble_ll_conn_sm *connsm, uint8_t status)
     enh_enabled = ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_ENH_CONN_COMPLETE);
 
     if (enabled || enh_enabled) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             /* Put common elements in event */
             evbuf[0] = BLE_HCI_EVCODE_LE_META;
@@ -246,7 +246,7 @@ ble_ll_conn_num_comp_pkts_event_send(void)
             (connsm->completed_pkts || !STAILQ_EMPTY(&connsm->conn_txq))) {
             /* If no buffer, get one, If cant get one, leave. */
             if (!evbuf) {
-                evbuf = os_memblock_get(&g_hci_cmd_pool);
+                evbuf = os_memblock_get(&g_hci_evt_pool);
                 if (!evbuf) {
                     break;
                 }
@@ -313,7 +313,7 @@ ble_ll_auth_pyld_tmo_event_send(struct ble_ll_conn_sm *connsm)
     uint8_t *evbuf;
 
     if (ble_ll_hci_is_event_enabled(BLE_HCI_EVCODE_AUTH_PYLD_TMO)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = BLE_HCI_EVCODE_AUTH_PYLD_TMO;
             evbuf[1] = sizeof(uint16_t);
@@ -338,7 +338,7 @@ ble_ll_disconn_comp_event_send(struct ble_ll_conn_sm *connsm, uint8_t reason)
     uint8_t *evbuf;
 
     if (ble_ll_hci_is_event_enabled(BLE_HCI_EVCODE_DISCONN_CMP)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = BLE_HCI_EVCODE_DISCONN_CMP;
             evbuf[1] = BLE_HCI_EVENT_DISCONN_COMPLETE_LEN;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/controller/src/ble_ll_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci.c b/net/nimble/controller/src/ble_ll_hci.c
index 1d73465..2889367 100644
--- a/net/nimble/controller/src/ble_ll_hci.c
+++ b/net/nimble/controller/src/ble_ll_hci.c
@@ -86,7 +86,7 @@ ble_ll_hci_send_noop(void)
     uint8_t *evbuf;
     uint16_t opcode;
 
-    evbuf = os_memblock_get(&g_hci_cmd_pool);
+    evbuf = os_memblock_get(&g_hci_evt_pool);
     if (evbuf) {
         /* Create a command complete event with a NO-OP opcode */
         opcode = 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/controller/src/ble_ll_hci_ev.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci_ev.c b/net/nimble/controller/src/ble_ll_hci_ev.c
index 773e4e6..5624c65 100644
--- a/net/nimble/controller/src/ble_ll_hci_ev.c
+++ b/net/nimble/controller/src/ble_ll_hci_ev.c
@@ -41,7 +41,7 @@ ble_ll_hci_ev_datalen_chg(struct ble_ll_conn_sm *connsm)
     uint8_t *evbuf;
 
     if (ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_DATA_LEN_CHG)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = BLE_HCI_EVCODE_LE_META;
             evbuf[1] = BLE_HCI_LE_DATA_LEN_CHG_LEN;
@@ -68,7 +68,7 @@ ble_ll_hci_ev_rem_conn_parm_req(struct ble_ll_conn_sm *connsm,
     uint8_t *evbuf;
 
     if (ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_REM_CONN_PARM_REQ)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = BLE_HCI_EVCODE_LE_META;
             evbuf[1] = BLE_HCI_LE_REM_CONN_PARM_REQ_LEN;
@@ -95,7 +95,7 @@ ble_ll_hci_ev_conn_update(struct ble_ll_conn_sm *connsm, uint8_t status)
     uint8_t *evbuf;
 
     if (ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_CONN_UPD_COMPLETE)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = BLE_HCI_EVCODE_LE_META;
             evbuf[1] = BLE_HCI_LE_CONN_UPD_LEN;
@@ -127,7 +127,7 @@ ble_ll_hci_ev_encrypt_chg(struct ble_ll_conn_sm *connsm, uint8_t status)
     }
 
     if (ble_ll_hci_is_event_enabled(evcode)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = evcode;
             evbuf[1] = evlen;
@@ -158,7 +158,7 @@ ble_ll_hci_ev_ltk_req(struct ble_ll_conn_sm *connsm)
     uint8_t *evbuf;
 
     if (ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_LT_KEY_REQ)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = BLE_HCI_EVCODE_LE_META;
             evbuf[1] = BLE_HCI_LE_LT_KEY_REQ_LEN;
@@ -188,7 +188,7 @@ ble_ll_hci_ev_rd_rem_used_feat(struct ble_ll_conn_sm *connsm, uint8_t status)
     uint8_t *evbuf;
 
     if (ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_RD_REM_USED_FEAT)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = BLE_HCI_EVCODE_LE_META;
             evbuf[1] = BLE_HCI_LE_RD_REM_USED_FEAT_LEN;
@@ -208,7 +208,7 @@ ble_ll_hci_ev_rd_rem_ver(struct ble_ll_conn_sm *connsm, uint8_t status)
     uint8_t *evbuf;
 
     if (ble_ll_hci_is_event_enabled(BLE_HCI_EVCODE_RD_REM_VER_INFO_CMP)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = BLE_HCI_EVCODE_RD_REM_VER_INFO_CMP;
             evbuf[1] = BLE_HCI_EVENT_RD_RM_VER_LEN;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index e7346ba..c926846 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -424,7 +424,7 @@ ble_ll_hci_send_adv_report(uint8_t pdu_type, uint8_t txadd, uint8_t *rxbuf,
     }
 
     if (ble_ll_hci_is_le_event_enabled(subev)) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         if (evbuf) {
             evbuf[0] = BLE_HCI_EVCODE_LE_META;
             evbuf[1] = event_len;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/host/include/host/host_hci.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/host_hci.h b/net/nimble/host/include/host/host_hci.h
index f2a2a94..1bf3c06 100644
--- a/net/nimble/host/include/host/host_hci.h
+++ b/net/nimble/host/include/host/host_hci.h
@@ -25,6 +25,7 @@ struct ble_hs_conn;
 struct os_mbuf;
 
 #define HCI_CMD_BUF_SIZE        260
+#define HCI_EVT_BUF_SIZE        260
 
 extern uint8_t host_hci_cmd_buf[HCI_CMD_BUF_SIZE];
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index b9f55ae..8f3cd1b 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -39,8 +39,8 @@
 static struct log_handler ble_hs_log_console_handler;
 struct log ble_hs_log;
 
-struct os_mempool g_hci_cmd_pool;
-static void *ble_hs_hci_cmd_buf;
+struct os_mempool g_hci_evt_pool;
+static void *ble_hs_hci_evt_buf;
 
 /* XXX: this might be transport layer */
 #define HCI_OS_EVENT_BUF_SIZE   (sizeof(struct os_event))
@@ -349,8 +349,8 @@ ble_hs_tx_data(struct os_mbuf *om)
 static void
 ble_hs_free_mem(void)
 {
-    free(ble_hs_hci_cmd_buf);
-    ble_hs_hci_cmd_buf = NULL;
+    free(ble_hs_hci_evt_buf);
+    ble_hs_hci_evt_buf = NULL;
 
     free(ble_hs_hci_os_event_buf);
     ble_hs_hci_os_event_buf = NULL;
@@ -392,16 +392,16 @@ ble_hs_init(struct os_eventq *app_evq, struct ble_hs_cfg *cfg)
     log_console_handler_init(&ble_hs_log_console_handler);
     log_register("ble_hs", &ble_hs_log, &ble_hs_log_console_handler);
 
-    ble_hs_hci_cmd_buf = malloc(OS_MEMPOOL_BYTES(ble_hs_cfg.max_hci_bufs,
-                                                 HCI_CMD_BUF_SIZE));
-    if (ble_hs_hci_cmd_buf == NULL) {
+    ble_hs_hci_evt_buf = malloc(OS_MEMPOOL_BYTES(ble_hs_cfg.max_hci_bufs,
+                                                 HCI_EVT_BUF_SIZE));
+    if (ble_hs_hci_evt_buf == NULL) {
         rc = BLE_HS_ENOMEM;
         goto err;
     }
 
     /* Create memory pool of command buffers */
-    rc = os_mempool_init(&g_hci_cmd_pool, ble_hs_cfg.max_hci_bufs,
-                         HCI_CMD_BUF_SIZE, ble_hs_hci_cmd_buf,
+    rc = os_mempool_init(&g_hci_evt_pool, ble_hs_cfg.max_hci_bufs,
+                         HCI_EVT_BUF_SIZE, ble_hs_hci_evt_buf,
                          "HCICmdPool");
     assert(rc == 0);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/host/src/host_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci.c b/net/nimble/host/src/host_hci.c
index 5251231..ce483cd 100644
--- a/net/nimble/host/src/host_hci.c
+++ b/net/nimble/host/src/host_hci.c
@@ -622,7 +622,7 @@ host_hci_os_event_proc(struct os_event *ev)
     rc = host_hci_event_rx(ev->ev_arg);
 
     /* Free the command buffer */
-    err = os_memblock_put(&g_hci_cmd_pool, ev->ev_arg);
+    err = os_memblock_put(&g_hci_evt_pool, ev->ev_arg);
     BLE_HS_DBG_ASSERT_EVAL(err == OS_OK);
 
     /* Free the event */
@@ -662,7 +662,7 @@ ble_hci_transport_ctlr_event_send(uint8_t *hci_ev)
         /* Get an event structure off the queue */
         ev = (struct os_event *)os_memblock_get(&g_hci_os_event_pool);
         if (!ev) {
-            err = os_memblock_put(&g_hci_cmd_pool, hci_ev);
+            err = os_memblock_put(&g_hci_evt_pool, hci_ev);
             BLE_HS_DBG_ASSERT_EVAL(err == OS_OK);
             return -1;
         }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/host/src/host_hci_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci_cmd.c b/net/nimble/host/src/host_hci_cmd.c
index c1151fc..af33371 100644
--- a/net/nimble/host/src/host_hci_cmd.c
+++ b/net/nimble/host/src/host_hci_cmd.c
@@ -32,7 +32,13 @@
 #include "host/ble_hs_test.h"
 #endif
 
-uint8_t host_hci_cmd_buf[HCI_CMD_BUF_SIZE];
+/**
+ * This buffer holds one of the following:
+ * 1. The current outgoing HCI command.
+ * 2. The current incoming HCI acknowledgement (command complete or command
+ *    status event).
+ */
+uint8_t host_hci_cmd_buf[HCI_EVT_BUF_SIZE];
 
 static int
 host_hci_cmd_transport(uint8_t *cmdbuf)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/host/src/test/ble_hs_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test.c b/net/nimble/host/src/test/ble_hs_test.c
index 388d449..16ae9b9 100644
--- a/net/nimble/host/src/test/ble_hs_test.c
+++ b/net/nimble/host/src/test/ble_hs_test.c
@@ -36,7 +36,7 @@ void
 ble_hs_test_hci_txed(uint8_t *cmdbuf)
 {
     ble_hs_test_util_enqueue_hci_tx(cmdbuf);
-    os_memblock_put(&g_hci_cmd_pool, cmdbuf);
+    os_memblock_put(&g_hci_evt_pool, cmdbuf);
 }
 
 #ifdef MYNEWT_SELFTEST

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/host/src/test/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test_util.c b/net/nimble/host/src/test/ble_hs_test_util.c
index c5d72c6..a830449 100644
--- a/net/nimble/host/src/test/ble_hs_test_util.c
+++ b/net/nimble/host/src/test/ble_hs_test_util.c
@@ -246,7 +246,7 @@ ble_hs_test_util_rx_hci_evt(uint8_t *evt)
     TEST_ASSERT_FATAL(totlen <= UINT8_MAX + BLE_HCI_EVENT_HDR_LEN);
 
     if (os_started()) {
-        evbuf = os_memblock_get(&g_hci_cmd_pool);
+        evbuf = os_memblock_get(&g_hci_evt_pool);
         TEST_ASSERT_FATAL(evbuf != NULL);
 
         memcpy(evbuf, evt, totlen);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/895e8037/net/nimble/include/nimble/ble.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/ble.h b/net/nimble/include/nimble/ble.h
index aae501a..f2041c8 100644
--- a/net/nimble/include/nimble/ble.h
+++ b/net/nimble/include/nimble/ble.h
@@ -35,7 +35,7 @@ struct ble_encryption_block
 };
 
 /* Shared command pool for transort between host and controller */
-extern struct os_mempool g_hci_cmd_pool;
+extern struct os_mempool g_hci_evt_pool;
 extern struct os_mempool g_hci_os_event_pool;
 
 /*