Skip to contentSkip to conversation

Add mgmt event for BIGInfo report

PATCH In review Iulia Tanasescu 3 participants 8 messages Aug 24, 2023 – Aug 30, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add mgmt event for BIGInfo report

This patch introduces MGMT events for BIGInfo advertising reports, so that the event can be passed from kernel to userspace.

This patch also adds the sync_handle field to the bt_iso_bcast_qos structure.

These changes are needed in order to implement the BASS Set Broadcast Code operation - a BASS Server is required to inspect BIGInfo advertising reports received from a Broadcast Source, to determine if the BIG is encrypted or not. The Server is only able to associate a Broadcast Source with a received BIGInfo report by looking at the sync_handle field. This is why the sync_handle needs to be available in the QoS structure, so it can e retrieved via getsockopt, once PA sync is established.

This patch depends on the kernel updates introduced by
https://patchwork.kernel.org/project/bluetooth/cover/[email protected]/

Iulia Tanasescu (4):
lib/mgmt: Add mgmt event for BIGInfo report
monitor: Add decoding support for BIGInfo mgmt event
monitor: Fix decoding issue for hci BIGInfo report
lib: Add sync_handle to bcast QoS

 lib/bluetooth.h   |  1 +
 lib/mgmt.h        | 18 ++++++++++++++++++
 monitor/control.c | 25 +++++++++++++++++++++++++
 monitor/packet.c  | 35 ++++++++++++++++++++++++++++++++++-
 4 files changed, 78 insertions(+), 1 deletion(-)

base-commit: 60731cab5891ad2be01f5fcdbf5908aff7df4fd1

Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 lib/mgmt: Add mgmt event for BIGInfo report

This adds the MGMT_EV_LE_BIG_INFO_ADV_REPORT event.

---
 lib/mgmt.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
lib/mgmt.h +18 -0
index 8f92b7731..f075d435c 100644
@@ -4,6 +4,7 @@
  *
  *  Copyright (C) 2010  Nokia Corporation
  *  Copyright (C) 2010  Marcel Holtmann <[email protected]>
+ *  Copyright 2023 NXP
  *
  *
  */
@@ -1092,6 +1093,23 @@ struct mgmt_ev_mesh_pkt_cmplt {
 	uint8_t	handle;
 } __packed;
 
+#define MGMT_EV_LE_BIG_INFO_ADV_REPORT	0x0033
+struct mgmt_ev_le_big_info_adv_report {
+	uint16_t sync_handle;
+	uint8_t num_bis;
+	uint8_t nse;
+	uint16_t iso_interval;
+	uint8_t bn;
+	uint8_t pto;
+	uint8_t irc;
+	uint16_t max_pdu;
+	uint8_t sdu_interval[3];
+	uint16_t max_sdu;
+	uint8_t phy;
+	uint8_t framing;
+	uint8_t encryption;
+} __packed;
+
 static const char *mgmt_op[] = {
 	"<0x0000>",
 	"Read Version",
Signature · 1 line
2.34.1
#2 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=778937

---Test result---

Test Summary:

CheckPatch                    PASS      2.02 seconds
GitLint                       PASS      1.36 seconds
BuildEll                      PASS      33.49 seconds
BluezMake                     PASS      1179.64 seconds
MakeCheck                     PASS      13.23 seconds
MakeDistcheck                 PASS      194.96 seconds
CheckValgrind                 PASS      317.38 seconds
CheckSmatch                   WARNING   441.39 seconds
bluezmakeextell               PASS      132.17 seconds
IncrementalBuild              PASS      4149.24 seconds
ScanBuild                     PASS      1407.55 seconds

Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
monitor/packet.c: note: in included file:monitor/display.h:82:26: warning: Variable length array is used.monitor/packet.c:1856:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/bt.h:3606:52: warning: array of flexible structuresmonitor/bt.h:3594:40: warning: array of flexible structuresmonitor/packet.c: note: in included file:monitor/display.h:82:26: warning: Variable length array is used.monitor/packet.c:1856:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/bt.h:3606:52: warning: array of flexible structuresmonitor/bt.h:3594:40: warning: array of flexible structures

---
Regards,
Linux Bluetooth

#3 lore raw

PATCH 2/4 monitor: Add decoding support for BIGInfo mgmt event

In reply to Iulia Tanasescu

This adds btmon support for decoding BIGInfo MGMT events.

---
 monitor/control.c | 25 +++++++++++++++++++++++++
 monitor/packet.c  | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
monitor/control.c +25 -0
index 009cf1520..b843d076f 100644
@@ -5,6 +5,7 @@
  *
  *  Copyright (C) 2011-2014  Intel Corporation
  *  Copyright (C) 2002-2010  Marcel Holtmann <[email protected]>
+ *  Copyright 2023 NXP
  *
  *
  */
@@ -788,6 +789,27 @@ static void mgmt_advertising_removed(uint16_t len, const void *buf)
 	packet_hexdump(buf, len);
 }
 
