• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 // ----------------------------------------------------------------------
19 //
20 // This Software is an original work of authorship of PacketVideo Corporation.
21 // Portions of the Software were developed in collaboration with NTT  DoCoMo,
22 // Inc. or were derived from the public domain or materials licensed from
23 // third parties.  Title and ownership, including all intellectual property
24 // rights in and to the Software shall remain with PacketVideo Corporation
25 // and NTT DoCoMo, Inc.
26 //
27 // -----------------------------------------------------------------------
28 /************************************************************************/
29 /*  file name       : selcblccmn.h                                      */
30 /*  file contents   : Uni-Directional and Bi-Directional                */
31 /*                  :              Logical Channel Signalling Entity    */
32 /*                  :                          Common Management Header */
33 /*  draw            : '96.11.11                                         */
34 /*----------------------------------------------------------------------*/
35 /*  amendment       :                                                   */
36 /*                          Copyright (C) 1996 NTT DoCoMo               */
37 /************************************************************************/
38 #ifndef _LCENTRY_H_
39 #define _LCENTRY_H_
40 
41 #include <stdio.h>
42 #include "oscl_vector.h"
43 #include "oscl_mem.h"
44 #include "oscl_base.h"
45 
46 /************************************************************************/
47 /*  Uni-Directional and Bi-Directional Logical Status Definition        */
48 /************************************************************************/
49 #define     LCBLC_OUTGOING_RLSED            0X00    /* Outgoing Released */
50 #define     LCBLC_OUTGOING_AWTING_ETBMNT    0X10    /* Outgoing Awaiting Establishement */
51 #define     LCBLC_OUTGOING_ETBED            0X20    /* Outgoing Established */
52 #define     LCBLC_OUTGOING_AWTING_RLS       0X30    /* Outgoing Awaiting Release */
53 #define     LCBLC_INCOMING_RLSED            0X01    /* Incoming Released */
54 #define     LCBLC_INCOMING_AWTING_ETBMNT    0X11    /* Incoming Awaiting Establishment */
55 #define     LCBLC_INCOMING_AWTING_CNFMTN    0X21    /* Incoming Awaiting Confirmation ( Bi-Directional Only ) */
56 #define     LCBLC_INCOMING_ETBED            0X31    /* Incoming Established */
57 
58 
59 /************************************************************************/
60 /*  Directional Information Definition                                  */
61 /************************************************************************/
62 #define     NO_DIRECTIONAL      0   /* No-Directional */
63 #define     UNI_DIRECTIONAL     1   /* Uni-Directional */
64 #define     BI_DIRECTIONAL      2   /* Bi-Directional */
65 
66 
67 /************************************************************************/
68 /*  CLC Definition                                                      */
69 /************************************************************************/
70 #define     CLS_OUTGOING_IDLE           0X00    /* Outgoing Idle */
71 #define     CLS_OUTGOING_AWTING_RPS     0X10    /* Outgoing Awaiting Response */
72 #define     CLS_INCOMING_IDLE           0X01    /* Incoming Idle */
73 #define     CLS_INCOMING_AWTING_RPS     0X11    /* Incoming Awaiting Response */
74 
75 
76 /************************************************************************/
77 /*  Class Definitions                                                   */
78 /************************************************************************/
79 typedef enum { LC_OUTGOING, LC_INCOMING } LCDirection_t;
80 
81 class LCEntry
82 {
83     public:
LCEntry(uint32 lcn,LCDirection_t direction)84         LCEntry(uint32 lcn, LCDirection_t direction)
85         {
86             FwdLcn = lcn ;
87             RvsLcn = 0 ;
88 
89             /********************************************************/
90             /* NOTE: OUTGOING with respect to LCBLC                 */
91             /********************************************************/
92             if (direction == LC_OUTGOING)
93             {
94                 Status = LCBLC_OUTGOING_RLSED ;
95                 ClcStatus = CLS_INCOMING_IDLE;
96             }
97             else
98             {
99                 Status = LCBLC_INCOMING_RLSED ;
100                 ClcStatus = CLS_OUTGOING_IDLE;
101             }
102 
103             Directional = NO_DIRECTIONAL ;
104             TmrSqcNumber = 0 ;
105             ClcTmrSqcNumber = 0;
106         }
~LCEntry()107         ~LCEntry() {}
108 
Reset()109         void Reset()
110         {
111             RvsLcn = 0 ;
112 
113             if (Status & 0x01)    //LC_INCOMING
114             {
115                 Status = LCBLC_INCOMING_RLSED ;
116                 ClcStatus = CLS_OUTGOING_IDLE;
117             }
118             else   //LC_OUTGOING
119             {
120                 Status = LCBLC_OUTGOING_RLSED ;
121                 ClcStatus = CLS_INCOMING_IDLE;
122             }
123 
124             Directional = NO_DIRECTIONAL ;
125             TmrSqcNumber = 0 ;
126             ClcTmrSqcNumber = 0;
127         }
128 
FwdLcnRead()129         uint32 FwdLcnRead()
130         {
131             return FwdLcn;
132         }
FwdLcnWrite(uint32 fwdLcn)133         void FwdLcnWrite(uint32 fwdLcn)
134         {
135             FwdLcn = fwdLcn;
136         }
137 
RvsLcnRead()138         uint32 RvsLcnRead()
139         {
140             return RvsLcn;
141         }
RvsLcnWrite(uint32 rvsLcn)142         void RvsLcnWrite(uint32 rvsLcn)
143         {
144             RvsLcn = rvsLcn;
145         }
146 
StatusRead()147         uint8 StatusRead()
148         {
149             return Status;
150         }
StatusWrite(uint8 status)151         void StatusWrite(uint8 status)
152         {
153 #ifdef PVANALYZER
154             StatusShow(status, Status);
155 #endif
156             Status = status;
157 
158             // if LC is set to released state, then reset it's attributes so it can be used again
159             if (Status == LCBLC_OUTGOING_RLSED || Status == LCBLC_INCOMING_RLSED)
160             {
161                 RvsLcn = 0;
162                 Directional = NO_DIRECTIONAL ;
163                 TmrSqcNumber = 0 ;
164             }
165         }
166 
DirectionalRead()167         uint8 DirectionalRead()
168         {
169             return Directional;
170         }
DirectionalWrite(uint8 directional)171         void DirectionalWrite(uint8 directional)
172         {
173             Directional = directional;
174         }
175 
TmrSqcNumberClear()176         void TmrSqcNumberClear()
177         {
178             TmrSqcNumber = 0;
179         }
TmrSqcNumberRead()180         int32 TmrSqcNumberRead()
181         {
182             return TmrSqcNumber;
183         }
TmrSqcNumberInc()184         int32 TmrSqcNumberInc()
185         {
186             return (++TmrSqcNumber);
187         }
188 
ClcStatusRead()189         uint8 ClcStatusRead()
190         {
191             return ClcStatus;
192         }
ClcStatusWrite(uint8 status)193         void ClcStatusWrite(uint8 status)
194         {
195 #ifdef PVANALYZER
196             ClcStatusShow(status, ClcStatus);
197 #endif
198             ClcStatus = status;
199         }
200 
ClcTmrSqcNumberClear()201         void ClcTmrSqcNumberClear()
202         {
203             ClcTmrSqcNumber = 0;
204         }
ClcTmrSqcNumberRead()205         int32 ClcTmrSqcNumberRead()
206         {
207             return ClcTmrSqcNumber;
208         }
ClcTmrSqcNumberInc()209         void ClcTmrSqcNumberInc()
210         {
211             ClcTmrSqcNumber++;
212         }
213 
214 #ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
215 #define ANALYZER_SE 0x0020      // (Assume tag is fixed)
StatusShow(uint8 oldStatus,uint8 newStatus)216         void StatusShow(uint8 oldStatus, uint8 newStatus)
217         {
218             void Show245(uint16 tag, uint16 indent, char* inString);
219             char tempString[80];
220 
221             Show245(ANALYZER_SE, 0, "LCSE/BLCSE State Transition:");
222             sprintf(tempString, "  LogicalChannelNumber = %u", FwdLcn);
223             Show245(ANALYZER_SE, 0, tempString);
224             sprintf(tempString, "  from--> %s", StateLabel(oldStatus));
225             Show245(ANALYZER_SE, 0, tempString);
226             sprintf(tempString, "    to--> %s", StateLabel(newStatus));
227             Show245(ANALYZER_SE, 0, tempString);
228             Show245(ANALYZER_SE, 0, " ");
229         }
230 
StateLabel(uint8 status)231         char* StateLabel(uint8 status)
232         {
233             switch (status)
234             {
235                 case LCBLC_OUTGOING_RLSED:
236                     return("Outgoing RELEASED");
237                     break;
238                 case LCBLC_OUTGOING_AWTING_ETBMNT:
239                     return("Outgoing AWAITING ESTABLISHMENT");
240                     break;
241                 case LCBLC_OUTGOING_ETBED:
242                     return("Outgoing ESTABLISHED");
243                     break;
244                 case LCBLC_OUTGOING_AWTING_RLS:
245                     return("Outgoing AWAITING RELEASE");
246                     break;
247                 case LCBLC_INCOMING_RLSED:
248                     return("Incoming RELEASED");
249                     break;
250                 case LCBLC_INCOMING_AWTING_ETBMNT:
251                     return("Incoming AWAITING ESTABLISHMENT");
252                     break;
253                 case LCBLC_INCOMING_AWTING_CNFMTN:
254                     return("Incoming AWAITING CONFIRMATION");
255                     break;
256                 case LCBLC_INCOMING_ETBED:
257                     return("Incoming ESTABLISHED");
258                     break;
259                 default:
260                     return("UNKNOWN STATE");
261             }
262         }
263 
ClcStatusShow(uint8 oldStatus,uint8 newStatus)264         void ClcStatusShow(uint8 oldStatus, uint8 newStatus)
265         {
266             void Show245(uint16 tag, uint16 indent, char* inString);
267             char tempString[80];
268 
269             Show245(ANALYZER_SE, 0, "CLCSE State Transition:");
270             sprintf(tempString, "  LogicalChannelNumber = %u", FwdLcn);
271             Show245(ANALYZER_SE, 0, tempString);
272             sprintf(tempString, "  from--> %s", ClcStateLabel(oldStatus));
273             Show245(ANALYZER_SE, 0, tempString);
274             sprintf(tempString, "    to--> %s", ClcStateLabel(newStatus));
275             Show245(ANALYZER_SE, 0, tempString);
276             Show245(ANALYZER_SE, 0, " ");
277         }
278 
ClcStateLabel(uint8 status)279         char *ClcStateLabel(uint8 status)
280         {
281             switch (status)
282             {
283                 case CLS_OUTGOING_IDLE:
284                     return("Outgoing IDLE");
285                     break;
286                 case CLS_OUTGOING_AWTING_RPS:
287                     return("Outgoing AWAITING RESPONSE");
288                     break;
289                 case CLS_INCOMING_IDLE:
290                     return("Incoming IDLE");
291                     break;
292                 case CLS_INCOMING_AWTING_RPS:
293                     return("Incoming AWAITING RESPONSE");
294                     break;
295                 default:
296                     return("UNKNOWN STATE");
297             }
298         }
299 
300 #endif            /* --------------------------------- */
301 
302     private:
303         LCEntry(const LCEntry&);
304 
305         uint32    FwdLcn ;
306         uint32    RvsLcn ;
307         uint8   Directional ;
308         uint8   Status ;
309         int32     TmrSqcNumber ;
310         uint8   ClcStatus;          /* Multiple CLCSEs (RAN) */
311         int32     ClcTmrSqcNumber;    /* Multiple CLCSEs (RAN) */
312 };
313 
314 class LCEntryList
315 {
316     public:
LCEntryList()317         LCEntryList() : Direction(LC_OUTGOING) {}
LCEntryList(LCDirection_t direction)318         LCEntryList(LCDirection_t direction) : Direction(direction) {}
319 
~LCEntryList()320         ~LCEntryList()
321         {
322             // delete all LCEntry's remaining
323             for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++) OSCL_DELETE((*it));
324         }
325 
Reset()326         void Reset()
327         {
328             // reset all LCEntry's remaining
329             for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++)(*it)->Reset();
330         }
331 
SetDirection(LCDirection_t direction)332         void SetDirection(LCDirection_t direction)
333         {
334             Direction = direction;
335         }
336 
NewLCEntry(uint32 lcn)337         LCEntry* NewLCEntry(uint32 lcn)
338         {
339             // allocate a new LCEntry
340             LCEntry *lcentry = OSCL_NEW(LCEntry, (lcn, Direction));
341             OsclError::LeaveIfNull(lcentry);
342             // add it to the list
343             EntryList.push_back(lcentry);
344 
345             return lcentry;
346         }
347 
GetLCEntry(uint32 lcn)348         LCEntry* GetLCEntry(uint32 lcn)
349         {
350             lcn = (lcn & 0xFFFF);
351             // look for existing LCEntry
352             for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++)
353             {
354                 if ((*it)->FwdLcnRead() == lcn)
355                 {
356                     return (*it);
357                 }
358             }
359 
360             return NULL;
361         }
362 
DeleteLCEntry(uint32 lcn)363         void DeleteLCEntry(uint32 lcn)
364         {
365             for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++)
366             {
367                 if ((*it)->FwdLcnRead() == lcn)
368                 {
369                     OSCL_DELETE((*it));
370                     EntryList.erase(it);
371                     return;
372                 }
373             }
374         }
375 
DeleteLCEntry(LCEntry * lcentry)376         void DeleteLCEntry(LCEntry *lcentry)
377         {
378             for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++)
379             {
380                 if ((*it) == lcentry)
381                 {
382                     OSCL_DELETE((*it));
383                     EntryList.erase(it);
384                     return;
385                 }
386             }
387         }
388 
389     private:
390         LCDirection_t Direction;
391         Oscl_Vector<LCEntry*, OsclMemAllocator> EntryList;
392 };
393 
394 #endif /* _LCENTRY_H_ */
395