Commit Graph

266 Commits

Author SHA1 Message Date
Oron Peled c3b020a155 new "dahdi_waitfor_span_assignments" tool
* Allows waiting until all spans are "assigned" or "unassigned"
* Current implementation use a polling loop with sleep
* Future implementation may block on sysfs attribute
  (like waitfor_xpds is blocking on sysfs Astribanks attribute)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 12:35:59 +02:00
Oron Peled 7f826a7d35 hotplug modularization: split logic to scriptlets
* Device related operations are ordered in /usr/share/dahdi/handle_device.d/
* Span related operations are ordered in /usr/share/dahdi/span_config.d/
* In the future, span_config.d/50-asterisk should be moved to Asterisk.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 12:35:59 +02:00
Oron Peled cdedf024ae hotplug modularization: move sources to a subdir
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 12:35:59 +02:00
Russ Meyerriecks a6203e151f wcte13xp: Teach tools about te131 te132 products
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 17:45:58 -06:00
Shaun Ruffell 69ce6f07e0 dahdi_cfg: Allow dynamic spans to handle udev based span assignment.
Prior to this commit, if auto_assign_spans was set to 0, it was possible to
get in an endless loop creating and destroying spans. The primary reason was
that all dynamic spans are destroyed and recreated each time dahdi_cfg runs, BUT
dahdi_cfg was run each time a new span showed up in udev when auto_assign_spans
was set to 0.

Now dahdi_cfg will only destroy and recreate dynamic spans if dahdi_cfg is run
without a specifc span number. Also, while creating dynamic spans, dahdi_cfg
will pause for up to one second for the span to be assigned in order to ensure
that the spans are numbered consistently when auto span assignment is
configured.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 12:58:57 -06:00
Shaun Ruffell 9989b8779c dahdi_cfg: Add semaphore to prevent parallel execution.
When dahdi is configured for fully dynamic configuration on a device and
span basis via sysfs and udev it is possible for multiple instances of
dahdi_cfg to be run in parallel on different spans. If this happens it
is possible to see errors on the console that tone zones are already
registered since the check for the existence of a tone zone and the
re-registering needs to be atomic.

