diff mbox series

[v5,1/3] Bluetooth: Add struct of reading AOSP vendor capabilities

Message ID 20211019200701.v5.1.I139e71adfd3f00b88fe9edb63d013f9cd3e24506@changeid (mailing list archive)
State Superseded
Headers show
Series [v5,1/3] Bluetooth: Add struct of reading AOSP vendor capabilities | expand

Checks

Context Check Description
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS
tedd_an/buildkernel success Build Kernel PASS
tedd_an/testrunnersetup success Test Runner Setup PASS
tedd_an/testrunnerl2cap-tester success Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerbnep-tester success Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnermgmt-tester success Total: 468, Passed: 468 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerrfcomm-tester success Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersco-tester success Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersmp-tester success Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunneruserchan-tester success Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0

Commit Message

Joseph Hwang Oct. 19, 2021, 12:07 p.m. UTC
This patch adds the struct of reading AOSP vendor capabilities.
New capabilities are added incrementally. Note that the
version_supported octets will be used to determine whether a
capability has been defined for the version.

Signed-off-by: Joseph Hwang <josephsih@chromium.org>

---

Changes in v5:
- This is a new patch.
- Add struct aosp_rp_le_get_vendor_capabilities so that next patch
  can determine whether a particular capability is supported or not.

 net/bluetooth/aosp.c | 45 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)

Comments

bluez.test.bot@gmail.com Oct. 19, 2021, 1:25 p.m. UTC | #1
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=566289

---Test result---

Test Summary:
CheckPatch                    PASS      5.41 seconds
GitLint                       PASS      2.91 seconds
BuildKernel                   PASS      534.06 seconds
TestRunner: Setup             PASS      395.79 seconds
TestRunner: l2cap-tester      PASS      8.86 seconds
TestRunner: bnep-tester       PASS      4.96 seconds
TestRunner: mgmt-tester       PASS      84.58 seconds
TestRunner: rfcomm-tester     PASS      5.90 seconds
TestRunner: sco-tester        PASS      6.17 seconds
TestRunner: smp-tester        PASS      6.03 seconds
TestRunner: userchan-tester   PASS      5.16 seconds



---
Regards,
Linux Bluetooth
Marcel Holtmann Oct. 19, 2021, 8:07 p.m. UTC | #2
Hi Joseph,

> This patch adds the struct of reading AOSP vendor capabilities.
> New capabilities are added incrementally. Note that the
> version_supported octets will be used to determine whether a
> capability has been defined for the version.
> 
> Signed-off-by: Joseph Hwang <josephsih@chromium.org>
> 
> ---
> 
> Changes in v5:
> - This is a new patch.
> - Add struct aosp_rp_le_get_vendor_capabilities so that next patch
>  can determine whether a particular capability is supported or not.
> 
> net/bluetooth/aosp.c | 45 +++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 42 insertions(+), 3 deletions(-)
> 
> diff --git a/net/bluetooth/aosp.c b/net/bluetooth/aosp.c
> index a1b7762335a5..3f0ea57a68de 100644
> --- a/net/bluetooth/aosp.c
> +++ b/net/bluetooth/aosp.c
> @@ -8,9 +8,32 @@
> 
> #include "aosp.h"
> 
> +#define AOSP_OP_LE_GET_VENDOR_CAPABILITIES	0x153

I rather have the hci_opcode_pack(0x3f, 0x153) here.

> +struct aosp_rp_le_get_vendor_capabilities {
> +	__u8	status;
> +	__u8	max_advt_instances;
> +	__u8	offloaded_resolution_of_private_address;
> +	__u16	total_scan_results_storage;
> +	__u8	max_irk_list_sz;
> +	__u8	filtering_support;
> +	__u8	max_filter;
> +	__u8	activity_energy_info_support;
> +	__u16	version_supported;
> +	__u16	total_num_of_advt_tracked;
> +	__u8	extended_scan_support;
> +	__u8	debug_logging_supported;
> +	__u8	le_address_generation_offloading_support;
> +	__u32	a2dp_source_offload_capability_mask;
> +	__u8	bluetooth_quality_report_support;
> +	__u32	dynamic_audio_buffer_support;
> +} __packed;

So as far as I recall, the original struct was smaller. Google started to add new fields over time.

