This source file includes following definitions.
- strisdnevent
- pcbit_fsm_timer
- pcbit_fsm_event
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #define __NO_VERSION__
21
22 #include <linux/module.h>
23
24 #include <linux/sched.h>
25 #include <linux/string.h>
26 #include <linux/kernel.h>
27
28 #include <linux/types.h>
29 #include <linux/malloc.h>
30 #include <linux/mm.h>
31 #include <linux/tqueue.h>
32 #include <linux/skbuff.h>
33
34 #include <linux/timer.h>
35 #include <asm/io.h>
36
37 #include <linux/isdnif.h>
38
39 #include "pcbit.h"
40 #include "edss1.h"
41 #include "layer2.h"
42 #include "callbacks.h"
43
44
45 extern void pcbit_state_change(struct pcbit_dev *, struct pcbit_chan *,
46 unsigned short i, unsigned short ev,
47 unsigned short f);
48
49 extern struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS];
50
51 char * isdn_state_table[] = {
52 "Closed",
53 "Call initiated",
54 "Overlap sending",
55 "Outgoing call proceeding",
56 "NOT DEFINED",
57 "Call delivered",
58 "Call present",
59 "Call received",
60 "Connect request",
61 "Incoming call proceeding",
62 "Active",
63 "Disconnect request",
64 "Disconnect indication",
65 "NOT DEFINED",
66 "NOT DEFINED",
67 "Suspend request",
68 "NOT DEFINED",
69 "Resume request",
70 "NOT DEFINED",
71 "Release Request",
72 "NOT DEFINED",
73 "NOT DEFINED",
74 "NOT DEFINED",
75 "NOT DEFINED",
76 "NOT DEFINED",
77 "Overlap receiving",
78 "Select protocol on B-Channel",
79 "Activate B-channel protocol"
80 };
81
82 #ifdef DEBUG_ERRS
83 static
84 struct CauseValue {
85 byte nr;
86 char *descr;
87 } cvlist[]={
88 {0x01,"Unallocated (unassigned) number"},
89 {0x02,"No route to specified transit network"},
90 {0x03,"No route to destination"},
91 {0x04,"Send special information tone"},
92 {0x05,"Misdialled trunk prefix"},
93 {0x06,"Channel unacceptable"},
94 {0x07,"Channel awarded and being delivered in an established channel"},
95 {0x08,"Preemption"},
96 {0x09,"Preemption - circuit reserved for reuse"},
97 {0x10,"Normal call clearing"},
98 {0x11,"User busy"},
99 {0x12,"No user responding"},
100 {0x13,"No answer from user (user alerted)"},
101 {0x14,"Subscriber absent"},
102 {0x15,"Call rejected"},
103 {0x16,"Number changed"},
104 {0x1a,"non-selected user clearing"},
105 {0x1b,"Destination out of order"},
106 {0x1c,"Invalid number format (address incomplete)"},
107 {0x1d,"Facility rejected"},
108 {0x1e,"Response to Status enquiry"},
109 {0x1f,"Normal, unspecified"},
110 {0x22,"No circuit/channel available"},
111 {0x26,"Network out of order"},
112 {0x27,"Permanent frame mode connection out-of-service"},
113 {0x28,"Permanent frame mode connection operational"},
114 {0x29,"Temporary failure"},
115 {0x2a,"Switching equipment congestion"},
116 {0x2b,"Access information discarded"},
117 {0x2c,"Requested circuit/channel not available"},
118 {0x2e,"Precedence call blocked"},
119 {0x2f,"Resource unavailable, unspecified"},
120 {0x31,"Quality of service unavailable"},
121 {0x32,"Requested facility not subscribed"},
122 {0x35,"Outgoing calls barred within CUG"},
123 {0x37,"Incoming calls barred within CUG"},
124 {0x39,"Bearer capability not authorized"},
125 {0x3a,"Bearer capability not presently available"},
126 {0x3e,"Inconsistency in designated outgoing access information and subscriber class"},
127 {0x3f,"Service or option not available, unspecified"},
128 {0x41,"Bearer capability not implemented"},
129 {0x42,"Channel type not implemented"},
130 {0x43,"Requested facility not implemented"},
131 {0x44,"Only restricted digital information bearer capability is available"},
132 {0x4f,"Service or option not implemented"},
133 {0x51,"Invalid call reference value"},
134 {0x52,"Identified channel does not exist"},
135 {0x53,"A suspended call exists, but this call identity does not"},
136 {0x54,"Call identity in use"},
137 {0x55,"No call suspended"},
138 {0x56,"Call having the requested call identity has been cleared"},
139 {0x57,"User not member of CUG"},
140 {0x58,"Incompatible destination"},
141 {0x5a,"Non-existent CUG"},
142 {0x5b,"Invalid transit network selection"},
143 {0x5f,"Invalid message, unspecified"},
144 {0x60,"Mandatory information element is missing"},
145 {0x61,"Message type non-existent or not implemented"},
146 {0x62,"Message not compatible with call state or message type non-existent or not implemented"},
147 {0x63,"Information element/parameter non-existent or not implemented"},
148 {0x64,"Invalid information element contents"},
149 {0x65,"Message not compatible with call state"},
150 {0x66,"Recovery on timer expiry"},
151 {0x67,"Parameter non-existent or not implemented - passed on"},
152 {0x6e,"Message with unrecognized parameter discarded"},
153 {0x6f,"Protocol error, unspecified"},
154 {0x7f,"Interworking, unspecified"}
155 };
156
157 #endif
158
159 static struct isdn_event_desc {
160 unsigned short ev;
161 char * desc;
162 } isdn_event_table [] = {
163 {EV_USR_SETUP_REQ, "CC->L3: Setup Request"},
164 {EV_USR_SETUP_RESP, "CC->L3: Setup Response"},
165 {EV_USR_PROCED_REQ, "CC->L3: Proceeding Request"},
166 {EV_USR_RELEASE_REQ, "CC->L3: Release Request"},
167
168 {EV_NET_SETUP, "NET->TE: setup "},
169 {EV_NET_CALL_PROC, "NET->TE: call proceeding"},
170 {EV_NET_SETUP_ACK, "NET->TE: setup acknowledge (more info needed)"},
171 {EV_NET_CONN, "NET->TE: connect"},
172 {EV_NET_CONN_ACK, "NET->TE: connect acknowledge"},
173 {EV_NET_DISC, "NET->TE: disconnect indication"},
174 {EV_NET_RELEASE, "NET->TE: release"},
175 {EV_NET_RELEASE_COMP, "NET->TE: release complete"},
176 {EV_NET_SELP_RESP, "Board: Select B-channel protocol ack"},
177 {EV_NET_ACTV_RESP, "Board: Activate B-channel protocol ack"},
178 {EV_TIMER, "Timeout"},
179 {0, "NULL"}
180 };
181
182 char * strisdnevent(ushort ev)
183 {
184 struct isdn_event_desc * entry;
185
186 for (entry = isdn_event_table; entry->ev; entry++)
187 if (entry->ev == ev)
188 break;
189
190 return entry->desc;
191 }
192
193
194
195
196
197 static struct fsm_timer_entry fsm_timers[] = {
198 {ST_CALL_PROC, 10},
199 {ST_DISC_REQ, 2},
200 {ST_ACTIVE_SELP, 5},
201 {ST_ACTIVE_ACTV, 5},
202 {ST_INCM_PROC, 10},
203 {ST_CONN_REQ, 2},
204 {0xff, 0}
205 };
206
207 static struct fsm_entry fsm_table[] = {
208
209
210 {ST_NULL, ST_CALL_INIT, EV_USR_SETUP_REQ, cb_out_1},
211
212 {ST_CALL_INIT, ST_OVER_SEND, EV_NET_SETUP_ACK, cb_notdone},
213 {ST_CALL_INIT, ST_CALL_PROC, EV_NET_CALL_PROC, NULL},
214 {ST_CALL_INIT, ST_NULL, EV_NET_DISC, cb_out_2},
215
216 {ST_CALL_PROC, ST_ACTIVE_SELP, EV_NET_CONN, cb_out_2},
217 {ST_CALL_PROC, ST_NULL, EV_NET_DISC, cb_disc_1},
218 {ST_CALL_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2},
219
220
221 {ST_NULL, ST_CALL_PRES, EV_NET_SETUP, NULL},
222
223 {ST_CALL_PRES, ST_INCM_PROC, EV_USR_PROCED_REQ, cb_in_1},
224 {ST_CALL_PRES, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2},
225
226 {ST_INCM_PROC, ST_CONN_REQ, EV_USR_SETUP_RESP, cb_in_2},
227 {ST_INCM_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2},
228
229 {ST_CONN_REQ, ST_ACTIVE_SELP, EV_NET_CONN_ACK, cb_in_3},
230
231
232 {ST_ACTIVE, ST_NULL, EV_NET_DISC, cb_disc_1},
233 {ST_ACTIVE, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2},
234 {ST_ACTIVE, ST_NULL, EV_NET_RELEASE, cb_disc_3},
235
236
237
238 {ST_DISC_REQ, ST_NULL, EV_NET_DISC, cb_disc_1},
239 {ST_DISC_REQ, ST_NULL, EV_NET_RELEASE, cb_disc_3},
240
241
242 {ST_ACTIVE_SELP, ST_ACTIVE_ACTV, EV_NET_SELP_RESP, cb_selp_1},
243 {ST_ACTIVE_SELP, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2},
244
245 {ST_ACTIVE_ACTV, ST_ACTIVE, EV_NET_ACTV_RESP, cb_open},
246 {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2},
247
248
249 {ST_CALL_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2},
250 {ST_DISC_REQ, ST_NULL, EV_TIMER, cb_disc_3},
251 {ST_ACTIVE_SELP, ST_DISC_REQ, EV_TIMER, cb_disc_2},
252 {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_TIMER, cb_disc_2},
253 {ST_INCM_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2},
254 {ST_CONN_REQ, ST_CONN_REQ, EV_TIMER, cb_in_2},
255
256 {0xff, 0, 0, NULL}
257 };
258
259
260 static void pcbit_fsm_timer(unsigned long data)
261 {
262 struct pcbit_dev *dev;
263 struct pcbit_chan *chan;
264
265 chan = (struct pcbit_chan *) data;
266
267 del_timer(&chan->fsm_timer);
268 chan->fsm_timer.function = NULL;
269
270 dev = chan2dev(chan);
271
272 if (dev == NULL) {
273 printk(KERN_WARNING "pcbit: timer for unknown device\n");
274 return;
275 }
276
277 pcbit_fsm_event(dev, chan, EV_TIMER, NULL);
278 }
279
280
281 void pcbit_fsm_event(struct pcbit_dev *dev, struct pcbit_chan *chan,
282 unsigned short event, struct callb_data *data)
283 {
284 struct fsm_entry * action;
285 struct fsm_timer_entry *tentry;
286 unsigned long flags;
287
288 save_flags(flags);
289 cli();
290
291 if (chan->fsm_timer.function) {
292 del_timer(&chan->fsm_timer);
293 chan->fsm_timer.function = NULL;
294 }
295
296 for (action = fsm_table; action->init != 0xff; action++)
297 if (action->init == chan->fsm_state && action->event == event)
298 break;
299
300
301 if (action->init == 0xff) {
302
303 printk(KERN_DEBUG "fsm error: event %x on state %x\n",
304 event, chan->fsm_state);
305 return;
306 }
307
308 chan->fsm_state = action->final;
309
310 pcbit_state_change(dev, chan, action->init, event, action->final);
311
312 for (tentry = fsm_timers; tentry->init != 0xff; tentry++)
313 if (tentry->init == chan->fsm_state)
314 break;
315
316 if (tentry->init != 0xff) {
317 init_timer(&chan->fsm_timer);
318 chan->fsm_timer.function = &pcbit_fsm_timer;
319 chan->fsm_timer.data = (ulong) chan;
320 chan->fsm_timer.expires = jiffies + tentry->timeout * HZ;
321 add_timer(&chan->fsm_timer);
322 }
323
324 restore_flags(flags);
325
326 if (action->callb)
327 action->callb(dev, chan, data);
328
329 }
330
331
332
333