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/17 09:00:07 UTC

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

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