new driver: Nosy, a low-budget FireWire packet sniffer
Subsystems (2)
cover new driver: Nosy, a low-budget FireWire packet sniffer
Here is a (not so) new driver proposed for merge into the mainline:
Nosy - turns a Texas Instruments PCILynx card into an IEEE 1394
(FireWire) bus analyzer
This kernel driver is useful to reverse-engineer undocumented vendor-specific protocols and as an aid in IEEE 1394 application/ driver/ firmware development or even hardware development.
The driver was written by Kristian Høgsberg several years ago and has been maintained outside the mainline. Perhaps because of its rather limited user base, it took so long for a proposal to merge it into the mainline.
The driver requires a TI PCILynx or PCILynx-2 based FireWire controller, i.e. a TSB12LV21/ TSB12LV21A/ TSB12LV21B. My guess is that the current PCILynx-2 TSB12LV21B is better tested by Nosy users. To my knowledge, the following cards are based on PCILynx-2 or PCILynx:
- IOI IOI-1394TT (PCI card, current)
- Unibrain Fireboard 400 PCI Lynx-2 (PCI card, current)
- Newer Technology FireWire 2 Go (CardBus card, discontinued product)
- Apple Power Mac G3 blue & white (onboard controller, discontinued)
Regular OHCI-1394 FireWire controllers cannot be used for this purpose since OHCI compliant cards do not receive peer-to-peer packets into their link layers that are not addressed to them.
Along with the rather small kernel driver called nosy comes a simple userspace frontend, called nosy-dump. These two communicate via a 'misc' character device file with a simple ioctl() and read() based protocol. See the file nosy-user.h in patch 1/2 for a description of the character device file ABI.
Since the frontend nosy-dump is rather small regarding code size and is tightly bound to nosy regarding the kernel driver's usage scenario, it is proposed to maintain nosy-dump in the kernel source tree too. Patch 2/2 contains nosy-dump, placed into a new tools/firewire/ directory.
When I picked up nosy and nosy-dump from Kristian, I did a number of modifications to prepare for mainline merge. I have published the short history of these modifications in linux1394-2.6.git now, in a branch called 'nosy':
(git clone or pull)
git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git nosy
(gitweb)
http://git.kernel.org/?p=linux/kernel/git/ieee1394/linux1394-2.6.git;a=shortlog;h=refs/heads/nosy
I would prefer to merge this history instead of the two combined diffs which I am going to post for review now. Note, the 'nosy' git branch may be rebased if there will be review comments that warrant rewriting that branch.
Kristian's original sources are published at
git://anongit.freedesktop.org/~krh/nosy
There used to be a web site about nosy:
http://web.archive.org/web/20080225222139/http://bitplanet.net/nosy/
Current content of linux1394-2.6.git nosy:
Stefan Richter (21):
firewire: new driver: nosy - IEEE 1394 traffic sniffer
firewire: nosy: misc cleanups
firewire: nosy: convert to unlocked ioctl
firewire: nosy: fix list corruption by NOSY_IOC_STOP
firewire: nosy: use flagless variants of spinlock accessors
firewire: nosy: unroll some simple functions
firewire: nosy: fix IRQ handler for card ejection
firewire: nosy: handle errors in device probe
firewire: nosy: fix device shutdown with active client
firewire: nosy: annotate __user pointers and __iomem pointers
firewire: nosy: endianess fixes and annotations
firewire: nosy: use generic printk macros tools/firewire: add userspace front-end of nosy tools/firewire: nosy-dump: fix it on x86-64 tools/firewire: nosy-dump: work around segfault in decode_fcp tools/firewire: nosy-dump: change to kernel coding style tools/firewire: nosy-dump: make some symbols static or const tools/firewire: nosy-dump: break up a deeply nested function tools/firewire: nosy-dump: use linux/firewire-constants.h tools/firewire: nosy-dump: remove unused code tools/firewire: nosy-dump: increment program version
MAINTAINERS | 1 + drivers/firewire/Kconfig | 24 + drivers/firewire/Makefile | 1 + drivers/firewire/nosy-user.h | 25 + drivers/firewire/nosy.c | 720 ++++++++++++++++++++++++ drivers/firewire/nosy.h | 237 ++++++++ tools/firewire/Makefile | 19 + tools/firewire/decode-fcp.c | 213 +++++++ tools/firewire/list.h | 62 ++ tools/firewire/nosy-dump.c | 1031 ++++++++++++++++++++++++++++++++++ tools/firewire/nosy-dump.h | 173 ++++++ 11 files changed, 2506 insertions(+), 0 deletions(-) create mode 100644 drivers/firewire/nosy-user.h create mode 100644 drivers/firewire/nosy.c create mode 100644 drivers/firewire/nosy.h create mode 100644 tools/firewire/Makefile create mode 100644 tools/firewire/decode-fcp.c create mode 100644 tools/firewire/list.h create mode 100644 tools/firewire/nosy-dump.c create mode 100644 tools/firewire/nosy-dump.h
Signature · 3 lines
Stefan Richter -=====-==-=- -=== =-==- http://arcgraph.de/sr/
PATCH 1/2 firewire: new driver: nosy - IEEE 1394 traffic sniffer
This adds the traffic sniffer driver for Texas Instruments PCILynx/ PCILynx2 based cards. The use cases for nosy are analysis of nonstandard protocols and as an aid in development of drivers, applications, or firmwares.
This comparably small kernel driver sets up packet reception DMA in the special snoop mode of the PCILynx chip. Userspace can pick up the snooped FireWire traffic via a misc char device file "/dev/nosy". The file supports poll(), read(), and four ioctl()s; see nosy-user.h.
The ioctls use type code '&' which is currently unallocated according to Documentation/ioctl/ioctl-number.txt. Is this OK or should it be moved to a different type code?
A side note regarding maintainability: The PCILynx chip is well documented in Texas Instruments' literature SCPA020A and SLLA023.
--- drivers/firewire/Kconfig | 23 ++ drivers/firewire/Makefile | 1 + drivers/firewire/nosy-user.h | 25 ++ drivers/firewire/nosy.c | 720 ++++++++++++++++++++++++++++++++++++++++++ drivers/firewire/nosy.h | 237 ++++++++++++++ 5 files changed, 1006 insertions(+), 0 deletions(-) create mode 100644 drivers/firewire/nosy-user.h create mode 100644 drivers/firewire/nosy.c create mode 100644 drivers/firewire/nosy.h
drivers/firewire/Kconfig +23 -0
@@ -66,4 +66,27 @@ config FIREWIRE_NET source "drivers/ieee1394/Kconfig" +config FIREWIRE_NOSY + tristate "Nosy - a FireWire traffic sniffer for PCILynx cards" + depends on PCI + help + Nosy is an IEEE 1394 packet sniffer that is used for protocol + analysis and in development of IEEE 1394 drivers, applications, + or firmwares. + + This driver lets you use a Texas Instruments PCILynx 1394 to PCI + link layer controller TSB12LV21/A/B as a low-budget bus analyzer. + PCILynx is a nowadays very rare IEEE 1394 controller which is + not OHCI 1394 compliant. + + The following cards are known to be based on PCILynx or PCILynx-2: + IOI IOI-1394TT (PCI card), Unibrain Fireboard 400 PCI Lynx-2 + (PCI card), Newer Technology FireWire 2 Go (CardBus card), + Apple Power Mac G3 blue & white (onboard controller). + + To compile this driver as a module, say M here: The module will be + called nosy. + + If unsure, say N. + endmenu
drivers/firewire/Makefile +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_FIREWIRE) += firewire-core.o obj-$(CONFIG_FIREWIRE_OHCI) += firewire-ohci.o obj-$(CONFIG_FIREWIRE_SBP2) += firewire-sbp2.o obj-$(CONFIG_FIREWIRE_NET) += firewire-net.o +obj-$(CONFIG_FIREWIRE_NOSY) += nosy.o
drivers/firewire/nosy-user.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef __nosy_user_h +#define __nosy_user_h + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define NOSY_IOC_GET_STATS _IOR('&', 0, struct nosy_stats) +#define NOSY_IOC_START _IO('&', 1) +#define NOSY_IOC_STOP _IO('&', 2) +#define NOSY_IOC_FILTER _IOW('&', 2, __u32) + +struct nosy_stats { +__u32 total_packet_count; +__u32 lost_packet_count; +}; + +/* +* Format of packets returned from the kernel driver: +* +* quadlet with timestamp (microseconds, CPU endian) +* quadlet-padded packet data... (little endian) +* quadlet with ack (little endian) +*/ + +#endif /* __nosy_user_h */
drivers/firewire/nosy.c new file +720 -0
720 lines not on this page · raw message
drivers/firewire/nosy.h new file +237 -0
237 lines not on this page · raw message
Signature · 3 lines
Stefan Richter -=====-==-=- -=== =-==- http://arcgraph.de/sr/
Re: [review patch 1/2] firewire: new driver: nosy - IEEE 1394 traffic sniffer
Quoted 34 lines · On Thu, 22 Jul 2010 11:56:38 +0200 (CEST) Stefan Richter wrote:
This adds the traffic sniffer driver for Texas Instruments PCILynx/ PCILynx2 based cards. The use cases for nosy are analysis of nonstandard protocols and as an aid in development of drivers, applications, or firmwares.
This comparably small kernel driver sets up packet reception DMA in the special snoop mode of the PCILynx chip. Userspace can pick up the snooped FireWire traffic via a misc char device file "
/dev/nosy". The file supportspoll(),read(), and four ioctl()s; seenosy-user.h.The ioctls use type code '&' which is currently unallocated according to
Documentation/ioctl/ioctl-number.txt. Is this OK or should it be moved to a different type code?A side note regarding maintainability: The PCILynx chip is well documented in Texas Instruments' literature SCPA020A and SLLA023.
Signed-off-by Stefan Richter <[email protected]>--- drivers/firewire/Kconfig | 23 ++ drivers/firewire/Makefile | 1 + drivers/firewire/nosy-user.h | 25 ++ drivers/firewire/nosy.c | 720 ++++++++++++++++++++++++++++++++++++++++++ drivers/firewire/nosy.h | 237 ++++++++++++++ 5 files changed, 1006 insertions(+), 0 deletions(-) create mode 100644 drivers/firewire/nosy-user.h create mode 100644 drivers/firewire/nosy.c create mode 100644 drivers/firewire/nosy.hdrivers/firewire/Kconfig +0
-0
drivers/firewire/Kconfig config FIREWIRE_NET · line 71
Quoted 6 lines
drivers/firewire/Kconfig +3
-0@@ -66,4 +66,27 @@ config FIREWIRE_NET source "drivers/ieee1394/Kconfig" +config FIREWIRE_NOSY + tristate "Nosy - a FireWire traffic sniffer for PCILynx cards" + depends on PCI
Just curious: why not depends on IEEE1394_PCILYNX ?
Quoted 36 lines
drivers/firewire/Kconfig +20
-0+ help + Nosy is an IEEE 1394 packet sniffer that is used for protocol + analysis and in development of IEEE 1394 drivers, applications, + or firmwares. + + This driver lets you use a Texas Instruments PCILynx 1394 to PCI + link layer controller TSB12LV21/A/B as a low-budget bus analyzer. + PCILynx is a nowadays very rare IEEE 1394 controller which is + not OHCI 1394 compliant. + + The following cards are known to be based on PCILynx or PCILynx-2: + IOI IOI-1394TT (PCI card), Unibrain Fireboard 400 PCI Lynx-2 + (PCI card), Newer Technology FireWire 2 Go (CardBus card), + Apple Power Mac G3 blue & white (onboard controller). + + To compile this driver as a module, say M here: The module will be + called nosy. + + If unsure, say N. + endmenudrivers/firewire/Makefile +1
-0@@ -12,3 +12,4 @@ obj-$(CONFIG_FIREWIRE) += firewire-core.o obj-$(CONFIG_FIREWIRE_OHCI) += firewire-ohci.o obj-$(CONFIG_FIREWIRE_SBP2) += firewire-sbp2.o obj-$(CONFIG_FIREWIRE_NET) += firewire-net.o +obj-$(CONFIG_FIREWIRE_NOSY) += nosy.odrivers/firewire/nosy-user.h new file +0
-0
drivers/firewire/nosy-user.h line 10
Quoted 10 lines
drivers/firewire/nosy-user.h new file +10
-0@@ -0,0 +1,25 @@ +#ifndef __nosy_user_h +#define __nosy_user_h + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define NOSY_IOC_GET_STATS _IOR('&', 0, struct nosy_stats) +#define NOSY_IOC_START _IO('&', 1) +#define NOSY_IOC_STOP _IO('&', 2) +#define NOSY_IOC_FILTER _IOW('&', 2, __u32)
Please add '&' to Documentation/ioctl/ioctl-number.txt.
Quoted 4 lines
drivers/firewire/nosy-user.h new file +4
-0+struct nosy_stats { +__u32 total_packet_count; +__u32 lost_packet_count; +};
drivers/firewire/nosy-user.h line 25
Quoted 10 lines
drivers/firewire/nosy-user.h new file +10
-0+ +/* +* Format of packets returned from the kernel driver: +* +* quadlet with timestamp (microseconds, CPU endian) +* quadlet-padded packet data... (little endian) +* quadlet with ack (little endian) +*/ + +#endif /* __nosy_user_h */
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
Re: [review patch 1/2] firewire: new driver: nosy - IEEE 1394 traffic sniffer
Quoted 5 lines · Randy Dunlap
Quoted 4 lines · On Thu, 22 Jul 2010 11:56:38 +0200 (CEST) Stefan Richter wrote:
drivers/firewire/Kconfig +0
-0@@ -66,4 +66,27 @@ config FIREWIRE_NET
Quoted 7 lines
drivers/firewire/Kconfig config FIREWIRE_NET · line 71
Quoted 5 lines
drivers/firewire/Kconfig +3
-0source "drivers/ieee1394/Kconfig" +config FIREWIRE_NOSY + tristate "Nosy - a FireWire traffic sniffer for PCILynx cards" + depends on PCIJust curious: why not depends on
IEEE1394_PCILYNX?
This is a stand-alone driver that interacts neither with the old nor with the new FireWire kernel subsystem. It contains only the minimum of DMA programming that is required to get PCILynx' snoop mode (a catch-all reception DMA) up and running.
IEEE1394_PCILYNX alias pcilynx on the other hand is a bigger card driver which implements several transmit and receive DMA modes as required by a low-level driver of the ieee1394 stack.¹
Thus, nosy does not use code from or share code with anything in drivers/ieee1394/.
¹) except for isochronous transmission and reception; this was initially also provided by pcilynx but became outdated early on in the history of the ieee1394 stack when video1394 was added; and except for physical DMA that the sbp2 driver requires
If you have a PCILynx card, you can bind either pcilynx or nosy to it. (As the kernel's build system works, I think nosy is going to be bound before pcilynx if both are present.) However, nosy the bus analyzer provides better value than pcilynx the ieee1394 lowlevel driver that lacks 3/4 of the functionality that ohci1394 offers.
Quoted 7 lines
Quoted 7 lines
drivers/firewire/nosy-user.h new file +4
-0@@ -0,0 +1,25 @@ +#ifndef __nosy_user_h +#define __nosy_user_h + +#include <linux/ioctl.h>
Quoted 8 lines
drivers/firewire/nosy-user.h line 10
Quoted 6 lines
drivers/firewire/nosy-user.h new file +6
-0+#include <linux/types.h> + +#define NOSY_IOC_GET_STATS _IOR('&', 0, struct nosy_stats) +#define NOSY_IOC_START _IO('&', 1) +#define NOSY_IOC_STOP _IO('&', 2) +#define NOSY_IOC_FILTER _IOW('&', 2, __u32)Please add '&' to
Documentation/ioctl/ioctl-number.txt.
Right, I will send a follow-up patch which does this if there are no fundamental objections to this ioctl allocation.
Signature · 3 lines
Stefan Richter -=====-==-=- -=== =-==- http://arcgraph.de/sr/
[review patch 3/2] firewire: nosy: note ioctls in ioctl-number.txt
These are the ioctls for the special-purpose misc device /dev/nosy, the interface to the IEEE 1394 packet sniffer/ protocol analyzer driver. Currently only the numbers 00...02 are in use; let's block a few more for unforeseen use cases.
---
As mentioned in patch 1/2, this is up for discussion. These ioctls have been used during nosy's out-of-tree life for several years; but due to the nature of this driver and its frontend as special-purpose application on special hardware, an incompatible change of these ioctls in the process of mainline merge won't be overly hurtful.
Documentation/ioctl/ioctl-number.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/ioctl/ioctl-number.txt +1 -0
@@ -79,6 +79,7 @@ Code Seq#(hex) Include File Comments 0x22 all scsi/sg.h '#' 00-3F IEEE 1394 Subsystem Block for the entire subsystem '$' 00-0F linux/perf_counter.h, linux/perf_event.h +'&' 00-07 drivers/firewire/nosy-user.h '1' 00-1F <linux/timepps.h> PPS kit from Ulrich Windl <ftp://ftp.de.kernel.org/pub/linux/daemons/ntp/PPS/> '2' 01-04 linux/i2o.h
Signature · 3 lines
Stefan Richter -=====-==-=- -=== =-==- http://arcgraph.de/sr/
Re: [review patch 3/2] firewire: nosy: note ioctls in ioctl-number.txt
Quoted 25 lines · Stefan Richter
These are the ioctls for the special-purpose misc device
/dev/nosy, the interface to the IEEE 1394 packet sniffer/ protocol analyzer driver. Currently only the numbers 00...02 are in use; let's block a few more for unforeseen use cases.Cc Randy Dunlap <[email protected]>Cc Kristian Høgsberg <[email protected]>Signed-off-by Stefan Richter <[email protected]>---
As mentioned in patch 1/2, this is up for discussion. These ioctls have been used during nosy's out-of-tree life for several years; but due to the nature of this driver and its frontend as special-purpose application on special hardware, an incompatible change of these ioctls in the process of mainline merge won't be overly hurtful.
Documentation/ioctl/ioctl-number.txt | 1 + 1 file changed, 1 insertion(+)Index:
b/Documentation/ioctl/ioctl-number.txt
===================================================================
Documentation/ioctl/ioctl-number.txt Code Seq#(hex) Include File Comments · line 85
Quoted 7 lines
Documentation/ioctl/ioctl-number.txt +1
-0@@ -79,6 +79,7 @@ Code Seq#(hex) Include File Comments 0x22 all scsi/sg.h '#' 00-3F IEEE 1394 Subsystem Block for the entire subsystem '$' 00-0F linux/perf_counter.h, linux/perf_event.h +'&' 00-07 drivers/firewire/nosy-user.h '1' 00-1F <linux/timepps.h> PPS kit from Ulrich Windl <ftp://ftp.de.kernel.org/pub/linux/daemons/ntp/PPS/> '2' 01-04 linux/i2o.h
(Sorry, I mistyped the mailinglist address in that posting...)
Signature · 3 lines
Stefan Richter -=====-==-=- -=== =-==- http://arcgraph.de/sr/
PATCH 2/2 tools/firewire: add nosy-dump, frontend to the driver nosy
In reply to Stefan RichterThis adds the userspace frontend to nosy, the traffic sniffer driver for Texas Instruments PCILynx/ PCILynx2 based cards.
Nosy-dump currently offers three views upon bus traffic: Plain dump of the packets with minimal decoding (generic link packet components and most PHY packet components); a transaction view to track 1394 requests and responses, together with basic decoding of FCP frames; a statistics view which merely counst packets and other events. Several instances of nosy-dump can be attached to a single PCILynx card.
Because nosy and nosy-dump are so closely coupled regarding their use case, it is proposed to keep them also closely coupled regarding their source code management and distribution. Hence I would like to add this userspace utility to tools/ in the Linux kernel sources.
If need for a more feature rich, bigger userspace frontend arises, such a frontend could be developed and maintained separately from nosy-dump which would then serve as starter kit for users and baseline for programmers.
Side note: I attempted to replace nosy-dump's list.h by the kernel's include/linux/list.h but quickly stumbled over the other kernel headers which it pulls in. I need to have a look at how tools/perf/ does it.
--- MAINTAINERS | 1 + drivers/firewire/Kconfig | 3 +- tools/firewire/Makefile | 19 + tools/firewire/decode-fcp.c | 213 +++++++++ tools/firewire/list.h | 62 +++ tools/firewire/nosy-dump.c | 1031 +++++++++++++++++++++++++++++++++++++++++++ tools/firewire/nosy-dump.h | 173 ++++++++ 7 files changed, 1501 insertions(+), 1 deletions(-) create mode 100644 tools/firewire/Makefile create mode 100644 tools/firewire/decode-fcp.c create mode 100644 tools/firewire/list.h create mode 100644 tools/firewire/nosy-dump.c create mode 100644 tools/firewire/nosy-dump.h
MAINTAINERS +1 -0
@@ -2256,6 +2256,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git S: Maintained F: drivers/firewire/ F: include/linux/firewire*.h +F: tools/firewire/ FIRMWARE LOADER (request_firmware) S: Orphan
drivers/firewire/Kconfig +2 -1
@@ -85,7 +85,8 @@ config FIREWIRE_NOSY Apple Power Mac G3 blue & white (onboard controller). To compile this driver as a module, say M here: The module will be - called nosy. + called nosy. Source code of a userspace interface to nosy, called + nosy-dump, can be found in tools/firewire/ of the kernel sources. If unsure, say N.
tools/firewire/Makefile new file +19 -0
@@ -0,0 +1,19 @@ +prefix = /usr +nosy-dump-version = 0.4 + +CC = gcc + +all : nosy-dump + +nosy-dump : CFLAGS = -Wall -O2 -g +nosy-dump : CPPFLAGS = -DVERSION=\"$(nosy-dump-version)\" -I../../drivers/firewire +nosy-dump : LDFLAGS = -g +nosy-dump : LDLIBS = -lpopt + +nosy-dump : nosy-dump.o decode-fcp.o + +clean : + rm -rf *.o nosy-dump + +install : + install nosy-dump $(prefix)/bin/nosy-dump
tools/firewire/decode-fcp.c new file +213 -0
213 lines not on this page · raw message
tools/firewire/list.h new file +62 -0
62 lines not on this page · raw message
tools/firewire/nosy-dump.c new file +1031 -0
1,031 lines not on this page · raw message
tools/firewire/nosy-dump.h new file +173 -0
173 lines not on this page · raw message
Signature · 3 lines
Stefan Richter -=====-==-=- -=== =-==- http://arcgraph.de/sr/