diff options
author | Karsten Keil <kkeil@suse.de> | 2008-07-26 19:54:58 -0400 |
---|---|---|
committer | Karsten Keil <kkeil@suse.de> | 2008-07-26 19:54:58 -0400 |
commit | 1b2b03f8e514e4f68e293846ba511a948b80243c (patch) | |
tree | 5ffb07d532afca95170ea0615bb74af78b0d0483 /include/linux | |
parent | 04578dd330f1ec6bc9c4233833bee0d0ca73ff09 (diff) |
Add mISDN core files
Add mISDN core files
Signed-off-by: Karsten Keil <kkeil@suse.de>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/mISDNhw.h | 193 | ||||
-rw-r--r-- | include/linux/mISDNif.h | 487 |
2 files changed, 680 insertions, 0 deletions
diff --git a/include/linux/mISDNhw.h b/include/linux/mISDNhw.h new file mode 100644 index 000000000000..e794dfb87504 --- /dev/null +++ b/include/linux/mISDNhw.h | |||
@@ -0,0 +1,193 @@ | |||
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 | |||
20 | #ifndef MISDNHW_H | ||
21 | #define MISDNHW_H | ||
22 | #include <linux/mISDNif.h> | ||
23 | #include <linux/timer.h> | ||
24 | |||
25 | /* | ||
26 | * HW DEBUG 0xHHHHGGGG | ||
27 | * H - hardware driver specific bits | ||
28 | * G - for all drivers | ||
29 | */ | ||
30 | |||
31 | #define DEBUG_HW 0x00000001 | ||
32 | #define DEBUG_HW_OPEN 0x00000002 | ||
33 | #define DEBUG_HW_DCHANNEL 0x00000100 | ||
34 | #define DEBUG_HW_DFIFO 0x00000200 | ||
35 | #define DEBUG_HW_BCHANNEL 0x00001000 | ||
36 | #define DEBUG_HW_BFIFO 0x00002000 | ||
37 | |||
38 | #define MAX_DFRAME_LEN_L1 300 | ||
39 | #define MAX_MON_FRAME 32 | ||
40 | #define MAX_LOG_SPACE 2048 | ||
41 | #define MISDN_COPY_SIZE 32 | ||
42 | |||
43 | /* channel->Flags bit field */ | ||
44 | #define FLG_TX_BUSY 0 /* tx_buf in use */ | ||
45 | #define FLG_TX_NEXT 1 /* next_skb in use */ | ||
46 | #define FLG_L1_BUSY 2 /* L1 is permanent busy */ | ||
47 | #define FLG_L2_ACTIVATED 3 /* activated from L2 */ | ||
48 | #define FLG_OPEN 5 /* channel is in use */ | ||
49 | #define FLG_ACTIVE 6 /* channel is activated */ | ||
50 | #define FLG_BUSY_TIMER 7 | ||
51 | /* channel type */ | ||
52 | #define FLG_DCHANNEL 8 /* channel is D-channel */ | ||
53 | #define FLG_BCHANNEL 9 /* channel is B-channel */ | ||
54 | #define FLG_ECHANNEL 10 /* channel is E-channel */ | ||
55 | #define FLG_TRANSPARENT 12 /* channel use transparent data */ | ||
56 | #define FLG_HDLC 13 /* channel use hdlc data */ | ||
57 | #define FLG_L2DATA 14 /* channel use L2 DATA primitivs */ | ||
58 | #define FLG_ORIGIN 15 /* channel is on origin site */ | ||
59 | /* channel specific stuff */ | ||
60 | /* arcofi specific */ | ||
61 | #define FLG_ARCOFI_TIMER 16 | ||
62 | #define FLG_ARCOFI_ERROR 17 | ||
63 | /* isar specific */ | ||
64 | #define FLG_INITIALIZED 16 | ||
65 | #define FLG_DLEETX 17 | ||
66 | #define FLG_LASTDLE 18 | ||
67 | #define FLG_FIRST 19 | ||
68 | #define FLG_LASTDATA 20 | ||
69 | #define FLG_NMD_DATA 21 | ||
70 | #define FLG_FTI_RUN 22 | ||
71 | #define FLG_LL_OK 23 | ||
72 | #define FLG_LL_CONN 24 | ||
73 | #define FLG_DTMFSEND 25 | ||
74 | |||
75 | /* workq events */ | ||
76 | #define FLG_RECVQUEUE 30 | ||
77 | #define FLG_PHCHANGE 31 | ||
78 | |||
79 | #define schedule_event(s, ev) do { \ | ||
80 | test_and_set_bit(ev, &((s)->Flags)); \ | ||
81 | schedule_work(&((s)->workq)); \ | ||
82 | } while (0) | ||
83 | |||
84 | struct dchannel { | ||
85 | struct mISDNdevice dev; | ||
86 | u_long Flags; | ||
87 | struct work_struct workq; | ||
88 | void (*phfunc) (struct dchannel *); | ||
89 | u_int state; | ||
90 | void *l1; | ||
91 | /* HW access */ | ||
92 | u_char (*read_reg) (void *, u_char); | ||
93 | void (*write_reg) (void *, u_char, u_char); | ||
94 | void (*read_fifo) (void *, u_char *, int); | ||
95 | void (*write_fifo) (void *, u_char *, int); | ||
96 | void *hw; | ||
97 | int slot; /* multiport card channel slot */ | ||
98 | struct timer_list timer; | ||
99 | /* receive data */ | ||
100 | struct sk_buff *rx_skb; | ||
101 | int maxlen; | ||
102 | /* send data */ | ||
103 | struct sk_buff_head squeue; | ||
104 | struct sk_buff_head rqueue; | ||
105 | struct sk_buff *tx_skb; | ||
106 | int tx_idx; | ||
107 | int debug; | ||
108 | /* statistics */ | ||
109 | int err_crc; | ||
110 | int err_tx; | ||
111 | int err_rx; | ||
112 | }; | ||
113 | |||
114 | typedef int (dchannel_l1callback)(struct dchannel *, u_int); | ||
115 | extern int create_l1(struct dchannel *, dchannel_l1callback *); | ||
116 | |||
117 | /* private L1 commands */ | ||
118 | #define INFO0 0x8002 | ||
119 | #define INFO1 0x8102 | ||
120 | #define INFO2 0x8202 | ||
121 | #define INFO3_P8 0x8302 | ||
122 | #define INFO3_P10 0x8402 | ||
123 | #define INFO4_P8 0x8502 | ||
124 | #define INFO4_P10 0x8602 | ||
125 | #define LOSTFRAMING 0x8702 | ||
126 | #define ANYSIGNAL 0x8802 | ||
127 | #define HW_POWERDOWN 0x8902 | ||
128 | #define HW_RESET_REQ 0x8a02 | ||
129 | #define HW_POWERUP_REQ 0x8b02 | ||
130 | #define HW_DEACT_REQ 0x8c02 | ||
131 | #define HW_ACTIVATE_REQ 0x8e02 | ||
132 | #define HW_D_NOBLOCKED 0x8f02 | ||
133 | #define HW_RESET_IND 0x9002 | ||
134 | #define HW_POWERUP_IND 0x9102 | ||
135 | #define HW_DEACT_IND 0x9202 | ||
136 | #define HW_ACTIVATE_IND 0x9302 | ||
137 | #define HW_DEACT_CNF 0x9402 | ||
138 | #define HW_TESTLOOP 0x9502 | ||
139 | #define HW_TESTRX_RAW 0x9602 | ||
140 | #define HW_TESTRX_HDLC 0x9702 | ||
141 | #define HW_TESTRX_OFF 0x9802 | ||
142 | |||
143 | struct layer1; | ||
144 | extern int l1_event(struct layer1 *, u_int); | ||
145 | |||
146 | |||
147 | struct bchannel { | ||
148 | struct mISDNchannel ch; | ||
149 | int nr; | ||
150 | u_long Flags; | ||
151 | struct work_struct workq; | ||
152 | u_int state; | ||
153 | /* HW access */ | ||
154 | u_char (*read_reg) (void *, u_char); | ||
155 | void (*write_reg) (void *, u_char, u_char); | ||
156 | void (*read_fifo) (void *, u_char *, int); | ||
157 | void (*write_fifo) (void *, u_char *, int); | ||
158 | void *hw; | ||
159 | int slot; /* multiport card channel slot */ | ||
160 | struct timer_list timer; | ||
161 | /* receive data */ | ||
162 | struct sk_buff *rx_skb; | ||
163 | int maxlen; | ||
164 | /* send data */ | ||
165 | struct sk_buff *next_skb; | ||
166 | struct sk_buff *tx_skb; | ||
167 | struct sk_buff_head rqueue; | ||
168 | int rcount; | ||
169 | int tx_idx; | ||
170 | int debug; | ||
171 | /* statistics */ | ||
172 | int err_crc; | ||
173 | int err_tx; | ||
174 | int err_rx; | ||
175 | }; | ||
176 | |||
177 | extern int mISDN_initdchannel(struct dchannel *, int, void *); | ||
178 | extern int mISDN_initbchannel(struct bchannel *, int); | ||
179 | extern int mISDN_freedchannel(struct dchannel *); | ||
180 | extern int mISDN_freebchannel(struct bchannel *); | ||
181 | extern void queue_ch_frame(struct mISDNchannel *, u_int, | ||
182 | int, struct sk_buff *); | ||
183 | extern int dchannel_senddata(struct dchannel *, struct sk_buff *); | ||
184 | extern int bchannel_senddata(struct bchannel *, struct sk_buff *); | ||
185 | extern void recv_Dchannel(struct dchannel *); | ||
186 | extern void recv_Bchannel(struct bchannel *); | ||
187 | extern void recv_Dchannel_skb(struct dchannel *, struct sk_buff *); | ||
188 | extern void recv_Bchannel_skb(struct bchannel *, struct sk_buff *); | ||
189 | extern void confirm_Bsend(struct bchannel *bch); | ||
190 | extern int get_next_bframe(struct bchannel *); | ||
191 | extern int get_next_dframe(struct dchannel *); | ||
192 | |||
193 | #endif | ||
diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h new file mode 100644 index 000000000000..5c948f337817 --- /dev/null +++ b/include/linux/mISDNif.h | |||
@@ -0,0 +1,487 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Author Karsten Keil <kkeil@novell.com> | ||
4 | * | ||
5 | * Copyright 2008 by Karsten Keil <kkeil@novell.com> | ||
6 | * | ||
7 | * This code is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE | ||
9 | * version 2.1 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This code is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU LESSER GENERAL PUBLIC LICENSE for more details. | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #ifndef mISDNIF_H | ||
19 | #define mISDNIF_H | ||
20 | |||
21 | #include <stdarg.h> | ||
22 | #include <linux/types.h> | ||
23 | #include <linux/errno.h> | ||
24 | #include <linux/socket.h> | ||
25 | |||
26 | /* | ||
27 | * ABI Version 32 bit | ||
28 | * | ||
29 | * <8 bit> Major version | ||
30 | * - changed if any interface become backwards incompatible | ||
31 | * | ||
32 | * <8 bit> Minor version | ||
33 | * - changed if any interface is extended but backwards compatible | ||
34 | * | ||
35 | * <16 bit> Release number | ||
36 | * - should be incremented on every checkin | ||
37 | */ | ||
38 | #define MISDN_MAJOR_VERSION 1 | ||
39 | #define MISDN_MINOR_VERSION 0 | ||
40 | #define MISDN_RELEASE 18 | ||
41 | |||
42 | /* primitives for information exchange | ||
43 | * generell format | ||
44 | * <16 bit 0 > | ||
45 | * <8 bit command> | ||
46 | * BIT 8 = 1 LAYER private | ||
47 | * BIT 7 = 1 answer | ||
48 | * BIT 6 = 1 DATA | ||
49 | * <8 bit target layer mask> | ||
50 | * | ||
51 | * Layer = 00 is reserved for general commands | ||
52 | Layer = 01 L2 -> HW | ||
53 | Layer = 02 HW -> L2 | ||
54 | Layer = 04 L3 -> L2 | ||
55 | Layer = 08 L2 -> L3 | ||
56 | * Layer = FF is reserved for broadcast commands | ||
57 | */ | ||
58 | |||
59 | #define MISDN_CMDMASK 0xff00 | ||
60 | #define MISDN_LAYERMASK 0x00ff | ||
61 | |||
62 | /* generell commands */ | ||
63 | #define OPEN_CHANNEL 0x0100 | ||
64 | #define CLOSE_CHANNEL 0x0200 | ||
65 | #define CONTROL_CHANNEL 0x0300 | ||
66 | #define CHECK_DATA 0x0400 | ||
67 | |||
68 | /* layer 2 -> layer 1 */ | ||
69 | #define PH_ACTIVATE_REQ 0x0101 | ||
70 | #define PH_DEACTIVATE_REQ 0x0201 | ||
71 | #define PH_DATA_REQ 0x2001 | ||
72 | #define MPH_ACTIVATE_REQ 0x0501 | ||
73 | #define MPH_DEACTIVATE_REQ 0x0601 | ||
74 | #define MPH_INFORMATION_REQ 0x0701 | ||
75 | #define PH_CONTROL_REQ 0x0801 | ||
76 | |||
77 | /* layer 1 -> layer 2 */ | ||
78 | #define PH_ACTIVATE_IND 0x0102 | ||
79 | #define PH_ACTIVATE_CNF 0x4102 | ||
80 | #define PH_DEACTIVATE_IND 0x0202 | ||
81 | #define PH_DEACTIVATE_CNF 0x4202 | ||
82 | #define PH_DATA_IND 0x2002 | ||
83 | #define MPH_ACTIVATE_IND 0x0502 | ||
84 | #define MPH_DEACTIVATE_IND 0x0602 | ||
85 | #define MPH_INFORMATION_IND 0x0702 | ||
86 | #define PH_DATA_CNF 0x6002 | ||
87 | #define PH_CONTROL_IND 0x0802 | ||
88 | #define PH_CONTROL_CNF 0x4802 | ||
89 | |||
90 | /* layer 3 -> layer 2 */ | ||
91 | #define DL_ESTABLISH_REQ 0x1004 | ||
92 | #define DL_RELEASE_REQ 0x1104 | ||
93 | #define DL_DATA_REQ 0x3004 | ||
94 | #define DL_UNITDATA_REQ 0x3104 | ||
95 | #define DL_INFORMATION_REQ 0x0004 | ||
96 | |||
97 | /* layer 2 -> layer 3 */ | ||
98 | #define DL_ESTABLISH_IND 0x1008 | ||
99 | #define DL_ESTABLISH_CNF 0x5008 | ||
100 | #define DL_RELEASE_IND 0x1108 | ||
101 | #define DL_RELEASE_CNF 0x5108 | ||
102 | #define DL_DATA_IND 0x3008 | ||
103 | #define DL_UNITDATA_IND 0x3108 | ||
104 | #define DL_INFORMATION_IND 0x0008 | ||
105 | |||
106 | /* intern layer 2 managment */ | ||
107 | #define MDL_ASSIGN_REQ 0x1804 | ||
108 | #define MDL_ASSIGN_IND 0x1904 | ||
109 | #define MDL_REMOVE_REQ 0x1A04 | ||
110 | #define MDL_REMOVE_IND 0x1B04 | ||
111 | #define MDL_STATUS_UP_IND 0x1C04 | ||
112 | #define MDL_STATUS_DOWN_IND 0x1D04 | ||
113 | #define MDL_STATUS_UI_IND 0x1E04 | ||
114 | #define MDL_ERROR_IND 0x1F04 | ||
115 | #define MDL_ERROR_RSP 0x5F04 | ||
116 | |||
117 | /* DL_INFORMATION_IND types */ | ||
118 | #define DL_INFO_L2_CONNECT 0x0001 | ||
119 | #define DL_INFO_L2_REMOVED 0x0002 | ||
120 | |||
121 | /* PH_CONTROL types */ | ||
122 | /* TOUCH TONE IS 0x20XX XX "0"..."9", "A","B","C","D","*","#" */ | ||
123 | #define DTMF_TONE_VAL 0x2000 | ||
124 | #define DTMF_TONE_MASK 0x007F | ||
125 | #define DTMF_TONE_START 0x2100 | ||
126 | #define DTMF_TONE_STOP 0x2200 | ||
127 | #define DTMF_HFC_COEF 0x4000 | ||
128 | #define DSP_CONF_JOIN 0x2403 | ||
129 | #define DSP_CONF_SPLIT 0x2404 | ||
130 | #define DSP_RECEIVE_OFF 0x2405 | ||
131 | #define DSP_RECEIVE_ON 0x2406 | ||
132 | #define DSP_ECHO_ON 0x2407 | ||
133 | #define DSP_ECHO_OFF 0x2408 | ||
134 | #define DSP_MIX_ON 0x2409 | ||
135 | #define DSP_MIX_OFF 0x240a | ||
136 | #define DSP_DELAY 0x240b | ||
137 | #define DSP_JITTER 0x240c | ||
138 | #define DSP_TXDATA_ON 0x240d | ||
139 | #define DSP_TXDATA_OFF 0x240e | ||
140 | #define DSP_TX_DEJITTER 0x240f | ||
141 | #define DSP_TX_DEJ_OFF 0x2410 | ||
142 | #define DSP_TONE_PATT_ON 0x2411 | ||
143 | #define DSP_TONE_PATT_OFF 0x2412 | ||
144 | #define DSP_VOL_CHANGE_TX 0x2413 | ||
145 | #define DSP_VOL_CHANGE_RX 0x2414 | ||
146 | #define DSP_BF_ENABLE_KEY 0x2415 | ||
147 | #define DSP_BF_DISABLE 0x2416 | ||
148 | #define DSP_BF_ACCEPT 0x2416 | ||
149 | #define DSP_BF_REJECT 0x2417 | ||
150 | #define DSP_PIPELINE_CFG 0x2418 | ||
151 | #define HFC_VOL_CHANGE_TX 0x2601 | ||
152 | #define HFC_VOL_CHANGE_RX 0x2602 | ||
153 | #define HFC_SPL_LOOP_ON 0x2603 | ||
154 | #define HFC_SPL_LOOP_OFF 0x2604 | ||
155 | |||
156 | /* DSP_TONE_PATT_ON parameter */ | ||
157 | #define TONE_OFF 0x0000 | ||
158 | #define TONE_GERMAN_DIALTONE 0x0001 | ||
159 | #define TONE_GERMAN_OLDDIALTONE 0x0002 | ||
160 | #define TONE_AMERICAN_DIALTONE 0x0003 | ||
161 | #define TONE_GERMAN_DIALPBX 0x0004 | ||
162 | #define TONE_GERMAN_OLDDIALPBX 0x0005 | ||
163 | #define TONE_AMERICAN_DIALPBX 0x0006 | ||
164 | #define TONE_GERMAN_RINGING 0x0007 | ||
165 | #define TONE_GERMAN_OLDRINGING 0x0008 | ||
166 | #define TONE_AMERICAN_RINGPBX 0x000b | ||
167 | #define TONE_GERMAN_RINGPBX 0x000c | ||
168 | #define TONE_GERMAN_OLDRINGPBX 0x000d | ||
169 | #define TONE_AMERICAN_RINGING 0x000e | ||
170 | #define TONE_GERMAN_BUSY 0x000f | ||
171 | #define TONE_GERMAN_OLDBUSY 0x0010 | ||
172 | #define TONE_AMERICAN_BUSY 0x0011 | ||
173 | #define TONE_GERMAN_HANGUP 0x0012 | ||
174 | #define TONE_GERMAN_OLDHANGUP 0x0013 | ||
175 | #define TONE_AMERICAN_HANGUP 0x0014 | ||
176 | #define TONE_SPECIAL_INFO 0x0015 | ||
177 | #define TONE_GERMAN_GASSENBESETZT 0x0016 | ||
178 | #define TONE_GERMAN_AUFSCHALTTON 0x0016 | ||
179 | |||
180 | /* MPH_INFORMATION_IND */ | ||
181 | #define L1_SIGNAL_LOS_OFF 0x0010 | ||
182 | #define L1_SIGNAL_LOS_ON 0x0011 | ||
183 | #define L1_SIGNAL_AIS_OFF 0x0012 | ||
184 | #define L1_SIGNAL_AIS_ON 0x0013 | ||
185 | #define L1_SIGNAL_RDI_OFF 0x0014 | ||
186 | #define L1_SIGNAL_RDI_ON 0x0015 | ||
187 | #define L1_SIGNAL_SLIP_RX 0x0020 | ||
188 | #define L1_SIGNAL_SLIP_TX 0x0021 | ||
189 | |||
190 | /* | ||
191 | * protocol ids | ||
192 | * D channel 1-31 | ||
193 | * B channel 33 - 63 | ||
194 | */ | ||
195 | |||
196 | #define ISDN_P_NONE 0 | ||
197 | #define ISDN_P_BASE 0 | ||
198 | #define ISDN_P_TE_S0 0x01 | ||
199 | #define ISDN_P_NT_S0 0x02 | ||
200 | #define ISDN_P_TE_E1 0x03 | ||
201 | #define ISDN_P_NT_E1 0x04 | ||
202 | #define ISDN_P_LAPD_TE 0x10 | ||
203 | #define ISDN_P_LAPD_NT 0x11 | ||
204 | |||
205 | #define ISDN_P_B_MASK 0x1f | ||
206 | #define ISDN_P_B_START 0x20 | ||
207 | |||
208 | #define ISDN_P_B_RAW 0x21 | ||
209 | #define ISDN_P_B_HDLC 0x22 | ||
210 | #define ISDN_P_B_X75SLP 0x23 | ||
211 | #define ISDN_P_B_L2DTMF 0x24 | ||
212 | #define ISDN_P_B_L2DSP 0x25 | ||
213 | #define ISDN_P_B_L2DSPHDLC 0x26 | ||
214 | |||
215 | #define OPTION_L2_PMX 1 | ||
216 | #define OPTION_L2_PTP 2 | ||
217 | #define OPTION_L2_FIXEDTEI 3 | ||
218 | #define OPTION_L2_CLEANUP 4 | ||
219 | |||
220 | /* should be in sync with linux/kobject.h:KOBJ_NAME_LEN */ | ||
221 | #define MISDN_MAX_IDLEN 20 | ||
222 | |||
223 | struct mISDNhead { | ||
224 | unsigned int prim; | ||
225 | unsigned int id; | ||
226 | } __attribute__((packed)); | ||
227 | |||
228 | #define MISDN_HEADER_LEN sizeof(struct mISDNhead) | ||
229 | #define MAX_DATA_SIZE 2048 | ||
230 | #define MAX_DATA_MEM (MAX_DATA_SIZE + MISDN_HEADER_LEN) | ||
231 | #define MAX_DFRAME_LEN 260 | ||
232 | |||
233 | #define MISDN_ID_ADDR_MASK 0xFFFF | ||
234 | #define MISDN_ID_TEI_MASK 0xFF00 | ||
235 | #define MISDN_ID_SAPI_MASK 0x00FF | ||
236 | #define MISDN_ID_TEI_ANY 0x7F00 | ||
237 | |||
238 | #define MISDN_ID_ANY 0xFFFF | ||
239 | #define MISDN_ID_NONE 0xFFFE | ||
240 | |||
241 | #define GROUP_TEI 127 | ||
242 | #define TEI_SAPI 63 | ||
243 | #define CTRL_SAPI 0 | ||
244 | |||
245 | #define MISDN_CHMAP_SIZE 4 | ||
246 | |||
247 | #define SOL_MISDN 0 | ||
248 | |||
249 | struct sockaddr_mISDN { | ||
250 | sa_family_t family; | ||
251 | unsigned char dev; | ||
252 | unsigned char channel; | ||
253 | unsigned char sapi; | ||
254 | unsigned char tei; | ||
255 | }; | ||
256 | |||
257 | /* timer device ioctl */ | ||
258 | #define IMADDTIMER _IOR('I', 64, int) | ||
259 | #define IMDELTIMER _IOR('I', 65, int) | ||
260 | /* socket ioctls */ | ||
261 | #define IMGETVERSION _IOR('I', 66, int) | ||
262 | #define IMGETCOUNT _IOR('I', 67, int) | ||
263 | #define IMGETDEVINFO _IOR('I', 68, int) | ||
264 | #define IMCTRLREQ _IOR('I', 69, int) | ||
265 | #define IMCLEAR_L2 _IOR('I', 70, int) | ||
266 | |||
267 | struct mISDNversion { | ||
268 | unsigned char major; | ||
269 | unsigned char minor; | ||
270 | unsigned short release; | ||
271 | }; | ||
272 | |||
273 | struct mISDN_devinfo { | ||
274 | u_int id; | ||
275 | u_int Dprotocols; | ||
276 | u_int Bprotocols; | ||
277 | u_int protocol; | ||
278 | u_long channelmap[MISDN_CHMAP_SIZE]; | ||
279 | u_int nrbchan; | ||
280 | char name[MISDN_MAX_IDLEN]; | ||
281 | }; | ||
282 | |||
283 | /* CONTROL_CHANNEL parameters */ | ||
284 | #define MISDN_CTRL_GETOP 0x0000 | ||
285 | #define MISDN_CTRL_LOOP 0x0001 | ||
286 | #define MISDN_CTRL_CONNECT 0x0002 | ||
287 | #define MISDN_CTRL_DISCONNECT 0x0004 | ||
288 | #define MISDN_CTRL_PCMCONNECT 0x0010 | ||
289 | #define MISDN_CTRL_PCMDISCONNECT 0x0020 | ||
290 | #define MISDN_CTRL_SETPEER 0x0040 | ||
291 | #define MISDN_CTRL_UNSETPEER 0x0080 | ||
292 | #define MISDN_CTRL_RX_OFF 0x0100 | ||
293 | #define MISDN_CTRL_HW_FEATURES_OP 0x2000 | ||
294 | #define MISDN_CTRL_HW_FEATURES 0x2001 | ||
295 | #define MISDN_CTRL_HFC_OP 0x4000 | ||
296 | #define MISDN_CTRL_HFC_PCM_CONN 0x4001 | ||
297 | #define MISDN_CTRL_HFC_PCM_DISC 0x4002 | ||
298 | #define MISDN_CTRL_HFC_CONF_JOIN 0x4003 | ||
299 | #define MISDN_CTRL_HFC_CONF_SPLIT 0x4004 | ||
300 | #define MISDN_CTRL_HFC_RECEIVE_OFF 0x4005 | ||
301 | #define MISDN_CTRL_HFC_RECEIVE_ON 0x4006 | ||
302 | #define MISDN_CTRL_HFC_ECHOCAN_ON 0x4007 | ||
303 | #define MISDN_CTRL_HFC_ECHOCAN_OFF 0x4008 | ||
304 | |||
305 | |||
306 | /* socket options */ | ||
307 | #define MISDN_TIME_STAMP 0x0001 | ||
308 | |||
309 | struct mISDN_ctrl_req { | ||
310 | int op; | ||
311 | int channel; | ||
312 | int p1; | ||
313 | int p2; | ||
314 | }; | ||
315 | |||
316 | /* muxer options */ | ||
317 | #define MISDN_OPT_ALL 1 | ||
318 | #define MISDN_OPT_TEIMGR 2 | ||
319 | |||
320 | #ifdef __KERNEL__ | ||
321 | #include <linux/list.h> | ||
322 | #include <linux/skbuff.h> | ||
323 | #include <linux/net.h> | ||
324 | #include <net/sock.h> | ||
325 | #include <linux/completion.h> | ||
326 | |||
327 | #define DEBUG_CORE 0x000000ff | ||
328 | #define DEBUG_CORE_FUNC 0x00000002 | ||
329 | #define DEBUG_SOCKET 0x00000004 | ||
330 | #define DEBUG_MANAGER 0x00000008 | ||
331 | #define DEBUG_SEND_ERR 0x00000010 | ||
332 | #define DEBUG_MSG_THREAD 0x00000020 | ||
333 | #define DEBUG_QUEUE_FUNC 0x00000040 | ||
334 | #define DEBUG_L1 0x0000ff00 | ||
335 | #define DEBUG_L1_FSM 0x00000200 | ||
336 | #define DEBUG_L2 0x00ff0000 | ||
337 | #define DEBUG_L2_FSM 0x00020000 | ||
338 | #define DEBUG_L2_CTRL 0x00040000 | ||
339 | #define DEBUG_L2_RECV 0x00080000 | ||
340 | #define DEBUG_L2_TEI 0x00100000 | ||
341 | #define DEBUG_L2_TEIFSM 0x00200000 | ||
342 | #define DEBUG_TIMER 0x01000000 | ||
343 | |||
344 | #define mISDN_HEAD_P(s) ((struct mISDNhead *)&s->cb[0]) | ||
345 | #define mISDN_HEAD_PRIM(s) (((struct mISDNhead *)&s->cb[0])->prim) | ||
346 | #define mISDN_HEAD_ID(s) (((struct mISDNhead *)&s->cb[0])->id) | ||
347 | |||
348 | /* socket states */ | ||
349 | #define MISDN_OPEN 1 | ||
350 | #define MISDN_BOUND 2 | ||
351 | #define MISDN_CLOSED 3 | ||
352 | |||
353 | struct mISDNchannel; | ||
354 | struct mISDNdevice; | ||
355 | struct mISDNstack; | ||
356 | |||
357 | struct channel_req { | ||
358 | u_int protocol; | ||
359 | struct sockaddr_mISDN adr; | ||
360 | struct mISDNchannel *ch; | ||
361 | }; | ||
362 | |||
363 | typedef int (ctrl_func_t)(struct mISDNchannel *, u_int, void *); | ||
364 | typedef int (send_func_t)(struct mISDNchannel *, struct sk_buff *); | ||
365 | typedef int (create_func_t)(struct channel_req *); | ||
366 | |||
367 | struct Bprotocol { | ||
368 | struct list_head list; | ||
369 | char *name; | ||
370 | u_int Bprotocols; | ||
371 | create_func_t *create; | ||
372 | }; | ||
373 | |||
374 | struct mISDNchannel { | ||
375 | struct list_head list; | ||
376 | u_int protocol; | ||
377 | u_int nr; | ||
378 | u_long opt; | ||
379 | u_int addr; | ||
380 | struct mISDNstack *st; | ||
381 | struct mISDNchannel *peer; | ||
382 | send_func_t *send; | ||
383 | send_func_t *recv; | ||
384 | ctrl_func_t *ctrl; | ||
385 | }; | ||
386 | |||
387 | struct mISDN_sock_list { | ||
388 | struct hlist_head head; | ||
389 | rwlock_t lock; | ||
390 | }; | ||
391 | |||
392 | struct mISDN_sock { | ||
393 | struct sock sk; | ||
394 | struct mISDNchannel ch; | ||
395 | u_int cmask; | ||
396 | struct mISDNdevice *dev; | ||
397 | }; | ||
398 | |||
399 | |||
400 | |||
401 | struct mISDNdevice { | ||
402 | struct mISDNchannel D; | ||
403 | u_int id; | ||
404 | char name[MISDN_MAX_IDLEN]; | ||
405 | u_int Dprotocols; | ||
406 | u_int Bprotocols; | ||
407 | u_int nrbchan; | ||
408 | u_long channelmap[MISDN_CHMAP_SIZE]; | ||
409 | struct list_head bchannels; | ||
410 | struct mISDNchannel *teimgr; | ||
411 | struct device dev; | ||
412 | }; | ||
413 | |||
414 | struct mISDNstack { | ||
415 | u_long status; | ||
416 | struct mISDNdevice *dev; | ||
417 | struct task_struct *thread; | ||
418 | struct completion *notify; | ||
419 | wait_queue_head_t workq; | ||
420 | struct sk_buff_head msgq; | ||
421 | struct list_head layer2; | ||
422 | struct mISDNchannel *layer1; | ||
423 | struct mISDNchannel own; | ||
424 | struct mutex lmutex; /* protect lists */ | ||
425 | struct mISDN_sock_list l1sock; | ||
426 | #ifdef MISDN_MSG_STATS | ||
427 | u_int msg_cnt; | ||
428 | u_int sleep_cnt; | ||
429 | u_int stopped_cnt; | ||
430 | #endif | ||
431 | }; | ||
432 | |||
433 | /* global alloc/queue dunctions */ | ||
434 | |||
435 | static inline struct sk_buff * | ||
436 | mI_alloc_skb(unsigned int len, gfp_t gfp_mask) | ||
437 | { | ||
438 | struct sk_buff *skb; | ||
439 | |||
440 | skb = alloc_skb(len + MISDN_HEADER_LEN, gfp_mask); | ||
441 | if (likely(skb)) | ||
442 | skb_reserve(skb, MISDN_HEADER_LEN); | ||
443 | return skb; | ||
444 | } | ||
445 | |||
446 | static inline struct sk_buff * | ||
447 | _alloc_mISDN_skb(u_int prim, u_int id, u_int len, void *dp, gfp_t gfp_mask) | ||
448 | { | ||
449 | struct sk_buff *skb = mI_alloc_skb(len, gfp_mask); | ||
450 | struct mISDNhead *hh; | ||
451 | |||
452 | if (!skb) | ||
453 | return NULL; | ||
454 | if (len) | ||
455 | memcpy(skb_put(skb, len), dp, len); | ||
456 | hh = mISDN_HEAD_P(skb); | ||
457 | hh->prim = prim; | ||
458 | hh->id = id; | ||
459 | return skb; | ||
460 | } | ||
461 | |||
462 | static inline void | ||
463 | _queue_data(struct mISDNchannel *ch, u_int prim, | ||
464 | u_int id, u_int len, void *dp, gfp_t gfp_mask) | ||
465 | { | ||
466 | struct sk_buff *skb; | ||
467 | |||
468 | if (!ch->peer) | ||
469 | return; | ||
470 | skb = _alloc_mISDN_skb(prim, id, len, dp, gfp_mask); | ||
471 | if (!skb) | ||
472 | return; | ||
473 | if (ch->recv(ch->peer, skb)) | ||
474 | dev_kfree_skb(skb); | ||
475 | } | ||
476 | |||
477 | /* global register/unregister functions */ | ||
478 | |||
479 | extern int mISDN_register_device(struct mISDNdevice *, char *name); | ||
480 | extern void mISDN_unregister_device(struct mISDNdevice *); | ||
481 | extern int mISDN_register_Bprotocol(struct Bprotocol *); | ||
482 | extern void mISDN_unregister_Bprotocol(struct Bprotocol *); | ||
483 | |||
484 | extern void set_channel_address(struct mISDNchannel *, u_int, u_int); | ||
485 | |||
486 | #endif /* __KERNEL__ */ | ||
487 | #endif /* mISDNIF_H */ | ||