Skip to content

Commit 4f5323a

Browse files
ivaniushkovjhedberg
authored andcommitted
Bluetooth: fix HCI ISO Data packets fragmentation
this commit partially reverts e460847 According to Core Spec 5.4, Vol. 4, Part E, 5.4.5, Data_Total_Length field contains length of the whole packet including optional fields of SDU (Time_Stamp, Packet_Sequence_Number, ISO_SDU_Length, RFU and Packet_Status_Flag). In Zephyr Host, Data_Total_Length value is stored in bt_dev.le.iso_mtu field. Therefore, there is no need to calculate iso_hdr_len(), this length is already taken into account in conn_mtu(conn). This commits removes iso_hdr_len() function and fixes calculation of HCI ISO Data packet length calculations. Signed-off-by: Ivan Iushkov <[email protected]>
1 parent 7ac34d0 commit 4f5323a

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -656,21 +656,6 @@ static int do_send_frag(struct bt_conn *conn, struct net_buf *buf, uint8_t flags
656656
return err;
657657
}
658658

659-
static size_t iso_hdr_len(struct net_buf *buf, struct bt_conn *conn)
660-
{
661-
#if defined(CONFIG_BT_ISO)
662-
if (conn->type == BT_CONN_TYPE_ISO) {
663-
if (tx_data(buf)->iso_has_ts) {
664-
return BT_HCI_ISO_TS_DATA_HDR_SIZE;
665-
} else {
666-
return BT_HCI_ISO_DATA_HDR_SIZE;
667-
}
668-
}
669-
#endif
670-
671-
return 0;
672-
}
673-
674659
static int send_frag(struct bt_conn *conn,
675660
struct net_buf *buf, struct net_buf *frag,
676661
uint8_t flags)
@@ -683,9 +668,7 @@ static int send_frag(struct bt_conn *conn,
683668

684669
/* Add the data to the buffer */
685670
if (frag) {
686-
size_t iso_hdr = flags == FRAG_START ? iso_hdr_len(buf, conn) : 0;
687-
uint16_t frag_len = MIN(conn_mtu(conn) + iso_hdr,
688-
net_buf_tailroom(frag));
671+
uint16_t frag_len = MIN(conn_mtu(conn), net_buf_tailroom(frag));
689672

690673
net_buf_add_mem(frag, buf->data, frag_len);
691674
net_buf_pull(buf, frag_len);
@@ -733,11 +716,6 @@ static struct net_buf *create_frag(struct bt_conn *conn, struct net_buf *buf)
733716
return frag;
734717
}
735718

736-
static bool fits_single_ctlr_buf(struct net_buf *buf, struct bt_conn *conn)
737-
{
738-
return buf->len - iso_hdr_len(buf, conn) <= conn_mtu(conn);
739-
}
740-
741719
static int send_buf(struct bt_conn *conn, struct net_buf *buf)
742720
{
743721
struct net_buf *frag;
@@ -747,7 +725,7 @@ static int send_buf(struct bt_conn *conn, struct net_buf *buf)
747725
LOG_DBG("conn %p buf %p len %u", conn, buf, buf->len);
748726

749727
/* Send directly if the packet fits the ACL MTU */
750-
if (fits_single_ctlr_buf(buf, conn) && !tx_data(buf)->is_cont) {
728+
if (buf->len <= conn_mtu(conn) && !tx_data(buf)->is_cont) {
751729
LOG_DBG("send single");
752730
return send_frag(conn, buf, NULL, FRAG_SINGLE);
753731
}

0 commit comments

Comments
 (0)