+static void mgmt_big_info_adv_report(uint16_t len, const void *buf)
+{
+	const struct mgmt_ev_le_big_info_adv_report *ev = buf;
+	uint16_t sync_handle;
+
+	if (len < sizeof(*ev)) {
+		printf("* Malformed BIGInfo advertising report control\n");
+		return;
+	}
+
+	sync_handle = le16_to_cpu(ev->sync_handle);
+
+	printf("@ BIGInfo Advertising Report: sync_handle 0x%4.4x num_bis %u "
+		"encryption %u\n", sync_handle, ev->num_bis, ev->encryption);
+
+	buf += sizeof(*ev);
+	len -= sizeof(*ev);
+
+	packet_hexdump(buf, len);
+}
+
 void control_message(uint16_t opcode, const void *data, uint16_t size)
 {
 	if (!decode_control)
@@ -893,6 +915,9 @@ void control_message(uint16_t opcode, const void *data, uint16_t size)
 	case MGMT_EV_ADVERTISING_REMOVED:
 		mgmt_advertising_removed(size, data);
 		break;
+	case MGMT_EV_LE_BIG_INFO_ADV_REPORT:
+		mgmt_big_info_adv_report(size, data);
+		break;
 	default:
 		printf("* Unknown control (code %d len %d)\n", opcode, size);
 		packet_hexdump(data, size);
monitor/packet.c +33 -0
index 8eae8c9ea..96fc2662e 100644
@@ -15396,6 +15396,37 @@ static void mgmt_mesh_device_found_evt(const void *data, uint16_t size)
 	print_hex_field("EIR Data", eir_data, size);
 }
 
+static void mgmt_big_info_adv_report(const void *data, uint16_t size)
+{
+	uint16_t sync_handle = get_le16(data);
+	uint8_t num_bis = get_u8(data + 2);
+	uint8_t nse = get_u8(data + 3);
+	uint16_t iso_interval = get_le16(data + 4);
+	uint8_t bn = get_u8(data + 6);
+	uint8_t pto = get_u8(data + 7);
+	uint8_t irc = get_u8(data + 8);
+	uint16_t max_pdu = get_le16(data + 9);
+	const uint8_t *sdu_interval = data + 11;
+	uint16_t max_sdu = get_le16(data + 14);
+	uint8_t phy = get_u8(data + 16);
+	uint8_t framing = get_u8(data + 17);
+	uint8_t encryption = get_u8(data + 18);
+
+	print_field("Sync Handle: 0x%4.4x", sync_handle);
+	print_field("Number BIS: %u", num_bis);
+	print_field("NSE: %u", nse);
+	print_slot_125("ISO Interval", iso_interval);
+	print_field("BN: %u", bn);
+	print_field("PTO: %u", pto);
+	print_field("IRC: %u", irc);
+	print_field("Maximum PDU: %u", max_pdu);
+	print_usec_interval("SDU Interval", sdu_interval);
+	print_field("Maximum SDU: %u", max_sdu);
+	print_le_phy("PHY", phy);
+	print_framing(framing);
+	print_field("Encryption: 0x%02x", encryption);
+}
+
 static void mgmt_mesh_packet_cmplt_evt(const void *data, uint16_t size)
 {
 	uint8_t handle = get_u8(data);
@@ -15500,6 +15531,8 @@ static const struct mgmt_data mgmt_event_table[] = {
 			mgmt_mesh_device_found_evt, 22, false },
 	{ 0x0032, "Mesh Packet Complete",
 			mgmt_mesh_packet_cmplt_evt, 1, true },
+	{ 0x0033, "BIGInfo advertising report",
+			mgmt_big_info_adv_report, 19, false },
 	{ }
 };
 
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH BlueZ 2/4] monitor: Add decoding support for BIGInfo mgmt event

Hi Iulia,

Quoted 101 lines · Iulia Tanasescu

This adds btmon support for decoding BIGInfo MGMT events.

---
 monitor/control.c | 25 +++++++++++++++++++++++++
 monitor/packet.c  | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
