mISDNhw.h 5.4 KB

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