act2000.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /* $Id: act2000.h,v 1.8.6.3 2001/09/23 22:24:32 kai Exp $
  2. *
  3. * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
  4. *
  5. * Author Fritz Elfert
  6. * Copyright by Fritz Elfert <fritz@isdn4linux.de>
  7. *
  8. * This software may be used and distributed according to the terms
  9. * of the GNU General Public License, incorporated herein by reference.
  10. *
  11. * Thanks to Friedemann Baitinger and IBM Germany
  12. *
  13. */
  14. #ifndef act2000_h
  15. #define act2000_h
  16. #include <linux/compiler.h>
  17. #define ACT2000_IOCTL_SETPORT 1
  18. #define ACT2000_IOCTL_GETPORT 2
  19. #define ACT2000_IOCTL_SETIRQ 3
  20. #define ACT2000_IOCTL_GETIRQ 4
  21. #define ACT2000_IOCTL_SETBUS 5
  22. #define ACT2000_IOCTL_GETBUS 6
  23. #define ACT2000_IOCTL_SETPROTO 7
  24. #define ACT2000_IOCTL_GETPROTO 8
  25. #define ACT2000_IOCTL_SETMSN 9
  26. #define ACT2000_IOCTL_GETMSN 10
  27. #define ACT2000_IOCTL_LOADBOOT 11
  28. #define ACT2000_IOCTL_ADDCARD 12
  29. #define ACT2000_IOCTL_TEST 98
  30. #define ACT2000_IOCTL_DEBUGVAR 99
  31. #define ACT2000_BUS_ISA 1
  32. #define ACT2000_BUS_MCA 2
  33. #define ACT2000_BUS_PCMCIA 3
  34. /* Struct for adding new cards */
  35. typedef struct act2000_cdef {
  36. int bus;
  37. int port;
  38. int irq;
  39. char id[10];
  40. } act2000_cdef;
  41. /* Struct for downloading firmware */
  42. typedef struct act2000_ddef {
  43. int length; /* Length of code */
  44. char __user *buffer; /* Ptr. to code */
  45. } act2000_ddef;
  46. typedef struct act2000_fwid {
  47. char isdn[4];
  48. char revlen[2];
  49. char revision[504];
  50. } act2000_fwid;
  51. #if defined(__KERNEL__) || defined(__DEBUGVAR__)
  52. #ifdef __KERNEL__
  53. /* Kernel includes */
  54. #include <linux/sched.h>
  55. #include <linux/string.h>
  56. #include <linux/workqueue.h>
  57. #include <linux/interrupt.h>
  58. #include <linux/skbuff.h>
  59. #include <linux/errno.h>
  60. #include <linux/fs.h>
  61. #include <linux/major.h>
  62. #include <asm/io.h>
  63. #include <linux/kernel.h>
  64. #include <linux/signal.h>
  65. #include <linux/slab.h>
  66. #include <linux/mm.h>
  67. #include <linux/mman.h>
  68. #include <linux/ioport.h>
  69. #include <linux/timer.h>
  70. #include <linux/wait.h>
  71. #include <linux/delay.h>
  72. #include <linux/ctype.h>
  73. #include <linux/isdnif.h>
  74. #endif /* __KERNEL__ */
  75. #define ACT2000_PORTLEN 8
  76. #define ACT2000_FLAGS_RUNNING 1 /* Cards driver activated */
  77. #define ACT2000_FLAGS_PVALID 2 /* Cards port is valid */
  78. #define ACT2000_FLAGS_IVALID 4 /* Cards irq is valid */
  79. #define ACT2000_FLAGS_LOADED 8 /* Firmware loaded */
  80. #define ACT2000_BCH 2 /* # of channels per card */
  81. /* D-Channel states */
  82. #define ACT2000_STATE_NULL 0
  83. #define ACT2000_STATE_ICALL 1
  84. #define ACT2000_STATE_OCALL 2
  85. #define ACT2000_STATE_IWAIT 3
  86. #define ACT2000_STATE_OWAIT 4
  87. #define ACT2000_STATE_IBWAIT 5
  88. #define ACT2000_STATE_OBWAIT 6
  89. #define ACT2000_STATE_BWAIT 7
  90. #define ACT2000_STATE_BHWAIT 8
  91. #define ACT2000_STATE_BHWAIT2 9
  92. #define ACT2000_STATE_DHWAIT 10
  93. #define ACT2000_STATE_DHWAIT2 11
  94. #define ACT2000_STATE_BSETUP 12
  95. #define ACT2000_STATE_ACTIVE 13
  96. #define ACT2000_MAX_QUEUED 8000 /* 2 * maxbuff */
  97. #define ACT2000_LOCK_TX 0
  98. #define ACT2000_LOCK_RX 1
  99. typedef struct act2000_chan {
  100. unsigned short callref; /* Call Reference */
  101. unsigned short fsm_state; /* Current D-Channel state */
  102. unsigned short eazmask; /* EAZ-Mask for this Channel */
  103. short queued; /* User-Data Bytes in TX queue */
  104. unsigned short plci;
  105. unsigned short ncci;
  106. unsigned char l2prot; /* Layer 2 protocol */
  107. unsigned char l3prot; /* Layer 3 protocol */
  108. } act2000_chan;
  109. typedef struct msn_entry {
  110. char eaz;
  111. char msn[16];
  112. struct msn_entry * next;
  113. } msn_entry;
  114. typedef struct irq_data_isa {
  115. __u8 *rcvptr;
  116. __u16 rcvidx;
  117. __u16 rcvlen;
  118. struct sk_buff *rcvskb;
  119. __u8 rcvignore;
  120. __u8 rcvhdr[8];
  121. } irq_data_isa;
  122. typedef union act2000_irq_data {
  123. irq_data_isa isa;
  124. } act2000_irq_data;
  125. /*
  126. * Per card driver data
  127. */
  128. typedef struct act2000_card {
  129. unsigned short port; /* Base-port-address */
  130. unsigned short irq; /* Interrupt */
  131. u_char ptype; /* Protocol type (1TR6 or Euro) */
  132. u_char bus; /* Cardtype (ISA, MCA, PCMCIA) */
  133. struct act2000_card *next; /* Pointer to next device struct */
  134. spinlock_t lock; /* protect critical operations */
  135. int myid; /* Driver-Nr. assigned by linklevel */
  136. unsigned long flags; /* Statusflags */
  137. unsigned long ilock; /* Semaphores for IRQ-Routines */
  138. struct sk_buff_head rcvq; /* Receive-Message queue */
  139. struct sk_buff_head sndq; /* Send-Message queue */
  140. struct sk_buff_head ackq; /* Data-Ack-Message queue */
  141. u_char *ack_msg; /* Ptr to User Data in User skb */
  142. __u16 need_b3ack; /* Flag: Need ACK for current skb */
  143. struct sk_buff *sbuf; /* skb which is currently sent */
  144. struct timer_list ptimer; /* Poll timer */
  145. struct work_struct snd_tq; /* Task struct for xmit bh */
  146. struct work_struct rcv_tq; /* Task struct for rcv bh */
  147. struct work_struct poll_tq; /* Task struct for polled rcv bh */
  148. msn_entry *msn_list;
  149. unsigned short msgnum; /* Message number for sending */
  150. spinlock_t mnlock; /* lock for msgnum */
  151. act2000_chan bch[ACT2000_BCH]; /* B-Channel status/control */
  152. char status_buf[256]; /* Buffer for status messages */
  153. char *status_buf_read;
  154. char *status_buf_write;
  155. char *status_buf_end;
  156. act2000_irq_data idat; /* Data used for IRQ handler */
  157. isdn_if interface; /* Interface to upper layer */
  158. char regname[35]; /* Name used for request_region */
  159. } act2000_card;
  160. static inline void act2000_schedule_tx(act2000_card *card)
  161. {
  162. schedule_work(&card->snd_tq);
  163. }
  164. static inline void act2000_schedule_rx(act2000_card *card)
  165. {
  166. schedule_work(&card->rcv_tq);
  167. }
  168. static inline void act2000_schedule_poll(act2000_card *card)
  169. {
  170. schedule_work(&card->poll_tq);
  171. }
  172. extern char *act2000_find_eaz(act2000_card *, char);
  173. #endif /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
  174. #endif /* act2000_h */