farsync.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. /*
  2. * FarSync X21 driver for Linux
  3. *
  4. * Actually sync driver for X.21, V.35 and V.24 on FarSync T-series cards
  5. *
  6. * Copyright (C) 2001 FarSite Communications Ltd.
  7. * www.farsite.co.uk
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. *
  14. * Author: R.J.Dunlop <bob.dunlop@farsite.co.uk>
  15. *
  16. * For the most part this file only contains structures and information
  17. * that is visible to applications outside the driver. Shared memory
  18. * layout etc is internal to the driver and described within farsync.c.
  19. * Overlap exists in that the values used for some fields within the
  20. * ioctl interface extend into the cards firmware interface so values in
  21. * this file may not be changed arbitrarily.
  22. */
  23. /* What's in a name
  24. *
  25. * The project name for this driver is Oscar. The driver is intended to be
  26. * used with the FarSite T-Series cards (T2P & T4P) running in the high
  27. * speed frame shifter mode. This is sometimes referred to as X.21 mode
  28. * which is a complete misnomer as the card continues to support V.24 and
  29. * V.35 as well as X.21.
  30. *
  31. * A short common prefix is useful for routines within the driver to avoid
  32. * conflict with other similar drivers and I chosen to use "fst_" for this
  33. * purpose (FarSite T-series).
  34. *
  35. * Finally the device driver needs a short network interface name. Since
  36. * "hdlc" is already in use I've chosen the even less informative "sync"
  37. * for the present.
  38. */
  39. #define FST_NAME "fst" /* In debug/info etc */
  40. #define FST_NDEV_NAME "sync" /* For net interface */
  41. #define FST_DEV_NAME "farsync" /* For misc interfaces */
  42. /* User version number
  43. *
  44. * This version number is incremented with each official release of the
  45. * package and is a simplified number for normal user reference.
  46. * Individual files are tracked by the version control system and may
  47. * have individual versions (or IDs) that move much faster than the
  48. * the release version as individual updates are tracked.
  49. */
  50. #define FST_USER_VERSION "1.04"
  51. /* Ioctl call command values
  52. *
  53. * The first three private ioctls are used by the sync-PPP module,
  54. * allowing a little room for expansion we start our numbering at 10.
  55. */
  56. #define FSTWRITE (SIOCDEVPRIVATE+10)
  57. #define FSTCPURESET (SIOCDEVPRIVATE+11)
  58. #define FSTCPURELEASE (SIOCDEVPRIVATE+12)
  59. #define FSTGETCONF (SIOCDEVPRIVATE+13)
  60. #define FSTSETCONF (SIOCDEVPRIVATE+14)
  61. /* FSTWRITE
  62. *
  63. * Used to write a block of data (firmware etc) before the card is running
  64. */
  65. struct fstioc_write {
  66. unsigned int size;
  67. unsigned int offset;
  68. unsigned char data[0];
  69. };
  70. /* FSTCPURESET and FSTCPURELEASE
  71. *
  72. * These take no additional data.
  73. * FSTCPURESET forces the cards CPU into a reset state and holds it there.
  74. * FSTCPURELEASE releases the CPU from this reset state allowing it to run,
  75. * the reset vector should be setup before this ioctl is run.
  76. */
  77. /* FSTGETCONF and FSTSETCONF
  78. *
  79. * Get and set a card/ports configuration.
  80. * In order to allow selective setting of items and for the kernel to
  81. * indicate a partial status response the first field "valid" is a bitmask
  82. * indicating which other fields in the structure are valid.
  83. * Many of the field names in this structure match those used in the
  84. * firmware shared memory configuration interface and come originally from
  85. * the NT header file Smc.h
  86. *
  87. * When used with FSTGETCONF this structure should be zeroed before use.
  88. * This is to allow for possible future expansion when some of the fields
  89. * might be used to indicate a different (expanded) structure.
  90. */
  91. struct fstioc_info {
  92. unsigned int valid; /* Bits of structure that are valid */
  93. unsigned int nports; /* Number of serial ports */
  94. unsigned int type; /* Type index of card */
  95. unsigned int state; /* State of card */
  96. unsigned int index; /* Index of port ioctl was issued on */
  97. unsigned int smcFirmwareVersion;
  98. unsigned long kernelVersion; /* What Kernel version we are working with */
  99. unsigned short lineInterface; /* Physical interface type */
  100. unsigned char proto; /* Line protocol */
  101. unsigned char internalClock; /* 1 => internal clock, 0 => external */
  102. unsigned int lineSpeed; /* Speed in bps */
  103. unsigned int v24IpSts; /* V.24 control input status */
  104. unsigned int v24OpSts; /* V.24 control output status */
  105. unsigned short clockStatus; /* lsb: 0=> present, 1=> absent */
  106. unsigned short cableStatus; /* lsb: 0=> present, 1=> absent */
  107. unsigned short cardMode; /* lsb: LED id mode */
  108. unsigned short debug; /* Debug flags */
  109. unsigned char transparentMode; /* Not used always 0 */
  110. unsigned char invertClock; /* Invert clock feature for syncing */
  111. unsigned char startingSlot; /* Time slot to use for start of tx */
  112. unsigned char clockSource; /* External or internal */
  113. unsigned char framing; /* E1, T1 or J1 */
  114. unsigned char structure; /* unframed, double, crc4, f4, f12, */
  115. /* f24 f72 */
  116. unsigned char interface; /* rj48c or bnc */
  117. unsigned char coding; /* hdb3 b8zs */
  118. unsigned char lineBuildOut; /* 0, -7.5, -15, -22 */
  119. unsigned char equalizer; /* short or lon haul settings */
  120. unsigned char loopMode; /* various loopbacks */
  121. unsigned char range; /* cable lengths */
  122. unsigned char txBufferMode; /* tx elastic buffer depth */
  123. unsigned char rxBufferMode; /* rx elastic buffer depth */
  124. unsigned char losThreshold; /* Attenuation on LOS signal */
  125. unsigned char idleCode; /* Value to send as idle timeslot */
  126. unsigned int receiveBufferDelay; /* delay thro rx buffer timeslots */
  127. unsigned int framingErrorCount; /* framing errors */
  128. unsigned int codeViolationCount; /* code violations */
  129. unsigned int crcErrorCount; /* CRC errors */
  130. int lineAttenuation; /* in dB*/
  131. unsigned short lossOfSignal;
  132. unsigned short receiveRemoteAlarm;
  133. unsigned short alarmIndicationSignal;
  134. };
  135. /* "valid" bitmask */
  136. #define FSTVAL_NONE 0x00000000 /* Nothing valid (firmware not running).
  137. * Slight misnomer. In fact nports,
  138. * type, state and index will be set
  139. * based on hardware detected.
  140. */
  141. #define FSTVAL_OMODEM 0x0000001F /* First 5 bits correspond to the
  142. * output status bits defined for
  143. * v24OpSts
  144. */
  145. #define FSTVAL_SPEED 0x00000020 /* internalClock, lineSpeed, clockStatus
  146. */
  147. #define FSTVAL_CABLE 0x00000040 /* lineInterface, cableStatus */
  148. #define FSTVAL_IMODEM 0x00000080 /* v24IpSts */
  149. #define FSTVAL_CARD 0x00000100 /* nports, type, state, index,
  150. * smcFirmwareVersion
  151. */
  152. #define FSTVAL_PROTO 0x00000200 /* proto */
  153. #define FSTVAL_MODE 0x00000400 /* cardMode */
  154. #define FSTVAL_PHASE 0x00000800 /* Clock phase */
  155. #define FSTVAL_TE1 0x00001000 /* T1E1 Configuration */
  156. #define FSTVAL_DEBUG 0x80000000 /* debug */
  157. #define FSTVAL_ALL 0x00001FFF /* Note: does not include DEBUG flag */
  158. /* "type" */
  159. #define FST_TYPE_NONE 0 /* Probably should never happen */
  160. #define FST_TYPE_T2P 1 /* T2P X21 2 port card */
  161. #define FST_TYPE_T4P 2 /* T4P X21 4 port card */
  162. #define FST_TYPE_T1U 3 /* T1U X21 1 port card */
  163. #define FST_TYPE_T2U 4 /* T2U X21 2 port card */
  164. #define FST_TYPE_T4U 5 /* T4U X21 4 port card */
  165. #define FST_TYPE_TE1 6 /* T1E1 X21 1 port card */
  166. /* "family" */
  167. #define FST_FAMILY_TXP 0 /* T2P or T4P */
  168. #define FST_FAMILY_TXU 1 /* T1U or T2U or T4U */
  169. /* "state" */
  170. #define FST_UNINIT 0 /* Raw uninitialised state following
  171. * system startup */
  172. #define FST_RESET 1 /* Processor held in reset state */
  173. #define FST_DOWNLOAD 2 /* Card being downloaded */
  174. #define FST_STARTING 3 /* Released following download */
  175. #define FST_RUNNING 4 /* Processor running */
  176. #define FST_BADVERSION 5 /* Bad shared memory version detected */
  177. #define FST_HALTED 6 /* Processor flagged a halt */
  178. #define FST_IFAILED 7 /* Firmware issued initialisation failed
  179. * interrupt
  180. */
  181. /* "lineInterface" */
  182. #define V24 1
  183. #define X21 2
  184. #define V35 3
  185. #define X21D 4
  186. #define T1 5
  187. #define E1 6
  188. #define J1 7
  189. /* "proto" */
  190. #define FST_HDLC 1 /* Cisco compatible HDLC */
  191. #define FST_PPP 2 /* Sync PPP */
  192. #define FST_MONITOR 3 /* Monitor only (raw packet reception) */
  193. #define FST_RAW 4 /* Two way raw packets */
  194. #define FST_GEN_HDLC 5 /* Using "Generic HDLC" module */
  195. /* "internalClock" */
  196. #define INTCLK 1
  197. #define EXTCLK 0
  198. /* "v24IpSts" bitmask */
  199. #define IPSTS_CTS 0x00000001 /* Clear To Send (Indicate for X.21) */
  200. #define IPSTS_INDICATE IPSTS_CTS
  201. #define IPSTS_DSR 0x00000002 /* Data Set Ready (T2P Port A) */
  202. #define IPSTS_DCD 0x00000004 /* Data Carrier Detect */
  203. #define IPSTS_RI 0x00000008 /* Ring Indicator (T2P Port A) */
  204. #define IPSTS_TMI 0x00000010 /* Test Mode Indicator (Not Supported)*/
  205. /* "v24OpSts" bitmask */
  206. #define OPSTS_RTS 0x00000001 /* Request To Send (Control for X.21) */
  207. #define OPSTS_CONTROL OPSTS_RTS
  208. #define OPSTS_DTR 0x00000002 /* Data Terminal Ready */
  209. #define OPSTS_DSRS 0x00000004 /* Data Signalling Rate Select (Not
  210. * Supported) */
  211. #define OPSTS_SS 0x00000008 /* Select Standby (Not Supported) */
  212. #define OPSTS_LL 0x00000010 /* Maintenance Test (Not Supported) */
  213. /* "cardMode" bitmask */
  214. #define CARD_MODE_IDENTIFY 0x0001
  215. /*
  216. * Constants for T1/E1 configuration
  217. */
  218. /*
  219. * Clock source
  220. */
  221. #define CLOCKING_SLAVE 0
  222. #define CLOCKING_MASTER 1
  223. /*
  224. * Framing
  225. */
  226. #define FRAMING_E1 0
  227. #define FRAMING_J1 1
  228. #define FRAMING_T1 2
  229. /*
  230. * Structure
  231. */
  232. #define STRUCTURE_UNFRAMED 0
  233. #define STRUCTURE_E1_DOUBLE 1
  234. #define STRUCTURE_E1_CRC4 2
  235. #define STRUCTURE_E1_CRC4M 3
  236. #define STRUCTURE_T1_4 4
  237. #define STRUCTURE_T1_12 5
  238. #define STRUCTURE_T1_24 6
  239. #define STRUCTURE_T1_72 7
  240. /*
  241. * Interface
  242. */
  243. #define INTERFACE_RJ48C 0
  244. #define INTERFACE_BNC 1
  245. /*
  246. * Coding
  247. */
  248. #define CODING_HDB3 0
  249. #define CODING_NRZ 1
  250. #define CODING_CMI 2
  251. #define CODING_CMI_HDB3 3
  252. #define CODING_CMI_B8ZS 4
  253. #define CODING_AMI 5
  254. #define CODING_AMI_ZCS 6
  255. #define CODING_B8ZS 7
  256. /*
  257. * Line Build Out
  258. */
  259. #define LBO_0dB 0
  260. #define LBO_7dB5 1
  261. #define LBO_15dB 2
  262. #define LBO_22dB5 3
  263. /*
  264. * Range for long haul t1 > 655ft
  265. */
  266. #define RANGE_0_133_FT 0
  267. #define RANGE_0_40_M RANGE_0_133_FT
  268. #define RANGE_133_266_FT 1
  269. #define RANGE_40_81_M RANGE_133_266_FT
  270. #define RANGE_266_399_FT 2
  271. #define RANGE_81_122_M RANGE_266_399_FT
  272. #define RANGE_399_533_FT 3
  273. #define RANGE_122_162_M RANGE_399_533_FT
  274. #define RANGE_533_655_FT 4
  275. #define RANGE_162_200_M RANGE_533_655_FT
  276. /*
  277. * Receive Equaliser
  278. */
  279. #define EQUALIZER_SHORT 0
  280. #define EQUALIZER_LONG 1
  281. /*
  282. * Loop modes
  283. */
  284. #define LOOP_NONE 0
  285. #define LOOP_LOCAL 1
  286. #define LOOP_PAYLOAD_EXC_TS0 2
  287. #define LOOP_PAYLOAD_INC_TS0 3
  288. #define LOOP_REMOTE 4
  289. /*
  290. * Buffer modes
  291. */
  292. #define BUFFER_2_FRAME 0
  293. #define BUFFER_1_FRAME 1
  294. #define BUFFER_96_BIT 2
  295. #define BUFFER_NONE 3
  296. /* Debug support
  297. *
  298. * These should only be enabled for development kernels, production code
  299. * should define FST_DEBUG=0 in order to exclude the code.
  300. * Setting FST_DEBUG=1 will include all the debug code but in a disabled
  301. * state, use the FSTSETCONF ioctl to enable specific debug actions, or
  302. * FST_DEBUG can be set to prime the debug selection.
  303. */
  304. #define FST_DEBUG 0x0000
  305. #if FST_DEBUG
  306. extern int fst_debug_mask; /* Bit mask of actions to debug, bits
  307. * listed below. Note: Bit 0 is used
  308. * to trigger the inclusion of this
  309. * code, without enabling any actions.
  310. */
  311. #define DBG_INIT 0x0002 /* Card detection and initialisation */
  312. #define DBG_OPEN 0x0004 /* Open and close sequences */
  313. #define DBG_PCI 0x0008 /* PCI config operations */
  314. #define DBG_IOCTL 0x0010 /* Ioctls and other config */
  315. #define DBG_INTR 0x0020 /* Interrupt routines (be careful) */
  316. #define DBG_TX 0x0040 /* Packet transmission */
  317. #define DBG_RX 0x0080 /* Packet reception */
  318. #define DBG_CMD 0x0100 /* Port command issuing */
  319. #define DBG_ASS 0xFFFF /* Assert like statements. Code that
  320. * should never be reached, if you see
  321. * one of these then I've been an ass
  322. */
  323. #endif /* FST_DEBUG */