linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo F. Padovan" <gustavo@padovan.org>
To: Mat Martineau <mathewm@codeaurora.org>
Cc: linux-bluetooth@vger.kernel.org, marcel@holtmann.org,
	rshaffer@codeaurora.org, linux-arm-msm@vger.kernel.org
Subject: Re: [RFC 6/7] Bluetooth: Reassemble enhanced L2CAP PDUs using skb fragments.
Date: Wed, 11 Aug 2010 02:24:33 -0300	[thread overview]
Message-ID: <20100811052433.GA10773@vigoh> (raw)
In-Reply-To: <1281467704-5378-7-git-send-email-mathewm@codeaurora.org>

Hi Mat,

* Mat Martineau <mathewm@codeaurora.org> [2010-08-10 12:15:03 -0700]:

> As enhanced L2CAP PDUs arrive, it is not necessary to copy them
> in to a separate skbuff.  Instead, the skbuffs can be linked
> together as fragments, only being copied in to a linear buffer
> when the data is copied to userspace.  This avoids the need
> to allocate additional buffers for incoming data, and
> eliminates copying of data payloads during SDU reassembly.
> This is of greater concern with high-speed AMP links than
> with BR/EDR.
> 
> Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
> ---
>  include/net/bluetooth/l2cap.h |    1 +
>  net/bluetooth/l2cap.c         |   66 +++++++++++++++++++++-------------------
>  2 files changed, 36 insertions(+), 31 deletions(-)
> 
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index 2f3222f..9384e87 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -357,6 +357,7 @@ struct l2cap_pinfo {
>  	__u16		sdu_len;
>  	__u16		partial_sdu_len;
>  	struct sk_buff	*sdu;
> +	struct sk_buff	*sdu_last_frag;
>  
>  	__u8		ident;
>  
> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
> index b485c4a..0212035 100644
> --- a/net/bluetooth/l2cap.c
> +++ b/net/bluetooth/l2cap.c
> @@ -290,6 +290,9 @@ static void l2cap_chan_del(struct sock *sk, int err)
>  		skb_queue_purge(SREJ_QUEUE(sk));
>  		skb_queue_purge(BUSY_QUEUE(sk));
>  
> +		if (l2cap_pi(sk)->sdu)
> +			kfree_skb(l2cap_pi(sk)->sdu);
> +
>  		list_for_each_entry_safe(l, tmp, SREJ_LIST(sk), list) {
>  			list_del(&l->list);
>  			kfree(l);
> @@ -3635,6 +3638,27 @@ static int l2cap_add_to_srej_queue(struct sock *sk, struct sk_buff *skb, u8 tx_s
>  	return 0;
>  }
>  
> +static inline void append_skb_frag(struct sk_buff *skb,
> +			struct sk_buff *new_frag, struct sk_buff **last_frag)

Call this l2cap_append_skb_frag()

> +{
> +	/* skb->len reflects data in skb as well as all fragments
> +	   skb->data_len reflects only data in fragments
> +	 */
> +	BT_DBG("skb %p, new_frag %p, *last_frag %p", skb, new_frag, *last_frag);
> +
> +	if (!skb_has_frags(skb))
> +		skb_shinfo(skb)->frag_list = new_frag;
> +
> +	new_frag->next = NULL;
> +
> +	(*last_frag)->next = new_frag;
> +	*last_frag = new_frag;
> +
> +	skb->len += new_frag->len;
> +	skb->data_len += new_frag->len;
> +	skb->truesize += new_frag->truesize;
> +}
> +

Wondering if it is possible to do that append more simple, but I looked
through the kernel code it's not possible, we have to keep last frag
pointer.

This change should go to l2cap_streaming_reassembly_sdu() as well, then
you can get ride of partial_sdu_len in the struct l2cap_pinfo.

>  static int l2cap_ertm_reassembly_sdu(struct sock *sk, struct sk_buff *skb, u16 control)
>  {
>  	struct l2cap_pinfo *pi = l2cap_pi(sk);
> @@ -3643,7 +3667,7 @@ static int l2cap_ertm_reassembly_sdu(struct sock *sk, struct sk_buff *skb, u16 c
>  
>  	switch (control & L2CAP_CTRL_SAR) {
>  	case L2CAP_SDU_UNSEGMENTED:
> -		if (pi->conn_state & L2CAP_CONN_SAR_SDU)
> +		if (pi->sdu)

pi->sdu can do the work work of pi->conn_state & L2CAP_CONN_SAR_SDU, so
a separated patch for that change sounds better (you can change that for
the Streaming mode at the same time, it's a similar code, but more simple).


-- 
Gustavo F. Padovan
http://padovan.org

  reply	other threads:[~2010-08-11  5:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-10 19:14 [RFC 0/7] L2CAP fragmentation changes Mat Martineau
2010-08-10 19:14 ` [RFC 1/7] Bluetooth: Calculate L2CAP FCS on fragmented skbuffs Mat Martineau
2010-08-10 21:22   ` Marcel Holtmann
2010-08-10 21:57   ` Gustavo F. Padovan
2010-08-10 19:14 ` [RFC 2/7] Bluetooth: Use enhanced L2CAP header structure and symbolic values Mat Martineau
2010-08-10 21:39   ` Marcel Holtmann
2010-08-10 22:07   ` Gustavo F. Padovan
2010-08-11  2:24     ` Mat Martineau
2010-08-11  3:23       ` Gustavo F. Padovan
2010-08-10 19:15 ` [RFC 3/7] Bluetooth: Add FCS awareness to L2CAP HCI fragmentation Mat Martineau
2010-08-10 21:29   ` Marcel Holtmann
2010-08-11  3:35   ` Gustavo F. Padovan
2010-08-11  3:56     ` Gustavo F. Padovan
2010-08-10 19:15 ` [RFC 4/7] Bluetooth: Linearize received L2CAP skbuffs Mat Martineau
2010-08-10 21:38   ` Marcel Holtmann
2010-08-11  3:58     ` Gustavo F. Padovan
2010-08-10 19:15 ` [RFC 5/7] Bluetooth: Handle fragmented skbs in bt_sock_stream_recvmsg() Mat Martineau
2010-08-11  4:25   ` Gustavo F. Padovan
2010-08-10 19:15 ` [RFC 6/7] Bluetooth: Reassemble enhanced L2CAP PDUs using skb fragments Mat Martineau
2010-08-11  5:24   ` Gustavo F. Padovan [this message]
2010-08-10 19:15 ` [RFC 7/7] Bluetooth: Do not limit enhanced L2CAP max PDU size to HCI MTU Mat Martineau
2010-08-11  5:25   ` Gustavo F. Padovan

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=20100811052433.GA10773@vigoh \
    --to=gustavo@padovan.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mathewm@codeaurora.org \
    --cc=rshaffer@codeaurora.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).