blob: 8953ca6e7d5f949eee0b8bf2de8c51316518db88 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2016
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS (""MEDIATEK SOFTWARE"")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN ""AS-IS"" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35/*************************************************************
36*
37* This Software is the property of VIA Telecom, Inc. and may only be used pursuant to a license from VIA Telecom, Inc.
38*
39* Any unauthorized use inconsistent with the terms of such license is strictly prohibited.
40*
41* Copyright (c) 2006-2010 VIA Telecom, Inc. All rights reserved.
42*
43*************************************************************/
44#ifndef _CLCIRATM_H_
45#define _CLCIRATM_H_ 1
46/*****************************************************************************
47*
48* FILE NAME : clciratm.h
49*
50* DESCRIPTION : This file includes the definition of OMP
51*
52* HISTORY :
53* See Log at end of file
54*
55*****************************************************************************/
56
57#ifdef MTK_DEV_C2K_IRAT
58
59/*----------------------------------------------------------------------------
60 Include Files
61----------------------------------------------------------------------------*/
62#include "cpbuf.h"
63#include "do_clcapi.h"
64#include "clcomp.h"
65#include "do_rupapi.h"
66#include "do_idpapi.h"
67#include "do_dsaapi.h"
68#include "do_ompapi.h"
69#include "clctimer.h"
70
71
72/*----------------------------------------------------------------------------
73 Global Defines and Macros
74----------------------------------------------------------------------------*/
75
76#define IRATM_ERRC_MAX_INTER_FREQUENCY 8
77
78#define IRATM_NUM_BARRED_CELLS 16
79
80#define IRATM_ERRC_MAX_INTER_FREQ_CELL (16)
81
82#define IRATM_NUM_OF_TIMERS IRATM_ERRC_MAX_INTER_FREQUENCY * IRATM_ERRC_MAX_INTER_FREQ_CELL
83
84#define INVALID_EARFCN (0xFFFF)
85
86#define INVALID_EUTRA_PHYS_CELL_ID (0xFFFF)
87
88#define INVALID_RESELECTION_PRIORITY (0xFF)
89
90
91/** Defines the scaling factors to be used for all dB and dBm measurements. */
92#define RRC_SYS_INFO_DB_SCALING_FACTOR 4
93
94#define IRATM_MIN_RSRQ_VALUE (-255 * RRC_SYS_INFO_DB_SCALING_FACTOR)
95#define IRATM_MAX_RSRQ_VALUE (255 * RRC_SYS_INFO_DB_SCALING_FACTOR)
96#define IRATM_INVALID_RSRQ_VALUE (0xFF)
97#define IRATM_INITIAL_RSRQ_VALUE (0)
98
99#define MAX_IRATM_TIMER_NUM (30)
100#define MAX_OMP_PLMN_NUM 8
101#define MAX_EUTRA_FREQ_NUM 8
102
103#define MAX_IRATM_NUM_HPLMN 26
104#define NWSEL_MAX_IRATM_NUM_PLMNS 300
105#define MAX_PREFER_PLMN_NUM 255
106
107#define MAX_IRAT_CCELL_MEAS_MSG_QUEUE_LEN 2
108
109/** Defines the RSRP measurement in 1/8dBm units.
110 * Range is -140 (x8) to -44 (x8).
111 */
112typedef kal_int16 EutraRsrp;
113
114/** Defines the RSRQ measurement in 1/8dB units.
115 * Range is -19.5 (x8) to -3 (x8).
116 */
117typedef kal_int16 EutraRsrq;
118
119extern RmcIratmCcellMeasReqT rmcIratmCcellMeasReq;
120
121/*----------------------------------------------------------------------------
122 Global Typedefs
123----------------------------------------------------------------------------*/
124
125typedef kal_uint8 /* 0 to 7 */ CellReselectionPriority;
126
127typedef kal_uint16 /* 0 to 16 */ Ecell_T_Reselection;
128
129typedef kal_uint16 /* 0 to 503 */ EutraPhysCellId;
130
131typedef enum {
132 BASE_PRIORITY,
133 BASE_MEASUREMENT,
134 BASE_RESERVED
135} EutranMeasModeT;
136
137
138/** Identifies the LTE physical cell */
139typedef struct
140{
141 eas_target_cell_info target_cell;
142
143 kal_uint8 TimerID;
144}
145ECellIdentifierT;
146
147typedef struct
148{
149 kal_uint8 band;
150 kal_uint16 channel;
151 kal_uint16 pn; /* indicate the pilot number the measurement result belonged, range: 0..511 */
152 kal_int16 phase; /* indicate CDMA pilot phase, represent in chips */
153 kal_uint16 strength; /* indicate CDMA pilot strength, in -0.125db format
154 note: CAS will send the strength value calculated by formula [FLOOR(-2 x 10 x log10 Ec/Io)]
155 without adding negative sign, and EAS needs to multiply the strength value by (-1)
156 when it evaluates reselection criteria if fulfill: Srxlev > ThreshxHighP, ThreshxLowP */
157}IratmServingPilotMeasResultT;
158
159typedef struct
160{
161 kal_uint8 tid; /* tid is used by EAS to filter the measurement report from CAS, range: 0..255
162 the CCELL_MEAS_IND corresponding to this CCELL_MEAS_REQ should return the same tid
163 Note that (1) ERRC will maintain two tid. One is for HP_MODE. The other one is for LP_MODE/RESEL/CONNECTED.
164 (2) CAS also needs to maintain two tid like ERRC. */
165 cas_meas_type_enum meas_type; /* indicate the measurement type of this CCELL_MEAS_REQ
166 - if 'RESEL' type is selected, the set of sectors indicated in this primitive should be a subset of the previously measured sectors
167 - if 'CONNECTED' type is selected, it means EAS is in connected mode and requests CAS to do measurement
168 (in order to distinguish from HP/LP/RESEL modes which used in idle mode)
169 - when this primitive is used to stop measurement, EAS should choose correct type to inform CAS which type of measurement should be stopped */
170 kal_uint8 meas_period; /* indicate the absolute measurement period used by C2K to report the measurement results to LTE
171 this field is only valid if 'meas_type' = HP_MODE, represent in 'seconds' */
172 kal_uint8 band_num; /* indicate the number of measurement bands, range: 0..MAX_NUM_MEAS_C2K_BAND
173 if band_num=0, CAS should stop the measurement specified in the 'meas_type' */
174 cas_meas_band_info_struct band_list[MAX_NUM_MEAS_C2K_BAND]; /* indicate the measurement information */
175}EasCasConfigCcellMeasReqT;
176
177
178
179typedef struct
180{
181 kal_bool bWaitProcessing;
182 kal_bool bStopMeasForMissMatchConfig;
183 EasCasConfigCcellMeasReqT cCellMeasConfig;
184}IratCcellMeasConfigT;
185
186/* IRATM Timers */
187typedef enum
188{
189 /* Barred Frequency timers */
190 IRATM_FREQUENCY_BARRED_TIMER_0,
191 IRATM_FREQUENCY_BARRED_TIMER_1,
192 IRATM_FREQUENCY_BARRED_TIMER_2,
193 IRATM_FREQUENCY_BARRED_TIMER_3,
194 IRATM_FREQUENCY_BARRED_TIMER_4,
195 IRATM_FREQUENCY_BARRED_TIMER_5,
196 IRATM_FREQUENCY_BARRED_TIMER_6,
197 IRATM_FREQUENCY_BARRED_TIMER_7,
198
199 /* Barred Cell timers */
200 IRATM_CELL_BARRED_TIMER_0,
201 IRATM_CELL_BARRED_TIMER_1,
202 IRATM_CELL_BARRED_TIMER_2,
203 IRATM_CELL_BARRED_TIMER_3,
204 IRATM_CELL_BARRED_TIMER_4,
205 IRATM_CELL_BARRED_TIMER_5,
206 IRATM_CELL_BARRED_TIMER_6,
207 IRATM_CELL_BARRED_TIMER_7,
208 IRATM_CELL_BARRED_TIMER_8,
209 IRATM_CELL_BARRED_TIMER_9,
210 IRATM_CELL_BARRED_TIMER_10,
211 IRATM_CELL_BARRED_TIMER_11,
212 IRATM_CELL_BARRED_TIMER_12,
213 IRATM_CELL_BARRED_TIMER_13,
214 IRATM_CELL_BARRED_TIMER_14,
215 IRATM_CELL_BARRED_TIMER_15,
216 IRATM_DEPRIORITIZATION_TIMER,
217
218 /* Base timer for inter-frequency T-Reselection */
219 IRATM_INTER_F_T_RESELECTION_TIMER_BASE,
220
221 /* NOTE: this is not a real timer and must be last in the list! */
222 IRATM_MAX_NUM_OF_TIMERS = IRATM_INTER_F_T_RESELECTION_TIMER_BASE + IRATM_NUM_OF_TIMERS,
223}
224IratmTimerIndex;
225
226
227typedef struct
228{
229 kal_bool Active;
230 IratmTimerIndex timerIndex;
231 eventid eventid;
232}IratmExeTimerT;
233
234typedef struct
235{
236 kal_uint32 TimerId;
237}IratmTimerExpiredMsgT;
238
239typedef struct
240{
241 EARFCN earfcn;
242 kal_bool neverAllowed;
243 te_eval_activate_fail_type failType;
244}IratmBarFrequencyT;
245
246/* Inter-frequency priority relative to serving-frequency */
247typedef enum
248{
249 HIGH_PRIORITY_EARFCN,
250 EQUAL_PRIORITY_EARFCN,
251 LOW_PRIORITY_EARFCN
252}
253IratmPriorityRelativeToServFreq;
254
255/* E-UTRA cell information */
256typedef struct IratmCellEutraInfoTag
257{
258 /* Indicated presence of this position */
259 kal_bool cellPresent;
260
261 /* Physical Cell Identity of the target cell */
262 kal_uint16 physCellId;
263
264 /* RSRP of the E-UTRA cell in 1/4dBm units */
265 kal_int16 rsrp;
266
267 /* RSRQ of the E-UTRA cell in 1/4dB units */
268 kal_int16 rsrq;
269
270 /* Srxlev of the E-UTRA cell in 1/4dB units */
271 kal_int16 srxlev;
272
273 /* Squal of the E-UTRA cell in 1/4dB units */
274 kal_int16 squal;
275
276 /* Ranking value of the E-UTRA cell in 1/4dB units */
277 kal_int16 rankingValue;
278
279 /* Indicated whether T-reselection timer has been expired or not */
280 kal_bool tReselectionExpired;
281}
282IratmEutraCellInfo;
283
284
285/* E-UTRA frequency information */
286typedef struct
287{
288 /* E-UTRA Arfcn of the frequency */
289 EARFCN earfcn;
290
291 /* Cell Reselection Priority of this Carrier */
292 kal_uint8 cellReselectionPriority;
293
294 eas_bandwidth_enum measBandWidth;
295
296 /* E-UTRA cell information on the carrier */
297 IratmEutraCellInfo eutraCellInfo [IRATM_ERRC_MAX_INTER_FREQ_CELL];
298}
299IratmEutraFreqInfo;
300
301typedef enum
302{
303 Home_PLMN_Type, /*Contain at least one home or ehome Plmn*/
304 Prefer_PLMN_Type, /*Contain no home or ehome Plmn, but at least one perfer Plmn*/
305 Any_PLMN_Type /*Contain no home or ehome Plmn, no perfer Plmn*/
306}
307IratmPlmnType;
308
309typedef enum
310{
311 EHPLMN_Type,
312 UPLMN_Type,
313 OPLMN_Type
314}
315IratmSimPlmnType_enum;
316
317typedef struct
318{
319 kal_uint8 NumPLMNIds;
320 cas_eas_plmn_id_struct PLMNID[MAX_OMP_PLMN_NUM];
321}
322IratmEutranPlmnInfo;
323
324typedef struct
325{
326 /* HOME+EHOME PLMN */
327 kal_uint16 num_of_home_plmn;
328 cas_eas_plmn_id_struct hplmn[MAX_IRATM_NUM_HPLMN];
329 kal_uint32 hplmnU32[MAX_IRATM_NUM_HPLMN];
330
331 /* PERFER PLMN, uplmn+oplmn from GMSS
332 For priority uplmn>oplmn, then the list include uplmn first, then oplmn*/
333 kal_uint16 num_of_pref_plmn;
334 cas_eas_plmn_id_struct prefplmn[MAX_PREFER_PLMN_NUM];
335 kal_uint32 prefplmnU32[MAX_PREFER_PLMN_NUM];
336}
337IratmSimEutranPlmnInfo;
338
339
340typedef struct
341{
342 srlteRatTypeT curIratmState;
343 srlteRatTypeT SettingIratmState;
344 EutranMeasModeT currEutranMeasMode;
345 IratmServingPilotMeasResultT servingPilot;
346 kal_bool bIHOInProgress;
347 kal_bool bOmpUpdated; /* True: can start irat measurement
348 False: can't start irat measurement */
349 kal_bool bStdByHPMeasIsDoing;
350 kal_bool bStdByReselMeasIsDoing;
351 kal_bool bStdByLPMeasIsDoing;
352 kal_bool bStdByConnMeasIsDoing;
353 kal_bool bStdByStopHPMeasIsDoing;
354 kal_bool bStdByStopReselMeasIsDoing;
355 kal_bool bStdByStopLPMeasIsDoing;
356 kal_bool bStdByStopConnMeasIsDoing;
357 kal_bool bStandBySuspendIsDoing;
358 kal_bool bStandByLtePowerOffIsDoing;
359 kal_bool bStandByLtePowerOffCgiStopIsDoing;
360 kal_bool bStandBySyncReceivingIsDoing;
361 kal_bool bStandByMeasCnfIsWaiting;
362 kal_bool bStandbyVirtualSuspendIsDoing;
363 kal_bool bActIratHpMeasIsDoing;
364 kal_bool bActIratQualifyMeasIsDoing;
365 kal_bool bActIratLpMeasIsDoing;
366 kal_bool bActIratAllMeasIsDoing;
367 kal_bool bActIratSuspendIsDoing;
368 kal_bool bActIratVirtualSuspendIsDoing;
369 kal_bool bActIratMeasStopIsDoing;
370 kal_bool bActIratDePriorityStopMeasIsDoing;
371 kal_bool bActIratMeasResultIsReceived;
372 kal_bool bCssMeasCtrl;/* True: start; False: stop */
373 kal_bool bAbortMeas;/* True: abort; False: don't abort */
374 kal_bool bAlmpMeasCtrl;/* True: start;False stop */
375 kal_bool bDeprioritizationInfoValid;/* Indicate if deprioritization list exist */
376 kal_bool bCgiIsDoing;
377 kal_bool bCgiStopIsDoing;
378 kal_bool bSpIsAcquired;
379 kal_bool bCssStopMeasIsDoing;
380 kal_bool bAlmpStopMeasIsDoing;
381 kal_bool bOmpStopMeasIsDoing;
382 kal_bool bReselectionIsDoing;
383 kal_bool bEvaluationIsDoing;
384 kal_bool bStopEvaluationIsDoing;
385 kal_bool bPlmnInfoIsChanged;
386 kal_bool bHighPrioritySearchMode;
387 kal_bool bToLteReselIsDoing;
388 kal_bool bCssSuspendReqWaitProcess;
389 kal_bool bLtePowerOffWaitProcess;
390 kal_bool bCssPowerOffWaitProcess;
391 kal_bool bCssSuspendResumeReqWaitProcess;
392 kal_bool bCssSetRatIsDoing;
393 kal_bool bCssSetRatNeedCnf;
394 kal_uint8 eCellMeasConfigTid;
395 OmpEUTRANNeigborListRecT eutranNeighborInfo;
396 kal_uint8 sectorID[OMP_SECTORID_LENGTH_IN_BYTE];
397 /* Barred frequency list */
398 IratmBarFrequencyT barredEutraArfcns [IRATM_ERRC_MAX_INTER_FREQUENCY];
399
400 /* Barred cell list */
401 ECellIdentifierT barredCells [IRATM_NUM_BARRED_CELLS];
402
403 Ecell_T_Reselection tReselection;
404
405 eas_cas_report_cgi_req_struct cgiInfo;
406 cgi_info_status_enum currentCgiDetectedState;
407
408 eas_deprioritization_info_struct deprioritizationInfo;
409
410 /* Number of inter frequency carrier */
411 kal_uint8 numberOfLteInterFreq;
412
413 /* Inter frequency information list */
414 IratmEutraFreqInfo lteInterFreqInfoList [IRATM_ERRC_MAX_INTER_FREQUENCY];
415
416 kal_uint8 numberOfLtePlmnInterFreq;
417
418 IratmEutraFreqInfo ltePlmnInterFreqInfoList [IRATM_ERRC_MAX_INTER_FREQUENCY];
419
420 kal_uint8 numHighLayer;
421
422 cas_eas_lte_measurement_req_struct currentErrcFreqMeasReq;
423 cas_eas_evaluate_ecell_req_struct eCellEvaluateReq;
424
425 cas_eas_lte_hps_qualify_cell_ind_struct hps_qualify_cell_ind;
426
427 IratmSimEutranPlmnInfo SimPlmnInfo;
428
429}IratmInfoT;
430
431typedef struct
432{
433 eas_cas_config_ccell_meas_req_struct data[MAX_IRAT_CCELL_MEAS_MSG_QUEUE_LEN];
434 int front;
435 int rear;
436}MsgQueue;
437
438
439/*----------------------------------------------------------------------------
440 Global Data
441----------------------------------------------------------------------------*/
442/*----------------------------------------------------------------------------
443 Global Function Prototypes
444----------------------------------------------------------------------------*/
445void iratmInit(void);
446void iratmInfoInit(kal_bool bResetPlmnInfo,kal_bool bResetBarInfo);
447kal_bool IratmCheckCgiState (void);
448kal_bool IratmCheckStandBySyncReceivingState (void);
449void IratmResetStandBySyncReceivingState (void);
450void IratmClearBarFreqForTaNotAllowed (void);
451void IratmClearBarFreqForCellBarredResvOperatorFreq (void);
452kal_bool IratmCheckStandByMeasState (void);
453void IratmSendSyncMsgToRmc (kal_bool bMsgDecodeSuccess,kal_uint16 PilotPN, kal_uint32 Lower32, kal_uint8 Upper6,
454 kal_uint16 cCCycleStartTime);
455void ProcessIratmRmcCgiFail(cgi_info_status_enum cgiFail);
456OmpEUTRANNeigborListRecT *IratmGeteutranNeighborInfo (void);
457void iratmTimerInit (void);
458
459void RunIratmStateMachine(kal_uint32 MsgId, void *MsgDataP);
460void ProcessIratmCgiInfo(kal_uint8 *pInfo);
461kal_bool isIratmProcessedMsg(kal_uint32 MsgId);
462void ProcessIratmAlmpToLteMeasCtrlReq(void* pMsg);
463kal_bool IratmGetAlmpMeasCtrlStatus(void);
464void IratmSetOmpUpdateFlag (kal_bool flag);
465void IratmSetActiveSetInfo(void);
466kal_bool IratmCheckIfPriorityChange(OmpEUTRANNeigborListRecT *pEutranNLRec,
467 OmpEUTRANNeigborListRecT *pOmpOtherRatNLRec);
468kal_bool IratmJudgeIfActiveRatState (void);
469
470
471#endif
472
473/*****************************************************************************
474* End of File
475*****************************************************************************/
476#endif /*_CLCOMP_H_*/
477
478