3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * @(#) $FreeBSD: src/sys/netatm/uni/q2110_sigaa.c,v 1.4 2000/01/17 20:49:48 mks Exp $
27 * @(#) $DragonFly: src/sys/netproto/atm/uni/q2110_sigaa.c,v 1.6 2006/01/14 13:36:39 swildner Exp $
31 * ATM Forum UNI Support
32 * ---------------------
34 * ITU-T Q.2110 - Process AA-signals (SAP_SSCOP)
38 #include <netproto/atm/kern_include.h>
41 #include "sscop_misc.h"
42 #include "sscop_var.h"
47 static void sscop_resreq_ready (struct sscop
*, int, int);
48 static void sscop_resrsp_inresyn (struct sscop
*, int, int);
49 static void sscop_recrsp_recovrsp (struct sscop
*, int, int);
50 static void sscop_recrsp_inrecov (struct sscop
*, int, int);
54 * Stack command state lookup tables
57 static void (*sscop_init_tab
[SOS_NUMSTATES
])
58 (struct sscop
*, int, int) = {
59 sscop_init_inst
, /* SOS_INST */
61 NULL
, /* SOS_OUTCONN */
62 NULL
, /* SOS_INCONN */
63 NULL
, /* SOS_OUTDISC */
64 NULL
, /* SOS_OUTRESYN */
65 NULL
, /* SOS_INRESYN */
66 NULL
, /* SOS_OUTRECOV */
67 NULL
, /* SOS_RECOVRSP */
68 NULL
, /* SOS_INRECOV */
74 static void (*sscop_term_tab
[SOS_NUMSTATES
])
75 (struct sscop
*, int, int) = {
76 sscop_term_all
, /* SOS_INST */
77 sscop_term_all
, /* SOS_IDLE */
78 sscop_term_all
, /* SOS_OUTCONN */
79 sscop_term_all
, /* SOS_INCONN */
80 sscop_term_all
, /* SOS_OUTDISC */
81 sscop_term_all
, /* SOS_OUTRESYN */
82 sscop_term_all
, /* SOS_INRESYN */
83 sscop_term_all
, /* SOS_OUTRECOV */
84 sscop_term_all
, /* SOS_RECOVRSP */
85 sscop_term_all
, /* SOS_INRECOV */
86 sscop_term_all
, /* SOS_READY */
87 sscop_term_all
/* SOS_TERM */
90 /* SSCOP_ESTABLISH_REQ */
91 static void (*sscop_estreq_tab
[SOS_NUMSTATES
])
92 (struct sscop
*, int, int) = {
94 sscop_estreq_idle
, /* SOS_IDLE */
95 NULL
, /* SOS_OUTCONN */
96 NULL
, /* SOS_INCONN */
97 sscop_estreq_idle
, /* SOS_OUTDISC */
98 NULL
, /* SOS_OUTRESYN */
99 NULL
, /* SOS_INRESYN */
100 NULL
, /* SOS_OUTRECOV */
101 NULL
, /* SOS_RECOVRSP */
102 NULL
, /* SOS_INRECOV */
103 NULL
, /* SOS_READY */
104 sscop_aa_noop_1
/* SOS_TERM */
107 /* SSCOP_ESTABLISH_RSP */
108 static void (*sscop_estrsp_tab
[SOS_NUMSTATES
])
109 (struct sscop
*, int, int) = {
112 NULL
, /* SOS_OUTCONN */
113 sscop_estrsp_inconn
, /* SOS_INCONN */
114 NULL
, /* SOS_OUTDISC */
115 NULL
, /* SOS_OUTRESYN */
116 NULL
, /* SOS_INRESYN */
117 NULL
, /* SOS_OUTRECOV */
118 NULL
, /* SOS_RECOVRSP */
119 NULL
, /* SOS_INRECOV */
120 NULL
, /* SOS_READY */
121 sscop_aa_noop_1
/* SOS_TERM */
124 /* SSCOP_RELEASE_REQ */
125 static void (*sscop_relreq_tab
[SOS_NUMSTATES
])
126 (struct sscop
*, int, int) = {
129 sscop_relreq_outconn
, /* SOS_OUTCONN */
130 sscop_relreq_inconn
, /* SOS_INCONN */
131 NULL
, /* SOS_OUTDISC */
132 sscop_relreq_outconn
, /* SOS_OUTRESYN */
133 sscop_relreq_outconn
, /* SOS_INRESYN */
134 sscop_relreq_ready
, /* SOS_OUTRECOV */
135 sscop_relreq_outconn
, /* SOS_RECOVRSP */
136 sscop_relreq_outconn
, /* SOS_INRECOV */
137 sscop_relreq_ready
, /* SOS_READY */
138 sscop_aa_noop_1
/* SOS_TERM */
142 static void (*sscop_datreq_tab
[SOS_NUMSTATES
])
143 (struct sscop
*, int, int) = {
146 NULL
, /* SOS_OUTCONN */
147 NULL
, /* SOS_INCONN */
148 NULL
, /* SOS_OUTDISC */
149 NULL
, /* SOS_OUTRESYN */
150 NULL
, /* SOS_INRESYN */
151 sscop_aa_noop_1
, /* SOS_OUTRECOV */
152 NULL
, /* SOS_RECOVRSP */
153 NULL
, /* SOS_INRECOV */
154 sscop_datreq_ready
, /* SOS_READY */
155 sscop_aa_noop_1
/* SOS_TERM */
158 /* SSCOP_RESYNC_REQ */
159 static void (*sscop_resreq_tab
[SOS_NUMSTATES
])
160 (struct sscop
*, int, int) = {
163 NULL
, /* SOS_OUTCONN */
164 NULL
, /* SOS_INCONN */
165 NULL
, /* SOS_OUTDISC */
166 NULL
, /* SOS_OUTRESYN */
167 NULL
, /* SOS_INRESYN */
168 sscop_resreq_ready
, /* SOS_OUTRECOV */
169 sscop_resreq_ready
, /* SOS_RECOVRSP */
170 sscop_resreq_ready
, /* SOS_INRECOV */
171 sscop_resreq_ready
, /* SOS_READY */
172 sscop_aa_noop_1
/* SOS_TERM */
175 /* SSCOP_RESYNC_RSP */
176 static void (*sscop_resrsp_tab
[SOS_NUMSTATES
])
177 (struct sscop
*, int, int) = {
180 NULL
, /* SOS_OUTCONN */
181 NULL
, /* SOS_INCONN */
182 NULL
, /* SOS_OUTDISC */
183 NULL
, /* SOS_OUTRESYN */
184 sscop_resrsp_inresyn
, /* SOS_INRESYN */
185 NULL
, /* SOS_OUTRECOV */
186 NULL
, /* SOS_RECOVRSP */
187 NULL
, /* SOS_INRECOV */
188 NULL
, /* SOS_READY */
189 sscop_aa_noop_0
/* SOS_TERM */
192 /* SSCOP_RECOVER_RSP */
193 static void (*sscop_recrsp_tab
[SOS_NUMSTATES
])
194 (struct sscop
*, int, int) = {
197 NULL
, /* SOS_OUTCONN */
198 NULL
, /* SOS_INCONN */
199 NULL
, /* SOS_OUTDISC */
200 NULL
, /* SOS_OUTRESYN */
201 NULL
, /* SOS_INRESYN */
202 NULL
, /* SOS_OUTRECOV */
203 sscop_recrsp_recovrsp
, /* SOS_RECOVRSP */
204 sscop_recrsp_inrecov
, /* SOS_INRECOV */
205 NULL
, /* SOS_READY */
206 sscop_aa_noop_0
/* SOS_TERM */
209 /* SSCOP_UNITDATA_REQ */
210 static void (*sscop_udtreq_tab
[SOS_NUMSTATES
])
211 (struct sscop
*, int, int) = {
213 sscop_udtreq_all
, /* SOS_IDLE */
214 sscop_udtreq_all
, /* SOS_OUTCONN */
215 sscop_udtreq_all
, /* SOS_INCONN */
216 sscop_udtreq_all
, /* SOS_OUTDISC */
217 sscop_udtreq_all
, /* SOS_OUTRESYN */
218 sscop_udtreq_all
, /* SOS_INRESYN */
219 sscop_udtreq_all
, /* SOS_OUTRECOV */
220 sscop_udtreq_all
, /* SOS_RECOVRSP */
221 sscop_udtreq_all
, /* SOS_INRECOV */
222 sscop_udtreq_all
, /* SOS_READY */
223 sscop_aa_noop_1
/* SOS_TERM */
226 /* SSCOP_RETRIEVE_REQ */
227 static void (*sscop_retreq_tab
[SOS_NUMSTATES
])
228 (struct sscop
*, int, int) = {
231 NULL
, /* SOS_OUTCONN */
232 NULL
, /* SOS_INCONN */
233 NULL
, /* SOS_OUTDISC */
234 NULL
, /* SOS_OUTRESYN */
235 NULL
, /* SOS_INRESYN */
236 NULL
, /* SOS_OUTRECOV */
237 NULL
, /* SOS_RECOVRSP */
238 NULL
, /* SOS_INRECOV */
239 NULL
, /* SOS_READY */
245 * Stack command lookup table
247 void (*(*sscop_q2110_aatab
[SSCOP_CMD_SIZE
]))
248 (struct sscop
*, int, int) = {
289 * SSCOP_RESYNC_REQ / SOS_READY Command Processor
292 * sop pointer to sscop connection block
293 * arg1 pointer to buffer containing SSCOP-UU data
301 sscop_resreq_ready(struct sscop
*sop
, int arg1
, int arg2
)
305 * We don't support SSCOP-UU data
307 if (arg1
!= SSCOP_UU_NULL
)
308 KB_FREEALL((KBuffer
*)arg1
);
311 * Stop data transfer timers
313 sop
->so_timer
[SSCOP_T_POLL
] = 0;
314 sop
->so_timer
[SSCOP_T_NORESP
] = 0;
315 sop
->so_timer
[SSCOP_T_IDLE
] = 0;
316 sop
->so_flags
&= ~SOF_KEEPALIVE
;
319 * Initialize receiver window
321 SEQ_SET(sop
->so_rcvmax
, sop
->so_parm
.sp_rcvwin
);
327 SEQ_INCR(sop
->so_sendconn
, 1);
331 * Drain transmit and receive queues
333 sscop_xmit_drain(sop
);
334 sscop_rcvr_drain(sop
);
337 * Set retransmit timer
339 sop
->so_timer
[SSCOP_T_CC
] = sop
->so_parm
.sp_timecc
;
344 sop
->so_state
= SOS_OUTRESYN
;
351 * SSCOP_RESYNC_RSP / SOS_INRESYN Command Processor
354 * sop pointer to sscop connection block
363 sscop_resrsp_inresyn(struct sscop
*sop
, int arg1
, int arg2
)
367 * Clear transmitter buffers
369 q2110_clear_xmit(sop
);
372 * Initialize state variables
374 SEQ_SET(sop
->so_rcvmax
, sop
->so_parm
.sp_rcvwin
);
375 q2110_init_state(sop
);
380 sscop_send_rsak(sop
);
383 * Start data transfer timers
385 sop
->so_timer
[SSCOP_T_POLL
] = sop
->so_parm
.sp_timepoll
;
386 sop
->so_timer
[SSCOP_T_NORESP
] = sop
->so_parm
.sp_timeresp
;
389 * Back to data transfer state
391 sop
->so_state
= SOS_READY
;
398 * SSCOP_RECOVER_RSP / SOS_RECOVRSP Command Processor
401 * sop pointer to sscop connection block
410 sscop_recrsp_recovrsp(struct sscop
*sop
, int arg1
, int arg2
)
414 * Clear transmitter buffers, if not done earlier
416 if (sop
->so_flags
& SOF_NOCLRBUF
)
417 q2110_clear_xmit(sop
);
420 * Initialize state variables
422 q2110_init_state(sop
);
425 * Start data transfer timers
427 sop
->so_timer
[SSCOP_T_POLL
] = sop
->so_parm
.sp_timepoll
;
428 sop
->so_timer
[SSCOP_T_NORESP
] = sop
->so_parm
.sp_timeresp
;
431 * Back to data transfer state
433 sop
->so_state
= SOS_READY
;
436 * See if transmit queues need servicing
438 if (sop
->so_flags
& SOF_XMITSRVC
)
439 sscop_service_xmit(sop
);
446 * SSCOP_RECOVER_RSP / SOS_INRECOV Command Processor
449 * sop pointer to sscop connection block
458 sscop_recrsp_inrecov(struct sscop
*sop
, int arg1
, int arg2
)
462 * Clear transmitter buffers, if not done earlier
464 if (sop
->so_flags
& SOF_NOCLRBUF
)
465 q2110_clear_xmit(sop
);
468 * Initialize state variables
470 SEQ_SET(sop
->so_rcvmax
, sop
->so_parm
.sp_rcvwin
);
471 q2110_init_state(sop
);
476 sscop_send_erak(sop
);
479 * Start data transfer timers
481 sop
->so_timer
[SSCOP_T_POLL
] = sop
->so_parm
.sp_timepoll
;
482 sop
->so_timer
[SSCOP_T_NORESP
] = sop
->so_parm
.sp_timeresp
;
485 * Back to data transfer state
487 sop
->so_state
= SOS_READY
;
490 * See if transmit queues need servicing
492 if (sop
->so_flags
& SOF_XMITSRVC
)
493 sscop_service_xmit(sop
);