monitor/control.c +25 -0
index 009cf1520..b843d076f 100644
@@ -5,6 +5,7 @@
  *
  *  Copyright (C) 2011-2014  Intel Corporation
  *  Copyright (C) 2002-2010  Marcel Holtmann <[email protected]>
+ *  Copyright 2023 NXP
  *
  *
  */
@@ -788,6 +789,27 @@ static void mgmt_advertising_removed(uint16_t len, const void *buf)
        packet_hexdump(buf, len);
 }
 
+static void mgmt_big_info_adv_report(uint16_t len, const void *buf)
+{
+       const struct mgmt_ev_le_big_info_adv_report *ev = buf;
+       uint16_t sync_handle;
+
+       if (len < sizeof(*ev)) {
+               printf("* Malformed BIGInfo advertising report control\n");
+               return;
+       }
+
+       sync_handle = le16_to_cpu(ev->sync_handle);
+
+       printf("@ BIGInfo Advertising Report: sync_handle 0x%4.4x num_bis %u "
+               "encryption %u\n", sync_handle, ev->num_bis, ev->encryption);
+
+       buf += sizeof(*ev);
+       len -= sizeof(*ev);
+
+       packet_hexdump(buf, len);
+}
+
 void control_message(uint16_t opcode, const void *data, uint16_t size)
 {
        if (!decode_control)
@@ -893,6 +915,9 @@ void control_message(uint16_t opcode, const void *data, uint16_t size)
        case MGMT_EV_ADVERTISING_REMOVED:
                mgmt_advertising_removed(size, data);
                break;
+       case MGMT_EV_LE_BIG_INFO_ADV_REPORT:
+               mgmt_big_info_adv_report(size, data);
+               break;
        default:
                printf("* Unknown control (code %d len %d)\n", opcode, size);
                packet_hexdump(data, size);
monitor/packet.c +31 -0
index 8eae8c9ea..96fc2662e 100644
@@ -15396,6 +15396,37 @@ static void mgmt_mesh_device_found_evt(const void *data, uint16_t size)
        print_hex_field("EIR Data", eir_data, size);
 }
 
