You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/03/17 10:50:12 UTC

[mynewt-nimble] 02/22: nimble/transport: Add common code for new HCI transport

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit d5201cb83bf0a5f3b9788b0721b656fb22a96223
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Mar 3 18:07:56 2022 +0100

    nimble/transport: Add common code for new HCI transport
---
 nimble/include/nimble/ble_hci_trans.h       | 192 ------------------------
 nimble/transport/include/nimble/transport.h |  55 +++++++
 nimble/transport/pkg.yml                    |  48 +++---
 nimble/transport/src/transport.c            | 217 ++++++++++++++++++++++++++++
 nimble/transport/syscfg.defunct.yml         |  40 +++++
 nimble/transport/syscfg.yml                 | 153 ++++++++------------
 6 files changed, 394 insertions(+), 311 deletions(-)

diff --git a/nimble/include/nimble/ble_hci_trans.h b/nimble/include/nimble/ble_hci_trans.h
deleted file mode 100644
index e8d3ec0..0000000
--- a/nimble/include/nimble/ble_hci_trans.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-
-#ifndef H_HCI_TRANSPORT_
-#define H_HCI_TRANSPORT_
-
-#include <inttypes.h>
-#include "os/os_mempool.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct os_mbuf;
-
-#define BLE_HCI_TRANS_CMD_SZ        260
-
-/*** Type of buffers for holding commands and events. */
-/**
- * Controller-to-host event buffers.  Events have one of two priorities:
- * o Low-priority   (BLE_HCI_TRANS_BUF_EVT_LO)
- * o High-priority  (BLE_HCI_TRANS_BUF_EVT_HI)
- *
- * Low-priority event buffers are only used for advertising reports.  If there
- * are no free low-priority event buffers, then an incoming advertising report
- * will get dropped.
- *
- * High-priority event buffers are for everything except advertising reports.
- * If there are no free high-priority event buffers, a request to allocate one
- * will try to allocate a low-priority buffer instead.
- *
- * If you want all events to be given equal treatment, then you should allocate
- * low-priority events only.
- *
- * Event priorities solve the problem of critical events getting dropped due to
- * a flood of advertising reports.  This solution is likely temporary: when
- * HCI flow control is added, event priorities may become obsolete.
- *
- * Not all transports distinguish between low and high priority events.  If the
- * transport does not have separate settings for low and high buffer counts,
- * then it treats all events with equal priority.
- */
-#define BLE_HCI_TRANS_BUF_EVT_LO    1
-#define BLE_HCI_TRANS_BUF_EVT_HI    2
-
-/* Host-to-controller command. */
-#define BLE_HCI_TRANS_BUF_CMD       3
-
-/** Callback function types; executed when HCI packets are received. */
-typedef int ble_hci_trans_rx_cmd_fn(uint8_t *cmd, void *arg);
-typedef int ble_hci_trans_rx_acl_fn(struct os_mbuf *om, void *arg);
-
-/**
- * Sends an HCI event from the controller to the host.
- *
- * @param cmd                   The HCI event to send.  This buffer must be
- *                                  allocated via ble_hci_trans_buf_alloc().
- *
- * @return                      0 on success;
- *                              A BLE_ERR_[...] error code on failure.
- */
-int ble_hci_trans_ll_evt_tx(uint8_t *hci_ev);
-
-/**
- * Sends ACL data from controller to host.
- *
- * @param om                    The ACL data packet to send.
- *
- * @return                      0 on success;
- *                              A BLE_ERR_[...] error code on failure.
- */
-int ble_hci_trans_ll_acl_tx(struct os_mbuf *om);
-
-/**
- * Sends an HCI command from the host to the controller.
- *
- * @param cmd                   The HCI command to send.  This buffer must be
- *                                  allocated via ble_hci_trans_buf_alloc().
- *
- * @return                      0 on success;
- *                              A BLE_ERR_[...] error code on failure.
- */
-int ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
-
-/**
- * Sends ACL data from host to controller.
- *
- * @param om                    The ACL data packet to send.
- *
- * @return                      0 on success;
- *                              A BLE_ERR_[...] error code on failure.
- */
-int ble_hci_trans_hs_acl_tx(struct os_mbuf *om);
-
-/**
- * Allocates a flat buffer of the specified type.
- *
- * @param type                  The type of buffer to allocate; one of the
- *                                  BLE_HCI_TRANS_BUF_[...] constants.
- *
- * @return                      The allocated buffer on success;
- *                              NULL on buffer exhaustion.
- */
-uint8_t *ble_hci_trans_buf_alloc(int type);
-
-/**
- * Frees the specified flat buffer.  The buffer must have been allocated via
- * ble_hci_trans_buf_alloc().
- *
- * @param buf                   The buffer to free.
- */
-void ble_hci_trans_buf_free(uint8_t *buf);
-
-/**
- * Configures a callback to get executed whenever an ACL data packet is freed.
- * The function is called immediately before the free occurs.
- *
- * @param cb                    The callback to configure.
- * @param arg                   An optional argument to pass to the callback.
- *
- * @return                      0 on success;
- *                              BLE_ERR_UNSUPPORTED if the transport does not
- *                                  support this operation.
- */
-int ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg);
-
-/**
- * Configures the HCI transport to operate with a controller.  The transport
- * will execute specified callbacks upon receiving HCI packets from the host.
- *
- * @param cmd_cb                The callback to execute upon receiving an HCI
- *                                  command.
- * @param cmd_arg               Optional argument to pass to the command
- *                                  callback.
- * @param acl_cb                The callback to execute upon receiving ACL
- *                                  data.
- * @param acl_arg               Optional argument to pass to the ACL
- *                                  callback.
- */
-void ble_hci_trans_cfg_ll(ble_hci_trans_rx_cmd_fn *cmd_cb,
-                          void *cmd_arg,
-                          ble_hci_trans_rx_acl_fn *acl_cb,
-                          void *acl_arg);
-
-/**
- * Configures the HCI transport to operate with a host.  The transport will
- * execute specified callbacks upon receiving HCI packets from the controller.
- *
- * @param evt_cb                The callback to execute upon receiving an HCI
- *                                  event.
- * @param evt_arg               Optional argument to pass to the event
- *                                  callback.
- * @param acl_cb                The callback to execute upon receiving ACL
- *                                  data.
- * @param acl_arg               Optional argument to pass to the ACL
- *                                  callback.
- */
-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);
-
-/**
- * Resets the HCI module to a clean state.  Frees all buffers and reinitializes
- * the underlying transport.
- *
- * @return                      0 on success;
- *                              A BLE_ERR_[...] error code on failure.
- */
-int ble_hci_trans_reset(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_HCI_TRANSPORT_ */
diff --git a/nimble/transport/include/nimble/transport.h b/nimble/transport/include/nimble/transport.h
new file mode 100644
index 0000000..98dba30
--- /dev/null
+++ b/nimble/transport/include/nimble/transport.h
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+#ifndef H_NIMBLE_TRANSPORT_
+#define H_NIMBLE_TRANSPORT_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct os_mbuf;
+
+/* Init functions to be implemented for transport acting as HS/LL side */
+extern void ble_transport_ll_init(void);
+extern void ble_transport_hs_init(void);
+
+/* APIs to be implemented by HS/LL side of transports */
+extern int ble_transport_to_ll_cmd(void *buf);
+extern int ble_transport_to_ll_acl(struct os_mbuf *om);
+extern int ble_transport_to_hs_evt(void *buf);
+extern int ble_transport_to_hs_acl(struct os_mbuf *om);
+
+/* Allocators for supported data types */
+void *ble_transport_alloc_cmd(void);
+void *ble_transport_alloc_evt(int discardable);
+struct os_mbuf *ble_transport_alloc_acl_from_hs(void);
+struct os_mbuf *ble_transport_alloc_acl_from_ll(void);
+
+/* Generic deallocator for cmd/evt buffers */
+void ble_transport_free(void *buf);
+
+/* Register put callback on acl_from_ll mbufs (for ll-hs flow control) */
+int ble_transport_register_put_acl_from_ll_cb(os_mempool_put_fn *cb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_NIMBLE_TRANSPORT_ */
diff --git a/nimble/transport/pkg.yml b/nimble/transport/pkg.yml
index 5484002..287ed97 100644
--- a/nimble/transport/pkg.yml
+++ b/nimble/transport/pkg.yml
@@ -25,36 +25,26 @@ pkg.keywords:
     - ble
     - bluetooth
 
-pkg.deps.'BLE_HCI_TRANSPORT == "builtin"':
-    - nimble/transport/ram
-    - nimble/controller
-
-pkg.deps.'BLE_HCI_TRANSPORT == "emspi"':
-    - nimble/transport/emspi
-
-pkg.deps.'BLE_HCI_TRANSPORT == "ram"':
-    - nimble/transport/ram
-
-pkg.deps.'BLE_HCI_TRANSPORT == "socket"':
-    - nimble/transport/socket
+pkg.apis:
+    - ble_transport
 
-pkg.deps.'BLE_HCI_TRANSPORT == "uart"':
-    - nimble/transport/uart
-
-pkg.deps.'BLE_HCI_TRANSPORT == "da1469x"':
-    - nimble/transport/da1469x
-
-pkg.deps.'BLE_HCI_TRANSPORT == "dialog_cmac"':
+pkg.deps.'BLE_TRANSPORT_HS == "native"':
+    - nimble/host
+pkg.deps.'BLE_TRANSPORT_LL == "native"':
+    - nimble/controller
+pkg.deps.'BLE_TRANSPORT_HS == "dialog_cmac" || BLE_TRANSPORT_LL == "dialog_cmac"':
     - nimble/transport/dialog_cmac
-
-pkg.deps.'BLE_HCI_TRANSPORT == "usb"':
-    - nimble/transport/usb
-
-pkg.deps.'BLE_HCI_TRANSPORT == "nrf5340"':
-    - nimble/transport/nrf5340
-
-pkg.deps.'BLE_HCI_BRIDGE_TRANSPORT == "nrf5340"':
+pkg.deps.'BLE_TRANSPORT_HS == "nrf5340" || BLE_TRANSPORT_LL == "nrf5340"':
     - nimble/transport/nrf5340
+pkg.deps.'BLE_TRANSPORT_HS == "uart"':
+    - nimble/transport/uart
+pkg.deps.'BLE_TRANSPORT_HS == "usb"':
+    - nimble/transport/usb
 
-pkg.deps.'BLE_HCI_BRIDGE_TRANSPORT == "dialog_cmac"':
-    - nimble/transport/dialog_cmac
+pkg.init:
+    ble_transport_init: 250
+    ble_transport_hs_init:
+        - $after:ble_transport_init
+        - $before:ble_transport_ll_init
+    ble_transport_ll_init:
+        - $after:ble_transport_hs_init
diff --git a/nimble/transport/src/transport.c b/nimble/transport/src/transport.c
new file mode 100644
index 0000000..7c868f1
--- /dev/null
+++ b/nimble/transport/src/transport.c
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <stdint.h>
+#include <syscfg/syscfg.h>
+#include <sysinit/sysinit.h>
+#include <os/os_mbuf.h>
+#include <os/os_mempool.h>
+#include <nimble/ble.h>
+#include <nimble/hci_common.h>
+#include <nimble/transport.h>
+
+#define OMP_FLAG_FROM_HS        (0x01)
+#define OMP_FLAG_FROM_LL        (0x02)
+#define OMP_FLAG_FROM_MASK      (0x03)
+
+#if MYNEWT_VAL(BLE_HS_FLOW_CTRL) || \
+    MYNEWT_VAL(BLE_LL_CFG_FEAT_CTRL_TO_HOST_FLOW_CONTROL)
+#define POOL_CMD_COUNT      (2)
+#else
+#define POOL_CMD_COUNT      (1)
+#endif
+#define POOL_CMD_SIZE       (258)
+
+#define POOL_EVT_COUNT      (MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT))
+#define POOL_EVT_LO_COUNT   (MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT))
+#define POOL_EVT_SIZE       (MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE))
+
+#if MYNEWT_VAL_CHOICE(BLE_TRANSPORT_LL, native) && \
+   MYNEWT_VAL_CHOICE(BLE_TRANSPORT_HS, native)
+#define POOL_ACL_COUNT      (0)
+#elif !MYNEWT_VAL_CHOICE(BLE_TRANSPORT_LL, native) && \
+      !MYNEWT_VAL_CHOICE(BLE_TRANSPORT_HS, native)
+#define POOL_ACL_COUNT      ((MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_HS_COUNT)) + \
+                             (MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT)))
+#elif MYNEWT_VAL_CHOICE(BLE_TRANSPORT_LL, native)
+#define POOL_ACL_COUNT      (MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_HS_COUNT))
+#else
+#define POOL_ACL_COUNT      (MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT))
+#endif
+#define POOL_ACL_SIZE       (OS_ALIGN( MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE) + \
+                                       BLE_MBUF_MEMBLOCK_OVERHEAD +         \
+                                       BLE_HCI_DATA_HDR_SZ, OS_ALIGNMENT))
+
+static uint8_t pool_cmd_buf[ OS_MEMPOOL_BYTES(POOL_CMD_COUNT, POOL_CMD_SIZE) ];
+static struct os_mempool pool_cmd;
+
+static uint8_t pool_evt_buf[ OS_MEMPOOL_BYTES(POOL_EVT_COUNT, POOL_EVT_SIZE) ];
+static struct os_mempool pool_evt;
+
+static uint8_t pool_evt_lo_buf[ OS_MEMPOOL_BYTES(POOL_EVT_LO_COUNT, POOL_EVT_SIZE) ];
+static struct os_mempool pool_evt_lo;
+
+static uint8_t pool_acl_buf[ OS_MEMPOOL_BYTES(POOL_ACL_COUNT, POOL_ACL_SIZE) ];
+static struct os_mempool_ext pool_acl;
+static struct os_mbuf_pool mpool_acl;
+
+static os_mempool_put_fn *transport_put_acl_from_ll_cb;
+
+void *
+ble_transport_alloc_cmd(void)
+{
+    return os_memblock_get(&pool_cmd);
+}
+
+void *
+ble_transport_alloc_evt(int discarcable)
+{
+    void *buf;
+
+    if (discarcable) {
+        buf = os_memblock_get(&pool_evt_lo);
+    } else {
+        buf = os_memblock_get(&pool_evt);
+        if (!buf) {
+            buf = os_memblock_get(&pool_evt_lo);
+        }
+    }
+
+    return buf;
+}
+
+struct os_mbuf *
+ble_transport_alloc_acl_from_hs(void)
+{
+    struct os_mbuf *om;
+    struct os_mbuf_pkthdr *pkthdr;
+    uint16_t usrhdr_len;
+
+#if MYNEWT_VAL_CHOICE(BLE_TRANSPORT_LL, native)
+    usrhdr_len = sizeof(struct ble_mbuf_hdr);
+#else
+    usrhdr_len = 0;
+#endif
+
+    om = os_mbuf_get_pkthdr(&mpool_acl, usrhdr_len);
+    if (om) {
+        pkthdr = OS_MBUF_PKTHDR(om);
+        pkthdr->omp_flags = OMP_FLAG_FROM_HS;
+    }
+
+    return om;
+}
+
+struct os_mbuf *
+ble_transport_alloc_acl_from_ll(void)
+{
+    struct os_mbuf *om;
+    struct os_mbuf_pkthdr *pkthdr;
+
+    om = os_mbuf_get_pkthdr(&mpool_acl, 0);
+    if (om) {
+        pkthdr = OS_MBUF_PKTHDR(om);
+        pkthdr->omp_flags = OMP_FLAG_FROM_LL;
+    }
+
+    return om;
+}
+
+void
+ble_transport_free(void *buf)
+{
+    if (os_memblock_from(&pool_cmd, buf)) {
+        os_memblock_put(&pool_cmd, buf);
+    } else if (os_memblock_from(&pool_evt, buf)) {
+        os_memblock_put(&pool_evt, buf);
+    } else if (os_memblock_from(&pool_evt_lo, buf)) {
+        os_memblock_put(&pool_evt_lo, buf);
+    } else {
+        assert(0);
+    }
+}
+
+static os_error_t
+ble_transport_acl_put(struct os_mempool_ext *mpe, void *data, void *arg)
+{
+    struct os_mbuf *om;
+    struct os_mbuf_pkthdr *pkthdr;
+    os_error_t err;
+
+    om = data;
+    pkthdr = OS_MBUF_PKTHDR(om);
+
+    switch (pkthdr->omp_flags & OMP_FLAG_FROM_MASK) {
+    case OMP_FLAG_FROM_LL:
+        if (transport_put_acl_from_ll_cb) {
+            return transport_put_acl_from_ll_cb(mpe, data, arg);
+        }
+        break;
+    case OMP_FLAG_FROM_HS:
+        break;
+    default:
+        assert(0);
+        break;
+    }
+
+    err = os_memblock_put_from_cb(&mpe->mpe_mp, data);
+    if (err) {
+        return err;
+    }
+
+    return 0;
+}
+
+void
+ble_transport_init(void)
+{
+    int rc;
+
+    SYSINIT_ASSERT_ACTIVE();
+
+    rc = os_mempool_init(&pool_cmd, POOL_CMD_COUNT, POOL_CMD_SIZE,
+                         pool_cmd_buf, "transport_pool_cmd");
+    SYSINIT_PANIC_ASSERT(rc == 0);
+
+    rc = os_mempool_init(&pool_evt, POOL_EVT_COUNT, POOL_EVT_SIZE,
+                         pool_evt_buf, "transport_pool_evt");
+    SYSINIT_PANIC_ASSERT(rc == 0);
+
+    rc = os_mempool_init(&pool_evt_lo, POOL_EVT_LO_COUNT, POOL_EVT_SIZE,
+                         pool_evt_lo_buf, "transport_pool_evt_lo");
+    SYSINIT_PANIC_ASSERT(rc == 0);
+
+    rc = os_mempool_ext_init(&pool_acl, POOL_ACL_COUNT, POOL_ACL_SIZE,
+                             pool_acl_buf, "transport_pool_acl");
+    SYSINIT_PANIC_ASSERT(rc == 0);
+
+    rc = os_mbuf_pool_init(&mpool_acl, &pool_acl.mpe_mp,
+                           POOL_ACL_SIZE, POOL_ACL_COUNT);
+    SYSINIT_PANIC_ASSERT(rc == 0);
+
+    pool_acl.mpe_put_cb = ble_transport_acl_put;
+}
+
+int
+ble_transport_register_put_acl_from_ll_cb(os_mempool_put_fn (*cb))
+{
+    transport_put_acl_from_ll_cb = cb;
+
+    return 0;
+}
diff --git a/nimble/transport/syscfg.defunct.yml b/nimble/transport/syscfg.defunct.yml
new file mode 100644
index 0000000..dc18ef4
--- /dev/null
+++ b/nimble/transport/syscfg.defunct.yml
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
+
+syscfg.defs:
+    BLE_HCI_TRANSPORT:
+        description: see doc/transport.md
+        defunct: 1
+    BLE_HCI_BRIDGE:
+        description: see doc/transport.md
+        defunct: 1
+    BLE_HCI_EVT_HI_BUF_COUNT:
+        description: use BLE_TRANSPORT_EVT_COUNT
+        defunct: 1
+    BLE_HCI_EVT_LO_BUF_COUNT:
+        description: use BLE_TRANSPORT_EVT_DISCARDABLE_COUNT
+        defunct: 1
+    BLE_HCI_EVT_BUF_SIZE:
+        description: use BLE_TRANSPORT_EVT_SIZE
+        defunct: 1
+    BLE_ACL_BUF_COUNT:
+        description: use BLE_TRANSPORT_ACL_COUNT
+        defunct: 1
+    BLE_ACL_BUF_SIZE:
+        description: use BLE_TRANSPORT_ACL_SIZE
+        defunct: 1
diff --git a/nimble/transport/syscfg.yml b/nimble/transport/syscfg.yml
index 7eed69b..d2404e1 100644
--- a/nimble/transport/syscfg.yml
+++ b/nimble/transport/syscfg.yml
@@ -17,103 +17,76 @@
 #
 
 syscfg.defs:
-    BLE_HCI_TRANSPORT:
+    BLE_TRANSPORT: 1
+
+    BLE_TRANSPORT_HS:
         description: >
-            Selects HCI transport to be included in build.
-            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.
-        value: builtin
-        restrictions: $notnull
+            Select HCI transport used towards host.
+            "native" means NimBLE host is running on the same core and no
+            transport is required.
+        value: native
         choices:
-            - builtin           # Built-in NimBLE controller and RAM transport
-            - custom            # Custom transport, has to be included manually by user
-            - ram               # RAM transport
-            - uart              # UART HCI H4 transport
-            - socket            # Socket transport (for native builds)
-            - emspi             # SPI transport for EM Microelectionic controllers
-            - da1469x           # Dialog DA1469x integrated controller
-            - dialog_cmac       # Dialog CMAC via shared memory
-            - usb               # USB
-            - nrf5340           # nRF5340
-
-    BLE_HCI_BRIDGE_TRANSPORT:
+            - native
+            - dialog_cmac
+            - nrf5340
+            - uart
+            - usb
+            - custom
+    BLE_TRANSPORT_LL:
         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:
+            Select HCI transport used towards controller.
+            "native" means NimBLE controller is running on the same core and no
+            transport is required.
+        value: native
         choices:
-            - dialog_cmac       # Dialog CMAC via shared memory
-            - nrf5340           # nRF5340
+            - native
+            - dialog_cmac
+            - nrf5340
+            - custom
 
-    BLE_HCI_BRIDGE:
+    BLE_TRANSPORT_ACL_COUNT:
         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:
+            Number of ACL buffers available in transport. This determines
+            number of buffers used by host/controller for flow control.
+            Buffers pool is allocated for each non-native transport side
+            selected, unless overriden by BLE_TRANSPORT_ACL_FROM_[HS|LL]_COUNT.
+        value: 10
+    BLE_TRANSPORT_ACL_SIZE:
+        description: Size of each buffer in ACL pool.
+        value: 255
+    BLE_TRANSPORT_EVT_COUNT:
         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.
-        value: 0
-        deprecated: 1
-    BLE_HCI_TRANSPORT_EMSPI:
-        description: Use BLE_HCI_TRANSPORT instead.
-        value: 0
-        deprecated: 1
-    BLE_HCI_TRANSPORT_RAM:
-        description: Use BLE_HCI_TRANSPORT instead.
-        value: 0
-        deprecated: 1
-    BLE_HCI_TRANSPORT_SOCKET:
-        description: Use BLE_HCI_TRANSPORT instead.
-        value: 0
-        deprecated: 1
-    BLE_HCI_TRANSPORT_UART:
-        description: Use BLE_HCI_TRANSPORT instead.
-        value: 0
-        deprecated: 1
-
-syscfg.vals.BLE_HCI_TRANSPORT_NIMBLE_BUILTIN:
-    BLE_HCI_TRANSPORT: builtin
-syscfg.vals.BLE_HCI_TRANSPORT_RAM:
-    BLE_HCI_TRANSPORT: ram
-syscfg.vals.BLE_HCI_TRANSPORT_UART:
-    BLE_HCI_TRANSPORT: uart
-syscfg.vals.BLE_HCI_TRANSPORT_SOCKET:
-    BLE_HCI_TRANSPORT: socket
-syscfg.vals.BLE_HCI_TRANSPORT_EMSPI:
-    BLE_HCI_TRANSPORT: emspi
+            Number of event buffers available in transport.
+        value: 4
+    BLE_TRANSPORT_EVT_DISCARDABLE_COUNT:
+        description: >
+            Number of discardable event buffers available in transport.
+            Discardable event buffers are used for events that can be safely
+            dropped by controller if there's no free buffer available, e.g.
+            advertising reports.
+        value: 16
+    BLE_TRANSPORT_EVT_SIZE:
+        description: >
+            Size of each buffer in events pool. This applies to both regular
+            and discardable buffers. Value is automatically adjusted if
+            extended advertising is enabled so in most cases it's better to
+            leave it at default settings.
+        value: 70
 
