README 51 KB

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