+static void mgmt_big_info_adv_report(const void *data, uint16_t size)
+{
+       uint16_t sync_handle = get_le16(data);
+       uint8_t num_bis = get_u8(data + 2);
+       uint8_t nse = get_u8(data + 3);
+       uint16_t iso_interval = get_le16(data + 4);
+       uint8_t bn = get_u8(data + 6);
+       uint8_t pto = get_u8(data + 7);
+       uint8_t irc = get_u8(data + 8);
+       uint16_t max_pdu = get_le16(data + 9);
+       const uint8_t *sdu_interval = data + 11;
+       uint16_t max_sdu = get_le16(data + 14);
+       uint8_t phy = get_u8(data + 16);
+       uint8_t framing = get_u8(data + 17);
+       uint8_t encryption = get_u8(data + 18);
+
+       print_field("Sync Handle: 0x%4.4x", sync_handle);
+       print_field("Number BIS: %u", num_bis);
+       print_field("NSE: %u", nse);
+       print_slot_125("ISO Interval", iso_interval);
+       print_field("BN: %u", bn);
+       print_field("PTO: %u", pto);
+       print_field("IRC: %u", irc);
+       print_field("Maximum PDU: %u", max_pdu);
+       print_usec_interval("SDU Interval", sdu_interval);
+       print_field("Maximum SDU: %u", max_sdu);
+       print_le_phy("PHY", phy);
+       print_framing(framing);
+       print_field("Encryption: 0x%02x", encryption);
+}
+
 static void mgmt_mesh_packet_cmplt_evt(const void *data, uint16_t size)
 {
        uint8_t handle = get_u8(data);

monitor/packet.c static const struct mgmt_data mgmt_event_table[] = { · line 15535

Quoted 5 lines
monitor/packet.c +2 -0
@@ -15500,6 +15531,8 @@ static const struct mgmt_data mgmt_event_table[] = {
                        mgmt_mesh_device_found_evt, 22, false },
        { 0x0032, "Mesh Packet Complete",
                        mgmt_mesh_packet_cmplt_evt, 1, true },
+       { 0x0033, "BIGInfo advertising report",
+                       mgmt_big_info_adv_report, 19, false },

This should got to the ISO socket not via mgmt interface, that said we may need to do some changes to how we discover the broadcast, it seems we will need to do short lived PA sync to enumerate the BASE, so I think we are better of having the driver register with BAA UUID, initially this can probably be done in userspace so once it detects the device is advertising with BCAA it will attempt to fetch the BASE automatically and merge it into the bt_ad.

Later on we may decide to move this into the kernel as part of general discovery procedure and then merge the discovered BASE into Device Found event, etc, but I think it is too early to evaluate if that is a good idea or not before exploring if the short lived PA sync would work reliably, or if we really need a dedicated API for discovering Broadcasters.

Quoted 6 lines
monitor/packet.c +0 -1
        { }
 };
 
--

2.34.1

Signature · 1 line
Luiz Augusto von Dentz
#5 lore raw

Re: [PATCH BlueZ 2/4] monitor: Add decoding support for BIGInfo mgmt event

Hi Luiz,

Quoted 133 lines

-----Original Message-----
From: Luiz Augusto von Dentz <[email protected]>
Sent: Friday, August 25, 2023 11:06 PM
To: Iulia Tanasescu <[email protected]>
Cc: [email protected]; Claudia Cristina Draghicescu <[email protected]>; Mihai-Octavian Urzica <mihai- [email protected]>; Silviu Florian Barbulescu <[email protected]>; Vlad Pruteanu <[email protected]>; Andrei Istodorescu <[email protected]>
Subject: Re: [PATCH BlueZ 2/4] monitor: Add decoding support for BIGInfo mgmt event

Hi Iulia,

Quoted 5 lines · Iulia Tanasescu

This adds btmon support for decoding BIGInfo MGMT events.

---
monitor/control.c | 25 +++++++++++++++++++++++++ monitor/packet.c

|

monitor/control.c static void mgmt_advertising_removed(uint16_t

Quoted 16 lines

33 +++++++++++++++++++++++++++++++++

 2 files changed, 58 insertions(+)
monitor/control.c index renamed from monitor/control.c +0 -0

009cf1520..b843d076f 100644

monitor/control.c +1 -0
@@ -5,6 +5,7 @@
  *
  *  Copyright (C) 2011-2014  Intel Corporation
  *  Copyright (C) 2002-2010  Marcel Holtmann <[email protected]>
+ *  Copyright 2023 NXP
  *
  *
  */
@@ -788,6 +789,27 @@ static void mgmt_advertising_removed(uint16_t

len, const void *buf)

Quoted 5 lines
monitor/control.c +2 -0
        packet_hexdump(buf, len);
 }
 
+static void mgmt_big_info_adv_report(uint16_t len, const void *buf) {
+       const struct mgmt_ev_le_big_info_adv_report *ev = buf;

monitor/control.c static void mgmt_advertising_removed(uint16_t len, const void *buf)

Quoted 10 lines
monitor/control.c +10 -0
+       uint16_t sync_handle;
+
+       if (len < sizeof(*ev)) {
+               printf("* Malformed BIGInfo advertising report control\n");
+               return;
+       }
+
+       sync_handle = le16_to_cpu(ev->sync_handle);
+
+       printf("@ BIGInfo Advertising Report: sync_handle 0x%4.4x

num_bis %u "

monitor/control.c void control_message(uint16_t opcode, const void

Quoted 13 lines
monitor/control.c +9 -0
+               "encryption %u\n", sync_handle, ev->num_bis,
+ ev->encryption);
+
+       buf += sizeof(*ev);
+       len -= sizeof(*ev);
+
+       packet_hexdump(buf, len);
+}
+
 void control_message(uint16_t opcode, const void *data, uint16_t
 size)  {
        if (!decode_control)
@@ -893,6 +915,9 @@ void control_message(uint16_t opcode, const void

*data, uint16_t size)

monitor/packet.c static void

Quoted 14 lines
monitor/control.c +3 -0
        case MGMT_EV_ADVERTISING_REMOVED:
                mgmt_advertising_removed(size, data);
                break;
+       case MGMT_EV_LE_BIG_INFO_ADV_REPORT:
+               mgmt_big_info_adv_report(size, data);
+               break;
        default:
                printf("* Unknown control (code %d len %d)\n", opcode, size);
                packet_hexdump(data, size); diff --git

a/monitor/packet.c b/monitor/packet.c index 8eae8c9ea..96fc2662e 100644

monitor/packet.c +0 -0
@@ -15396,6 +15396,37 @@ static void

mgmt_mesh_device_found_evt(const void *data, uint16_t size)

Quoted 31 lines
monitor/packet.c +29 -0
        print_hex_field("EIR Data", eir_data, size);  }
 
+static void mgmt_big_info_adv_report(const void *data, uint16_t size)
+{
+       uint16_t sync_handle = get_le16(data);
+       uint8_t num_bis = get_u8(data + 2);
+       uint8_t nse = get_u8(data + 3);
+       uint16_t iso_interval = get_le16(data + 4);
+       uint8_t bn = get_u8(data + 6);
+       uint8_t pto = get_u8(data + 7);
+       uint8_t irc = get_u8(data + 8);
+       uint16_t max_pdu = get_le16(data + 9);
+       const uint8_t *sdu_interval = data + 11;
+       uint16_t max_sdu = get_le16(data + 14);
+       uint8_t phy = get_u8(data + 16);
+       uint8_t framing = get_u8(data + 17);
+       uint8_t encryption = get_u8(data + 18);
+
+       print_field("Sync Handle: 0x%4.4x", sync_handle);
+       print_field("Number BIS: %u", num_bis);
+       print_field("NSE: %u", nse);
+       print_slot_125("ISO Interval", iso_interval);
+       print_field("BN: %u", bn);
+       print_field("PTO: %u", pto);
+       print_field("IRC: %u", irc);
+       print_field("Maximum PDU: %u", max_pdu);
+       print_usec_interval("SDU Interval", sdu_interval);
+       print_field("Maximum SDU: %u", max_sdu);
+       print_le_phy("PHY", phy);
+       print_framing(framing);
+       print_field("Encryption: 0x%02x", encryption); }

monitor/packet.c static void mgmt_mesh_device_found_evt(const void *data, uint16_t size)

Quoted 10 lines
monitor/packet.c +3 -0
+
 static void mgmt_mesh_packet_cmplt_evt(const void *data, uint16_t
 size)  {
        uint8_t handle = get_u8(data); @@ -15500,6 +15531,8 @@ static
 const struct mgmt_data mgmt_event_table[] = {
                        mgmt_mesh_device_found_evt, 22, false },
        { 0x0032, "Mesh Packet Complete",
                        mgmt_mesh_packet_cmplt_evt, 1, true },
+       { 0x0033, "BIGInfo advertising report",
+                       mgmt_big_info_adv_report, 19, false },

This should got to the ISO socket not via mgmt interface, that said we may need to do some changes to how we discover the broadcast, it seems we will need to do short lived PA sync to enumerate the BASE, so I think we are better of having the driver register with BAA UUID, initially this can probably be done in userspace so once it detects the device is advertising with BCAA it will attempt to fetch the BASE automatically and merge it into the bt_ad.

Quoted 6 lines

Later on we may decide to move this into the kernel as part of general discovery procedure and then merge the discovered BASE into Device Found event, etc, but I think it is too early to evaluate if that is a good idea or not before exploring if the short lived PA sync would work reliably, or if we really need a dedicated API for discovering Broadcasters.

I submitted a new kernel patch, which enables a broadcast sink to discover if the PA it has synced with is associated with an encrypted BIG, by looking at the socket QoS.

Quoted 10 lines
Quoted 6 lines
        { }

};

--
2.34.1

--
Luiz Augusto von Dentz

Regards,
Iulia

#6 lore raw

PATCH 3/4 monitor: Fix decoding issue for hci BIGInfo report

In reply to Iulia Tanasescu

This fixes the fact that when decoding a BIGInfo hci report, the bn fild is printed two times.

---
 monitor/packet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/packet.c +1 -1
index 96fc2662e..69600e93d 100644
@@ -11783,7 +11783,7 @@ static void le_big_info_evt(struct timeval *tv, uint16_t index,
 	print_field("NSE: %u", evt->nse);
 	print_slot_125("ISO Interval", evt->iso_interval);
 	print_field("BN: %u", evt->bn);
-	print_field("PTO: %u", evt->bn);
+	print_field("PTO: %u", evt->pto);
 	print_field("IRC: %u", evt->irc);
 	print_field("Maximum PDU: %u", evt->max_pdu);
 	print_usec_interval("SDU Interval", evt->sdu_interval);
Signature · 1 line
2.34.1
#7 lore raw

PATCH 4/4 lib: Add sync_handle to bcast QoS

In reply to Iulia Tanasescu

This adds the sync_handle field to the bt_iso_qos struct.

---
 lib/bluetooth.h | 1 +
 1 file changed, 1 insertion(+)
lib/bluetooth.h +1 -0
index 1286aa763..f007240f4 100644
@@ -187,6 +187,7 @@ struct bt_iso_bcast_qos {
 	uint8_t  sync_cte_type;
 	uint8_t  mse;
 	uint16_t timeout;
+	uint16_t sync_handle;
 };
 
 /* (HCI_MAX_PER_AD_LENGTH - EIR_SERVICE_DATA_LENGTH) */
Signature · 1 line
2.34.1