You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2022/03/08 07:46:57 UTC

[GitHub] [mynewt-nimble] andrzej-kaczmarek opened a new pull request #1200: nimble/transport: Refactor HCI transport

andrzej-kaczmarek opened a new pull request #1200:
URL: https://github.com/apache/mynewt-nimble/pull/1200


   This is a huge refactor of HCI transport ot make it - hopefully - easier to maintain and configure.
   
   There's now common code that manages cmd/evt/ACL pools, no need to do this is each transport separately.
   HS and LL no longer use callbacks to register to transport, instead there are dedicated APIs which they use and link directly and thus there's no need for separate RAM transport since both host and controller and host will call directly each other.
   Each transport can implement those APIs and thus act as host or controller side, this makes possible to flexibly select transport on each side and thus removes need for dedicated bridge app - blehci can to the same now.
   Settings and automatic package dependencies were also simplified - app can only include nimble/host and all dependencies and configuration will be applied automatically assuming BSP is properly configured.
   
   See nimble/doc/transport.md for more information.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] andrzej-kaczmarek commented on a change in pull request #1200: nimble/transport: Refactor HCI transport

Posted by GitBox <gi...@apache.org>.
andrzej-kaczmarek commented on a change in pull request #1200:
URL: https://github.com/apache/mynewt-nimble/pull/1200#discussion_r828830498



##########
File path: nimble/controller/src/ble_ll_conn_hci.c
##########
@@ -76,7 +75,7 @@ ble_ll_init_alloc_conn_comp_ev(void)
     rc = 0;
     evbuf = g_ble_ll_conn_comp_ev;
     if (evbuf == NULL) {
-        evbuf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI);
+        evbuf =ble_transport_alloc_evt(0);

Review comment:
       the parameter name is `discardable` so it's pretty clear what `0` and `1` mean here




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] andrzej-kaczmarek commented on a change in pull request #1200: nimble/transport: Refactor HCI transport

Posted by GitBox <gi...@apache.org>.
andrzej-kaczmarek commented on a change in pull request #1200:
URL: https://github.com/apache/mynewt-nimble/pull/1200#discussion_r828831679



##########
File path: 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>
+
+os_mempool_put_fn *transport_put_acl_from_ll_cb;

Review comment:
       I'll investigate and get back to you




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] sjanc commented on a change in pull request #1200: nimble/transport: Refactor HCI transport

Posted by GitBox <gi...@apache.org>.
sjanc commented on a change in pull request #1200:
URL: https://github.com/apache/mynewt-nimble/pull/1200#discussion_r827081638



