Bluetooth: drivers: Update to use new H:4 buffer encoding
Update all HCI drivers to use the new H:4 encoding for buffers passing to/from drivers. One behavioral change that's done in favor of simplicity, is that where there's previously been switch statements that could return an error for unsupported packet types now simply pass any received packet unchanged to lower layers of the controller (or the HCI transport). Handling this is now the responsibility of the lower layers, however in practice hitting such scenarios means that there's a mismatch between configured host and controller features. Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
This commit is contained in:
committed by
Benjamin Cabé
parent
26d97164be
commit
6113230ce3
@@ -348,12 +348,6 @@ static inline void read_payload(const struct device *dev)
|
||||
buf = h4->rx.buf;
|
||||
h4->rx.buf = NULL;
|
||||
|
||||
if (h4->rx.type == BT_HCI_H4_EVT) {
|
||||
bt_buf_set_type(buf, BT_BUF_EVT);
|
||||
} else {
|
||||
bt_buf_set_type(buf, BT_BUF_ACL_IN);
|
||||
}
|
||||
|
||||
reset_rx(h4);
|
||||
|
||||
LOG_DBG("Putting buf %p to rx fifo", buf);
|
||||
@@ -411,33 +405,6 @@ static inline void process_tx(const struct device *dev)
|
||||
}
|
||||
}
|
||||
|
||||
if (!h4->tx.type) {
|
||||
switch (bt_buf_get_type(h4->tx.buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
h4->tx.type = BT_HCI_H4_ACL;
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
h4->tx.type = BT_HCI_H4_CMD;
|
||||
break;
|
||||
case BT_BUF_ISO_OUT:
|
||||
if (IS_ENABLED(CONFIG_BT_ISO)) {
|
||||
h4->tx.type = BT_HCI_H4_ISO;
|
||||
break;
|
||||
}
|
||||
__fallthrough;
|
||||
default:
|
||||
LOG_ERR("Unknown buffer type");
|
||||
goto done;
|
||||
}
|
||||
|
||||
bytes = uart_fifo_fill(cfg->uart, &h4->tx.type, 1);
|
||||
if (bytes != 1) {
|
||||
LOG_WRN("Unable to send H:4 type");
|
||||
h4->tx.type = BT_HCI_H4_NONE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bytes = uart_fifo_fill(cfg->uart, h4->tx.buf->data, h4->tx.buf->len);
|
||||
if (unlikely(bytes < 0)) {
|
||||
LOG_ERR("Unable to write to UART (err %d)", bytes);
|
||||
@@ -449,7 +416,6 @@ static inline void process_tx(const struct device *dev)
|
||||
return;
|
||||
}
|
||||
|
||||
done:
|
||||
h4->tx.type = BT_HCI_H4_NONE;
|
||||
net_buf_unref(h4->tx.buf);
|
||||
h4->tx.buf = k_fifo_get(&h4->tx.fifo, K_NO_WAIT);
|
||||
@@ -499,7 +465,7 @@ static int h4_send(const struct device *dev, struct net_buf *buf)
|
||||
const struct h4_config *cfg = dev->config;
|
||||
struct h4_data *h4 = dev->data;
|
||||
|
||||
LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
LOG_DBG("buf %p type %u len %u", buf, buf->data[0], buf->len);
|
||||
|
||||
k_fifo_put(&h4->tx.fifo, buf);
|
||||
uart_irq_tx_enable(cfg->uart);
|
||||
|
||||
@@ -598,26 +598,8 @@ static uint8_t h5_get_type(struct net_buf *buf)
|
||||
static int h5_queue(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
struct h5_data *h5 = dev->data;
|
||||
uint8_t type;
|
||||
|
||||
LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_CMD:
|
||||
type = HCI_COMMAND_PKT;
|
||||
break;
|
||||
case BT_BUF_ACL_OUT:
|
||||
type = HCI_ACLDATA_PKT;
|
||||
break;
|
||||
case BT_BUF_ISO_OUT:
|
||||
type = HCI_ISODATA_PKT;
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Unknown packet type %u", bt_buf_get_type(buf));
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(net_buf_push(buf, sizeof(type)), &type, sizeof(type));
|
||||
LOG_DBG("buf %p type %u len %u", buf, buf->data[0], buf->len);
|
||||
|
||||
k_fifo_put(&h5->tx_queue, buf);
|
||||
|
||||
|
||||
@@ -344,27 +344,13 @@ static void bt_spi_rx_thread(void *p1, void *p2, void *p3)
|
||||
|
||||
static int bt_apollo_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
/* Buffer needs an additional byte for type */
|
||||
if (buf->len >= SPI_MAX_TX_MSG_LEN) {
|
||||
if (buf->len > SPI_MAX_TX_MSG_LEN) {
|
||||
LOG_ERR("Message too long");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ACL);
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_CMD);
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Unsupported type");
|
||||
net_buf_unref(buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Send the SPI packet */
|
||||
ret = spi_send_packet(buf->data, buf->len);
|
||||
|
||||
|
||||
@@ -330,12 +330,6 @@ static inline void read_payload(void)
|
||||
buf = rx.buf;
|
||||
rx.buf = NULL;
|
||||
|
||||
if (rx.type == BT_HCI_H4_EVT) {
|
||||
bt_buf_set_type(buf, BT_BUF_EVT);
|
||||
} else {
|
||||
bt_buf_set_type(buf, BT_BUF_ACL_IN);
|
||||
}
|
||||
|
||||
reset_rx();
|
||||
|
||||
LOG_DBG("Putting buf %p to rx fifo", buf);
|
||||
@@ -474,20 +468,6 @@ static int bt_da1469x_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
LOG_DBG("ACL: buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ACL);
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
LOG_DBG("CMD: buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
net_buf_push_u8(buf, BT_HCI_H4_CMD);
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Unsupported type");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cmac_mbox_write(buf->data, buf->len);
|
||||
|
||||
net_buf_unref(buf);
|
||||
|
||||
@@ -237,25 +237,8 @@ static esp_vhci_host_callback_t vhci_host_cb = {
|
||||
static int bt_esp32_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
int err = 0;
|
||||
uint8_t pkt_indicator;
|
||||
|
||||
LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
pkt_indicator = BT_HCI_H4_ACL;
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
pkt_indicator = BT_HCI_H4_CMD;
|
||||
break;
|
||||
case BT_BUF_ISO_OUT:
|
||||
pkt_indicator = BT_HCI_H4_ISO;
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Unknown type %u", bt_buf_get_type(buf));
|
||||
goto done;
|
||||
}
|
||||
net_buf_push_u8(buf, pkt_indicator);
|
||||
LOG_DBG("buf %p type %u len %u", buf, buf->data[0], buf->len);
|
||||
|
||||
LOG_HEXDUMP_DBG(buf->data, buf->len, "Final HCI buffer:");
|
||||
|
||||
@@ -270,7 +253,6 @@ static int bt_esp32_send(const struct device *dev, struct net_buf *buf)
|
||||
err = -ETIMEDOUT;
|
||||
}
|
||||
|
||||
done:
|
||||
net_buf_unref(buf);
|
||||
k_sem_give(&hci_send_sem);
|
||||
|
||||
|
||||
@@ -257,32 +257,36 @@ static int cyw208xx_close(const struct device *dev)
|
||||
|
||||
static int cyw208xx_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
uint8_t type;
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
k_sem_take(&hci_sem, K_FOREVER);
|
||||
|
||||
LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
type = net_buf_pull_u8(buf);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
LOG_DBG("buf %p type %u len %u", buf, type, buf->len);
|
||||
|
||||
switch (type) {
|
||||
case BT_HCI_H4_ACL:
|
||||
uint8_t *bt_msg = host_stack_get_acl_to_lower_buffer(BT_TRANSPORT_LE, buf->len);
|
||||
|
||||
memcpy(bt_msg, buf->data, buf->len);
|
||||
ret = host_stack_send_acl_to_lower(BT_TRANSPORT_LE, bt_msg, buf->len);
|
||||
break;
|
||||
|
||||
case BT_BUF_CMD:
|
||||
case BT_HCI_H4_CMD:
|
||||
ret = host_stack_send_cmd_to_lower(buf->data, buf->len);
|
||||
break;
|
||||
|
||||
case BT_BUF_ISO_OUT:
|
||||
case BT_HCI_H4_ISO:
|
||||
ret = host_stack_send_iso_to_lower(buf->data, buf->len);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERR("Unknown type %u", bt_buf_get_type(buf));
|
||||
LOG_ERR("Unknown type %u", type);
|
||||
ret = EIO;
|
||||
goto done;
|
||||
}
|
||||
@@ -376,7 +380,6 @@ void wiced_bt_process_hci(hci_packet_type_t pti, uint8_t *data, uint32_t length)
|
||||
LOG_ERR("Failed to allocate the buffer for RX: ACL ");
|
||||
return;
|
||||
}
|
||||
bt_buf_set_type(buf, BT_BUF_ACL_IN);
|
||||
break;
|
||||
|
||||
case HCI_PACKET_TYPE_SCO:
|
||||
|
||||
@@ -126,10 +126,8 @@ static void psoc6_bless_events_handler(uint32_t eventCode, void *eventParam)
|
||||
LOG_ERR("Failed to allocate the buffer for RX: ACL ");
|
||||
return;
|
||||
}
|
||||
bt_buf_set_type(buf, BT_BUF_ACL_IN);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_WRN("Unsupported HCI Packet Received");
|
||||
return;
|
||||
@@ -168,21 +166,10 @@ static int psoc6_bless_send(const struct device *dev, struct net_buf *buf)
|
||||
|
||||
memset(&hci_tx_pkt, 0, sizeof(cy_stc_ble_hci_tx_packet_info_t));
|
||||
|
||||
hci_tx_pkt.packetType = net_buf_pull_u8(buf);
|
||||
hci_tx_pkt.dataLength = buf->len;
|
||||
hci_tx_pkt.data = buf->data;
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
hci_tx_pkt.packetType = BT_HCI_H4_ACL;
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
hci_tx_pkt.packetType = BT_HCI_H4_CMD;
|
||||
break;
|
||||
default:
|
||||
net_buf_unref(buf);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (k_sem_take(&psoc6_bless_operation_sem, K_MSEC(BLE_LOCK_TMOUT_MS)) != 0) {
|
||||
LOG_ERR("Failed to acquire BLE DRV Semaphore");
|
||||
net_buf_unref(buf);
|
||||
|
||||
@@ -403,23 +403,8 @@ static void hci_rx_cb(uint8_t packetType, uint8_t *data, uint16_t len)
|
||||
|
||||
static int bt_nxp_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
uint8_t packetType;
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_CMD:
|
||||
packetType = BT_HCI_H4_CMD;
|
||||
break;
|
||||
case BT_BUF_ACL_OUT:
|
||||
packetType = BT_HCI_H4_ACL;
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Not supported type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
net_buf_push_u8(buf, packetType);
|
||||
#if defined(HCI_NXP_LOCK_STANDBY_BEFORE_SEND)
|
||||
/* Sending an HCI message requires to wake up the controller core if it's asleep.
|
||||
* Platform controllers may send reponses using non wakeable interrupts which can
|
||||
|
||||
@@ -195,28 +195,12 @@ uint32_t hci_common_transport_transmit(uint8_t *data, int16_t len)
|
||||
|
||||
static int slz_bt_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
int rv = 0;
|
||||
int rv;
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ACL);
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_CMD);
|
||||
break;
|
||||
default:
|
||||
rv = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
rv = hci_common_transport_receive(buf->data, buf->len, true);
|
||||
if (!rv) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
net_buf_unref(buf);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -36,22 +36,8 @@ static int siwx91x_bt_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
struct hci_data *hci = dev->data;
|
||||
int sc = -EOVERFLOW;
|
||||
uint8_t packet_type = BT_HCI_H4_NONE;
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
packet_type = BT_HCI_H4_ACL;
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
packet_type = BT_HCI_H4_CMD;
|
||||
break;
|
||||
default:
|
||||
sc = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((packet_type != BT_HCI_H4_NONE) && (buf->len < sizeof(hci->rsi_data_packet.data))) {
|
||||
net_buf_push_u8(buf, packet_type);
|
||||
if (buf->len < sizeof(hci->rsi_data_packet.data)) {
|
||||
memcpy(&hci->rsi_data_packet, buf->data, buf->len);
|
||||
sc = rsi_bt_driver_send_cmd(RSI_BLE_REQ_HCI_RAW, &hci->rsi_data_packet, NULL);
|
||||
/* TODO SILABS ZEPHYR Convert to errno. A common function from rsi/sl_status should
|
||||
|
||||
@@ -569,23 +569,6 @@ static int bt_spi_send(const struct device *dev, struct net_buf *buf)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ACL);
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_CMD);
|
||||
break;
|
||||
#if defined(CONFIG_BT_ISO)
|
||||
case BT_BUF_ISO_OUT:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ISO);
|
||||
break;
|
||||
#endif /* CONFIG_BT_ISO */
|
||||
default:
|
||||
LOG_ERR("Unsupported type");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Wait for SPI bus to be available */
|
||||
k_sem_take(&sem_busy, K_FOREVER);
|
||||
data_ptr = buf->data;
|
||||
|
||||
@@ -201,7 +201,7 @@ void send_event(uint8_t *buffer_out, uint16_t buffer_out_length, int8_t overflow
|
||||
|
||||
if (buf) {
|
||||
/* Handle the received HCI data */
|
||||
LOG_DBG("New event %p len %u type %u", buf, buf->len, bt_buf_get_type(buf));
|
||||
LOG_DBG("New event %p len %u type %u", buf, buf->len, buf->data[0]);
|
||||
hci->recv(dev, buf);
|
||||
} else {
|
||||
LOG_ERR("Buf is null");
|
||||
@@ -371,12 +371,13 @@ static struct net_buf *get_rx(uint8_t *msg)
|
||||
static int bt_hci_stm32wb0_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8_t type = net_buf_pull_u8(buf);
|
||||
uint8_t *hci_buffer = buf->data;
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT: {
|
||||
switch (type) {
|
||||
case BT_HCI_H4_ACL: {
|
||||
uint16_t connection_handle;
|
||||
uint16_t data_len;
|
||||
uint8_t *pdu;
|
||||
@@ -392,7 +393,7 @@ static int bt_hci_stm32wb0_send(const struct device *dev, struct net_buf *buf)
|
||||
break;
|
||||
}
|
||||
#if defined(CONFIG_BT_ISO)
|
||||
case BT_BUF_ISO_OUT: {
|
||||
case BT_HCI_H4_ISO: {
|
||||
uint16_t connection_handle;
|
||||
uint16_t iso_data_load_len;
|
||||
uint8_t *iso_data_load;
|
||||
@@ -409,7 +410,7 @@ static int bt_hci_stm32wb0_send(const struct device *dev, struct net_buf *buf)
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BT_ISO */
|
||||
case BT_BUF_CMD:
|
||||
case BT_HCI_H4_CMD:
|
||||
process_command(hci_buffer, buf->len, buffer_out_mem, sizeof(buffer_out_mem));
|
||||
send_event(buffer_out_mem, 0, 0);
|
||||
break;
|
||||
|
||||
@@ -302,31 +302,13 @@ uint8_t BLECB_Indication(const uint8_t *data, uint16_t length,
|
||||
static int bt_hci_stm32wba_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
uint16_t event_length;
|
||||
uint8_t pkt_indicator;
|
||||
uint8_t tx_buffer[BLE_CTRLR_STACK_BUFFER_SIZE];
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
k_sem_take(&hci_sem, K_FOREVER);
|
||||
|
||||
LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
pkt_indicator = BT_HCI_H4_ACL;
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
pkt_indicator = BT_HCI_H4_CMD;
|
||||
break;
|
||||
case BT_BUF_ISO_OUT:
|
||||
pkt_indicator = BT_HCI_H4_ISO;
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Unknown type %u", bt_buf_get_type(buf));
|
||||
k_sem_give(&hci_sem);
|
||||
return -EIO;
|
||||
}
|
||||
net_buf_push_u8(buf, pkt_indicator);
|
||||
LOG_DBG("buf %p type %u len %u", buf, buf->data[0], buf->len);
|
||||
|
||||
memcpy(&tx_buffer, buf->data, buf->len);
|
||||
|
||||
|
||||
@@ -264,28 +264,8 @@ static int bt_ipc_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
struct ipc_data *data = dev->data;
|
||||
int err;
|
||||
uint8_t pkt_indicator;
|
||||
|
||||
LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
pkt_indicator = BT_HCI_H4_ACL;
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
pkt_indicator = BT_HCI_H4_CMD;
|
||||
break;
|
||||
case BT_BUF_ISO_OUT:
|
||||
pkt_indicator = BT_HCI_H4_ISO;
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Unknown type %u", bt_buf_get_type(buf));
|
||||
err = -ENOMSG;
|
||||
goto done;
|
||||
}
|
||||
net_buf_push_u8(buf, pkt_indicator);
|
||||
|
||||
LOG_HEXDUMP_DBG(buf->data, buf->len, "Final HCI buffer:");
|
||||
LOG_DBG("buf %p type %u len %u", buf, buf->data[0], buf->len);
|
||||
|
||||
for (int retries = 0; retries < CONFIG_BT_HCI_IPC_SEND_RETRY_COUNT + 1; retries++) {
|
||||
err = ipc_service_send(&data->hci_ept, buf->data, buf->len);
|
||||
@@ -306,7 +286,6 @@ static int bt_ipc_send(const struct device *dev, struct net_buf *buf)
|
||||
err = 0;
|
||||
}
|
||||
|
||||
done:
|
||||
net_buf_unref(buf);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -361,22 +361,19 @@ static int bt_ipm_send(const struct device *dev, struct net_buf *buf)
|
||||
|
||||
k_sem_take(&ipm_busy, K_FOREVER);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
LOG_DBG("ACL: buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
switch (buf->data[0]) {
|
||||
case BT_HCI_H4_ACL:
|
||||
LOG_DBG("ACL: buf %p type %u len %u", buf, buf->data[0], buf->len);
|
||||
k_sem_take(&acl_data_ack, K_FOREVER);
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ACL);
|
||||
memcpy((void *)
|
||||
&((TL_AclDataPacket_t *)HciAclDataBuffer)->AclDataSerial,
|
||||
memcpy((void *)&((TL_AclDataPacket_t *)HciAclDataBuffer)->AclDataSerial,
|
||||
buf->data, buf->len);
|
||||
TL_BLE_SendAclData(NULL, 0);
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
LOG_DBG("CMD: buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
ble_cmd_buff->cmdserial.type = BT_HCI_H4_CMD;
|
||||
case BT_HCI_H4_CMD:
|
||||
LOG_DBG("CMD: buf %p type %u len %u", buf, buf->data[0], buf->len);
|
||||
ble_cmd_buff->cmdserial.type = net_buf_pull_u8(buf);
|
||||
ble_cmd_buff->cmdserial.cmd.plen = buf->len;
|
||||
memcpy((void *)&ble_cmd_buff->cmdserial.cmd, buf->data,
|
||||
buf->len);
|
||||
memcpy((void *)&ble_cmd_buff->cmdserial.cmd, buf->data, buf->len);
|
||||
TL_BLE_SendCmd(NULL, 0);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -318,19 +318,6 @@ static int bt_spi_send(const struct device *dev, struct net_buf *buf)
|
||||
/* Wait for SPI bus to be available */
|
||||
k_sem_take(&sem_busy, K_FOREVER);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ACL);
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_CMD);
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Unsupported type");
|
||||
k_sem_give(&sem_busy);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = bt_spi_get_header(SPI_WRITE, &size);
|
||||
size = MIN(buf->len, size);
|
||||
|
||||
|
||||
@@ -267,31 +267,13 @@ static int uc_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
struct uc_data *uc = dev->data;
|
||||
|
||||
LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
|
||||
LOG_DBG("buf %p type %u len %u", buf, buf->data[0], buf->len);
|
||||
|
||||
if (uc->fd < 0) {
|
||||
LOG_ERR("User channel not open");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ACL);
|
||||
break;
|
||||
case BT_BUF_CMD:
|
||||
net_buf_push_u8(buf, BT_HCI_H4_CMD);
|
||||
break;
|
||||
case BT_BUF_ISO_OUT:
|
||||
if (IS_ENABLED(CONFIG_BT_ISO)) {
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ISO);
|
||||
break;
|
||||
}
|
||||
__fallthrough;
|
||||
default:
|
||||
LOG_ERR("Unknown buffer type");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (nsi_host_write(uc->fd, buf->data, buf->len) < 0) {
|
||||
return -nsi_host_get_errno();
|
||||
}
|
||||
|
||||
@@ -5210,8 +5210,7 @@ static void vs_read_tx_power_level(struct net_buf *buf, struct net_buf **evt)
|
||||
|
||||
#if defined(CONFIG_BT_HCI_VS_FATAL_ERROR)
|
||||
/* A memory pool for vandor specific events for fatal error reporting purposes. */
|
||||
NET_BUF_POOL_FIXED_DEFINE(vs_err_tx_pool, 1, BT_BUF_EVT_RX_SIZE,
|
||||
sizeof(struct bt_buf_data), NULL);
|
||||
NET_BUF_POOL_FIXED_DEFINE(vs_err_tx_pool, 1, BT_BUF_EVT_RX_SIZE, 0, NULL);
|
||||
|
||||
/* The alias for convenience of Controller HCI implementation. Controller is build for
|
||||
* a particular architecture hence the alias will allow to avoid conditional compilation.
|
||||
@@ -5244,8 +5243,7 @@ static struct net_buf *vs_err_evt_create(uint8_t subevt, uint8_t len)
|
||||
struct bt_hci_evt_le_meta_event *me;
|
||||
struct bt_hci_evt_hdr *hdr;
|
||||
|
||||
net_buf_reserve(buf, BT_BUF_RESERVE);
|
||||
bt_buf_set_type(buf, BT_BUF_EVT);
|
||||
net_buf_add_u8(buf, BT_HCI_H4_EVT);
|
||||
|
||||
hdr = net_buf_add(buf, sizeof(*hdr));
|
||||
hdr->evt = BT_HCI_EVT_VENDOR;
|
||||
|
||||
@@ -98,7 +98,8 @@ isoal_status_t sink_sdu_alloc_hci(const struct isoal_sink *sink_ctx,
|
||||
|
||||
if (buf) {
|
||||
/* Increase reserved space for headers */
|
||||
net_buf_reserve(buf, SDU_HCI_HDR_SIZE + net_buf_headroom(buf));
|
||||
net_buf_reset(buf);
|
||||
net_buf_reserve(buf, BT_BUF_RESERVE + SDU_HCI_HDR_SIZE);
|
||||
|
||||
sdu_buffer->dbuf = buf;
|
||||
sdu_buffer->size = net_buf_tailroom(buf);
|
||||
@@ -197,6 +198,8 @@ isoal_status_t sink_sdu_emit_hci(const struct isoal_sink *sink_ctx,
|
||||
hdr->handle = sys_cpu_to_le16(handle_packed);
|
||||
hdr->len = sys_cpu_to_le16(len);
|
||||
|
||||
net_buf_push_u8(buf, BT_HCI_H4_ISO);
|
||||
|
||||
/* send fragment up the chain */
|
||||
data->recv(dev, buf);
|
||||
}
|
||||
@@ -268,8 +271,8 @@ static int bt_recv_prio(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
const struct hci_driver_data *data = dev->data;
|
||||
|
||||
if (bt_buf_get_type(buf) == BT_BUF_EVT) {
|
||||
struct bt_hci_evt_hdr *hdr = (void *)buf->data;
|
||||
if (buf->data[0] == BT_HCI_H4_EVT) {
|
||||
struct bt_hci_evt_hdr *hdr = (void *)(buf->data + 1);
|
||||
uint8_t evt_flags = bt_hci_evt_get_flags(hdr->evt);
|
||||
|
||||
if ((evt_flags & BT_HCI_EVT_FLAG_RECV_PRIO) &&
|
||||
@@ -869,8 +872,8 @@ static void recv_thread(void *p1, void *p2, void *p3)
|
||||
frag = net_buf_ref(buf);
|
||||
buf = net_buf_frag_del(NULL, buf);
|
||||
|
||||
if (frag->len) {
|
||||
LOG_DBG("Packet in: type:%u len:%u", bt_buf_get_type(frag),
|
||||
if (frag->len > 1) {
|
||||
LOG_DBG("Packet in: type:%u len:%u", frag->data[0],
|
||||
frag->len);
|
||||
|
||||
data->recv(dev, frag);
|
||||
@@ -963,18 +966,18 @@ static int hci_driver_send(const struct device *dev, struct net_buf *buf)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
type = bt_buf_get_type(buf);
|
||||
type = net_buf_pull_u8(buf);
|
||||
switch (type) {
|
||||
#if defined(CONFIG_BT_CONN)
|
||||
case BT_BUF_ACL_OUT:
|
||||
case BT_HCI_H4_ACL:
|
||||
err = acl_handle(dev, buf);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CONN */
|
||||
case BT_BUF_CMD:
|
||||
case BT_HCI_H4_CMD:
|
||||
err = cmd_handle(dev, buf);
|
||||
break;
|
||||
#if defined(CONFIG_BT_CTLR_ADV_ISO) || defined(CONFIG_BT_CTLR_CONN_ISO)
|
||||
case BT_BUF_ISO_OUT:
|
||||
case BT_HCI_H4_ISO:
|
||||
err = iso_handle(dev, buf);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_CONN_ISO */
|
||||
|
||||
Reference in New Issue
Block a user