linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list
@ 2023-02-25  0:20 Luiz Augusto von Dentz
  2023-02-25  0:20 ` [PATCH 2/3] Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2023-02-25  0:20 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes hci_conn_hash_add append to the tail of the conn_hash so it
matches the order they are created, this is required if the controller
attempts to match the order of ACL with CIS which uses append logic
when programming the CIS ids on the CIG.

The result of this change affects Create CIS:

From:

< HCI Command: LE Create Connected Isochronous Stream (0x08|0x0064) plen 9
        Number of CIS: 2
        CIS Handle: 2560
        ACL Handle: 3586
        CIS Handle: 2561
        ACL Handle: 3585

To:

< HCI Command: LE Create Connected Isochronous Stream (0x08|0x0064) plen 9
        Number of CIS: 2
        CIS Handle: 2560
        ACL Handle: 3585
        CIS Handle: 2561
        ACL Handle: 3586

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 include/net/bluetooth/hci_core.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 7254edfba4c9..9488671c1219 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -978,7 +978,7 @@ static inline bool hci_conn_sc_enabled(struct hci_conn *conn)
 static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
 {
 	struct hci_conn_hash *h = &hdev->conn_hash;
-	list_add_rcu(&c->list, &h->list);
+	list_add_tail_rcu(&c->list, &h->list);
 	switch (c->type) {
 	case ACL_LINK:
 		h->acl_num++;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3]  Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet
  2023-02-25  0:20 [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list Luiz Augusto von Dentz
@ 2023-02-25  0:20 ` Luiz Augusto von Dentz
  2023-02-25  0:20 ` [PATCH 3/3] Bluetooth: btusb: Remove detection of ISO packets over bulk Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2023-02-25  0:20 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Because some transports don't have a dedicated type for ISO packets
(see 14202eff214e1e941fefa0366d4c3bc4b1a0d500) they may use ACL type
when in fact they are ISO packets.

In the past this was left for the driver to detect such thing but it
creates a problem when using the likes of btproxy when used by a VM as
the host would not be aware of the connection the guest is doing it
won't be able to detect such behavior, so this make bt_recv_frame
detect when it happens as it is the common interface to all drivers
including guest VMs.

Fixes: 14202eff214e ("Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/hci_core.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b65c3aabcd53..334e308451f5 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2871,10 +2871,25 @@ int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
 		return -ENXIO;
 	}
 
-	if (hci_skb_pkt_type(skb) != HCI_EVENT_PKT &&
-	    hci_skb_pkt_type(skb) != HCI_ACLDATA_PKT &&
-	    hci_skb_pkt_type(skb) != HCI_SCODATA_PKT &&
-	    hci_skb_pkt_type(skb) != HCI_ISODATA_PKT) {
+	switch (hci_skb_pkt_type(skb)) {
+	case HCI_EVENT_PKT:
+		break;
+	case HCI_ACLDATA_PKT:
+		/* Detect if ISO packet has been sent as ACL */
+		if (hci_conn_num(hdev, ISO_LINK)) {
+			__u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle);
+			__u8 type;
+
+			type = hci_conn_lookup_type(hdev, hci_handle(handle));
+			if (type == ISO_LINK)
+				hci_skb_pkt_type(skb) = HCI_ISODATA_PKT;
+		}
+		break;
+	case HCI_SCODATA_PKT:
+		break;
+	case HCI_ISODATA_PKT:
+		break;
+	default:
 		kfree_skb(skb);
 		return -EINVAL;
 	}
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] Bluetooth: btusb: Remove detection of ISO packets over bulk
  2023-02-25  0:20 [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list Luiz Augusto von Dentz
  2023-02-25  0:20 ` [PATCH 2/3] Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet Luiz Augusto von Dentz