dahdi_cfg will now prevent itself from running in parallel.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 12:58:57 -06:00
Shaun Ruffell a4f79134c9 dahdi_handle_device: Auto assign only the device being added.
Eliminates trying to add spans multiple times as seen below:

    'dahdi_handle_device'[21993]: add: /devices/dynamic:loc:1
    'dahdi_handle_device'[21991]: add: /devices/dynamic:loc:0
    'dahdi_handle_device'[22001]: auto-assign /sys/bus/dahdi_devices/devices/dynamic:loc:0
    'dahdi_handle_device'[22001]: auto-assign /sys/bus/dahdi_devices/devices/dynamic:loc:1
    'dahdi_handle_device'[21999]: auto-assign /sys/bus/dahdi_devices/devices/dynamic:loc:0
    'dahdi_handle_device'[21999]: auto-assign /sys/bus/dahdi_devices/devices/dynamic:loc:1
    kernel: [ 3348.312534] dahdi_devices dynamic:loc:0: local span 1 is already assigned span 1
    kernel: [ 3348.312552] dahdi_devices dynamic:loc:1: local span 1 is already assigned span 2

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:57 +02:00
Shaun Ruffell d8074f434f dahdi_span_types: Show location of configuration file in help message.
Makes similar in for the dahdi_span_assignments in that the location of the
default configuration file is shown in the help screen.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:57 +02:00
Shaun Ruffell 15875924f0 dahdi_genconf: Add 'modules', 'spantypes', and 'assignedspans' to list of available generators.
This is a documentation change, that hopefully will help until I can remember
the names of the new generators.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:57 +02:00
Tzafrir Cohen a5bf1d3a2e dahdi_genconf: don't generate spantypes by default
A sane value for span-types.conf is either "all E1" or "all T1". Either
way it is not hardware-dependent, and hence no point in regenerating on
when the hardware changes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:57 +02:00
Tzafrir Cohen bf960799ea span_types/assignments: no * in device list
If there are no dahdi devices, $devbase/* expans to have a literal '*',
which leads to warnings such as:
/usr/sbin/dahdi_span_types: 1: cd: can't cd to /sys/bus/dahdi_devices/devices/*

Let's just avoid those.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:03 +02:00
Shaun Ruffell 4f259cd569 dahdi_handle_device, dahdi_span_config: Check for auto_assign_spans only when ACTION is add.
When dahdi.ko is unloaded, it may be possible for the driver to be removed from
the kernel before the udev scripts are run.  When this happens, you'll see
messages like the following which are not accurate:

    'dahdi_handle_device'[24567]: Old driver (no auto_assign_spans parameter). Skip /devices/pci0000:00/0000:00:1e.0/0000:11:01.0/pci:0000:11:01.0

Now instead you will see:

    'dahdi_handle_device'[28008]: remove: /devices/pci0000:00/0000:00:1e.0/0000:11:01.0/pci:0000:11:01.0

Also, all the udev events will be logged in the system log even when they are
ignored because of legacy auto span assignment. This will help show what is
going on during the transition period to full udev configuration of spans.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2014-01-08 17:56:52 -06:00
Tzafrir Cohen 4d5ca04ad6 README: Update the install targets
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-30 19:24:23 +02:00
Tzafrir Cohen 2d3580a3db README: document initialization
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-30 19:12:59 +02:00
Tzafrir Cohen d96be70986 README: indentation level for config samples
Indent the configuration samples one level deeper

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-29 20:32:12 +02:00
Tzafrir Cohen 41a725adea .gitignore: more generated files
Ignore test binaries and files generated by 'make docs'

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-29 13:53:53 +02:00
Shaun Ruffell 6ed0adc086 dahdi_span_config: Do not run auto span configuration if spans are auto assigned.
I have seen cases were users run:

  # modprobe <driver>; dahdi_cfg -c <custom config file>

and the spans end up misconfigured because dahdi_span_assignments ends up
running, via udev, after the user configured the span the way it wanted.

dahdi_span_assignments now looks at auto_assign_spans module parameter on
dahdi.ko, like dahdi_handle_device already does, to determine if legacy or udev
based configuration is being done.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2013-12-21 00:02:22 -06:00
Tzafrir Cohen 5e75fa48f4 dahdi.rules: use += for RUN
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-12 23:47:50 +02:00
Tzafrir Cohen 4ab8e95d0b dahdi.rules: Replace SYSFS with ATTRS
SYSFS has been deprecated. Use ATTRS.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-12 23:47:50 +02:00
Shaun Ruffell 5ca600c7c7 dahdi_cfg: Wait for all spans to be assigned.
When auto span assignment is disabled, it's possible that simply running

  # /etc/init.d/dahdi restart

Will fail since dahdi_cfg can run in parallel with udev scripts that are
assigning spans, which results in /etc/dahdi/system.conf describing spans that
do not exist in the system.

This change sets up dahdi_cfg, when run without the -C or -S options, to look in
sysfs and make sure all spans for each device are assigned.  dahdi_cfg will wait
5 seconds for span assignment to happen before proceeding normally.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-12 09:08:51 -06:00
Oron Peled 98736e1add Makefile: do install all man-pages
Fixes a regression in 2.8 (ffced0ca) in the main Makefile:
MAN_PAGES gets assigned twice and thus most man pages will not get
installed.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-09 22:57:41 +02:00
Oron Peled a9338d9b74 Makefile: new 'make-dist' target
Creates a tar.gz:
* Identical results to Digium's distributed tarballs
* Named "dahdi-tools-<version>.tar.gz"
* Only from committed files (uses git-archive)
* Adds a .version file

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-02 23:01:17 +02:00
Shaun Ruffell c0e19d47e8 dahdi_span_assignments, dahdi_span_types: Allow conf file to be overridden.
The environment variables that specified the full path the the configuration
files for dahdi_span_types and dahdi_span_assignments was documented, but they
were not actually set from the environment.

Also, the case of the variable was changed to match the one for the directory
where the rest of the config files are located.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-26 13:50:02 -06:00
Shaun Ruffell ffced0cad2 Add dahdi_ prefix to handle_device, span_types, span_assignments, and span_config.
All new dahdi tools and utilities will be prefixed with "dahdi_" in order to
avoid any future conflicts with other packages.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2013-11-26 13:50:02 -06:00
Shaun Ruffell e298eb1237 span_types: Fix bug that would prevent matching on devpath.
If a configuration file was specified that used the devpath, like:

  # Device: [] @Board_ID_Switch_0 /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0
  /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0 1:E1
  /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0 2:E1
  /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0 3:E1
  /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0 4:E1

Then the span_types script would silently fail to match the configuration lines
for the device and silently fail to change the linemodes.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2013-11-25 16:11:37 -06:00
Tzafrir Cohen a97d373d95 configure: regenerate for 6d10525
Regenerate configure script following changes in commit
6d10525863.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-24 18:11:04 +02:00
Shaun Ruffell c27664dc1b dahdi.init: Remove spurious "Missing '/sys/bus/astribanks/drivers/xppdrv/sync'".
The xpp_sync will fail if there are not any Astribank devices loaded. Check for
existence of the tools before trying to sync.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-24 10:06:11 -06:00
Tzafrir Cohen 365a12f42a README: include pinned spans config files
Include pinned-spans.conf and span-types.conf in the generated
README.html. Reformat them to render properly.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-24 16:48:29 +02:00
Oron Peled 2a84216fe4 Terminology rename: "pinned" -> "assigned"
* File names fixed
* File contents fixed

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:42:15 +02:00
Oron Peled 791a596c07 dahdi.rules: add persistent channel names as well
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:39:33 +02:00
Oron Peled d145364c00 dahdi.rules: don't process "add" events unless needed
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:38:43 +02:00
Oron Peled 0afba16b2e hotplug: run fxotune from span_config:
* Use fxotune -b/-e options to run on wanted channel range
2013-11-24 16:36:01 +02:00
Oron Peled c163caca00 fxotune: Now options '-b/-e' also apply with '-s'
* Now we can limit fxotune "set" mode to specific channel range.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:35:10 +02:00
Oron Peled c9e8ec7499 dahdi.rules: use tools_rootdir from driver
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:30:49 +02:00
Oron Peled 1356a55d77 span_types: fix for white-space in hardware_id
* Sanitize hardware_id/location attributes, just like span_assignments
* Allow control of keys via SPAN_ASSIGNMENTS_KEY or '-k <key>' option
* In general, import most features/options from span_assignments

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:22:58 +02:00
Oron Peled 10a6622774 udev scripts now read /etc/dahdi/init.conf
Added two override variables in init.conf:
* DAHDI_UDEV_DISABLE_DEVICES
* DAHDI_UDEV_DISABLE_SPANS

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:20:08 +02:00
Oron Peled a4217f6977 sysfs: restored legacy names /etc/dahdi/<channo>:
Update dahdi.rules to create again the old fashioned device files
(/dev/dahdi/<channo>), but as symlinks to modern names.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:17:35 +02:00
Oron Peled fb1a2b5572 added udev rules and their install target:
* Added missing Makefile install rule for dahdi.rules
* Pulled xpp.rules from dahdi-linux and added install rules for it

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:16:33 +02:00
Oron Peled 6d10525863 pinned-spans: remove '--enable-pinned' from configure
pinned-spans utilities are now essential:
* Called by udev rules
* Called by dahdi_genconf

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:13:51 +02:00
Oron Peled a1d4355c20 pinned-spans: fix examples in configuration files
* Correctly use the new "location" attribute
* Document the possibility to match against sysfs devpath
  (used to be the "location")

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:08:31 +02:00
Oron Peled b303802658 pinned-spans: fix configuration file names
* Install them as *.conf.sample -- that's what they are
* Correctly rename spantype.conf to span-types.conf (new name)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:05:11 +02:00
Shaun Ruffell 8d9a6bdd80 dahdi_genconf: Do not fail if pinned/assigned span utilities were not installed.
If you installed dahdi tools and did not specify DAHDI_PINNED=yes on the
makefile, when you run dahdi_genconf you would get an error like the following:

  # dahdi_genconf
  sh: span_types: command not found
  Command failed (status=32512): 'span_types dumpconfig > /etc/dahdi/span-types.conf' at ...

This change allows the generator for span-types.conf and span-assignements.conf
check for the existence of the utilities before attempting to call them.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-22 11:12:12 -06:00
Shaun Ruffell bb19620c52 wcte43x: Teach tools about the wcte43x driver.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 15:40:11 -06:00
Shaun Ruffell 11310bde53 wcaxx: Teach tools about the wcaxx driver.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 15:39:51 -06:00
Tzafrir Cohen b123bc87dd xpp_fxloader: support loading AB with ID > 201
Support loading firmware for Astribanks with bcdDevice > 2.01, as we'll
have 2.02 soon.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-21 16:55:18 +03:00
Oron Peled 299d9d9d9c fix typos in man-page
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-14 15:45:21 +03:00
Tzafrir Cohen 5e30a1401f Man pages for span_types and span_assignments
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-13 23:28:46 +03:00
Tzafrir Cohen 2f688f83c4 Remove dahdi_map, obsoleted by span_assignments
dahdi_map can be replaced by span_assignments list / dumpconfig

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-13 11:03:00 -04:00
Oron Peled 680f3e1d1d dahdi_registration: adapt to pinned-spans
* If xpp.dahdi_autoreg parameter is 'Y' -- Skip actuall registration.
* If dahdi.auto_assign_spans is '0' and there's no /etc/dahdi/pinned-spans.conf
  Than use 'span_assignments auto ...' to assign device spans.
* Since dahdi_registration iterate in correct xpp_order, the span
  assignment logic provides migration path for users who did not
  generate their pinned-spans.conf configuration yet.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-13 11:02:47 -04:00
Oron Peled 60fca920bc span_assignments: -k / --keys and more
* New functionality (documented in the script header):
  - Alternative "keys" for device matching
  - Added new command line options: --help, --dry-run, --verbose, --key

* Clean sysfs attribute contents from special characters in every use-case.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-13 11:01:56 -04:00