ERTM state machine changes, part 2
Subsystems (2)
cover ERTM state machine changes, part 2
This is the second patch series reworking the ERTM state machine and closely related streaming mode code. These patches include bug fixes and segmentation of outgoing L2CAP data.
RFCv1: Four of eight patches were merged. RFCv2: Fixed the send lock patch, found and fixed a few more issues
with locking, reference counting, and unused code. Four of eight patches were merged.
PATCHv1: Confirmed ERTM operation with locking and segmentation updates
Mat Martineau (4):
Bluetooth: Fix a redundant and problematic incoming MTU check
Bluetooth: Restore locking semantics when looking up L2CAP channels
Bluetooth: Lock the L2CAP channel when sending
Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation
include/net/bluetooth/bluetooth.h | 2 - include/net/bluetooth/l2cap.h | 1 + net/bluetooth/l2cap_core.c | 184 +++++++++++++++++++------------------ net/bluetooth/l2cap_sock.c | 15 +-- 4 files changed, 103 insertions(+), 99 deletions(-)
Signature · 6 lines
1.7.10 -- Mat Martineau Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH 1/4 Bluetooth: Fix a redundant and problematic incoming MTU check
The L2CAP MTU for incoming data is verified differently depending on the L2CAP mode, so the check is best performed in a mode-specific context. Checking the incoming MTU before HCI fragment reassembly is a layer violation and assumes all bytes after the standard L2CAP header are L2CAP data.
This approach causes issues with unsegmented ERTM or streaming mode frames, where there are additional enhanced or extended headers before the data payload and possible FCS bytes after the data payload. A valid frame could be as many as 10 bytes larger than the MTU.
Removing this code is the best fix, because the MTU is checked later on for all L2CAP data frames (connectionless, basic, ERTM, and streaming). This also gets rid of outdated locking (socket instead of l2cap_chan) and an extra lookup of the channel ID.
--- net/bluetooth/l2cap_core.c | 20 -------------------- 1 file changed, 20 deletions(-)
net/bluetooth/l2cap_core.c +0 -20
@@ -4953,8 +4953,6 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)if (!(flags &ACL_CONT )) {struct l2cap_hdr *hdr; -struct l2cap_chan *chan; -u16 cid;int len;if (conn->rx_len) {
@@ -4974,7 +4972,6 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) hdr = (struct l2cap_hdr *) skb->data; len =__le16_to_cpu (hdr->len) +L2CAP_HDR_SIZE ; - cid =__le16_to_cpu (hdr->cid);if (len == skb->len) {/* Complete frame received */
@@ -4991,23 +4988,6 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) goto drop; } - chan =l2cap_get_chan_by_scid (conn, cid); - -if (chan && chan->sk) { -struct sock *sk = chan->sk; -lock_sock (sk); - -if (chan->imtu < len -L2CAP_HDR_SIZE ) { -BT_ERR ("Frame exceeding recv MTU (len %d, " -"MTU %d)" , len, - chan->imtu); -release_sock (sk); -l2cap_conn_unreliable (conn,ECOMM ); - goto drop; - } -release_sock (sk); - } -/* Allocate skb for the complete frame (with header) */ conn->rx_skb =bt_skb_alloc (len,GFP_ATOMIC );if (!conn->rx_skb)
Signature · 6 lines
1.7.10 -- Mat Martineau Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH 2/4 Bluetooth: Restore locking semantics when looking up L2CAP channels
In reply to Mat MartineauAs the comment for l2cap_get_chan_by_scid indicated, the function used to return a locked socket. The lock for the socket was acquired while the channel list was also locked.
When locking was moved over to the l2cap_chan structure, the channel lock was no longer acquired with the channel list still locked. This made it possible for the l2cap_chan to be deleted after conn->chan_lock was released but before l2cap_chan_lock was called. Making the call to l2cap_chan_lock before releasing conn->chan_lock makes it impossible for the l2cap_chan to be deleted at the wrong time.
--- net/bluetooth/l2cap_core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
net/bluetooth/l2cap_core.c +3 -7
@@ -98,13 +98,15 @@ static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 }/* Find channel with given SCID. -* Returns locked socket */ +* Returns locked channel. */ static struct l2cap_chan *l2cap_get_chan_by_scid (struct l2cap_conn *conn,u16 cid) {struct l2cap_chan *c;mutex_lock (&conn->chan_lock); c =__l2cap_get_chan_by_scid (conn, cid); +if (c) +l2cap_chan_lock (c);mutex_unlock (&conn->chan_lock);return c;
@@ -3141,8 +3143,6 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdrif (!chan)return -ENOENT ; -l2cap_chan_lock (chan); -if (chan->state !=BT_CONFIG && chan->state !=BT_CONNECT2 ) {struct l2cap_cmd_rej_cid rej;
@@ -3255,8 +3255,6 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdrif (!chan)return 0 ; -l2cap_chan_lock (chan); -switch (result) {case L2CAP_CONF_SUCCESS :l2cap_conf_rfc_get (chan, rsp->data, len);
@@ -4589,8 +4587,6 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct skreturn 0 ; } -l2cap_chan_lock (chan); -BT_DBG ("chan %p, len %d" , chan, skb->len);if (chan->state !=BT_CONNECTED )
Signature · 6 lines
1.7.10 -- Mat Martineau Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH 3/4 Bluetooth: Lock the L2CAP channel when sending
In reply to Mat MartineauThe ERTM and streaming mode transmit queue must only be accessed while the L2CAP channel lock is held. Locking the channel before calling l2cap_chan_send ensures that multiple threads cannot simultaneously manipulate the queue when sending and receiving concurrently.
L2CAP channel locking had previously moved to the l2cap_chan struct instead of the associated socket, so some of the old socket locking can also be removed in this patch.
--- include/net/bluetooth/bluetooth.h | 2 -- net/bluetooth/l2cap_sock.c | 15 ++++++++------- 2 files changed, 8 insertions(+), 9 deletions(-)
include/net/bluetooth/bluetooth.h +0 -2
@@ -256,12 +256,10 @@ static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, {struct sk_buff *skb; -release_sock (sk);if ((skb =sock_alloc_send_skb (sk, len +BT_SKB_RESERVE , nb, err))) {skb_reserve (skb,BT_SKB_RESERVE );bt_cb (skb)->incoming =0 ; } -lock_sock (sk);if (!skb && *err)return NULL ;
net/bluetooth/l2cap_sock.c +8 -7
@@ -716,16 +716,13 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msif (msg->msg_flags &MSG_OOB )return -EOPNOTSUPP ; -lock_sock (sk); - -if (sk->sk_state !=BT_CONNECTED ) { -release_sock (sk); +if (sk->sk_state !=BT_CONNECTED )return -ENOTCONN ; - } +l2cap_chan_lock (chan); err =l2cap_chan_send (chan, msg, len, sk->sk_priority); +l2cap_chan_unlock (chan); -release_sock (sk);return err; }
@@ -936,9 +933,13 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,struct sk_buff *skb;int err; +l2cap_chan_unlock (chan); + skb =bt_skb_send_alloc (chan->sk, len, nb, &err);if (!skb) -return (ERR_PTR (err)); + skb =ERR_PTR (err); + +l2cap_chan_lock (chan);return skb; }
Signature · 6 lines
1.7.10 -- Mat Martineau Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH 4/4 Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation
In reply to Mat MartineauUse more common code for ERTM and streaming mode segmentation and transmission, and begin using skb control block data for delaying extended or enhanced header generation until just before the packet is transmitted. This code is also better suited for resegmentation, which is needed when L2CAP links are reconfigured after an AMP channel move.
--- include/net/bluetooth/l2cap.h | 1 + net/bluetooth/l2cap_core.c | 154 ++++++++++++++++++++++++----------------- 2 files changed, 92 insertions(+), 63 deletions(-)
include/net/bluetooth/l2cap.h +1 -0
@@ -44,6 +44,7 @@#define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF#define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF#define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF +#define L2CAP_BREDR_MAX_PAYLOAD 1019/* 3-DH5 packet */ #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100)#define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000)
net/bluetooth/l2cap_core.c +91 -63
222 lines not on this page · raw message
Signature · 6 lines
1.7.10 -- Mat Martineau Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
Quoted 17 lines · Mat Martineau
This is the second patch series reworking the ERTM state machine and closely related streaming mode code. These patches include bug fixes and segmentation of outgoing L2CAP data.
RFCv1: Four of eight patches were merged. RFCv2: Fixed the send lock patch, found and fixed a few more issueswith locking, reference counting, and unused code. Four of eight patches were merged.
PATCHv1: Confirmed ERTM operation with locking and segmentation updatesMat Martineau (4):
Bluetooth: Fix a redundant and problematic incoming MTU check
Bluetooth: Restore locking semantics when looking up L2CAP channels
Bluetooth: Lock the L2CAP channel when sending
Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation
Quoted 8 lines
include/net/bluetooth/bluetooth.h | 2 - include/net/bluetooth/l2cap.h | 1 + net/bluetooth/l2cap_core.c | 184 +++++++++++++++++++------------------ net/bluetooth/l2cap_sock.c | 15 +-- 4 files changed, 103 insertions(+), 99 deletions(-)Signature · 1 line
1.7.10
Patches 1, 2, and 3 might be appropriate for the bluetooth repository (not just bluetooth-next).
--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
Re: [PATCH 1/4] Bluetooth: Fix a redundant and problematic incoming MTU check
In reply to Mat MartineauHi Mat,
On Wed, May 2, 2012 at 1:41 PM, Mat Martineau <[email protected]> wrot= e:
Quoted 16 lines
The L2CAP MTU for incoming data is verified differently depending on the L2CAP mode, so the check is best performed in a mode-specific context. =A0Checking the incoming MTU before HCI fragment reassembly is a layer violation and assumes all bytes after the standard L2CAP header are L2CAP data.
This approach causes issues with unsegmented ERTM or streaming mode frames, where there are additional enhanced or extended headers before the data payload and possible FCS bytes after the data payload. =A0A valid frame could be as many as 10 bytes larger than the MTU.
Removing this code is the best fix, because the MTU is checked later on for all L2CAP data frames (connectionless, basic, ERTM, and streaming). =A0This also gets rid of outdated locking (socket instead of
l2cap_chan) and an extra lookup of the channel ID.
Quoted 4 lines
Signed-off-by Mat Martineau <[email protected]>---
=A0net/bluetooth/l2cap_core.c | =A0 20 -------------------- =A01 file changed, 20 deletions(-)
This looks good and correct to me.
Regards,
--=20
Ulisses Furquim
ProFUSION embedded systems
http://profusion.mobi
Mobile: +55 19 9250 0942
Skype: ulissesffs
Re: [PATCH 2/4] Bluetooth: Restore locking semantics when looking up L2CAP channels
In reply to Mat MartineauHi Mat,
Quoted 12 lines · Mat Martineau
As the comment for
l2cap_get_chan_by_scidindicated, the function used to return a locked socket. The lock for the socket was acquired while the channel list was also locked.When locking was moved over to the
l2cap_chanstructure, the channel lock was no longer acquired with the channel list still locked. This made it possible for thel2cap_chanto be deleted afterconn->chan_lockwas released but beforel2cap_chan_lockwas called. Making the call tol2cap_chan_lockbefore releasingconn->chan_lockmakes it impossible for thel2cap_chanto be deleted at the wrong time.
Quoted 4 lines
Signed-off-by Mat Martineau <[email protected]>---
net/bluetooth/l2cap_core.c | 10 +++-------1 file changed, 3 insertions(+), 7 deletions(-)
Looks good. I couldn't see this problem when Andrei was adding l2cap_chan_lock and doing other changes, thanks for fixing it.
Regards,
Signature · 5 lines
Ulisses Furquim ProFUSION embedded systems http://profusion.mobi Mobile: +55 19 9250 0942 Skype: ulissesffs
Re: [PATCH 3/4] Bluetooth: Lock the L2CAP channel when sending
In reply to Mat MartineauHi Mat,
On Wed, May 2, 2012 at 1:42 PM, Mat Martineau <[email protected]> wrot= e:
Quoted 9 lines
The ERTM and streaming mode transmit queue must only be accessed while the L2CAP channel lock is held. =A0Locking the channel before calling
l2cap_chan_sendensures that multiple threads cannot simultaneously manipulate the queue when sending and receiving concurrently.L2CAP channel locking had previously moved to the
l2cap_chanstruct instead of the associated socket, so some of the old socket locking can also be removed in this patch.
Quoted 5 lines
Signed-off-by Mat Martineau <[email protected]>---
=A0include/net/bluetooth/bluetooth.h | =A0 =A02 -- =A0net/bluetooth/l2cap_sock.c =A0 =A0 =A0 =A0| =A0 15 ++++++++------- =A02 files changed, 8 insertions(+), 9 deletions(-)
Looks good. I'm just wondering if we still have issues with chan lock versus sock lock elsewhere. Maybe you've done some auditing of this?
Regards,
--=20
Ulisses Furquim
ProFUSION embedded systems
http://profusion.mobi
Mobile: +55 19 9250 0942
Skype: ulissesffs
Hi Mat,
On Wed, May 2, 2012 at 6:40 PM, Mat Martineau <[email protected]> wrot= e:
Quoted 10 lines · Mat Martineau
Quoted 8 lines
This is the second patch series reworking the ERTM state machine and closely related streaming mode code. =A0These patches include bug fixes and segmentation of outgoing L2CAP data.
RFCv1: =A0 Four of eight patches were merged.
RFCv2: =A0 Fixed the send lock patch, found and fixed a few more issues =A0 =A0 =A0 =A0with locking, reference counting, and unused code. =A0Fou=
r of
Quoted 17 lines
Quoted 17 lines
=A0 =A0 =A0 =A0eight patches were merged.
PATCHv1: Confirmed ERTM operation with locking and segmentation updatesMat Martineau (4):
=A0Bluetooth: Fix a redundant and problematic incoming MTU check =A0Bluetooth: Restore locking semantics when looking up L2CAP channels =A0Bluetooth: Lock the L2CAP channel when sending =A0Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation
include/net/bluetooth/bluetooth.h| =A0 =A02 -include/net/bluetooth/l2cap.h=A0 =A0 | =A0 =A01 +net/bluetooth/l2cap_core.c=A0 =A0 =A0 =A0| =A0184
+++++++++++++++++++------------------net/bluetooth/l2cap_sock.c=A0 =A0 =A0 =A0| =A0 15 +--4 files changed, 103 insertions(+), 99 deletions(-)
Quoted 5 lines
Quoted 2 lines
--
1.7.10Patches 1, 2, and 3 might be appropriate for the bluetooth repository (no=
t
Quoted 1 line
just bluetooth-next).
I agree they might be candidates for bluetooth repository as well.
Regards,
--=20
Ulisses Furquim
ProFUSION embedded systems
http://profusion.mobi
Mobile: +55 19 9250 0942
Skype: ulissesffs
Re: [PATCH 4/4] Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation
In reply to Mat MartineauHi Mat,
On Wed, May 2, 2012 at 1:42 PM, Mat Martineau <[email protected]> wrot= e:
Quoted 11 lines
Use more common code for ERTM and streaming mode segmentation and transmission, and begin using skb control block data for delaying extended or enhanced header generation until just before the packet is transmitted. =A0This code is also better suited for resegmentation, which is needed when L2CAP links are reconfigured after an AMP channel move.
Signed-off-by Mat Martineau <[email protected]>---
=A0include/net/bluetooth/l2cap.h | =A0 =A01 + =A0net/bluetooth/l2cap_core.c =A0 =A0| =A0154 ++++++++++++++++++++++++---=
--------------
Quoted 1 line
=A02 files changed, 92 insertions(+), 63 deletions(-)
This patch also looks good to me, but it'd be good if Andrei or someone else could check as well.
Regards,
--=20
Ulisses Furquim
ProFUSION embedded systems
http://profusion.mobi
Mobile: +55 19 9250 0942
Skype: ulissesffs
Re: [PATCH 1/4] Bluetooth: Fix a redundant and problematic incoming MTU check
In reply to Mat MartineauHi Mat,
Quoted 16 lines · Mat Martineau
The L2CAP MTU for incoming data is verified differently depending on the L2CAP mode, so the check is best performed in a mode-specific context. Checking the incoming MTU before HCI fragment reassembly is a layer violation and assumes all bytes after the standard L2CAP header are L2CAP data.
This approach causes issues with unsegmented ERTM or streaming mode frames, where there are additional enhanced or extended headers before the data payload and possible FCS bytes after the data payload. A valid frame could be as many as 10 bytes larger than the MTU.
Removing this code is the best fix, because the MTU is checked later on for all L2CAP data frames (connectionless, basic, ERTM, and streaming). This also gets rid of outdated locking (socket instead of
l2cap_chan) and an extra lookup of the channel ID.
Quoted 4 lines
Signed-off-by Mat Martineau <[email protected]>--- net/bluetooth/l2cap_core.c | 20 -------------------- 1 file changed, 20 deletions(-)
Patch has been applied to the bluetooth tree. Thanks.
Gustavo
Re: [PATCH 1/4] Bluetooth: Fix a redundant and problematic incoming MTU check
In reply to Ulisses FurquimHi Ulisses,
Quoted 3 lines · Ulisses Furquim
Hi Mat,
=20
On Wed, May 2, 2012 at 1:41 PM, Mat Martineau <[email protected]> wr=
ote:
Quoted 16 lines
Quoted 16 lines
The L2CAP MTU for incoming data is verified differently depending on the L2CAP mode, so the check is best performed in a mode-specific context. =A0Checking the incoming MTU before HCI fragment reassembly is a layer violation and assumes all bytes after the standard L2CAP header are L2CAP data.
This approach causes issues with unsegmented ERTM or streaming mode frames, where there are additional enhanced or extended headers before the data payload and possible FCS bytes after the data payload. =A0A valid frame could be as many as 10 bytes larger than the MTU.
Removing this code is the best fix, because the MTU is checked later on for all L2CAP data frames (connectionless, basic, ERTM, and streaming). =A0This also gets rid of outdated locking (socket instead of
l2cap_chan) and an extra lookup of the channel ID.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Mat Martineau <[email protected]>---
=A0net/bluetooth/l2cap_core.c | =A0 20 -------------------- =A01 file changed, 20 deletions(-)=20
This looks good and correct to me.
Please add proper Reviewed-by tag when we are ok with a patch, it easier to us pick it up here.
Gustavo
Re: [PATCH 4/4] Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation
In reply to Mat MartineauHi Mat,
Quoted 7 lines · Mat Martineau
Use more common code for ERTM and streaming mode segmentation and transmission, and begin using skb control block data for delaying extended or enhanced header generation until just before the packet is transmitted. This code is also better suited for resegmentation, which is needed when L2CAP links are reconfigured after an AMP channel move.
Quoted 5 lines
Signed-off-by Mat Martineau <[email protected]>--- include/net/bluetooth/l2cap.h | 1 + net/bluetooth/l2cap_core.c | 154 ++++++++++++++++++++++++----------------- 2 files changed, 92 insertions(+), 63 deletions(-)
Patch looks good to me. Applied to bluetooth-next. Thanks.
Gustavo
Re: [PATCH 3/4] Bluetooth: Lock the L2CAP channel when sending
In reply to Ulisses FurquimHi Ulisses -
Quoted 12 lines · Ulisses Furquim
Hi Mat,
Quoted 9 lines · Mat Martineau
The ERTM and streaming mode transmit queue must only be accessed while the L2CAP channel lock is held. Locking the channel before calling
l2cap_chan_sendensures that multiple threads cannot simultaneously manipulate the queue when sending and receiving concurrently.L2CAP channel locking had previously moved to the
l2cap_chanstruct instead of the associated socket, so some of the old socket locking can also be removed in this patch.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Mat Martineau <[email protected]>---
include/net/bluetooth/bluetooth.h | 2 --net/bluetooth/l2cap_sock.c| 15 ++++++++-------2 files changed, 8 insertions(+), 9 deletions(-)Looks good. I'm just wondering if we still have issues with chan lock versus sock lock elsewhere. Maybe you've done some auditing of this?
I did an extensive review of the locking code with respect to ERTM last week, and I'm satisfied with the use of chan_lock there.
The work to decouple l2cap_chan from sockets is not yet complete, so there are still socket locking calls at connect and disconnect time. The data path looks like it is clear of socket locks now.
--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
Re: [PATCH 3/4] Bluetooth: Lock the L2CAP channel when sending
Hi Mat,
Quoted 30 lines · Mat Martineau
Hi Ulisses -
Quoted 21 lines · Ulisses Furquim
Hi Mat,
Quoted 10 lines · Mat Martineau
The ERTM and streaming mode transmit queue must only be accessed while the L2CAP channel lock is held. Locking the channel before calling
l2cap_chan_sendensures that multiple threads cannot simultaneously manipulate the queue when sending and receiving concurrently.L2CAP channel locking had previously moved to the
l2cap_chanstruct instead of the associated socket, so some of the old socket locking can also be removed in this patch.Quoted 5 lines
Signed-off-by Mat Martineau <[email protected]>---
include/net/bluetooth/bluetooth.h | 2 --net/bluetooth/l2cap_sock.c| 15 ++++++++-------2 files changed, 8 insertions(+), 9 deletions(-)Quoted 2 lines
Looks good. I'm just wondering if we still have issues with chan lock versus sock lock elsewhere. Maybe you've done some auditing of this?
Quoted 6 lines
I did an extensive review of the locking code with respect to ERTM last week, and I'm satisfied with the use of
chan_lockthere.The work to decouple
l2cap_chanfrom sockets is not yet complete, so there are still socket locking calls at connect and disconnect time. The data path looks like it is clear of socket locks now.
Thanks, that's good to know.
Regards,
Signature · 5 lines
Ulisses Furquim ProFUSION embedded systems http://profusion.mobi Mobile: +55 19 9250 0942 Skype: ulissesffs
Re: [PATCH 4/4] Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation
In reply to Mat MartineauHi Mat,
Quoted 6 lines · Mat Martineau
Use more common code for ERTM and streaming mode segmentation and transmission, and begin using skb control block data for delaying extended or enhanced header generation until just before the packet is transmitted. This code is also better suited for resegmentation, which is needed when L2CAP links are reconfigured after an AMP channel move.
...
net/bluetooth/l2cap_core.c static int l2cap_ertm_send(struct l2cap_chan *chan) · line 1715
Quoted 8 lines
net/bluetooth/l2cap_core.c +3
-0@@ -1708,6 +1709,9 @@ static int l2cap_ertm_send(struct l2cap_chan *chan)if (chan->state !=BT_CONNECTED )return -ENOTCONN ; +if (test_bit (CONN_REMOTE_BUSY , &chan->conn_state)) +return 0 ; +while ((skb = chan->tx_send_head) && (!l2cap_tx_window_full (chan))) {
We check here chan->tx_send_head. But:
...
Quoted 3 lines
net/bluetooth/l2cap_core.c +0
-3-skb_queue_splice_tail (&sar_queue, &chan->tx_q); -if (chan->tx_send_head ==NULL ) - chan->tx_send_head = sar_queue.next;
...
net/bluetooth/l2cap_core.c int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, · line 2069
Quoted 3 lines
net/bluetooth/l2cap_core.c +0
-3- -if (chan->tx_send_head ==NULL ) - chan->tx_send_head = skb;
...
tx_send_head seems to be always NULL due to the change above. Have you tested that it actually works?
Best regards
Andrei Emeltchenko
Re: [PATCH 4/4] Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation
Hi Andrei -
Quoted 28 lines · Andrei Emeltchenko
Hi Mat,
Quoted 6 lines · Mat Martineau
Use more common code for ERTM and streaming mode segmentation and transmission, and begin using skb control block data for delaying extended or enhanced header generation until just before the packet is transmitted. This code is also better suited for resegmentation, which is needed when L2CAP links are reconfigured after an AMP channel move.
...
net/bluetooth/l2cap_core.c static int l2cap_ertm_send(struct l2cap_chan *chan) · line 1715
Quoted 8 lines
net/bluetooth/l2cap_core.c +3
-0@@ -1708,6 +1709,9 @@ static int l2cap_ertm_send(struct l2cap_chan *chan)if (chan->state !=BT_CONNECTED )return -ENOTCONN ; +if (test_bit (CONN_REMOTE_BUSY , &chan->conn_state)) +return 0 ; +while ((skb = chan->tx_send_head) && (!l2cap_tx_window_full (chan))) {We check here
chan->tx_send_head. But:...
Quoted 3 lines
net/bluetooth/l2cap_core.c +0
-3-skb_queue_splice_tail (&sar_queue, &chan->tx_q); -if (chan->tx_send_head ==NULL ) - chan->tx_send_head = sar_queue.next;...
Quoted 7 lines
net/bluetooth/l2cap_core.c int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, · line 2069
Quoted 3 lines
net/bluetooth/l2cap_core.c +0
-3- -if (chan->tx_send_head ==NULL ) - chan->tx_send_head = skb;...
tx_send_headseems to be always NULL due to the change above. Have you tested that it actually works?
I did some checks with l2test, but now that I look at the code I must have made a mistake (like accidentally using the wrong build). Sorry about that, I'll send a fix ASAP.
--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum