mISDNhw.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. #define FLG_TX_EMPTY 27
  71. /* stop sending received data upstream */
  72. #define FLG_RX_OFF 28
  73. /* workq events */
  74. #define FLG_RECVQUEUE 30
  75. #define FLG_PHCHANGE 31
  76. #define schedule_event(s, ev) do { \
  77. test_and_set_bit(ev, &((s)->Flags)); \
  78. schedule_work(&((s)->workq)); \
  79. } while (0)
  80. struct dchannel {
  81. struct mISDNdevice dev;
  82. u_long Flags;
  83. struct work_struct workq;
  84. void (*phfunc) (struct dchannel *);
  85. u_int state;
  86. void *l1;
  87. void *hw;
  88. int slot; /* multiport card channel slot */
  89. struct timer_list timer;
  90. /* receive data */
  91. struct sk_buff *rx_skb;
  92. int maxlen;
  93. /* send data */
  94. struct sk_buff_head squeue;
  95. struct sk_buff_head rqueue;
  96. struct sk_buff *tx_skb;
  97. int tx_idx;
  98. int debug;
  99. /* statistics */
  100. int err_crc;
  101. int err_tx;
  102. int err_rx;
  103. };
  104. typedef int (dchannel_l1callback)(struct dchannel *, u_int);
  105. extern int create_l1(struct dchannel *, dchannel_l1callback *);
  106. /* private L1 commands */
  107. #define INFO0 0x8002
  108. #define INFO1 0x8102
  109. #define INFO2 0x8202
  110. #define INFO3_P8 0x8302
  111. #define INFO3_P10 0x8402
  112. #define INFO4_P8 0x8502
  113. #define INFO4_P10 0x8602
  114. #define LOSTFRAMING 0x8702
  115. #define ANYSIGNAL 0x8802
  116. #define HW_POWERDOWN 0x8902
  117. #define HW_RESET_REQ 0x8a02
  118. #define HW_POWERUP_REQ 0x8b02
  119. #define HW_DEACT_REQ 0x8c02
  120. #define HW_ACTIVATE_REQ 0x8e02
  121. #define HW_D_NOBLOCKED 0x8f02
  122. #define HW_RESET_IND 0x9002
  123. #define HW_POWERUP_IND 0x9102
  124. #define HW_DEACT_IND 0x9202
  125. #define HW_ACTIVATE_IND 0x9302
  126. #define HW_DEACT_CNF 0x9402
  127. #define HW_TESTLOOP 0x9502
  128. #define HW_TESTRX_RAW 0x9602
  129. #define HW_TESTRX_HDLC 0x9702
  130. #define HW_TESTRX_OFF 0x9802
  131. #define HW_TIMER3_IND 0x9902
  132. #define HW_TIMER3_VALUE 0x9a00
  133. #define HW_TIMER3_VMASK 0x00FF
  134. struct layer1;
  135. extern int l1_event(struct layer1 *, u_int);
  136. #define MISDN_BCH_FILL_SIZE 4
  137. struct bchannel {
  138. struct mISDNchannel ch;
  139. int nr;
  140. u_long Flags;
  141. struct work_struct workq;
  142. u_int state;
  143. void *hw;
  144. int slot; /* multiport card channel slot */
  145. struct timer_list timer;
  146. /* receive data */
  147. u8 fill[MISDN_BCH_FILL_SIZE];
  148. struct sk_buff *rx_skb;
  149. unsigned short maxlen;
  150. unsigned short init_maxlen; /* initial value */
  151. unsigned short next_maxlen; /* pending value */
  152. unsigned short minlen; /* for transparent data */
  153. unsigned short init_minlen; /* initial value */
  154. unsigned short next_minlen; /* pending value */
  155. /* send data */
  156. struct sk_buff *next_skb;
  157. struct sk_buff *tx_skb;
  158. struct sk_buff_head rqueue;
  159. int rcount;
  160. int tx_idx;
  161. int debug;
  162. /* statistics */
  163. int err_crc;
  164. int err_tx;
  165. int err_rx;
  166. int dropcnt;
  167. };
  168. extern int mISDN_initdchannel(struct dchannel *, int, void *);
  169. extern int mISDN_initbchannel(struct bchannel *, unsigned short,
  170. unsigned short);
  171. extern int mISDN_freedchannel(struct dchannel *);
  172. extern void mISDN_clear_bchannel(struct bchannel *);
  173. extern void mISDN_freebchannel(struct bchannel *);
  174. extern int mISDN_ctrl_bchannel(struct bchannel *, struct mISDN_ctrl_req *);
  175. extern void queue_ch_frame(struct mISDNchannel *, u_int,
  176. int, struct sk_buff *);
  177. extern int dchannel_senddata(struct dchannel *, struct sk_buff *);
  178. extern int bchannel_senddata(struct bchannel *, struct sk_buff *);
  179. extern int bchannel_get_rxbuf(struct bchannel *, int);
  180. extern void recv_Dchannel(struct dchannel *);
  181. extern void recv_Echannel(struct dchannel *, struct dchannel *);
  182. extern void recv_Bchannel(struct bchannel *, unsigned int, bool);
  183. extern void recv_Dchannel_skb(struct dchannel *, struct sk_buff *);
  184. extern void recv_Bchannel_skb(struct bchannel *, struct sk_buff *);
  185. extern int get_next_bframe(struct bchannel *);
  186. extern int get_next_dframe(struct dchannel *);
  187. #endif