Bluetooth: hci_raw: Move buffer management to common place
This makes hci_raw to manage RX and TX buffers so its logic don't have to be replicated on each an every driver/application, it also makes it simpler to deal with extra headers for H:4 mode since that then can be done at earlier at buffer allocation. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
05f0816f93
commit
4b622afbb3
8 changed files with 171 additions and 270 deletions
|
@ -32,6 +32,8 @@ enum bt_buf_type {
|
|||
BT_BUF_ACL_OUT,
|
||||
/** Incoming ACL data */
|
||||
BT_BUF_ACL_IN,
|
||||
/** H:4 data */
|
||||
BT_BUF_H4,
|
||||
};
|
||||
|
||||
/** Minimum amount of user data size for buffers passed to the stack. */
|
||||
|
@ -61,6 +63,22 @@ enum bt_buf_type {
|
|||
*/
|
||||
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, s32_t timeout);
|
||||
|
||||
/** Allocate a buffer for outgoing data
|
||||
*
|
||||
* This will set the buffer type so bt_buf_set_type() does not need to
|
||||
* be explicitly called before bt_send().
|
||||
*
|
||||
* @param type Type of buffer. Only BT_BUF_CMD, BT_BUF_ACL_OUT or
|
||||
* BT_BUF_H4, when operating on H:4 mode, are allowed.
|
||||
* @param timeout Timeout in milliseconds, or one of the special values
|
||||
* K_NO_WAIT and K_FOREVER.
|
||||
* @param data Initial data to append to buffer.
|
||||
* @param size Initial data size.
|
||||
* @return A new buffer.
|
||||
*/
|
||||
struct net_buf *bt_buf_get_tx(enum bt_buf_type type, s32_t timeout,
|
||||
const void *data, size_t size);
|
||||
|
||||
/** Allocate a buffer for an HCI Command Complete/Status Event
|
||||
*
|
||||
* This will set the buffer type so bt_buf_set_type() does not need to
|
||||
|
|
|
@ -21,6 +21,23 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_TX_BUFFER_SIZE)
|
||||
#define BT_L2CAP_MTU (CONFIG_BT_CTLR_TX_BUFFER_SIZE - BT_L2CAP_HDR_SIZE)
|
||||
#else
|
||||
#define BT_L2CAP_MTU 65 /* 64-byte public key + opcode */
|
||||
#endif /* CONFIG_BT_CTLR */
|
||||
|
||||
/** Data size needed for ACL buffers */
|
||||
#define BT_BUF_ACL_SIZE BT_L2CAP_BUF_SIZE(BT_L2CAP_MTU)
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_TX_BUFFERS)
|
||||
#define BT_HCI_ACL_COUNT CONFIG_BT_CTLR_TX_BUFFERS
|
||||
#else
|
||||
#define BT_HCI_ACL_COUNT 6
|
||||
#endif
|
||||
|
||||
#define BT_BUF_TX_SIZE MAX(BT_BUF_RX_SIZE, BT_BUF_ACL_SIZE)
|
||||
|
||||
/** @brief Send packet to the Bluetooth controller
|
||||
*
|
||||
* Send packet to the Bluetooth controller. Caller needs to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue