Bluetooth: Remove per-connection RX fiber

Now that there's the split of Command Complete/Status events from all
other RX data we don't anymore need dedicated per-connection RX
fibers. Remove these fibers and their associated FIFO and use
bt_l2cap_recv() directly from bt_conn_recv().

Change-Id: Ib9740e76200cfa40d46ee234f9693dcb7e8387fd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-05-23 20:38:23 +03:00 committed by Anas Nashif
commit c825e91e57
2 changed files with 4 additions and 45 deletions

View file

@ -147,7 +147,7 @@ void bt_conn_recv(struct bt_conn *conn, struct bt_buf *buf, uint8_t flags)
BT_DBG("Successfully parsed %u byte L2CAP packet\n", buf->len);
nano_fiber_fifo_put(&conn->rx_queue, buf);
bt_l2cap_recv(conn, buf);
}
void bt_conn_send(struct bt_conn *conn, struct bt_buf *buf)
@ -196,40 +196,6 @@ void bt_conn_send(struct bt_conn *conn, struct bt_buf *buf)
}
}
static void conn_rx_fiber(int arg1, int arg2)
{
struct bt_conn *conn = (struct bt_conn *)arg1;
struct bt_buf *buf;
BT_DBG("Started for handle %u\n", conn->handle);
while (conn->state == BT_CONN_CONNECTED) {
BT_DBG("calling fifo_get_wait\n");
buf = nano_fifo_get_wait(&conn->rx_queue);
/* check for disconnection */
if (conn->state != BT_CONN_CONNECTED) {
bt_buf_put(buf);
break;
}
BT_DBG("passing buf %p len %u to L2CAP\n", buf, buf->len);
bt_l2cap_recv(conn, buf);
}
BT_DBG("handle %u disconnected - cleaning up\n", conn->handle);
/* Give back any allocated buffers */
while ((buf = nano_fifo_get(&conn->rx_queue))) {
bt_buf_put(buf);
}
bt_conn_reset_rx_state(conn);
BT_DBG("handle %u exiting\n", conn->handle);
bt_conn_put(conn);
}
static void conn_tx_fiber(int arg1, int arg2)
{
struct bt_conn *conn = (struct bt_conn *)arg1;
@ -269,6 +235,8 @@ static void conn_tx_fiber(int arg1, int arg2)
bt_buf_put(buf);
}
bt_conn_reset_rx_state(conn);
BT_DBG("handle %u exiting\n", conn->handle);
bt_conn_put(conn);
}
@ -297,10 +265,6 @@ struct bt_conn *bt_conn_add(struct bt_dev *dev, uint16_t handle)
conn->dev = dev;
nano_fifo_init(&conn->tx_queue);
nano_fifo_init(&conn->rx_queue);
fiber_start(conn->rx_stack, BT_CONN_RX_STACK_SIZE, conn_rx_fiber,
(int)bt_conn_get(conn), 0, 7, 0);
fiber_start(conn->tx_stack, BT_CONN_TX_STACK_SIZE, conn_tx_fiber,
(int)bt_conn_get(conn), 0, 7, 0);
@ -320,9 +284,8 @@ void bt_conn_del(struct bt_conn *conn)
conn->state = BT_CONN_DISCONNECTED;
/* Send dummy buffers to wake up and kill the fibers */
/* Send dummy buffer to wake up and kill the tx fiber */
nano_fifo_put(&conn->tx_queue, bt_buf_get(BT_DUMMY, 0));
nano_fifo_put(&conn->rx_queue, bt_buf_get(BT_DUMMY, 0));
bt_conn_put(conn);
}

View file

@ -32,10 +32,8 @@
#if defined(CONFIG_BLUETOOTH_DEBUG)
#define BT_CONN_TX_STACK_SIZE 1024
#define BT_CONN_RX_STACK_SIZE 2048
#else
#define BT_CONN_TX_STACK_SIZE 256
#define BT_CONN_RX_STACK_SIZE 1024
#endif
enum {
@ -62,7 +60,6 @@ struct bt_conn {
/* Queue for outgoing ACL data */
struct nano_fifo tx_queue;
struct nano_fifo rx_queue;
/* Fixed channel contexts */
struct bt_conn_l2cap l2cap;
@ -76,7 +73,6 @@ struct bt_conn {
uint8_t state;
char tx_stack[BT_CONN_TX_STACK_SIZE];
char rx_stack[BT_CONN_RX_STACK_SIZE];
};
/* Process incoming data for a connection */