Bluetooth: Add ACL user data to bt_buf

To track which ACL handle each buffer belongs to (needed for host flow
control) add the necessary information into a new ACL-specific struct.

Change-Id: Ie6cc7c32a70b43a4ff5954bb9dca34e4f62da292
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-04-28 15:20:33 +03:00 committed by Anas Nashif
commit 25af03265c
3 changed files with 12 additions and 7 deletions

View file

@ -54,12 +54,17 @@ struct bt_buf_hci_data {
uint16_t opcode;
};
struct bt_buf_acl_data {
uint16_t handle;
};
struct bt_buf {
/* FIFO uses first 4 bytes itself, reserve space */
int __unused;
union {
struct bt_buf_hci_data hci;
struct bt_buf_acl_data acl;
};
/* Type of data contained in the buffer */

View file

@ -76,12 +76,12 @@ struct bt_buf *bt_buf_get(enum bt_buf_type type, size_t reserve_head)
return NULL;
}
memset(buf, 0, sizeof(*buf));
buf->type = type;
buf->data = buf->buf + reserve_head;
buf->len = 0;
buf->hci.sync = NULL;
BT_DBG("buf %p reserve %u\n", buf, reserve_head);
BT_DBG("buf %p type %d reserve %u\n", buf, buf->type, reserve_head);
return buf;
}

View file

@ -125,11 +125,11 @@ static void hci_acl(struct bt_buf *buf)
handle = sys_le16_to_cpu(hdr->handle);
flags = (handle >> 12);
handle = bt_acl_handle(handle);
buf->acl.handle = bt_acl_handle(handle);
bt_buf_pull(buf, sizeof(*hdr));
BT_DBG("handle %u len %u flags %u\n", handle, len, flags);
BT_DBG("handle %u len %u flags %u\n", buf->acl.handle, len, flags);
if (buf->len != len) {
BT_ERR("ACL data length mismatch (%u != %u)\n", buf->len, len);
@ -137,9 +137,9 @@ static void hci_acl(struct bt_buf *buf)
return;
}
conn = bt_conn_lookup(handle);
conn = bt_conn_lookup(buf->acl.handle);
if (!conn) {
BT_ERR("Unable to find conn for handle %u\n", handle);
BT_ERR("Unable to find conn for handle %u\n", buf->acl.handle);
bt_buf_put(buf);
return;
}