> +
> void aosp_do_open(struct hci_dev *hdev)
> {
> 	struct sk_buff *skb;
> +	struct aosp_rp_le_get_vendor_capabilities *rp;
> +	u16 opcode;
> +	u16 version_supported;
> 
> 	if (!hdev->aosp_capable)
> 		return;
> @@ -18,10 +41,26 @@ void aosp_do_open(struct hci_dev *hdev)
> 	bt_dev_dbg(hdev, "Initialize AOSP extension");
> 
> 	/* LE Get Vendor Capabilities Command */
> -	skb = __hci_cmd_sync(hdev, hci_opcode_pack(0x3f, 0x153), 0, NULL,
> -			     HCI_CMD_TIMEOUT);
> -	if (IS_ERR(skb))
> +	opcode = hci_opcode_pack(0x3f, AOSP_OP_LE_GET_VENDOR_CAPABILITIES);
> +	skb = __hci_cmd_sync(hdev, opcode, 0, NULL, HCI_CMD_TIMEOUT);
> +	if (IS_ERR(skb)) {
> +		bt_dev_warn(hdev, "AOSP get vendor capabilities (%ld)",
> +			    PTR_ERR(skb));
> +		return;
> +	}
> +
> +	bt_dev_info(hdev, "aosp le vendor capabilities length %d", skb->len);

This is not a bt_dev_info.

> +
> +	rp = (struct aosp_rp_le_get_vendor_capabilities *)skb->data;
> +
> +	if (rp->status) {
> +		bt_dev_err(hdev, "AOSP LE Get Vendor Capabilities status %d",
> +			   rp->status);
> 		return;
> +	}
> +
> +	version_supported = le16_to_cpu(rp->version_supported);
> +	bt_dev_info(hdev, "AOSP version 0x%4.4x", version_supported);

You need to check the supported version for basic length of the struct and then also bluetooth_quality_report_support details.

Regards

Marcel
diff mbox series

Patch

diff --git a/net/bluetooth/aosp.c b/net/bluetooth/aosp.c
index a1b7762335a5..3f0ea57a68de 100644
--- a/net/bluetooth/aosp.c
+++ b/net/bluetooth/aosp.c
@@ -8,9 +8,32 @@ 
 
 #include "aosp.h"
 
+#define AOSP_OP_LE_GET_VENDOR_CAPABILITIES	0x153
+struct aosp_rp_le_get_vendor_capabilities {
+	__u8	status;
+	__u8	max_advt_instances;
+	__u8	offloaded_resolution_of_private_address;
+	__u16	total_scan_results_storage;
+	__u8	max_irk_list_sz;
+	__u8	filtering_support;
+	__u8	max_filter;
+	__u8	activity_energy_info_support;
+	__u16	version_supported;
+	__u16	total_num_of_advt_tracked;
+	__u8	extended_scan_support;
+	__u8	debug_logging_supported;
+	__u8	le_address_generation_offloading_support;
+	__u32	a2dp_source_offload_capability_mask;
+	__u8	bluetooth_quality_report_support;
+	__u32	dynamic_audio_buffer_support;
+} __packed;
+
 void aosp_do_open(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
+	struct aosp_rp_le_get_vendor_capabilities *rp;
+	u16 opcode;
+	u16 version_supported;
 
 	if (!hdev->aosp_capable)
 		return;
@@ -18,10 +41,26 @@  void aosp_do_open(struct hci_dev *hdev)
 	bt_dev_dbg(hdev, "Initialize AOSP extension");
 
 	/* LE Get Vendor Capabilities Command */
-	skb = __hci_cmd_sync(hdev, hci_opcode_pack(0x3f, 0x153), 0, NULL,
-			     HCI_CMD_TIMEOUT);
-	if (IS_ERR(skb))
+	opcode = hci_opcode_pack(0x3f, AOSP_OP_LE_GET_VENDOR_CAPABILITIES);
+	skb = __hci_cmd_sync(hdev, opcode, 0, NULL, HCI_CMD_TIMEOUT);
+	if (IS_ERR(skb)) {
+		bt_dev_warn(hdev, "AOSP get vendor capabilities (%ld)",
+			    PTR_ERR(skb));
+		return;
+	}
+
+	bt_dev_info(hdev, "aosp le vendor capabilities length %d", skb->len);
+
+	rp = (struct aosp_rp_le_get_vendor_capabilities *)skb->data;
+
+	if (rp->status) {
+		bt_dev_err(hdev, "AOSP LE Get Vendor Capabilities status %d",
+			   rp->status);
 		return;
+	}
+
+	version_supported = le16_to_cpu(rp->version_supported);
+	bt_dev_info(hdev, "AOSP version 0x%4.4x", version_supported);
 
 	kfree_skb(skb);
 }