@@ -126,6 +126,7 @@ struct hci_conn_hash {
126126 unsigned int acl_num ;
127127 unsigned int amp_num ;
128128 unsigned int sco_num ;
129+ unsigned int iso_num ;
129130 unsigned int le_num ;
130131 unsigned int le_num_peripheral ;
131132};
@@ -474,13 +475,16 @@ struct hci_dev {
474475 unsigned int acl_cnt ;
475476 unsigned int sco_cnt ;
476477 unsigned int le_cnt ;
478+ unsigned int iso_cnt ;
477479
478480 unsigned int acl_mtu ;
479481 unsigned int sco_mtu ;
480482 unsigned int le_mtu ;
483+ unsigned int iso_mtu ;
481484 unsigned int acl_pkts ;
482485 unsigned int sco_pkts ;
483486 unsigned int le_pkts ;
487+ unsigned int iso_pkts ;
484488
485489 __u16 block_len ;
486490 __u16 block_mtu ;
@@ -657,6 +661,7 @@ enum conn_reasons {
657661 CONN_REASON_PAIR_DEVICE ,
658662 CONN_REASON_L2CAP_CHAN ,
659663 CONN_REASON_SCO_CONNECT ,
664+ CONN_REASON_ISO_CONNECT ,
660665};
661666
662667struct hci_conn {
@@ -709,6 +714,7 @@ struct hci_conn {
709714 __s8 rssi ;
710715 __s8 tx_power ;
711716 __s8 max_tx_power ;
717+ struct bt_iso_qos iso_qos ;
712718 unsigned long flags ;
713719
714720 enum conn_reasons conn_reason ;
@@ -739,6 +745,7 @@ struct hci_conn {
739745 struct hci_dev * hdev ;
740746 void * l2cap_data ;
741747 void * sco_data ;
748+ void * iso_data ;
742749 struct amp_mgr * amp_mgr ;
743750
744751 struct hci_conn * link ;
@@ -747,6 +754,8 @@ struct hci_conn {
747754 void (* connect_cfm_cb ) (struct hci_conn * conn , u8 status );
748755 void (* security_cfm_cb ) (struct hci_conn * conn , u8 status );
749756 void (* disconn_cfm_cb ) (struct hci_conn * conn , u8 reason );
757+
758+ void (* cleanup )(struct hci_conn * conn );
750759};
751760
752761struct hci_chan {
@@ -954,6 +963,9 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
954963 case ESCO_LINK :
955964 h -> sco_num ++ ;
956965 break ;
966+ case ISO_LINK :
967+ h -> iso_num ++ ;
968+ break ;
957969 }
958970}
959971
@@ -980,6 +992,9 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
980992 case ESCO_LINK :
981993 h -> sco_num -- ;
982994 break ;
995+ case ISO_LINK :
996+ h -> iso_num -- ;
997+ break ;
983998 }
984999}
9851000
@@ -996,6 +1011,8 @@ static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type)
9961011 case SCO_LINK :
9971012 case ESCO_LINK :
9981013 return h -> sco_num ;
1014+ case ISO_LINK :
1015+ return h -> iso_num ;
9991016 default :
10001017 return 0 ;
10011018 }
@@ -1005,7 +1022,7 @@ static inline unsigned int hci_conn_count(struct hci_dev *hdev)
10051022{
10061023 struct hci_conn_hash * c = & hdev -> conn_hash ;
10071024
1008- return c -> acl_num + c -> amp_num + c -> sco_num + c -> le_num ;
1025+ return c -> acl_num + c -> amp_num + c -> sco_num + c -> le_num + c -> iso_num ;
10091026}
10101027
10111028static inline __u8 hci_conn_lookup_type (struct hci_dev * hdev , __u16 handle )
@@ -1091,6 +1108,53 @@ static inline struct hci_conn *hci_conn_hash_lookup_le(struct hci_dev *hdev,
10911108 return NULL ;
10921109}
10931110
1111+ static inline struct hci_conn * hci_conn_hash_lookup_cis (struct hci_dev * hdev ,
1112+ bdaddr_t * ba ,
1113+ __u8 ba_type )
1114+ {
1115+ struct hci_conn_hash * h = & hdev -> conn_hash ;
1116+ struct hci_conn * c ;
1117+
1118+ rcu_read_lock ();
1119+
1120+ list_for_each_entry_rcu (c , & h -> list , list ) {
1121+ if (c -> type != ISO_LINK )
1122+ continue ;
1123+
1124+ if (ba_type == c -> dst_type && !bacmp (& c -> dst , ba )) {
1125+ rcu_read_unlock ();
1126+ return c ;
1127+ }
1128+ }
1129+
1130+ rcu_read_unlock ();
1131+
1132+ return NULL ;
1133+ }
1134+
1135+ static inline struct hci_conn * hci_conn_hash_lookup_cig (struct hci_dev * hdev ,
1136+ __u8 handle )
1137+ {
1138+ struct hci_conn_hash * h = & hdev -> conn_hash ;
1139+ struct hci_conn * c ;
1140+
1141+ rcu_read_lock ();
1142+
1143+ list_for_each_entry_rcu (c , & h -> list , list ) {
1144+ if (c -> type != ISO_LINK )
1145+ continue ;
1146+
1147+ if (handle == c -> iso_qos .cig ) {
1148+ rcu_read_unlock ();
1149+ return c ;
1150+ }
1151+ }
1152+
1153+ rcu_read_unlock ();
1154+
1155+ return NULL ;
1156+ }
1157+
10941158static inline struct hci_conn * hci_conn_hash_lookup_state (struct hci_dev * hdev ,
10951159 __u8 type , __u16 state )
10961160{
@@ -1111,6 +1175,27 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
11111175 return NULL ;
11121176}
11131177
1178+ typedef void (* hci_conn_func_t )(struct hci_conn * conn , void * data );
1179+ static inline void hci_conn_hash_list_state (struct hci_dev * hdev ,
1180+ hci_conn_func_t func , __u8 type ,
1181+ __u16 state , void * data )
1182+ {
1183+ struct hci_conn_hash * h = & hdev -> conn_hash ;
1184+ struct hci_conn * c ;
1185+
1186+ if (!func )
1187+ return ;
1188+
1189+ rcu_read_lock ();
1190+
1191+ list_for_each_entry_rcu (c , & h -> list , list ) {
1192+ if (c -> type == type && c -> state == state )
1193+ func (c , data );
1194+ }
1195+
1196+ rcu_read_unlock ();
1197+ }
1198+
11141199static inline struct hci_conn * hci_lookup_le_connect (struct hci_dev * hdev )
11151200{
11161201 struct hci_conn_hash * h = & hdev -> conn_hash ;
@@ -1134,6 +1219,8 @@ static inline struct hci_conn *hci_lookup_le_connect(struct hci_dev *hdev)
11341219int hci_disconnect (struct hci_conn * conn , __u8 reason );
11351220bool hci_setup_sync (struct hci_conn * conn , __u16 handle );
11361221void hci_sco_setup (struct hci_conn * conn , __u8 status );
1222+ bool hci_iso_setup_path (struct hci_conn * conn );
1223+ int hci_le_create_cis (struct hci_conn * conn );
11371224
11381225struct hci_conn * hci_conn_add (struct hci_dev * hdev , int type , bdaddr_t * dst ,
11391226 u8 role );
@@ -1158,6 +1245,10 @@ struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
11581245 enum conn_reasons conn_reason );
11591246struct hci_conn * hci_connect_sco (struct hci_dev * hdev , int type , bdaddr_t * dst ,
11601247 __u16 setting , struct bt_codec * codec );
1248+ struct hci_conn * hci_bind_cis (struct hci_dev * hdev , bdaddr_t * dst ,
1249+ __u8 dst_type , struct bt_iso_qos * qos );
1250+ struct hci_conn * hci_connect_cis (struct hci_dev * hdev , bdaddr_t * dst ,
1251+ __u8 dst_type , struct bt_iso_qos * qos );
11611252int hci_conn_check_link_mode (struct hci_conn * conn );
11621253int hci_conn_check_secure (struct hci_conn * conn , __u8 sec_level );
11631254int hci_conn_security (struct hci_conn * conn , __u8 sec_level , __u8 auth_type ,
@@ -1525,6 +1616,15 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
15251616#define use_enhanced_conn_complete (dev ) (ll_privacy_capable(dev) || \
15261617 ext_adv_capable(dev))
15271618
1619+ /* CIS Master/Slave support */
1620+ #define iso_capable (dev ) (cis_capable(dev))
1621+ #define cis_capable (dev ) \
1622+ (cis_central_capable(dev) || cis_peripheral_capable(dev))
1623+ #define cis_central_capable (dev ) \
1624+ ((dev)->le_features[3] & HCI_LE_CIS_CENTRAL)
1625+ #define cis_peripheral_capable (dev ) \
1626+ ((dev)->le_features[3] & HCI_LE_CIS_PERIPHERAL)
1627+
15281628/* ----- HCI protocols ----- */
15291629#define HCI_PROTO_DEFER 0x01
15301630
@@ -1539,6 +1639,10 @@ static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,
15391639 case ESCO_LINK :
15401640 return sco_connect_ind (hdev , bdaddr , flags );
15411641
1642+ case ISO_LINK :
1643+ /* TODO: Handle connection indication */
1644+ return - EINVAL ;
1645+
15421646 default :
15431647 BT_ERR ("unknown link type %d" , type );
15441648 return - EINVAL ;
@@ -1746,6 +1850,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
17461850 const void * param );
17471851void hci_send_acl (struct hci_chan * chan , struct sk_buff * skb , __u16 flags );
17481852void hci_send_sco (struct hci_conn * conn , struct sk_buff * skb );
1853+ void hci_send_iso (struct hci_conn * conn , struct sk_buff * skb );
17491854
17501855void * hci_sent_cmd_data (struct hci_dev * hdev , __u16 opcode );
17511856void * hci_recv_event_data (struct hci_dev * hdev , __u8 event );
0 commit comments