annotate src/g23m-gprs/llc/llc_irxl.c @ 303:f76436d19a7a default tip

!GPRS config: fix long-standing AT+COPS chance hanging bug There has been a long-standing bug in FreeCalypso going back years: sometimes in the AT command bring-up sequence of an ACI-only MS, the AT+COPS command would produce only a power scan followed by cessation of protocol stack activity (only L1 ADC traces), instead of the expected network search sequence. This behaviour was seen in different FC firmware versions going back to Citrine, and seemed to follow some law of chance, not reliably repeatable. This bug has been tracked down and found to be specific to !GPRS configuration, stemming from our TCS2/TCS3 hybrid and reconstruction of !GPRS support that was bitrotten in TCS3.2/LoCosto version. ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3 version and had to be pulled from TCS2 - but as it turns out, there is a new field in the MMR_REG_REQ primitive that needs to be set correctly, and that psa_mms.c module is the place where this initialization needed to be added.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Jun 2023 08:23:37 +0000
parents fa8dc04885d8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 +-----------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 | Project :
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 | Modul :
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 +-----------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 | Copyright 2002 Texas Instruments Berlin, AG
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 | All rights reserved.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 |
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 | This file is confidential and a trade secret of Texas
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 | Instruments Berlin, AG
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 | The receipt of or possession of this file does not convey
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 | any rights to reproduce or disclose its contents or to
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 | manufacture, use, or sell anything it may describe, in
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 | whole, or in part, without the specific written consent of
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 | Texas Instruments Berlin, AG.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 +-----------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 | Purpose : This modul is part of the entity LLC and implements all labels
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 | in the SDL-documentation (IRX-statemachine) that are called from
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 | more than one diagram/place.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 +-----------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #ifndef LLC_IRXL_C
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 #define LLC_IRXL_C
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 #endif
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 #define ENTITY_LLC
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /*==== INCLUDES =============================================================*/
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "typedefs.h" /* to get Condat data types */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "vsi.h" /* to get a lot of macros */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "macdef.h"
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "gprs.h"
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 #include "gsm.h" /* to get a lot of macros */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 #include "cnf_llc.h" /* to get cnf-definitions */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 #include "mon_llc.h" /* to get mon-definitions */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 #include "prim.h" /* to get the definitions of used SAP and directions */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 #include "llc.h" /* to get the global entity definitions */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 #include "llc_irxf.h" /* to get local IRX functions */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 #include "llc_irxl.h" /* to get local IRX labels */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 #include "llc_llmes.h" /* to get signal interface to LLME */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 #include "llc_txs.h" /* to get signal interface to TX */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 /*==== CONST ================================================================*/
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 /*==== LOCAL VARS ===========================================================*/
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 /*==== PRIVATE FUNCTIONS ====================================================*/
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 +------------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 | Function : irx_get_next_gap
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 +------------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 | Description : Searches queue with already received frames.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 |
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 | Parameters : next_free - pointer to T_FRAME_NUM, number of the next
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 | frame that has not been received yet.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 | If queue is empty, this parameter will be
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 | set to (llc_data->sapi->vr + 1) %
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 | (MAX_SEQUENCE_NUMBER + 1).
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 | gap_size - pointer to T_FRAME_NUM, 0, 1 or bigger
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 | Preconditions: llc_data->sapi points to the affected sapi.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 | There is 1 entry in the queue with vr==ns.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 |
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 +------------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 GLOBAL void irx_get_next_gap (T_FRAME_NUM* next_free,
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 T_FRAME_NUM* gap_size)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 T_IRX_QUEUE* entry = llc_data->irx->queue;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 BOOL gap_found = FALSE;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 TRACE_FUNCTION("irx_get_next_gap");
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 *next_free = (llc_data->sapi->vr + 1) % (MAX_SEQUENCE_NUMBER + 1);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 *gap_size = 0;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 TRACE_EVENT_P1("*next_free: %d", *next_free);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 while ((entry != NULL) &&
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 FRAME_NUM_VALID( entry->ns,
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 llc_data->sapi->vr,
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 llc_data->sapi->vr + *(llc_data->ku)) )
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 entry = entry->next;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 * If rest of queue is empty, values of next_free and gap_size are ok.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 if (entry == NULL)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 return;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 } /* if (entry == NULL) */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 * Queue is not empty. Find the first gap.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 while ((entry != NULL) && !gap_found)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 T_FRAME_NUM num = entry->ns;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 if (num == *next_free)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 entry = entry->next;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 *next_free = (*next_free + 1) % (MAX_SEQUENCE_NUMBER + 1);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 gap_found = TRUE;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 *gap_size = (num - *next_free) % (MAX_SEQUENCE_NUMBER + 1);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 } /* while ((entry != NULL) && !gap_found) */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 TRACE_EVENT_P2("*next_free: %u *gap_size: %u ", *next_free, *gap_size);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 } /* irx_get_next_gap() */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 /*==== PUBLIC FUNCTIONS =====================================================*/
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 +------------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 | Function : irx_label_if
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 +------------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 | Description : Describes label IRX_IF
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 |
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 | Parameters : ll_unitdata_ind - a valid pointer to an LL_UNITDATA_IND
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 | primitive
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 | ns - N(S) of received frame
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 | a_bit - A bit of received frame
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 | state - current state of IRX
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 |
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 +------------------------------------------------------------------------------
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 GLOBAL void irx_label_if (T_LL_UNITDATA_IND *ll_unitdata_ind,
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 T_FRAME_NUM ns,
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 T_BIT a_bit,
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 UBYTE state)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 BOOL is_busy;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 T_FRAME_NUM vsi;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 BOOL vsi_found;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 TRACE_FUNCTION( "irx_label_if" );
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 if (state == IRX_ABM)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 * Label IRX_IF_ABM
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 if ( ns == llc_data->sapi->vr )
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 BOOL found = FALSE;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 T_FRAME_NUM num = 0;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 irx_get_last_queued_ns(&found, &num);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 if (!found)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 * Store N(S)/V(R) condition
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 llc_data->irx->last_ns = NS_EQUAL_VR;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 * If N(s) = V(r) increment V(r), handle OC(rx)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 llc_data->sapi->vr++;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 if (llc_data->sapi->vr > MAX_SEQUENCE_NUMBER)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 llc_data->sapi->oc_i_rx += (MAX_SEQUENCE_NUMBER+1);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 llc_data->sapi->vr = 0;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 T_FRAME_NUM next_free = 0;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 T_FRAME_NUM gap_size = 0;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 irx_get_next_gap (&next_free, &gap_size);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 * vr will be set to next_free. If MAX_SEQUENCE_NUMBER is passed,
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 * increment overflow counter.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 if (llc_data->sapi->vr > next_free)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 llc_data->sapi->oc_i_rx += (MAX_SEQUENCE_NUMBER + 1);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 llc_data->sapi->vr = next_free;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 if (gap_size == 0) {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 llc_data->irx->last_ns = NS_EQUAL_VR;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 } else if (gap_size == 1) {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 llc_data->irx->last_ns = NS_EQUAL_VR_PLUS_1;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 } else {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 llc_data->irx->last_ns = NS_NO_SEQUENCE_ERROR;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 * Expected next frame received.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 if ( llc_data->irx->ll_send_ready == TRUE )
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 * Forward the frame to L3
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 PPASS (ll_unitdata_ind, ll_data_ind, LL_DATA_IND);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 TRACE_2_OUT_PARA("s:%d len:%d", ll_data_ind->sapi, BYTELEN(ll_data_ind->sdu.l_buf));
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 PSEND (hCommSNDCP, ll_data_ind);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 llc_data->irx->ll_send_ready = FALSE;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 * Increment V(f) (= Next frame number to forward to L3)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 llc_data->irx->vf += 1;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 llc_data->irx->vf %= (MAX_SEQUENCE_NUMBER+1);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 * Update V(R) if we have the next frames already queued
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 irx_update_vr ();
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 * Handle the acknowledgement
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 irx_send_ack (a_bit);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 /* SET_STATE (IRX, SAME_STATE); */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 * store frame and update V(R) if next frames already stored
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 irx_queue_store (ll_unitdata_ind, ns, &is_busy);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 irx_update_vr ();
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 if ( is_busy == TRUE )
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 irx_send_rnr ();
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 SET_STATE (IRX, IRX_ABM_BUSY);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 irx_send_ack (a_bit);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 /* SET_STATE (IRX, SAME_STATE); */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 * Not the expected next frame received. Check if it is in receive window.
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 if ( FRAME_NUM_VALID (llc_data->sapi->vr + 1, ns, llc_data->sapi->vr + *(llc_data->ku)) )
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 * Store N(S)/V(R) condition
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 if (ns == (llc_data->sapi->vr + 1) % (MAX_SEQUENCE_NUMBER+1))
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 llc_data->irx->last_ns = NS_EQUAL_VR_PLUS_1;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 * Check if we have detect a sequence error or not: If ns equals to
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 * ns + 1 of the last queued frame then we have not detect a new error
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 irx_get_last_queued_ns (&vsi_found, &vsi);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 if (vsi_found)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 if (ns == (vsi + 1) % (MAX_SEQUENCE_NUMBER+1))
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 * ok, seems to be in sequence
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 llc_data->irx->last_ns = NS_NO_SEQUENCE_ERROR;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 * sequence error found
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 llc_data->irx->last_ns = NS_IN_RANGE_VR_KU;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 * sequence error found
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 llc_data->irx->last_ns = NS_IN_RANGE_VR_KU;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 * store frame and update V(R)
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 irx_queue_store (ll_unitdata_ind, ns, &is_busy);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321 if ( is_busy == TRUE )
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 irx_send_rnr ();
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 SET_STATE (IRX, IRX_ABM_BUSY);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 irx_send_ack (a_bit);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 /* SET_STATE (IRX, SAME_STATE); */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 * duplicate frame
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 TRACE_0_INFO ("Duplicated frame received");
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 PFREE (ll_unitdata_ind);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 irx_send_ack (a_bit);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 /* SET_STATE (IRX, SAME_STATE); */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 else
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346 {
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 * ABM_BUSY
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 irx_send_rnr ();
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 /*
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 * ignore I frame in state 'own receiver busy'
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 PFREE (ll_unitdata_ind);
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 /* SET_STATE (IRX, SAME_STATE); */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 }
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 return;
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 } /* irx_label_if() */
fa8dc04885d8 src/g23m-*: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361