Debian Codegraph @

README

raw
1 DAHDI Telephony Interface Driver
2 =================================
3 Asterisk Development Team <[email protected]>
4 $Revision$, $Date$
5
6 DAHDI stands for Digium Asterisk Hardware Device Interface.
7
8 This package contains the kernel modules for DAHDI. For the required
9 userspace tools see the package dahdi-tools.
10
11 Supported Hardware
12 ------------------
13 Digital Cards
14 ~~~~~~~~~~~~~
15 - wcte43x:
16 * Digium TE435: PCI express quad-port T1/E1/J1
17 * Digium TE436: PCI quad-port T1/E1/J1
18 * Digium TE235: PCI express dual-port T1/E1/J1
19 * Digium TE236: PCI dual-port T1/E1/J1
20 - wcte13xp:
21 * Digium TE131: PCI express single-port T1/E1/J1
22 * Digium TE133: PCI express single-port T1/E1/J1 with echocan
23 * Digium TE132: PCI single-port T1/E1/J1
24 * Digium TE134: PCI single-port T1/E1/J1 with echocan
25 - wct4xxp:
26 * Digium TE205P/TE207P/TE210P/TE212P: PCI dual-port T1/E1/J1
27 * Digium TE405P/TE407P/TE410P/TE412P: PCI quad-port T1/E1/J1
28 * Digium TE220: PCI-Express dual-port T1/E1/J1
29 * Digium TE420: PCI-Express quad-port T1/E1/J1
30 * Digium TE820: PCI-Express eight-port T1/E1/J1
31 - wcte12xp:
32 * Digium TE120P: PCI single-port T1/E1/J1
33 * Digium TE121: PCI-Express single-port T1/E1/J1
34 * Digium TE122: PCI single-port T1/E1/J1
35 - wcte11xp:
36 * Digium TE110P: PCI single-port T1/E1/J1
37 - wct1xxp:
38 * Digium T100P: PCI single-port T1
39 * Digium E100P: PCI single-port E1
40 - wcb4xxp:
41 * Digium B410: PCI quad-port BRI
42 - tor2: Tormenta quad-span T1/E1 card from the Zapata Telephony project
43
44
45 Analog Cards
46 ~~~~~~~~~~~~
47 - wcaxx:
48 * Digium A8A: PCI up to 8 mixed FXS/FXO ports
49 * Digium A8B: PCI express up to 8 mixed FXS/FXO ports
50 * Digium A4A: PCI up to 4 mixed FXS/FXO ports
51 * Digium A4B: PCI express up to 4 mixed FXS/FXO ports
52 - wctdm24xxp:
53 * Digium TDM2400P/AEX2400: up to 24 analog ports
54 * Digium TDM800P/AEX800: up to 8 analog ports
55 * Digium TDM410P/AEX410: up to 4 analog ports
56 * Digium Hx8 Series: Up to 8 analog or BRI ports
57 - wctdm:
58 * Digium TDM400P: up to 4 analog ports
59 - xpp: Xorcom Astribank: a USB connected unit of up to 32 ports
60 (including the digital BRI and E1/T1 modules)
61 - wcfxo: X100P, similar and clones. A simple single-port FXO card
62
63
64 Other Drivers
65 ~~~~~~~~~~~~~
66 - pciradio: Zapata Telephony PCI Quad Radio Interface
67 - wctc4xxp: Digium hardware transcoder cards (also need dahdi_transcode)
68 - dahdi_dynamic_eth: TDM over Ethernet (TDMoE) driver. Requires dahdi_dynamic
69 - dahdi_dynamic_loc: Mirror a local span. Requires dahdi_dynamic
70
71 Installation
72 ------------
73 If all is well, you just need to run the following:
74
75 make
76 make install
77
78 You'll need the utilities provided in the package dahdi-tools to
79 configure DAHDI devices on your system.
80
81 If using `sudo` to build/install, you may need to add /sbin to your PATH.
82
83 If you still have problems, read further.
84
85
86 Build Requirements
87 ~~~~~~~~~~~~~~~~~~
88 gcc and friends. Generally you will need to install the package gcc.
89 There may be cases where you will need a specific version of gcc to build
90 kernel modules.
91
92 Kernel Source / "Headers"
93 ^^^^^^^^^^^^^^^^^^^^^^^^^
94 - Building DAHDI-linux requires a kernel build tree.
95 - This should basically be at least a partial kernel source tree and
96 most importantly, the exact kernel .config file used for the build as
97 well as several files generated at kernel build time.
98 - KERNEL_VERSION is the output of the command `uname -r`
99 - If you build your own kernel, you need to point to the exact kernel
100 build tree. Luckily for you, this will typically be pointed by the
101 symbolic link /lib/modules/KERNEL_VERSION/build which is the location
102 zaptel checks by default.
103 - If you use a kernel from your distribution you will typically have a
104 package with all the files required to build a kernel modules for your
105 kernel image.
106 * On Debian and Ubuntu this is
107 +++ linux-headers-`uname -r` +++
108 * On Fedora, RHEL and compatibles (e.g. CentOS) and SUSE this is
109 the kernel-devel package. Or if you run kernel-smp or kernel-xen,
110 you need kernel-smp-devel or kernel-xen-devel, respectively.
111 * In some distributions (e.g.: in RHEL/CentOS, Fedora, Ubuntu) the
112 installation of the kernel-devel / kernel-headers package will
113 be of a version that is newer than the one you currently run. In
114 such a case you may need to upgrade the kernel package itself as
115 well and reboot.
116 - To point explicitly to a different build tree: set KSRC to the kernel
117 source tree or KVERS to the exact kernel version (if "headers" are
118 available for a different version). This parameter must be run on
119 every calls to 'make' (e.g.: 'make clean', 'make install').
120
121 make KVERS=2.6.18.Custom
122 make KSRC=/home/tzafrir/kernels/linus
123
124
125 Kernel Configuration
126 ^^^^^^^^^^^^^^^^^^^^
127 If you build a custom kernel, note the following configuration items:
128
129 - CONFIG_CRC_CCITT must be enabled ('y' or 'm'). On 2.6 kernels this can
130 be selected These can be selected from the "Library Routines" submenu
131 during kernel configuration via "make menuconfig".
132 - DAHDI will work if you disable module unloading. But you may need
133 extra reboots.
134 - DAHDI needs the BKL (Big Kernel Lock). This may be annoying in
135 >=2.6.37 kernels. Make sure you enable CONFIG_BKL on those kernels.
136
137
138 Installing to a Subtree
139 ~~~~~~~~~~~~~~~~~~~~~~~
140 The following may be useful when testing the package or when preparing a
141 package for a binary distribution (such as an rpm package) installing
142 onto a subtree rather than on the real system.
143
144 make install DESTDIR=targetdir
145
146 This can be useful for any partial install target of the above (e.g:
147 install-modules or install-programs).
148
149 the targetdir must be an absolute path, at least if you install the
150 modules. To install to a relative path you can use something like:
151
152 make install-modules DESTDIR=$PWD/target
153
154
155 Extra Modules
156 ~~~~~~~~~~~~~
157 To build extra modules / modules directory not included in the DAHDI
158 distribution, use the optional variables MODULES_EXTRA and
159 SUBDIRS_EXTRA:
160
161 make MODULES_EXTRA="mod1 mod2"
162 make MODULES_EXTRA="mod1 mod2" SUBDIRS_EXTRA="subdir1/ subdir1/"
163
164
165 Static Device Files
166 ~~~~~~~~~~~~~~~~~~~
167 Userspace programs communicate with the DAHDI modules through special
168 device files under /dev/dahdi . Those are normally created by udev, but
169 if you use an embedded-type system and don't wish to use udev, you can
170 generate them with the following script, from the source directory:
171
172 ./build_tools/make_static_devs
173
174 This will generate the device files under /dev/dahdi . If you need to
175 generate them elsewhere (e.g. `tmp/newroot/dev/dahdi`) use the option -d
176 to the script:
177
178 ./build_tools/make_static_devs -d tmp/newroot/dev/dahdi
179
180
181 DKMS
182 ~~~~
183 DKMS, Dynamic Kernel Module Support, is a framework for building Linux
184 kernel modules. It is used, among others, by several distributions that
185 package the DAHDI kernel modules.
186
187 DKMS is designed to provide updates over drivers installed from original
188 kernel modules tree. Thus it installed modules into /lib/modules/updates
189 or /lib/modules/VERSION/updates . This is generally not an issue on
190 normal operation. However if you try to install DAHDI from source on
191 a system with DAHDI installed from DKMS this way (potentially of an
192 older version), be sure to remove the DKMS-installed modules from the
193 updates directory. If you're not sure, the following command will give
194 you a clue of the versions installed:
195
196 find /lib/modules -name dahdi.ko
197
198
199 Installing the B410P drivers with mISDN
200 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201 DAHDI includes the wcb4xxp driver for the B410P, however, support for the
202 B410P was historically provided by mISDN. If you would like to use the mISDN
203 driver with the B410P, please comment out the wcb4xxp line in /etc/dahdi/modules.
204 This will prevent DAHDI from loading wcb4xxp which will conflict with the mISDN
205 driver.
206
207 To install the mISDN driver for the B410P, please see http://www.misdn.org for
208 more information, but the following sequence of steps is roughly equivalent to
209 'make b410p' from previous releases.
210
211 wget http://www.misdn.org/downloads/releases/mISDN-1_1_8.tar.gz
212 wget http://www.misdn.org/downloads/releases/mISDNuser-1_1_8.tar.gz
213 tar xfz mISDN-1_1_8.tar.gz
214 tar xfz mISDNuser-1_1_8.tar.gz
215 pushd mISDN-1_1_8
216 make install
217 popd
218 pushd mISDNuser-1_1_8
219 make install
220 popd
221 /usr/sbin/misdn-init config
222
223 You will then also want to make sure /etc/init.d/misdn-init is started
224 automatically with either 'chkconfig --add misdn-init' or 'update-rc.d
225 misdn-init defaults 15 30' depending on your distribution.
226
227 NOTE: At the time this was written, misdn-1.1.8 is not compatible the
228 2.6.25 kernel. Please use a kernel version 2.6.25 or earlier.
229
230
231 OSLEC
232 ~~~~~
233 http://www.rowetel.com/ucasterisk/oslec.html[OSLEC] is an
234 Open Source Line Echo Canceller. It is currently in the staging subtree
235 of the mainline kernel and will hopefully be fully merged at around
236 version 2.6.29. The echo canceller module dahdi_echocan_oslec
237 provides a DAHDI echo canceller module that uses the code from OSLEC. As
238 OSLEC has not been accepted into mainline yet, its interface is not set
239 in stone and thus this driver may need to change. Thus it is not
240 built by default.
241
242 Luckily the structure of the dahdi-linux tree matches that of the kernel
243 tree. Hence you can basically copy drivers/staging/echo and place it
244 under driver/staging/echo . In fact, dahdi_echocan_oslec assumes that
245 this is where the oslec code lies. If it is elsewhere you'll need to fix
246 the #include line.
247
248 Thus for the moment, the simplest way to build OSLEC with dahdi is to
249 copy the directory `drivers/staging/echo` from a recent kernel tree (at
250 least 2.6.28-rc1) to the a subdirectory with the same name in the
251 dahdi-linux tree.
252
253 After doing that, you'll see the following when building (running
254 'make')
255
256 ...
257 CC [M] /home/tzafrir/dahdi-linux/drivers/dahdi/dahdi_echocan_oslec.o
258 CC [M] /home/tzafrir/dahdi-linux/drivers/dahdi/../staging/echo/echo.o
259 ...
260
261 As this is an experimental driver, problems building and using it should
262 be reported on the
263 https://lists.sourceforge.net/lists/listinfo/freetel-oslec[OSLEC mailing
264 list].
265
266 Alternatively you can also get the OSLEC code from the dahdi-linux-extra
267 GIT repository:
268
269 git clone git://gitorious.org/dahdi-extra/dahdi-linux-extra.git
270 cd dahdi-linux-extra
271 git archive extra-2.6 drivers/staging | (cd ..; tar xf -)
272 cd ..; rm -rf dahdi-linux-extra
273
274
275 Live Install
276 ~~~~~~~~~~~~
277 In many cases you already have DAHDI installed on your system but would
278 like to try a different version. E.g. in order to check if the latest
279 version fixes a bug that your current system happens to have.
280
281 DAHDI-linux includes a script to automate the task of installing DAHDI
282 to a subtree and using it instead of the system copy. Module loading
283 through modprobe cannot be used. Thus the script pre-loads the required
284 modules with insmod (which requires some quesswork as for which modules
285 to load). It also sets PATH and other environment variables to make all
286 the commands do the right thing.
287
288 There is an extra mode of operation to copy all the required files to a
289 remote host and run things there, for those who don't like to test code
290 on thir build system.
291
292 Live Install: The Basics
293 ^^^^^^^^^^^^^^^^^^^^^^^^
294 Basic operation is through running
295
296 ./build_tools/live_dahdi
297
298 from the root directory of the dahdi-linux tree. Using DAHDI requires
299 dahdi-tools as well, and the script builds and installs dahdi-tools. By
300 default it assumes the tree of dahdi-tools is in the directory
301 'dahdi-tools' alongside the dahdi-linux tree. If you want to checkout
302 the trunks from SVN, use:
303
304 svn checkout http://svn.asterisk.org/svn/dahdi/linux/trunk dahdi-linux
305 svn checkout http://svn.asterisk.org/svn/dahdi/tools/trunk dahdi-tools
306 cd dahdi-linux
307
308 If the tools directory resides elsewhere, you'll need to edit
309 live/live.conf (see later on). The usage message of live_dahdi:
310
311 Usage: equivalent of:
312 live_dahdi configure ./configure
313 live_dahdi install make install
314 live_dahdi config make config
315 live_dahdi unload /etc/init.d/dahdi stop
316 live_dahdi load /etc/init.d/dahdi start
317 live_dahdi reload /etc/init.d/dahdi restart
318 live_dahdi xpp-firm (Reset and load xpp firmware)
319 live_dahdi rsync TARGET (copy filea to /tmp/live in host TARGET)
320 live_dahdi exec COMMAND (Run COMMAND in 'live' environment)
321
322 Normally you should run:
323
324 ./build_tools/live_dahdi configure
325 ./build_tools/live_dahdi install
326 ./build_tools/live_dahdi config
327
328 to build and install everything. Up until now no real change was done.
329 This could actually be run by a non-root user. All files are installed
330 under the subdirectory live/ .
331
332 Reloading the modules (and restarting Asterisk) is done by:
333
334 ./build_tools/live_dahdi reload
335
336 Note: this stops Asterisk, unloads the DAHDI modules, loads the DAHDI
337 modules from the live/ subdirectory, configures the system and re-starts
338 Asterisk. This *can* do damage to your system. Furthermore, the DAHDI
339 configuration is generated by dahdi_genconf. It can be influenced by
340 a genconf_parameters file. But it may or may not be what you want.
341
342 If you want to run a command in the environment of the live system, use
343 the command 'exec':
344
345 ./build_tools/live_dahdi lsdahdi
346 ./build_tools/live_dahdi dahdi_hardware -v
347
348 Note however:
349
350 ./build_tools/live_dahdi dahdi_cfg -c live/etc/dahdi/system.conf
351
352 Live Install Remote
353 ^^^^^^^^^^^^^^^^^^^
354 As mentioned above, live_dahdi can also copy all the live system files
355 to a remote system and run from there. This requires rsync installed on
356 both system and assumes you can connect to the remove system through
357 ssh.
358
359 tzafrir@hilbert $ ./build_tools/live_dahdi rsync root@david
360 root@david's password:
361 <f+++++++++ live_dahdi
362 cd+++++++++ live/
363 <f+++++++++ live/live.conf
364 cd+++++++++ live/dev/
365 cd+++++++++ live/dev/dahdi/
366 cd+++++++++ live/etc/
367 cd+++++++++ live/etc/asterisk/
368 cd+++++++++ live/etc/dahdi/
369 <f+++++++++ live/etc/dahdi/genconf_parameters
370 <f+++++++++ live/etc/dahdi/init.conf
371 ...
372
373 As you can see, it copies the script itselfand the whole live/
374 subdirectory. The target directory is /tmp/live on the target directory
375 (changing it should probably be simple, but I never needed that).
376
377 Then, on the remove computer:
378
379 root@david:/tmp# ./live_dahdi reload
380
381
382 Configuring a Live Install
383 ^^^^^^^^^^^^^^^^^^^^^^^^^^
384 The live_dahdi script reads a configuration file in 'live/live.conf' if
385 it exists. This file has the format of a shell script snippet:
386
387 var1=value # a '#' sign begins a comment
388 var2='value'
389
390 # comments and empty lines are ignored
391 var3="value"
392
393 The variables below can also be overriden from the environment:
394
395 var1='value' ./build_tools/live_dahdi
396
397 ===== LINUX_DIR
398 The relative path to the dahdi-linux tree. The default is '.' and normally
399 there's no reason to override it.
400
401 ===== TOOLS_DIR
402 The relative path to the dahdi-tools tree. The default is 'dahdi-tools'.
403
404 ===== XPP_SYNC
405 Set a syncing astribank. See xpp_sync(8). Default is 'auto'.
406
407 ===== AST_SCRIPT
408 The command for an init.d script to start/stop Asterisk. Should accept
409 'start' and 'stop' commands. Use 'true' if you want to make that a
410 no-op. Defaults to '/etc/init.d/asterisk' .
411
412 ===== MODULES_LOAD
413 Manual list of modules. They will be loaded by insmod. If reside in a
414 subdir, add it explicitly. Modules for the drivers that are detected on
415 the system will be added by the script. Default: 'dahdi
416 dahdi_echocan_mg2'
417
418 ===== REMOVE_MODULES
419 A list of modules to remove when unloading. Will be resolved
420 recursively. The default is 'dahdi'. You may also want to have 'oslec'
421 or 'hpec' there if you use them.
422
423 ===== KVERS
424 If you want to build DAHDI for a different kernel version than the one
425 currently running on the system (mostly useful for a remote install).
426 Note that you will normally need to export this, in order for this to
427 take effect on the 'make' command. In live/live.conf itself have the line:
428
429 export KVERS="2.6.39-local"
430
431 ===== KSRC
432 Alternatively, if you want to point to an exact kernel source tree,
433 set it with KSRC. Just like KVERS above, it needs to be explicitly exported.
434
435 export KSRC="/usr/src/tree/linux"
436
437
438 Module Parameters
439 -----------------
440 The kernel modules can be configured through module parameters. Module
441 parameters can optionally be set at load time. They are normally set (if
442 needed) by a line in a file under /etc/modprobe.d/ or in the file
443 /etc/modprobe.conf.
444
445 Example line:
446
447 options dahdi debug=1
448
449 The module parameters can normally be modified at runtime through sysfs:
450
451 pungenday:~# cat /sys/module/dahdi/parameters/debug
452 0
453 pungenday:~# echo 1 >/sys/module/dahdi/parameters/debug
454 pungenday:~# cat /sys/module/dahdi/parameters/debug
455 1
456
457 Viewing and setting parameters that way is possible as of kernel 2.6 .
458 In kernels older than 2.6.10, the sysfs "files" for the parameters
459 reside directly under /sys/module/'module_name' .
460
461 Useful module parameters:
462
463 === debug
464 (most modules)
465
466 Sets debug mode / debug level. With most modules 'debug' can be either
467 disabled (0, the default value) or enabled (any other value).
468
469 wctdm and wcte1xp print several extra debugging messages if the value
470 of debug is more than 1.
471
472 Some modules have "debugging flags" bits - the value of debug is a
473 bitmask and several messages are printed if some bits are set:
474
475 To get a list of parameters supported by a module, use
476
477 modinfo module_name
478
479 Or, for a module you have just built:
480
481 modinfo ./drivers/dahdi/module_name.ko
482
483 For the xpp modules this will also include the description and default
484 value of the module. You can find a list of useful xpp module parameters
485 in README.Astribank .
486
487
488 - wctdm24xxp:
489 * 1: DEBUG_CARD
490 * 2: DEBUG_ECHOCAN
491 - wct4xxp:
492 * 1: DEBUG_MAIN
493 * 2: DEBUG_DTMF
494 * 4: DEBUG_REGS
495 * 8: DEBUG_TSI
496 * 16: DEBUG_ECHOCAN
497 * 32: DEBUG_RBS
498 * 64: DEBUG_FRAMER
499 - xpp: See also README.Astribank:
500 * 1: GENERAL - General debug comments.
501 * 2: PCM - PCM-related messages. Tend to flood logs.
502 * 4: LEDS - Anything related to the LEDs status control. The driver
503 produces a lot of messages when the option is enabled.
504 * 8: SYNC - Synchronization related messages.
505 * 16: SIGNAL - DAHDI signalling related messages.
506 * 32: PROC - Messages related to the procfs interface.
507 * 64: REGS - Reading and writing to chip registers. Tends to flood
508 logs.
509 * 128: DEVICES - Device instantiation, destruction and such.
510 * 256 - COMMANDS - Protocol commands. Tends to flood logs.
511 +
512 +
513 The script xpp_debug in the source tree can help settting them at run
514 time.
515
516 === deftaps
517 (dahdi)
518
519 The default size for the echo canceller. The number is in "taps", that
520 is "samples", 1/8 ms. The default is 64 - for a tail size of 8 ms.
521
522 Asterisk's chan_dahdi tends to pass its own value anyway, with a
523 different default size. So normally setting this doesn't change
524 anything.
525
526 === max_pseudo_channels
527 (dahdi)
528
529 The maximum number of pseudo channels that dahdi will allow userspace to
530 create. Pseudo channels are used when conferencing channels together.
531 The default is 512.
532
533 === auto_assign_spans
534 (dahdi)
535
536 See <<_span_assignments,Span Assignments>> below.
537
538 XPP (Astribank) module parameters
539 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
540 ==== debug
541 (all modules) - see above.
542
543 ==== dahdi_autoreg
544 (xpp)
545
546 Deprecated. See dahdi.<<_auto_assign_spans,auto_assign_spans>> above.
547
548 Originally had a somewhat similar (but xpp-specific and more limited)
549 role to auto_assign_spans. For backward compatibility this variable is
550 still kept, but its value is unused. Astribanks will auto-register
551 with dahdi if auto_assign_spans is not set.
552
553 ==== tools_rootdir
554 (xpp)
555
556 Defaults to /. Passed (as the variable DAHDI_TOOLS_ROOTDIR) to generated
557 events (which can be used in udev hooks). Also serves as the base of
558 the variable DAHDI_INIT_DIR (by default: $DAHDI_TOOLS_DIR/usr/share/dahdi).
559
560 ==== initdir
561 (xpp)
562
563 Deprecated. Setting both initdir and tools_rootdir will generate an error.
564
565 A directory under tools_rootdir containing the initialization scripts.
566 The default is /usr/share/dahdi .
567 Setting this value could be useful if that location is inconvenient for you.
568
569 ==== rx_tasklet
570 (xpp)
571
572 Enable (1) or disable (0) doing most of the packets processing in
573 separate tasklets. This should probably help on higher-end systems with
574 multiple Astribanks.
575
576 ==== vmwi_ioctl
577 (xpd_fxs)
578
579 Does userspace support VMWI notification via ioctl? Default: 1 (yes).
580
581 Disable this (0) to have the driver attempt to detect the voicemail
582 message waiting indication status for this port from FSK messages
583 userspace (Asterisk) sends. Set the ports to use AC neon-lamp style
584 message waiting indication. The detection from the FSK messages takes
585 extra CPU cycles but is required with e.g. Asterisk < 1.6.0 .
586
587 Also note that in order for this parameter to take effect, it must be
588 set before the span is registered. This practically means that it
589 should be set through modprobe.d files.
590
591 See also Voicemail Indication in README.Astribank.
592
593 ==== usb1
594 (xpp_usb)
595
596 Enable (1) or disable (0) support of USB1 devices. Disabled by default.
597
598 USB1 devices are not well-tested. It seems that they don't work at all
599 for Astribank BRI. Generally they should work with the current code, but
600 we expect the voice quality issues. Hence we would like to make it
601 very clear that you if you have a USB1 port (rather than a USB2 one, as
602 recommended) you will have to take an action to enable the device.
603
604 ==== poll intervals
605 (various)
606
607 There are various values which the driver occasionally polls the
608 device for. For instance, the parameter poll_battery_interval for
609 xpd_fxo to poll the battery, in order to know if the telco line is
610 actually connected.
611
612 The value of those parameters is typically a number in milliseconds.
613 0 is used to disable polling. Under normal operation there should be
614 no reason to play with those parameters.
615
616 ==== dtmf_detection
617 (xpd_fxs)
618
619 Enable (1) or disable (0) support of hardware DTMF detection by the
620 Astribank.
621
622 ==== caller_id_style
623 (xpd_fxo)
624
625 Various types of caller ID signalling styles require knowing the PCM
626 even when the line is on-hook (which is usually a waste of CPU and
627 bandwidth). This parameter allows fine-tuning the behaviour here:
628
629 * 0 (default) - Don't pass extra PCM when on-hook.
630 * 1 ETSI-FSK: Wait for polarity reversal to come before a ring and
631 then start passing PCM until the caller ID has been passed.
632 * 2 ETSI-DTMF: Always pass PCM and generate a DTMF if polarity reversal is
633 detected before ring.
634 * 3 Passthrough: Always pass PCM as-is.
635
636 This parameter is read-only. It cannot be changed at run-time.
637
638 ==== battery_threshold
639 (xpd_fxo)
640
641 Minimum voltage that shows there is battery. Defaults to 3. Normally you
642 should not need to change this, unless dealing with a funky PSTN
643 provider.
644
645 ==== battery_debounce
646 (xpd_fxo)
647
648 Minimum interval (msec) for detection of battery off (as opposed to e.g.
649 a temporary power denial to signal a hangup). Defaults to 1000. As with
650 battery_threshold above, there's normally no need to tweak it.
651
652 ==== use_polrev_firmware
653 (xpd_fxo)
654
655 Enable (1, default) or disable (0) support for polarity reversal
656 detection in the hardware. Only has effect with PIC_TYPE_2.hex rev. >=
657 11039 and with the initialization changes (init_card_2_30) in rev.
658 949aa49.
659
660 This parameter is read-only. It cannot be changed at run-time.
661
662
663 Internals
664 ---------
665 DAHDI Device Files
666 ~~~~~~~~~~~~~~~~~~
667 Userspace programs will usually interact with DAHDI through device
668 files under the /dev/dahdi directory (pedantically: character device files
669 with major number 196) . Those device files can be generated statically
670 or dynamically through the udev system.
671
672 * /dev/dahdi/ctl (196:0) - a general device file for various information and
673 control operations on the DAHDI channels.
674 * /dev/dahdi/chan/N/M - A device file for channel M in span N
675 - Both N and M are zero padded 3 digit numbers
676 - Both N and M start at 001
677 - M is chanpos - numbering relative to the current span.
678 * /dev/dahdi/NNN (196:NNN) - for NNN in the range 1-249. A device file for
679 DAHDI channel NNN. It can be used to read data from the channel
680 and write data to the channel. It is not generated by default but may
681 be generated as a symlink using udev rules.
682 * /dev/dahdi/transcode (196:250) - Used to connect to a DAHDI transcoding
683 device.
684 * /dev/dahdi/timer (196:253) - Allows setting timers. Used anywhere?
685 * /dev/dahdi/channel (196:254) - Can be used to open an arbitrary DAHDI
686 channel. This is an alternative to /dev/dahdi/NNN that is not limited to
687 249 channels.
688 * /dev/dahdi/pseudo (196:255) - A timing-only device. Every time you open
689 it, a new DAHDI channel is created. That DAHDI channel is "pseudo" -
690 DAHDI receives no data in it, and only sends garbage data with the
691 same timing as the DAHDI timing master device.
692
693
694 DAHDI Timing
695 ~~~~~~~~~~~~
696 A PBX system should generally have a single clock. If you are connected to a
697 telephony provider via a digital interface (e.g: E1, T1) you should also
698 typically use the provider's clock (as you get through the interface). Hence
699 one important job of Asterisk is to provide timing to the PBX.
700
701 DAHDI "ticks" once per millisecond (1000 times per second). On each tick every
702 active DAHDI channel reads and 8 bytes of data. Asterisk also uses this for
703 timing, through a DAHDI pseudo channel it opens.
704
705 However, not all PBX systems are connected to a telephony provider via a T1 or
706 similar connection. With an analog connection you are not synced to the other
707 party. And some systems don't have DAHDI hardware at all. Even a digital card
708 may be used for other uses or is simply not connected to a provider. DAHDI
709 cards are also capable of providing timing from a clock on card. Cheap x100P
710 clone cards are sometimes used for that purpose.
711
712 If a hardware timing source either cannot be found or stops providing timing
713 during runtime, DAHDI will automatically use the host timer in order provide
714 timing.
715
716 You can check the DAHDI timing source with dahdi_test, which is a small
717 utility that is included with DAHDI. It runs in cycles. In each such cycle it
718 tries to read 8192 bytes, and sees how long it takes. If DAHDI is not loaded
719 or you don't have the device files, it will fail immediately. If you lack a
720 timing device it will hang forever in the first cycle. Otherwise it will just
721 give you in each cycle the percent of how close it was. Also try running it
722 with the option -v for a verbose output.
723
724
725 Spans and Channels
726 ~~~~~~~~~~~~~~~~~~
727 DAHDI provides telephony *channels* to the userspace applications.
728 Those channels are channels are incorporated into logical units called
729 *spans*.
730
731 With digital telephony adapters (e.g: E1 or T1), a span normally
732 represents a single port. With analog telephony a span typically
733 represents a PCI adapter or a similar logical unit.
734
735 Both channels and spans are identified by enumerating numbers (beginning
736 with 1). The number of the channel is the lowest unused one when it is
737 generated, and ditto for spans.
738
739 There are up to 128 spans and 1024 channels. This is a hard-wired limit
740 (see dahdi/user.h . Several places throuout the code assume a channel
741 number fits in a 16 bits number). Channel and span numbers start at 1.
742
743
744 Span Assignments
745 ~~~~~~~~~~~~~~~~
746 A DAHDI device (e.g. a PCI card) is represented within the DAHDI drivers
747 as a 'DAHDI device'. Normally (with auto_assign_spans=1 in the module
748 dahdi, which is the default), when a device is discovered and loaded,
749 it registers with the DAHDI core and its spans automatically become
750 available. However if you have more than one device, you may be
751 interested to set explicit spans and channels numbers for them. To use
752 manual span assigment, set 'auto_assign_spans' to 0 . e.g. in a file
753 under /etc/modprobe.d/ include the following line:
754
755 options dahdi auto_assign_spans=0
756
757 You will then need to assign the spans manually at device startup. You
758 will need to assign a span number and channel numbers for each
759 available span on the system. On my test system I have one BRI PCI card
760 and one Astribank BRI+FXS:
761
762 # grep . /sys/bus/dahdi_devices/devices/*/spantype
763 /sys/bus/dahdi_devices/devices/astribanks:xbus-00/spantype:1:BRI
764 /sys/bus/dahdi_devices/devices/astribanks:xbus-00/spantype:2:BRI
765 /sys/bus/dahdi_devices/devices/astribanks:xbus-00/spantype:3:BRI
766 /sys/bus/dahdi_devices/devices/astribanks:xbus-00/spantype:4:BRI
767 /sys/bus/dahdi_devices/devices/astribanks:xbus-00/spantype:5:BRI
768 /sys/bus/dahdi_devices/devices/astribanks:xbus-00/spantype:6:BRI
769 /sys/bus/dahdi_devices/devices/astribanks:xbus-00/spantype:7:BRI
770 /sys/bus/dahdi_devices/devices/astribanks:xbus-00/spantype:8:BRI
771 /sys/bus/dahdi_devices/devices/astribanks:xbus-00/spantype:9:FXS
772 /sys/bus/dahdi_devices/devices/pci:0000:00:09.0/spantype:1:TE
773 /sys/bus/dahdi_devices/devices/pci:0000:00:09.0/spantype:2:TE
774 /sys/bus/dahdi_devices/devices/pci:0000:00:09.0/spantype:3:NT
775 /sys/bus/dahdi_devices/devices/pci:0000:00:09.0/spantype:4:NT
776
777 All spans here, except the FXS one, are BRI spans with 3 channels per span.
778
779 In order to assign a span, we write three numbers separated by colns to
780 the file 'assign_span' in the SysFS node
781
782 local_num:span_num:base_chan_num
783
784 Thus:
785
786 echo 9:5:10 >/sys/bus/dahdi_devices/devices/astribanks:xbus-00/assign_span
787 echo 2:8:40 >/sys/bus/dahdi_devices/devices/pci:0000:00:09.0/assign_span
788 echo 1:1:1 >/sys/bus/dahdi_devices/devices/astribanks:xbus-00/assign_span
789 echo 4:6:20 >/sys/bus/dahdi_devices/devices/pci:0000:00:09.0/assign_span
790 echo 3:2:5 >/sys/bus/dahdi_devices/devices/astribanks:xbus-00/assign_span
791
792 As you can see, the order of span numbers or local span number is
793 insignificant. However the order of channel numbers must be the same as
794 that of span numbers.
795
796 Which indeed produced:
797
798 # head -n3 -q /proc/dahdi/*
799 Span 1: XBUS-00/XPD-00 "Xorcom XPD [usb:LAB-0003].1: BRI_NT"
800
801 1 XPP_BRI_NT/00/00/0
802 Span 2: XBUS-00/XPD-02 "Xorcom XPD [usb:LAB-0003].3: BRI_TE"
803
804 5 XPP_BRI_TE/00/02/0
805 Span 5: XBUS-00/XPD-10 "Xorcom XPD [usb:LAB-0003].9: FXS" (MASTER)
806
807 10 XPP_FXS/00/10/0
808 Span 6: B4/0/4 "B4XXP (PCI) Card 0 Span 4" RED
809
810 23 B4/0/4/1 YELLOW
811 Span 8: B4/0/2 "B4XXP (PCI) Card 0 Span 2" RED
812
813 40 B4/0/2/1 RED
814
815 Likewise spans can be unassigned by writing to the 'unassign-span'
816 "file".
817
818
819 Dynamic Spans
820 ~~~~~~~~~~~~~
821 Dynamic spans are spans that are not represented by real hardware.
822 Currently there are two types of them:
823
824 tdmoe::
825 TDM over Ethernet. A remote span is identified by an ethernet (MAC)
826 address.
827
828 local::
829 Generates a span that is actually a loopback to a different local
830 span.
831
832 Modules that support the dynamic spans are typically loaded at the time
833 the ioctl DAHDI_DYNAMIC_CREATE is called. This is typically called by
834 dahdi_cfg when it has a line such as:
835
836 dynamic,somename,params
837
838 in /etc/dahdi/system.conf . In that case it will typically try to load
839 (through modprobe) the modules dahdi_dynamic and
840 dahdi_dynamic_'somename'. It will then pass 'params' to it.
841
842 Dynamic spans are known to be tricky and are some of the least-tested
843 parts of DAHDI.
844
845
846 Echo Cancellers
847 ~~~~~~~~~~~~~~~
848 (To be documented later)
849
850
851 Tone Zones
852 ~~~~~~~~~~
853 (To be documented later)
854
855
856 PROCFS Interface: /proc/dahdi
857 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
858 A simple way to get the current list of spans and channels each span contains
859 is the files under /proc/dahdi . /proc/dahdi is generated by DAHDI as it
860 loads. As each span registers to DAHDI, a file under /proc/dahdi is created
861 for it. The name of that file is the number of that span.
862
863 Each file has a 1-line title for the span followed by a few optional
864 general counter lines, an empty line and then a line for each channel of
865 the span.
866
867 The title line shows the number of the span, its name and title, and
868 (potentially) the alarms in which it is.
869
870 The title shows the span number and name, followed by any alarms the
871 span may have: For example, here is the first span in my system (with no
872 alarms):
873
874 Span 1: XBUS-00/XPD-00 "Xorcom XPD #0/0: FXS"
875
876 There are several extra optional keywords that may be added there:
877
878 (Master)::
879 This span is the master span. See <<_dahdi_timing,DAHDI Timing>>.
880 ClockSource::
881 The clock source among several spans that belong to a single E1/J1/T1
882 card.
883 RED/YELLOW/RED/NOTOPEN/LOOP/RECOVERING::
884 The span is in alarm
885
886 Following that line there may be some optional lines about IRQ misses,
887 timing slips and such, if there are any.
888
889 The channel line for each channel shows its channel number, name and the
890 actual signalling assigned to it through dahdi_cfg. Before being configured by
891 dahdi_cfg: This is DAHDI channel 2, whose name is 'XPP_FXS/0/0/1'.
892
893 2 XPP_FXS/0/0/1
894
895 After being configured by dahdi_cfg: the signalling 'FXOLS' was added. FXS
896 channels have FXO signalling and vice versa:
897
898 2 XPP_FXS/0/0/1 FXOLS
899
900 If the channel is in use (typically opened by Asterisk) then you will
901 see an extra '(In use)':
902
903 2 XPP_FXS/0/0/1 FXOLS (In use)
904
905
906 SysFS Interface
907 ~~~~~~~~~~~~~~~
908 DAHDI exposes several interfaces under the SysFS virtual file system.
909 SysFS represents kernel objects in nodes - directories. There properties
910 are often files. They may also contain other nodes or include symlinks
911 to other nodes.
912
913 Class DAHDI
914 ^^^^^^^^^^^
915 Under /sys/class/dadhi there exists a node for the non-channel DAHDI
916 device file under /dev/dahdi. The name is 'dahdi!foo' for the file
917 '/dev/dahdi/foo' (udev translates exclamation marks to slashes). Those
918 nodes are not, for the most part, proper SysFS nodes, and don't include
919 any interesting properties. The files in this class `ctl`, `timer`,
920 `channel`, `pseudo` and (if exists) `transcode`.
921
922
923 Devices Bus
924 ^^^^^^^^^^^
925 Each DAHDI device (a physical device, such as a PCI card) is represented
926 by a node under /sys/bus/dahdi_devices/devices named with the name of
927 its device.
928
929 Its attributes include:
930
931 ===== /sys/bus/dahdi_devices/devices/DEVICE/assgin-span
932 Write-only attribute: this device's spans should now be assigned
933 ("registered"). See section about <<_span_assignments>>.
934
935 ===== /sys/bus/dahdi_devices/devices/DEVICE/auto-assign
936 Write-only attribute. Spans in the device auto-assign ("register" as in
937 the original interface). See section about <<_span_assignments>>.
938
939 ===== /sys/bus/dahdi_devices/devices/DEVICE/hardware_id
940 A unique hardware-level identifier (e.g. serial number), if available.
941
942 ===== /sys/bus/dahdi_devices/devices/DEVICE/manufacturer
943 The name of the manufacturer. Freeform-string.
944
945 ===== /sys/bus/dahdi_devices/devices/DEVICE/registration_time
946 The time at which the device registered with the DAHDI core. Example
947 value: "0005634136.941901429".
948
949 ===== /sys/bus/dahdi_devices/devices/DEVICE/spantype
950 A line for each available span: <num>:<type>. This has to be provided
951 here as in the case of manual assignment, userspace may need to know
952 it before span nodes are created.
953
954 ===== /sys/bus/dahdi_devices/devices/DEVICE/spantype
955 Device type.
956
957 ===== /sys/bus/dahdi_devices/devices/DEVICE/unassign-span
958 Write-only attribute: the span whose device-local number is written
959 should now be unassigned ("unregistered"). See section about
960 <<_span_assignments>>.
961
962
963 Spans Bus
964 ^^^^^^^^^
965 Each DAHDI span is represented by a node under
966 /sys/bus/dahdi_spans/devices with the name 'span-N' (where N is the
967 number of the span). Spans of each device also reside under the node of
968 the device.
969
970 Useful attributes in the span node:
971
972 ===== /sys/bus/dahdi_spans/devices/span-N/alarms
973 The alarms of the span. Currently this is a numeric representation.
974 This may change in the future.
975
976 ===== /sys/bus/dahdi_spans/devices/span-N/basechan
977 The channel number of the first channel. The channel numbers of the
978 following channels are guaranteed to follow it.
979
980 ===== /sys/bus/dahdi_spans/devices/span-N/channels
981 The number of the channels in the span.
982
983 ===== /sys/bus/dahdi_spans/devices/span-N/desc
984 A free-form description of the span.
985
986 ===== /sys/bus/dahdi_spans/devices/span-N/is_digital
987 1 if the span is digital, 0 if it isn't.
988
989 ===== /sys/bus/dahdi_spans/devices/span-N/is_sync_master
990 1 if the span is the sync master, 0 if it isn't.
991
992 ===== /sys/bus/dahdi_spans/devices/span-N/lbo
993 LBO setting for the channel.
994
995 ===== /sys/bus/dahdi_spans/devices/span-N/lineconfig
996 The framing and coding of the span, for a digital span. Textual
997 represenation:
998
999 <B8ZS|AMI|HDB3>/<D4|ESF|CCS>[/CRC4]
1000
1001 ===== /sys/bus/dahdi_spans/devices/span-N/local_spanno
1002 The number of the span within the DAHDI device.
1003
1004 ===== /sys/bus/dahdi_spans/devices/span-N/name
1005 A concise name for this span.
1006
1007 ===== /sys/bus/dahdi_spans/devices/span-N/spantype
1008 A very short type string.
1009
1010 ===== /sys/bus/dahdi_spans/devices/span-N/syncsrc
1011 Current sync source.
1012
1013 ==== sys/bus/dahdi_spans/drivers/generic_lowlevel/master_span
1014 All spans in the bus are handled by a single driver. The driver has one
1015 non-standard attribute: master_span. printing it shows the current DAHDI
1016 master span writing a number to it forces setting this span as the master
1017 span.
1018
1019
1020 Channels Bus
1021 ^^^^^^^^^^^^
1022 Each DAHDI channel is represented by a node under
1023 /sys/bus/dahdi_channels/devices with the name 'dahdi!channels!N!M'
1024 (where N is the number of the span and M is the number of the channel
1025 in the span - chanpos). Channels of each span also reside under the node
1026 of the span.
1027
1028 Useful attributes in the channel node (All attributed listed below are
1029 read-only):
1030
1031 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/alarms
1032 List of names of the current active alarms (space separated). Normally
1033 (no alarms) empty. Example:
1034
1035 RED YELLOW
1036
1037 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/blocksize
1038 The block size set by userspace.
1039
1040 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/channo
1041 The (global) channel number.
1042
1043 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/chanpos
1044 The channel number within the span.
1045
1046 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/dev
1047 Major and minor device numbers.
1048
1049 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/ec_factory
1050 The name of the echo canceller to be used in the channel, if one is
1051 configured. Example:
1052
1053 MG2
1054
1055 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/ec_state
1056 State of the echo canceller. ACTIVE: configured and inuse. INACTIVE
1057 otherwise.
1058
1059 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/in_use
1060 1 if the channel is in use (was opepend by userspace), 0 otherwise.
1061
1062 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/name
1063 A name string for the channel
1064
1065 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/sig
1066 The signalling types set for the channel. A space-separated list of
1067 signalling types.
1068
1069 ===== /sys/bus/dahdi_spans/devices/span-N/dahdi!channels!N!M/sigcap
1070 The signalling types this channel may be configured to handle. A space-
1071 separated list of signalling types.
1072
1073
1074 User-space Interface
1075 ~~~~~~~~~~~~~~~~~~~~
1076 User-space programs can only work with DAHDI channels. The basic
1077 operation is 'read()' to read audio from the device and write() to write
1078 audio to it. Audio can be encoded as either alaw (G.711a) or (m)ulaw
1079 (G.711u). See the ioctl DAHDI_SETLAW.
1080
1081 While it is technically possible to use /dev/dahdi/NUMBER directly, this
1082 will only work for channel numbers up to 249. Generally you should use:
1083
1084 int channo = CHAN_NUMBER_TO_OPEN;
1085 int rc;
1086 int fd = open("/dev/dahdi/channel", O_RDRW, 0600);
1087 // Make sure fd >= 0
1088 rc = ioctl(fd, DAHDI_SPECIFY, &channo) < 0);
1089 // Make sure this rc >= 0
1090
1091 FIXME: there's more to tell about the user-space interface.
1092
1093
1094 Configuration
1095 ~~~~~~~~~~~~~
1096 Most of the configuration is applied from userspace using the tool
1097 'dahdi_cfg' in the package dahdi_tools. This section will not cover the
1098 specifics of that file. Rather it will cover the way configuration from
1099 this file is applied. Also note that there are other methods to
1100 configure DAHDI drivers: there are <<_module_parameters,Module
1101 Parameters>>. The xpp driver have their own separate initialization
1102 scripts and xpp.conf that arecovered in README.Astribank.
1103
1104 When a span is registered, it is considered "unconfigured". Only after
1105 dahdi_cfg has been run to apply configuration, the span is ready to run.
1106
1107 Some of the configuration is handled by the DAHDI core. Some of it is
1108 handled by callbacks, which are function pointers in the `struct
1109 dahdi_span': 'spanconfig', 'chanconfig' and (in a way) 'startup'.
1110
1111 Dahdi_cfg starts by reading the configuration from the configuration
1112 file ('/etc/dahdi/system.conf', by default), and creating a local
1113 configuration to apply. If you use -v, at this stage it will pront the
1114 configuration that is "about to be configured". Then it will start to
1115 actually apply the configuration.
1116
1117 Before actually applying configuration, it destroys any existing
1118 <<_dynamic_spans,dynamic spans>> and generates new ones (if so
1119 configured. FIXME: what about running DAHDI_SPANCONFIG for new dynamic
1120 spans?).
1121
1122 Next thing it will do is apply the parameters from *span* lines using
1123 the ioctl DAHDI_SPANCONFIG. Some generic processing of parameters passed
1124 in DAHDI_SPANCONFIG is done in the DAHDI core, in the callback function
1125 spanconfig in , but most of it is left to 'spanconfig' callback of the
1126 span (if it exists. This one typically does not exists on analog cards).
1127
1128 Now dahdi_cfg will ask each existing channel for its existing
1129 configuration and apply configuration if configuration changes are
1130 needed. Configuration is applied to the channels using the ioctl call
1131 DAHDI_CHANCONFIG ioctl. As in the case of the span configuration, part
1132 of it is applied by the DAHDI core, and then it is handed over to the
1133 span's chanconfig callback. Typically all spans will have such a
1134 callback.
1135
1136 <<_echo_cancellers,Echo cancellers>> and <<_tone_zones,tone-zones>> are
1137 handled separately later.
1138
1139 Once everything is done, the ioctl DAHDI_STARTUP is called for every
1140 span. This is also translated to a call to the optional span callback
1141 'startup'.
1142
1143 Finally the ioctl DAHDI_HDLC_RATE is called for every channel (that is:
1144 if '56k' is not set for the channel, it will be explicitly set to the
1145 standard HDLC rate of 64k).
1146
1147
1148 Low-Level Drivers
1149 ~~~~~~~~~~~~~~~~~
1150 Low-level drivers create spans ('struct dahdi_span'). They register the
1151 spans with the DAHDI core using 'dahdi_device_register()'.
1152
1153 'struct dahdi_span' has a number of informative members that are updated
1154 solely by the low-level driver:
1155
1156 name::
1157 A concise span name. E.g.: Foo/1
1158 desc::
1159 A slightly longer span name.
1160 spantype::
1161 Span type in text form.
1162 manufacturer::
1163 Span's device manufacturer
1164 devicetype::
1165 Span's device type
1166 location::
1167 span device's location in system
1168 irq::
1169 IRQ for this span's hardware
1170 irqmisses::
1171 Interrupt misses
1172 timingslips::
1173 Clock slips
1174
1175 There are various function pointers in the struct 'dahdi_span' which are
1176 used by the DAHDI core to call the low-level driver. Most of them are
1177 optional.
1178
1179 The following apply to a span:
1180
1181 setchunksize::
1182 FIXME: seems to be unused.
1183
1184 spanconfig::
1185 Basic span configuration (called from dahdi_cfg).
1186
1187 startup::
1188 Last minute initialization after the configuration was applied.
1189
1190 shutdown::
1191 Explicit shutdown (e.g. for dynamic spans). Normally not needed.
1192
1193 maint::
1194 Enable/disable maintinance mode (FIXME: document).
1195
1196 sync_tick::
1197 Get notified that the master span has ticked.
1198
1199 The following apply to a single channel.
1200
1201 chanconfig::
1202 Configure the channel (called from dahdi_cfg).
1203
1204 open::
1205 Channel was opened for read/write from user-space.
1206
1207 close::
1208 Channel was closed by user-space.
1209
1210 ioctl::
1211 Handle extra ioctls. Should return -ENOTTY if ioctl is not known to
1212 the channel
1213
1214 echocan_create::
1215 Create a custom echo canceller. Normally used for providing a hardware
1216 echo canceller. If NULL, the standard DAHDI echo canceller modules
1217 will be used.
1218
1219 rbsbits::
1220 Copy signalling bits to device. See below on signalling.
1221
1222 hooksig::
1223 Implement RBS-like signalling-handling. See below on signalling.
1224
1225 sethook::
1226 Handle signalling yourself. See below on signalling.
1227
1228 hdlc_hard_xmit::
1229 Used to tell an onboard HDLC controller that there is data ready to
1230 transmit.
1231
1232 audio_notify::
1233 (if DAHDI_AUDIO_NOTIFY is set) - be notified when the channel is (or
1234 isn't) in audio mode. Which may mean (for an ISDN B-channel) that its
1235 data need not be sent.
1236
1237 There are several alternative methods for a span to use for
1238 signalling. One of them should be used.
1239
1240 Signalling: rbsbits
1241 ^^^^^^^^^^^^^^^^^^^
1242 If the device is a CAS interface, the driver should copy the signalling
1243 bits to and from the other side, and DAHDI will handle the signalling.
1244 The driver just need to provide a 'rbsbits' and set DAHDI_FLAG_RBS in
1245 the span->flags.
1246
1247 Note that 'rbs' (Robed Bits Signalling) here merely refers to the (up
1248 to) 4 signalling bits of the channel. In T1 they are transmitted by
1249 "robbing" bits from the channels and hence the name. In E1 they are
1250 transmitted in a timeframe of their own.
1251
1252 The driver should then signal a change in the signalling bits in a
1253 channel using dahdi_rbsbits().
1254
1255
1256 Signalling: hooksig
1257 ^^^^^^^^^^^^^^^^^^^
1258 If the device does not know about signalling bits, but has their
1259 equivalents (i.e. can disconnect battery, detect off hook, generate
1260 ring, etc directly) then the driver can specify a 'sethook' function and
1261 set DAHDI_FLAG_RBS in span->flags. In that case DAHDI will call that
1262 function whenever the signalling state changes.
1263
1264 The hooksig function is only used if the rbsbits function is not set.
1265
1266 The span should notify DAHDI of a change of signalling in a channel using
1267 dahdi_hooksig().
1268
1269
1270 Signalling: sethook
1271 ^^^^^^^^^^^^^^^^^^^
1272 Alternatively, if DAHDI_FLAG_RBS is not set in the flags of the span (to
1273 use either rbsbits or hooksig), the DAHDI core will try to call the
1274 'sethook' function of the span (if it exists) to handle individual hook
1275 states.
1276
1277 The span should then notify DAHDI of a change in the signalling state
1278 using dahdi_sethook().
1279
1280 FIXME: anybody using this one?
1281
1282
1283 ABI Compatibility
1284 ~~~~~~~~~~~~~~~~~
1285 Like any other kernel code, DAHDI strives to maintain a stable interface to
1286 userspace programs. The API of DAHDI to userspace programs, dahdi/user.h, has
1287 remained backward-compatible for a long time and is expected to remain so in
1288 the future. With the ABI (the bits themselves) things are slightly trickier.
1289
1290 DAHDI's interface to userspace is mostly ioctl(3) calls. Ioctl calls
1291 are identified by a number that stems from various things, one of which
1292 is the size of the data structure passed between the kernel and
1293 userspace.
1294
1295 Many of the DAHDI ioctl-s use some specific structs to pass information
1296 between kernel and userspace. In some cases the need arose to pass a few
1297 more data members in each call. Simply adding a new member to the struct
1298 would have meant a new number for the ioctl, as its number depends on
1299 the size of the data passed.
1300
1301 Thus we would add a new ioctl with the same base number and with the
1302 original struct.
1303
1304 So suppose we had the following ioctl:
1305 ----------------------------------
1306 struct dahdi_example {
1307 int sample;
1308 }
1309
1310 #define DAHDI_EXAMPLE _IOWR (DAHDI_CODE, 62, struct dahdi_example)
1311 ----------------------------------
1312
1313 And we want to add the field 'int onemore', we won't just add it to the
1314 struct. We will do something that is more complex:
1315 ------------------------------------
1316 /* The original, unchanged: */
1317 struct dahdi_example_v1 {
1318 int sample;
1319 }
1320
1321 /* The new struct: */
1322 struct dahdi_example {
1323 int sample;
1324 int onemore;
1325 }
1326
1327 #define DAHDI_EXAMPLE_V1 _IOWR(DAHDI_CODE, 62, struct dahdi_example_v1)
1328 #define DAHDI_EXAMPLE _IOWR(DAHDI_CODE, 62, struct dahdi_example)
1329 ------------------------------------
1330 We actually have here two different ioctls: the old DAHDI_EXAMPLE would be
1331 0xC004DA3E . DAHDI_EXAMPLE_V1 would have the same value. But the new value
1332 of DAHDI_EXAMPLE would be 0xC008DA3E .
1333
1334 Programs built with the original dahdi/user.h (before the change) use the
1335 original ioctl, whether or not the kernel code is actually of the newer
1336 version. Thus in most cases there are no compatibility issues.
1337
1338 When can we have compatibility issues? If we have code built with the new
1339 dahdi/user.h, but the loaded kernel code (modules) are of the older version.
1340 Thus the userspace program will try to use the newer DAHDI_EXAMPLE (0xC008DA3E).
1341 But the kernel code has no handler for that ioctl. The result: the error 25,
1342 ENOTTY, which means "Inappropriate ioctl for device".
1343
1344 As a by-product of that method, for each interface change a new #define is
1345 added. That definition is for the old version and thus it might appear
1346 slightly confusing in the code, but it is useful for writing code that works
1347 with all versions of DAHDI.
1348
1349 Past Incompatibilities
1350 ^^^^^^^^^^^^^^^^^^^^^^
1351 .DAHDI 2.3:
1352 DAHDI_SPANINFO_V1 (extra members added). This will typically only be
1353 used on ISDN (PRI/BRI) spans in Asterisk.
1354
1355 .DAHDI 2.2:
1356 * DAHDI_GET_PARAMS_V1, DAHDI_GETCONF_V1, DAHDI_SETCONF_V1,
1357 DAHDI_GETGAINS_V1 ('direction' changed from 'R' to 'RW' to fix
1358 FreeBSD support).
1359 * DAHDI_CONFDIAG_V1, DAHDI_CHANDIAG_V1 (fixed direction).
1360
1361
1362 Alarm Types
1363 ~~~~~~~~~~~
1364 An alarm indicates that a port is not available for some reason. Thus it
1365 is probably not a good idea to try to call out through it.
1366
1367
1368 Red Alarm
1369 ^^^^^^^^^
1370 Your T1/E1 port will go into red alarm when it cannot maintain
1371 synchronization with the remote switch. A red alarm typically
1372 indicates either a physical wiring problem, loss of connectivity, or a
1373 framing and/or line-coding mismatch with the remote switch. When your
1374 T1/E1 port loses sync, it will transmit a yellow alarm to the remote
1375 switch to indicate that it's having a problem receiving signal from
1376 the remote switch.
1377
1378 The easy way to remember this is that the R in red stands for "right
1379 here" and "receive"... indicating that we're having a problem right
1380 here receiving the signal from the remote switch.
1381
1382
1383 Yellow Alarm
1384 ^^^^^^^^^^^^
1385 (RAI -- Remote Alarm Indication)
1386
1387 Your T1/E1 port will go into yellow alarm when it receives a signal
1388 from the remote switch that the port on that remote switch is in red
1389 alarm. This essentially means that the remote switch is not able to
1390 maintain sync with you, or is not receiving your transmission.
1391
1392 The easy way to remember this is that the Y in yellow stands for
1393 "yonder"... indicating that the remote switch (over yonder) isn't able
1394 to see what you're sending.
1395
1396
1397 Blue Alarm
1398 ^^^^^^^^^^
1399 (AIS -- Alarm Indication Signal)
1400
1401 Your T1/E1 port will go into blue alarm when it receives all unframed
1402 1s on all timeslots from the remote switch. This is a special signal
1403 to indicate that the remote switch is having problems with its
1404 upstream connection. dahdi_tool and Asterisk don't correctly indicate
1405 a blue alarm at this time. The easy way to remember this is that
1406 streams are blue, so a blue alarm indicates a problem upstream from
1407 the switch you're connected to.
1408
1409
1410 Recovering from Alarm
1411 ^^^^^^^^^^^^^^^^^^^^^
1412 TODO: explain.
1413
1414
1415 Loopback
1416 ^^^^^^^^
1417 Not really an alarm. Indicates that a span is not available, as the port
1418 is in either a local or remote loopback mode.
1419
1420
1421 Not Open
1422 ^^^^^^^^
1423 Something is not connected. Used by e.g. the drivers of the Astribank to
1424 indicate a span that belongs to a device that has been disconnected
1425 but is still being used by userspace programs and thus can't e
1426 destroyed.
1427
1428
1429 License
1430 -------
1431 This package is distributed under the terms of the GNU General Public License
1432 Version 2, except for some components which are distributed under the terms of
1433 the GNU Lesser General Public License Version 2.1. Both licenses are included
1434 in this directory, and each file is clearly marked as to which license applies.
1435
1436 If you wish to use the DAHDI drivers in an application for which the license
1437 terms are not appropriate (e.g. a proprietary embedded system), licenses under
1438 more flexible terms can be readily obtained through Digium, Inc. at reasonable
1439 cost.
1440
1441 Known Issues
1442 ------------
1443
1444 KB1 does not function when echocancel > 128
1445 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1446 KB1 was not designed to function at greater than 128 taps, and if configured
1447 this way, will result in the destruction of audio. Ideally DAHDI would return
1448 an error when a KB1 echocanceller is configured with greater than 128 taps.
1449
1450
1451 Reporting Bugs
1452 --------------
1453 Please report bug and patches to the Asterisk bug tracker at
1454 http://issues.asterisk.org in the "DAHDI-linux" category.
1455
1456 Links
1457 -----
1458 - http://asterisk.org/[] - The Asterisk PBX
1459 - http://voip-info.org/[]
1460 - http://voip-info.org/wiki/view/DAHDI[]
1461 - http://docs.tzafrir.org.il/dahdi-linux/README.html[Up-to-date HTML version
1462 of this file]