README 51 KB

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