All of lore.kernel.org
 help / color / mirror / Atom feed
From: Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com>
To: Szymon Janc <szymon.janc@tieto.com>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [RFCv2 6/7] Bluetooth: add EFS option in l2cap conf req
Date: Fri, 2 Sep 2011 10:25:09 +0300	[thread overview]
Message-ID: <20110902072500.GA6423@aemeltch-MOBL1> (raw)
In-Reply-To: <201109011445.03117.szymon.janc@tieto.com>

Hi Szymon,

On Thu, Sep 01, 2011 at 02:45:03PM +0200, Szymon Janc wrote:
> Hi Andrei,
> 
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > 
> > Adds extended flowspec option when building l2cap config request
> > EFS is added if both the local and remote L2CAP entities have
> > indicated support for the Extended Flow Specification for BR/EDR
> > 
> > Based upon haijun.liu <haijun.liu@atheros.com> series of patches
> > (sent Sun, 22 Aug 2010)
> > 
> > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > ---
> >  include/net/bluetooth/l2cap.h |    2 +
> >  net/bluetooth/l2cap_core.c    |   70 ++++++++++++++++++++++++++++++++++++++++-
> >  2 files changed, 71 insertions(+), 1 deletions(-)
> > 
> > diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> > index 1f26a39..fc81771 100644
> > --- a/include/net/bluetooth/l2cap.h
> > +++ b/include/net/bluetooth/l2cap.h
> > @@ -445,6 +445,8 @@ struct l2cap_conn {
> >  	__u32		rx_len;
> >  	__u8		tx_ident;
> >  
> > +	__u8		flowspec_ident;
> > +
> >  	__u8		disc_reason;
> >  
> >  	__u8		preq[7]; /* SMP Pairing Request */
> > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > index 02908f0..c2c5eb7 100644
> > --- a/net/bluetooth/l2cap_core.c
> > +++ b/net/bluetooth/l2cap_core.c
> > @@ -549,6 +549,26 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn)
> >  	return id;
> >  }
> >  
> > +static inline u8 l2cap_flowspec_ident(struct l2cap_conn *conn)
> > +{
> > +	u8 id;
> > +
> > +	/* Get next available ident for the flow spec of guaranteed channel.
> > +	 *    2 - 255 are used.
> > +	 */
> > +
> > +	spin_lock_bh(&conn->lock);
> > +
> > +	if (++conn->flowspec_ident > 256)
> > +		conn->flowspec_ident = 2;
> 
> flowspec_ident is u8, shouldn't this be 'if (++conn->flowspec_ident < 2)' ?
> Also shouldn't you check if there is no channel with specified id before using that id?

Yes you are right here. But I am thinking to drop this function as we
might to support only Best Effort with fixed ident.

Best regards 
Andrei Emeltchenko 


> 
> > +
> > +	id = conn->flowspec_ident;
> > +
> > +	spin_unlock_bh(&conn->lock);
> > +
> > +	return id;
> > +}
> > +
> >  static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
> >  {
> >  	struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
> > @@ -1908,6 +1928,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
> >  {
> >  	struct l2cap_conf_req *req = data;
> >  	struct l2cap_conf_rfc rfc = { .mode = chan->mode };
> > +	struct l2cap_conf_efs efs = { .service_type = L2CAP_SERV_BESTEFFORT };
> >  	void *ptr = req->data;
> >  
> >  	BT_DBG("chan %p", chan);
> > @@ -1921,7 +1942,11 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
> >  		if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state))
> >  			break;
> >  
> > -		/* fall through */
> > +		if (__l2cap_efs_supported(chan))
> > +			set_bit(FLAG_EFS_ENABLE, &chan->flags);
> > +
> > +		break;
> > +
> >  	default:
> >  		chan->mode = l2cap_select_mode(rfc.mode, chan->conn->feat_mask);
> >  		break;
> > @@ -1961,6 +1986,33 @@ done:
> >  		l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
> >  							(unsigned long) &rfc);
> >  
> > +		if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) {
> > +			efs.service_type = chan->local_stype;
> > +			efs.max_sdu_size = cpu_to_le16(chan->local_msdu);
> > +			efs.sdu_inter_time = cpu_to_le32(chan->local_sdu_itime);
> > +
> > +			if (chan->local_stype == L2CAP_SERV_BESTEFFORT) {
> > +				chan->local_id = 1;
> > +				efs.id = chan->local_id;
> > +				efs.access_latency =
> > +					cpu_to_le32(L2CAP_DEFAULT_ACCESS_LATENCY);
> > +				efs.flush_timeout =
> > +					cpu_to_le32(L2CAP_DEFAULT_FLUSH_TO);
> > +			} else {
> > +				/* As spec, the ident shall be unique within
> > +				   the scope of a physical link.
> > +				 */
> > +				chan->local_id = l2cap_flowspec_ident(chan->conn);
> > +				efs.id = chan->local_id;
> > +				efs.access_latency =
> > +					cpu_to_le32(chan->local_acc_lat);
> > +				efs.flush_timeout =
> > +					cpu_to_le32(chan->local_flush_to);
> > +			}
> > +			l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS,
> > +					sizeof(efs), (unsigned long) &efs);
> > +		}
> > +
> >  		if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS))
> >  			break;
> >  
> > @@ -1969,6 +2021,7 @@ done:
> >  			chan->fcs = L2CAP_FCS_NONE;
> >  			l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs);
> >  		}
> > +
> >  		break;
> >  
> >  	case L2CAP_MODE_STREAMING:
> > @@ -1984,6 +2037,20 @@ done:
> >  		l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
> >  							(unsigned long) &rfc);
> >  
> > +		if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) {
> > +			efs.id = 1;
> > +			efs.service_type = L2CAP_SERV_BESTEFFORT;
> > +			efs.max_sdu_size =
> > +				cpu_to_le16(chan->local_msdu);
> > +			efs.sdu_inter_time =
> > +				cpu_to_le32(chan->local_sdu_itime);
> > +			efs.access_latency = 0;
> > +			efs.flush_timeout = 0;
> > +
> > +			l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS,
> > +					sizeof(efs), (unsigned long) &efs);
> > +		}
> > +
> >  		if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS))
> >  			break;
> >  
> > @@ -1992,6 +2059,7 @@ done:
> >  			chan->fcs = L2CAP_FCS_NONE;
> >  			l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs);
> >  		}
> > +
> >  		break;
> >  	}
> >  
> > 
> 
> -- 
> BR
> Szymon Janc

  reply	other threads:[~2011-09-02  7:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01 11:07 [RFCv2 0/7] EFS: extended flow specification option support Emeltchenko Andrei
2011-09-01 11:07 ` [RFCv2 1/7] Bluetooth: L2CAP extended feature mask update Emeltchenko Andrei
2011-09-01 11:07 ` [RFCv2 2/7] Bluetooth: EFS: definitions and headers for EFS Emeltchenko Andrei
2011-09-01 11:07 ` [RFCv2 3/7] Bluetooth: EFS: add disable_flowspec kernel param Emeltchenko Andrei
2011-09-13 20:17   ` Gustavo Padovan
2011-09-14  5:30     ` Marcel Holtmann
2011-09-14  8:30       ` Emeltchenko Andrei
2011-09-14 13:38         ` Gustavo Padovan
2011-09-01 11:07 ` [RFCv2 4/7] Bluetooth: parse EFS in l2cap config request Emeltchenko Andrei
2011-09-13 20:32   ` Gustavo Padovan
2011-09-01 11:07 ` [RFCv2 5/7] Bluetooth: parse EFS in l2cap config response Emeltchenko Andrei
2011-09-01 11:07 ` [RFCv2 6/7] Bluetooth: add EFS option in l2cap conf req Emeltchenko Andrei
2011-09-01 12:45   ` Szymon Janc
2011-09-02  7:25     ` Emeltchenko Andrei [this message]
2011-09-01 11:07 ` [RFCv2 7/7] Bluetooth: EFS: parse l2cap config rsp pending 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=20110902072500.GA6423@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=szymon.janc@tieto.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.