Skip to content

Commit f32ad53

Browse files
committed
Bluetooth: Add PA_LINK to distinguish BIG sync and PA sync connections
JIRA: https://issues.redhat.com/browse/RHEL-107922 commit a7bcffc Author: Yang Li <yang.li@amlogic.com> Date: Thu Jul 10 18:52:47 2025 +0800 Bluetooth: Add PA_LINK to distinguish BIG sync and PA sync connections Currently, BIS_LINK is used for both BIG sync and PA sync connections, which makes it impossible to distinguish them when searching for a PA sync connection. Adding PA_LINK will make the distinction clearer and simplify future extensions for PA-related features. Signed-off-by: Yang Li <yang.li@amlogic.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: David Marlin <dmarlin@redhat.com>
1 parent 9d04feb commit f32ad53

File tree

8 files changed

+46
-30
lines changed

8 files changed

+46
-30
lines changed

include/net/bluetooth/hci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ enum {
562562
#define LE_LINK 0x80
563563
#define CIS_LINK 0x82
564564
#define BIS_LINK 0x83
565+
#define PA_LINK 0x84
565566
#define INVALID_LINK 0xff
566567

567568
/* LMP features */

include/net/bluetooth/hci_core.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
10091009
break;
10101010
case CIS_LINK:
10111011
case BIS_LINK:
1012+
case PA_LINK:
10121013
h->iso_num++;
10131014
break;
10141015
}
@@ -1036,6 +1037,7 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
10361037
break;
10371038
case CIS_LINK:
10381039
case BIS_LINK:
1040+
case PA_LINK:
10391041
h->iso_num--;
10401042
break;
10411043
}
@@ -1054,6 +1056,7 @@ static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type)
10541056
return h->sco_num;
10551057
case CIS_LINK:
10561058
case BIS_LINK:
1059+
case PA_LINK:
10571060
return h->iso_num;
10581061
default:
10591062
return 0;
@@ -1136,7 +1139,7 @@ hci_conn_hash_lookup_create_pa_sync(struct hci_dev *hdev)
11361139
rcu_read_lock();
11371140

