farsync.h 14 KB

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