Lines Matching full:buf
15 #include <zephyr/bluetooth/buf.h>
40 static void hci_rx_buf_destroy(struct net_buf *buf) in hci_rx_buf_destroy() argument
42 net_buf_destroy(buf); in hci_rx_buf_destroy()
85 struct net_buf *buf; in bt_buf_get_rx() local
97 buf = net_buf_alloc(&hci_rx_pool, timeout); in bt_buf_get_rx()
98 if (!buf) { in bt_buf_get_rx()
99 return buf; in bt_buf_get_rx()
102 net_buf_reserve(buf, BT_BUF_RESERVE); in bt_buf_get_rx()
103 bt_buf_set_type(buf, type); in bt_buf_get_rx()
105 return buf; in bt_buf_get_rx()
117 struct net_buf *buf; in bt_buf_get_tx() local
167 buf = net_buf_alloc(pool, timeout); in bt_buf_get_tx()
168 if (!buf) { in bt_buf_get_tx()
169 return buf; in bt_buf_get_tx()
172 net_buf_reserve(buf, BT_BUF_RESERVE); in bt_buf_get_tx()
173 bt_buf_set_type(buf, type); in bt_buf_get_tx()
176 if (net_buf_tailroom(buf) < size) { in bt_buf_get_tx()
177 net_buf_unref(buf); in bt_buf_get_tx()
181 net_buf_add_mem(buf, data, size); in bt_buf_get_tx()
184 return buf; in bt_buf_get_tx()
192 int bt_hci_recv(const struct device *dev, struct net_buf *buf) in bt_hci_recv() argument
196 LOG_DBG("buf %p len %u", buf, buf->len); in bt_hci_recv()
198 bt_monitor_send(bt_monitor_opcode(buf), buf->data, buf->len); in bt_hci_recv()
202 switch (bt_buf_get_type(buf)) { in bt_hci_recv()
204 net_buf_push_u8(buf, BT_HCI_H4_EVT); in bt_hci_recv()
207 net_buf_push_u8(buf, BT_HCI_H4_ACL); in bt_hci_recv()
211 net_buf_push_u8(buf, BT_HCI_H4_ISO); in bt_hci_recv()
216 LOG_ERR("Unknown type %u", bt_buf_get_type(buf)); in bt_hci_recv()
222 k_fifo_put(raw_rx, buf); in bt_hci_recv()
229 struct net_buf *buf; in bt_cmd_complete_ext() local
236 buf = bt_hci_cmd_complete_create(op, sizeof(*cc)); in bt_cmd_complete_ext()
237 cc = net_buf_add(buf, sizeof(*cc)); in bt_cmd_complete_ext()
240 bt_hci_recv(bt_dev.hci, buf); in bt_cmd_complete_ext()
243 static uint8_t bt_send_ext(struct net_buf *buf) in bt_send_ext() argument
257 net_buf_simple_save(&buf->b, &state); in bt_send_ext()
259 if (buf->len < sizeof(*hdr)) { in bt_send_ext()
264 hdr = net_buf_pull_mem(buf, sizeof(*hdr)); in bt_send_ext()
265 if (buf->len < hdr->param_len) { in bt_send_ext()
276 if (buf->len < cmd->min_len) { in bt_send_ext()
279 status = cmd->func(buf); in bt_send_ext()
291 net_buf_simple_restore(&buf->b, &state); in bt_send_ext()
296 int bt_send(struct net_buf *buf) in bt_send() argument
298 LOG_DBG("buf %p len %u", buf, buf->len); in bt_send()
300 if (buf->len == 0) { in bt_send()
304 bt_monitor_send(bt_monitor_opcode(buf), buf->data, buf->len); in bt_send()
307 bt_buf_get_type(buf) == BT_BUF_CMD) { in bt_send()
310 status = bt_send_ext(buf); in bt_send()
317 return bt_hci_ecc_send(buf); in bt_send()
320 return bt_hci_send(bt_dev.hci, buf); in bt_send()