Bluetooth: hci_core: Introduce hci_recv_event_data
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v6 1/7 Bluetooth: hci_core: Introduce hci_recv_event_data
From: Luiz Augusto von Dentz <[email protected]>
This introduces hci_recv_event_data to make it simpler to access the contents of last received event rather than having to pass its contents to the likes of *_ind/*_cfm callbacks.
---
v2: Fixes CI/kernel test robot findings
v3: Fix crash when disabling ISO Socket experimental UUID.
v4: Fix crashes when running iso-tester Defer and Defer Send tests which just binds the CIS using DEFER_SETUP without attempting to connect it at first.
v5: Fix kbuild findings
v6: Fix checkpatch findings
include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_core.c | 32 ++++++++++++++++++++++++++++++++ net/bluetooth/hci_event.c | 3 +++ 3 files changed, 37 insertions(+)
include/net/bluetooth/hci_core.h +2 -0
@@ -530,6 +530,7 @@ struct hci_dev {struct sk_buff_head cmd_q;struct sk_buff *sent_cmd; +struct sk_buff *recv_event;struct mutex req_lock;wait_queue_head_t req_wait_q;
@@ -1755,6 +1756,7 @@ void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags);void hci_send_sco (struct hci_conn *conn,struct sk_buff *skb);void *hci_sent_cmd_data (struct hci_dev *hdev,__u16 opcode); +void *hci_recv_event_data (struct hci_dev *hdev,__u8 event);u32 hci_conn_get_phy (struct hci_conn *conn);
net/bluetooth/hci_core.c +32 -0
@@ -2739,6 +2739,7 @@ void hci_release_dev(struct hci_dev *hdev)ida_simple_remove (&hci_index_ida, hdev->id);kfree_skb (hdev->sent_cmd); +kfree_skb (hdev->recv_event);kfree (hdev); }EXPORT_SYMBOL (hci_release_dev);
@@ -3045,6 +3046,37 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode)return hdev->sent_cmd->data +HCI_COMMAND_HDR_SIZE ; } +/* Get data from last received event */ +void *hci_recv_event_data (struct hci_dev *hdev,__u8 event) +{ +struct hci_event_hdr *hdr; +int offset; + +if (!hdev->recv_event) +return NULL ; + + hdr = (void *)hdev->recv_event->data; + offset =sizeof (*hdr); + +if (hdr->evt != event) { +/* In case of LE metaevent check the subevent match */ +if (hdr->evt ==HCI_EV_LE_META ) { +struct hci_ev_le_meta *ev; + + ev = (void *)hdev->recv_event->data + offset; + offset +=sizeof (*ev); +if (ev->subevent == event) + goto found; + } +return NULL ; + } + +found: +bt_dev_dbg (hdev,"event 0x%2.2x" , event); + +return hdev->recv_event->data + offset; +} +/* Send ACL data */ static void hci_add_acl_hdr (struct sk_buff *skb,__u16 handle,__u16 flags) {
net/bluetooth/hci_event.c +3 -0
@@ -6936,6 +6936,9 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) goto done; } +kfree_skb (hdev->recv_event); + hdev->recv_event =skb_clone (skb,GFP_KERNEL ); + event = hdr->evt;if (!event) { bt_dev_warn(hdev, "Received unexpected HCI Event 0x%2.2x",
Signature · 1 line
2.35.3
Luiz Augusto von Dentz
maintainerPATCH v6 2/7 Bluetooth: Add initial implementation of CIS connections
From: Luiz Augusto von Dentz <[email protected]>
This adds the initial implementation of CIS connections and introduces the ISO packets/links.
== Central: Set CIG Parameters, create a CIS and Setup Data Path ==
Quoted 1 line
tools/isotest-s <address>
< HCI Command: LE Extended Create... (0x08|0x0043) plen 26
...
Quoted 1 line
HCI Event: Command Status (
0x0f) plen 4
LE Extended Create Connection (0x08|0x0043) ncmd 1
Status: Success (0x00)Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 31
LE Enhanced Connection Complete (0x0a)
...< HCI Command: LE Create Connected... (0x08|0x0064) plen 5
...
Quoted 1 line
HCI Event: Command Status (
0x0f) plen 4
LE Create Connected Isochronous Stream (0x08|0x0064) ncmd 1
Status: Success (0x00)Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 29
LE Connected Isochronous Stream Established (0x19)
...< HCI Command: LE Setup Isochronou.. (0x08|0x006e) plen 13
...
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 6
LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
Status: Success (0x00)
Handle: 257< HCI Command: LE Setup Isochronou.. (0x08|0x006e) plen 13
...
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 6
LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
Status: Success (0x00)
Handle: 257== Peripheral: Accept CIS and Setup Data Path ==
Quoted 1 line
tools/isotest-d
HCI Event: LE Meta Event (0x3e) plen 7
LE Connected Isochronous Stream Request (0x1a)
...
< HCI Command: LE Accept Co.. (0x08|0x0066) plen 2
...
Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 29
LE Connected Isochronous Stream Established (0x19)
...
< HCI Command: LE Setup Is.. (0x08|0x006e) plen 13
...
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 6
LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
Status: Success (0x00)
Handle: 257< HCI Command: LE Setup Is.. (0x08|0x006e) plen 13
...
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 6
LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
Status: Success (0x00)
Handle: 257--- include/net/bluetooth/bluetooth.h | 33 ++- include/net/bluetooth/hci.h | 28 +- include/net/bluetooth/hci_core.h | 107 +++++++- include/net/bluetooth/hci_sock.h | 2 + include/net/bluetooth/hci_sync.h | 3 + net/bluetooth/Kconfig | 1 + net/bluetooth/hci_conn.c | 440 ++++++++++++++++++++++++++++++ net/bluetooth/hci_core.c | 230 ++++++++++++---- net/bluetooth/hci_event.c | 307 ++++++++++++++++++++- net/bluetooth/hci_sync.c | 49 +++- 10 files changed, 1145 insertions(+), 55 deletions(-)
include/net/bluetooth/bluetooth.h +32 -1
@@ -55,6 +55,8 @@#define BTPROTO_CMTP 5#define BTPROTO_HIDP 6#define BTPROTO_AVDTP 7 +#define BTPROTO_ISO 8 +#define BTPROTO_LAST BTPROTO_ISO#define SOL_HCI 0#define SOL_L2CAP 6
@@ -149,10 +151,39 @@ struct bt_voice {#define BT_MODE_LE_FLOWCTL 0x03#define BT_MODE_EXT_FLOWCTL 0x04 -#define BT_PKT_STATUS 16 +#define BT_PKT_STATUS 16#define BT_SCM_PKT_STATUS 0x03 +#define BT_ISO_QOS 17 + +#define BT_ISO_QOS_CIG_UNSET 0xff +#define BT_ISO_QOS_CIS_UNSET 0xff + +struct bt_iso_io_qos { +__u32 interval; +__u16 latency; +__u16 sdu; +__u8 phy; +__u8 rtn; +}; + +struct bt_iso_qos { +__u8 cig; +__u8 cis; +__u8 sca; +__u8 packing; +__u8 framing; +struct bt_iso_io_qos in; +struct bt_iso_io_qos out; +}; + +#define BT_ISO_PHY_1M 0x01 +#define BT_ISO_PHY_2M 0x02 +#define BT_ISO_PHY_CODED 0x04 +#define BT_ISO_PHY_ANY (BT_ISO_PHY_1M | BT_ISO_PHY_2M | \ + BT_ISO_PHY_CODED) +#define BT_CODEC 19struct bt_codec_caps {
include/net/bluetooth/hci.h +26 -2
@@ -1999,7 +1999,7 @@ struct hci_rp_le_read_iso_tx_sync {struct hci_cis_params {__u8 cis_id;__le16 c_sdu; -__le16 p_pdu; +__le16 p_sdu;__u8 c_phy;__u8 p_phy;__u8 c_rtn;
@@ -2010,7 +2010,7 @@ struct hci_cp_le_set_cig_params {__u8 cig_id;__u8 c_interval[3 ];__u8 p_interval[3 ]; -__u8 wc_sca; +__u8 sca;__u8 packing;__u8 framing;__le16 c_latency;
@@ -2053,6 +2053,30 @@ struct hci_cp_le_reject_cis {__u8 reason; } __packed; +#define HCI_OP_LE_SETUP_ISO_PATH 0x206e +struct hci_cp_le_setup_iso_path { +__le16 handle; +__u8 direction; +__u8 path; +__u8 codec; +__le16 codec_cid; +__le16 codec_vid; +__u8 delay[3 ]; +__u8 codec_cfg_len; +__u8 codec_cfg[0 ]; +} __packed; + +struct hci_rp_le_setup_iso_path { +__u8 status; +__le16 handle; +} __packed; + +#define HCI_OP_LE_SET_HOST_FEATURE 0x2074 +struct hci_cp_le_set_host_feature { +__u8 bit_number; +__u8 bit_value; +} __packed; +/* ---- HCI Events ---- */ struct hci_ev_status {__u8 status;
include/net/bluetooth/hci_core.h +106 -1
216 lines not on this page · raw message
include/net/bluetooth/hci_sock.h +2 -0
@@ -124,6 +124,8 @@ struct hci_dev_info {__u16 acl_pkts;__u16 sco_mtu;__u16 sco_pkts; +__u16 iso_mtu; +__u16 iso_pkts;struct hci_dev_stats stat; };
include/net/bluetooth/hci_sync.h +3 -0
@@ -106,3 +106,6 @@ int hci_resume_sync(struct hci_dev *hdev);struct hci_conn ;int hci_le_create_conn_sync (struct hci_dev *hdev,struct hci_conn *conn); + +int hci_le_remove_cig_sync (struct hci_dev *hdev,u8 handle); +int hci_le_remove_cig (struct hci_dev *hdev,u8 handle);
net/bluetooth/Kconfig +1 -0
@@ -29,6 +29,7 @@ menuconfig BT SCO audio links L2CAP (Logical Link Control and Adaptation Protocol) SMP (Security Manager Protocol) on LE (Low Energy) links + ISO isochronous links HCI Device drivers (Interface to the hardware) RFCOMM Module (RFCOMM Protocol) BNEP Module (Bluetooth Network Encapsulation Protocol)
net/bluetooth/hci_conn.c +440 -0
458 lines not on this page · raw message
net/bluetooth/hci_core.c +183 -47
292 lines not on this page · raw message
net/bluetooth/hci_event.c +304 -3
355 lines not on this page · raw message
net/bluetooth/hci_sync.c +48 -1
88 lines not on this page · raw message
Signature · 1 line
2.35.3
Luiz Augusto von Dentz
maintainerPATCH v6 3/7 Bluetooth: Add BTPROTO_ISO socket type
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This introduces a new socket type BTPROTO_ISO which can be enabled with use of ISO Socket experiemental UUID, it can used to initiate/accept connections and transfer packets between userspace and kernel similarly to how BTPROTO_SCO works:
Central -> uses connect with address set to destination bdaddr:
Quoted 1 line
tools/isotest-s 00:AA:01:00:00:00
Peripheral -> uses listen:
Quoted 1 line
tools/isotest-d
--- include/net/bluetooth/bluetooth.h | 21 + include/net/bluetooth/hci_core.h | 18 +- include/net/bluetooth/iso.h | 21 + net/bluetooth/Makefile | 1 + net/bluetooth/af_bluetooth.c | 4 +- net/bluetooth/hci_core.c | 6 +- net/bluetooth/iso.c | 1498 +++++++++++++++++++++++++++++ net/bluetooth/mgmt.c | 69 +- 8 files changed, 1633 insertions(+), 5 deletions(-) create mode 100644 include/net/bluetooth/iso.h create mode 100644 net/bluetooth/iso.c
include/net/bluetooth/bluetooth.h +21 -0
@@ -590,6 +590,27 @@ static inline void sco_exit(void) }#endif +#if IS_ENABLED (CONFIG_BT_LE ) +int iso_init (void ); +int iso_exit (void ); +bool iso_enabled (void ); +#else +static inline int iso_init (void ) +{ +return 0 ; +} + +static inline int iso_exit (void ) +{ +return 0 ; +} + +static inline bool iso_enabled (void ) +{ +return false; +} +#endif +int mgmt_init (void );void mgmt_exit (void );
include/net/bluetooth/hci_core.h +16 -2
@@ -848,6 +848,21 @@ static inline void sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb) }#endif +#if IS_ENABLED (CONFIG_BT_LE ) +int iso_connect_ind (struct hci_dev *hdev,bdaddr_t *bdaddr,__u8 *flags); +void iso_recv (struct hci_conn *hcon,struct sk_buff *skb,u16 flags); +#else +static inline int iso_connect_ind (struct hci_dev *hdev,bdaddr_t *bdaddr, +__u8 *flags) +{ +return 0 ; +} +static inline void iso_recv (struct hci_conn *hcon,struct sk_buff *skb, +u16 flags) +{ +} +#endif +/* ----- Inquiry cache ----- */ #define INQUIRY_CACHE_AGE_MAX (HZ*30)/* 30 seconds */ #define INQUIRY_ENTRY_AGE_MAX (HZ*60)/* 60 seconds */
@@ -1648,8 +1663,7 @@ static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,return sco_connect_ind (hdev, bdaddr, flags);case ISO_LINK : -/* TODO: Handle connection indication */ -return -EINVAL ; +return iso_connect_ind (hdev, bdaddr, flags);default :BT_ERR ("unknown link type %d" , type);
include/net/bluetooth/iso.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2022 Intel Corporation +*/ + +#ifndef __ISO_H +#define __ISO_H + +/* ISO defaults */ +#define ISO_DEFAULT_MTU 251 + +/* ISO socket address */ +struct sockaddr_iso { +sa_family_t iso_family; +bdaddr_t iso_bdaddr; +__u8 iso_bdaddr_type; +}; + +#endif /* __ISO_H */
net/bluetooth/Makefile +1 -0
@@ -18,6 +18,7 @@ bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ eir.o hci_sync.o bluetooth-$(CONFIG_BT_BREDR) += sco.o +bluetooth-$(CONFIG_BT_LE) += iso.o bluetooth-$(CONFIG_BT_HS) += a2mp.o amp.o bluetooth-$(CONFIG_BT_LEDS) += leds.o bluetooth-$(CONFIG_BT_MSFTEXT) += msft.o
net/bluetooth/af_bluetooth.c +3 -1
@@ -38,7 +38,7 @@#include "selftest.h" /* Bluetooth sockets */ -#define BT_MAX_PROTO 8 +#define BT_MAX_PROTO (BTPROTO_LAST + 1)static const struct net_proto_family *bt_proto[BT_MAX_PROTO ];static DEFINE_RWLOCK (bt_proto_lock);
@@ -52,6 +52,7 @@ static const char *const bt_key_strings[BT_MAX_PROTO] = {"sk_lock-AF_BLUETOOTH-BTPROTO_CMTP" ,"sk_lock-AF_BLUETOOTH-BTPROTO_HIDP" ,"sk_lock-AF_BLUETOOTH-BTPROTO_AVDTP" , + "sk_lock-AF_BLUETOOTH-BTPROTO_ISO", };static struct lock_class_key bt_slock_key[BT_MAX_PROTO ];
@@ -64,6 +65,7 @@ static const char *const bt_slock_key_strings[BT_MAX_PROTO] = {"slock-AF_BLUETOOTH-BTPROTO_CMTP" ,"slock-AF_BLUETOOTH-BTPROTO_HIDP" ,"slock-AF_BLUETOOTH-BTPROTO_AVDTP" , + "slock-AF_BLUETOOTH-BTPROTO_ISO", };void bt_sock_reclassify_lock (struct sock *sk,int proto)
net/bluetooth/hci_core.c +5 -1
@@ -3849,12 +3849,16 @@ static void hci_isodata_packet(struct hci_dev *hdev, struct sk_buff *skb) conn =hci_conn_hash_lookup_handle (hdev, handle);hci_dev_unlock (hdev); -/* TODO: Send to upper protocol */ if (!conn) {bt_dev_err (hdev,"ISO packet for unknown connection handle %d" , handle); + goto drop; } +/* Send to upper protocol */ +iso_recv (conn, skb, flags); +return ; + drop:kfree_skb (skb); }
net/bluetooth/iso.c new file +1498 -0
1,498 lines not on this page · raw message
net/bluetooth/mgmt.c +68 -1
96 lines not on this page · raw message
Signature · 1 line
2.35.3
Luiz Augusto von Dentz
maintainerPATCH v6 4/7 Bluetooth: Add initial implementation of BIS connections
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds initial support for BIS/BIG which includes:
== Broadcaster role: Setup a periodic advertising and create a BIG ==
Quoted 1 line
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
...
Quoted 1 line
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
...
Quoted 1 line
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
...
Quoted 1 line
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
...
Quoted 1 line
HCI Event: Command Status (
0x0f) plen 4
LE Create Broadcast Isochronous Group (0x08|0x0068) ncmd 1
Status: Success (0x00)Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 21
LE Broadcast Isochronous Group Complete (0x1b)
...== Broadcast Receiver role: Create a PA Sync and BIG Sync ==
Quoted 1 line
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
...
Quoted 1 line
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
...
Quoted 1 line
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
...
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4
LE Set Extended Scan Enable (0x08|0x0042) ncmd 1
Status: Success (0x00)Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 29
LE Extended Advertising Report (0x0d)
...Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 16
LE Periodic Advertising Sync Established (0x0e)
...< HCI Command: LE Broadcast Isoch.. (0x08|0x006b) plen 25
...
Quoted 1 line
HCI Event: Command Status (
0x0f) plen 4
LE Broadcast Isochronous Group Create Sync (0x08|0x006b) ncmd 1
Status: Success (0x00)Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 17
LE Broadcast Isochronous Group Sync Estabilished (0x1d)
...--- include/net/bluetooth/bluetooth.h | 18 +- include/net/bluetooth/hci.h | 162 ++++++++- include/net/bluetooth/hci_core.h | 89 ++++- include/net/bluetooth/hci_sync.h | 12 +- net/bluetooth/eir.c | 21 ++ net/bluetooth/eir.h | 1 + net/bluetooth/hci_conn.c | 561 +++++++++++++++++++++++++++--- net/bluetooth/hci_core.c | 80 +++-- net/bluetooth/hci_event.c | 206 +++++++++++ net/bluetooth/hci_request.c | 36 +- net/bluetooth/hci_request.h | 9 + net/bluetooth/hci_sync.c | 249 ++++++++++++- net/bluetooth/mgmt.c | 15 +- 13 files changed, 1333 insertions(+), 126 deletions(-)
include/net/bluetooth/bluetooth.h +15 -3
@@ -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;
@@ -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;
include/net/bluetooth/hci.h +155 -7
219 lines not on this page · raw message
include/net/bluetooth/hci_core.h +80 -9
167 lines not on this page · raw message
include/net/bluetooth/hci_sync.h +11 -1
@@ -65,6 +65,10 @@ int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance);int hci_enable_advertising_sync (struct hci_dev *hdev);int hci_enable_advertising (struct hci_dev *hdev); +int hci_start_per_adv_sync (struct hci_dev *hdev,u8 instance,u8 data_len, +u8 *data,u32 flags,u16 min_interval, +u16 max_interval,u16 sync_interval); +int hci_remove_advertising_sync (struct hci_dev *hdev,struct sock *sk,u8 instance,bool force);int hci_disable_advertising_sync (struct hci_dev *hdev);
@@ -82,6 +86,7 @@ int hci_update_scan_sync(struct hci_dev *hdev);int hci_write_le_host_supported_sync (struct hci_dev *hdev,u8 le,u8 simul);int hci_remove_ext_adv_instance_sync (struct hci_dev *hdev,u8 instance,struct sock *sk); +int hci_remove_ext_adv_instance (struct hci_dev *hdev,u8 instance);struct sk_buff *hci_read_local_oob_data_sync (struct hci_dev *hdev,bool ext,struct sock *sk);
@@ -108,4 +113,9 @@ struct hci_conn;int hci_le_create_conn_sync (struct hci_dev *hdev,struct hci_conn *conn);int hci_le_remove_cig_sync (struct hci_dev *hdev,u8 handle); -int hci_le_remove_cig (struct hci_dev *hdev,u8 handle); + +int hci_le_terminate_big_sync (struct hci_dev *hdev,u8 handle,u8 reason); + +int hci_le_big_terminate_sync (struct hci_dev *hdev,u8 handle); + +int hci_le_pa_terminate_sync (struct hci_dev *hdev,u16 handle);
net/bluetooth/eir.c +21 -0
@@ -236,6 +236,27 @@ void eir_create(struct hci_dev *hdev, u8 *data) ptr =create_uuid128_list (hdev, ptr,HCI_MAX_EIR_LENGTH - (ptr - data)); } +u8 eir_create_per_adv_data (struct hci_dev *hdev,u8 instance,u8 *ptr) +{ +struct adv_info *adv =NULL ; +u8 ad_len =0 ; + +/* Return 0 when the current instance identifier is invalid. */ +if (instance) { + adv =hci_find_adv_instance (hdev, instance); +if (!adv) +return 0 ; + } + +if (adv) { +memcpy (ptr, adv->per_adv_data, adv->per_adv_data_len); + ad_len += adv->per_adv_data_len; + ptr += adv->per_adv_data_len; + } + +return ad_len; +} +u8 eir_create_adv_data (struct hci_dev *hdev,u8 instance,u8 *ptr) {struct adv_info *adv =NULL ;
net/bluetooth/eir.h +1 -0
@@ -11,6 +11,7 @@ void eir_create(struct hci_dev *hdev, u8 *data);u8 eir_create_adv_data (struct hci_dev *hdev,u8 instance,u8 *ptr);u8 eir_create_scan_rsp (struct hci_dev *hdev,u8 instance,u8 *ptr); +u8 eir_create_per_adv_data (struct hci_dev *hdev,u8 instance,u8 *ptr);u8 eir_append_local_name (struct hci_dev *hdev,u8 *eir,u8 ad_len);u8 eir_append_appearance (struct hci_dev *hdev,u8 *ptr,u8 ad_len);
net/bluetooth/hci_conn.c +508 -53
622 lines not on this page · raw message
net/bluetooth/hci_core.c +50 -30
107 lines not on this page · raw message
net/bluetooth/hci_event.c +206 -0
248 lines not on this page · raw message
net/bluetooth/hci_request.c +21 -15
@@ -827,7 +827,6 @@ void __hci_req_disable_advertising(struct hci_request *req) {if (ext_adv_capable (req->hdev)) {__hci_req_disable_ext_adv_instance (req,0x00 ); - }else {u8 enable =0x00 ;
@@ -1338,15 +1337,15 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)bdaddr_t random_addr;u8 own_addr_type;int err; -struct adv_info *adv_instance; -bool secondary_adv; +struct adv_info *adv; +bool secondary_adv, require_privacy;if (instance >0 ) { - adv_instance =hci_find_adv_instance (hdev, instance); -if (!adv_instance) + adv =hci_find_adv_instance (hdev, instance); +if (!adv)return -EINVAL ; }else { - adv_instance =NULL ; + adv =NULL ; } flags =hci_adv_instance_flags (hdev, instance);
@@ -1364,18 +1363,24 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)* advertising is used. In that case it is fine to use a * non-resolvable private address. */ - err =hci_get_random_address (hdev, !connectable, -adv_use_rpa (hdev, flags), adv_instance, + require_privacy = !connectable; + +/* Don't require privacy for periodic adv? */ +if (adv && adv->periodic) + require_privacy = false; + + err =hci_get_random_address (hdev, require_privacy, +adv_use_rpa (hdev, flags), adv, &own_addr_type, &random_addr);if (err <0 )return err;memset (&cp,0 ,sizeof (cp)); -if (adv_instance) { -hci_cpu_to_le24 (adv_instance->min_interval, cp.min_interval); -hci_cpu_to_le24 (adv_instance->max_interval, cp.max_interval); - cp.tx_power = adv_instance->tx_power; +if (adv) { +hci_cpu_to_le24 (adv->min_interval, cp.min_interval); +hci_cpu_to_le24 (adv->max_interval, cp.max_interval); + cp.tx_power = adv->tx_power; }else {hci_cpu_to_le24 (hdev->le_adv_min_interval, cp.min_interval);hci_cpu_to_le24 (hdev->le_adv_max_interval, cp.max_interval);
@@ -1396,7 +1401,8 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)else cp.evt_properties =cpu_to_le16 (LE_LEGACY_ADV_SCAN_IND ); }else { -if (secondary_adv) +/* Secondary and periodic cannot use legacy PDUs */ +if (secondary_adv || (adv && adv->periodic)) cp.evt_properties =cpu_to_le16 (LE_EXT_ADV_NON_CONN_IND );else cp.evt_properties =cpu_to_le16 (LE_LEGACY_NONCONN_IND );
@@ -1426,8 +1432,8 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)struct hci_cp_le_set_adv_set_rand_addr cp;/* Check if random address need to be updated */ -if (adv_instance) { -if (!bacmp (&random_addr, &adv_instance->random_addr)) +if (adv) { +if (!bacmp (&random_addr, &adv->random_addr))return 0 ; }else {if (!bacmp (&random_addr, &hdev->random_addr))
net/bluetooth/hci_request.h +9 -0
@@ -85,6 +85,9 @@ void __hci_req_enable_advertising(struct hci_request *req);void __hci_req_disable_advertising (struct hci_request *req);void __hci_req_update_adv_data (struct hci_request *req,u8 instance);int hci_req_update_adv_data (struct hci_dev *hdev,u8 instance); +int hci_req_start_per_adv (struct hci_dev *hdev,u8 instance,u32 flags, +u16 min_interval,u16 max_interval, +u16 sync_interval);void __hci_req_update_scan_rsp_data (struct hci_request *req,u8 instance); int __hci_req_schedule_adv_instance(struct hci_request *req, u8 instance,
@@ -94,8 +97,14 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk, bool force);int __hci_req_setup_ext_adv_instance (struct hci_request *req,u8 instance); +int __hci_req_setup_per_adv_instance (struct hci_request *req,u8 instance, +u16 min_interval,u16 max_interval);int __hci_req_start_ext_adv (struct hci_request *req,u8 instance); +int __hci_req_start_per_adv (struct hci_request *req,u8 instance,u32 flags, +u16 min_interval,u16 max_interval, +u16 sync_interval);int __hci_req_enable_ext_advertising (struct hci_request *req,u8 instance); +int __hci_req_enable_per_advertising (struct hci_request *req,u8 instance);int __hci_req_disable_ext_adv_instance (struct hci_request *req,u8 instance);int __hci_req_remove_ext_adv_instance (struct hci_request *req,u8 instance);void __hci_req_clear_ext_adv_sets (struct hci_request *req);
net/bluetooth/hci_sync.c +248 -1
276 lines not on this page · raw message
net/bluetooth/mgmt.c +8 -7
@@ -8166,7 +8166,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,u16 timeout, duration;unsigned int prev_instance_cnt;u8 schedule_instance =0 ; -struct adv_info *next_instance; +struct adv_info *adv, *next_instance;int err;struct mgmt_pending_cmd *cmd;
@@ -8217,7 +8217,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, prev_instance_cnt = hdev->adv_instance_cnt; - err = hci_add_adv_instance(hdev, cp->instance, flags, + adv = hci_add_adv_instance(hdev, cp->instance, flags, cp->adv_data_len, cp->data, cp->scan_rsp_len, cp->data + cp->adv_data_len,
@@ -8225,7 +8225,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,HCI_ADV_TX_POWER_NO_PREFERENCE , hdev->le_adv_min_interval, hdev->le_adv_max_interval); -if (err <0 ) { +if (IS_ERR (adv)) { err =mgmt_cmd_status (sk, hdev->id,MGMT_OP_ADD_ADVERTISING ,MGMT_STATUS_FAILED ); goto unlock;
@@ -8356,6 +8356,7 @@ static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev,struct mgmt_cp_add_ext_adv_params *cp = data;struct mgmt_rp_add_ext_adv_params rp;struct mgmt_pending_cmd *cmd =NULL ; +struct adv_info *adv;u32 flags, min_interval, max_interval;u16 timeout, duration;u8 status;
@@ -8425,11 +8426,11 @@ static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev,HCI_ADV_TX_POWER_NO_PREFERENCE ;/* Create advertising instance with no advertising or response data */ - err =hci_add_adv_instance (hdev, cp->instance, flags, -0 ,NULL ,0 ,NULL , timeout, duration, - tx_power, min_interval, max_interval); + adv =hci_add_adv_instance (hdev, cp->instance, flags,0 ,NULL ,0 ,NULL , + timeout, duration, tx_power, min_interval, + max_interval); -if (err <0 ) { +if (IS_ERR (adv)) { err =mgmt_cmd_status (sk, hdev->id,MGMT_OP_ADD_EXT_ADV_PARAMS ,MGMT_STATUS_FAILED ); goto unlock;
Signature · 1 line
2.35.3
Luiz Augusto von Dentz
maintainerPATCH v6 5/7 Bluetooth: ISO: Add broadcast support
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds broadcast support for BTPROTO_ISO by extending the sockaddr_iso with a new struct sockaddr_iso_bc where the socket user can set the broadcast address when receiving, the SID and the BIS indexes it wants to synchronize.
When using BTPROTO_ISO for broadcast the roles are:
Broadcaster -> uses connect with address set to BDADDR_ANY:
Quoted 1 line
tools/isotest-s 00:00:00:00:00:00
Broadcast Receiver -> uses listen with address set to broadcaster:
Quoted 1 line
tools/isotest-d 00:AA:01:00:00:00
--- include/net/bluetooth/bluetooth.h | 2 + include/net/bluetooth/iso.h | 11 + net/bluetooth/iso.c | 393 +++++++++++++++++++++++++++--- 3 files changed, 371 insertions(+), 35 deletions(-)
include/net/bluetooth/bluetooth.h +2 -0
@@ -220,6 +220,8 @@ struct bt_codecs {#define BT_CODEC_TRANSPARENT 0x03#define BT_CODEC_MSBC 0x05 +#define BT_ISO_BASE 20 + __printf(1, 2)void bt_info (const char *fmt, ...);__printf (1 ,2 )
include/net/bluetooth/iso.h +11 -0
@@ -10,12 +10,23 @@/* ISO defaults */ #define ISO_DEFAULT_MTU 251 +#define ISO_MAX_NUM_BIS 0x1f + +/* ISO socket broadcast address */ +struct sockaddr_iso_bc { +bdaddr_t bc_bdaddr; +__u8 bc_bdaddr_type; +__u8 bc_sid; +__u8 bc_num_bis; +__u8 bc_bis[ISO_MAX_NUM_BIS ]; +};/* ISO socket address */ struct sockaddr_iso {sa_family_t iso_family;bdaddr_t iso_bdaddr;__u8 iso_bdaddr_type; +struct sockaddr_iso_bc iso_bc[]; };#endif /* __ISO_H */
net/bluetooth/iso.c +358 -35
540 lines not on this page · raw message
Signature · 1 line
2.35.3
Luiz Augusto von Dentz
maintainerPATCH v6 6/7 Bluetooth: btusb: Add support for ISO packets
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This enabled btusb driver to properly transmit ISO packets.
--- drivers/bluetooth/btusb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/bluetooth/btusb.c +14 -0
@@ -1765,6 +1765,13 @@ static int btusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb) hdev->stat.sco_tx++;return submit_tx_urb (hdev, urb); + +case HCI_ISODATA_PKT : + urb =alloc_bulk_urb (hdev, skb); +if (IS_ERR (urb)) +return PTR_ERR (urb); + +return submit_or_queue_tx_urb (hdev, urb); }return -EILSEQ ;
@@ -2258,6 +2265,13 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb) hdev->stat.sco_tx++;return submit_tx_urb (hdev, urb); + +case HCI_ISODATA_PKT : + urb =alloc_bulk_urb (hdev, skb); +if (IS_ERR (urb)) +return PTR_ERR (urb); + +return submit_or_queue_tx_urb (hdev, urb); }return -EILSEQ ;
Signature · 1 line
2.35.3
Luiz Augusto von Dentz
maintainerPATCH v6 7/7 Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Fix up the packet type if ISO packets are sent over the bulk endpoint.
Note: This is a stopgap since the Bluetooth specification currently doesn't define any endpoint to transport ISO packets.
--- drivers/bluetooth/btusb.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/bluetooth/btusb.c +10 -0
@@ -896,11 +896,21 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)hci_skb_expect (skb) -= len;if (skb->len ==HCI_ACL_HDR_SIZE ) { +__u16 handle =__le16_to_cpu (hci_acl_hdr (skb)->handle);__le16 dlen =hci_acl_hdr (skb)->dlen; +__u8 type;/* Complete ACL header */ hci_skb_expect (skb) =__le16_to_cpu (dlen); +/* Detect if ISO packet has been sent over bulk */ +if (hci_conn_num (data->hdev,ISO_LINK )) { + type =hci_conn_lookup_type (data->hdev, +hci_handle (handle)); +if (type ==ISO_LINK ) +hci_skb_pkt_type (skb) =HCI_ISODATA_PKT ; + } +if (skb_tailroom (skb) <hci_skb_expect (skb)) {kfree_skb (skb); skb =NULL ;
Signature · 1 line
2.35.3
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=655963
---Test result---
Test Summary:
CheckPatch FAIL 11.79 seconds GitLint PASS 7.58 seconds SubjectPrefix PASS 6.52 seconds BuildKernel PASS 39.92 seconds BuildKernel32 PASS 35.22 seconds Incremental Build with patchesPASS 203.93 seconds TestRunner: Setup PASS 576.19 seconds TestRunner: l2cap-tester PASS 19.53 seconds TestRunner: bnep-tester PASS 7.02 seconds TestRunner: mgmt-tester FAIL 113.63 seconds TestRunner: rfcomm-tester PASS 10.95 seconds TestRunner: sco-tester PASS 10.53 seconds TestRunner: smp-tester PASS 10.69 seconds TestRunner: userchan-tester PASS 7.19 seconds
Details
##############################
Test: CheckPatch - FAIL - 11.79 seconds
Run checkpatch.pl script with rule in .checkpatch.conf
[v6,3/7] Bluetooth: Add BTPROTO_ISO socket type\Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #177:
new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 1718 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/12903856.patch has style problems, please review.
NOTE: Ignored message types: UNKNOWN_COMMIT_ID
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: TestRunner: mgmt-tester - FAIL - 113.63 seconds Run test-runner with mgmt-tester
Total: 494, Passed: 492 (99.6%), Failed: 2, Not Run: 0
Failed Test Cases
Read Exp Feature - Success Failed 0.110 seconds Read Exp Feature - Success (Index None) Failed 0.111 seconds
---
Regards,
Linux Bluetooth