Bluetooth: host: Optimize L2CAP resource usage

Making sure struct bt_l2cap_chan has absolutely no members related
to dynamic channels.

That way we ensure that there is no overhead for a build where only
fixed channels are used.

It's not enough that the dynamic channel-related members are put behind
ifdefs - they should be completely moved out from the struct definition.

Furthermore, the public l2cap.h header file already has a struct
that's meant to be used for dynamic channels: struct bt_l2cap_le_chan!

However, currently dynamic channel support is a mess - it's a mix
between these two structs. The bt_l2cap_le_chan struct should really
be an extension of the bt_l2cap_chan struct, i.e. the former should
contain as a member the latter.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
Lingao Meng 2022-01-29 09:30:12 +08:00 committed by Carles Cufí
commit 20ff55e234
9 changed files with 267 additions and 232 deletions

View file

@ -259,7 +259,7 @@ static void connect(uint8_t *data, uint16_t len)
fail:
for (i = 0U; i < ARRAY_SIZE(allocated_channels); i++) {
if (allocated_channels[i]) {
channels[allocated_channels[i]->ident].in_use = false;
channels[BT_L2CAP_LE_CHAN(allocated_channels[i])->ident].in_use = false;
}
}
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_CONNECT, CONTROLLER_INDEX,