mISDNhw.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. *
  3. * Author Karsten Keil <kkeil@novell.com>
  4. *
  5. * Basic declarations for the mISDN HW channels
  6. *
  7. * Copyright 2008 by Karsten Keil <kkeil@novell.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #ifndef MISDNHW_H
  20. #define MISDNHW_H
  21. #include <linux/mISDNif.h>
  22. #include <linux/timer.h>
  23. /*
  24. * HW DEBUG 0xHHHHGGGG
  25. * H - hardware driver specific bits
  26. * G - for all drivers
  27. */
  28. #define DEBUG_HW 0x00000001
  29. #define DEBUG_HW_OPEN 0x00000002
  30. #define DEBUG_HW_DCHANNEL 0x00000100
  31. #define DEBUG_HW_DFIFO 0x00000200
  32. #define DEBUG_HW_BCHANNEL 0x00001000
  33. #define DEBUG_HW_BFIFO 0x00002000
  34. #define MAX_DFRAME_LEN_L1 300
  35. #define MAX_MON_FRAME 32
  36. #define MAX_LOG_SPACE 2048
  37. #define MISDN_COPY_SIZE 32
  38. /* channel->Flags bit field */
  39. #define FLG_TX_BUSY 0 /* tx_buf in use */
  40. #define FLG_TX_NEXT 1 /* next_skb in use */
  41. #define FLG_L1_BUSY 2 /* L1 is permanent busy */
  42. #define FLG_L2_ACTIVATED 3 /* activated from L2 */
  43. #define FLG_OPEN 5 /* channel is in use */
  44. #define FLG_ACTIVE 6 /* channel is activated */
  45. #define FLG_BUSY_TIMER 7
  46. /* channel type */
  47. #define FLG_DCHANNEL 8 /* channel is D-channel */
  48. #define FLG_BCHANNEL 9 /* channel is B-channel */
  49. #define FLG_ECHANNEL 10 /* channel is E-channel */
  50. #define FLG_TRANSPARENT 12 /* channel use transparent data */
  51. #define FLG_HDLC 13 /* channel use hdlc data */
  52. #define FLG_L2DATA 14 /* channel use L2 DATA primitivs */
  53. #define FLG_ORIGIN 15 /* channel is on origin site */
  54. /* channel specific stuff */
  55. #define FLG_FILLEMPTY 16 /* fill fifo on first frame (empty) */
  56. /* arcofi specific */
  57. #define FLG_ARCOFI_TIMER 17
  58. #define FLG_ARCOFI_ERROR 18
  59. /* isar specific */
  60. #define FLG_INITIALIZED 17
  61. #define FLG_DLEETX 18
  62. #define FLG_LASTDLE 19
  63. #define FLG_FIRST 20
  64. #define FLG_LASTDATA 21
  65. #define FLG_NMD_DATA 22
  66. #define FLG_FTI_RUN 23
  67. #define FLG_LL_OK 24
  68. #define FLG_LL_CONN 25
  69. #define FLG_DTMFSEND 26
  70. /* workq events */
  71. #define FLG_RECVQUEUE 30
  72. #define FLG_PHCHANGE 31
  73. #define schedule_event(s, ev) do { \
  74. test_and_set_bit(ev, &((s)->Flags)); \
  75. schedule_work(&((s)->workq)); \
  76. } while (0)
  77. struct dchannel {
  78. struct mISDNdevice dev;
  79. u_long Flags;
  80. struct work_struct workq;
  81. void (*phfunc) (struct dchannel *);
  82. u_int state;
  83. void *l1;
  84. /* HW access */
  85. u_char (*read_reg) (void *, u_char);
  86. void (*write_reg) (void *, u_char, u_char);
  87. void (*read_fifo) (void *, u_char *, int);
  88. void (*write_fifo) (void *, u_char *, int);
  89. void *hw;
  90. int slot; /* multiport card channel slot */
  91. struct timer_list timer;
  92. /* receive data */
  93. struct sk_buff *rx_skb;
  94. int maxlen;
  95. /* send data */
  96. struct sk_buff_head squeue;
  97. struct sk_buff_head rqueue;
  98. struct sk_buff *tx_skb;
  99. int tx_idx;
  100. int debug;
  101. /* statistics */
  102. int err_crc;
  103. int err_tx;
  104. int err_rx;
  105. };
  106. typedef int (dchannel_l1callback)(struct dchannel *, u_int);
  107. extern int create_l1(struct dchannel *, dchannel_l1callback *);
  108. /* private L1 commands */
  109. #define INFO0 0x8002
  110. #define INFO1 0x8102
  111. #define INFO2 0x8202
  112. #define INFO3_P8 0x8302
  113. #define INFO3_P10 0x8402
  114. #define INFO4_P8 0x8502
  115. #define INFO4_P10 0x8602
  116. #define LOSTFRAMING 0x8702
  117. #define ANYSIGNAL 0x8802
  118. #define HW_POWERDOWN 0x8902
  119. #define HW_RESET_REQ 0x8a02
  120. #define HW_POWERUP_REQ 0x8b02
  121. #define HW_DEACT_REQ 0x8c02
  122. #define HW_ACTIVATE_REQ 0x8e02
  123. #define HW_D_NOBLOCKED 0x8f02
  124. #define HW_RESET_IND 0x9002
  125. #define HW_POWERUP_IND 0x9102
  126. #define HW_DEACT_IND 0x9202
  127. #define HW_ACTIVATE_IND 0x9302
  128. #define HW_DEACT_CNF 0x9402
  129. #define HW_TESTLOOP 0x9502
  130. #define HW_TESTRX_RAW 0x9602
  131. #define HW_TESTRX_HDLC 0x9702
  132. #define HW_TESTRX_OFF 0x9802
  133. struct layer1;
  134. extern int l1_event(struct layer1 *, u_int);
  135. struct bchannel {
  136. struct mISDNchannel ch;
  137. int nr;
  138. u_long Flags;
  139. struct work_struct workq;
  140. u_int state;
  141. /* HW access */
  142. u_char (*read_reg) (void *, u_char);
  143. void (*write_reg) (void *, u_char, u_char);
  144. void (*read_fifo) (void *, u_char *, int);
  145. void (*write_fifo) (void *, u_char *, int);
  146. void *hw;
  147. int slot; /* multiport card channel slot */
  148. struct timer_list timer;
  149. /* receive data */
  150. struct sk_buff *rx_skb;
  151. int maxlen;
  152. /* send data */
  153. struct sk_buff *next_skb;
  154. struct sk_buff *tx_skb;
  155. struct sk_buff_head rqueue;
  156. int rcount;
  157. int tx_idx;
  158. int debug;
  159. /* statistics */
  160. int err_crc;
  161. int err_tx;
  162. int err_rx;
  163. };
  164. extern int mISDN_initdchannel(struct dchannel *, int, void *);
  165. extern int mISDN_initbchannel(struct bchannel *, int);
  166. extern int mISDN_freedchannel(struct dchannel *);
  167. extern int mISDN_freebchannel(struct bchannel *);
  168. extern void queue_ch_frame(struct mISDNchannel *, u_int,
  169. int, struct sk_buff *);
  170. extern int dchannel_senddata(struct dchannel *, struct sk_buff *);
  171. extern int bchannel_senddata(struct bchannel *, struct sk_buff *);
  172. extern void recv_Dchannel(struct dchannel *);
  173. extern void recv_Echannel(struct dchannel *, struct dchannel *);
  174. extern void recv_Bchannel(struct bchannel *);
  175. extern void recv_Dchannel_skb(struct dchannel *, struct sk_buff *);
  176. extern void recv_Bchannel_skb(struct bchannel *, struct sk_buff *);
  177. extern void confirm_Bsend(struct bchannel *bch);
  178. extern int get_next_bframe(struct bchannel *);
  179. extern int get_next_dframe(struct dchannel *);
  180. #endif