linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gustavo Padovan <padovan@profusion.mobi>
To: Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com>,
	linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv3 11/16] Bluetooth: EWS: handling different Control fields
Date: Fri, 14 Oct 2011 15:19:31 -0300	[thread overview]
Message-ID: <20111014181931.GC30989@joana> (raw)
In-Reply-To: <20111014180915.GB30989@joana>

* Gustavo Padovan <padovan@profusion.mobi> [2011-10-14 15:09:15 -0300]:

> Hi Andrei,
> 
> * Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2011-10-14 13:56:03 +0300]:
> 
> > Hi Gustavo,
> > 
> > On Thu, Oct 13, 2011 at 04:49:25PM -0300, Gustavo Padovan wrote:
> > > * Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2011-10-11 13:37:51 +0300]:
> > > 
> > > > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > > > 
> > > > There are three different Control Field formats: the Standard Control
> > > > Field, the Enhanced Control Field, and the Extended Control Field.
> > > > Patch adds function to handle all those fields seamlessly.
> > > > 
> > > > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > > > ---
> > > >  include/net/bluetooth/l2cap.h |   43 +++++++++++++++++++
> > > >  net/bluetooth/l2cap_core.c    |   93 +++++++++++++++++++++-------------------
> > > >  2 files changed, 92 insertions(+), 44 deletions(-)
> > > > 
> > > > diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> > > > index 67a2fdb..3a5f4c0 100644
> > > > --- a/include/net/bluetooth/l2cap.h
> > > > +++ b/include/net/bluetooth/l2cap.h
> > > > @@ -27,6 +27,8 @@
> > > >  #ifndef __L2CAP_H
> > > >  #define __L2CAP_H
> > > >  
> > > > +#include <asm/unaligned.h>
> > > > +
> > > >  /* L2CAP defaults */
> > > >  #define L2CAP_DEFAULT_MTU		672
> > > >  #define L2CAP_DEFAULT_MIN_MTU		48
> > > > @@ -643,6 +645,47 @@ static inline bool __is_ctrl_poll(struct l2cap_chan *chan, __u32 ctrl)
> > > >  	else
> > > >  		return ctrl & L2CAP_CTRL_POLL;
> > > >  }
> > > > +
> > > > +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);
> > > > +}
> > > > +
> > > > +static inline __u32 __get_control_pull(struct l2cap_chan *chan,
> > > > +		struct sk_buff *skb, void *p)
> > > > +{
> > > > +	__u32 ctrl;
> > > > +
> > > > +	if (test_bit(FLAG_EXT_CTRL, &chan->flags)) {
> > > > +		ctrl = get_unaligned_le32(p);
> > > > +		skb_pull(skb, 4);
> > > > +	} else {
> > > > +		ctrl = get_unaligned_le16(p);
> > > > +		skb_pull(skb, 2);
> > > > +	}
> > > 
> > > 
> > > I prefer not hide the skb_pull inside another function.
> > 
> > OK, I will change it to something like:
> > 
> > <------8<----------------------------------------------------------------
> > |  @@ -4005,7 +4009,8 @@ static int l2cap_ertm_data_rcv(struct sock *sk,
> > |  struct sk_buff *skb)
> > |          u16 req_seq;
> > |          int len, next_tx_seq_offset, req_seq_offset;
> > |
> > |  -       control = __get_control_pull(chan, skb, skb->data);
> > |  +       control = __get_control(chan, skb->data);
> > |  +       skb_pull(skb, __get_ctrl_size(chan));
> > |          len = skb->len;
> > |
> > |          /*
> > |
> > <------8<----------------------------------------------------------------
> > 
> > 
> > > > +
> > > > +	return ctrl;
> > > > +}
> > > > +
> > > > +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);
> > > > +}
> > > > +
> > > > +static inline void __put_control_put(struct l2cap_chan *chan, __u32 control, void *p)
> > > > +{
> > > > +	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
> > > > +		return put_unaligned_le32(control, skb_put(p, 4));
> > > > +	else
> > > > +		return put_unaligned_le16(control, skb_put(p, 2));
> > > > +}
> > > 
> > > 
> > > get ride of this, you still can do __put_control(chan, control,
> > > skb_put())
> > the second argument in skb_put changes so I cannot use proposed way.
> 
> Why not? 
> 
> You just call __put_control(chan, control, skb_put(skb, N));

Actually it is __get_ctrl_size() instead of N here, and just rename it to
__ctrl_size() only.

	Gustavo

  reply	other threads:[~2011-10-14 18:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-11 10:37 [PATCHv3 00/16] EWS: extended window size and extended control field support Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 01/16] Bluetooth: clean up spaces in L2CAP header Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 02/16] Bluetooth: EWS: extended window size option support Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 03/16] Bluetooth: EWS: adds ext control field bit mask Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 04/16] Bluetooth: EWS: rewrite handling Supervisory (S) bits Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 05/16] Bluetooth: EWS: rewrite handling SAR bits Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 06/16] Bluetooth: EWS: rewrite reqseq calculation Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 07/16] Bluetooth: EWS: rewrite L2CAP ERTM txseq calculation Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 08/16] Bluetooth: EWS: rewrite check frame type function Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 09/16] Bluetooth: EWS: rewrite handling FINAL (F) bit Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 10/16] Bluetooth: EWS: rewrite handling POLL (P) bit Emeltchenko Andrei
2011-10-13 19:47   ` Gustavo Padovan
2011-10-11 10:37 ` [PATCHv3 11/16] Bluetooth: EWS: handling different Control fields Emeltchenko Andrei
2011-10-13 19:49   ` Gustavo Padovan
2011-10-14 10:56     ` Emeltchenko Andrei
2011-10-14 18:09       ` Gustavo Padovan
2011-10-14 18:19         ` Gustavo Padovan [this message]
2011-10-11 10:37 ` [PATCHv3 12/16] Bluetooth: EWS: recalculate L2CAP header size Emeltchenko Andrei
2011-10-13 19:54   ` Gustavo Padovan
2011-10-11 10:37 ` [PATCHv3 13/16] Bluetooth: EWS: support extended seq numbers Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 14/16] Bluetooth: EWS: define L2CAP header sizes Emeltchenko Andrei
2011-10-13 19:55   ` Gustavo Padovan
2011-10-14 11:15     ` Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 15/16] Bluetooth: EWS: remove magic numbers in l2cap Emeltchenko Andrei
2011-10-11 10:37 ` [PATCHv3 16/16] Bluetooth: EWS: fix max_pdu calculation Emeltchenko Andrei

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=20111014181931.GC30989@joana \
    --to=padovan@profusion.mobi \
    --cc=Andrei.Emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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).