##########
File path: nimble/transport/common/hci_h4/src/hci_h4.c
##########
@@ -0,0 +1,307 @@
+/*
+ * 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 <assert.h>
+#include <stdint.h>
+#include <string.h>
+#include <syscfg/syscfg.h>
+#include <os/os_mbuf.h>
+#include <nimble/hci_common.h>
+#include <nimble/transport.h>
+#include <nimble/transport/hci_h4.h>
+
+#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
+
+#define HCI_H4_SM_W4_PKT_TYPE   0
+#define HCI_H4_SM_W4_HEADER     1
+#define HCI_H4_SM_W4_PAYLOAD    2
+#define HCI_H4_SM_COMPLETED     3
+
+const struct hci_h4_allocators hci_h4_allocs_from_ll = {
+    .acl = ble_transport_alloc_acl_from_ll,
+    .evt = ble_transport_alloc_evt,
+};
+const struct hci_h4_allocators hci_h4_allocs_from_hs = {
+    .cmd = ble_transport_alloc_cmd,
+    .acl = ble_transport_alloc_acl_from_hs,
+};
+
+struct hci_h4_input_buffer {
+    const uint8_t *buf;
+    uint16_t len;
+};
+int andk;

Review comment:
       :-)

##########
File path: nimble/transport/common/hci_h4/src/hci_h4.c
##########
@@ -0,0 +1,307 @@
+/*
+ * 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 <assert.h>
+#include <stdint.h>
+#include <string.h>
+#include <syscfg/syscfg.h>
+#include <os/os_mbuf.h>
+#include <nimble/hci_common.h>
+#include <nimble/transport.h>
+#include <nimble/transport/hci_h4.h>
+
+#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
+
+#define HCI_H4_SM_W4_PKT_TYPE   0
+#define HCI_H4_SM_W4_HEADER     1
+#define HCI_H4_SM_W4_PAYLOAD    2
+#define HCI_H4_SM_COMPLETED     3
+
+const struct hci_h4_allocators hci_h4_allocs_from_ll = {
+    .acl = ble_transport_alloc_acl_from_ll,
+    .evt = ble_transport_alloc_evt,
+};
+const struct hci_h4_allocators hci_h4_allocs_from_hs = {
+    .cmd = ble_transport_alloc_cmd,
+    .acl = ble_transport_alloc_acl_from_hs,
+};
+
+struct hci_h4_input_buffer {
+    const uint8_t *buf;
+    uint16_t len;
+};
+int andk;
+static void
+hci_h4_frame_start(struct hci_h4_sm *rxs, uint8_t pkt_type)
+{
+    rxs->pkt_type = pkt_type;
+    rxs->len = 0;
+    rxs->exp_len = 0;
+
+    switch (rxs->pkt_type) {
+    case HCI_H4_CMD:
+        rxs->min_len = 3;
+        break;
+    case HCI_H4_ACL:
+        rxs->min_len = 4;
+        break;
+    case HCI_H4_EVT:
+        rxs->min_len = 2;
+        break;
+    default:
+        /* XXX sync loss */
+        assert(0);
+        break;
+    }
+}
+
+static int
+hci_h4_ib_consume(struct hci_h4_input_buffer *ib, uint16_t len)
+{
+    assert(ib->len >= len);
+
+    ib->buf += len;
+    ib->len -= len;
+
+    return len;
+}
+
+static int
+hci_h4_ib_pull_min_len(struct hci_h4_sm *rxs,
+                       struct hci_h4_input_buffer *ib)
+{
+    uint16_t len;
+
+    len = MIN(ib->len, rxs->min_len - rxs->len);
+    memcpy(&rxs->hdr[rxs->len], ib->buf, len);
+
+    rxs->len += len;
+    hci_h4_ib_consume(ib, len);
+
+    return rxs->len != rxs->min_len;
+}
+
+static int
+hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib)
+{
+    int rc;
+
+    rc = hci_h4_ib_pull_min_len(h4sm, ib);
+    if (rc) {
+        /* need more data */
+        return 1;
+    }
+
+    switch (h4sm->pkt_type) {
+    case HCI_H4_CMD:
+        assert(h4sm->allocs && h4sm->allocs->cmd);
+        h4sm->buf = h4sm->allocs->cmd();
+        if (!h4sm->buf) {
+            return -1;
+        }
+
+        memcpy(h4sm->buf, h4sm->hdr, h4sm->len);
+        h4sm->exp_len = h4sm->hdr[2] + 3;
+        break;
+    case HCI_H4_ACL:
+        assert(h4sm->allocs && h4sm->allocs->acl);
+        h4sm->om = h4sm->allocs->acl();
+        if (!h4sm->om) {
+            return -1;
+        }
+
+        os_mbuf_append(h4sm->om, h4sm->hdr, h4sm->len);
+        h4sm->exp_len = get_le16(&h4sm->hdr[2]) + 4;
+        break;
+    case HCI_H4_EVT:
+        if (h4sm->hdr[0] == BLE_HCI_EVCODE_LE_META) {
+            /* For LE Meta event we need 3 bytes to parse header */
+            h4sm->min_len = 3;
+            rc = hci_h4_ib_pull_min_len(h4sm, ib);
+            if (rc) {
+                /* need more data */
+                return 1;
+            }
+        }
+
+        /* TODO lo/hi pool? */
+
+        assert(h4sm->allocs && h4sm->allocs->evt);
+        h4sm->buf = h4sm->allocs->evt(0);
+        if (!h4sm->buf) {
+            return -1;
+        }
+
+        memcpy(h4sm->buf, h4sm->hdr, h4sm->len);
+
+        h4sm->exp_len = h4sm->hdr[1] + 2;
+        break;
+    default:
+        assert(0);
+        break;
+    }
+
+    return 0;
+}
+
+static int
+hci_h4_sm_w4_payload(struct hci_h4_sm *h4sm,
+                     struct hci_h4_input_buffer *ib)
+{
+    uint16_t mbuf_len;
+    uint16_t len;
+    int rc;
+
+    len = min(ib->len, h4sm->exp_len - h4sm->len);
+
+    switch (h4sm->pkt_type) {
+    case HCI_H4_CMD:
+    case HCI_H4_EVT:
+        if (h4sm->buf) {
+            memcpy(&h4sm->buf[h4sm->len], ib->buf, len);
+        }
+        break;
+    case HCI_H4_ACL:
+        assert(h4sm->om);
+
+        mbuf_len = OS_MBUF_PKTLEN(h4sm->om);
+        rc = os_mbuf_append(h4sm->om, ib->buf, len);
+        if (rc) {
+            /* Some data may already be appended so need to adjust h4sm only by
+             * the size of appended data.
+             */
+            len = OS_MBUF_PKTLEN(h4sm->om) - mbuf_len;
+            h4sm->len += len;
+            hci_h4_ib_consume(ib, len);
+
+            return -1;
+        }
+        break;
+    default:
+        assert(0);
+        break;
+    }
+
+    h4sm->len += len;
+    hci_h4_ib_consume(ib, len);
+
+    /* return 1 if need more data */
+    return h4sm->len != h4sm->exp_len;
+}
+
+static void
+hci_h4_sm_completed(struct hci_h4_sm *h4sm)
+{
+    int rc;
+
+    switch (h4sm->pkt_type) {
+    case HCI_H4_CMD:
+    case HCI_H4_EVT:
+        if (h4sm->buf) {
+            assert(h4sm->frame_cb);
+            rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->buf);
+            if (rc != 0) {
+                ble_transport_free(h4sm->buf);
+            }
+            h4sm->buf = NULL;
+        }
+        break;
+    case HCI_H4_ACL:
+        if (h4sm->om) {
+            assert(h4sm->frame_cb);
+            rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->om);
+            if (rc != 0) {
+                os_mbuf_free_chain(h4sm->om);
+            }
+            h4sm->om = NULL;
+        }
+        break;
+    default:
+        assert(0);
+        break;
+    }
+}
+
+int
+hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len)
+{
+    struct hci_h4_input_buffer ib = {
+        .buf = buf,
+        .len = len,
+    };
+
+    int rc = 0;
+    while (ib.len && (rc >= 0)) {
+        rc = 0;
+        switch (h4sm->state) {
+        case HCI_H4_SM_W4_PKT_TYPE:
+            hci_h4_frame_start(h4sm, ib.buf[0]);
+            hci_h4_ib_consume(&ib, 1);
+            h4sm->state = HCI_H4_SM_W4_HEADER;
+        /* no break */
+        case HCI_H4_SM_W4_HEADER:
+            rc = hci_h4_sm_w4_header(h4sm, &ib);
+            if (rc) {
+                break;
+            }
+            h4sm->state = HCI_H4_SM_W4_PAYLOAD;
+        /* no break */
+        case HCI_H4_SM_W4_PAYLOAD:
+            rc = hci_h4_sm_w4_payload(h4sm, &ib);
+            if (rc) {
+                break;
+            }
+            h4sm->state = HCI_H4_SM_COMPLETED;
+        /* no break */
+        case HCI_H4_SM_COMPLETED:
+            hci_h4_sm_completed(h4sm);
+            h4sm->state = HCI_H4_SM_W4_PKT_TYPE;
+            break;
+        default:
+            assert(0);
+            /* consume all remaining data */
+            hci_h4_ib_consume(&ib, ib.len);

Review comment:
       wouldn't this already assert?

##########
File path: babblesim/edtt/hci_transport/syscfg.yml
##########
@@ -31,19 +31,10 @@ syscfg.defs:
         type: task_priority
         value: 2
 
-    BLE_HCI_ACL_OUT_COUNT:
-        description: >
-            This count is used in creating a pool of elements used by the
-            code to enqueue various elements. In the case of the controller
-            only HCI, this number should be equal to the number of mbufs in
-            the msys pool. For host only, it is really dependent on the
-            number of ACL buffers that the controller tells the host it
-            has.
-        value: 12
-
 syscfg.vals:
-    BLE_ACL_BUF_COUNT: 32
-    BLE_ACL_BUF_SIZE: 255
-    BLE_HCI_EVT_BUF_SIZE: 257
-    BLE_HCI_EVT_HI_BUF_COUNT: 32
-    BLE_HCI_EVT_LO_BUF_COUNT: 32
+    BLE_TRANSPORT_ACL_COUNT: 32
+    BLE_TRANSPORT_EVT_COUNT: 64
+
+syscfg.restrictions:
+    - BLE_TRANSPORT_HS == "custom"
+    - BLE_TRANSPORT_LL == "native"

Review comment:
       nitpick

##########
File path: nimble/host/test/src/ble_hs_test_util.c
##########
@@ -2046,3 +2041,9 @@ ble_hs_test_util_init(void)
     /* Clear random address. */
     ble_hs_id_rnd_reset();
 }
+
+void
+ble_transport_ll_init(void)
+{
+    /* nothing here */
+}

Review comment:
       nitpick

##########
File path: nimble/transport/common/hci_h4/src/hci_h4.c
##########
@@ -0,0 +1,307 @@
+/*
+ * 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 <assert.h>
+#include <stdint.h>
+#include <string.h>
+#include <syscfg/syscfg.h>
+#include <os/os_mbuf.h>
+#include <nimble/hci_common.h>
+#include <nimble/transport.h>
+#include <nimble/transport/hci_h4.h>
+
+#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))

Review comment:
       we have min() in os/os.h

##########
File path: 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>
+
+os_mempool_put_fn *transport_put_acl_from_ll_cb;

Review comment:
       can this be static?

##########
File path: nimble/host/syscfg.yml
##########
@@ -497,3 +497,6 @@ syscfg.logs:
 
 syscfg.vals.BLE_MESH:
     BLE_SM_SC: 1
+
+syscfg.restrictions:
+    - BLE_TRANSPORT_HS == "native"

Review comment:
       hmm I'm not sure if I get this restriction

##########
File path: nimble/controller/src/ble_ll_conn_hci.c
##########
@@ -76,7 +75,7 @@ ble_ll_init_alloc_conn_comp_ev(void)
     rc = 0;
     evbuf = g_ble_ll_conn_comp_ev;
     if (evbuf == NULL) {
-        evbuf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI);
+        evbuf =ble_transport_alloc_evt(0);

Review comment:
       I liked how original defines for hi/low made code easy to read,   maybe add BLE_HCI_TRANS_EVT_DISCARDABLE or similar?

##########
File path: nimble/transport/emspi/src/ble_hci_emspi.c
##########
@@ -955,3 +684,15 @@ ble_hci_emspi_init(void)
                       MYNEWT_VAL(BLE_HCI_EMSPI_STACK_SIZE));
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
+
+int
+ble_transport_to_ll_cmd(void *buf)
+{
+    return ble_hci_emspi_cmdevt_tx(buf, BLE_HCI_EMSPI_PKT_CMD);
+}
+
+int
+ble_transport_to_ll_acl(struct os_mbuf *om)
+{
+    return ble_hci_emspi_acl_tx(om);
+}

Review comment:
       nitpick




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] kasjer commented on a change in pull request #1200: nimble/transport: Refactor HCI transport

Posted by GitBox <gi...@apache.org>.
kasjer commented on a change in pull request #1200:
URL: https://github.com/apache/mynewt-nimble/pull/1200#discussion_r828851768



##########
File path: nimble/transport/src/transport.c
##########
@@ -0,0 +1,220 @@
+/*
+ * 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>
+
+os_mempool_put_fn *transport_put_acl_from_ll_cb;
+
+#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;
+
+void *
+ble_transport_alloc_cmd(void)
+{
+    return os_memblock_get(&pool_cmd);
+}
+
+void *
+ble_transport_alloc_evt(int discarcable)

Review comment:
       typo

##########
File path: nimble/doc/transport.md
##########
@@ -0,0 +1,189 @@
+<!--
+#
+# 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.
+#
+-->
+
+# NimBLE HCI transport
+
+## Overview
+
+Transport is split into host (HS) and controller (LL) sides. Those do not
+necessarily represent actual host/controller, they can be just interfaces to
+external host (e.g. UART or USB) or  controller (e.g.IPC to LL running on
+another core).
+
+```
++----------+                       +----------+
+| cmd pool |                       | evt pool |
++----------+                       +----------+
+| acl pool |                       | acl pool |
++----------+                       +----------+
+  ||                                       ||
++----+                                   +----+
+|    | <--- ble_transport_to_ll_acl ---- |    |
+|    | <--- ble_transport_to_ll_evt ---- |    |
+| HS |                                   | LL |
+|    | ---- ble_transport_to_ll_cmd ---> |    |
+|    | ---- ble_transport_to_ll_cmd ---> |    |

Review comment:
       are those line intentionally the same?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] andrzej-kaczmarek commented on a change in pull request #1200: nimble/transport: Refactor HCI transport

Posted by GitBox <gi...@apache.org>.
andrzej-kaczmarek commented on a change in pull request #1200:
URL: https://github.com/apache/mynewt-nimble/pull/1200#discussion_r828831558



##########
File path: nimble/host/syscfg.yml
##########
@@ -497,3 +497,6 @@ syscfg.logs:
 
 syscfg.vals.BLE_MESH:
     BLE_SM_SC: 1
+
+syscfg.restrictions:
+    - BLE_TRANSPORT_HS == "native"

Review comment:
       this is to make sure transport on hs side is not overridden to something else when an actual host is included in build - such conbination would not make sense




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] andrzej-kaczmarek merged pull request #1200: nimble/transport: Refactor HCI transport

Posted by GitBox <gi...@apache.org>.
andrzej-kaczmarek merged pull request #1200:
URL: https://github.com/apache/mynewt-nimble/pull/1200


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org