[asterisk-dev] Sysfs udev /dev/dahdi/span-names/ population
Tzafrir Cohen
tzafrir.cohen at xorcom.com
Sat Jul 24 15:48:52 CDT 2010
On Sat, Jul 24, 2010 at 09:49:05PM +0200, Kevin P. Fleming wrote:
> On 07/24/2010 03:38 PM, Tzafrir Cohen wrote:
> > On Fri, Jul 23, 2010 at 05:01:02PM -0500, Russ Meyerriecks wrote:
> >> Tzafrir,
> >> What do you think about removing the "location" and using just
> >> "span_id" as a global unique span identifier?
> >
> > Astribanks have two persistant identifiers:
> >
> > * Connector string: This basically describes the USB connector you
> > plugged the device into
> > * Label: Essentially a serial number. Identifies a specific box.
> >
> > Both are useful to identify devices by, as we have seen customers in the
> > field. Identifying by the connector rather than the label may be more
> > useful for those who want to easily replace one device with another in
> > case of a problem.
> >
> > So I can't make an easy choice which of those two to present as a span
> > ID.
>
> ... and this is exactly why sysfs and udev were created. The policy of
> which identifier is going to be used by userspace to refer to that
> device does belong in the driver (unless of course there is only one
> option). The driver should expose the various pieces of information it
> has available, and the admin can create a suitable udev rule (probably
> by copying an example that would exist in the docs) based on whether
> they prefer to use the connector string or the label... or whether they
> want to just give the device some completely unrelated name (but be able
> to move that name to a replacement device should the need arise).
>
> Please don't put *policy* in the driver; only provide the mechanisms
> that are needed to implement the policies, and in cases where it makes
> sense, choose a suitable default. Personally, I'd be absolutely fine if
> the span device was not created by the driver at all, but was created by
> udev rules, so that there was only one place that the logic for how it
> should be named would live. This would require installing 'default' udev
> rules when dahdi-linux is installed, but then at least there is only
> place the admin needs to look to figure out why a device got a
> particular name, and only one place to change it.
Well, it's not there, mostly. See below the information included in
sysfs (which is the new information exposed by the kernel to userspace,
and also roughly represents data structures in the kernel).
While there are some changes in the kernel (channels are not simple
numbers under /sys/class/dahdi), the kernel part certainly does provide
the information to userspace.
All the hirarchy under /dev/dahdi/span-names and /dev/dahdi/span-aliases
is implemented in udev hooks, with no explicit support from the kernel
side.
We believe providing a separate span_id is to userspace is useful in any
case, regardless of whether or not other cards have a hardware_id.
lambert:~# ls -F /sys/bus/
ac97/ dahdi_chans/ isa/ platform/ serio/ virtio/
acpi/ dahdi_spans/ pci/ pnp/ spi/ xpds/
astribanks/ ide/ pci_express/ scsi/ usb/
lambert:~# ls /sys/bus/dahdi_spans/devices/
span-1 span-2 span-3 span-4 span-5 span-6 span-7
alarms dahdi!spans!6!4/ devicetype is_sync_master span_id
bus@ dahdi!spans!6!5/ driver@ lbo spantype
configured_channels dahdi!spans!6!6/ hardware_id location subsystem@
dahdi!spans!6!1/ dahdi!spans!6!7/ irq manufacturer syncsrc
dahdi!spans!6!2/ dahdi!spans!6!8/ irqmisses name uevent
dahdi!spans!6!3/ desc is_digital power/ user_ready
lambert:~# grep . /sys/bus/dahdi_spans/devices/span-6/*
/sys/bus/dahdi_spans/devices/span-6/alarms:0x0
/sys/bus/dahdi_spans/devices/span-6/configured_channels:6 8/8
XBUS-00/XPD-20
/sys/bus/dahdi_spans/devices/span-6/desc:Xorcom XPD #00/20: FXS
/sys/bus/dahdi_spans/devices/span-6/devicetype:Astribank: Unit 2 Subunit
0: FXS
/sys/bus/dahdi_spans/devices/span-6/hardware_id:usb:INT00415
/sys/bus/dahdi_spans/devices/span-6/irq:0
/sys/bus/dahdi_spans/devices/span-6/irqmisses:0
/sys/bus/dahdi_spans/devices/span-6/is_digital:0
/sys/bus/dahdi_spans/devices/span-6/is_sync_master:0
/sys/bus/dahdi_spans/devices/span-6/lbo:0
/sys/bus/dahdi_spans/devices/span-6/location:usb-0000:00:03.3-5.3
/sys/bus/dahdi_spans/devices/span-6/manufacturer:Xorcom Inc.
/sys/bus/dahdi_spans/devices/span-6/name:XBUS-00/XPD-20
/sys/bus/dahdi_spans/devices/span-6/span_id:20
/sys/bus/dahdi_spans/devices/span-6/spantype:FXS
/sys/bus/dahdi_spans/devices/span-6/syncsrc:0
/sys/bus/dahdi_spans/devices/span-6/uevent:DRIVER=generic_lowlevel
/sys/bus/dahdi_spans/devices/span-6/uevent:PHYSDEVBUS=dahdi_spans
/sys/bus/dahdi_spans/devices/span-6/uevent:PHYSDEVDRIVER=generic_lowlevel
/sys/bus/dahdi_spans/devices/span-6/uevent:DAHDI_INIT_DIR=/usr/src/git/dahdi-linux-sysfs/live/usr/share/dahdi
/sys/bus/dahdi_spans/devices/span-6/uevent:SPAN_NUM=6
/sys/bus/dahdi_spans/devices/span-6/uevent:SPAN_NAME=XBUS-00/XPD-20
/sys/bus/dahdi_spans/devices/span-6/user_ready:6 8/8 XBUS-00/XPD-20
lambert:~# ls -F /sys/bus/dahdi_chans/devices/
...
dahdi!spans!1!27@ dahdi!spans!2!4@ dahdi!spans!4!1@ dahdi!spans!5!7@
dahdi!spans!1!28@ dahdi!spans!2!5@ dahdi!spans!4!10@ dahdi!spans!5!8@
dahdi!spans!1!29@ dahdi!spans!2!6@ dahdi!spans!4!11@ dahdi!spans!6!1@
...
lambert:~# ls -F /sys/class/dahdi/
dahdi!channel/ dahdi!ctl/ dahdi!pseudo/ dahdi!timer/
--
Tzafrir Cohen
icq#16849755 jabber:tzafrir.cohen at xorcom.com
+972-50-7952406 mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com iax:guest at local.xorcom.com/tzafrir
More information about the asterisk-dev
mailing list