9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] usbether
@ 2012-09-29 16:16 Richard Miller
  2012-09-29 16:39 ` Gorka Guardiola
  2012-09-30 23:29 ` Tristan
  0 siblings, 2 replies; 16+ messages in thread
From: Richard Miller @ 2012-09-29 16:16 UTC (permalink / raw)
  To: 9fans

I've been struggling to get the raspberry pi's built-in usb ethernet
adapter working.  I can send and receive packets reliably enough to
get a remote file system mounted, but with any kind of heavy use the
usbether input seems to be missing a lot of packets, and everything
gets horribly slow.

After running out of 9pi-specific things to debug, it occurred to me
to try a usb ethernet dongle on an x86 plan 9 machine.  There I
observed the same thing: so many dropped packets that the connection
is unusable.

So, has anyone had success using usbether to connect a plan 9 system
to the outside world?  I am hoping someone can give me an encouraging
report.  I'm a bit worried that it's a fundamental problem with the
plan 9 usb architecture, which is basically synchronous - the host
adapter driver in the kernel will poll a device for input only when
the user-level driver process does a read.  This is ok for things like
usbdisk which have an rpc-like protocol, but seems less well suited to
things like ethernet and serial interfaces, where the equivalent
non-usb kernel drivers use qio to read ahead into a queue of buffers
until the user-level consuming process gets around to reading them.

Would anyone like to share experiences or comments?




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 16:16 [9fans] usbether Richard Miller
@ 2012-09-29 16:39 ` Gorka Guardiola
  2012-09-29 17:03   ` erik quanstrom
  2012-09-30 23:29 ` Tristan
  1 sibling, 1 reply; 16+ messages in thread
From: Gorka Guardiola @ 2012-09-29 16:39 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Sat, Sep 29, 2012 at 6:16 PM, Richard Miller <9fans@hamnavoe.com> wrote:
> So, has anyone had success using usbether to connect a plan 9 system
> to the outside world?  I am hoping someone can give me an encouraging
> report.  I'm a bit worried that it's a fundamental problem with the
> plan 9 usb architecture, which is basically synchronous - the host
> adapter driver in the kernel will poll a device for input only when
> the user-level driver process does a read.  This is ok for things like
> usbdisk which have an rpc-like protocol, but seems less well suited to
> things like ethernet and serial interfaces, where the equivalent
> non-usb kernel drivers use qio to read ahead into a queue of buffers
> until the user-level consuming process gets around to reading them.
>
> Would anyone like to share experiences or comments?
>
>

I had a similar problem with serial a while ago. The problem was that
it was taking too long doing too many system calls, doing big reads
and buffering may help you?

G.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 16:39 ` Gorka Guardiola
@ 2012-09-29 17:03   ` erik quanstrom
  2012-09-29 18:01     ` Richard Miller
  0 siblings, 1 reply; 16+ messages in thread
From: erik quanstrom @ 2012-09-29 17:03 UTC (permalink / raw)
  To: 9fans

> I had a similar problem with serial a while ago. The problem was that
> it was taking too long doing too many system calls, doing big reads
> and buffering may help you?

why doesn't the device do the buffering?  or is the problem
that usb/ether essentially an event loop of <read packet> <write packet>
and any delays in that pipeline accumulate?

- erik



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 17:03   ` erik quanstrom
@ 2012-09-29 18:01     ` Richard Miller
  2012-09-29 18:19       ` Gorka Guardiola
  2012-09-29 18:41       ` erik quanstrom
  0 siblings, 2 replies; 16+ messages in thread
From: Richard Miller @ 2012-09-29 18:01 UTC (permalink / raw)
  To: 9fans

> why doesn't the device do the buffering?

By "device" do you mean the hardware usb/ether adapter?  It does some
buffering - you can configure it to "burst" as many ether input packets
as will fit in N 512-byte usb packets, in each usb input operation.
I've got N=37 because that's what the linux driver does; of course
there's no documentation to explain what the allowed range is or
what the consequences of varying it would be.  As far as I can see
there's no "overrun" flag for the device to tell me I've missed
reading some packets.

>  or is the problem
> that usb/ether essentially an event loop of <read packet> <write packet>
> and any delays in that pipeline accumulate?

Almost: it's a pipeline of one thread reading a buffer full of packets,
splitting it up, and sending a packet at a time to a second thread, which
writes them to the kernel packet ethernet interface, which stores them
in a Buf queue.




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 18:01     ` Richard Miller
@ 2012-09-29 18:19       ` Gorka Guardiola
  2012-09-29 18:24         ` Richard Miller
  2012-09-29 18:41       ` erik quanstrom
  1 sibling, 1 reply; 16+ messages in thread
From: Gorka Guardiola @ 2012-09-29 18:19 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Sat, Sep 29, 2012 at 8:01 PM, Richard Miller <9fans@hamnavoe.com> wrote:

> Almost: it's a pipeline of one thread reading a buffer full of packets,
> splitting it up, and sending a packet at a time to a second thread, which
> writes them to the kernel packet ethernet interface, which stores them
> in a Buf queue.
>

Taking a cursory glance it looks as if it just reading at most one
full packet at a time
(the size of the buffer is 2000), it may be if they are small you may
get more than one
in one read, but it may not be so, depends on the device and what is
set as maxpkt
which may be changed with usbctl if the device lets you

Making a bigger buffer (after making sure you can actually read more
bytes) and or decoupling
reader and processer by having a buffered channel so that the
reader can spend more time reading may help (it helped for serial).


G.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 18:19       ` Gorka Guardiola
@ 2012-09-29 18:24         ` Richard Miller
  2012-09-29 21:38           ` Gorka Guardiola
  0 siblings, 1 reply; 16+ messages in thread
From: Richard Miller @ 2012-09-29 18:24 UTC (permalink / raw)
  To: 9fans

> Taking a cursory glance it looks as if it just reading at most one
> full packet at a time
> (the size of the buffer is 2000)

That's the asix driver: the raspberry pi adapter has an SMSC LAN95xx,
see /n/sources/contrib/miller/usb/ether/smsc.c for my driver which
reads up to 37*512=18944 bytes at a time.




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 18:01     ` Richard Miller
  2012-09-29 18:19       ` Gorka Guardiola
@ 2012-09-29 18:41       ` erik quanstrom
  2012-09-29 19:49         ` Charles Forsyth
  1 sibling, 1 reply; 16+ messages in thread
From: erik quanstrom @ 2012-09-29 18:41 UTC (permalink / raw)
  To: 9fans, 9fans

On Sat Sep 29 14:02:51 EDT 2012, 9fans@hamnavoe.com wrote:
> > why doesn't the device do the buffering?
>
> By "device" do you mean the hardware usb/ether adapter?  It does some

i ment #u itself.  sorry for being unclear.  actually, echoing
gorka, i think there's going to need to be enough threads/buffering
to decouple the packet pipeline.

it might be that the usb packet shuffler should be in the kernel, and
usbd should poke it from user land.  for a device without more
processing power than a cray 2, this could make a big difference.
i wrote a sd loopback device that turns a file into a sd device;
perhaps the same model would work for ether?  (sdloop is in 9atom.)

- erik



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 18:41       ` erik quanstrom
@ 2012-09-29 19:49         ` Charles Forsyth
  0 siblings, 0 replies; 16+ messages in thread
From: Charles Forsyth @ 2012-09-29 19:49 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 255 bytes --]

>the host adapter driver in the kernel will poll a device for input only
when
>the user-level driver process does a read

I'm fairly sure the original driver could post a batch of polling requests,
for just that reason,
but it was a long time ago.

[-- Attachment #2: Type: text/html, Size: 692 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 18:24         ` Richard Miller
@ 2012-09-29 21:38           ` Gorka Guardiola
  2012-09-29 21:46             ` Richard Miller
  0 siblings, 1 reply; 16+ messages in thread
From: Gorka Guardiola @ 2012-09-29 21:38 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 350 bytes --]

On 29/09/2012, at 23:25, Richard Miller <9fans@hamnavoe.com> wrote:


That's the asix driver: the raspberry pi adapter has an SMSC LAN95xx,
see /n/sources/contrib/miller/usb/ether/smsc.c for my driver which
reads up to 37*512=18944 bytes at a time.


And is it really doing it? I mean it asks for many bytes but how many
does it get?

G.

[-- Attachment #2: Type: text/html, Size: 746 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 21:38           ` Gorka Guardiola
@ 2012-09-29 21:46             ` Richard Miller
  2012-09-29 21:48               ` erik quanstrom
  2012-09-30  9:20               ` Charles Forsyth
  0 siblings, 2 replies; 16+ messages in thread
From: Richard Miller @ 2012-09-29 21:46 UTC (permalink / raw)
  To: 9fans

> And is it really doing it? I mean it asks for many bytes but how many
> does it get?

It often gets about 8k at a time (a complete 9p message).  I'll have
to add a check to see what the maximum is.




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 21:46             ` Richard Miller
@ 2012-09-29 21:48               ` erik quanstrom
  2012-10-01 19:20                 ` Richard Miller
  2012-09-30  9:20               ` Charles Forsyth
  1 sibling, 1 reply; 16+ messages in thread
From: erik quanstrom @ 2012-09-29 21:48 UTC (permalink / raw)
  To: 9fans

On Sat Sep 29 17:47:18 EDT 2012, 9fans@hamnavoe.com wrote:
> > And is it really doing it? I mean it asks for many bytes but how many
> > does it get?
>
> It often gets about 8k at a time (a complete 9p message).  I'll have
> to add a check to see what the maximum is.

of course the 64bit question is, which queue is dropping packets.
there are so many to choose from.

- erik



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 21:46             ` Richard Miller
  2012-09-29 21:48               ` erik quanstrom
@ 2012-09-30  9:20               ` Charles Forsyth
  2012-09-30 10:24                 ` Richard Miller
  1 sibling, 1 reply; 16+ messages in thread
From: Charles Forsyth @ 2012-09-30  9:20 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

the qopen sets the queue limit to 8k, which seems a little low, unless it's
reset later.
the later unchecked qpass (with comment) will toss the data away, which is
a little drastic.

On 29 September 2012 22:46, Richard Miller <9fans@hamnavoe.com> wrote:

> It often gets about 8k at a time (a complete 9p message).  I'll have
> to add a check to see what the maximum is.
>

[-- Attachment #2: Type: text/html, Size: 660 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-30  9:20               ` Charles Forsyth
@ 2012-09-30 10:24                 ` Richard Miller
  2012-09-30 13:54                   ` Charles Forsyth
  0 siblings, 1 reply; 16+ messages in thread
From: Richard Miller @ 2012-09-30 10:24 UTC (permalink / raw)
  To: 9fans

> the qopen sets the queue limit to 8k

Which qopen are you referring to?




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-30 10:24                 ` Richard Miller
@ 2012-09-30 13:54                   ` Charles Forsyth
  0 siblings, 0 replies; 16+ messages in thread
From: Charles Forsyth @ 2012-09-30 13:54 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 141 bytes --]

the wrong one. never mind.

On 30 September 2012 11:24, Richard Miller <9fans@hamnavoe.com> wrote:

> Which qopen are you referring to?

[-- Attachment #2: Type: text/html, Size: 380 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 16:16 [9fans] usbether Richard Miller
  2012-09-29 16:39 ` Gorka Guardiola
@ 2012-09-30 23:29 ` Tristan
  1 sibling, 0 replies; 16+ messages in thread
From: Tristan @ 2012-09-30 23:29 UTC (permalink / raw)
  To: 9fans

> After running out of 9pi-specific things to debug, it occurred to me
> to try a usb ethernet dongle on an x86 plan 9 machine.  There I
> observed the same thing: so many dropped packets that the connection
> is unusable.

> So, has anyone had success using usbether to connect a plan 9 system
> to the outside world?  I am hoping someone can give me an encouraging
> report.

Not usb/ether, but my usb/wifi (which is very much based on it) written
for the Libertas (in OLPC) wireless worked a lot better than the any of
my usb ethernet dongles. I never have gotten around to figuring out why.

Good luck!
Tristan

-- 
All original matter is hereby placed immediately under the public domain.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] usbether
  2012-09-29 21:48               ` erik quanstrom
@ 2012-10-01 19:20                 ` Richard Miller
  0 siblings, 0 replies; 16+ messages in thread
From: Richard Miller @ 2012-10-01 19:20 UTC (permalink / raw)
  To: 9fans

> of course the 64bit question is, which queue is dropping packets.
> there are so many to choose from.

Looks my initial guess was wrong.  I added some readahead to the kernel
usb driver and that didn't help at all.  Then I reduced the device's
buffering ("burst factor"), and increased the intermediate buffering
between input and output processes in the generic part of the usb/ether
driver.  That seems to have done the trick: no more dropped packets.

That's with the raspberry pi built-in usb ether.  My asix-based ethernet
dongle doesn't work any better on an x86 host; but at least it doesn't
work any worse.  Geoff has pushed the new usb/ether code onto sources.
Anybody who is actually using usb/ether - could you try the new version
and let us know if we've broken yours?




^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-10-01 19:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-29 16:16 [9fans] usbether Richard Miller
2012-09-29 16:39 ` Gorka Guardiola
2012-09-29 17:03   ` erik quanstrom
2012-09-29 18:01     ` Richard Miller
2012-09-29 18:19       ` Gorka Guardiola
2012-09-29 18:24         ` Richard Miller
2012-09-29 21:38           ` Gorka Guardiola
2012-09-29 21:46             ` Richard Miller
2012-09-29 21:48               ` erik quanstrom
2012-10-01 19:20                 ` Richard Miller
2012-09-30  9:20               ` Charles Forsyth
2012-09-30 10:24                 ` Richard Miller
2012-09-30 13:54                   ` Charles Forsyth
2012-09-29 18:41       ` erik quanstrom
2012-09-29 19:49         ` Charles Forsyth
2012-09-30 23:29 ` Tristan

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).