Lines Matching refs:buf
41 static void hci_rx_buf_destroy(struct net_buf *buf) in hci_rx_buf_destroy() argument
43 net_buf_destroy(buf); in hci_rx_buf_destroy()
86 struct net_buf *buf; in bt_buf_get_rx() local
98 buf = net_buf_alloc(&hci_rx_pool, timeout); in bt_buf_get_rx()
99 if (!buf) { in bt_buf_get_rx()
100 return buf; in bt_buf_get_rx()
103 net_buf_reserve(buf, BT_BUF_RESERVE); in bt_buf_get_rx()
104 bt_buf_set_type(buf, type); in bt_buf_get_rx()
106 return buf; in bt_buf_get_rx()
118 struct net_buf *buf; in bt_buf_get_tx() local
168 buf = net_buf_alloc(pool, timeout); in bt_buf_get_tx()
169 if (!buf) { in bt_buf_get_tx()
170 return buf; in bt_buf_get_tx()
173 net_buf_reserve(buf, BT_BUF_RESERVE); in bt_buf_get_tx()
174 bt_buf_set_type(buf, type); in bt_buf_get_tx()
177 if (net_buf_tailroom(buf) < size) { in bt_buf_get_tx()
178 net_buf_unref(buf); in bt_buf_get_tx()
182 net_buf_add_mem(buf, data, size); in bt_buf_get_tx()
185 return buf; in bt_buf_get_tx()
193 int bt_hci_recv(const struct device *dev, struct net_buf *buf) in bt_hci_recv() argument
197 LOG_DBG("buf %p len %u", buf, buf->len); in bt_hci_recv()
199 bt_monitor_send(bt_monitor_opcode(buf), buf->data, buf->len); in bt_hci_recv()
203 switch (bt_buf_get_type(buf)) { in bt_hci_recv()
205 net_buf_push_u8(buf, BT_HCI_H4_EVT); in bt_hci_recv()
208 net_buf_push_u8(buf, BT_HCI_H4_ACL); in bt_hci_recv()
212 net_buf_push_u8(buf, BT_HCI_H4_ISO); in bt_hci_recv()
217 LOG_ERR("Unknown type %u", bt_buf_get_type(buf)); in bt_hci_recv()
223 k_fifo_put(raw_rx, buf); in bt_hci_recv()
230 struct net_buf *buf; in bt_cmd_complete_ext() local
237 buf = bt_hci_cmd_complete_create(op, sizeof(*cc)); in bt_cmd_complete_ext()
238 cc = net_buf_add(buf, sizeof(*cc)); in bt_cmd_complete_ext()
241 bt_hci_recv(bt_dev.hci, buf); in bt_cmd_complete_ext()
244 static uint8_t bt_send_ext(struct net_buf *buf) in bt_send_ext() argument
258 net_buf_simple_save(&buf->b, &state); in bt_send_ext()
260 if (buf->len < sizeof(*hdr)) { in bt_send_ext()
265 hdr = net_buf_pull_mem(buf, sizeof(*hdr)); in bt_send_ext()
266 if (buf->len < hdr->param_len) { in bt_send_ext()
277 if (buf->len < cmd->min_len) { in bt_send_ext()
280 status = cmd->func(buf); in bt_send_ext()
292 net_buf_simple_restore(&buf->b, &state); in bt_send_ext()
297 int bt_send(struct net_buf *buf) in bt_send() argument
299 LOG_DBG("buf %p len %u", buf, buf->len); in bt_send()
301 if (buf->len == 0) { in bt_send()
305 bt_monitor_send(bt_monitor_opcode(buf), buf->data, buf->len); in bt_send()
308 bt_buf_get_type(buf) == BT_BUF_CMD) { in bt_send()
311 status = bt_send_ext(buf); in bt_send()
317 return bt_hci_send(bt_dev.hci, buf); in bt_send()