farsync.h 14 KB

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