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 694d389e2267b333f33891cff4a4bccb7d4b31ff
Author: Mariusz Skamra <[email protected]>
AuthorDate: Wed Jan 8 13:56:04 2025 +0100

    nimble/ll: Move HCI command handler out from ble_ll_isoal
    
    This moves the ISO ralated command handlers out from ISOAL.
    This adds new ble_ll_iso source file that will hold common
    code for ISO connections.
---
 nimble/controller/include/controller/ble_ll_iso.h  |   9 +-
 .../controller/include/controller/ble_ll_isoal.h   |   8 --
 nimble/controller/src/ble_ll_hci.c                 |   6 +-
 nimble/controller/src/ble_ll_iso.c                 | 116 +++++++++++++++++++++
 nimble/controller/src/ble_ll_isoal.c               |  93 +----------------
 5 files changed, 130 insertions(+), 102 deletions(-)

diff --git a/nimble/controller/include/controller/ble_ll_iso.h 
b/nimble/controller/include/controller/ble_ll_iso.h
index 2944b0747..fb20a4f34 100644
--- a/nimble/controller/include/controller/ble_ll_iso.h
+++ b/nimble/controller/include/controller/ble_ll_iso.h
@@ -26,7 +26,8 @@
 extern "C" {
 #endif
 
-int ble_ll_iso_read_tx_sync(const uint8_t *cmdbuf, uint8_t len);
+/* HCI command handlers */
+int ble_ll_iso_read_tx_sync(const uint8_t *cmdbuf, uint8_t len, uint8_t 
*rspbuf, uint8_t *rsplen);
 int ble_ll_iso_set_cig_param(const uint8_t *cmdbuf, uint8_t len, uint8_t 
*rspbuf, uint8_t *rsplen);
 int ble_ll_iso_set_cig_param_test(const uint8_t *cmdbuf, uint8_t len, uint8_t 
*rspbuf, uint8_t *rsplen);
 int ble_ll_iso_create_cis(const uint8_t *cmdbuf, uint8_t len);
@@ -39,13 +40,15 @@ int ble_ll_iso_create_big_test(const uint8_t *cmdbuf, 
uint8_t len);
 int ble_ll_iso_terminate_big(const uint8_t *cmdbuf, uint8_t len);
 int ble_ll_iso_big_create_sync(const uint8_t *cmdbuf, uint8_t len);
 int ble_ll_iso_big_terminate_sync(const uint8_t *cmdbuf, uint8_t len);
-int ble_ll_iso_setup_iso_data_path(const uint8_t *cmdbuf, uint8_t len);
-int ble_ll_iso_remove_iso_data_path(const uint8_t *cmdbuf, uint8_t len);
+int ble_ll_iso_setup_iso_data_path(const uint8_t *cmdbuf, uint8_t len, uint8_t 
*rspbuf, uint8_t *rsplen);
+int ble_ll_iso_remove_iso_data_path(const uint8_t *cmdbuf, uint8_t len, 
uint8_t *rspbuf, uint8_t *rsplen);
 int ble_ll_iso_transmit_test(const uint8_t *cmdbuf, uint8_t len);
 int ble_ll_iso_receive_test(const uint8_t *cmdbuf, uint8_t len);
 int ble_ll_iso_read_counters_test(const uint8_t *cmdbuf, uint8_t len);
 int ble_ll_iso_end_test(const uint8_t *cmdbuf, uint8_t len);
 
+struct ble_ll_isoal_mux *ble_ll_iso_find_mux_by_handle(uint16_t conn_handle);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/nimble/controller/include/controller/ble_ll_isoal.h 
b/nimble/controller/include/controller/ble_ll_isoal.h
index caf15e2d5..3bb7075bc 100644
--- a/nimble/controller/include/controller/ble_ll_isoal.h
+++ b/nimble/controller/include/controller/ble_ll_isoal.h
@@ -70,14 +70,6 @@ int
 ble_ll_isoal_mux_unframed_get(struct ble_ll_isoal_mux *mux, uint8_t idx,
                               uint8_t *llid, void *dptr);
 
-/* HCI command handlers */
-int ble_ll_isoal_hci_setup_iso_data_path(const uint8_t *cmdbuf, uint8_t cmdlen,
-                                         uint8_t *rspbuf, uint8_t *rsplen);
-int ble_ll_isoal_hci_remove_iso_data_path(const uint8_t *cmdbuf, uint8_t 
cmdlen,
-                                          uint8_t *rspbuf, uint8_t *rsplen);
-int ble_ll_isoal_hci_read_tx_sync(const uint8_t *cmdbuf, uint8_t cmdlen,
-                                  uint8_t *rspbuf, uint8_t *rsplen);
-
 void ble_ll_isoal_init(void);
 void ble_ll_isoal_reset(void);
 int ble_ll_isoal_data_in(struct os_mbuf *om);
diff --git a/nimble/controller/src/ble_ll_hci.c 
b/nimble/controller/src/ble_ll_hci.c
index 93fac9d60..e8250284e 100644
--- a/nimble/controller/src/ble_ll_hci.c
+++ b/nimble/controller/src/ble_ll_hci.c
@@ -1287,13 +1287,13 @@ ble_ll_hci_le_cmd_proc(const uint8_t *cmdbuf, uint8_t 
len, uint16_t ocf,
 #endif /* BLE_LL_ISO_BROADCASTER */
 #if MYNEWT_VAL(BLE_LL_ISO)
     case BLE_HCI_OCF_LE_SETUP_ISO_DATA_PATH:
-        rc = ble_ll_isoal_hci_setup_iso_data_path(cmdbuf, len, rspbuf, rsplen);
+        rc = ble_ll_iso_setup_iso_data_path(cmdbuf, len, rspbuf, rsplen);
         break;
     case BLE_HCI_OCF_LE_REMOVE_ISO_DATA_PATH:
-        rc = ble_ll_isoal_hci_remove_iso_data_path(cmdbuf, len, rspbuf, 
rsplen);
+        rc = ble_ll_iso_remove_iso_data_path(cmdbuf, len, rspbuf, rsplen);
         break;
     case BLE_HCI_OCF_LE_READ_ISO_TX_SYNC:
-        rc = ble_ll_isoal_hci_read_tx_sync(cmdbuf, len, rspbuf, rsplen);
+        rc = ble_ll_iso_read_tx_sync(cmdbuf, len, rspbuf, rsplen);
         break;
     case BLE_HCI_OCF_LE_RD_BUF_SIZE_V2:
         if (len == 0) {
diff --git a/nimble/controller/src/ble_ll_iso.c 
b/nimble/controller/src/ble_ll_iso.c
new file mode 100644
index 000000000..46e25ee52
--- /dev/null
+++ b/nimble/controller/src/ble_ll_iso.c
@@ -0,0 +1,116 @@
+/*
+ * 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 <nimble/hci_common.h>
+#include <controller/ble_ll.h>
+#include <controller/ble_ll_isoal.h>
+#include <controller/ble_ll_iso.h>
+#include <controller/ble_ll_iso_big.h>
+
+#if MYNEWT_VAL(BLE_LL_ISO)
+
+int
+ble_ll_iso_setup_iso_data_path(const uint8_t *cmdbuf, uint8_t cmdlen,
+                               uint8_t *rspbuf, uint8_t *rsplen)
+{
+    const struct ble_hci_le_setup_iso_data_path_cp *cmd = (const void *)cmdbuf;
+    struct ble_hci_le_setup_iso_data_path_rp *rsp = (void *)rspbuf;
+    struct ble_ll_iso_bis *bis;
+    uint16_t conn_handle;
+
+    conn_handle = le16toh(cmd->conn_handle);
+    switch (BLE_LL_CONN_HANDLE_TYPE(conn_handle)) {
+    case BLE_LL_CONN_HANDLE_TYPE_BIS:
+        bis = ble_ll_iso_big_find_bis_by_handle(conn_handle);
+        if (bis) {
+            break;
+        }
+    default:
+        return BLE_ERR_UNK_CONN_ID;
+    }
+
+    /* Only input for now since we only support BIS */
+    if (cmd->data_path_dir) {
+        return BLE_ERR_CMD_DISALLOWED;
+    }
+
+    /* We do not (yet) support any vendor-specific data path */
+    if (cmd->data_path_id) {
+        return BLE_ERR_CMD_DISALLOWED;
+    }
+
+    rsp->conn_handle = cmd->conn_handle;
+    *rsplen = sizeof(*rsp);
+
+    return 0;
+}
+
+int
+ble_ll_iso_remove_iso_data_path(const uint8_t *cmdbuf, uint8_t cmdlen,
+                                uint8_t *rspbuf, uint8_t *rsplen)
+{
+    const struct ble_hci_le_remove_iso_data_path_cp *cmd = (const void 
*)cmdbuf;
+    struct ble_hci_le_remove_iso_data_path_rp *rsp = (void *)rspbuf;
+
+    /* XXX accepts anything for now */
+    rsp->conn_handle = cmd->conn_handle;
+    *rsplen = sizeof(*rsp);
+
+    return 0;
+}
+
+int
+ble_ll_iso_read_tx_sync(const uint8_t *cmdbuf, uint8_t cmdlen,
+                        uint8_t *rspbuf, uint8_t *rsplen)
+{
+    const struct ble_hci_le_read_iso_tx_sync_cp *cmd = (const void *)cmdbuf;
+    struct ble_hci_le_read_iso_tx_sync_rp *rsp = (void *)rspbuf;
+    struct ble_ll_isoal_mux *mux;
+    uint16_t handle;
+
+    handle = le16toh(cmd->conn_handle);
+    mux = ble_ll_iso_find_mux_by_handle(handle);
+    if (!mux) {
+        return BLE_ERR_UNK_CONN_ID;
+    }
+
+    rsp->conn_handle = cmd->conn_handle;
+    rsp->packet_seq_num = htole16(mux->last_tx_packet_seq_num);
+    rsp->tx_timestamp = htole32(mux->last_tx_timestamp);
+    put_le24(rsp->time_offset, 0);
+
+    *rsplen = sizeof(*rsp);
+
+    return 0;
+}
+
+struct ble_ll_isoal_mux *
+ble_ll_iso_find_mux_by_handle(uint16_t conn_handle)
+{
+    switch (BLE_LL_CONN_HANDLE_TYPE(conn_handle)) {
+    case BLE_LL_CONN_HANDLE_TYPE_BIS:
+        return ble_ll_iso_big_find_mux_by_handle(conn_handle);
+    default:
+        return NULL;
+    }
+}
+
+#endif /* BLE_LL_ISO */
diff --git a/nimble/controller/src/ble_ll_isoal.c 
b/nimble/controller/src/ble_ll_isoal.c
index d23382c96..8e7bfa4d0 100644
--- a/nimble/controller/src/ble_ll_isoal.c
+++ b/nimble/controller/src/ble_ll_isoal.c
@@ -22,7 +22,7 @@
 #include <nimble/hci_common.h>
 #include <controller/ble_ll.h>
 #include <controller/ble_ll_isoal.h>
-#include <controller/ble_ll_iso_big.h>
+#include <controller/ble_ll_iso.h>
 
 #ifndef min
 #define min(a, b) ((a) < (b) ? (a) : (b))
@@ -309,97 +309,14 @@ ble_ll_isoal_tx_pkt_in(struct ble_npl_event *ev)
             continue;
         }
 
-        switch (BLE_LL_CONN_HANDLE_TYPE(conn_handle)) {
-        case BLE_LL_CONN_HANDLE_TYPE_BIS:
-            mux = ble_ll_iso_big_find_mux_by_handle(conn_handle);
-            ble_ll_isoal_mux_tx_pkt_in(mux, om, pb_flag, timestamp);
-            break;
-        default:
+        mux = ble_ll_iso_find_mux_by_handle(conn_handle);
+        if (!mux) {
             os_mbuf_free_chain(om);
-            break;
-        }
-    }
-}
-
-int
-ble_ll_isoal_hci_setup_iso_data_path(const uint8_t *cmdbuf, uint8_t cmdlen,
-                                     uint8_t *rspbuf, uint8_t *rsplen)
-{
-    const struct ble_hci_le_setup_iso_data_path_cp *cmd = (const void *)cmdbuf;
-    struct ble_hci_le_setup_iso_data_path_rp *rsp = (void *)rspbuf;
-    struct ble_ll_iso_bis *bis;
-    uint16_t conn_handle;
-
-    conn_handle = le16toh(cmd->conn_handle);
-    switch (BLE_LL_CONN_HANDLE_TYPE(conn_handle)) {
-    case BLE_LL_CONN_HANDLE_TYPE_BIS:
-        bis = ble_ll_iso_big_find_bis_by_handle(conn_handle);
-        if (bis) {
-            break;
+            continue;
         }
-    default:
-        return BLE_ERR_UNK_CONN_ID;
-    }
-
-    /* Only input for now since we only support BIS */
-    if (cmd->data_path_dir) {
-        return BLE_ERR_CMD_DISALLOWED;
-    }
-
-    /* We do not (yet) support any vendor-specific data path */
-    if (cmd->data_path_id) {
-        return BLE_ERR_CMD_DISALLOWED;
-    }
-
-    rsp->conn_handle = cmd->conn_handle;
-    *rsplen = sizeof(*rsp);
-
-    return 0;
-}
 
