blob: 77ffa06bb82652dc1f5f841c35cac8799d532f81 [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) 2012
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 * Filename:
38 * ---------
39 * emac_api.h
40 *
41 * Project:
42 * --------
43 * UMOLY
44 *
45 * Description:
46 * ------------
47 *
48 *
49 * Author:
50 * -------
51 *
52 *
53 *
54 * ==========================================================================
55 * $Log$
56 *
57 * 05 25 2018 jia-shi.lin
58 * [MOLY00328472] [EIGER][MT3967][RDIT][FT][CT][Overnight][Auto][CAT][SH][SIM1:CT][SIM2:CU]md1:(MCU_core1.vpe0.tc0(VPE2)) [ASSERT] file:mcu/protocol/el2/ert/emac/src/emac_ert.c line:1383
59 * 1. rename emac_txhisr_proc as emac_tti_done_proc
60 * 2. emac_tti_done_proc move to txlisr for 95
61 *
62 * 01 11 2018 jia-shi.lin
63 * [MOLY00301451] [SMO release][93/95]EL1 relative interface
64 * emac/el1 interface re-arch
65 *
66 * 07 12 2017 jia-shi.lin
67 * [MOLY00263796] [Gen93] EL1C always ticks PCSI during DRX off period which locks sleep mode
68 * add emac api emac_slp_cqi_srs_predict_result_rxlisr
69 *
70 * 07 11 2017 jia-shi.lin
71 * [MOLY00263426] [Bianco][N1][SRLTE][CT 6M C][LTE IOT][FT][CD][HW][TC-SMFT-07005]EE md1:(MCU_core0.vpe1.tc1(VPE1)) [ASSERT] file:mcu/pcore/modem/el2/common/el2_utility.c line:509
72 * relax the 1ms timing protection for ert sf proc
73 *
74 * 06 22 2017 nicole.hsu
75 * [MOLY00259119] [MT6763][EL2] EMAC/EL2EM/EL2POW maintenance
76 * [TRUNK] potential bug fix, RSIM EM, AT&T EM
77 *
78 * 06 09 2017 jia-shi.lin
79 * [MOLY00254140] [MT6293][EL1C] Reduce processing in RRC idle
80 * check in emac_txlisr_mt_chk_stage3()
81 *
82 * 06 09 2017 mf.jhang
83 * [MOLY00254140] [MT6293][EL1C] Reduce processing in RRC idle
84 * .Provide is emac_txlisr_active for EL1
85 *
86 * 05 19 2017 jia-shi.lin
87 * [MOLY00249306] [SE2 Internal Test][MT6293][UMOLYA][ATE][20170512][1][core0,vpe1,tc2(vpe1)] Assert fail emac_drx.c 811 - (LISR)EL1_C_TX
88 * 1. drx bug fix
89 * 2. mid ind to ert
90 * 3. dl wo pdsch ind
91 *
92 * 05 19 2017 nicole.hsu
93 * [MOLY00250929] [Copy CR][BIANCO][MT6763][RDIT][PHONE][Overnight][HQ][MTBF][Lab][Ericsson][ASSERT] file:mcu/l1core/modem/el1/el1c/phs/src/el1_phs_msg.c line:2429
94 * SCell new interface/design
95 *
96 * 04 18 2017 mf.jhang
97 * [MOLY00241929] [BIANCO][MT6763][RDIT][4GPS][RTD][HEAT][LTE_04_13_02_R12_UL64QUAM_2_UL64QAMonBothCCs_Type0]Assert fail: el1_meas_ctrl.c 11916 - EL1_MPC
98 * . Add EL1C command queue
99 *
100 * 04 05 2017 jia-shi.lin
101 * [MOLY00237731] [MT6293][L+L] Feature development
102 * [EMAC] Update EL1TX EMAC interface (EMAC part).
103 *
104 * 03 02 2017 jia-shi.lin
105 * [MOLY00194987] [MT6293][UMOLYA/PS DEV] EMAC maintenance
106 * remove emac_force_phy_config_sch_close
107 *
108 * 01 19 2017 mf.jhang
109 * [MOLY00194987] [MT6293][UMOLYA/PS DEV] EMAC maintenance
110 * Split emac txlisr process into 3 stages for load balance
111 *
112 * 12 21 2016 nicole.hsu
113 * [MOLY00194987] [MT6293][UMOLYA/PS DEV] EMAC maintenance
114 * [Seamless Meta Mode] EMAC part
115 * - provide dummy API to be called in Meta Mode
116 * - provide force sch_close API to be called before leaving Meta Mode
117 *
118 * 10 18 2016 jia-shi.lin
119 * [MOLY00194987] [MT6293][UMOLYA/PS DEV] EMAC maintenance
120 * add one phich result type
121 *
122 * 10 05 2016 mf.jhang
123 * [MOLY00206476] [MT6293][NWSIM][Regression][TC_7_1_4_16] Failed at step 6
124 * add emac_ta_stag_ta_diff_exceeded
125 *
126 * 10 03 2016 nicole.hsu
127 * [MOLY00194987] [MT6293][UMOLYA/PS DEV] EMAC maintenance
128 * 1. RAR grant size check and handling
129 * 2. fix PHR api for ra group selection
130 *
131 * 08 11 2016 yu-chun.chen
132 * [MOLY00176078] [EL1C] UMOLYA code sync
133 * Back out changelist 2711251
134 *
135 * 08 11 2016 nicole.hsu
136 * [MOLY00194987] [MT6293][UMOLYA/PS DEV] EMAC maintenance
137 * 1. fix sim api warning
138 * 2. fix sim api prototype
139 * 3. provide rar_acsi_trigger assert function for el1tx
140 *
141 * 08 10 2016 shang-lun.chiu
142 * [MOLY00196539] [MT6293][EL1TX] Update comments to generate doxygen document
143 *
144 * 08 02 2016 wen-jiunn.liu
145 * [MOLY00194298] [UMOLYA] EL2 + EMAC Code Review
146 * Revise EL1-EMAC Interface
147 * - CRC Handler
148 * - DL Assignment
149 *
150 * 08 02 2016 nicole.hsu
151 * [MOLY00194987] [MT6293][PS DEV] EMAC maintenance
152 * [EMAC] ra api fix
153 *
154 * 08 01 2016 jeremy.chen
155 * [MOLY00190683] [UMOLYA][6293] EL2 merge back to UMOLYA TRUNK & PS DEV
156 *
157 * [EL2][RD domain] Sync EL2 interface from Aric CBr
158 *
159 ****************************************************************************/
160/**
161 * @file emac_api.h
162 * @brief EMAC Exported APIs to Other Libraries
163 *
164 * @author
165 * @date 2016/2/22
166 *
167 **/
168
169#ifndef __EMAC_API_H__
170#define __EMAC_API_H__
171
172#include "kal_public_api.h"
173#include "lte_time_common.h"
174#include "abs_time.h"
175#include "el1_emac_str.h"
176
177// =========================================
178// TTI Execution Process
179// =========================================
180
181/***************************************//**
182 * @brief Initialize the EMAC context before each TTI process
183 * @note Get air time from global variables / reset EMAC TTI related context
184 * @param protocol_idx
185 * @return (void)
186 ******************************************/
187void
188emac_txlisr_init_tti_proc(kal_uint32 protocol_idx);
189
190void
191emac_txlisr_proc_stage1();
192
193/***************************************//**
194 * @brief Main process for EMAC \n
195 * E.g., SCELL / TA / DL HARQ / UL HARQ / BSR / SR / RA / DRX
196 * @note Execution after all handler inputs are ready
197 * @param[in] p_sf_input Tx subframe parameter for EMAC, including information of
198 * - gap
199 * - subframe type
200 * .
201 * @return (void)
202 ******************************************/
203void
204emac_txlisr_proc_stage2(
205 emac_el1tx_tti_input_t* p_sf_input
206);
207
208void
209emac_txlisr_proc_stage3();
210
211kal_bool
212emac_txlisr_mt_chk_stage3();
213
214/***************************************//**
215 * @brief Invoke this function \@ g_abs_time to check if any
216 * EMAC handled TX requirement for tx_abs_time (g_abs_time +2)
217 * @note Called by EL1TX to query EMAC if there is any tx requirement \n
218 * One TXLISR / one TX requirement invoked (1-to-1 mapping) \n
219 * EL1 could NOT modify tx_bmp in the pointer
220 * @param (void)
221 * @return emac_el1tx_tx_req_struct* Pointer to TX request of this TTI
222 * in EMAC context \n
223 * The returned EMAC context will be cleared
224 * \@ emac_txlisr_init_tti_proc()
225 ******************************************/
226emac_el1tx_tx_req_struct*
227emac_txlisr_get_tx_req();
228
229/***************************************//**
230 * @brief Post process for EMAC \n
231 * E.g., MUX Decision / Clear UL HARQ Context / Clear TX Timeline / ...
232 * @note Execution after all handler inputs are ready
233 * @param[in] tx_results Bitmap of emac_el1tx_tx_bitmap_e
234 * @return (void)
235 ******************************************/
236void
237emac_txlisr_post_proc(
238 kal_uint32 tx_results
239);
240
241/***************************************//**
242 * @brief EMAC process in TXHISR for 93 (e.g., send ERT polling ILM)
243 * EMAC process in TXLISR for 95 (e.g., send ERT polling ILM)
244 * @note Called only in TXHISR for 93, called only in TXLISR for 95
245 * @param (void)
246 * @return (void)
247 ******************************************/
248void
249emac_tti_done_proc();
250
251// =========================================
252// TTI Input Handler Related APIs
253// =========================================
254
255/***************************************//**
256 * @brief Report n-2 or n-1 (i.e., g_abs_time -2 or -1) DCI result for DL HARQ \n
257 * Support only
258 * - C-RNTI
259 * - TC-RNTI
260 * - RA-RNTI
261 * - SPS-CRNTI (Act/Retx/Rel)
262 * .
263 * @note This function is used to update EMAC DL HARQ status \n
264 * DL unsolicited is NOT included (EMAC will calculate DL SPS) \n
265 * Indicate TB "new transmission" or not (instead of raw NDI value)
266 * @param[in] rcv_abs_time g_abs_time -1 or -2
267 * @param[in] p_pdcch_dl_info DL information carried in PDCCH
268 * @return (void)
269 ******************************************/
270void
271emac_pdcch_dl_assign_handler(
272 ABS_TICK_TIME rcv_abs_time,
273 el1tx_pdcch_dl_info_struct* p_pdcch_dl_info
274);
275
276/***************************************//**
277 * @brief Report n-2 or n-1 (i.e., g_abs_time -2 or -1) DCI result for UL HARQ \n
278 * Support only
279 * - C-RNTI
280 * - TC-RNTI
281 * - RA-RNTI
282 * - SPS-CRNTI (Act/Retx/Rel)
283 * .
284 * @note This function is used to update EMAC UL HARQ status \n
285 * UL unsolicited is NOT included (EMAC will calculate UL SPS)
286 * @param[in] ul_cc_idx UL CC index
287 * @param[in] rcv_abs_time g_abs_time -1 or -2
288 * @param[in] p_pdcch_ul_info UL information carried in PDCCH
289 * @return (void)
290 ******************************************/
291void
292emac_pdcch_ul_info_handler(
293 kal_uint8 ul_cc_idx,
294 ABS_TICK_TIME rcv_abs_time,
295 el1tx_pdcch_ul_info_struct* p_pdcch_ul_info
296);
297
298/***************************************//**
299 * @brief Report n-2 or n-1 (i.e., g_abs_time -2 or -1) PHICH result for UL HARQ
300 * @note This function is used to update EMAC UL HARQ status
301 * @param[in] ul_cc_idx UL CC index
302 * @param[in] harq_id HARQ ID
303 * @param[in] el1tx_phich_rlt_enum PHICH result
304 * @return (void)
305 ******************************************/
306void
307emac_pdcch_set_phich_result_handler(
308 kal_uint8 ul_cc_idx,
309 ABS_TICK_TIME rcv_abs_time,
310 kal_uint8 harq_id,
311 el1tx_phich_rlt_enum phich_result
312);
313
314/***************************************//**
315 * @brief - [TBC] Report n-3 or n-2 (i.e., g_abs_time -3 or -2)
316 * with each TB CRC decoding result
317 * - [TBC] Invoked after DL Assignment Handler\n
318 * With assumption of ignorance DCI for same TB within 4 subframes
319 * - [TBC] DCI v.s. CRC report is 1-to-1 mapping
320 * - Report only
321 * -- C-RNTI
322 * -- TC-RNTI
323 * -- SPS-CRNTI (Act/Retx/Config)
324 * .
325 * .
326 * @note TB information is with bitwise operation (BIT0 for TB0 : BIT1 for TB1)
327 * @param[in] p_crc_result CRC result information
328 * @return (void)
329 ******************************************/
330void
331emac_pdcch_set_crc_result_handler(
332 el1tx_pdcch_crc_result_struct* p_crc_result
333);
334
335/***************************************//**
336 * @brief Report n-2 or n-1 (i.e., g_abs_time -2 or -1) PDCCH order for RA
337 * @note If PDCCH order is received, call function to trigger PDCCH order RA process
338 * @param[in] rcv_abs_time g_abs_time -1 or -2
339 * @param[in] ul_cc_idx UL CC index
340 * @param[in] rapid RA preamble ID
341 * @param[in] mask RA mask index
342 * @return (void)
343 ******************************************/
344void
345emac_ra_pdcch_order_rcv(
346 ABS_TICK_TIME rcv_time,
347 kal_uint8 ul_cc_idx,
348 kal_uint8 rapid,
349 kal_uint8 mask
350);
351
352
353// =========================================
354// SPS Related APIs
355// =========================================
356
357/***************************************//**
358 * @brief Get UL SPS Active State in EMAC context
359 * @note This function is used to check current UL SPS state in
360 * EMAC context \@ TXLISR \n
361 * May be called in different threads, not TXLISR \n
362 * Caller should take care of multi-thread effects
363 * @param (void)
364 * @return KAL_TRUE: UL SPS is active \n
365 * KAL_FALSE: UL SPS is not active
366 ******************************************/
367kal_bool
368emac_sps_ul_get_active_state();
369
370
371// =========================================
372// UL HARQ Related APIs
373// =========================================
374
375/***************************************//**
376 * @brief Check if any UL HARQ for an UL CC is on-going
377 * @note This function is used to check PUSCH UL HARQ status \n
378 * Caller should take care of multi-thread effects \n
379 * @param[in] ul_cc_idx UL CC index
380 * @return KAL_TRUE: one or more UL HARQ are on-going \n
381 * KAL_FALSE: no UL HARQ is on-going
382 ******************************************/
383kal_bool
384emac_ul_harq_is_any_on_going(kal_uint8 ul_cc_idx);
385
386/***************************************//**
387 * @brief Predict if the grant is applied for TX based on
388 * the current UL HARQ view (Best Effort)
389 * @note This function is used to predict if the grant can be applied for TX
390 * based on the current EMAC UL HARQ view (Best Effort) \n
391 * Caller should take care of multi-thread effects \n
392 * May be called in TXLISR and RXLISR,
393 * EL1 should guarantees no simultaneous execution (no lock needed) for
394 * the same tx_abs_time
395 * @param[in] ul_cc_idx UL CC index
396 * @param[in] p_predict_req Grant to be predicted
397 * @return KAL_TRUE: grant is predicted as applied for TX in the
398 * current EMAC UL HARQ view \n
399 * KAL_FALSE: grant is predicted as NOT applied for TX in the
400 * current EMAC UL HARQ view
401 ******************************************/
402kal_bool
403emac_ul_harq_predict_grant_apply(
404 kal_uint8 ul_cc_idx,
405 el1tx_grant_apply_predict_req_struct* p_predict_req
406);
407
408/***************************************//**
409 * @brief emac_el1_txtimeline_extension_t should be defined by EL1 \n
410 * Return the EL1 extension memory (e.g., for implementing CQI only)
411 * @note Caller should take care of multi-thread effects \n
412 * EL1 extension will be cleared when TX timeline entry is cleared
413 * (\@ EMAC TXLISR post process)
414 * @param[in] ul_cc_idx UL CC index
415 * @param[in] tx_abs_time The time to refer to the timeline enrty
416 * @return Start address of EL1 extension
417 ******************************************/
418emac_el1_txtimeline_extension_t*
419emac_ul_harq_get_timeline_el1_extension(
420 kal_uint8 ul_cc_idx,
421 ABS_TICK_TIME tx_abs_time
422);
423
424
425// =========================================
426// DRX Related APIs
427// =========================================
428
429/***************************************//**
430 * @brief When EL1TX has a periodic CQI transmission on PUCCH,
431 * EL1TX needs to
432 * call this function no later than <b>cqi_tx_time - 5</b>
433 * (EL1TX does NOT support now).
434 * The reason is that EMAC needs to calculate the admission for
435 * this CQI TX
436 * @note Caller should take care of multi-thread effects \n
437 * Currently, EL1TX need not call this API since EMAC will
438 * calculate the admission for CQI TX for every TTI \n
439 * When EL1TX can support the call of this function no later
440 * than <b>cqi_tx_time -5</b>, EMAC will only calculate the admission
441 * for CQI TX in <b>cqi_tx_time</b> to save the MIPS
442 * @param[in] cqi_tx_time CQI TX time
443 * @return (void)
444 ******************************************/
445void emac_drx_set_cqi_tx_time(ABS_TICK_TIME cqi_tx_time);
446
447/***************************************//**
448 * @brief When EL1TX has a type0 SRS transmission, EL1TX needs to
449 * call this function no later than <b>type0_srs_tx_time - 5</b>.
450 * The reason is that EMAC needs to calculate the admission for this SRS TX
451 * @note Caller should take care of multi-thread effects \n
452 * Currently, EL1TX need not call this API since EMAC will
453 * calculate the admission for type0 SRS TX for every TTI \n
454 * When EL1TX can support the call of this function no later
455 * than <b>type0_srs_tx_time -5</b>, EMAC will only calculate the admission
456 * for type0 SRS TX in <b>type0_srs_tx_time</b> to save the MIPS
457 * @param[in] type0_srs_tx_time type0 SRS TX time
458 * @return (void)
459 ******************************************/
460void emac_drx_set_type0_srs_tx_time(ABS_TICK_TIME type0_srs_tx_time);
461
462/***************************************//**
463 * @brief EMAC will return the TX admission of cqi and type0 srs
464 * for tx_abs_time
465 * @note emac_drx_set_cqi_tx_time or emac_drx_set_type0_srs_tx_time should be called
466 * before emac_drx_cqi_srs_admin is called \n
467 * Caller should take care of multi-thread effects \n
468 * The timing for calling this API is expected to be after the EMAC TTI
469 * process of <b>tx_abs_time -2</b>
470 * @param[in] tx_abs_time periodic CQI and type0 SRS time
471 * @param[out] p_cqi_srs_admin_info admission information of periodic CQI and type0 SRS
472 * @return (void)
473 ******************************************/
474void emac_drx_cqi_srs_admin(ABS_TICK_TIME tx_abs_time,
475 emac_el1tx_drx_cqi_srs_admin_info_struct * p_cqi_srs_admin_info);
476
477
478/***************************************//**
479 * @brief DL without PDSCH occurs
480 * @note when DL without PDSCH occurs, call this api
481 * @param[in] rcv_abs_time the rcv_abs_time for this DL
482 * @return (void)
483 ******************************************/
484void emac_drx_dl_wo_pdsch_handler(ABS_TICK_TIME rcv_abs_time);
485
486
487
488// =========================================
489// SLEEP Related APIs
490// =========================================
491
492kal_bool emac_slp_is_prev1_dci_info_required(void);
493kal_bool emac_slp_cqi_srs_predict_result_rxlisr(ABS_TICK_TIME tx_abs_time);
494
495// =========================================
496// RA Related APIs
497// =========================================
498
499kal_bool emac_ra_is_rar_grant_valid(el1tx_pdcch_ul_info_struct* p_grant);
500void emac_ra_set_max_txpower_reached();
501void emac_ra_rar_acsi_trigger_fail();
502void emac_ra_tcrnti_ack_add_fail();
503void emac_ra_set_last_prach_tx_power(kal_uint16 prach_tx_power);
504
505// =========================================
506// PHR Related APIs
507// =========================================
508
509kal_bool emac_el1_phr_res_handler(emac_el1tx_phr_res_struct phr_content);
510
511// =========================================
512// TA Related APIs
513// =========================================
514void emac_ta_stag_ta_diff_exceeded(kal_uint32 stag_id);
515
516// =========================================
517// SCELL Related APIs
518// =========================================
519void emac_scell_el1c_cnf();
520void emac_scell_rel(kal_uint32 cc_idx);
521
522kal_bool emac_txlisr_active(ABS_TICK_TIME cur_abs_time);
523kal_bool emac_txlisr_tx_checksum_error_bypass_check(ABS_TICK_TIME tx_abs_time);
524
525// =========================================
526// META_MODE Related APIs
527// =========================================
528void emac_dummy_txlisr_init_tti_proc(kal_uint32 protocol_idx);
529void emac_dummy_txlisr_post_proc(kal_uint32 tx_results);
530void emac_dummy_txlisr_proc(emac_el1tx_tti_input_t* p_sf_input);
531void emac_dummy_tti_done_proc();
532void emac_dummy_txlisr_proc_stage1();
533void emac_dummy_txlisr_proc_stage3();
534
535
536#endif