mISDNhw.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. /* arcofi specific */
  56. #define FLG_ARCOFI_TIMER 16
  57. #define FLG_ARCOFI_ERROR 17
  58. /* isar specific */
  59. #define FLG_INITIALIZED 16
  60. #define FLG_DLEETX 17
  61. #define FLG_LASTDLE 18
  62. #define FLG_FIRST 19
  63. #define FLG_LASTDATA 20
  64. #define FLG_NMD_DATA 21
  65. #define FLG_FTI_RUN 22
  66. #define FLG_LL_OK 23
  67. #define FLG_LL_CONN 24
  68. #define FLG_DTMFSEND 25
  69. /* workq events */
  70. #define FLG_RECVQUEUE 30
  71. #define FLG_PHCHANGE 31
  72. #define schedule_event(s, ev) do { \
  73. test_and_set_bit(ev, &((s)->Flags)); \
  74. schedule_work(&((s)->workq)); \
  75. } while (0)
  76. struct dchannel {
  77. struct mISDNdevice dev;
  78. u_long Flags;
  79. struct work_struct workq;
  80. void (*phfunc) (struct dchannel *);
  81. u_int state;
  82. void *l1;
  83. /* HW access */
  84. u_char (*read_reg) (void *, u_char);
  85. void (*write_reg) (void *, u_char, u_char);
  86. void (*read_fifo) (void *, u_char *, int);
  87. void (*write_fifo) (void *, u_char *, int);
  88. void *hw;
  89. int slot; /* multiport card channel slot */
  90. struct timer_list timer;
  91. /* receive data */
  92. struct sk_buff *rx_skb;
  93. int maxlen;
  94. /* send data */
  95. struct sk_buff_head squeue;
  96. struct sk_buff_head rqueue;
  97. struct sk_buff *tx_skb;
  98. int tx_idx;
  99. int debug;
  100. /* statistics */
  101. int err_crc;
  102. int err_tx;
  103. int err_rx;
  104. };
  105. typedef int (dchannel_l1callback)(struct dchannel *, u_int);
  106. extern int create_l1(struct dchannel *, dchannel_l1callback *);
  107. /* private L1 commands */
  108. #define INFO0 0x8002
  109. #define INFO1 0x8102
  110. #define INFO2 0x8202
  111. #define INFO3_P8 0x8302
  112. #define INFO3_P10 0x8402
  113. #define INFO4_P8 0x8502
  114. #define INFO4_P10 0x8602
  115. #define LOSTFRAMING 0x8702
  116. #define ANYSIGNAL 0x8802
  117. #define HW_POWERDOWN 0x8902
  118. #define HW_RESET_REQ 0x8a02
  119. #define HW_POWERUP_REQ 0x8b02
  120. #define HW_DEACT_REQ 0x8c02
  121. #define HW_ACTIVATE_REQ 0x8e02
  122. #define HW_D_NOBLOCKED 0x8f02
  123. #define HW_RESET_IND 0x9002
  124. #define HW_POWERUP_IND 0x9102
  125. #define HW_DEACT_IND 0x9202
  126. #define HW_ACTIVATE_IND 0x9302
  127. #define HW_DEACT_CNF 0x9402
  128. #define HW_TESTLOOP 0x9502
  129. #define HW_TESTRX_RAW 0x9602
  130. #define HW_TESTRX_HDLC 0x9702
  131. #define HW_TESTRX_OFF 0x9802
  132. struct layer1;
  133. extern int l1_event(struct layer1 *, u_int);
  134. struct bchannel {
  135. struct mISDNchannel ch;
  136. int nr;
  137. u_long Flags;
  138. struct work_struct workq;
  139. u_int state;
  140. /* HW access */
  141. u_char (*read_reg) (void *, u_char);
  142. void (*write_reg) (void *, u_char, u_char);
  143. void (*read_fifo) (void *, u_char *, int);
  144. void (*write_fifo) (void *, u_char *, int);
  145. void *hw;
  146. int slot; /* multiport card channel slot */
  147. struct timer_list timer;
  148. /* receive data */
  149. struct sk_buff *rx_skb;
  150. int maxlen;
  151. /* send data */
  152. struct sk_buff *next_skb;
  153. struct sk_buff *tx_skb;
  154. struct sk_buff_head rqueue;
  155. int rcount;
  156. int tx_idx;
  157. int debug;
  158. /* statistics */
  159. int err_crc;
  160. int err_tx;
  161. int err_rx;
  162. };
  163. extern int mISDN_initdchannel(struct dchannel *, int, void *);
  164. extern int mISDN_initbchannel(struct bchannel *, int);
  165. extern int mISDN_freedchannel(struct dchannel *);
  166. extern int mISDN_freebchannel(struct bchannel *);
  167. extern void queue_ch_frame(struct mISDNchannel *, u_int,
  168. int, struct sk_buff *);
  169. extern int dchannel_senddata(struct dchannel *, struct sk_buff *);
  170. extern int bchannel_senddata(struct bchannel *, struct sk_buff *);
  171. extern void recv_Dchannel(struct dchannel *);
  172. extern void recv_Bchannel(struct bchannel *);
  173. extern void recv_Dchannel_skb(struct dchannel *, struct sk_buff *);
  174. extern void recv_Bchannel_skb(struct bchannel *, struct sk_buff *);
  175. extern void confirm_Bsend(struct bchannel *bch);
  176. extern int get_next_bframe(struct bchannel *);
  177. extern int get_next_dframe(struct dchannel *);
  178. #endif