diff --git a/nimble/transport/da1469x/syscfg.yml b/nimble/transport/da1469x/syscfg.yml index 4ea9da9b3..2ce8cd3cf 100644 --- a/nimble/transport/da1469x/syscfg.yml +++ b/nimble/transport/da1469x/syscfg.yml @@ -16,28 +16,12 @@ # under the License. # -syscfg.defs: - BLE_HCI_EVT_HI_BUF_COUNT: - description: 'Number of high-priority event buffers.' - value: 2 +syscfg.vals.'!BLE_HCI_BRIDGE && !BLE_EXT_ADV': + BLE_HCI_EVT_HI_BUF_COUNT: 2 + BLE_HCI_EVT_LO_BUF_COUNT: 8 + BLE_HCI_EVT_BUF_SIZE: 70 + BLE_ACL_BUF_COUNT: 4 + BLE_ACL_BUF_SIZE: 255 - BLE_HCI_EVT_LO_BUF_COUNT: - description: 'Number of low-priority event buffers.' - value: 8 - - BLE_HCI_EVT_BUF_SIZE: - description: 'Size of each event buffer, in bytes.' - value: 70 - - BLE_ACL_BUF_COUNT: - description: 'The number of ACL data buffers' - value: 4 - - BLE_ACL_BUF_SIZE: - description: > - This is the maximum size of the data portion of HCI ACL data - packets. It does not include the HCI data header (of 4 bytes). - value: 255 - -syscfg.vals.BLE_EXT_ADV: +syscfg.vals.'!BLE_HCI_BRIDGE && BLE_EXT_ADV': BLE_HCI_EVT_BUF_SIZE: 274 diff --git a/nimble/transport/dialog_cmac/cmac_driver/diag/src/cmac_diag.c b/nimble/transport/dialog_cmac/cmac_driver/diag/src/cmac_diag.c index 4f7547065..0a4e27e6d 100644 --- a/nimble/transport/dialog_cmac/cmac_driver/diag/src/cmac_diag.c +++ b/nimble/transport/dialog_cmac/cmac_driver/diag/src/cmac_diag.c @@ -20,7 +20,7 @@ #include "syscfg/syscfg.h" #include "mcu/mcu.h" -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) void cmac_diag_setup_host(void) { diff --git a/nimble/transport/dialog_cmac/cmac_driver/include/cmac_driver/cmac_shared.h b/nimble/transport/dialog_cmac/cmac_driver/include/cmac_driver/cmac_shared.h index 90b5827dd..4e37bb8b8 100644 --- a/nimble/transport/dialog_cmac/cmac_driver/include/cmac_driver/cmac_shared.h +++ b/nimble/transport/dialog_cmac/cmac_driver/include/cmac_driver/cmac_shared.h @@ -131,7 +131,7 @@ struct cmac_shared_data { uint8_t mbox_c2s_buf[ MYNEWT_VAL(CMAC_MBOX_SIZE_C2S) ]; }; -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) extern volatile struct cmac_shared_data *g_cmac_shared_data; #elif MYNEWT_VAL(BLE_CONTROLLER) extern volatile struct cmac_shared_data g_cmac_shared_data; @@ -161,7 +161,7 @@ void cmac_rand_set_isr_cb(cmac_rand_isr_cb_t cb); void cmac_shared_init(void); void cmac_shared_sync(void); -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) #define CMAC_SHARED_LOCK_VAL 0x40000000 #elif MYNEWT_VAL(BLE_CONTROLLER) #define CMAC_SHARED_LOCK_VAL 0xc0000000 diff --git a/nimble/transport/dialog_cmac/cmac_driver/pkg.yml b/nimble/transport/dialog_cmac/cmac_driver/pkg.yml index 5b4a21291..00200b65a 100644 --- a/nimble/transport/dialog_cmac/cmac_driver/pkg.yml +++ b/nimble/transport/dialog_cmac/cmac_driver/pkg.yml @@ -37,3 +37,6 @@ pkg.post_link_cmds.BLE_CONTROLLER: pkg.pre_link_cmds.BLE_HOST: scripts/build_libcmac.sh: 100 + +pkg.pre_link_cmds.BLE_HCI_BRIDGE: + scripts/build_libcmac.sh: 100 diff --git a/nimble/transport/dialog_cmac/cmac_driver/src/cmac_mbox.c b/nimble/transport/dialog_cmac/cmac_driver/src/cmac_mbox.c index 9594dbe90..88764c4df 100644 --- a/nimble/transport/dialog_cmac/cmac_driver/src/cmac_mbox.c +++ b/nimble/transport/dialog_cmac/cmac_driver/src/cmac_mbox.c @@ -49,7 +49,7 @@ cmac_mbox_set_write_notif_cb(cmac_mbox_write_notif_cb *cb) int cmac_mbox_read(void) { -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) volatile struct cmac_mbox *mbox = &g_cmac_shared_data->mbox_c2s; uint8_t *mbox_buf = (uint8_t *)&g_cmac_shared_data->mbox_c2s_buf; const uint16_t mbox_size = MYNEWT_VAL(CMAC_MBOX_SIZE_C2S); @@ -96,7 +96,7 @@ cmac_mbox_read(void) int cmac_mbox_write(const void *data, uint16_t len) { -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) volatile struct cmac_mbox *mbox = &g_cmac_shared_data->mbox_s2c; uint8_t *mbox_buf = (uint8_t *)&g_cmac_shared_data->mbox_s2c_buf; const uint16_t mbox_size = MYNEWT_VAL(CMAC_MBOX_SIZE_S2C); diff --git a/nimble/transport/dialog_cmac/cmac_driver/src/cmac_rand.c b/nimble/transport/dialog_cmac/cmac_driver/src/cmac_rand.c index 67a315f96..10810972c 100644 --- a/nimble/transport/dialog_cmac/cmac_driver/src/cmac_rand.c +++ b/nimble/transport/dialog_cmac/cmac_driver/src/cmac_rand.c @@ -26,7 +26,7 @@ #include "os/os_arch.h" #include "os/os.h" -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) int cmac_rand_is_active(void) { diff --git a/nimble/transport/dialog_cmac/cmac_driver/src/cmac_shared.c b/nimble/transport/dialog_cmac/cmac_driver/src/cmac_shared.c index 24640ca47..a4f2e37f5 100644 --- a/nimble/transport/dialog_cmac/cmac_driver/src/cmac_shared.c +++ b/nimble/transport/dialog_cmac/cmac_driver/src/cmac_shared.c @@ -34,7 +34,7 @@ #define min(_a, _b) ((_a) < (_b) ? (_a) : (_b)) #endif -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) volatile struct cmac_shared_data *g_cmac_shared_data; #include "mcu/da1469x_clock.h" #define MCU_DIAG_SER(_x) @@ -45,7 +45,7 @@ volatile struct cmac_shared_data g_cmac_shared_data __attribute__((section(" void cmac_shared_init(void) { -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) g_cmac_shared_data = (void *)(MCU_MEM_SYSRAM_START_ADDRESS + MEMCTRL->CMI_SHARED_BASE_REG); @@ -77,7 +77,7 @@ cmac_shared_sync(void) * to wait until CMAC finished initialization as otherwise host may start * sending HCI packets which will timeout as there is no one to read them. */ -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) assert(g_cmac_shared_data->magic_sys == 0); while (g_cmac_shared_data->magic_cmac != CMAC_SHARED_MAGIC_CMAC); diff --git a/nimble/transport/dialog_cmac/src/ble_hci_cmac_common.c b/nimble/transport/dialog_cmac/src/ble_hci_cmac_common.c index 665b62166..5a41ee631 100644 --- a/nimble/transport/dialog_cmac/src/ble_hci_cmac_common.c +++ b/nimble/transport/dialog_cmac/src/ble_hci_cmac_common.c @@ -41,6 +41,7 @@ BLE_MBUF_MEMBLOCK_OVERHEAD + \ BLE_HCI_DATA_HDR_SZ, OS_ALIGNMENT) +#if !MYNEWT_VAL(BLE_HCI_BRIDGE) static uint8_t ble_hci_pool_cmd_mempool_buf[ OS_MEMPOOL_BYTES(HCI_CMD_COUNT, BLE_HCI_TRANS_CMD_SZ)]; static struct os_mempool ble_hci_pool_cmd_mempool; @@ -54,6 +55,7 @@ static uint8_t ble_hci_pool_evt_lo_mempool_buf[ OS_MEMPOOL_BYTES(MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT), MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE))]; static struct os_mempool ble_hci_pool_evt_lo_mempool; +#endif static uint8_t ble_hci_pool_acl_mempool_buf[ OS_MEMPOOL_BYTES(MYNEWT_VAL(BLE_ACL_BUF_COUNT), @@ -66,6 +68,7 @@ __attribute__((weak)) void ble_hci_trans_notify_free(void); static os_mempool_put_fn *g_ble_hci_pool_acl_mempool_put_cb; static void *g_ble_hci_pool_acl_mempool_put_arg; +#if !MYNEWT_VAL(BLE_HCI_BRIDGE) int ble_hci_trans_reset(void) { @@ -117,6 +120,7 @@ ble_hci_trans_buf_free(uint8_t *buf) ble_hci_trans_notify_free(); } +#endif struct os_mbuf * ble_hci_cmac_alloc_acl_mbuf(void) @@ -147,6 +151,7 @@ ble_hci_cmac_free_acl_cb(struct os_mempool_ext *mpe, void *data, void *arg) } +#if !MYNEWT_VAL(BLE_HCI_BRIDGE) int ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg) { @@ -155,6 +160,7 @@ ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg) return 0; } +#endif void ble_hci_cmac_init(void) @@ -163,6 +169,7 @@ ble_hci_cmac_init(void) SYSINIT_ASSERT_ACTIVE(); +#if !MYNEWT_VAL(BLE_HCI_BRIDGE) rc = os_mempool_init(&ble_hci_pool_cmd_mempool, HCI_CMD_COUNT, BLE_HCI_TRANS_CMD_SZ, ble_hci_pool_cmd_mempool_buf, "ble_hci_cmd"); @@ -179,6 +186,7 @@ ble_hci_cmac_init(void) MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE), ble_hci_pool_evt_lo_mempool_buf, "ble_hci_evt_lo"); SYSINIT_PANIC_ASSERT(rc == 0); +#endif rc = os_mempool_ext_init(&ble_hci_pool_acl_mempool, MYNEWT_VAL(BLE_ACL_BUF_COUNT), POOL_ACL_BLOCK_SIZE, diff --git a/nimble/transport/dialog_cmac/src/ble_hci_cmac_hs.c b/nimble/transport/dialog_cmac/src/ble_hci_cmac_hs.c index 1164fe718..172fc8795 100644 --- a/nimble/transport/dialog_cmac/src/ble_hci_cmac_hs.c +++ b/nimble/transport/dialog_cmac/src/ble_hci_cmac_hs.c @@ -21,7 +21,7 @@ #include #include "syscfg/syscfg.h" -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) #include "cmac_driver/cmac_shared.h" #include "cmac_driver/cmac_host.h" diff --git a/nimble/transport/dialog_cmac/src/ble_hci_trans_h4.c b/nimble/transport/dialog_cmac/src/ble_hci_trans_h4.c index 74da39123..628ae75d9 100644 --- a/nimble/transport/dialog_cmac/src/ble_hci_trans_h4.c +++ b/nimble/transport/dialog_cmac/src/ble_hci_trans_h4.c @@ -64,7 +64,7 @@ ble_hci_trans_h4_rxs_start(struct ble_hci_trans_h4_rx_state *rxs, uint8_t pkt_ty case BLE_HCI_TRANS_H4_PKT_TYPE_ACL: rxs->min_len = 4; break; -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) case BLE_HCI_TRANS_H4_PKT_TYPE_EVT: rxs->min_len = 2; break; @@ -95,7 +95,7 @@ static int ble_hci_trans_h4_rx_state_w4_header(struct ble_hci_trans_h4_rx_state *rxs, struct input_buffer *ib) { -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) int pool; #endif int rc; @@ -127,7 +127,7 @@ ble_hci_trans_h4_rx_state_w4_header(struct ble_hci_trans_h4_rx_state *rxs, os_mbuf_append(rxs->om, rxs->hdr, rxs->len); rxs->expected_len = get_le16(&rxs->hdr[2]) + 4; break; -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) case BLE_HCI_TRANS_H4_PKT_TYPE_EVT: pool = BLE_HCI_TRANS_BUF_EVT_HI; if (rxs->hdr[0] == BLE_HCI_EVCODE_LE_META) { @@ -194,7 +194,7 @@ ble_hci_trans_h4_rx_state_w4_payload(struct ble_hci_trans_h4_rx_state *rxs, #if MYNEWT_VAL(BLE_CONTROLLER) case BLE_HCI_TRANS_H4_PKT_TYPE_CMD: #endif -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) case BLE_HCI_TRANS_H4_PKT_TYPE_EVT: #endif if (rxs->buf) { @@ -240,7 +240,7 @@ ble_hci_trans_h4_rx_state_completed(struct ble_hci_trans_h4_rx_state *rxs, #if MYNEWT_VAL(BLE_CONTROLLER) case BLE_HCI_TRANS_H4_PKT_TYPE_CMD: #endif -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) case BLE_HCI_TRANS_H4_PKT_TYPE_EVT: #endif if (rxs->buf) { diff --git a/nimble/transport/dialog_cmac/syscfg.yml b/nimble/transport/dialog_cmac/syscfg.yml index c44773efc..54607fd81 100644 --- a/nimble/transport/dialog_cmac/syscfg.yml +++ b/nimble/transport/dialog_cmac/syscfg.yml @@ -16,28 +16,12 @@ # under the License. # -syscfg.defs: - BLE_HCI_EVT_HI_BUF_COUNT: - description: 'Number of high-priority event buffers.' - value: 2 +syscfg.vals.'!BLE_HCI_BRIDGE && !(BLE_EXT_ADV || BLE_LL_CFG_FEAT_LL_EXT_ADV)': + BLE_HCI_EVT_HI_BUF_COUNT: 2 + BLE_HCI_EVT_LO_BUF_COUNT: 8 + BLE_HCI_EVT_BUF_SIZE: 70 + BLE_ACL_BUF_COUNT: 4 + BLE_ACL_BUF_SIZE: 255 - BLE_HCI_EVT_LO_BUF_COUNT: - description: 'Number of low-priority event buffers.' - value: 8 - - BLE_HCI_EVT_BUF_SIZE: - description: 'Size of each event buffer, in bytes.' - value: 70 - - BLE_ACL_BUF_COUNT: - description: 'The number of ACL data buffers' - value: 4 - - BLE_ACL_BUF_SIZE: - description: > - This is the maximum size of the data portion of HCI ACL data - packets. It does not include the HCI data header (of 4 bytes). - value: 255 - -syscfg.vals.'BLE_EXT_ADV || BLE_LL_CFG_FEAT_LL_EXT_ADV': +syscfg.vals.'!BLE_HCI_BRIDGE && (BLE_EXT_ADV || BLE_LL_CFG_FEAT_LL_EXT_ADV)': BLE_HCI_EVT_BUF_SIZE: 257 diff --git a/nimble/transport/emspi/syscfg.yml b/nimble/transport/emspi/syscfg.yml index 4751271b0..501175467 100644 --- a/nimble/transport/emspi/syscfg.yml +++ b/nimble/transport/emspi/syscfg.yml @@ -28,28 +28,6 @@ syscfg.defs: # This is a host-only transport. - BLE_HOST - BLE_HCI_EVT_HI_BUF_COUNT: - description: 'Number of high-priority event buffers.' - value: 2 - - BLE_HCI_EVT_LO_BUF_COUNT: - description: 'Number of low-priority event buffers.' - value: 8 - - BLE_HCI_EVT_BUF_SIZE: - description: 'Size of each event buffer, in bytes.' - value: 70 - - BLE_ACL_BUF_COUNT: - description: 'The number of ACL data buffers' - value: 4 - - BLE_ACL_BUF_SIZE: - description: > - This is the maximum size of the data portion of HCI ACL data - packets. It does not include the HCI data header (of 4 bytes). - value: 255 - BLE_HCI_ACL_OUT_COUNT: description: > This count is used in creating a pool of elements used by the @@ -95,5 +73,12 @@ syscfg.defs: Sysinit stage for the EMSPI BLE transport. value: 100 -syscfg.vals.BLE_EXT_ADV: +syscfg.vals.'!BLE_HCI_BRIDGE && BLE_EXT_ADV': BLE_HCI_EVT_BUF_SIZE: 257 + +syscfg.vals.'!BLE_HCI_BRIDGE && !BLE_EXT_ADV': + BLE_HCI_EVT_HI_BUF_COUNT: 2 + BLE_HCI_EVT_LO_BUF_COUNT: 8 + BLE_HCI_EVT_BUF_SIZE: 70 + BLE_ACL_BUF_COUNT: 4 + BLE_ACL_BUF_SIZE: 255 diff --git a/nimble/transport/nrf5340/src/nrf5340_ble_hci.c b/nimble/transport/nrf5340/src/nrf5340_ble_hci.c index 9bf956b56..fe93c0fd6 100644 --- a/nimble/transport/nrf5340/src/nrf5340_ble_hci.c +++ b/nimble/transport/nrf5340/src/nrf5340_ble_hci.c @@ -39,7 +39,7 @@ #define IPC_RX_CHANNEL 1 #endif -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) #define IPC_TX_CHANNEL 1 #define IPC_RX_CHANNEL 0 #endif @@ -49,7 +49,7 @@ struct nrf5340_ble_hci_api { ble_hci_trans_rx_cmd_fn *cmd_cb; void *cmd_arg; #endif -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) ble_hci_trans_rx_cmd_fn *evt_cb; void *evt_arg; #endif @@ -73,6 +73,7 @@ struct nrf5340_ble_hci_pool_cmd { bool allocated; }; +#if !MYNEWT_VAL(BLE_HCI_BRIDGE) /* * If controller-to-host flow control is enabled we need to hold an extra command * buffer for HCI_Host_Number_Of_Completed_Packets which can be sent at any time. @@ -98,6 +99,8 @@ static uint8_t nrf5340_ble_hci_pool_evt_lo_buf[OS_MEMPOOL_BYTES( MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE))]; static struct os_mempool nrf5340_ble_hci_pool_evt_lo; +#endif + /* Pool for ACL data */ static uint8_t nrf5340_ble_hci_pool_acl_buf[OS_MEMPOOL_BYTES( MYNEWT_VAL(BLE_ACL_BUF_COUNT), @@ -111,12 +114,14 @@ static struct nrf5340_ble_hci_api nrf5340_ble_hci_api; /* State of RX currently in progress (needs to reassemble frame) */ static struct nrf5340_ble_hci_rx_data nrf5340_ble_hci_rx_data; +#if !MYNEWT_VAL(BLE_HCI_BRIDGE) int ble_hci_trans_reset(void) { /* XXX Should we do something with RF and/or BLE core? */ return 0; } +#endif static int ble_hci_trans_acl_tx(struct os_mbuf *om) @@ -177,7 +182,7 @@ ble_hci_trans_ll_acl_tx(struct os_mbuf *om) } #endif -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) void ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *evt_cb, void *evt_arg, ble_hci_trans_rx_acl_fn *acl_cb, void *acl_arg) @@ -212,6 +217,7 @@ ble_hci_trans_hs_acl_tx(struct os_mbuf *om) } #endif +#if !MYNEWT_VAL(BLE_HCI_BRIDGE) uint8_t * ble_hci_trans_buf_alloc(int type) { @@ -255,12 +261,13 @@ ble_hci_trans_buf_free(uint8_t *buf) assert(rc == 0); } } +#endif static void nrf5340_ble_hci_trans_rx_process(int channel) { struct nrf5340_ble_hci_rx_data *rxd = &nrf5340_ble_hci_rx_data; -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) int pool = BLE_HCI_TRANS_BUF_EVT_HI; #endif int rc; @@ -274,7 +281,7 @@ nrf5340_ble_hci_trans_rx_process(int channel) #if MYNEWT_VAL(BLE_CONTROLLER) assert((rxd->type == HCI_PKT_ACL) || (rxd->type == HCI_PKT_CMD)); #endif -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) assert((rxd->type == HCI_PKT_ACL) || (rxd->type == HCI_PKT_EVT)); #endif break; @@ -312,7 +319,7 @@ nrf5340_ble_hci_trans_rx_process(int channel) rxd->type = HCI_PKT_NONE; break; #endif -#if MYNEWT_VAL(BLE_HOST) +#if MYNEWT_VAL(BLE_HOST) || MYNEWT_VAL(BLE_HCI_BRIDGE) case HCI_PKT_EVT: /* header */ if (rxd->len < 2) { @@ -433,6 +440,7 @@ nrf5340_ble_hci_trans_rx(int channel, void *user_data) } } +#if !MYNEWT_VAL(BLE_HCI_BRIDGE) int ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg) { @@ -441,6 +449,7 @@ ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg) return 0; } +#endif void nrf5340_ble_hci_init(void) @@ -460,6 +469,7 @@ nrf5340_ble_hci_init(void) MYNEWT_VAL(BLE_ACL_BUF_COUNT)); SYSINIT_PANIC_ASSERT(rc == 0); +#if !MYNEWT_VAL(BLE_HCI_BRIDGE) rc = os_mempool_init(&nrf5340_ble_hci_pool_evt_hi, MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT), MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE), @@ -479,6 +489,7 @@ nrf5340_ble_hci_init(void) nrf5340_ble_hci_pool_cmd_mempool_buf, "nrf5340_ble_hci_pool_cmd_mempool"); SYSINIT_PANIC_ASSERT(rc == 0); +#endif ipc_nrf5340_recv(IPC_RX_CHANNEL, nrf5340_ble_hci_trans_rx, NULL); } diff --git a/nimble/transport/nrf5340/syscfg.yml b/nimble/transport/nrf5340/syscfg.yml index 1417bbc03..a12e0c373 100644 --- a/nimble/transport/nrf5340/syscfg.yml +++ b/nimble/transport/nrf5340/syscfg.yml @@ -17,34 +17,21 @@ # syscfg.defs: - BLE_HCI_EVT_HI_BUF_COUNT: - description: 'Number of high-priority event buffers.' - value: 2 - - BLE_HCI_EVT_LO_BUF_COUNT: - description: 'Number of low-priority event buffers.' - value: 8 - - BLE_HCI_EVT_BUF_SIZE: - description: 'Size of each event buffer, in bytes.' - value: 70 - - BLE_ACL_BUF_COUNT: - description: 'The number of ACL data buffers' - value: 4 - - BLE_ACL_BUF_SIZE: - description: > - This is the maximum size of the data portion of HCI ACL data - packets. It does not include the HCI data header (of 4 bytes). - value: 255 - BLE_TRANS_NRF5340_SYSINIT_STAGE: description: > Sysinit stage for the RAM BLE transport. value: 100 -syscfg.vals.BLE_EXT_ADV: +syscfg.vals.'!BLE_HCI_BRIDGE: + BLE_HCI_EVT_HI_BUF_COUNT: 2 + BLE_HCI_EVT_LO_BUF_COUNT: 8 + BLE_ACL_BUF_COUNT: 4 + BLE_ACL_BUF_SIZE: 255 + +syscfg.vals.'!BLE_HCI_BRIDGE && !BLE_EXT_ADV': + BLE_HCI_EVT_BUF_SIZE: 70 + +syscfg.vals.'!BLE_HCI_BRIDGE && BLE_EXT_ADV': BLE_HCI_EVT_BUF_SIZE: 257 syscfg.restrictions: diff --git a/nimble/transport/pkg.yml b/nimble/transport/pkg.yml index 8174286d0..5484002eb 100644 --- a/nimble/transport/pkg.yml +++ b/nimble/transport/pkg.yml @@ -52,3 +52,9 @@ pkg.deps.'BLE_HCI_TRANSPORT == "usb"': pkg.deps.'BLE_HCI_TRANSPORT == "nrf5340"': - nimble/transport/nrf5340 + +pkg.deps.'BLE_HCI_BRIDGE_TRANSPORT == "nrf5340"': + - nimble/transport/nrf5340 + +pkg.deps.'BLE_HCI_BRIDGE_TRANSPORT == "dialog_cmac"': + - nimble/transport/dialog_cmac diff --git a/nimble/transport/ram/syscfg.yml b/nimble/transport/ram/syscfg.yml index cbb57163a..6286dfe72 100644 --- a/nimble/transport/ram/syscfg.yml +++ b/nimble/transport/ram/syscfg.yml @@ -17,32 +17,17 @@ # syscfg.defs: - BLE_HCI_EVT_HI_BUF_COUNT: - description: 'Number of high-priority event buffers.' - value: 2 - - BLE_HCI_EVT_LO_BUF_COUNT: - description: 'Number of low-priority event buffers.' - value: 8 - - BLE_HCI_EVT_BUF_SIZE: - description: 'Size of each event buffer, in bytes.' - value: 70 - - BLE_ACL_BUF_COUNT: - description: 'The number of ACL data buffers' - value: 4 - - BLE_ACL_BUF_SIZE: - description: > - This is the maximum size of the data portion of HCI ACL data - packets. It does not include the HCI data header (of 4 bytes). - value: 65535 - BLE_TRANS_RAM_SYSINIT_STAGE: description: > Sysinit stage for the RAM BLE transport. value: 100 +syscfg.vals: + BLE_HCI_EVT_HI_BUF_COUNT: 2 + BLE_HCI_EVT_LO_BUF_COUNT: 8 + BLE_HCI_EVT_BUF_SIZE: 70 + BLE_ACL_BUF_COUNT: 4 + BLE_ACL_BUF_SIZE: 65535 + syscfg.vals.BLE_EXT_ADV: BLE_HCI_EVT_BUF_SIZE: 257 diff --git a/nimble/transport/socket/syscfg.yml b/nimble/transport/socket/syscfg.yml index 2050f6469..9c8fa583d 100644 --- a/nimble/transport/socket/syscfg.yml +++ b/nimble/transport/socket/syscfg.yml @@ -17,24 +17,6 @@ # syscfg.defs: - BLE_HCI_EVT_BUF_SIZE: - description: 'The size of the allocated event buffers' - value: 70 - BLE_HCI_EVT_HI_BUF_COUNT: - description: 'The number of high priority event buffers' - value: 8 - BLE_HCI_EVT_LO_BUF_COUNT: - description: 'The number of low priority event buffers' - value: 8 - BLE_ACL_BUF_COUNT: - description: 'The number of ACL data buffers' - value: 24 - BLE_ACL_BUF_SIZE: - description: > - This is the maximum size of the data portion of HCI ACL data - packets. It does not include the HCI data header (of 4 bytes). - value: 255 - BLE_HCI_ACL_OUT_COUNT: description: > This count is used in creating a pool of elements used by the @@ -75,5 +57,12 @@ syscfg.defs: Sysinit stage for the socket BLE transport. value: 500 -syscfg.vals.BLE_EXT_ADV: +syscfg.vals.'!BLE_HCI_BRIDGE && BLE_EXT_ADV': BLE_HCI_EVT_BUF_SIZE: 257 + +syscfg.vals.'!BLE_HCI_BRIDGE && !BLE_EXT_ADV': + BLE_HCI_EVT_BUF_SIZE: 70 + BLE_HCI_EVT_HI_BUF_COUNT: 8 + BLE_HCI_EVT_LO_BUF_COUNT: 8 + BLE_ACL_BUF_COUNT: 24 + BLE_ACL_BUF_SIZE: 255 diff --git a/nimble/transport/syscfg.yml b/nimble/transport/syscfg.yml index 5bec6adf4..7eed69ba4 100644 --- a/nimble/transport/syscfg.yml +++ b/nimble/transport/syscfg.yml @@ -37,6 +37,47 @@ syscfg.defs: - usb # USB - nrf5340 # nRF5340 + BLE_HCI_BRIDGE_TRANSPORT: + description: > + Selects HCI transport to be included in bridge configuration build. + This applies to multi core configurations where controller runs + on separate core and main core forwards HCI traffic to external host. + This has virtually the same effect as including package dependency + manually, but it allows to easily override HCI transport package in + application or target settings. + This is the transport + value: + choices: + - dialog_cmac # Dialog CMAC via shared memory + - nrf5340 # nRF5340 + + BLE_HCI_BRIDGE: + description: > + External interface (UART/USB/Socket) bridged to second core controller. + value: 0 + + BLE_HCI_EVT_HI_BUF_COUNT: + description: 'Number of high-priority event buffers.' + value: + + BLE_HCI_EVT_LO_BUF_COUNT: + description: 'Number of low-priority event buffers.' + value: + + BLE_HCI_EVT_BUF_SIZE: + description: 'Size of each event buffer, in bytes.' + value: + + BLE_ACL_BUF_COUNT: + description: 'The number of ACL data buffers' + value: + + BLE_ACL_BUF_SIZE: + description: > + This is the maximum size of the data portion of HCI ACL data + packets. + value: + # Deprecated settings BLE_HCI_TRANSPORT_NIMBLE_BUILTIN: description: Use BLE_HCI_TRANSPORT instead. @@ -69,3 +110,10 @@ syscfg.vals.BLE_HCI_TRANSPORT_SOCKET: BLE_HCI_TRANSPORT: socket syscfg.vals.BLE_HCI_TRANSPORT_EMSPI: BLE_HCI_TRANSPORT: emspi + +syscfg.vals.'(MCU_TARGET == "DA14691" || MCU_TARGET == "DA14695" || MCU_TARGET == "DA14697" || MCU_TARGET == "DA14699")': + BLE_HCI_BRIDGE_TRANSPORT: dialog_cmac + +syscfg.vals.'(MCU_TARGET == "nRF5340_APP")': + BLE_HCI_BRIDGE_TRANSPORT: nrf5340 + diff --git a/nimble/transport/uart/src/ble_hci_uart.c b/nimble/transport/uart/src/ble_hci_uart.c index ac49b30b0..cc796c000 100644 --- a/nimble/transport/uart/src/ble_hci_uart.c +++ b/nimble/transport/uart/src/ble_hci_uart.c @@ -53,7 +53,7 @@ */ /* XXX: for now, define this here */ -#if MYNEWT_VAL(BLE_CONTROLLER) +#if MYNEWT_VAL(BLE_CONTROLLER) || MYNEWT_VAL(BLE_HCI_BRIDGE) extern void ble_ll_data_buffer_overflow(void); extern void ble_ll_hw_error(void); @@ -385,7 +385,7 @@ ble_hci_uart_tx_char(void *arg) return rc; } -#if MYNEWT_VAL(BLE_CONTROLLER) +#if MYNEWT_VAL(BLE_CONTROLLER) || MYNEWT_VAL(BLE_HCI_BRIDGE) /** * HCI uart sync lost. * @@ -418,7 +418,7 @@ ble_hci_uart_rx_pkt_type(uint8_t data) switch (ble_hci_uart_state.rx_type) { /* Host should never receive a command! */ -#if MYNEWT_VAL(BLE_CONTROLLER) +#if MYNEWT_VAL(BLE_CONTROLLER) || MYNEWT_VAL(BLE_HCI_BRIDGE) case BLE_HCI_UART_H4_CMD: ble_hci_uart_state.rx_cmd.len = 0; ble_hci_uart_state.rx_cmd.cur = 0; @@ -458,7 +458,7 @@ ble_hci_uart_rx_pkt_type(uint8_t data) break; default: -#if MYNEWT_VAL(BLE_CONTROLLER) +#if MYNEWT_VAL(BLE_CONTROLLER) || MYNEWT_VAL(BLE_HCI_BRIDGE) /* * If we receive an unknown HCI packet type this is considered a loss * of sync. @@ -477,7 +477,7 @@ ble_hci_uart_rx_pkt_type(uint8_t data) return 0; } -#if MYNEWT_VAL(BLE_CONTROLLER) +#if MYNEWT_VAL(BLE_CONTROLLER) || MYNEWT_VAL(BLE_HCI_BRIDGE) /** * HCI uart sync loss. * @@ -708,7 +708,7 @@ ble_hci_uart_rx_acl(uint8_t data) */ if (pktlen > MYNEWT_VAL(BLE_ACL_BUF_SIZE)) { os_mbuf_free_chain(ble_hci_uart_state.rx_acl.buf); -#if MYNEWT_VAL(BLE_CONTROLLER) +#if MYNEWT_VAL(BLE_CONTROLLER) || MYNEWT_VAL(BLE_HCI_BRIDGE) ble_hci_uart_sync_lost(); #else /* @@ -769,7 +769,7 @@ ble_hci_uart_rx_char(void *arg, uint8_t data) switch (ble_hci_uart_state.rx_type) { case BLE_HCI_UART_H4_NONE: return ble_hci_uart_rx_pkt_type(data); -#if MYNEWT_VAL(BLE_CONTROLLER) +#if MYNEWT_VAL(BLE_CONTROLLER) || MYNEWT_VAL(BLE_HCI_BRIDGE) case BLE_HCI_UART_H4_CMD: ble_hci_uart_rx_cmd(data); return 0; @@ -898,6 +898,7 @@ ble_hci_trans_ll_acl_tx(struct os_mbuf *om) return rc; } +#if MYNEWT_VAL(BLE_HOST) /** * Sends an HCI command from the host to the controller. * @@ -955,6 +956,7 @@ ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *cmd_cb, { ble_hci_uart_set_rx_cbs(cmd_cb, cmd_arg, acl_cb, acl_arg); } +#endif /** * Configures the HCI transport to operate with a host. The transport will diff --git a/nimble/transport/uart/syscfg.yml b/nimble/transport/uart/syscfg.yml index 43486a8bf..7eff9517c 100644 --- a/nimble/transport/uart/syscfg.yml +++ b/nimble/transport/uart/syscfg.yml @@ -17,24 +17,6 @@ # syscfg.defs: - BLE_HCI_EVT_BUF_SIZE: - description: 'The size of the allocated event buffers' - value: 70 - BLE_HCI_EVT_HI_BUF_COUNT: - description: 'The number of high priority event buffers' - value: 8 - BLE_HCI_EVT_LO_BUF_COUNT: - description: 'The number of low priority event buffers' - value: 8 - BLE_ACL_BUF_COUNT: - description: 'The number of ACL data buffers' - value: 12 - BLE_ACL_BUF_SIZE: - description: > - This is the maximum size of the data portion of HCI ACL data - packets. It does not include the HCI data header (of 4 bytes). - value: 255 - BLE_HCI_ACL_OUT_COUNT: description: > This count is used in creating a pool of elements used by the @@ -70,3 +52,10 @@ syscfg.defs: syscfg.vals.BLE_EXT_ADV: BLE_HCI_EVT_BUF_SIZE: 257 + +syscfg.vals: + BLE_HCI_EVT_BUF_SIZE: 70 + BLE_HCI_EVT_HI_BUF_COUNT: 8 + BLE_HCI_EVT_LO_BUF_COUNT: 8 + BLE_ACL_BUF_COUNT: 12 + BLE_ACL_BUF_SIZE: 255 diff --git a/nimble/transport/usb/syscfg.yml b/nimble/transport/usb/syscfg.yml index ebc261a23..38effde60 100644 --- a/nimble/transport/usb/syscfg.yml +++ b/nimble/transport/usb/syscfg.yml @@ -17,24 +17,6 @@ # syscfg.defs: - BLE_HCI_EVT_BUF_SIZE: - description: 'The size of the allocated event buffers' - value: 70 - BLE_HCI_EVT_HI_BUF_COUNT: - description: 'The number of high priority event buffers' - value: 8 - BLE_HCI_EVT_LO_BUF_COUNT: - description: 'The number of low priority event buffers' - value: 8 - BLE_ACL_BUF_COUNT: - description: 'The number of ACL data buffers' - value: 12 - BLE_ACL_BUF_SIZE: - description: > - This is the maximum size of the data portion of HCI ACL data - packets. It does not include the HCI data header (of 4 bytes). - value: 255 - BLE_HCI_ACL_OUT_COUNT: description: > This count is used in creating a pool of elements used by the @@ -53,5 +35,12 @@ syscfg.defs: syscfg.vals.BLE_EXT_ADV: BLE_HCI_EVT_BUF_SIZE: 257 +syscfg.vals: + BLE_HCI_EVT_BUF_SIZE: 70 + BLE_HCI_EVT_HI_BUF_COUNT: 8 + BLE_HCI_EVT_LO_BUF_COUNT: 8 + BLE_ACL_BUF_COUNT: 12 + BLE_ACL_BUF_SIZE: 255 + syscfg.restrictions: - '!BLE_HOST'