Bluetooth: L2CAP: Extend bt_l2cap_create_pdu() with 'reserve' parameter

This makes it possible for protocols to reserve headroom for their own
headers.

Change-Id: I64530febc4b86b45a379660197f0ff63671fab6e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2016-09-27 17:03:12 +03:00
commit 49d2bb13cd
7 changed files with 30 additions and 30 deletions

View file

@ -1765,10 +1765,10 @@ struct net_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len)
/* Use a different buffer pool for indication/confirmations
* since they can be sent in parallel.
*/
buf = bt_l2cap_create_pdu(&ind_data);
buf = bt_l2cap_create_pdu(&ind_data, 0);
break;
default:
buf = bt_l2cap_create_pdu(&req_data);
buf = bt_l2cap_create_pdu(&req_data, 0);
}
if (!buf) {

View file

@ -339,9 +339,9 @@ void bt_l2cap_encrypt_change(struct bt_conn *conn)
}
}
struct net_buf *bt_l2cap_create_pdu(struct nano_fifo *fifo)
struct net_buf *bt_l2cap_create_pdu(struct nano_fifo *fifo, size_t reserve)
{
return bt_conn_create_pdu(fifo, sizeof(struct bt_l2cap_hdr));
return bt_conn_create_pdu(fifo, sizeof(struct bt_l2cap_hdr) + reserve);
}
void bt_l2cap_send(struct bt_conn *conn, uint16_t cid, struct net_buf *buf)
@ -362,7 +362,7 @@ static void l2cap_send_reject(struct bt_conn *conn, uint8_t ident,
struct bt_l2cap_sig_hdr *hdr;
struct net_buf *buf;
buf = bt_l2cap_create_pdu(&le_sig);
buf = bt_l2cap_create_pdu(&le_sig, 0);
if (!buf) {
return;
}
@ -426,7 +426,7 @@ static void le_conn_param_update_req(struct bt_l2cap *l2cap, uint8_t ident,
BT_DBG("min 0x%4.4x max 0x%4.4x latency: 0x%4.4x timeout: 0x%4.4x",
min, max, latency, timeout);
buf = bt_l2cap_create_pdu(&le_sig);
buf = bt_l2cap_create_pdu(&le_sig, 0);
if (!buf) {
return;
}
@ -583,7 +583,7 @@ static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident,
return;
}
buf = bt_l2cap_create_pdu(&le_sig);
buf = bt_l2cap_create_pdu(&le_sig, 0);
if (!buf) {
return;
}
@ -715,7 +715,7 @@ static void le_disconn_req(struct bt_l2cap *l2cap, uint8_t ident,
return;
}
buf = bt_l2cap_create_pdu(&le_sig);
buf = bt_l2cap_create_pdu(&le_sig, 0);
if (!buf) {
return;
}
@ -958,7 +958,7 @@ static void l2cap_chan_update_credits(struct bt_l2cap_le_chan *chan)
credits = L2CAP_LE_MAX_CREDITS - chan->rx.credits.nsig;
l2cap_chan_rx_give_credits(chan, credits);
buf = bt_l2cap_create_pdu(&le_sig);
buf = bt_l2cap_create_pdu(&le_sig, 0);
if (!buf) {
BT_ERR("Unable to send credits");
return;
@ -1123,7 +1123,7 @@ int bt_l2cap_update_conn_param(struct bt_conn *conn,
struct bt_l2cap_conn_param_req *req;
struct net_buf *buf;
buf = bt_l2cap_create_pdu(&le_sig);
buf = bt_l2cap_create_pdu(&le_sig, 0);
if (!buf) {
return -ENOBUFS;
}
@ -1275,7 +1275,7 @@ static int l2cap_le_connect(struct bt_conn *conn, struct bt_l2cap_le_chan *ch,
return -ENOMEM;
}
buf = bt_l2cap_create_pdu(&le_sig);
buf = bt_l2cap_create_pdu(&le_sig, 0);
if (!buf) {
BT_ERR("Unable to send L2CAP connection request");
return -ENOMEM;
@ -1345,7 +1345,7 @@ int bt_l2cap_chan_disconnect(struct bt_l2cap_chan *chan)
BT_DBG("chan %p scid 0x%04x dcid 0x%04x", chan, ch->rx.cid,
ch->tx.cid);
buf = bt_l2cap_create_pdu(&le_sig);
buf = bt_l2cap_create_pdu(&le_sig, 0);
if (!buf) {
BT_ERR("Unable to send L2CP disconnect request");
return -ENOMEM;
@ -1393,7 +1393,7 @@ static struct net_buf *l2cap_chan_create_seg(struct bt_l2cap_le_chan *ch,
}
segment:
seg = bt_l2cap_create_pdu(&le_data);
seg = bt_l2cap_create_pdu(&le_data, 0);
if (!seg) {
return NULL;
}

View file

@ -390,7 +390,7 @@ static void l2cap_br_get_info(struct bt_l2cap_br *l2cap, uint16_t info_type)
return;
}
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
BT_ERR("No buffers");
return;
@ -503,7 +503,7 @@ static int l2cap_br_info_req(struct bt_l2cap_br *l2cap, uint8_t ident,
return -EINVAL;
}
rsp_buf = bt_l2cap_create_pdu(&br_sig);
rsp_buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!rsp_buf) {
BT_ERR("No buffers");
return -ENOMEM;
@ -615,7 +615,7 @@ static void l2cap_br_conf(struct bt_l2cap_chan *chan)
struct bt_l2cap_conf_req *conf;
struct net_buf *buf;
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
return;
}
@ -753,7 +753,7 @@ static void l2cap_br_conn_req(struct bt_l2cap_br *l2cap, uint8_t ident,
BT_DBG("psm 0x%02x scid 0x%04x", psm, scid);
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
return;
}
@ -940,7 +940,7 @@ static void l2cap_br_send_reject(struct bt_conn *conn, uint8_t ident,
struct bt_l2cap_sig_hdr *hdr;
struct net_buf *buf;
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
return;
}
@ -1075,7 +1075,7 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident,
}
send_rsp:
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
return;
}
@ -1178,7 +1178,7 @@ static void l2cap_br_disconn_req(struct bt_l2cap_br *l2cap, uint8_t ident,
return;
}
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
return;
}
@ -1234,7 +1234,7 @@ int bt_l2cap_br_chan_disconnect(struct bt_l2cap_chan *chan)
BT_DBG("chan %p scid 0x%04x dcid 0x%04x", chan, ch->rx.cid,
ch->tx.cid);
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
BT_ERR("Unable to send L2CAP disconnect request");
return -ENOMEM;
@ -1339,7 +1339,7 @@ int bt_l2cap_br_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan,
return -EIO;
}
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
BT_ERR("Unable to send L2CAP connection request");
return -ENOMEM;
@ -1508,7 +1508,7 @@ static void l2cap_br_conn_pend(struct bt_l2cap_chan *chan)
* response and initiate configuration request.
*/
if (atomic_test_bit(BR_CHAN(chan)->flags, L2CAP_FLAG_CONN_ACCEPTOR)) {
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
BT_ERR("No buffers for PDU");
return;
@ -1537,7 +1537,7 @@ static void l2cap_br_conn_pend(struct bt_l2cap_chan *chan)
l2cap_br_conf(chan);
} else if (!atomic_test_bit(BR_CHAN(chan)->flags,
L2CAP_FLAG_CONN_PENDING)) {
buf = bt_l2cap_create_pdu(&br_sig);
buf = bt_l2cap_create_pdu(&br_sig, 0);
if (!buf) {
BT_ERR("Unable to send L2CAP connection request");
return;

View file

@ -225,7 +225,7 @@ void bt_l2cap_chan_del(struct bt_l2cap_chan *chan);
void bt_l2cap_encrypt_change(struct bt_conn *conn);
/* Prepare an L2CAP PDU to be sent over a connection */
struct net_buf *bt_l2cap_create_pdu(struct nano_fifo *fifo);
struct net_buf *bt_l2cap_create_pdu(struct nano_fifo *fifo, size_t reserve);
/* Send L2CAP PDU over a connection */
void bt_l2cap_send(struct bt_conn *conn, uint16_t cid, struct net_buf *buf);

View file

@ -321,7 +321,7 @@ static struct net_buf *rfcomm_make_uih_msg(struct bt_rfcomm_dlc *dlc,
struct net_buf *buf;
uint8_t hdr_cr;
buf = bt_l2cap_create_pdu(&rfcomm_session);
buf = bt_l2cap_create_pdu(&rfcomm_session, 0);
if (!buf) {
BT_ERR("No buffers");
return NULL;
@ -452,7 +452,7 @@ static int rfcomm_send_ua(struct bt_rfcomm_session *session, uint8_t dlci)
struct net_buf *buf;
uint8_t cr, fcs;
buf = bt_l2cap_create_pdu(&rfcomm_session);
buf = bt_l2cap_create_pdu(&rfcomm_session, 0);
if (!buf) {
BT_ERR("No buffers");
return -ENOMEM;
@ -578,7 +578,7 @@ static int rfcomm_send_credit(struct bt_rfcomm_dlc *dlc, uint8_t credits)
BT_DBG("Dlc %p credits %d", dlc, credits);
buf = bt_l2cap_create_pdu(&rfcomm_session);
buf = bt_l2cap_create_pdu(&rfcomm_session, 0);
if (!buf) {
BT_ERR("No buffers");
return -ENOMEM;

View file

@ -324,7 +324,7 @@ static struct net_buf *smp_create_pdu(struct bt_conn *conn, uint8_t op,
struct bt_smp_hdr *hdr;
struct net_buf *buf;
buf = bt_l2cap_create_pdu(&smp_buf);
buf = bt_l2cap_create_pdu(&smp_buf, 0);
if (!buf) {
return NULL;
}

View file

@ -65,7 +65,7 @@ static void bt_smp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
* Core Specification Vol. 3, Part H, 3.3
*/
buf = bt_l2cap_create_pdu(&smp_buf);
buf = bt_l2cap_create_pdu(&smp_buf, 0);
if (!buf) {
return;
}