From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCHv2 2/4] android/socket Use 64K buffer for socket handling
Date: Thu, 5 Dec 2013 15:48:24 +0200 [thread overview]
Message-ID: <20131205134822.GA13420@aemeltch-MOBL1> (raw)
In-Reply-To: <CABBYNZLzirtMJresKRYi9D-rJ8d0sJEXXDoP4X8ep=sUJv+ozQ@mail.gmail.com>
Hi Luiz,
On Thu, Dec 05, 2013 at 02:43:10PM +0200, Luiz Augusto von Dentz wrote:
> Hi Andrei,
>
> On Tue, Dec 3, 2013 at 5:51 PM, Andrei Emeltchenko
> <Andrei.Emeltchenko.news@gmail.com> wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >
> > Make SOCKET_BUFFER define and use 0xFFFE instead of 1K.
> > The value 0XFFFE is what Android sends in OBEX Connect packet in
> > Maximum Packet Length field. Though OBEX specify meximum packet
> > length as 64K - 1 which is 0xFFFF.
> > ---
> > android/socket.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/android/socket.c b/android/socket.c
> > index 9020874..9ff9019 100644
> > --- a/android/socket.c
> > +++ b/android/socket.c
> > @@ -52,6 +52,8 @@
> >
> > #define SVC_HINT_OBEX 0x10
> >
> > +#define SOCKET_BUFFER 0xFFFE
> > +
> > static bdaddr_t adapter_addr;
> >
> > /* Simple list of RFCOMM server sockets */
> > @@ -487,7 +489,7 @@ static gboolean sock_stack_event_cb(GIOChannel *io, GIOCondition cond,
> > gpointer data)
> > {
> > struct rfcomm_sock *rfsock = data;
> > - unsigned char buf[1024];
> > + unsigned char buf[SOCKET_BUFFER];
> > int len, sent;
> >
> > if (cond & G_IO_HUP) {
> > @@ -526,7 +528,7 @@ static gboolean sock_rfcomm_event_cb(GIOChannel *io, GIOCondition cond,
> > gpointer data)
> > {
> > struct rfcomm_sock *rfsock = data;
> > - unsigned char buf[1024];
> > + unsigned char buf[SOCKET_BUFFER];
> > int len, sent;
> >
> > if (cond & G_IO_HUP) {
> > --
> > 1.8.3.2
>
> We need to be a bit more generic here, the socket HAL is not
> restricted to OBEX only, also it doesn't seems you are adjusting the
> buffer level of the sockets,
it is in the following patch
> the buffer itself is just to copy between
> the sockets so we have to follow how much the sockets can
> transmit/receive not the other way around.
the idea is to copy data to socket buffers and then sleep.
> So it seems to me that we should either set the maximum MTU size we
> could use with RFCOMM (UINT16_MAX?) or read the MTU once connected
> (not sure if makes sense since it is SOCK_STREAM) and then allocate
> the same amount as buffer in a field in struct rfcomm_sock, also this
> needs then to be set back to socketpair with
> setsocketopt(SO_RCVBUF/SO_SNDBUF) so we minimize context switches and
> wakeups.
This can actually make more switches since RFCOMM packet size is
relatively small (990 bytes in my case). Maximum RFCOMM L2CAP MTU is 1013.
This is what we had before.
Best regards
Andrei Emeltchenko
next prev parent reply other threads:[~2013-12-05 13:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-03 15:51 [PATCHv2 0/4] Socket optimization Andrei Emeltchenko
2013-12-03 15:51 ` [PATCHv2 1/4] android/socket: Cleanup sockets on unregister Andrei Emeltchenko
2013-12-05 14:51 ` Luiz Augusto von Dentz
2013-12-03 15:51 ` [PATCHv2 2/4] android/socket Use 64K buffer for socket handling Andrei Emeltchenko
2013-12-05 12:43 ` Luiz Augusto von Dentz
2013-12-05 13:48 ` Andrei Emeltchenko [this message]
2013-12-03 15:51 ` [PATCHv2 3/4] android/socket: Use heap instead of stack Andrei Emeltchenko
2013-12-03 15:51 ` [PATCHv2 4/4] android/socket: Setup socket buffer sizes Andrei Emeltchenko
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=20131205134822.GA13420@aemeltch-MOBL1 \
--to=andrei.emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.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 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).