Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
buf.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2016 Intel Corporation
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11#ifndef ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_
12#define ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_
13
21#include <zephyr/types.h>
22#include <net/buf.h>
23#include <bluetooth/hci.h>
24#include <sys/util.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
46};
47
51};
52
53#if defined(CONFIG_BT_HCI_RAW)
54#define BT_BUF_RESERVE MAX(CONFIG_BT_HCI_RESERVE, CONFIG_BT_HCI_RAW_RESERVE)
55#else
56#define BT_BUF_RESERVE CONFIG_BT_HCI_RESERVE
57#endif
58
60#define BT_BUF_SIZE(size) (BT_BUF_RESERVE + (size))
61
63#define BT_BUF_ACL_SIZE(size) BT_BUF_SIZE(BT_HCI_ACL_HDR_SIZE + (size))
64
66#define BT_BUF_EVT_SIZE(size) BT_BUF_SIZE(BT_HCI_EVT_HDR_SIZE + (size))
67
69#define BT_BUF_CMD_SIZE(size) BT_BUF_SIZE(BT_HCI_CMD_HDR_SIZE + (size))
70
72#define BT_BUF_ACL_RX_SIZE BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE)
73
75#define BT_BUF_EVT_RX_SIZE BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_RX_SIZE)
76
78#define BT_BUF_RX_SIZE (MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE))
79
81#define BT_BUF_CMD_TX_SIZE BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE)
82
95
110 const void *data, size_t size);
111
122
134struct net_buf *bt_buf_get_evt(uint8_t evt, bool discardable, k_timeout_t timeout);
135
141static inline void bt_buf_set_type(struct net_buf *buf, enum bt_buf_type type)
142{
143 ((struct bt_buf_data *)net_buf_user_data(buf))->type = type;
144}
145
152static inline enum bt_buf_type bt_buf_get_type(struct net_buf *buf)
153{
154 return (enum bt_buf_type)((struct bt_buf_data *)net_buf_user_data(buf))
155 ->type;
156}
157
162#ifdef __cplusplus
163}
164#endif
165
166#endif /* ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_ */
ZTEST_BMEM int timeout
Definition: main.c:31
static enum bt_buf_type bt_buf_get_type(struct net_buf *buf)
Definition: buf.h:152
struct net_buf * bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
struct net_buf * bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout, const void *data, size_t size)
struct net_buf * bt_buf_get_evt(uint8_t evt, bool discardable, k_timeout_t timeout)
struct net_buf * bt_buf_get_cmd_complete(k_timeout_t timeout)
static void bt_buf_set_type(struct net_buf *buf, enum bt_buf_type type)
Definition: buf.h:141
bt_buf_type
Definition: buf.h:31
@ BT_BUF_EVT
Definition: buf.h:35
@ BT_BUF_ISO_OUT
Definition: buf.h:41
@ BT_BUF_ACL_OUT
Definition: buf.h:37
@ BT_BUF_ISO_IN
Definition: buf.h:43
@ BT_BUF_CMD
Definition: buf.h:33
@ BT_BUF_H4
Definition: buf.h:45
@ BT_BUF_ACL_IN
Definition: buf.h:39
static void * net_buf_user_data(const struct net_buf *buf)
Get a pointer to the user data of a buffer.
Definition: buf.h:1445
Buffer management.
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
This is a base type for bt_buf user data.
Definition: buf.h:49
uint8_t type
Definition: buf.h:50
Kernel timeout type.
Definition: sys_clock.h:65
Network buffer representation.
Definition: buf.h:919
uint16_t size
Definition: buf.h:950
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
Misc utilities.