11381141
list_for_each_entry_rcu(c, &h->list, list) {
1139-
if (c->type != BIS_LINK)
1142+
if (c->type != PA_LINK)
11401143
continue;
11411144

11421145
if (!test_bit(HCI_CONN_CREATE_PA_SYNC, &c->flags))
@@ -1331,7 +1334,7 @@ hci_conn_hash_lookup_big_sync_pend(struct hci_dev *hdev,
13311334
rcu_read_lock();
13321335

13331336
list_for_each_entry_rcu(c, &h->list, list) {
1334-
if (c->type != BIS_LINK)
1337+
if (c->type != PA_LINK)
13351338
continue;
13361339

13371340
if (handle == c->iso_qos.bcast.big && num_bis == c->num_bis) {
@@ -1400,7 +1403,7 @@ hci_conn_hash_lookup_pa_sync_handle(struct hci_dev *hdev, __u16 sync_handle)
14001403
rcu_read_lock();
14011404

14021405
list_for_each_entry_rcu(c, &h->list, list) {
1403-
if (c->type != BIS_LINK)
1406+
if (c->type != PA_LINK)
14041407
continue;
14051408

14061409
/* Ignore the listen hcon, we are looking
@@ -2019,6 +2022,7 @@ static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,
20192022

20202023
case CIS_LINK:
20212024
case BIS_LINK:
2025+
case PA_LINK:
20222026
return iso_connect_ind(hdev, bdaddr, flags);
20232027

20242028
default:

net/bluetooth/hci_conn.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, struct hci_conn *c
785785
d->sync_handle = conn->sync_handle;
786786

787787
if (test_and_clear_bit(HCI_CONN_PA_SYNC, &conn->flags)) {
788-
hci_conn_hash_list_flag(hdev, find_bis, BIS_LINK,
788+
hci_conn_hash_list_flag(hdev, find_bis, PA_LINK,
789789
HCI_CONN_PA_SYNC, d);
790790

791791
if (!d->count)
@@ -914,6 +914,7 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t
914914
break;
915915
case CIS_LINK:
916916
case BIS_LINK:
917+
case PA_LINK:
917918
if (hdev->iso_mtu)
918919
/* Dedicated ISO Buffer exists */
919920
break;
@@ -979,6 +980,7 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t
979980
break;
980981
case CIS_LINK:
981982
case BIS_LINK:
983+
case PA_LINK:
982984
/* conn->src should reflect the local identity address */
983985
hci_copy_identity_address(hdev, &conn->src, &conn->src_type);
984986

@@ -1033,7 +1035,6 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t
10331035
}
10341036

10351037
hci_conn_init_sysfs(conn);
1036-
10371038
return conn;
10381039
}
10391040

@@ -1077,6 +1078,7 @@ static void hci_conn_cleanup_child(struct hci_conn *conn, u8 reason)
10771078
break;
10781079
case CIS_LINK:
10791080
case BIS_LINK:
1081+
case PA_LINK:
10801082
if ((conn->state != BT_CONNECTED &&
10811083
!test_bit(HCI_CONN_CREATE_CIS, &conn->flags)) ||
10821084
test_bit(HCI_CONN_BIG_CREATED, &conn->flags))
@@ -1152,7 +1154,8 @@ void hci_conn_del(struct hci_conn *conn)
11521154
} else {
11531155
/* Unacked ISO frames */
11541156
if (conn->type == CIS_LINK ||
1155-
conn->type == BIS_LINK) {
1157+
conn->type == BIS_LINK ||
1158+
conn->type == PA_LINK) {
11561159
if (hdev->iso_pkts)
11571160
hdev->iso_cnt += conn->sent;
11581161
else if (hdev->le_pkts)
@@ -2081,7 +2084,7 @@ struct hci_conn *hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst,
20812084

20822085
bt_dev_dbg(hdev, "dst %pMR type %d sid %d", dst, dst_type, sid);
20832086

2084-
conn = hci_conn_add_unset(hdev, BIS_LINK, dst, HCI_ROLE_SLAVE);
2087+
conn = hci_conn_add_unset(hdev, PA_LINK, dst, HCI_ROLE_SLAVE);
20852088
if (IS_ERR(conn))
20862089
return conn;
20872090

@@ -2245,7 +2248,7 @@ struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
22452248
* the start periodic advertising and create BIG commands have
22462249
* been queued
22472250
*/
2248-
hci_conn_hash_list_state(hdev, bis_mark_per_adv, BIS_LINK,
2251+
hci_conn_hash_list_state(hdev, bis_mark_per_adv, PA_LINK,
22492252
BT_BOUND, &data);
22502253

22512254
/* Queue start periodic advertising and create BIG */
@@ -2979,6 +2982,7 @@ void hci_conn_tx_queue(struct hci_conn *conn, struct sk_buff *skb)
29792982
switch (conn->type) {
29802983
case CIS_LINK:
29812984
case BIS_LINK:
2985+
case PA_LINK:
29822986
case ACL_LINK:
29832987
case LE_LINK:
29842988
break;

net/bluetooth/hci_core.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,12 +2938,14 @@ int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
29382938
case HCI_ACLDATA_PKT:
29392939
/* Detect if ISO packet has been sent as ACL */
29402940
if (hci_conn_num(hdev, CIS_LINK) ||
2941-
hci_conn_num(hdev, BIS_LINK)) {
2941+
hci_conn_num(hdev, BIS_LINK) ||
2942+
hci_conn_num(hdev, PA_LINK)) {
29422943
__u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle);
29432944
__u8 type;
29442945

29452946
type = hci_conn_lookup_type(hdev, hci_handle(handle));
2946-
if (type == CIS_LINK || type == BIS_LINK)
2947+
if (type == CIS_LINK || type == BIS_LINK ||
2948+
type == PA_LINK)
29472949
hci_skb_pkt_type(skb) = HCI_ISODATA_PKT;
29482950
}
29492951
break;
@@ -3398,6 +3400,7 @@ static inline void hci_quote_sent(struct hci_conn *conn, int num, int *quote)
33983400
break;
33993401
case CIS_LINK:
34003402
case BIS_LINK:
3403+
case PA_LINK:
34013404
cnt = hdev->iso_mtu ? hdev->iso_cnt :
34023405
hdev->le_mtu ? hdev->le_cnt : hdev->acl_cnt;
34033406
break;
@@ -3411,7 +3414,7 @@ static inline void hci_quote_sent(struct hci_conn *conn, int num, int *quote)
34113414
}
34123415

34133416
static struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type,
3414-
__u8 type2, int *quote)
3417+
int *quote)
34153418
{
34163419
struct hci_conn_hash *h = &hdev->conn_hash;
34173420
struct hci_conn *conn = NULL, *c;
@@ -3423,7 +3426,7 @@ static struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type,
34233426
rcu_read_lock();
34243427

34253428
list_for_each_entry_rcu(c, &h->list, list) {
3426-
if ((c->type != type && c->type != type2) ||
3429+
if (c->type != type ||
34273430
skb_queue_empty(&c->data_q))
34283431
continue;
34293432

@@ -3627,7 +3630,7 @@ static void hci_sched_sco(struct hci_dev *hdev, __u8 type)
36273630
else
36283631
cnt = &hdev->sco_cnt;
36293632

3630-
while (*cnt && (conn = hci_low_sent(hdev, type, type, &quote))) {
3633+
while (*cnt && (conn = hci_low_sent(hdev, type, &quote))) {
36313634
while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
36323635
BT_DBG("skb %p len %d", skb, skb->len);
36333636
hci_send_conn_frame(hdev, conn, skb);
@@ -3746,23 +3749,21 @@ static void hci_sched_le(struct hci_dev *hdev)
37463749
hci_prio_recalculate(hdev, LE_LINK);
37473750
}
37483751

3749-
/* Schedule CIS */
3750-
static void hci_sched_iso(struct hci_dev *hdev)
3752+
/* Schedule iso */
3753+
static void hci_sched_iso(struct hci_dev *hdev, __u8 type)
37513754
{
37523755
struct hci_conn *conn;
37533756
struct sk_buff *skb;
37543757
int quote, *cnt;
37553758

37563759
BT_DBG("%s", hdev->name);
37573760

3758-
if (!hci_conn_num(hdev, CIS_LINK) &&
3759-
!hci_conn_num(hdev, BIS_LINK))
3761+
if (!hci_conn_num(hdev, type))
37603762
return;
37613763

37623764
cnt = hdev->iso_pkts ? &hdev->iso_cnt :
37633765
hdev->le_pkts ? &hdev->le_cnt : &hdev->acl_cnt;
3764-
while (*cnt && (conn = hci_low_sent(hdev, CIS_LINK, BIS_LINK,
3765-
&quote))) {
3766+
while (*cnt && (conn = hci_low_sent(hdev, type, &quote))) {
37663767
while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
37673768
BT_DBG("skb %p len %d", skb, skb->len);
37683769
hci_send_conn_frame(hdev, conn, skb);
@@ -3787,7 +3788,9 @@ static void hci_tx_work(struct work_struct *work)
37873788
/* Schedule queues and send stuff to HCI driver */
37883789
hci_sched_sco(hdev, SCO_LINK);
37893790
hci_sched_sco(hdev, ESCO_LINK);
3790-
hci_sched_iso(hdev);
3791+
hci_sched_iso(hdev, CIS_LINK);
3792+
hci_sched_iso(hdev, BIS_LINK);
3793+
hci_sched_iso(hdev, PA_LINK);
37913794
hci_sched_acl(hdev);
37923795
hci_sched_le(hdev);
37933796
}

net/bluetooth/hci_event.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,6 +4432,7 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, void *data,
44324432

44334433
case CIS_LINK:
44344434
case BIS_LINK:
4435+
case PA_LINK:
44354436
if (hdev->iso_pkts) {
44364437
hdev->iso_cnt += count;
44374438
if (hdev->iso_cnt > hdev->iso_pkts)
@@ -6377,7 +6378,7 @@ static void hci_le_pa_sync_estabilished_evt(struct hci_dev *hdev, void *data,
63776378
conn->sync_handle = le16_to_cpu(ev->handle);
63786379
conn->sid = HCI_SID_INVALID;
63796380

6380-
mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, BIS_LINK,
6381+
mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, PA_LINK,
63816382
&flags);
63826383
if (!(mask & HCI_LM_ACCEPT)) {
63836384
hci_le_pa_term_sync(hdev, ev->handle);
@@ -6388,7 +6389,7 @@ static void hci_le_pa_sync_estabilished_evt(struct hci_dev *hdev, void *data,
63886389
goto unlock;
63896390

63906391
/* Add connection to indicate PA sync event */
6391-
pa_sync = hci_conn_add_unset(hdev, BIS_LINK, BDADDR_ANY,
6392+
pa_sync = hci_conn_add_unset(hdev, PA_LINK, BDADDR_ANY,
63926393
HCI_ROLE_SLAVE);
63936394

63946395
if (IS_ERR(pa_sync))
@@ -6419,7 +6420,7 @@ static void hci_le_per_adv_report_evt(struct hci_dev *hdev, void *data,
64196420

64206421
hci_dev_lock(hdev);
64216422

6422-
mask |= hci_proto_connect_ind(hdev, BDADDR_ANY, BIS_LINK, &flags);
6423+
mask |= hci_proto_connect_ind(hdev, BDADDR_ANY, PA_LINK, &flags);
64236424
if (!(mask & HCI_LM_ACCEPT))
64246425
goto unlock;
64256426

net/bluetooth/hci_sync.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,7 +2929,7 @@ static int hci_le_set_ext_scan_param_sync(struct hci_dev *hdev, u8 type,
29292929
if (sent) {
29302930
struct hci_conn *conn;
29312931

2932-
conn = hci_conn_hash_lookup_ba(hdev, BIS_LINK,
2932+
conn = hci_conn_hash_lookup_ba(hdev, PA_LINK,
29332933
&sent->bdaddr);
29342934
if (conn) {
29352935
struct bt_iso_qos *qos = &conn->iso_qos;
@@ -5493,7 +5493,7 @@ static int hci_disconnect_sync(struct hci_dev *hdev, struct hci_conn *conn,
54935493
{
54945494
struct hci_cp_disconnect cp;
54955495

5496-
if (conn->type == BIS_LINK) {
5496+
if (conn->type == BIS_LINK || conn->type == PA_LINK) {
54975497
/* This is a BIS connection, hci_conn_del will
54985498
* do the necessary cleanup.
54995499
*/
@@ -5562,7 +5562,7 @@ static int hci_connect_cancel_sync(struct hci_dev *hdev, struct hci_conn *conn,
55625562
return HCI_ERROR_LOCAL_HOST_TERM;
55635563
}
55645564

5565-
if (conn->type == BIS_LINK) {
5565+
if (conn->type == BIS_LINK || conn->type == PA_LINK) {
55665566
/* There is no way to cancel a BIS without terminating the BIG
55675567
* which is done later on connection cleanup.
55685568
*/
@@ -5627,7 +5627,7 @@ static int hci_reject_conn_sync(struct hci_dev *hdev, struct hci_conn *conn,
56275627
if (conn->type == CIS_LINK)
56285628
return hci_le_reject_cis_sync(hdev, conn, reason);
56295629

5630-
if (conn->type == BIS_LINK)
5630+
if (conn->type == BIS_LINK || conn->type == PA_LINK)
56315631
return -EINVAL;
56325632

56335633
if (conn->type == SCO_LINK || conn->type == ESCO_LINK)
@@ -6992,7 +6992,7 @@ static void create_pa_complete(struct hci_dev *hdev, void *data, int err)
69926992
goto unlock;
69936993

69946994
/* Add connection to indicate PA sync error */
6995-
pa_sync = hci_conn_add_unset(hdev, BIS_LINK, BDADDR_ANY,
6995+
pa_sync = hci_conn_add_unset(hdev, PA_LINK, BDADDR_ANY,
69966996
HCI_ROLE_SLAVE);
69976997

69986998
if (IS_ERR(pa_sync))

net/bluetooth/iso.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,8 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
22262226

22272227
static void iso_connect_cfm(struct hci_conn *hcon, __u8 status)
22282228
{
2229-
if (hcon->type != CIS_LINK && hcon->type != BIS_LINK) {
2229+
if (hcon->type != CIS_LINK && hcon->type != BIS_LINK &&
2230+
hcon->type != PA_LINK) {
22302231
if (hcon->type != LE_LINK)
22312232
return;
22322233

@@ -2267,7 +2268,8 @@ static void iso_connect_cfm(struct hci_conn *hcon, __u8 status)
22672268

22682269
static void iso_disconn_cfm(struct hci_conn *hcon, __u8 reason)
22692270
{
2270-
if (hcon->type != CIS_LINK && hcon->type != BIS_LINK)
2271+
if (hcon->type != CIS_LINK && hcon->type != BIS_LINK &&
2272+
hcon->type != PA_LINK)
22712273
return;
22722274

22732275
BT_DBG("hcon %p reason %d", hcon, reason);

net/bluetooth/mgmt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,6 +3237,7 @@ static u8 link_to_bdaddr(u8 link_type, u8 addr_type)
32373237
switch (link_type) {
32383238
case CIS_LINK:
32393239
case BIS_LINK:
3240+
case PA_LINK:
32403241
case LE_LINK:
32413242
switch (addr_type) {
32423243
case ADDR_LE_DEV_PUBLIC:

0 commit comments

Comments
 (0)