mISDNhw.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. void *hw;
  85. int slot; /* multiport card channel slot */
  86. struct timer_list timer;
  87. /* receive data */
  88. struct sk_buff *rx_skb;
  89. int maxlen;
  90. /* send data */
  91. struct sk_buff_head squeue;
  92. struct sk_buff_head rqueue;
  93. struct sk_buff *tx_skb;
  94. int tx_idx;
  95. int debug;
  96. /* statistics */
  97. int err_crc;
  98. int err_tx;
  99. int err_rx;
  100. };
  101. typedef int (dchannel_l1callback)(struct dchannel *, u_int);
  102. extern int create_l1(struct dchannel *, dchannel_l1callback *);
  103. /* private L1 commands */
  104. #define INFO0 0x8002
  105. #define INFO1 0x8102
  106. #define INFO2 0x8202
  107. #define INFO3_P8 0x8302
  108. #define INFO3_P10 0x8402
  109. #define INFO4_P8 0x8502
  110. #define INFO4_P10 0x8602
  111. #define LOSTFRAMING 0x8702
  112. #define ANYSIGNAL 0x8802
  113. #define HW_POWERDOWN 0x8902
  114. #define HW_RESET_REQ 0x8a02
  115. #define HW_POWERUP_REQ 0x8b02
  116. #define HW_DEACT_REQ 0x8c02
  117. #define HW_ACTIVATE_REQ 0x8e02
  118. #define HW_D_NOBLOCKED 0x8f02
  119. #define HW_RESET_IND 0x9002
  120. #define HW_POWERUP_IND 0x9102
  121. #define HW_DEACT_IND 0x9202
  122. #define HW_ACTIVATE_IND 0x9302
  123. #define HW_DEACT_CNF 0x9402
  124. #define HW_TESTLOOP 0x9502
  125. #define HW_TESTRX_RAW 0x9602
  126. #define HW_TESTRX_HDLC 0x9702
  127. #define HW_TESTRX_OFF 0x9802
  128. struct layer1;
  129. extern int l1_event(struct layer1 *, u_int);
  130. struct bchannel {
  131. struct mISDNchannel ch;
  132. int nr;
  133. u_long Flags;
  134. struct work_struct workq;
  135. u_int state;
  136. void *hw;
  137. int slot; /* multiport card channel slot */
  138. struct timer_list timer;
  139. /* receive data */
  140. struct sk_buff *rx_skb;
  141. int maxlen;
  142. /* send data */
  143. struct sk_buff *next_skb;
  144. struct sk_buff *tx_skb;
  145. struct sk_buff_head rqueue;
  146. int rcount;
  147. int tx_idx;
  148. int debug;
  149. /* statistics */
  150. int err_crc;
  151. int err_tx;
  152. int err_rx;
  153. };
  154. extern int mISDN_initdchannel(struct dchannel *, int, void *);
  155. extern int mISDN_initbchannel(struct bchannel *, int);
  156. extern int mISDN_freedchannel(struct dchannel *);
  157. extern void mISDN_clear_bchannel(struct bchannel *);
  158. extern int mISDN_freebchannel(struct bchannel *);
  159. extern void queue_ch_frame(struct mISDNchannel *, u_int,
  160. int, struct sk_buff *);
  161. extern int dchannel_senddata(struct dchannel *, struct sk_buff *);
  162. extern int bchannel_senddata(struct bchannel *, struct sk_buff *);
  163. extern void recv_Dchannel(struct dchannel *);
  164. extern void recv_Echannel(struct dchannel *, struct dchannel *);
  165. extern void recv_Bchannel(struct bchannel *, unsigned int id);
  166. extern void recv_Dchannel_skb(struct dchannel *, struct sk_buff *);
  167. extern void recv_Bchannel_skb(struct bchannel *, struct sk_buff *);
  168. extern void confirm_Bsend(struct bchannel *bch);
  169. extern int get_next_bframe(struct bchannel *);
  170. extern int get_next_dframe(struct dchannel *);
  171. #endif