Skip to content

Commit

Permalink
Bluetooth: Add initial implementation of BIS connections
Browse files Browse the repository at this point in the history
This adds initial support for BIS/BIG which includes:

== Broadcaster role: Setup a periodic advertising and create a BIG ==

> tools/isotest -s 00:00:00:00:00:00
isotest[63]: Connected [00:00:00:00:00:00]
isotest[63]: QoS BIG 0x00 BIS 0x00 Packing 0x00 Framing 0x00]
isotest[63]: Output QoS [Interval 10000 us Latency 10 ms SDU 40 PHY 0x02
RTN 2]
isotest[63]: Sending ...
isotest[63]: Number of packets: 1
isotest[63]: Socket jitter buffer: 80 buffer
< HCI Command: LE Set Perio.. (0x08|0x003e) plen 7
...
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Periodic Advertising Parameters (0x08|0x003e) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Perio.. (0x08|0x003f) plen 7
...
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Periodic Advertising Data (0x08|0x003f) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Perio.. (0x08|0x0040) plen 2
...
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Periodic Advertising Enable (0x08|0x0040) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Create B.. (0x08|0x0068) plen 31
...
> HCI Event: Command Status (0x0f) plen 4
      LE Create Broadcast Isochronous Group (0x08|0x0068) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 21
      LE Broadcast Isochronous Group Complete (0x1b)
      ...

== Broadcast Receiver role: Create a PA Sync and BIG Sync ==

> tools/isotest -i hci1 -d 00:AA:01:00:00:00
isotest[66]: Waiting for connection 00:AA:01:00:00:00...
< HCI Command: LE Periodic Advert.. (0x08|0x0044) plen 14
...
> HCI Event: Command Status (0x0f) plen 4
      LE Periodic Advertising Create Sync (0x08|0x0044) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Extended Sca.. (0x08|0x0041) plen 8
...
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Extended Sca.. (0x08|0x0042) plen 6
...
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Scan Enable (0x08|0x0042) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 29
      LE Extended Advertising Report (0x0d)
      ...
> HCI Event: LE Meta Event (0x3e) plen 16
      LE Periodic Advertising Sync Established (0x0e)
      ...