-syscfg.vals.'(MCU_TARGET == "DA14691" || MCU_TARGET == "DA14695" || MCU_TARGET == "DA14697" || MCU_TARGET == "DA14699")':
-    BLE_HCI_BRIDGE_TRANSPORT: dialog_cmac
+    BLE_TRANSPORT_ACL_FROM_HS_COUNT:
+        description: >
+            Overrides BLE_TRANSPORT_ACL_COUNT on host side, i.e. number
+            of ACL buffers available for host.
+        value: MYNEWT_VAL(BLE_TRANSPORT_ACL_COUNT)
+    BLE_TRANSPORT_ACL_FROM_LL_COUNT:
+        description: >
+            Overrides BLE_TRANSPORT_ACL_COUNT on controller side, i.e. number
+            of ACL buffers available for controller.
+        value: MYNEWT_VAL(BLE_TRANSPORT_ACL_COUNT)
 
-syscfg.vals.'(MCU_TARGET == "nRF5340_APP")':
-    BLE_HCI_BRIDGE_TRANSPORT: nrf5340
+# import defunct settings from separate file to reduce clutter in main file
+$import:
+    - "@apache-mynewt-nimble/nimble/transport/syscfg.defunct.yml"
 
+syscfg.vals."BLE_EXT_ADV || BLE_LL_CFG_FEAT_LL_EXT_ADV":
+    BLE_TRANSPORT_EVT_SIZE: 257