@@ -2886,12 +2886,8 @@ static void hci_cs_le_read_remote_features(struct hci_dev *hdev, u8 status)
28862886 hci_dev_lock (hdev );
28872887
28882888 conn = hci_conn_hash_lookup_handle (hdev , __le16_to_cpu (cp -> handle ));
2889- if (conn ) {
2890- if (conn -> state == BT_CONFIG ) {
2891- hci_connect_cfm (conn , status );
2892- hci_conn_drop (conn );
2893- }
2894- }
2889+ if (conn && conn -> state == BT_CONFIG )
2890+ hci_connect_cfm (conn , status );
28952891
28962892 hci_dev_unlock (hdev );
28972893}
@@ -3915,11 +3911,49 @@ static u8 hci_cc_le_setup_iso_path(struct hci_dev *hdev, void *data,
39153911 return rp -> status ;
39163912}
39173913
3914+ static u8 hci_cc_le_read_all_local_features (struct hci_dev * hdev , void * data ,
3915+ struct sk_buff * skb )
3916+ {
3917+ struct hci_rp_le_read_all_local_features * rp = data ;
3918+
3919+ bt_dev_dbg (hdev , "status 0x%2.2x" , rp -> status );
3920+
3921+ if (rp -> status )
3922+ return rp -> status ;
3923+
3924+ memcpy (hdev -> le_features , rp -> features , 248 );
3925+
3926+ return rp -> status ;
3927+ }
3928+
39183929static void hci_cs_le_create_big (struct hci_dev * hdev , u8 status )
39193930{
39203931 bt_dev_dbg (hdev , "status 0x%2.2x" , status );
39213932}
39223933
3934+ static void hci_cs_le_read_all_remote_features (struct hci_dev * hdev , u8 status )
3935+ {
3936+ struct hci_cp_le_read_remote_features * cp ;
3937+ struct hci_conn * conn ;
3938+
3939+ bt_dev_dbg (hdev , "status 0x%2.2x" , status );
3940+
3941+ if (!status )
3942+ return ;
3943+
3944+ cp = hci_sent_cmd_data (hdev , HCI_OP_LE_READ_ALL_REMOTE_FEATURES );
3945+ if (!cp )
3946+ return ;
3947+
3948+ hci_dev_lock (hdev );
3949+
3950+ conn = hci_conn_hash_lookup_handle (hdev , __le16_to_cpu (cp -> handle ));
3951+ if (conn && conn -> state == BT_CONFIG )
3952+ hci_connect_cfm (conn , status );
3953+
3954+ hci_dev_unlock (hdev );
3955+ }
3956+
39233957static u8 hci_cc_set_per_adv_param (struct hci_dev * hdev , void * data ,
39243958 struct sk_buff * skb )
39253959{
@@ -4171,6 +4205,9 @@ static const struct hci_cc {
41714205 sizeof (struct hci_rp_le_set_cig_params ), HCI_MAX_EVENT_SIZE ),
41724206 HCI_CC (HCI_OP_LE_SETUP_ISO_PATH , hci_cc_le_setup_iso_path ,
41734207 sizeof (struct hci_rp_le_setup_iso_path )),
4208+ HCI_CC (HCI_OP_LE_READ_ALL_LOCAL_FEATURES ,
4209+ hci_cc_le_read_all_local_features ,
4210+ sizeof (struct hci_rp_le_read_all_local_features )),
41744211};
41754212
41764213static u8 hci_cc_func (struct hci_dev * hdev , const struct hci_cc * cc ,
@@ -4325,6 +4362,8 @@ static const struct hci_cs {
43254362 HCI_CS (HCI_OP_LE_EXT_CREATE_CONN , hci_cs_le_ext_create_conn ),
43264363 HCI_CS (HCI_OP_LE_CREATE_CIS , hci_cs_le_create_cis ),
43274364 HCI_CS (HCI_OP_LE_CREATE_BIG , hci_cs_le_create_big ),
4365+ HCI_CS (HCI_OP_LE_READ_ALL_REMOTE_FEATURES ,
4366+ hci_cs_le_read_all_remote_features ),
43284367};
43294368
43304369static void hci_cmd_status_evt (struct hci_dev * hdev , void * data ,
@@ -5645,6 +5684,7 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
56455684 struct hci_conn * conn ;
56465685 struct smp_irk * irk ;
56475686 u8 addr_type ;
5687+ int err ;
56485688
56495689 hci_dev_lock (hdev );
56505690
@@ -5775,26 +5815,8 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
57755815 hci_debugfs_create_conn (conn );
57765816 hci_conn_add_sysfs (conn );
57775817
5778- /* The remote features procedure is defined for central
5779- * role only. So only in case of an initiated connection
5780- * request the remote features.
5781- *
5782- * If the local controller supports peripheral-initiated features
5783- * exchange, then requesting the remote features in peripheral
5784- * role is possible. Otherwise just transition into the
5785- * connected state without requesting the remote features.
5786- */
5787- if (conn -> out ||
5788- (hdev -> le_features [0 ] & HCI_LE_PERIPHERAL_FEATURES )) {
5789- struct hci_cp_le_read_remote_features cp ;
5790-
5791- cp .handle = __cpu_to_le16 (conn -> handle );
5792-
5793- hci_send_cmd (hdev , HCI_OP_LE_READ_REMOTE_FEATURES ,
5794- sizeof (cp ), & cp );
5795-
5796- hci_conn_hold (conn );
5797- } else {
5818+ err = hci_le_read_remote_features (conn );
5819+ if (err ) {
57985820 conn -> state = BT_CONNECTED ;
57995821 hci_connect_cfm (conn , status );
58005822 }
@@ -6608,7 +6630,6 @@ static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev, void *data,
66086630
66096631 conn -> state = BT_CONNECTED ;
66106632 hci_connect_cfm (conn , status );
6611- hci_conn_drop (conn );
66126633 }
66136634 }
66146635
@@ -7186,6 +7207,50 @@ static void hci_le_big_info_adv_report_evt(struct hci_dev *hdev, void *data,
71867207 hci_dev_unlock (hdev );
71877208}
71887209
7210+ static void hci_le_read_all_remote_features_evt (struct hci_dev * hdev ,
7211+ void * data , struct sk_buff * skb )
7212+ {
7213+ struct hci_evt_le_read_all_remote_features_complete * ev = data ;
7214+ struct hci_conn * conn ;
7215+
7216+ bt_dev_dbg (hdev , "status 0x%2.2x" , ev -> status );
7217+
7218+ hci_dev_lock (hdev );
7219+
7220+ conn = hci_conn_hash_lookup_handle (hdev , __le16_to_cpu (ev -> handle ));
7221+ if (!conn )
7222+ goto unlock ;
7223+
7224+ if (!ev -> status )
7225+ memcpy (conn -> le_features , ev -> features , 248 );
7226+
7227+ if (conn -> state == BT_CONFIG ) {
7228+ __u8 status ;
7229+
7230+ /* If the local controller supports peripheral-initiated
7231+ * features exchange, but the remote controller does
7232+ * not, then it is possible that the error code 0x1a
7233+ * for unsupported remote feature gets returned.
7234+ *
7235+ * In this specific case, allow the connection to
7236+ * transition into connected state and mark it as
7237+ * successful.
7238+ */
7239+ if (!conn -> out &&
7240+ ev -> status == HCI_ERROR_UNSUPPORTED_REMOTE_FEATURE &&
7241+ (hdev -> le_features [0 ] & HCI_LE_PERIPHERAL_FEATURES ))
7242+ status = 0x00 ;
7243+ else
7244+ status = ev -> status ;
7245+
7246+ conn -> state = BT_CONNECTED ;
7247+ hci_connect_cfm (conn , status );
7248+ }
7249+
7250+ unlock :
7251+ hci_dev_unlock (hdev );
7252+ }
7253+
71897254#define HCI_LE_EV_VL (_op , _func , _min_len , _max_len ) \
71907255[_op] = { \
71917256 .func = _func, \
@@ -7291,6 +7356,12 @@ static const struct hci_le_ev {
72917356 hci_le_big_info_adv_report_evt ,
72927357 sizeof (struct hci_evt_le_big_info_adv_report ),
72937358 HCI_MAX_EVENT_SIZE ),
7359+ /* [0x2b = HCI_EVT_LE_ALL_REMOTE_FEATURES_COMPLETE] */
7360+ HCI_LE_EV_VL (HCI_EVT_LE_ALL_REMOTE_FEATURES_COMPLETE ,
7361+ hci_le_read_all_remote_features_evt ,
7362+ sizeof (struct
7363+ hci_evt_le_read_all_remote_features_complete ),
7364+ HCI_MAX_EVENT_SIZE ),
72947365};
72957366
72967367static void hci_le_meta_evt (struct hci_dev * hdev , void * data ,
0 commit comments