< HCI Command: LE Broadcast Isoch.. (0x08|0x006b) plen 25
...
> HCI Event: Command Status (0x0f) plen 4
      LE Broadcast Isochronous Group Create Sync (0x08|0x006b) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 17
      LE Broadcast Isochronous Group Sync Estabilished (0x1d)
      ...

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
Vudentz authored and intel-lab-lkp committed May 5, 2022
1 parent 9ab3ba7 commit d69aaea
Show file tree
Hide file tree
Showing 13 changed files with 1,352 additions and 135 deletions.
18 changes: 15 additions & 3 deletions include/net/bluetooth/bluetooth.h
Expand Up @@ -160,6 +160,9 @@ struct bt_voice {
#define BT_ISO_QOS_CIG_UNSET 0xff
#define BT_ISO_QOS_CIS_UNSET 0xff

#define BT_ISO_QOS_BIG_UNSET 0xff
#define BT_ISO_QOS_BIS_UNSET 0xff

struct bt_iso_io_qos {
__u32 interval;
__u16 latency;
Expand All @@ -169,9 +172,18 @@ struct bt_iso_io_qos {
};

struct bt_iso_qos {
__u8 cig;
__u8 cis;
__u8 sca;
union {
__u8 cig;
__u8 big;
};
union {
__u8 cis;
__u8 bis;
};
union {
__u8 sca;
__u8 sync_interval;
};
__u8 packing;
__u8 framing;
struct bt_iso_io_qos in;
Expand Down
162 changes: 155 additions & 7 deletions include/net/bluetooth/hci.h
Expand Up @@ -327,6 +327,7 @@ enum {
HCI_USER_CHANNEL,
HCI_EXT_CONFIGURED,
HCI_LE_ADV,
HCI_LE_PER_ADV,
HCI_LE_SCAN,
HCI_SSP_ENABLED,
HCI_SC_ENABLED,
Expand All @@ -349,6 +350,7 @@ enum {
HCI_LE_SCAN_INTERRUPTED,
HCI_WIDEBAND_SPEECH_ENABLED,
HCI_EVENT_FILTER_CONFIGURED,
HCI_PA_SYNC,

HCI_DUT_MODE,
HCI_VENDOR_DIAG,
Expand Down Expand Up @@ -528,9 +530,11 @@ enum {
#define HCI_LE_PHY_2M 0x01
#define HCI_LE_PHY_CODED 0x08
#define HCI_LE_EXT_ADV 0x10
#define HCI_LE_PERIODIC_ADV 0x20
#define HCI_LE_CHAN_SEL_ALG2 0x40
#define HCI_LE_CIS_CENTRAL 0x10
#define HCI_LE_CIS_PERIPHERAL 0x20
#define HCI_LE_ISO_BROADCASTER 0x40

/* Connection modes */
#define HCI_CM_ACTIVE 0x0000
Expand Down Expand Up @@ -1874,6 +1878,22 @@ struct hci_cp_le_ext_conn_param {
__le16 max_ce_len;
} __packed;

#define HCI_OP_LE_PA_CREATE_SYNC 0x2044
struct hci_cp_le_pa_create_sync {
__u8 options;
__u8 sid;
__u8 addr_type;
bdaddr_t addr;
__le16 skip;
__le16 sync_timeout;
__u8 sync_cte_type;
} __packed;

#define HCI_OP_LE_PA_TERM_SYNC 0x2046
struct hci_cp_le_pa_term_sync {
__le16 handle;
} __packed;

#define HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS 0x203b
struct hci_rp_le_read_num_supported_adv_sets {
__u8 status;
Expand Down Expand Up @@ -1908,13 +1928,6 @@ struct hci_rp_le_set_ext_adv_params {
__u8 tx_power;
} __packed;

#define HCI_OP_LE_SET_EXT_ADV_ENABLE 0x2039
struct hci_cp_le_set_ext_adv_enable {
__u8 enable;
__u8 num_of_sets;
__u8 data[];
} __packed;

struct hci_cp_ext_adv_set {
__u8 handle;
__le16 duration;
Expand All @@ -1941,6 +1954,37 @@ struct hci_cp_le_set_ext_scan_rsp_data {
__u8 data[];
} __packed;

#define HCI_OP_LE_SET_EXT_ADV_ENABLE 0x2039
struct hci_cp_le_set_ext_adv_enable {
__u8 enable;
__u8 num_of_sets;
__u8 data[];
} __packed;

#define HCI_OP_LE_SET_PER_ADV_PARAMS 0x203e
struct hci_cp_le_set_per_adv_params {
__u8 handle;
__le16 min_interval;
__le16 max_interval;
__le16 periodic_properties;
} __packed;

#define HCI_MAX_PER_AD_LENGTH 252

#define HCI_OP_LE_SET_PER_ADV_DATA 0x203f
struct hci_cp_le_set_per_adv_data {
__u8 handle;
__u8 operation;
__u8 length;
__u8 data[];
} __packed;

#define HCI_OP_LE_SET_PER_ADV_ENABLE 0x2040
struct hci_cp_le_set_per_adv_enable {
__u8 enable;
__u8 handle;
} __packed;

#define LE_SET_ADV_DATA_OP_COMPLETE 0x03

#define LE_SET_ADV_DATA_NO_FRAG 0x01
Expand Down Expand Up @@ -2052,6 +2096,49 @@ struct hci_cp_le_reject_cis {
__u8 reason;
} __packed;

#define HCI_OP_LE_CREATE_BIG 0x2068
struct hci_bis {
__u8 sdu_interval[3];
__u16 sdu;
__u16 latency;
__u8 rtn;
__u8 phy;
__u8 packing;
__u8 framing;
__u8 encryption;
__u8 bcode[16];
} __packed;

struct hci_cp_le_create_big {
__u8 handle;
__u8 adv_handle;
__u8 num_bis;
struct hci_bis bis;
} __packed;

#define HCI_OP_LE_TERM_BIG 0x206a
struct hci_cp_le_term_big {
__u8 handle;
__u8 reason;
} __packed;

#define HCI_OP_LE_BIG_CREATE_SYNC 0x206b
struct hci_cp_le_big_create_sync {
__u8 handle;
__le16 sync_handle;
__u8 encryption;
__u8 bcode[16];
__u8 mse;
__le16 timeout;
__u8 num_bis;
__u8 bis[0];
} __packed;

#define HCI_OP_LE_BIG_TERM_SYNC 0x206c
struct hci_cp_le_big_term_sync {
__u8 handle;
} __packed;

#define HCI_OP_LE_SETUP_ISO_PATH 0x206e
struct hci_cp_le_setup_iso_path {
__le16 handle;
Expand Down Expand Up @@ -2604,6 +2691,18 @@ struct hci_ev_le_ext_adv_report {
struct hci_ev_le_ext_adv_info info[];
} __packed;

#define HCI_EV_LE_PA_SYNC_ESTABLISHED 0x0e
struct hci_ev_le_pa_sync_established {
__u8 status;
__le16 handle;
__u8 sid;
__u8 bdaddr_type;
bdaddr_t bdaddr;
__u8 phy;
__le16 interval;
__u8 clock_accuracy;
} __packed;

#define HCI_EV_LE_ENHANCED_CONN_COMPLETE 0x0a
struct hci_ev_le_enh_conn_complete {
__u8 status;
Expand Down Expand Up @@ -2655,6 +2754,55 @@ struct hci_evt_le_cis_req {
__u8 cis_id;
} __packed;

#define HCI_EVT_LE_CREATE_BIG_COMPLETE 0x1b
struct hci_evt_le_create_big_complete {
__u8 status;
__u8 handle;
__u8 sync_delay[3];
__u8 transport_delay[3];
__u8 phy;
__u8 nse;
__u8 bn;
__u8 pto;
__u8 irc;
__le16 max_pdu;
__le16 interval;
__u8 num_bis;
__le16 bis_handle[];
} __packed;

#define HCI_EVT_LE_BIG_SYNC_ESTABILISHED 0x1d
struct hci_evt_le_big_sync_estabilished {
__u8 status;
__u8 handle;
__u8 latency[3];
__u8 nse;
__u8 bn;
__u8 pto;
__u8 irc;
__le16 max_pdu;
__le16 interval;
__u8 num_bis;
__le16 bis[];
} __packed;

#define HCI_EVT_LE_BIG_INFO_ADV_REPORT 0x22
struct hci_evt_le_big_info_adv_report {
__le16 sync_handle;
__u8 num_bis;
__u8 nse;
__le16 iso_interval;
__u8 bn;
__u8 pto;
__u8 irc;
__le16 max_pdu;
__u8 sdu_interval[3];
__le16 max_sdu;
__u8 phy;
__u8 framing;
__u8 encryption;
} __packed;

#define HCI_EV_VENDOR 0xff

/* Internal events generated by Bluetooth stack */
Expand Down

0 comments on commit d69aaea

Please sign in to comment.