Bluetooth: L2CAP: Move init BR/EDR pool signal buffers to l2cap_br.c

Moves initialization of signal buffer for BR/EDR transport to
l2cap_br.c unit and removes existing references to signal buffer in
l2cap.c file to prevent compiler complains.

Change-Id: I784b926df814e632944f3a12b0b6d03d144d2438
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
Arkadiusz Lichwa 2016-05-09 22:23:10 +02:00 committed by Johan Hedberg
commit bc1423f441
3 changed files with 20 additions and 28 deletions

View file

@ -44,8 +44,6 @@
#define L2CAP_LE_MAX_CREDITS (CONFIG_BLUETOOTH_ACL_IN_COUNT - 1)
#define L2CAP_LE_CREDITS_THRESHOLD (L2CAP_LE_MAX_CREDITS / 2)
#define L2CAP_BR_MIN_MTU 48
#define L2CAP_LE_DYN_CID_START 0x0040
#define L2CAP_LE_DYN_CID_END 0x007f
#define L2CAP_BR_DYN_CID_START 0x0040
@ -85,12 +83,6 @@ static NET_BUF_POOL(le_data_pool, CONFIG_BLUETOOTH_MAX_CONN,
#if defined(CONFIG_BLUETOOTH_BREDR)
static struct bt_l2cap_fixed_chan *br_channels;
/* Pool for outgoing BR/EDR signaling packets, min MTU is 48 */
static struct nano_fifo br_sig;
static NET_BUF_POOL(br_sig_pool, CONFIG_BLUETOOTH_MAX_CONN,
BT_L2CAP_BUF_SIZE(L2CAP_BR_MIN_MTU), &br_sig, NULL,
BT_BUF_USER_DATA_MIN);
#endif /* CONFIG_BLUETOOTH_BREDR */
/* L2CAP signalling channel specific context */
@ -290,24 +282,8 @@ static void l2cap_send_reject(struct bt_conn *conn, uint8_t ident,
struct bt_l2cap_cmd_reject *rej;
struct bt_l2cap_sig_hdr *hdr;
struct net_buf *buf;
uint16_t cid;
switch (conn->type) {
#if defined(CONFIG_BLUETOOTH_BREDR)
case BT_CONN_TYPE_BR:
cid = BT_L2CAP_CID_BR_SIG;
buf = bt_l2cap_create_pdu(&br_sig);
break;
#endif /* CONFIG_BLUETOOTH_BREDR */
case BT_CONN_TYPE_LE:
cid = BT_L2CAP_CID_LE_SIG;
buf = bt_l2cap_create_pdu(&le_sig);
break;
default:
buf = NULL;
break;
}
buf = bt_l2cap_create_pdu(&le_sig);
if (!buf) {
return;
}
@ -320,7 +296,7 @@ static void l2cap_send_reject(struct bt_conn *conn, uint8_t ident,
rej = net_buf_add(buf, sizeof(*rej));
rej->reason = sys_cpu_to_le16(reason);
bt_l2cap_send(conn, cid, buf);
bt_l2cap_send(conn, BT_L2CAP_CID_LE_SIG, buf);
}
static void le_conn_param_rsp(struct bt_l2cap *l2cap, struct net_buf *buf)
@ -1124,8 +1100,7 @@ void bt_l2cap_init(void)
.mask = BT_L2CAP_MASK_BR_SIG,
.accept = l2cap_accept,
};
net_buf_pool_init(br_sig_pool);
bt_l2cap_br_init();
bt_l2cap_br_fixed_chan_register(&chan_br);
#endif /* CONFIG_BLUETOOTH_BREDR */

View file

@ -29,6 +29,7 @@
#include <bluetooth/hci.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include <bluetooth/driver.h>
#include "hci_core.h"
#include "conn_internal.h"
@ -42,8 +43,16 @@
#define L2CAP_BR_PSM_START 0x0001
#define L2CAP_BR_PSM_END 0xffff
#define L2CAP_BR_MIN_MTU 48
static struct bt_l2cap_server *br_servers;
/* Pool for outgoing BR/EDR signaling packets, min MTU is 48 */
static struct nano_fifo br_sig;
static NET_BUF_POOL(br_sig_pool, CONFIG_BLUETOOTH_MAX_CONN,
BT_L2CAP_BUF_SIZE(L2CAP_BR_MIN_MTU), &br_sig, NULL,
BT_BUF_USER_DATA_MIN);
static struct bt_l2cap_server *l2cap_br_server_lookup_psm(uint16_t psm)
{
struct bt_l2cap_server *server;
@ -81,3 +90,8 @@ int bt_l2cap_br_server_register(struct bt_l2cap_server *server)
return 0;
}
void bt_l2cap_br_init(void)
{
net_buf_pool_init(br_sig_pool);
}

View file

@ -171,4 +171,7 @@ struct bt_l2cap_chan *bt_l2cap_lookup_rx_cid(struct bt_conn *conn,
#if defined(CONFIG_BLUETOOTH_BREDR)
/* Register a fixed L2CAP channel for BR/EDR connection transport */
void bt_l2cap_br_fixed_chan_register(struct bt_l2cap_fixed_chan *chan);
/* Initialize BR/EDR L2CAP signal layer */
void bt_l2cap_br_init(void);
#endif /* CONFIG_BLUETOOTH_BREDR */