Skip to contentSkip to conversation

Bluetooth: Add definitions for LE set address resolution

PATCH Superseded Ankit Navik 2 participants 3 messages Jul 16, 2018 – Jul 17, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Add definitions for LE set address resolution

Add the definitions for LE address resolution enable HCI commands. When the LE address resolution enable gets changed via HCI commands make sure that flag gets updated.

---
 include/net/bluetooth/hci.h |  2 ++
 net/bluetooth/hci_event.c   | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
include/net/bluetooth/hci.h +2 -0
index 1abcd14..c45fab5 100644
@@ -1512,6 +1512,8 @@ struct hci_rp_le_read_resolv_list_size {
 	__u8	size;
 } __packed;
 
+#define HCI_OP_LE_SET_ADDR_RESOLUTION_ENABLE 0x202d
+
 #define HCI_OP_LE_READ_MAX_DATA_LEN	0x202f
 struct hci_rp_le_read_max_data_len {
 	__u8	status;
net/bluetooth/hci_event.c +40 -0
index e8d6df9..e930556 100644
@@ -1372,6 +1372,42 @@ static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev,
 	hdev->le_resolv_list_size = rp->size;
 }
 
+static void hci_cc_le_set_addr_resolution_enable(struct hci_dev *hdev,
+						struct sk_buff *skb)
+{
+	__u8 *sent, status = *((__u8 *) skb->data);
+
+	BT_DBG("%s status 0x%2.2x", hdev->name, status);
+
+	if (status)
+		return;
+
+	sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADDR_RESOLUTION_ENABLE);
+	if (!sent)
+		return;
+
+	hci_dev_lock(hdev);
+
+	/* If we're doing connection initiation as peripheral. Set a
+	 * timeout in case something goes wrong.
+	 */
+	if (*sent) {
+		struct hci_conn *conn;
+
+		hci_dev_set_flag(hdev, HCI_RPA_RESOLVING);
+
+		conn = hci_lookup_le_connect(hdev);
+		if (conn)
+			queue_delayed_work(hdev->workqueue,
+					   &conn->le_conn_timeout,
+					   conn->conn_timeout);
+	} else {
+		hci_dev_clear_flag(hdev, HCI_RPA_RESOLVING);
+	}
+
+	hci_dev_unlock(hdev);
+}
+
 static void hci_cc_le_read_max_data_len(struct hci_dev *hdev,
 					struct sk_buff *skb)
 {
@@ -3097,6 +3133,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
 		hci_cc_le_read_resolv_list_size(hdev, skb);
 		break;
 
+	case HCI_OP_LE_SET_ADDR_RESOLUTION_ENABLE:
+		hci_cc_le_set_addr_resolution_enable(hdev, skb);
+		break;
+
 	case HCI_OP_LE_READ_MAX_DATA_LEN:
 		hci_cc_le_read_max_data_len(hdev, skb);
 		break;
Signature · 1 line
1.9.1
maintainer
#1 lore raw

Hi Ankit,

Quoted 15 lines

Add the definitions for LE address resolution enable HCI commands. When the LE address resolution enable gets changed via HCI commands make sure that flag gets updated.

---
include/net/bluetooth/hci.h | 2 ++
net/bluetooth/hci_event.c | 40 ++++++++++++++++++++++++++++++++++++++++

2 files changed, 42 insertions(+)
include/net/bluetooth/hci.h +0 -0
index 1abcd14..c45fab5 100644

include/net/bluetooth/hci.h struct hci_rp_le_read_resolv_list_size { · line 1516

Quoted 5 lines
include/net/bluetooth/hci.h +2 -0
@@ -1512,6 +1512,8 @@ struct hci_rp_le_read_resolv_list_size {
 	__u8	size;
 } __packed;
 
+#define HCI_OP_LE_SET_ADDR_RESOLUTION_ENABLE 0x202d
+

please shortcut this to ADDR_RESOLV_ENABLE.

Quoted 24 lines
include/net/bluetooth/hci.h +0 -0
 #define HCI_OP_LE_READ_MAX_DATA_LEN	0x202f
 struct hci_rp_le_read_max_data_len {
 	__u8	status;
net/bluetooth/hci_event.c +13 -0
index e8d6df9..e930556 100644
@@ -1372,6 +1372,42 @@ static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev,
 	hdev->le_resolv_list_size = rp->size;
 }
 
+static void hci_cc_le_set_addr_resolution_enable(struct hci_dev *hdev,
+						struct sk_buff *skb)
+{
+	__u8 *sent, status = *((__u8 *) skb->data);
+
+	BT_DBG("%s status 0x%2.2x", hdev->name, status);
+
+	if (status)
+		return;
+
+	sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADDR_RESOLUTION_ENABLE);
+	if (!sent)
+		return;

net/bluetooth/hci_event.c static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev, · line 1397

Quoted 10 lines
net/bluetooth/hci_event.c +10 -0
+
+	hci_dev_lock(hdev);
+
+	/* If we're doing connection initiation as peripheral. Set a
+	 * timeout in case something goes wrong.
+	 */
+	if (*sent) {
+		struct hci_conn *conn;
+
+		hci_dev_set_flag(hdev, HCI_RPA_RESOLVING);

Not sure we want to use the same flag here. Any concerns?

net/bluetooth/hci_event.c static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev, · line 1403

Quoted 6 lines
net/bluetooth/hci_event.c +6 -0
+
+		conn = hci_lookup_le_connect(hdev);
+		if (conn)
+			queue_delayed_work(hdev->workqueue,
+					   &conn->le_conn_timeout,
+					   conn->conn_timeout);

And I do not get the timeout here.

Quoted 11 lines
net/bluetooth/hci_event.c +7 -0
+	} else {
+		hci_dev_clear_flag(hdev, HCI_RPA_RESOLVING);
+	}
+
+	hci_dev_unlock(hdev);
+}
+
 static void hci_cc_le_read_max_data_len(struct hci_dev *hdev,
 					struct sk_buff *skb)
 {

net/bluetooth/hci_event.c static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, · line 3142

Quoted 10 lines
net/bluetooth/hci_event.c +4 -0
@@ -3097,6 +3133,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
 		hci_cc_le_read_resolv_list_size(hdev, skb);
 		break;
 
+	case HCI_OP_LE_SET_ADDR_RESOLUTION_ENABLE:
+		hci_cc_le_set_addr_resolution_enable(hdev, skb);
+		break;
+
 	case HCI_OP_LE_READ_MAX_DATA_LEN:
 		hci_cc_le_read_max_data_len(hdev, skb);
 		break;

Regards

Marcel

#2 lore raw

Hi Marcel,

Quoted 19 lines
Quoted 8 lines

Add the definitions for LE address resolution enable HCI commands. When the LE address resolution enable gets changed via HCI commands make sure that flag gets updated.

---
include/net/bluetooth/hci.h | 2 ++
net/bluetooth/hci_event.c | 40

++++++++++++++++++++++++++++++++++++++++

Quoted 10 lines
2 files changed, 42 insertions(+)
include/net/bluetooth/hci.h +0 -0
index 1abcd14..c45fab5 100644
@@ -1512,6 +1512,8 @@ struct hci_rp_le_read_resolv_list_size {
 	__u8	size;
 } __packed;
 
Quoted 4 lines

include/net/bluetooth/hci.h struct hci_rp_le_read_resolv_list_size { · line 1516

Quoted 2 lines
include/net/bluetooth/hci.h +2 -0
+#define HCI_OP_LE_SET_ADDR_RESOLUTION_ENABLE 0x202d
+

please shortcut this to ADDR_RESOLV_ENABLE.

This will be taken care in follow up patch

Quoted 24 lines

net/bluetooth/hci_event.c static void hci_cc_le_read_resolv_list_size(struct

Quoted 9 lines
include/net/bluetooth/hci.h +0 -0
 #define HCI_OP_LE_READ_MAX_DATA_LEN	0x202f
 struct hci_rp_le_read_max_data_len {
 	__u8	status;
net/bluetooth/hci_event.c +0 -0
index e8d6df9..e930556 100644
@@ -1372,6 +1372,42 @@ static void hci_cc_le_read_resolv_list_size(struct

hci_dev *hdev,

net/bluetooth/hci_event.c static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev,

Quoted 13 lines
net/bluetooth/hci_event.c +11 -0
 	hdev->le_resolv_list_size = rp->size; }
 
+static void hci_cc_le_set_addr_resolution_enable(struct hci_dev *hdev,
+						struct sk_buff *skb)
+{
+	__u8 *sent, status = *((__u8 *) skb->data);
+
+	BT_DBG("%s status 0x%2.2x", hdev->name, status);
+
+	if (status)
+		return;
+
+	sent = hci_sent_cmd_data(hdev,

HCI_OP_LE_SET_ADDR_RESOLUTION_ENABLE);

Quoted 14 lines

net/bluetooth/hci_event.c static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev, · line 1397

Quoted 12 lines
net/bluetooth/hci_event.c +12 -0
+	if (!sent)
+		return;
+
+	hci_dev_lock(hdev);
+
+	/* If we're doing connection initiation as peripheral. Set a
+	 * timeout in case something goes wrong.
+	 */
+	if (*sent) {
+		struct hci_conn *conn;
+
+		hci_dev_set_flag(hdev, HCI_RPA_RESOLVING);

Not sure we want to use the same flag here. Any concerns?

No concerns, we thought of reusing the existing flag but seems this is used for SMP RPA resolution. Shall I add a new flag (e.g. HCI_LL_RPA_RESOLUTION) for LL RPA resolving enablement?

Quoted 9 lines

net/bluetooth/hci_event.c static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev, · line 1403

Quoted 7 lines
net/bluetooth/hci_event.c +6 -0
+
+		conn = hci_lookup_le_connect(hdev);
+		if (conn)
+			queue_delayed_work(hdev->workqueue,
+					   &conn->le_conn_timeout,
+					   conn->conn_timeout);

And I do not get the timeout here.

I misunderstood this to be HCI connection timeout, which I think should not be considered in this case. This will be taken care in follow up patch.

Quoted 26 lines

net/bluetooth/hci_event.c static void hci_cmd_complete_evt(struct hci_dev

Quoted 12 lines
net/bluetooth/hci_event.c +7 -0
+	} else {
+		hci_dev_clear_flag(hdev, HCI_RPA_RESOLVING);
+	}
+
+	hci_dev_unlock(hdev);
+}
+
 static void hci_cc_le_read_max_data_len(struct hci_dev *hdev,
 					struct sk_buff *skb)
 {
@@ -3097,6 +3133,10 @@ static void hci_cmd_complete_evt(struct hci_dev

*hdev, struct sk_buff *skb,

net/bluetooth/hci_event.c static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, · line 3142

Quoted 10 lines
net/bluetooth/hci_event.c +4 -0
 		hci_cc_le_read_resolv_list_size(hdev, skb);
 		break;
 
+	case HCI_OP_LE_SET_ADDR_RESOLUTION_ENABLE:
+		hci_cc_le_set_addr_resolution_enable(hdev, skb);
+		break;
+
 	case HCI_OP_LE_READ_MAX_DATA_LEN:
 		hci_cc_le_read_max_data_len(hdev, skb);
 		break;

Regards

Quoted 1 line

Marcel

Regards,
Ankit