-int
-ble_ll_isoal_hci_remove_iso_data_path(const uint8_t *cmdbuf, uint8_t cmdlen,
-                                      uint8_t *rspbuf, uint8_t *rsplen)
-{
-    const struct ble_hci_le_remove_iso_data_path_cp *cmd = (const void 
*)cmdbuf;
-    struct ble_hci_le_remove_iso_data_path_rp *rsp = (void *)rspbuf;
-
-    /* XXX accepts anything for now */
-    rsp->conn_handle = cmd->conn_handle;
-    *rsplen = sizeof(*rsp);
-
-    return 0;
-}
-
-int
-ble_ll_isoal_hci_read_tx_sync(const uint8_t *cmdbuf, uint8_t cmdlen,
-                              uint8_t *rspbuf, uint8_t *rsplen)
-{
-    const struct ble_hci_le_read_iso_tx_sync_cp *cmd = (const void *)cmdbuf;
-    struct ble_hci_le_read_iso_tx_sync_rp *rsp = (void *)rspbuf;
-    struct ble_ll_isoal_mux *mux;
-    uint16_t handle;
-
-    handle = le16toh(cmd->conn_handle);
-    switch (BLE_LL_CONN_HANDLE_TYPE(handle)) {
-    case BLE_LL_CONN_HANDLE_TYPE_BIS:
-        mux = ble_ll_iso_big_find_mux_by_handle(handle);
-        if (!mux) {
-            return BLE_ERR_UNK_CONN_ID;
-        }
-        break;
-    default:
-        return BLE_ERR_UNK_CONN_ID;
+        ble_ll_isoal_mux_tx_pkt_in(mux, om, pb_flag, timestamp);
     }
-
-    rsp->conn_handle = cmd->conn_handle;
-    rsp->packet_seq_num = htole16(mux->last_tx_packet_seq_num);
-    rsp->tx_timestamp = htole32(mux->last_tx_timestamp);
-    put_le24(rsp->time_offset, 0);
-
-    *rsplen = sizeof(*rsp);
-
-    return 0;
 }
 
 void

Reply via email to