Bluetooth: ISO: Remove use of conn->channels for ISO

The channels list were originally meant to be used
for multiple bt_iso_chan per iso connect (bt_conn), but
that is not the case for the current API, and won't be
going forward, so the use of the list has been removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2021-08-24 14:00:45 +02:00 committed by Anas Nashif
commit 4bd326d6c9
3 changed files with 32 additions and 30 deletions

View file

@ -64,7 +64,6 @@ struct bt_iso_chan {
struct bt_iso_chan_ops *ops; struct bt_iso_chan_ops *ops;
/** Channel QoS reference */ /** Channel QoS reference */
struct bt_iso_chan_qos *qos; struct bt_iso_chan_qos *qos;
sys_snode_t node;
uint8_t state; uint8_t state;
bt_security_t required_sec_level; bt_security_t required_sec_level;
}; };

View file

@ -99,6 +99,10 @@ struct bt_conn_sco {
struct bt_conn_iso { struct bt_conn_iso {
/* Reference to ACL Connection */ /* Reference to ACL Connection */
struct bt_conn *acl; struct bt_conn *acl;
/* Reference to the struct bt_iso_chan */
struct bt_iso_chan *chan;
union { union {
/* CIG ID */ /* CIG ID */
uint8_t cig_id; uint8_t cig_id;
@ -179,7 +183,7 @@ struct bt_conn {
/* Queue for outgoing ACL data */ /* Queue for outgoing ACL data */
struct k_fifo tx_queue; struct k_fifo tx_queue;
/* Active L2CAP/ISO channels */ /* Active L2CAP channels */
sys_slist_t channels; sys_slist_t channels;
/* Delayed work deferred tasks: /* Delayed work deferred tasks:

View file

@ -31,6 +31,7 @@ NET_BUF_POOL_FIXED_DEFINE(iso_rx_pool, CONFIG_BT_ISO_RX_BUF_COUNT,
static struct bt_iso_recv_info iso_info_data[CONFIG_BT_ISO_RX_BUF_COUNT]; static struct bt_iso_recv_info iso_info_data[CONFIG_BT_ISO_RX_BUF_COUNT];
#define iso_info(buf) (&iso_info_data[net_buf_id(buf)]) #define iso_info(buf) (&iso_info_data[net_buf_id(buf)])
#define iso_chan(_conn) ((_conn)->iso.chan);
#if CONFIG_BT_ISO_TX_FRAG_COUNT > 0 #if CONFIG_BT_ISO_TX_FRAG_COUNT > 0
NET_BUF_POOL_FIXED_DEFINE(iso_frag_pool, CONFIG_BT_ISO_TX_FRAG_COUNT, NET_BUF_POOL_FIXED_DEFINE(iso_frag_pool, CONFIG_BT_ISO_TX_FRAG_COUNT,
@ -119,10 +120,10 @@ struct bt_conn *iso_new(void)
if (iso) { if (iso) {
iso->type = BT_CONN_TYPE_ISO; iso->type = BT_CONN_TYPE_ISO;
sys_slist_init(&iso->channels);
} else { } else {
BT_DBG("Could not create new ISO"); BT_DBG("Could not create new ISO");
} }
return iso; return iso;
} }
@ -248,8 +249,8 @@ static int hci_le_remove_iso_data_path(struct bt_conn *conn, uint8_t dir)
static void bt_iso_chan_add(struct bt_conn *conn, struct bt_iso_chan *chan) static void bt_iso_chan_add(struct bt_conn *conn, struct bt_iso_chan *chan)
{ {
/* Attach channel to the connection */ /* Attach channel to the connection */
sys_slist_append(&conn->channels, &chan->node);
chan->conn = conn; chan->conn = conn;
conn->iso.chan = chan;
BT_DBG("conn %p chan %p", conn, chan); BT_DBG("conn %p chan %p", conn, chan);
} }
@ -266,8 +267,8 @@ static int bt_iso_setup_data_path(struct bt_conn *conn)
struct bt_iso_chan_io_qos *tx_qos; struct bt_iso_chan_io_qos *tx_qos;
struct bt_iso_chan_io_qos *rx_qos; struct bt_iso_chan_io_qos *rx_qos;
chan = SYS_SLIST_PEEK_HEAD_CONTAINER(&conn->channels, chan, node); chan = iso_chan(conn);
if (!chan) { if (chan == NULL) {
return -EINVAL; return -EINVAL;
} }
@ -328,12 +329,16 @@ void bt_iso_connected(struct bt_conn *conn)
return; return;
} }
SYS_SLIST_FOR_EACH_CONTAINER(&conn->channels, chan, node) { chan = iso_chan(conn);
bt_iso_chan_set_state(chan, BT_ISO_CONNECTED); if (chan == NULL) {
BT_ERR("Could not lookup chan from connected ISO");
return;
}
if (chan->ops->connected) { bt_iso_chan_set_state(chan, BT_ISO_CONNECTED);
chan->ops->connected(chan);
} if (chan->ops->connected) {
chan->ops->connected(chan);
} }
} }
@ -346,8 +351,8 @@ void bt_iso_remove_data_path(struct bt_conn *conn)
struct bt_iso_chan_io_qos *tx_qos; struct bt_iso_chan_io_qos *tx_qos;
uint8_t dir; uint8_t dir;
chan = SYS_SLIST_PEEK_HEAD_CONTAINER(&conn->channels, chan, node); chan = iso_chan(conn);
if (!chan) { if (chan == NULL) {
return; return;
} }
@ -374,11 +379,6 @@ void bt_iso_remove_data_path(struct bt_conn *conn)
} }
} }
bool bt_iso_chan_remove(struct bt_conn *conn, struct bt_iso_chan *chan)
{
return sys_slist_find_and_remove(&conn->channels, &chan->node);
}
static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason) static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason)
{ {
BT_DBG("%p, reason 0x%02x", chan, reason); BT_DBG("%p, reason 0x%02x", chan, reason);
@ -392,9 +392,7 @@ static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason)
*/ */
if (IS_ENABLED(CONFIG_BT_ISO_UNICAST) && if (IS_ENABLED(CONFIG_BT_ISO_UNICAST) &&
chan->conn->role == BT_HCI_ROLE_SLAVE) { chan->conn->role == BT_HCI_ROLE_SLAVE) {
if (!bt_iso_chan_remove(chan->conn, chan)) { chan->conn->iso.chan = NULL;
BT_ERR("Could not remove chan from conn channels");
}
bt_conn_unref(chan->conn); bt_conn_unref(chan->conn);
chan->conn = NULL; chan->conn = NULL;
} }
@ -406,7 +404,7 @@ static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason)
void bt_iso_disconnected(struct bt_conn *conn) void bt_iso_disconnected(struct bt_conn *conn)
{ {
struct bt_iso_chan *chan, *next; struct bt_iso_chan *chan;
CHECKIF(!conn || conn->type != BT_CONN_TYPE_ISO) { CHECKIF(!conn || conn->type != BT_CONN_TYPE_ISO) {
BT_DBG("Invalid parameters: conn %p conn->type %u", conn, BT_DBG("Invalid parameters: conn %p conn->type %u", conn,
@ -416,13 +414,13 @@ void bt_iso_disconnected(struct bt_conn *conn)
BT_DBG("%p", conn); BT_DBG("%p", conn);
if (sys_slist_is_empty(&conn->channels)) { chan = iso_chan(conn);
if (chan == NULL) {
BT_ERR("Could not lookup chan from disconnected ISO");
return; return;
} }
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&conn->channels, chan, next, node) { bt_iso_chan_disconnected(chan, conn->err);
bt_iso_chan_disconnected(chan, conn->err);
}
} }
#if defined(CONFIG_BT_DEBUG_ISO) #if defined(CONFIG_BT_DEBUG_ISO)
@ -619,10 +617,11 @@ void bt_iso_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags)
return; return;
} }
SYS_SLIST_FOR_EACH_CONTAINER(&conn->channels, chan, node) { chan = iso_chan(conn);
if (chan->ops->recv) { if (chan == NULL) {
chan->ops->recv(chan, iso_info(conn->rx), conn->rx); BT_ERR("Could not lookup chan from receiving ISO");
} } else if (chan->ops->recv != NULL) {
chan->ops->recv(chan, iso_info(conn->rx), conn->rx);
} }
bt_conn_reset_rx_state(conn); bt_conn_reset_rx_state(conn);