linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: Mat Martineau <mathewm@codeaurora.org>
Cc: linux-bluetooth@vger.kernel.org, padovan@profusion.mobi,
	pkrystad@codeaurora.org, marcel@holtmann.org,
	luiz.dentz@gmail.com, ulisses@profusion.mobi
Subject: Re: [RFC 1/2] Bluetooth: Header changes for ERTM state machine replacement
Date: Fri, 24 Feb 2012 11:48:45 +0200	[thread overview]
Message-ID: <20120224094842.GA4013@aemeltch-MOBL1> (raw)
In-Reply-To: <1330029469-8565-2-git-send-email-mathewm@codeaurora.org>

Hi Mat,

It is better to have normal patches for a better review.
I think that we can minimize amount of changes by redefining defines
when they cannot be used.

I also think think that patches shall be logically split like:
- change control field handling
- working with FCS, etc which do not affect state machine
- adding states

Also check some comments below: (I copied some code from the link you sent)

On Thu, Feb 23, 2012 at 12:37:48PM -0800, Mat Martineau wrote:
> This change affects data structures storing ERTM state and control
> fields, and adds new definitions for states and events.  An
> l2cap_seq_list structure is added for tracking ERTM sequence numbers
> without repeated memory allocations.  Control fields are carried in
> the bt_skb_cb struct rather than constantly doing shift and mask
> operations.
> 
> Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
> ---
>  include/net/bluetooth/bluetooth.h |   14 ++-
>  include/net/bluetooth/l2cap.h     |  260 +++++++++----------------------------
>  2 files changed, 73 insertions(+), 201 deletions(-)

...

> -static inline int l2cap_tx_window_full(struct l2cap_chan *ch)
> -{
> -	int sub;
> -
> -	sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64;
> -
> -	if (sub < 0)
> -		sub += 64;
> -
> -	return sub == ch->remote_tx_win;
> -}

BTW: was it already changed? What is the status with Luiz's patch?

...

> -static inline __u32 __get_control(struct l2cap_chan *chan, void *p)
> -{
> -	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
> -		return get_unaligned_le32(p);
> -	else
> -		return get_unaligned_le16(p);
> -}

Cannot it still be used?

+       if (test_bit(FLAG_EXT_CTRL, &chan->flags)) {
+               __get_extended_control(get_unaligned_le32(skb->data),
+                                      control);
+               skb_pull(skb, L2CAP_EXT_CTRL_SIZE);
+       } else {
+               __get_enhanced_control(get_unaligned_le16(skb->data),
+                                      control);
+               skb_pull(skb, L2CAP_ENH_CTRL_SIZE);
+       }
 
-       control = __get_control(chan, skb->data);
-       skb_pull(skb, __ctrl_size(chan));

...

> -static inline void __put_control(struct l2cap_chan *chan, __u32 control,
> -								void *p)
> -{
> -	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
> -		return put_unaligned_le32(control, p);
> -	else
> -		return put_unaligned_le16(control, p);
> -}

Can it be used in the code below:

+               if (test_bit(FLAG_EXT_CTRL, &chan->flags)) {
+                       put_unaligned_le32(__pack_extended_control(control),
+                                       skb->data + L2CAP_HDR_SIZE);
+               } else {
+                       put_unaligned_le16(__pack_enhanced_control(control),
+                                       skb->data + L2CAP_HDR_SIZE);
+               }

and for example here:

-       __put_control(chan, control, skb_put(skb, __ctrl_size(chan)));
+       /* Control header is populated later */
+       if (test_bit(FLAG_EXT_CTRL, &chan->flags))
+               put_unaligned_le32(0, skb_put(skb, 4));
+       else
+               put_unaligned_le16(0, skb_put(skb, 2));


> -
> -static inline __u8 __ctrl_size(struct l2cap_chan *chan)
> -{
> -	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
> -		return L2CAP_EXT_HDR_SIZE - L2CAP_HDR_SIZE;
> -	else
> -		return L2CAP_ENH_HDR_SIZE - L2CAP_HDR_SIZE;
> -}

Regards,
Andrei

  reply	other threads:[~2012-02-24  9:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-23 20:37 [RFC 0/2] New L2CAP ERTM state machine Mat Martineau
2012-02-23 20:37 ` [RFC 1/2] Bluetooth: Header changes for ERTM state machine replacement Mat Martineau
2012-02-24  9:48   ` Andrei Emeltchenko [this message]
2012-02-24 17:42     ` Ulisses Furquim
2012-02-25  0:21       ` Mat Martineau
2012-02-25 15:37         ` Ulisses Furquim
2012-02-27  9:28         ` Andrei Emeltchenko
2012-02-24 17:39   ` Ulisses Furquim
2012-02-25  0:32     ` Mat Martineau
2012-02-25 15:32       ` Ulisses Furquim
2012-02-28 23:33   ` Gustavo Padovan
2012-03-03  0:19     ` Mat Martineau
2012-02-23 20:37 ` [RFC 2/2] Bluetooth: L2CAP " Mat Martineau
2012-02-24 20:13   ` Ulisses Furquim
2012-02-25  1:08     ` Mat Martineau
2012-02-25 15:52       ` Ulisses Furquim
2012-02-27  9:15         ` Andrei Emeltchenko
2012-02-28 23:49       ` Gustavo Padovan
2012-03-03  0:30         ` Mat Martineau
2012-03-03  0:40           ` Marcel Holtmann
2012-03-06 23:09             ` Mat Martineau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120224094842.GA4013@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=mathewm@codeaurora.org \
    --cc=padovan@profusion.mobi \
    --cc=pkrystad@codeaurora.org \
    --cc=ulisses@profusion.mobi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).