hysdn_defs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /* $Id: hysdn_defs.h,v 1.5.6.3 2001/09/23 22:24:54 kai Exp $
  2. *
  3. * Linux driver for HYSDN cards
  4. * global definitions and exported vars and functions.
  5. *
  6. * Author Werner Cornelius (werner@titro.de) for Hypercope GmbH
  7. * Copyright 1999 by Werner Cornelius (werner@titro.de)
  8. *
  9. * This software may be used and distributed according to the terms
  10. * of the GNU General Public License, incorporated herein by reference.
  11. *
  12. */
  13. #ifndef HYSDN_DEFS_H
  14. #define HYSDN_DEFS_H
  15. #include <linux/hysdn_if.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/workqueue.h>
  18. #include <linux/skbuff.h>
  19. #include "ince1pc.h"
  20. #ifdef CONFIG_HYSDN_CAPI
  21. #include <linux/capi.h>
  22. #include <linux/isdn/capicmd.h>
  23. #include <linux/isdn/capiutil.h>
  24. #include <linux/isdn/capilli.h>
  25. /***************************/
  26. /* CAPI-Profile values. */
  27. /***************************/
  28. #define GLOBAL_OPTION_INTERNAL_CONTROLLER 0x0001
  29. #define GLOBAL_OPTION_EXTERNAL_CONTROLLER 0x0002
  30. #define GLOBAL_OPTION_HANDSET 0x0004
  31. #define GLOBAL_OPTION_DTMF 0x0008
  32. #define GLOBAL_OPTION_SUPPL_SERVICES 0x0010
  33. #define GLOBAL_OPTION_CHANNEL_ALLOCATION 0x0020
  34. #define GLOBAL_OPTION_B_CHANNEL_OPERATION 0x0040
  35. #define B1_PROT_64KBIT_HDLC 0x0001
  36. #define B1_PROT_64KBIT_TRANSPARENT 0x0002
  37. #define B1_PROT_V110_ASYNCH 0x0004
  38. #define B1_PROT_V110_SYNCH 0x0008
  39. #define B1_PROT_T30 0x0010
  40. #define B1_PROT_64KBIT_INV_HDLC 0x0020
  41. #define B1_PROT_56KBIT_TRANSPARENT 0x0040
  42. #define B2_PROT_ISO7776 0x0001
  43. #define B2_PROT_TRANSPARENT 0x0002
  44. #define B2_PROT_SDLC 0x0004
  45. #define B2_PROT_LAPD 0x0008
  46. #define B2_PROT_T30 0x0010
  47. #define B2_PROT_PPP 0x0020
  48. #define B2_PROT_TRANSPARENT_IGNORE_B1_FRAMING_ERRORS 0x0040
  49. #define B3_PROT_TRANSPARENT 0x0001
  50. #define B3_PROT_T90NL 0x0002
  51. #define B3_PROT_ISO8208 0x0004
  52. #define B3_PROT_X25_DCE 0x0008
  53. #define B3_PROT_T30 0x0010
  54. #define B3_PROT_T30EXT 0x0020
  55. #define HYSDN_MAXVERSION 8
  56. /* Number of sendbuffers in CAPI-queue */
  57. #define HYSDN_MAX_CAPI_SKB 20
  58. #endif /* CONFIG_HYSDN_CAPI*/
  59. /************************************************/
  60. /* constants and bits for debugging/log outputs */
  61. /************************************************/
  62. #define LOG_MAX_LINELEN 120
  63. #define DEB_OUT_SYSLOG 0x80000000 /* output to syslog instead of proc fs */
  64. #define LOG_MEM_ERR 0x00000001 /* log memory errors like kmalloc failure */
  65. #define LOG_POF_OPEN 0x00000010 /* log pof open and close activities */
  66. #define LOG_POF_RECORD 0x00000020 /* log pof record parser */
  67. #define LOG_POF_WRITE 0x00000040 /* log detailed pof write operation */
  68. #define LOG_POF_CARD 0x00000080 /* log pof related card functions */
  69. #define LOG_CNF_LINE 0x00000100 /* all conf lines are put to procfs */
  70. #define LOG_CNF_DATA 0x00000200 /* non comment conf lines are shown with channel */
  71. #define LOG_CNF_MISC 0x00000400 /* additional conf line debug outputs */
  72. #define LOG_SCHED_ASYN 0x00001000 /* debug schedulers async tx routines */
  73. #define LOG_PROC_OPEN 0x00100000 /* open and close from procfs are logged */
  74. #define LOG_PROC_ALL 0x00200000 /* all actions from procfs are logged */
  75. #define LOG_NET_INIT 0x00010000 /* network init and deinit logging */
  76. #define DEF_DEB_FLAGS 0x7fff000f /* everything is logged to procfs */
  77. /**********************************/
  78. /* proc filesystem name constants */
  79. /**********************************/
  80. #define PROC_SUBDIR_NAME "hysdn"
  81. #define PROC_CONF_BASENAME "cardconf"
  82. #define PROC_LOG_BASENAME "cardlog"
  83. /***********************************/
  84. /* PCI 32 bit parms for IO and MEM */
  85. /***********************************/
  86. #define PCI_REG_PLX_MEM_BASE 0
  87. #define PCI_REG_PLX_IO_BASE 1
  88. #define PCI_REG_MEMORY_BASE 3
  89. /**************/
  90. /* card types */
  91. /**************/
  92. #define BD_NONE 0U
  93. #define BD_PERFORMANCE 1U
  94. #define BD_VALUE 2U
  95. #define BD_PCCARD 3U
  96. #define BD_ERGO 4U
  97. #define BD_METRO 5U
  98. #define BD_CHAMP2 6U
  99. #define BD_PLEXUS 7U
  100. /******************************************************/
  101. /* defined states for cards shown by reading cardconf */
  102. /******************************************************/
  103. #define CARD_STATE_UNUSED 0 /* never been used or booted */
  104. #define CARD_STATE_BOOTING 1 /* booting is in progress */
  105. #define CARD_STATE_BOOTERR 2 /* a previous boot was aborted */
  106. #define CARD_STATE_RUN 3 /* card is active */
  107. /*******************************/
  108. /* defines for error_log_state */
  109. /*******************************/
  110. #define ERRLOG_STATE_OFF 0 /* error log is switched off, nothing to do */
  111. #define ERRLOG_STATE_ON 1 /* error log is switched on, wait for data */
  112. #define ERRLOG_STATE_START 2 /* start error logging */
  113. #define ERRLOG_STATE_STOP 3 /* stop error logging */
  114. /*******************************/
  115. /* data structure for one card */
  116. /*******************************/
  117. typedef struct HYSDN_CARD {
  118. /* general variables for the cards */
  119. int myid; /* own driver card id */
  120. unsigned char bus; /* pci bus the card is connected to */
  121. unsigned char devfn; /* slot+function bit encoded */
  122. unsigned short subsysid;/* PCI subsystem id */
  123. unsigned char brdtype; /* type of card */
  124. unsigned int bchans; /* number of available B-channels */
  125. unsigned int faxchans; /* number of available fax-channels */
  126. unsigned char mac_addr[6];/* MAC Address read from card */
  127. unsigned int irq; /* interrupt number */
  128. unsigned int iobase; /* IO-port base address */
  129. unsigned long plxbase; /* PLX memory base */
  130. unsigned long membase; /* DPRAM memory base */
  131. unsigned long memend; /* DPRAM memory end */
  132. void *dpram; /* mapped dpram */
  133. int state; /* actual state of card -> CARD_STATE_** */
  134. struct HYSDN_CARD *next; /* pointer to next card */
  135. /* data areas for the /proc file system */
  136. void *proclog; /* pointer to proclog filesystem specific data */
  137. void *procconf; /* pointer to procconf filesystem specific data */
  138. /* debugging and logging */
  139. unsigned char err_log_state;/* actual error log state of the card */
  140. unsigned long debug_flags;/* tells what should be debugged and where */
  141. void (*set_errlog_state) (struct HYSDN_CARD *, int);
  142. /* interrupt handler + interrupt synchronisation */
  143. struct work_struct irq_queue; /* interrupt task queue */
  144. unsigned char volatile irq_enabled;/* interrupt enabled if != 0 */
  145. unsigned char volatile hw_lock;/* hardware is currently locked -> no access */
  146. /* boot process */
  147. void *boot; /* pointer to boot private data */
  148. int (*writebootimg) (struct HYSDN_CARD *, unsigned char *, unsigned long);
  149. int (*writebootseq) (struct HYSDN_CARD *, unsigned char *, int);
  150. int (*waitpofready) (struct HYSDN_CARD *);
  151. int (*testram) (struct HYSDN_CARD *);
  152. /* scheduler for data transfer (only async parts) */
  153. unsigned char async_data[256];/* async data to be sent (normally for config) */
  154. unsigned short volatile async_len;/* length of data to sent */
  155. unsigned short volatile async_channel;/* channel number for async transfer */
  156. int volatile async_busy; /* flag != 0 sending in progress */
  157. int volatile net_tx_busy; /* a network packet tx is in progress */
  158. /* network interface */
  159. void *netif; /* pointer to network structure */
  160. /* init and deinit stopcard for booting, too */
  161. void (*stopcard) (struct HYSDN_CARD *);
  162. void (*releasehardware) (struct HYSDN_CARD *);
  163. spinlock_t hysdn_lock;
  164. #ifdef CONFIG_HYSDN_CAPI
  165. struct hycapictrl_info {
  166. char cardname[32];
  167. spinlock_t lock;
  168. int versionlen;
  169. char versionbuf[1024];
  170. char *version[HYSDN_MAXVERSION];
  171. char infobuf[128]; /* for function procinfo */
  172. struct HYSDN_CARD *card;
  173. struct capi_ctr capi_ctrl;
  174. struct sk_buff *skbs[HYSDN_MAX_CAPI_SKB];
  175. int in_idx, out_idx; /* indexes to buffer ring */
  176. int sk_count; /* number of buffers currently in ring */
  177. struct sk_buff *tx_skb; /* buffer for tx operation */
  178. struct list_head ncci_head;
  179. } *hyctrlinfo;
  180. #endif /* CONFIG_HYSDN_CAPI */
  181. } hysdn_card;
  182. #ifdef CONFIG_HYSDN_CAPI
  183. typedef struct hycapictrl_info hycapictrl_info;
  184. #endif /* CONFIG_HYSDN_CAPI */
  185. /*****************/
  186. /* exported vars */
  187. /*****************/
  188. extern hysdn_card *card_root; /* pointer to first card */
  189. /*************************/
  190. /* im/exported functions */
  191. /*************************/
  192. /* hysdn_procconf.c */
  193. extern int hysdn_procconf_init(void); /* init proc config filesys */
  194. extern void hysdn_procconf_release(void); /* deinit proc config filesys */
  195. /* hysdn_proclog.c */
  196. extern int hysdn_proclog_init(hysdn_card *); /* init proc log entry */
  197. extern void hysdn_proclog_release(hysdn_card *); /* deinit proc log entry */
  198. extern void hysdn_addlog(hysdn_card *, char *, ...); /* output data to log */
  199. extern void hysdn_card_errlog(hysdn_card *, tErrLogEntry *, int); /* output card log */
  200. /* boardergo.c */
  201. extern int ergo_inithardware(hysdn_card *card); /* get hardware -> module init */
  202. /* hysdn_boot.c */
  203. extern int pof_write_close(hysdn_card *); /* close proc file after writing pof */
  204. extern int pof_write_open(hysdn_card *, unsigned char **); /* open proc file for writing pof */
  205. extern int pof_write_buffer(hysdn_card *, int); /* write boot data to card */
  206. extern int EvalSysrTokData(hysdn_card *, unsigned char *, int); /* Check Sysready Token Data */
  207. /* hysdn_sched.c */
  208. extern int hysdn_sched_tx(hysdn_card *, unsigned char *,
  209. unsigned short volatile *, unsigned short volatile *,
  210. unsigned short);
  211. extern int hysdn_sched_rx(hysdn_card *, unsigned char *, unsigned short,
  212. unsigned short);
  213. extern int hysdn_tx_cfgline(hysdn_card *, unsigned char *,
  214. unsigned short); /* send one cfg line */
  215. /* hysdn_net.c */
  216. extern unsigned int hynet_enable;
  217. extern int hysdn_net_create(hysdn_card *); /* create a new net device */
  218. extern int hysdn_net_release(hysdn_card *); /* delete the device */
  219. extern char *hysdn_net_getname(hysdn_card *); /* get name of net interface */
  220. extern void hysdn_tx_netack(hysdn_card *); /* acknowledge a packet tx */
  221. extern struct sk_buff *hysdn_tx_netget(hysdn_card *); /* get next network packet */
  222. extern void hysdn_rx_netpkt(hysdn_card *, unsigned char *,
  223. unsigned short); /* rxed packet from network */
  224. #ifdef CONFIG_HYSDN_CAPI
  225. extern unsigned int hycapi_enable;
  226. extern int hycapi_capi_create(hysdn_card *); /* create a new capi device */
  227. extern int hycapi_capi_release(hysdn_card *); /* delete the device */
  228. extern int hycapi_capi_stop(hysdn_card *card); /* suspend */
  229. extern void hycapi_rx_capipkt(hysdn_card *card, unsigned char *buf,
  230. unsigned short len);
  231. extern void hycapi_tx_capiack(hysdn_card *card);
  232. extern struct sk_buff *hycapi_tx_capiget(hysdn_card *card);
  233. extern int hycapi_init(void);
  234. extern void hycapi_cleanup(void);
  235. #endif /* CONFIG_HYSDN_CAPI */
  236. #endif /* HYSDN_DEFS_H */