@ 2023-02-25  0:20 ` Luiz Augusto von Dentz
  2023-02-25  1:17 ` [1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list bluez.test.bot
  2023-02-27 21:40 ` [PATCH 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2023-02-25  0:20 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This removes the code introduced by
14202eff214e1e941fefa0366d4c3bc4b1a0d500 as hci_recv_frame is now able
to detect ACL packets that are in fact ISO packets.

Fixes: 14202eff214e ("Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 drivers/bluetooth/btusb.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 6273a93defd2..4ca91c033d2f 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1050,21 +1050,11 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)
 		hci_skb_expect(skb) -= len;
 
 		if (skb->len == HCI_ACL_HDR_SIZE) {
-			__u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle);
 			__le16 dlen = hci_acl_hdr(skb)->dlen;
-			__u8 type;
 
 			/* Complete ACL header */
 			hci_skb_expect(skb) = __le16_to_cpu(dlen);
 
-			/* Detect if ISO packet has been sent over bulk */
-			if (hci_conn_num(data->hdev, ISO_LINK)) {
-				type = hci_conn_lookup_type(data->hdev,
-							    hci_handle(handle));
-				if (type == ISO_LINK)
-					hci_skb_pkt_type(skb) = HCI_ISODATA_PKT;
-			}
-
 			if (skb_tailroom(skb) < hci_skb_expect(skb)) {
 				kfree_skb(skb);
 				skb = NULL;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list
  2023-02-25  0:20 [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list Luiz Augusto von Dentz
  2023-02-25  0:20 ` [PATCH 2/3] Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet Luiz Augusto von Dentz
  2023-02-25  0:20 ` [PATCH 3/3] Bluetooth: btusb: Remove detection of ISO packets over bulk Luiz Augusto von Dentz
@ 2023-02-25  1:17 ` bluez.test.bot
  2023-02-27 21:40 ` [PATCH 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2023-02-25  1:17 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 2193 bytes --]

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=724805

---Test result---

Test Summary:
CheckPatch                    FAIL      1.96 seconds
GitLint                       PASS      0.79 seconds
SubjectPrefix                 PASS      0.26 seconds
BuildKernel                   PASS      31.97 seconds
CheckAllWarning               PASS      34.63 seconds
CheckSparse                   PASS      39.41 seconds
CheckSmatch                   PASS      109.16 seconds
BuildKernel32                 PASS      30.46 seconds
TestRunnerSetup               PASS      439.59 seconds
TestRunner_l2cap-tester       PASS      15.85 seconds
TestRunner_iso-tester         PASS      16.80 seconds
TestRunner_bnep-tester        PASS      5.43 seconds
TestRunner_mgmt-tester        PASS      108.45 seconds
TestRunner_rfcomm-tester      PASS      8.63 seconds
TestRunner_sco-tester         PASS      7.96 seconds
TestRunner_ioctl-tester       PASS      9.26 seconds
TestRunner_mesh-tester        PASS      6.87 seconds
TestRunner_smp-tester         PASS      7.79 seconds
TestRunner_userchan-tester    PASS      5.65 seconds
IncrementalBuild              PASS      38.78 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list
WARNING: Use a single space after To:
#98: 
To:

ERROR: Unrecognized email address: ''
#98: 
To:

ERROR: Missing Signed-off-by: line by nominal patch author ''

total: 2 errors, 1 warnings, 8 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13151871.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.




---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list
  2023-02-25  0:20 [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2023-02-25  1:17 ` [1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list bluez.test.bot
@ 2023-02-27 21:40 ` patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2023-02-27 21:40 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Fri, 24 Feb 2023 16:20:50 -0800 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This makes hci_conn_hash_add append to the tail of the conn_hash so it
> matches the order they are created, this is required if the controller
> attempts to match the order of ACL with CIS which uses append logic
> when programming the CIS ids on the CIG.
> 
> [...]

Here is the summary with links:
  - [1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list
    https://git.kernel.org/bluetooth/bluetooth-next/c/c25cd4779f1b
  - [2/3] Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet
    https://git.kernel.org/bluetooth/bluetooth-next/c/8c999e405d6b
  - [3/3] Bluetooth: btusb: Remove detection of ISO packets over bulk
    https://git.kernel.org/bluetooth/bluetooth-next/c/e574898ac6ae

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-27 21:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-25  0:20 [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list Luiz Augusto von Dentz
2023-02-25  0:20 ` [PATCH 2/3] Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet Luiz Augusto von Dentz
2023-02-25  0:20 ` [PATCH 3/3] Bluetooth: btusb: Remove detection of ISO packets over bulk Luiz Augusto von Dentz
2023-02-25  1:17 ` [1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list bluez.test.bot
2023-02-27 21:40 ` [PATCH 1/3] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).