public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Get a more accurate PDU len
@ 2012-05-25 20:54 Gustavo Padovan
  2012-05-25 21:22 ` Mat Martineau
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo Padovan @ 2012-05-25 20:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Both FCS and Extended header might be or might not be present in a ERTM
channel.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 net/bluetooth/l2cap_core.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c07c134..40d1d6f 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2143,6 +2143,14 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,
 	pdu_len = min_t(size_t, pdu_len, L2CAP_BREDR_MAX_PAYLOAD);
 
 	/* Adjust for largest possible L2CAP overhead. */
+	if (chan->fcs)
+		pdu_len -= L2CAP_FCS_SIZE;
+
+	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
+		pdu_len -= L2CAP_EXT_HDR_SIZE;
+	else
+		pdu_len -= L2CAP_ENH_HDR_SIZE;
+
 	pdu_len -= L2CAP_EXT_HDR_SIZE + L2CAP_FCS_SIZE;
 
 	/* Remote device may have requested smaller PDUs */
-- 
1.7.10.1


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

* Re: [PATCH] Bluetooth: Get a more accurate PDU len
  2012-05-25 20:54 [PATCH] Bluetooth: Get a more accurate PDU len Gustavo Padovan
@ 2012-05-25 21:22 ` Mat Martineau
  0 siblings, 0 replies; 5+ messages in thread
From: Mat Martineau @ 2012-05-25 21:22 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan


On Fri, 25 May 2012, Gustavo Padovan wrote:

> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> Both FCS and Extended header might be or might not be present in a ERTM
> channel.
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
> net/bluetooth/l2cap_core.c |    8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index c07c134..40d1d6f 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -2143,6 +2143,14 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,
> 	pdu_len = min_t(size_t, pdu_len, L2CAP_BREDR_MAX_PAYLOAD);
>
> 	/* Adjust for largest possible L2CAP overhead. */
> +	if (chan->fcs)
> +		pdu_len -= L2CAP_FCS_SIZE;
> +
> +	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
> +		pdu_len -= L2CAP_EXT_HDR_SIZE;
> +	else
> +		pdu_len -= L2CAP_ENH_HDR_SIZE;
> +
> 	pdu_len -= L2CAP_EXT_HDR_SIZE + L2CAP_FCS_SIZE;

Don't you want to remove this last line?

>
> 	/* Remote device may have requested smaller PDUs */
> -- 
> 1.7.10.1

--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

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

* [PATCH] Bluetooth: Get a more accurate PDU len
@ 2012-05-25 21:57 Gustavo Padovan
  2012-05-25 23:15 ` Mat Martineau
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo Padovan @ 2012-05-25 21:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Both FCS and Extended header might be or might not be present in a ERTM
channel.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 net/bluetooth/l2cap_core.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c07c134..c614532 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2143,7 +2143,13 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,
 	pdu_len = min_t(size_t, pdu_len, L2CAP_BREDR_MAX_PAYLOAD);
 
 	/* Adjust for largest possible L2CAP overhead. */
-	pdu_len -= L2CAP_EXT_HDR_SIZE + L2CAP_FCS_SIZE;
+	if (chan->fcs)
+		pdu_len -= L2CAP_FCS_SIZE;
+
+	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
+		pdu_len -= L2CAP_EXT_HDR_SIZE;
+	else
+		pdu_len -= L2CAP_ENH_HDR_SIZE;
 
 	/* Remote device may have requested smaller PDUs */
 	pdu_len = min_t(size_t, pdu_len, chan->remote_mps);
-- 
1.7.10.1


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

* Re: [PATCH] Bluetooth: Get a more accurate PDU len
  2012-05-25 21:57 Gustavo Padovan
@ 2012-05-25 23:15 ` Mat Martineau
  2012-05-26  3:15   ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Mat Martineau @ 2012-05-25 23:15 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan


On Fri, 25 May 2012, Gustavo Padovan wrote:

> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> Both FCS and Extended header might be or might not be present in a ERTM
> channel.
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
> net/bluetooth/l2cap_core.c |    8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index c07c134..c614532 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -2143,7 +2143,13 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,
> 	pdu_len = min_t(size_t, pdu_len, L2CAP_BREDR_MAX_PAYLOAD);
>
> 	/* Adjust for largest possible L2CAP overhead. */
> -	pdu_len -= L2CAP_EXT_HDR_SIZE + L2CAP_FCS_SIZE;
> +	if (chan->fcs)
> +		pdu_len -= L2CAP_FCS_SIZE;
> +
> +	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
> +		pdu_len -= L2CAP_EXT_HDR_SIZE;
> +	else
> +		pdu_len -= L2CAP_ENH_HDR_SIZE;
>
> 	/* Remote device may have requested smaller PDUs */
> 	pdu_len = min_t(size_t, pdu_len, chan->remote_mps);
> -- 
> 1.7.10.1

Looks good to me.

Reviewed-by: Mat Martineau <mathewm@codeaurora.org>

--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum


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

* Re: [PATCH] Bluetooth: Get a more accurate PDU len
  2012-05-25 23:15 ` Mat Martineau
@ 2012-05-26  3:15   ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2012-05-26  3:15 UTC (permalink / raw)
  To: Mat Martineau; +Cc: Gustavo Padovan, linux-bluetooth, Gustavo Padovan

Hi Gustavo,

> > From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> >
> > Both FCS and Extended header might be or might not be present in a ERTM
> > channel.
> >
> > Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > ---
> > net/bluetooth/l2cap_core.c |    8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > index c07c134..c614532 100644
> > --- a/net/bluetooth/l2cap_core.c
> > +++ b/net/bluetooth/l2cap_core.c
> > @@ -2143,7 +2143,13 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,
> > 	pdu_len = min_t(size_t, pdu_len, L2CAP_BREDR_MAX_PAYLOAD);
> >
> > 	/* Adjust for largest possible L2CAP overhead. */
> > -	pdu_len -= L2CAP_EXT_HDR_SIZE + L2CAP_FCS_SIZE;
> > +	if (chan->fcs)
> > +		pdu_len -= L2CAP_FCS_SIZE;
> > +
> > +	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
> > +		pdu_len -= L2CAP_EXT_HDR_SIZE;
> > +	else
> > +		pdu_len -= L2CAP_ENH_HDR_SIZE;
> >
> > 	/* Remote device may have requested smaller PDUs */
> > 	pdu_len = min_t(size_t, pdu_len, chan->remote_mps);
> > -- 
> > 1.7.10.1
> 
> Looks good to me.
> 
> Reviewed-by: Mat Martineau <mathewm@codeaurora.org>

patch has been applied to bluetooth-next tree.

Regards

Marcel



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

end of thread, other threads:[~2012-05-26  3:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-25 20:54 [PATCH] Bluetooth: Get a more accurate PDU len Gustavo Padovan
2012-05-25 21:22 ` Mat Martineau
  -- strict thread matches above, loose matches on Subject: below --
2012-05-25 21:57 Gustavo Padovan
2012-05-25 23:15 ` Mat Martineau
2012-05-26  3:15   ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox