Skip to contentSkip to conversation

staging: Add firewire-serial driver

PATCH In review Peter Hurley 4 participants 20 messages Oct 18, 2012 – Nov 28, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover staging: Add firewire-serial driver

Please consider this serial driver for review for submission to staging. The firewire-serial driver implements TTY over IEEE 1394. In its default configuration, it creates 4 TTY devices and one loopback device per firewire card (respectively, named fwtty<n>~fwtty<n+3> and fwloop<n>).

Currently, the TTY devices auto-connect to every cabled peer (the TODO list includes plans for providing a sysfs interface to control virtual cabling with whitelist/blacklist support per GUID).

Efforts are still ongoing for a companion console driver, with plans to eventually add early_printk & kgdb support (via additional drivers).

Some issues did arise with both the TTY and Firewire subsystems which are noted in the TODO file. Please review these workarounds.

Peter Hurley (1):
staging: fwserial: Add TTY-over-Firewire serial driver

 drivers/staging/Kconfig             |    2 +
 drivers/staging/Makefile            |    1 +
 drivers/staging/fwserial/Kconfig    |    9 +
 drivers/staging/fwserial/Makefile   |    2 +
 drivers/staging/fwserial/TODO       |   89 ++
 drivers/staging/fwserial/dma_fifo.c |  310 ++++
 drivers/staging/fwserial/dma_fifo.h |  130 ++
 drivers/staging/fwserial/fwserial.c | 2885 +++++++++++++++++++++++++++++++++++
 drivers/staging/fwserial/fwserial.h |  355 +++++
 9 files changed, 3783 insertions(+)
 create mode 100644 drivers/staging/fwserial/Kconfig
 create mode 100644 drivers/staging/fwserial/Makefile
 create mode 100644 drivers/staging/fwserial/TODO
 create mode 100644 drivers/staging/fwserial/dma_fifo.c
 create mode 100644 drivers/staging/fwserial/dma_fifo.h
 create mode 100644 drivers/staging/fwserial/fwserial.c
 create mode 100644 drivers/staging/fwserial/fwserial.h
Signature · 1 line
1.7.12.3
#1 lore raw
Quoted 9 lines · Peter Hurley

Please consider this serial driver for review for submission to staging. The firewire-serial driver implements TTY over IEEE 1394. In its default configuration, it creates 4 TTY devices and one loopback device per firewire card (respectively, named fwtty<n>~fwtty<n+3> and fwloop<n>).

Currently, the TTY devices auto-connect to every cabled peer (the TODO list includes plans for providing a sysfs interface to control virtual cabling with whitelist/blacklist support per GUID).

Quoted 8 lines

Efforts are still ongoing for a companion console driver, with plans to eventually add early_printk & kgdb support (via additional drivers).

Some issues did arise with both the TTY and Firewire subsystems which are noted in the TODO file. Please review these workarounds.

Peter Hurley (1):
staging: fwserial: Add TTY-over-Firewire serial driver

I'd like to get an Ack from Stefan here, before I'll add this to the staging tree.

thanks,

greg k-h

#2 lore raw
Quoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · Peter Hurley

Please consider this serial driver for review for submission to staging. The firewire-serial driver implements TTY over IEEE 1394. In its default configuration, it creates 4 TTY devices and one loopback device per firewire card (respectively, named fwtty<n>~fwtty<n+3> and fwloop<n>).

Currently, the TTY devices auto-connect to every cabled peer (the TODO list includes plans for providing a sysfs interface to control virtual cabling with whitelist/blacklist support per GUID).

Efforts are still ongoing for a companion console driver, with plans to eventually add early_printk & kgdb support (via additional drivers).

Quoted 8 lines
Quoted 5 lines

Some issues did arise with both the TTY and Firewire subsystems which are noted in the TODO file. Please review these workarounds.

Peter Hurley (1):
staging: fwserial: Add TTY-over-Firewire serial driver

I'd like to get an Ack from Stefan here, before I'll add this to the staging tree.

Of course.

Jiri's newest series ("TTY buffer in tty_port and other stuff") does break this driver, so I'll need to resubmit to address those changes. Two of the workarounds mentioned in the TODO are related to the tty_buffer interface; specifically,

1. The ldisc drops the contents of tty_buffer on hangup (rather than waiting for completion). Maybe for other devices this isn't so noticeable because the ldisc can mostly keep up with the device, but on firewire the ldisc lags well behind. Right now, this driver works around this by holding off the hangup until the ldisc empties the tty_buffer. The driver determines how much data is still left in the tty_buffer by walking the flip buffers.

2. Because this driver can fill the entire tty_buffer (64K +) before the ldisc even runs once, this driver has to self-throttle when feeding the tty_buffer. So as not to drop data, the driver has to know when a watermark is reached in the tty_buffer, to ensure that in-flight + already-accepted data can safely be moved to what remains avail in the tty_buffer. (The tty_buffer maxs at 64K). Currently, the avail level in the tty_buffer is computed by this driver (in the same manner as tty_buffer_alloc()).

Eventually, I'd like to move these changes into tty_buffer but I wanted to present the use case first.

Regards,
Peter Hurley

#3 lore raw
Quoted 30 lines · Peter Hurley
Quoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · Peter Hurley

Please consider this serial driver for review for submission to staging. The firewire-serial driver implements TTY over IEEE 1394. In its default configuration, it creates 4 TTY devices and one loopback device per firewire card (respectively, named fwtty<n>~fwtty<n+3> and fwloop<n>).

Currently, the TTY devices auto-connect to every cabled peer (the TODO list includes plans for providing a sysfs interface to control virtual cabling with whitelist/blacklist support per GUID).

Efforts are still ongoing for a companion console driver, with plans to eventually add early_printk & kgdb support (via additional drivers).

Quoted 8 lines
Quoted 5 lines

Some issues did arise with both the TTY and Firewire subsystems which are noted in the TODO file. Please review these workarounds.

Peter Hurley (1):
staging: fwserial: Add TTY-over-Firewire serial driver

I'd like to get an Ack from Stefan here, before I'll add this to the staging tree.

Of course.

Jiri's newest series ("TTY buffer in tty_port and other stuff") does break this driver, so I'll need to resubmit to address those changes. Two of the workarounds mentioned in the TODO are related to the tty_buffer interface; specifically,

Quoted 7 lines

1. The ldisc drops the contents of tty_buffer on hangup (rather than waiting for completion). Maybe for other devices this isn't so noticeable because the ldisc can mostly keep up with the device, but on firewire the ldisc lags well behind. Right now, this driver works around this by holding off the hangup until the ldisc empties the tty_buffer. The driver determines how much data is still left in the tty_buffer by walking the flip buffers.

That's not good. Surely other drivers must see this, as we handle tty over ethernet, that should be just as fast as firewire, right? What do those drivers do to handle this issue?

Quoted 8 lines

2. Because this driver can fill the entire tty_buffer (64K +) before the ldisc even runs once, this driver has to self-throttle when feeding the tty_buffer. So as not to drop data, the driver has to know when a watermark is reached in the tty_buffer, to ensure that in-flight + already-accepted data can safely be moved to what remains avail in the tty_buffer. (The tty_buffer maxs at 64K). Currently, the avail level in the tty_buffer is computed by this driver (in the same manner as tty_buffer_alloc()).

I suggest bringing this up on the linux-serial@vger mailing list, Alan and Jiri should be able to help you out.

thanks,

greg k-h

#4 lore raw
In reply to Peter Hurley
Quoted 7 lines

1. The ldisc drops the contents of tty_buffer on hangup (rather than waiting for completion). Maybe for other devices this isn't so noticeable because the ldisc can mostly keep up with the device, but on firewire the ldisc lags well behind. Right now, this driver works around this by holding off the hangup until the ldisc empties the tty_buffer. The driver determines how much data is still left in the tty_buffer by walking the flip buffers.

The driver should not be trying to look at this, so it's good that it broke now. If you need it to process the data on then hangup then the core code wants fixing to allow this to occur.

Quoted 3 lines

2. Because this driver can fill the entire tty_buffer (64K +) before the ldisc even runs once, this driver has to self-throttle when feeding the tty_buffer.

That wants investigating properly. We do multiple megabits quite happily via the tty layer with 3G modems over USB. What is your data rate ?

Again it wants dealing with properly.

Alan

#5 lore raw

[cc'ing linux-serial]

Quoted 11 lines · Alan Cox
Quoted 7 lines

1. The ldisc drops the contents of tty_buffer on hangup (rather than waiting for completion). Maybe for other devices this isn't so noticeable because the ldisc can mostly keep up with the device, but on firewire the ldisc lags well behind. Right now, this driver works around this by holding off the hangup until the ldisc empties the tty_buffer. The driver determines how much data is still left in the tty_buffer by walking the flip buffers.

The driver should not be trying to look at this, so it's good that it broke now. If you need it to process the data on then hangup then the core code wants fixing to allow this to occur.

Sorry. I assumed not waiting for ldisc completion on hangup was architectural.

tty_ldisc_hangup() has this comment from '09:

	/*
	 * FIXME: Once we trust the LDISC code better we can wait here for
	 * ldisc completion and fix the driver call race
	 */

and then several lines below specifically stops emptying the tty_buffer:

	cancel_work_sync(&tty->buf.work);

But even earlier in tty_ldisc_hangup(), the ldisc has been flushed (which the n_tty ldisc interprets as a reset).

Quoted 6 lines
Quoted 3 lines

2. Because this driver can fill the entire tty_buffer (64K +) before the ldisc even runs once, this driver has to self-throttle when feeding the tty_buffer.

That wants investigating properly. We do multiple megabits quite happily via the tty layer with 3G modems over USB. What is your data rate ?

The _slowest_ Firewire does 125 Mbits/sec using only the portion of the bus cycle assigned for async tx (which is what this driver uses). That's 2Kbytes every 125us. Real world can be pretty close to that because Firewire uses autonomous DMA and most controllers allow spillover into the portion of bus cycle assigned for sync tx (which is another 4Kbytes per 125us). (Technical note: the actual total max for combined async and sync tx is 6144 bytes per 125us clock)

2Kbytes/125us = 16Kbytes/1ms = 160Kbytes/jiffy (for CONFIG_HZ_100)

Some retail Firewire controllers do twice that, controllers in early-production do 4x that, and reportedly at least one prototype does 8x that (although I haven't seen it or tested it).

'cat /dev/fwtty0' using this driver gets considerably less that, but still enough to find this race.

Ignoring for a moment the data rates, the throttling logic is racy because the ldisc sends the throttle from non-atomic context (so that termios can be locked and accessed) but the driver fills the tty_buffer from atomic context. In other words, the condition for which the ldisc will send a throttle (receive_room < TTY_THRESHOLD_THROTTLE) hasn't yet happened, but it will the next time receive_buf() runs.

So, the best that tty_insert_flip_string_* can do is return an error that tty_buffer_alloc() refuses to allocate more than 64k. But the problem is this driver has data that __must__ go somewhere at that particular point in time. This driver could introduce another layer of buffering in front of this but that would defeat the purpose of even having tty_buffer in the first place.

Checking how much space might be avail for future rx and throttling if too low seems like the natural solution here. Of course, directly peeking at tty_buffer is the wrong way to go about doing it. But what if that was properly exposed by tty_buffer, such as (adjusted for Jiri's recent changes):

int tty_buffer_space_avail(struct tty_struct *tty)

{
	struct tty_port *port = tty->port;
	struct tty_bufhead *buf = &port->buf;
	unsigned long flags;
	int avail;

	spin_lock_irqsave(&buf->lock, flags);
	avail = 65536 - buf.memory_used;  /* threshold used by tty_buffer_alloc() */
	spin_unlock_irqrestore(&buf->lock, flags);
	return avail;
}

Regards,
Peter Hurley

#6 lore raw
Quoted 3 lines · On Oct 23 Peter Hurley wrote:

most controllers allow spillover into
the portion of bus cycle assigned for sync tx (which is another 4Kbytes per 125us).

All controllers do so and are expected to do so. Asynchronous traffic is not supposed to depend on a cycle master being active.

Quoted 2 lines

(Technical note: the actual total max for combined async and sync tx is 6144 bytes per 125us clock)

It depends on bus topology, transaction types, and more. For a single-hop S400 1394a bus (vulgo FireWire 400) I once calculated 44 MB/s bandwidth of asynchronous unified write transactions:
http://marc.info/?l=linux1394-devel&m=109128028930225
That's at the physical layer; link layer and application layer performances are less than that of course.

Signature · 9 lines
Stefan Richter
-=====-===-- =-=- =-===
http://arcgraph.de/sr/

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
#7 lore raw
In reply to Greg Kroah-Hartman
Quoted 13 lines · On Oct 22 Greg Kroah-Hartman wrote:
Quoted 12 lines · Peter Hurley

Please consider this serial driver for review for submission to staging. The firewire-serial driver implements TTY over IEEE 1394. In its default configuration, it creates 4 TTY devices and one loopback device per firewire card (respectively, named fwtty<n>~fwtty<n+3> and fwloop<n>).

Currently, the TTY devices auto-connect to every cabled peer (the TODO list includes plans for providing a sysfs interface to control virtual cabling with whitelist/blacklist support per GUID).

Efforts are still ongoing for a companion console driver, with plans to eventually add early_printk & kgdb support (via additional drivers).

Quoted 8 lines
Quoted 5 lines

Some issues did arise with both the TTY and Firewire subsystems which are noted in the TODO file. Please review these workarounds.

Peter Hurley (1):
staging: fwserial: Add TTY-over-Firewire serial driver

I'd like to get an Ack from Stefan here, before I'll add this to the staging tree.

I have not formed an opinion yet, and have not taken the time to look over the code yet. Personally, I am entirely unfamiliar with the application domain of tty drivers in general and with the tty-over-"high"speed-bus application domain in particular. IOW, I don't know who is going to use this for which purposes.

On the FireWire side, this driver implements an own transport protocol. AFAIK a standardized serial-over-1394 does not exist. This means that interoperability of this driver will initially be limited to Linux-to-Linux. Devices or other operating systems which implement this do not exist.

Apart from that aspect, the proposed fwserial driver looks to have requirements similar to the existing IPv4-over-1394 and SBP target-mode drivers (drivers/firewire/net.* and drivers/target/sbp/*). This means that
(a) fw-serial motivated changes to the firewire subsystem and (b) firewire subsystem motivated changes to fwserial could quite possibly also be interesting for or required by those other drivers as well, meaning that maintenance overhead should not increase much.

Quoted 4 lines
Quoted 4 lines
 drivers/staging/fwserial/dma_fifo.c |  310 ++++
 drivers/staging/fwserial/dma_fifo.h |  130 ++
 drivers/staging/fwserial/fwserial.c | 2885 +++++++++++++++++++++++++++++++++++
 drivers/staging/fwserial/fwserial.h |  355 +++++

drivers/firewire/net.c is 1721 lines, sbp_target is 2868 lines. Why is fwserial bigger?

Signature · 3 lines
Stefan Richter
-=====-===-- =-=- ==---
http://arcgraph.de/sr/
#8 lore raw
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
 drivers/staging/fwserial/dma_fifo.c |  310 ++++
 drivers/staging/fwserial/dma_fifo.h |  130 ++
 drivers/staging/fwserial/fwserial.c | 2885 +++++++++++++++++++++++++++++++++++
 drivers/staging/fwserial/fwserial.h |  355 +++++

drivers/firewire/net.c is 1721 lines, sbp_target is 2868 lines. Why is fwserial bigger?

1) Exclude the dma_fifo* files in the comparison, because block & net devices get dma-able memory management from their subsystems.
2) Certain tty concepts don't map well to an automated bus, so these are simulated (eg, break handling)
3) fwserial has to implement a protocol to virtually cable peers
4) sbp_target only supports 1 target.

#9 lore raw

v2 cover staging: Add firewire-serial driver

In reply to Peter Hurley

v2 of this driver submission builds and runs cleanly against Greg KH's tty-next and (hopefully) addresses the concerns raised regarding the dependence on tty_buffer internals; specifically with the workarounds to fix
1) data loss on hangup and 2) throttling before the flip buffers are full.

1) Data loss on hangup
Although I experimented with alternative solutions as Alan suggested, none were practical. For example, this sequence (which is almost identical to what the n_tty ldisc does in input_available_p()):

     tty_flush_to_ldisc(tty);
     n = ldisc->ops->chars_in_buffer(tty);

suffers from a race that the ldisc could have _just_ emptied the read buffer between these calls, so that n == 0 but data is still in the flip buffers.

For now, the driver v2 delays the hangup on carrier loss by a fixed timeout.

2) Flip buffers full before throttle received from ldisc Because driver throttling is performed by the ldisc, and not by the tty_buffer, the flip buffers can be filled before receiving a throttle request.

For now, the driver v2 pre-buffers in front of the tty_buffer; ie, rx data which is not accepted by tty_insert_flip_string...() is buffered in the driver, the sender is throttled and when ldisc unthrottles, normal operation resumes by feeding the tty_buffer from the pre-buffered data.

This driver v2 also fixes the occasionally flaky auto-connect, 2 (valid) lockdep warnings, racy line status changes, and delays fifo allocation until .activate() to minimize memory footprint.

As before, the TODO file notes the remaining issues.

Regards,
Peter

Peter Hurley (1):
staging: fwserial: Add TTY-over-Firewire serial driver

 drivers/staging/Kconfig             |    2 +
 drivers/staging/Makefile            |    1 +
 drivers/staging/fwserial/Kconfig    |    9 +
 drivers/staging/fwserial/Makefile   |    2 +
 drivers/staging/fwserial/TODO       |   37 +
 drivers/staging/fwserial/dma_fifo.c |  310 ++++
 drivers/staging/fwserial/dma_fifo.h |  130 ++
 drivers/staging/fwserial/fwserial.c | 2946 +++++++++++++++++++++++++++++++++++
 drivers/staging/fwserial/fwserial.h |  387 +++++
 9 files changed, 3824 insertions(+)
 create mode 100644 drivers/staging/fwserial/Kconfig
 create mode 100644 drivers/staging/fwserial/Makefile
 create mode 100644 drivers/staging/fwserial/TODO
 create mode 100644 drivers/staging/fwserial/dma_fifo.c
 create mode 100644 drivers/staging/fwserial/dma_fifo.h
 create mode 100644 drivers/staging/fwserial/fwserial.c
 create mode 100644 drivers/staging/fwserial/fwserial.h
Signature · 1 line
1.7.12.3
#10 lore raw

PATCH v2 1/1 staging: fwserial: Add TTY-over-Firewire serial driver

This patch provides the kernel driver for high-speed TTY communication over the IEEE 1394 bus.

---
v2
- Removes dependencies on tty_buffer internals
- Handles ldisc data loss on hangup with timer delay
- Buffers rx if flip buffers are full
- Fixes flaky auto-connect
- Moves fifo allocation to .activate - this saves memory on unused ports
- Fixes 2 lockdep warnings on allocations w/ spinlocks held
- Fixes all checkpatch warnings
- Fixes potential line status write order inversion
- Fixes completely bogus attempt at running delayed work (by using new mod_delayed_work())
- Fixes potential deadlock when cancelling peer work
- Respects CLOCAL for carrier state
- Properly resets port state on shutdown

---
 drivers/staging/Kconfig             |    2 +
 drivers/staging/Makefile            |    1 +
 drivers/staging/fwserial/Kconfig    |    9 +
 drivers/staging/fwserial/Makefile   |    2 +
 drivers/staging/fwserial/TODO       |   37 +
 drivers/staging/fwserial/dma_fifo.c |  310 ++++
 drivers/staging/fwserial/dma_fifo.h |  130 ++
 drivers/staging/fwserial/fwserial.c | 2946 +++++++++++++++++++++++++++++++++++
 drivers/staging/fwserial/fwserial.h |  387 +++++
 9 files changed, 3824 insertions(+)
 create mode 100644 drivers/staging/fwserial/Kconfig
 create mode 100644 drivers/staging/fwserial/Makefile
 create mode 100644 drivers/staging/fwserial/TODO
 create mode 100644 drivers/staging/fwserial/dma_fifo.c
 create mode 100644 drivers/staging/fwserial/dma_fifo.h
 create mode 100644 drivers/staging/fwserial/fwserial.c
 create mode 100644 drivers/staging/fwserial/fwserial.h
drivers/staging/Kconfig +2 -0
index d805eef..39696d6 100644
@@ -144,4 +144,6 @@ source "drivers/staging/imx-drm/Kconfig"
 
 source "drivers/staging/dgrp/Kconfig"
 
+source "drivers/staging/fwserial/Kconfig"
+
 endif # STAGING
drivers/staging/Makefile +1 -0
index 76e2ebd..5565d5f 100644
@@ -64,3 +64,4 @@ obj-$(CONFIG_NET_VENDOR_SILICOM)	+= silicom/
 obj-$(CONFIG_CED1401)		+= ced1401/
 obj-$(CONFIG_DRM_IMX)		+= imx-drm/
 obj-$(CONFIG_DGRP)		+= dgrp/
+obj-$(CONFIG_FIREWIRE_SERIAL)	+= fwserial/
drivers/staging/fwserial/Kconfig new file +9 -0
new file mode 100644
index 0000000..580406c
@@ -0,0 +1,9 @@
+config FIREWIRE_SERIAL
+       tristate "TTY over Firewire"
+       depends on FIREWIRE
+       help
+          This enables TTY over IEEE 1394, providing high-speed serial
+	  connectivity to cabled peers.
+
+	  To compile this driver as a module, say M here:  the module will
+	  be called firewire-serial.
drivers/staging/fwserial/Makefile new file +2 -0
new file mode 100644
index 0000000..2170869
@@ -0,0 +1,2 @@
+obj-$(CONFIG_FIREWIRE_SERIAL) += firewire-serial.o
+firewire-serial-objs := fwserial.o dma_fifo.o
drivers/staging/fwserial/TODO new file +37 -0
new file mode 100644
index 0000000..7269005
@@ -0,0 +1,37 @@
+TODOs
+-----
+1. Implement retries for RCODE_BUSY, RCODE_NO_ACK and RCODE_SEND_ERROR
+   - I/O is handled asynchronously which presents some issues when error
+     conditions occur.
+2. Implement _robust_ console on top of this. The existing prototype console
+   driver is not ready for the big leagues yet.
+3. Expose means of controlling attach/detach of peers via sysfs. Include
+   GUID-to-port matching/whitelist/blacklist.
+
+-- Issues with firewire stack --
+1. This driver uses the same unregistered vendor id that the firewire core does
+     (0xd00d1e). Perhaps this could be exposed as a define in
+     firewire-constants.h?
+2. MAX_ASYNC_PAYLOAD needs to be publicly exposed by core/ohci
+   - otherwise how will this driver know the max size of address window to
+     open for one packet write?
+3. Maybe device_max_receive() and link_speed_to_max_payload() should be
+     taken up by the firewire core?
+4. To avoid dropping rx data while still limiting the maximum buffering,
+     the size of the AR context must be known. How to expose this to drivers?
+5. Explore if bigger AR context will reduce RCODE_BUSY responses
+   (or auto-grow to certain max size -- but this would require major surgery
+    as the current AR is contiguously mapped)
+
+-- Issues with TTY core --
+  1. Hack for alternate device name scheme
+     - because udev no longer allows device renaming, devices should have
+       their proper names on creation. This is an issue for creating the
+       fwloop<n> device with the fwtty<n> devices because although duplicating
+       roughly the same operations as tty_port_register_device() isn't difficult,
+       access to the tty_class & tty_fops is restricted in scope.
+
+       This is currently being worked around in create_loop_device() by
+       extracting the tty_class ptr and tty_fops ptr from the previously created
+       tty devices. Perhaps an add'l api can be added -- eg.,
+       tty_{port_}register_named_device().
drivers/staging/fwserial/dma_fifo.c new file +310 -0

310 lines not on this page · raw message

drivers/staging/fwserial/dma_fifo.h new file +130 -0

130 lines not on this page · raw message

drivers/staging/fwserial/fwserial.c new file +2946 -0

2,502 lines not on this page · raw message

drivers/staging/fwserial/fwserial.h new file +387 -0

387 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.12.3

Part of the diff is not shown here. View the raw message.

#11 lore raw

Re: [PATCH v2 1/1] staging: fwserial: Add TTY-over-Firewire serial driver

Quoted 4 lines · On Nov 02 Peter Hurley wrote:

This patch provides the kernel driver for high-speed TTY communication over the IEEE 1394 bus.

Hi Greg,

you asked for an Ack. Here it is: I am OK with this getting added to the staging tree.

(Sorry for the delay, I was ill and at the same time buried in work at the day job.) Note, I only quickly scrolled through v1 and v2. I will do an actual review when somebody asks to move this from staging into a proper mainline place.

Peter,
below are some high-level comments to your TODOs.

Quoted 2 lines

---
v2

[...]

Quoted 18 lines
---
 drivers/staging/Kconfig             |    2 +
 drivers/staging/Makefile            |    1 +
 drivers/staging/fwserial/Kconfig    |    9 +
 drivers/staging/fwserial/Makefile   |    2 +
 drivers/staging/fwserial/TODO       |   37 +
 drivers/staging/fwserial/dma_fifo.c |  310 ++++
 drivers/staging/fwserial/dma_fifo.h |  130 ++
 drivers/staging/fwserial/fwserial.c | 2946 +++++++++++++++++++++++++++++++++++
 drivers/staging/fwserial/fwserial.h |  387 +++++
 9 files changed, 3824 insertions(+)
 create mode 100644 drivers/staging/fwserial/Kconfig
 create mode 100644 drivers/staging/fwserial/Makefile
 create mode 100644 drivers/staging/fwserial/TODO
 create mode 100644 drivers/staging/fwserial/dma_fifo.c
 create mode 100644 drivers/staging/fwserial/dma_fifo.h
 create mode 100644 drivers/staging/fwserial/fwserial.c
 create mode 100644 drivers/staging/fwserial/fwserial.h

[...]

drivers/staging/fwserial/Kconfig line 9

Quoted 12 lines
drivers/staging/fwserial/Kconfig new file +9 -0
@@ -0,0 +1,9 @@
+config FIREWIRE_SERIAL
+       tristate "TTY over Firewire"
+       depends on FIREWIRE
+       help
+          This enables TTY over IEEE 1394, providing high-speed serial
+	  connectivity to cabled peers.
+
+	  To compile this driver as a module, say M here:  the module will
+	  be called firewire-serial.

This should mention that this is a Linux-only affair at this time: It uses an ad-hoc defined protocol which no other platform is known to support for the time being.

[...]

Quoted 7 lines
drivers/staging/fwserial/TODO new file +4 -0
@@ -0,0 +1,37 @@
+TODOs
+-----
+1. Implement retries for RCODE_BUSY, RCODE_NO_ACK and RCODE_SEND_ERROR
+   - I/O is handled asynchronously which presents some issues when error

drivers/staging/fwserial/TODO line 14

Quoted 10 lines
drivers/staging/fwserial/TODO new file +10 -0
+     conditions occur.
+2. Implement _robust_ console on top of this. The existing prototype console
+   driver is not ready for the big leagues yet.
+3. Expose means of controlling attach/detach of peers via sysfs. Include
+   GUID-to-port matching/whitelist/blacklist.
+
+-- Issues with firewire stack --
+1. This driver uses the same unregistered vendor id that the firewire core does
+     (0xd00d1e). Perhaps this could be exposed as a define in
+     firewire-constants.h?

I guess there is no better OUI for this purpose.

The constant could be added to linux/firewire.h, but IMO rather not to uapi/linux/firewire-constants.h. We don't want this definition to leak out to userland; userland can hardwire its own hacks itself. :-)

This trivial move to a header should be deferred until the driver moves out of staging.

drivers/staging/fwserial/TODO line 17

Quoted 3 lines
drivers/staging/fwserial/TODO new file +3 -0
+2. MAX_ASYNC_PAYLOAD needs to be publicly exposed by core/ohci
+   - otherwise how will this driver know the max size of address window to
+     open for one packet write?

Hmm, don't firewire-sbp2 and firewire-net deal with this very problem already on their own? Firewire-sbp2 tells the target what maximum payload the local node is ready to accept, and firewire-net figures out whether it needs to fragment the datagrams in unicast TX depending on the remote node's capabilities.

drivers/staging/fwserial/TODO line 19

Quoted 2 lines
drivers/staging/fwserial/TODO new file +2 -0
+3. Maybe device_max_receive() and link_speed_to_max_payload() should be
+     taken up by the firewire core?

Sounds like an extension of item 2, and is easier resolved after the driver moves out of staging.

drivers/staging/fwserial/TODO line 21

Quoted 2 lines
drivers/staging/fwserial/TODO new file +2 -0
+4. To avoid dropping rx data while still limiting the maximum buffering,
+     the size of the AR context must be known. How to expose this to drivers?

I don't see a requirement to know the local or remote node's size of AR DMA buffer. Rather, keep the traffic throttled such that too frequent ack-busy are avoided. As far as I have learned from firewire-net, just limiting the number or in-flight transactions should work reasonably. Of course, hardware ack-busy retries which the OHCI performs on its own won't be noticed by software but take away from overall bus bandwidth. IOW the optimum queue depth is by a certain margin less than the depth at which software starts to see ack-busy transaction terminations.

Furthermore: In order to avoid dropping data, you don't need to know the buffer size at all. You need to implement proper software retries. I.e. either those which you noted yourself at the top of this TODO file, or you let the userland on top of the TTY handle it if this is possible. (I don't know how the TTY subsystem and TTY based applications work.)

drivers/staging/fwserial/TODO line 24

Quoted 3 lines
drivers/staging/fwserial/TODO new file +3 -0
+5. Explore if bigger AR context will reduce RCODE_BUSY responses
+   (or auto-grow to certain max size -- but this would require major surgery
+    as the current AR is contiguously mapped)

For the particular application "firewire-net", the present AR-Req DMA buffer size has apparently been determined as suitable. Of course if you find a different optimum, that could certainly be changed.

I haven't looked closely, but I suppose your bandwidth requirement concerns AR-Request DMA, not so much AR-Response DMA, right?

Signature · 3 lines
Stefan Richter
-=====-===-- =-== -==--
http://arcgraph.de/sr/
#12 lore raw

Re: [PATCH v2 1/1] staging: fwserial: Add TTY-over-Firewire serial driver

Quoted 10 lines · Stefan Richter
Quoted 4 lines · On Nov 02 Peter Hurley wrote:

This patch provides the kernel driver for high-speed TTY communication over the IEEE 1394 bus.

Hi Greg,

you asked for an Ack. Here it is: I am OK with this getting added to the staging tree.

Thanks, I'll queue it up later this week when I return from my travels.

greg k-h

#13 lore raw

Re: [PATCH v2 1/1] staging: fwserial: Add TTY-over-Firewire serial driver

Quoted 5 lines · Greg Kroah-Hartman
Quoted 4 lines · Stefan Richter
Quoted 3 lines · On Nov 02 Peter Hurley wrote:

This patch provides the kernel driver for high-speed TTY communication over the IEEE 1394 bus.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Hi Greg,

you asked for an Ack. Here it is: I am OK with this getting added to the staging tree.

Thanks, I'll queue it up later this week when I return from my travels.

Thanks, Greg.

Except for your and Alan's earlier concerns, which I think I addressed, I didn't get any other feedback on the TTY side of things. Are you personally reviewing this submission?

Regards,
Peter Hurley

#14 lore raw

Re: [PATCH v2 1/1] staging: fwserial: Add TTY-over-Firewire serial driver

Quoted 13 lines · Peter Hurley
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · Stefan Richter
Quoted 4 lines · On Nov 02 Peter Hurley wrote:

This patch provides the kernel driver for high-speed TTY communication over the IEEE 1394 bus.

Hi Greg,

you asked for an Ack. Here it is: I am OK with this getting added to the staging tree.

Quoted 7 lines
Quoted 1 line

Thanks, I'll queue it up later this week when I return from my travels.

Thanks, Greg.

Except for your and Alan's earlier concerns, which I think I addressed, I didn't get any other feedback on the TTY side of things. Are you personally reviewing this submission?

I will poke at it, odds are it will need some changes as there has been some tty changes in the tty.git tree that might need to also be done here. Give me a bit of time to catch up...

thanks,

greg k-h

#15 lore raw

Re: [PATCH v2 1/1] staging: fwserial: Add TTY-over-Firewire serial driver

In reply to Stefan Richter
Quoted 8 lines · Stefan Richter
Quoted 4 lines · On Nov 02 Peter Hurley wrote:

This patch provides the kernel driver for high-speed TTY communication over the IEEE 1394 bus.

Hi Greg,

Quoted 7 lines

you asked for an Ack. Here it is: I am OK with this getting added to the staging tree.

(Sorry for the delay, I was ill and at the same time buried in work at the day job.) Note, I only quickly scrolled through v1 and v2. I will do an actual review when somebody asks to move this from staging into a proper mainline place.

Hi Stefan,

Thanks very much for looking over this submission. (I hope you're feeling better.)

Quoted 19 lines

Peter,
below are some high-level comments to your TODOs.

drivers/staging/fwserial/Kconfig line 9

Quoted 12 lines
drivers/staging/fwserial/Kconfig new file +9 -0
@@ -0,0 +1,9 @@
+config FIREWIRE_SERIAL
+       tristate "TTY over Firewire"
+       depends on FIREWIRE
+       help
+          This enables TTY over IEEE 1394, providing high-speed serial
+	  connectivity to cabled peers.
+
+	  To compile this driver as a module, say M here:  the module will
+	  be called firewire-serial.

This should mention that this is a Linux-only affair at this time: It uses an ad-hoc defined protocol which no other platform is known to support for the time being.

Good point. I'll make this change.

Quoted 20 lines
Quoted 7 lines
drivers/staging/fwserial/TODO new file +4 -0
@@ -0,0 +1,37 @@
+TODOs
+-----
+1. Implement retries for RCODE_BUSY, RCODE_NO_ACK and RCODE_SEND_ERROR
+   - I/O is handled asynchronously which presents some issues when error

drivers/staging/fwserial/TODO line 14

Quoted 10 lines
drivers/staging/fwserial/TODO new file +10 -0
+     conditions occur.
+2. Implement _robust_ console on top of this. The existing prototype console
+   driver is not ready for the big leagues yet.
+3. Expose means of controlling attach/detach of peers via sysfs. Include
+   GUID-to-port matching/whitelist/blacklist.
+
+-- Issues with firewire stack --
+1. This driver uses the same unregistered vendor id that the firewire core does
+     (0xd00d1e). Perhaps this could be exposed as a define in
+     firewire-constants.h?

I guess there is no better OUI for this purpose.

Quoted 6 lines

The constant could be added to linux/firewire.h, but IMO rather not to uapi/linux/firewire-constants.h. We don't want this definition to leak out to userland; userland can hardwire its own hacks itself. :-)

This trivial move to a header should be deferred until the driver moves out of staging.

You're right. I'll update the TODO.

And I should have noted in the TODO file itself that the issues noted are for moving the driver out of staging.

Quoted 9 lines

drivers/staging/fwserial/TODO line 17

Quoted 3 lines
drivers/staging/fwserial/TODO new file +3 -0
+2. MAX_ASYNC_PAYLOAD needs to be publicly exposed by core/ohci
+   - otherwise how will this driver know the max size of address window to
+     open for one packet write?

Hmm, don't firewire-sbp2 and firewire-net deal with this very problem already on their own? Firewire-sbp2 tells the target what maximum payload the local node is ready to accept, and firewire-net figures out whether it needs to fragment the datagrams in unicast TX depending on the remote node's capabilities.

I wasn't as clear as I should have been here. This is only about how big to make the address handler window. Just like firewire-net, this driver communicates with remotes at S100 speeds (and packet sizes) to query the largest packet size that the remote supports.

Currently, firewire-net sets an arbitrary address handler length of 4096. This works because the largest AR packet size the current firewire-ohci driver handles is 4096 (value of MAX_ASYNC_PAYLOAD) + header/trailer. Note that firewire-ohci does not limit card->max_receive to this value.

So if the ohci driver changes to handle 8K+ AR packets and the hardware supports it, these address handler windows will be too small.

Quoted 5 lines

drivers/staging/fwserial/TODO line 19

Quoted 2 lines
drivers/staging/fwserial/TODO new file +2 -0
+3. Maybe device_max_receive() and link_speed_to_max_payload() should be
+     taken up by the firewire core?

Sounds like an extension of item 2, and is easier resolved after the driver moves out of staging.

Ok.

Quoted 12 lines

drivers/staging/fwserial/TODO line 21

Quoted 2 lines
drivers/staging/fwserial/TODO new file +2 -0
+4. To avoid dropping rx data while still limiting the maximum buffering,
+     the size of the AR context must be known. How to expose this to drivers?

I don't see a requirement to know the local or remote node's size of AR DMA buffer. Rather, keep the traffic throttled such that too frequent ack-busy are avoided. As far as I have learned from firewire-net, just limiting the number or in-flight transactions should work reasonably. Of course, hardware ack-busy retries which the OHCI performs on its own won't be noticed by software but take away from overall bus bandwidth. IOW the optimum queue depth is by a certain margin less than the depth at which software starts to see ack-busy transaction terminations.

Quoted 5 lines

Furthermore: In order to avoid dropping data, you don't need to know the buffer size at all. You need to implement proper software retries. I.e. either those which you noted yourself at the top of this TODO file, or you let the userland on top of the TTY handle it if this is possible. (I don't know how the TTY subsystem and TTY based applications work.)

I do need to implement retries but that will be of limited benefit to this particular problem.

Data is written from the remote as a posted write into the AR buffer. The remote receives hardware ack and continues writing more. Meanwhile, the local node schedules the AR tasklet. The AR tasklet runs, dispatching the packets to each appropriate handler. So, by the time this driver's handler is delivered the first packet, many packets could already have been acked and sitting in the AR buffer. At this point, throttling the remote will only prevent the remote from sending even more, and can't help with the data which has already been received.

The driver already limits the max in-flight transactions to 8. But since they're unified transactions, that doesn't do much. Under heavy loads, there may be many (small) completed packets in the AR buffer (NB: the driver already does write aggregation but this isn't appropriate in the console driver).

Besides the inefficiency of re-sending data that has already been received, retrying may not be possible. Consider when a console driver (work-in-progress) writes to the remote using the same interface. It could be one of the last things the remote does. And the most crucial information is that last write.

Despite my lengthy description, I agree that knowing the size of the AR context is not a requirement, and we can drop this as an issue. As you suggest, I can determine the appropriate buffer size experimentally (and implement retries).

Quoted 10 lines

drivers/staging/fwserial/TODO line 24

Quoted 3 lines
drivers/staging/fwserial/TODO new file +3 -0
+5. Explore if bigger AR context will reduce RCODE_BUSY responses
+   (or auto-grow to certain max size -- but this would require major surgery
+    as the current AR is contiguously mapped)

For the particular application "firewire-net", the present AR-Req DMA buffer size has apparently been determined as suitable. Of course if you find a different optimum, that could certainly be changed.

I haven't looked closely, but I suppose your bandwidth requirement concerns AR-Request DMA, not so much AR-Response DMA, right?

Exactly. And I was just thinking to myself there which unfortunately slipped into a public document :)

Thanks again for your time, Stefan.

Regards,
Peter Hurley

#16 lore raw

Re: [PATCH v2 1/1] staging: fwserial: Add TTY-over-Firewire serial driver

Quoted 6 lines · On Nov 13 Peter Hurley wrote:
Quoted 5 lines · Stefan Richter
Quoted 3 lines · On Nov 02 Peter Hurley wrote:

+2. MAX_ASYNC_PAYLOAD needs to be publicly exposed by core/ohci

drivers/staging/fwserial/TODO new file +2 -0
+   - otherwise how will this driver know the max size of address window to
+     open for one packet write?
Quoted 8 lines
Quoted 5 lines

Hmm, don't firewire-sbp2 and firewire-net deal with this very problem already on their own? Firewire-sbp2 tells the target what maximum payload the local node is ready to accept, and firewire-net figures out whether it needs to fragment the datagrams in unicast TX depending on the remote node's capabilities.

I wasn't as clear as I should have been here. This is only about how big to make the address handler window.

Isn't fw_card.max_receive what you were looking for? But since the current firewire-core API requires you to allocate one handler address and size for all cards --- even for cards which will be hot-added later while your driver is already running ---, you should surely just allocate 4096 bytes; see below.

Quoted 3 lines

Just like firewire-net, this driver
communicates with remotes at S100 speeds (and packet sizes) to query the largest packet size that the remote supports.

(RFC 2734 additionally keeps things sane for itself by requiring all 2734 compliant nodes to support at least max packet = 512 bytes.)

Could it be easier to take this information from fw_device.max_speed and the max_rec in fw_device.config_rom? RFC 2734 was designed to work without a local node management layer which is capable to gather such information, but we have this information on Linux (at the time when core_device.c finished its node discovery).

Quoted 8 lines

Currently, firewire-net sets an arbitrary address handler length of 4096. This works because the largest AR packet size the current firewire-ohci driver handles is 4096 (value of MAX_ASYNC_PAYLOAD) + header/trailer. Note that firewire-ohci does not limit card->max_receive to this value.

So if the ohci driver changes to handle 8K+ AR packets and the hardware supports it, these address handler windows will be too small.

While the IEEE 1394:2008 link layer specification (section 6) provides for asynchronous packet payloads of up to 16384 bytes (table 6-4), the IEEE 1394 beta mode port specification (section 13) only allows up to 4096 bytes (table 16-18). And alpha mode is of course limited to 2048 bytes.

So, asynchronous packet payloads greater than 4096 bytes are out of scope of the current revision of IEEE 1394.

Quoted 14 lines
Quoted 5 lines
Quoted 2 lines

+3. Maybe device_max_receive() and link_speed_to_max_payload() should be
+ taken up by the firewire core?

Sounds like an extension of item 2, and is easier resolved after the driver moves out of staging.

Ok.

Quoted 6 lines
Quoted 2 lines

+4. To avoid dropping rx data while still limiting the maximum buffering,
+ the size of the AR context must be known. How to expose this to drivers?

I don't see a requirement to know the local or remote node's size of AR DMA buffer. Rather, keep the traffic throttled such that too frequent ack-busy are avoided.

[...]

Quoted 4 lines

I do need to implement retries but that will be of limited benefit to this particular problem.

Data is written from the remote as a posted write into the AR buffer.

[...]

Oh, I forgot about posted writes. However, you only lose data with posted writes if the OHCI somehow fails to access the host bus. Merely getting to the end of the DMA program before all of the PCI posting FIFO could be emptied is not a reason to drop data. See OHCI-1394 section 3.3 which speaks about the possibility to drop selfID/ IR/ AR-resp data if out of buffer, but not AR-req data.

Well, maybe there are bad OHCI implementations which drop posted AR-req data...? I don't know.

firewire-net uses posted writes too. But with IP-over-1394, delivery guarantee is handled further above if needed, not by the 1394 encapsulation. firewire-sbp2 also uses posted writes, in two ways: With physical DMA to SCSI READ command data buffers, and for the SBP status FIFO. But physical DMA does not have a backing DMA program, and data loss during a status FIFO write would likely be covered by a SCSI transaction retry.

[...]

Quoted 5 lines

Besides the inefficiency of re-sending data that has already been received, retrying may not be possible. Consider when a console driver (work-in-progress) writes to the remote using the same interface. It could be one of the last things the remote does. And the most crucial information is that last write.

As mentioned, I have no idea how TTY works or is supposed to work. But even if the sending application is allowed to quit before its last outbound datagram was delivered, fwserial could still be made to deliver this last datagram at its own pace, with as many software retries as prudent.

Signature · 3 lines
Stefan Richter
-=====-===-- =-== -===-
http://arcgraph.de/sr/
#17 lore raw

Re: [PATCH v2 1/1] staging: fwserial: Add TTY-over-Firewire serial driver

Quoted 13 lines · Stefan Richter
Quoted 12 lines · On Nov 13 Peter Hurley wrote:
Quoted 10 lines · Stefan Richter

drivers/staging/fwserial/TODO line 17

Quoted 3 lines · On Nov 02 Peter Hurley wrote:

+2. MAX_ASYNC_PAYLOAD needs to be publicly exposed by core/ohci

drivers/staging/fwserial/TODO new file +2 -0
+   - otherwise how will this driver know the max size of address window to
+     open for one packet write?

Hmm, don't firewire-sbp2 and firewire-net deal with this very problem already on their own? Firewire-sbp2 tells the target what maximum payload the local node is ready to accept, and firewire-net figures out whether it needs to fragment the datagrams in unicast TX depending on the remote node's capabilities.

Quoted 4 lines
Quoted 2 lines

I wasn't as clear as I should have been here. This is only about how big to make the address handler window.

Isn't fw_card.max_receive what you were looking for?

Yes, you're right, this is what I should do.

Quoted 5 lines

But since the
current firewire-core API requires you to allocate one handler address and size for all cards --- even for cards which will be hot-added later while your driver is already running ---, you should surely just allocate 4096 bytes; see below.

This driver uses a 2-stage negotiation scheme.

A small address window is allocated for all cards in the unit address space. This address window is known to all peers because it is advertised in the unit device config rom for all cards. The associated handler handles requests for attach/detach from peers.

Then, when a local node is probed, the larger status+fifo address windows are allocated (one address window for each tty port). Thus each attached peer will get a dedicated address window.

The peer learns which status+fifo window it has been assigned (corresponding to a particular tty port) while negotiating the attach.

Currently, the larger windows are allocated before knowledge of which peer (or indeed any peer) might attempt to attach.

I will need to delay this allocation until during the attach negotiation.

But if it's ok with you, maybe I can put this off for right now and just note it in the TODO?

Quoted 4 lines
Quoted 3 lines

Just like firewire-net, this driver
communicates with remotes at S100 speeds (and packet sizes) to query the largest packet size that the remote supports.

Quoted 8 lines

(RFC 2734 additionally keeps things sane for itself by requiring all 2734 compliant nodes to support at least max packet = 512 bytes.)

Could it be easier to take this information from fw_device.max_speed and the max_rec in fw_device.config_rom? RFC 2734 was designed to work without a local node management layer which is capable to gather such information, but we have this information on Linux (at the time when core_device.c finished its node discovery).

I see your point and I hadn't considered that. That said, the attach/detach negiotiation doesn't need optimizing, so I'm comfortable leaving this as is.

Quoted 9 lines
Quoted 8 lines

Currently, firewire-net sets an arbitrary address handler length of 4096. This works because the largest AR packet size the current firewire-ohci driver handles is 4096 (value of MAX_ASYNC_PAYLOAD) + header/trailer. Note that firewire-ohci does not limit card->max_receive to this value.

So if the ohci driver changes to handle 8K+ AR packets and the hardware supports it, these address handler windows will be too small.

Quoted 7 lines

While the IEEE 1394:2008 link layer specification (section 6) provides for asynchronous packet payloads of up to 16384 bytes (table 6-4), the IEEE 1394 beta mode port specification (section 13) only allows up to 4096 bytes (table 16-18). And alpha mode is of course limited to 2048 bytes.

So, asynchronous packet payloads greater than 4096 bytes are out of scope of the current revision of IEEE 1394.

You should look at this 1394ta.org video
http://www.youtube.com/watch?v=xVXNvXHNQTY of DAP Technologies S1600 OHCI controllers running S1600 cameras using beta cables. (I apologize for the youtube link but that's where they hosted it :\)

Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

+4. To avoid dropping rx data while still limiting the maximum buffering,
+ the size of the AR context must be known. How to expose this to drivers?

I don't see a requirement to know the local or remote node's size of AR DMA buffer. Rather, keep the traffic throttled such that too frequent ack-busy are avoided.

[...]

Quoted 4 lines

I do need to implement retries but that will be of limited benefit to this particular problem.

Data is written from the remote as a posted write into the AR buffer.

[...]

Oh, I forgot about posted writes. However, you only lose data with posted writes if the OHCI somehow fails to access the host bus. Merely getting to the end of the DMA program before all of the PCI posting FIFO could be emptied is not a reason to drop data. See OHCI-1394 section 3.3 which speaks about the possibility to drop selfID/ IR/ AR-resp data if out of buffer, but not AR-req data.

Quoted 2 lines

Well, maybe there are bad OHCI implementations which drop posted AR-req data...? I don't know.

When I refer to dropping rx data here, I mean this sequence for receiving a posted write:

handle_ar_packet
fw_core_handle_request
handle_exclusive_region_request
handler->address_callback() => fwtty_port_handler(WRITE_BLOCK_REQUEST)
** tty buffer space is full so can't copy the data out of AR buffer **

That data will be dropped and need to be retransmitted. But see below.

Quoted 7 lines

firewire-net uses posted writes too. But with IP-over-1394, delivery guarantee is handled further above if needed, not by the 1394 encapsulation. firewire-sbp2 also uses posted writes, in two ways: With physical DMA to SCSI READ command data buffers, and for the SBP status FIFO. But physical DMA does not have a backing DMA program, and data loss during a status FIFO write would likely be covered by a SCSI transaction retry.

see below.

Quoted 7 lines

[...]

Quoted 5 lines

Besides the inefficiency of re-sending data that has already been received, retrying may not be possible. Consider when a console driver (work-in-progress) writes to the remote using the same interface. It could be one of the last things the remote does. And the most crucial information is that last write.

Quoted 5 lines

As mentioned, I have no idea how TTY works or is supposed to work. But even if the sending application is allowed to quit before its last outbound datagram was delivered, fwserial could still be made to deliver this last datagram at its own pace, with as many software retries as prudent.

Among the many uses for fast tty is to receive the output from a remote console driver (where printk's go). The last printk coming from the remote will be the most important as it may contain a vital clue as to why the remote host died. (Note: most console drivers will busy-wait the current cpu until the transmission completes or it times out).

That's why I'd like to only be forced to software retry if absolutely necessary. To my mind, software retrying is partly avoidable if the receiver can ensure enough tty buffer space is available at any given time. To provide this guarantee, this driver reserves a buffer as large as the AR-req buffer (initially I had wanted to simply use a watermark within the existing tty buffers but that idea was a non-starter). This way the receiver can throttle the remote but still receive all the data the remote may already have sent that is already in the AR-req buffer.

Does that make sense?

Regards,
Peter Hurley

#18 lore raw

Re: [PATCH v2 1/1] staging: fwserial: Add TTY-over-Firewire serial driver

Quoted 14 lines · On Nov 27 Peter Hurley wrote:
Quoted 14 lines
Quoted 8 lines

Currently, firewire-net sets an arbitrary address handler length of 4096. This works because the largest AR packet size the current firewire-ohci driver handles is 4096 (value of MAX_ASYNC_PAYLOAD) + header/trailer. Note that firewire-ohci does not limit card->max_receive to this value.

So if the ohci driver changes to handle 8K+ AR packets and the hardware supports it, these address handler windows will be too small.

While the IEEE 1394:2008 link layer specification (section 6) provides for asynchronous packet payloads of up to 16384 bytes (table 6-4), the IEEE 1394 beta mode port specification (section 13) only allows up to 4096 bytes (table 16-18). And alpha mode is of course limited to 2048 bytes.

Quoted 6 lines
Quoted 2 lines

So, asynchronous packet payloads greater than 4096 bytes are out of scope of the current revision of IEEE 1394.

You should look at this 1394ta.org video
http://www.youtube.com/watch?v=xVXNvXHNQTY of DAP Technologies S1600 OHCI controllers running S1600 cameras using beta cables.

I don't know the details of their implementation, but I suppose they conform with the 1394 beta mode port specification. Which in turn means that their S1600 solution (and by extrapolation, their S3200 prototypes) comply with a maximum asynchronous packet payload of 4096 bytes. Citing IEEE 1394-2008:

Quoted 1 line
Quoted 1 line
Quoted 1 line

Table 16-18———Maximum payload size for Beta data packets

 Data rate | Maximum asynchronous payload size | Maximum isochronous payload
           |              (bytes)              |           (bytes)
 ----------+-----------------------------------+----------------------------
    S100   |                 512               |             1024
    S200   |                1024               |             2048
    S400   |                2048               |             4096
    S800   |                4096               |             8192
    S1600  |                4096               |            16384
    S3200  |                4096               |            32768

<<<

(Alpha mode payload limits are the same as the S100...S400 subset of beta mode. In IEEE 1394b-2002, the table number is 16-3.)

You can of course define registers (or better termed: buffers) which are larger than what can be atomically read or written, or atomically compared-swapped; IOW which are larger than what can be accessed in a single transaction, if such registers or buffers are useful. But if you particularly need a register which is just large enough to accommodate the largest possible inbound block write transaction which complies with IEEE 1394, and you don't know the peer's capability and the speeds of all intermediary cable hops, then fw_card.max_receive is the number that you need. Or you ignore the cards actual capability and just allocate 4096 bytes.

OHCIs that you can buy offer fw_card.max_receive of 1024, or 2048, or 4096 bytes. 1024 bytes is the limit of many but not all 1394a S400 CardBus cards.

[Issues of transaction retries and possible loss at session termination to be left to another reply at another time.]

Signature · 7 lines
Stefan Richter
-=====-===-- =-== ==-==
http://arcgraph.de/sr/
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel
#19 lore raw

Re: [PATCH v2 1/1] staging: fwserial: Add TTY-over-Firewire serial driver

Quoted 43 lines · Stefan Richter
Quoted 14 lines · On Nov 27 Peter Hurley wrote:
Quoted 14 lines
Quoted 8 lines

Currently, firewire-net sets an arbitrary address handler length of 4096. This works because the largest AR packet size the current firewire-ohci driver handles is 4096 (value of MAX_ASYNC_PAYLOAD) + header/trailer. Note that firewire-ohci does not limit card->max_receive to this value.

So if the ohci driver changes to handle 8K+ AR packets and the hardware supports it, these address handler windows will be too small.

While the IEEE 1394:2008 link layer specification (section 6) provides for asynchronous packet payloads of up to 16384 bytes (table 6-4), the IEEE 1394 beta mode port specification (section 13) only allows up to 4096 bytes (table 16-18). And alpha mode is of course limited to 2048 bytes.

Quoted 6 lines
Quoted 2 lines

So, asynchronous packet payloads greater than 4096 bytes are out of scope of the current revision of IEEE 1394.

You should look at this 1394ta.org video
http://www.youtube.com/watch?v=xVXNvXHNQTY of DAP Technologies S1600 OHCI controllers running S1600 cameras using beta cables.

I don't know the details of their implementation, but I suppose they conform with the 1394 beta mode port specification. Which in turn means that their S1600 solution (and by extrapolation, their S3200 prototypes) comply with a maximum asynchronous packet payload of 4096 bytes. Citing IEEE 1394-2008:

Quoted 1 line
Quoted 1 line
Quoted 1 line

Table 16-18———Maximum payload size for Beta data packets

 Data rate | Maximum asynchronous payload size | Maximum isochronous payload
           |              (bytes)              |           (bytes)
 ----------+-----------------------------------+----------------------------
    S100   |                 512               |             1024
    S200   |                1024               |             2048
    S400   |                2048               |             4096
    S800   |                4096               |             8192
    S1600  |                4096               |            16384
    S3200  |                4096               |            32768

<<<

(Alpha mode payload limits are the same as the S100...S400 subset of beta mode. In IEEE 1394b-2002, the table number is 16-3.)

Quoted 9 lines

You can of course define registers (or better termed: buffers) which are larger than what can be atomically read or written, or atomically compared-swapped; IOW which are larger than what can be accessed in a single transaction, if such registers or buffers are useful. But if you particularly need a register which is just large enough to accommodate the largest possible inbound block write transaction which complies with IEEE 1394, and you don't know the peer's capability and the speeds of all intermediary cable hops, then fw_card.max_receive is the number that you need. Or you ignore the cards actual capability and just allocate 4096 bytes.

Thanks for the clarification. I need to update
link_speed_to_max_payload() now. ;)

Plus I should just renew my IEEE membership so I can get the 1394-2008 spec without having to saw my arm off.

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html