Bluetooth: controller: Fixes for BIGinfo endianness issues
The BIGinfo PDU bitsets were not accessed in a portable maner for endianness independence, and need to be handled as bit-manipulations. Add utility functions to access PDU bitset variables independent of endianness. Use macros to abstract the offsets and widths. Conversion of BIG_Handle to LE in HCI layer incorrectly use sys_cpu_to_le16, which fail because target type is 8-bit. Signed-off-by: Morten Priess <mtpr@oticon.com>
This commit is contained in:
parent
2262b294dd
commit
a30795e1f6
6 changed files with 177 additions and 81 deletions
|
@ -7772,19 +7772,23 @@ no_ext_hdr:
|
|||
|
||||
sep->sync_handle = sys_cpu_to_le16(node_rx->hdr.handle);
|
||||
|
||||
/* NOTE: both sep and bi struct store little-endian values,
|
||||
* explicit endian-ness conversion not required.
|
||||
/* NOTE: both sep and bi struct store little-endian values.
|
||||
* Multi-byte variables extracted using
|
||||
* PDU_BIG_INFO_ISO_*_GET macros, which return
|
||||
* value in host-endianness, require conversion.
|
||||
*/
|
||||
sep->num_bis = bi->num_bis;
|
||||
sep->nse = bi->nse;
|
||||
sep->iso_interval = bi->iso_interval;
|
||||
sep->bn = bi->bn;
|
||||
sep->pto = bi->pto;
|
||||
sep->irc = bi->irc;
|
||||
sep->max_pdu = bi->max_pdu;
|
||||
sys_put_le24(sys_le24_to_cpu(bi->sdu_interval),
|
||||
sep->sdu_interval);
|
||||
sep->max_sdu = bi->max_sdu;
|
||||
sep->num_bis = PDU_BIG_INFO_NUM_BIS_GET(bi);
|
||||
sep->nse = PDU_BIG_INFO_NSE_GET(bi);
|
||||
sep->iso_interval =
|
||||
sys_cpu_to_le16(PDU_BIG_INFO_ISO_INTERVAL_GET(bi));
|
||||
sep->bn = PDU_BIG_INFO_BN_GET(bi);
|
||||
sep->pto = PDU_BIG_INFO_PTO_GET(bi);
|
||||
sep->irc = PDU_BIG_INFO_IRC_GET(bi);
|
||||
|
||||
sep->max_pdu = sys_cpu_to_le16(bi->max_pdu);
|
||||
sys_put_le24(PDU_BIG_INFO_SDU_INTERVAL_GET(bi),
|
||||
sep->sdu_interval);
|
||||
sep->max_sdu = sys_cpu_to_le16(PDU_BIG_INFO_MAX_SDU_GET(bi));
|
||||
sep->phy = HCI_AUX_PHY_TO_HCI_PHY(bi->chm_phy[4] >> 5);
|
||||
sep->framing = (bi->payload_count_framing[4] >> 7) & 0x01;
|
||||
if (bi_size == (PDU_BIG_INFO_ENCRYPTED_SIZE + 1)) {
|
||||
|
@ -7833,7 +7837,7 @@ static void le_big_sync_established(struct pdu_data *pdu,
|
|||
evt_size = sizeof(*sep) + (lll->num_bis * sizeof(uint16_t));
|
||||
|
||||
sep = meta_evt(buf, BT_HCI_EVT_LE_BIG_SYNC_ESTABLISHED, evt_size);
|
||||
sep->big_handle = sys_cpu_to_le16(node_rx->hdr.handle);
|
||||
sep->big_handle = (uint8_t)node_rx->hdr.handle;
|
||||
|
||||
/* Check for pdu field being aligned before accessing ISO sync
|
||||
* established event.
|
||||
|
@ -7879,7 +7883,7 @@ static void le_big_sync_lost(struct pdu_data *pdu,
|
|||
}
|
||||
|
||||
sep = meta_evt(buf, BT_HCI_EVT_LE_BIG_SYNC_LOST, sizeof(*sep));
|
||||
sep->big_handle = sys_cpu_to_le16(node_rx->hdr.handle);
|
||||
sep->big_handle = (uint8_t)node_rx->hdr.handle;
|
||||
sep->reason = *((uint8_t *)pdu);
|
||||
}
|
||||
#endif /* CONFIG_BT_CTLR_SYNC_ISO */
|
||||
|
@ -7927,7 +7931,7 @@ static void le_big_complete(struct pdu_data *pdu_data,
|
|||
sep = meta_evt(buf, BT_HCI_EVT_LE_BIG_COMPLETE, evt_size);
|
||||
|
||||
sep->status = BT_HCI_ERR_SUCCESS;
|
||||
sep->big_handle = sys_cpu_to_le16(node_rx->hdr.handle);
|
||||
sep->big_handle = (uint8_t)node_rx->hdr.handle;
|
||||
|
||||
if (sep->status) {
|
||||
return;
|
||||
|
@ -7966,7 +7970,7 @@ static void le_big_terminate(struct pdu_data *pdu,
|
|||
}
|
||||
|
||||
sep = meta_evt(buf, BT_HCI_EVT_LE_BIG_TERMINATE, sizeof(*sep));
|
||||
sep->big_handle = sys_cpu_to_le16(node_rx->hdr.handle);
|
||||
sep->big_handle = (uint8_t)node_rx->hdr.handle;
|
||||
sep->reason = *((uint8_t *)pdu);
|
||||
}
|
||||
#endif /* CONFIG_BT_CTLR_ADV_ISO */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue