From 6b48fd6380424a00fe1bec170ee7639512bdda55 Mon Sep 17 00:00:00 2001 From: "Wilson W.K. Thong" Date: Mon, 2 May 2016 22:58:45 +0800 Subject: [PATCH 01/60] ** new procedure - refresh kENB from NAS -> AS ** added flow to refresh KeNB key in RRC on receiving S1AP-InitialContextSetup added flow to configure PDCP security mode enabled filling in the PDCP MAC code during and after RRC-SMC procedure (cherry picked from commit 898cd5c45aedb27625d73352568211b4467c8dd9) --- openair2/COMMON/as_message.h | 10 +++ openair2/COMMON/rrc_messages_def.h | 3 + openair2/COMMON/rrc_messages_types.h | 6 ++ openair2/RRC/LITE/defs.h | 4 + openair2/RRC/LITE/rrc_UE.c | 94 ++++++++++++++++++++ openair3/NAS/COMMON/API/NETWORK/l2_message.h | 10 +++ openair3/NAS/UE/EMM/SecurityModeControl.c | 6 +- openair3/NAS/UE/nas_itti_messaging.c | 35 ++++++++ openair3/NAS/UE/nas_itti_messaging.h | 5 ++ 9 files changed, 172 insertions(+), 1 deletion(-) diff --git a/openair2/COMMON/as_message.h b/openair2/COMMON/as_message.h index 30810a325e..5f7f6f3fa9 100644 --- a/openair2/COMMON/as_message.h +++ b/openair2/COMMON/as_message.h @@ -220,6 +220,16 @@ typedef struct broadcast_info_ind_s { #define AS_HSDUPA (1 << NET_ACCESS_HSDUPA) #define AS_EUTRAN (1 << NET_ACCESS_EUTRAN) +#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete +/* + * NAS->AS -K_eNB refresh request + * NAS request AS to refresh its KeNB key + */ +typedef struct kenb_refresh_req_s { + Byte_t kenb[32]; +} kenb_refresh_req_t; +#endif + /* * NAS->AS - Cell Information request * NAS request AS to search for a suitable cell belonging to the selected diff --git a/openair2/COMMON/rrc_messages_def.h b/openair2/COMMON/rrc_messages_def.h index 27d3a6bdd4..d521eab0ff 100644 --- a/openair2/COMMON/rrc_messages_def.h +++ b/openair2/COMMON/rrc_messages_def.h @@ -64,6 +64,9 @@ MESSAGE_DEF(RRC_STATE_IND, MESSAGE_PRIORITY_MED, RrcStateInd, MESSAGE_DEF(RRC_CONFIGURATION_REQ, MESSAGE_PRIORITY_MED, RrcConfigurationReq, rrc_configuration_req) // UE: NAS -> RRC messages +#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete +MESSAGE_DEF(NAS_KENB_REFRESH_REQ, MESSAGE_PRIORITY_MED, NasKenbRefreshReq, nas_kenb_refresh_req) +#endif MESSAGE_DEF(NAS_CELL_SELECTION_REQ, MESSAGE_PRIORITY_MED, NasCellSelectionReq, nas_cell_selection_req) MESSAGE_DEF(NAS_CONN_ESTABLI_REQ, MESSAGE_PRIORITY_MED, NasConnEstabliReq, nas_conn_establi_req) MESSAGE_DEF(NAS_UPLINK_DATA_REQ, MESSAGE_PRIORITY_MED, NasUlDataReq, nas_ul_data_req) diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index ffe194265f..908510d94b 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -70,6 +70,9 @@ typedef UL_DCCH_Message_t RrcUlDcchMessage; #define RRC_CONFIGURATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_configuration_req +#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete +#define NAS_KENB_REFRESH_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_kenb_refresh_req +#endif #define NAS_CELL_SELECTION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_cell_selection_req #define NAS_CONN_ESTABLI_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_establi_req #define NAS_UPLINK_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_ul_data_req @@ -183,6 +186,9 @@ typedef struct RrcConfigurationReq_s { } RrcConfigurationReq; // UE: NAS -> RRC messages +#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete +typedef kenb_refresh_req_t NasKenbRefreshReq; +#endif typedef cell_info_req_t NasCellSelectionReq; typedef nas_establish_req_t NasConnEstabliReq; typedef ul_info_transfer_req_t NasUlDataReq; diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index e546b52f8e..e34c532990 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -182,7 +182,11 @@ typedef enum HO_STATE_e { #define PAYLOAD_SIZE_MAX 1024 #define RRC_BUF_SIZE 255 #define UNDEF_SECURITY_MODE 0xff +#if 1 // wilson 2016-05-01 let RRC security mode command to return OK instead of failed +#define NO_SECURITY_MODE 0x20 +#else #define NO_SECURITY_MODE 0x33 +#endif #define CBA_OFFSET 0xfff4 // #define NUM_MAX_CBA_GROUP 4 // in the platform_constants diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index 01c1ee6ca9..51c7aa076d 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -39,6 +39,7 @@ #define RRC_UE_C #include "assertions.h" +#include "hashtable.h" #include "asn1_conversions.h" #include "defs.h" #include "PHY/TOOLS/dB_routines.h" @@ -107,6 +108,15 @@ extern void *bigphys_malloc(int); extern int8_t dB_fixed2(uint32_t x,uint32_t y); +extern void pdcp_config_set_security( + const protocol_ctxt_t* const ctxt_pP, + pdcp_t * const pdcp_pP, + const rb_id_t rb_idP, + const uint16_t lc_idP, + const uint8_t security_modeP, + uint8_t * const kRRCenc, + uint8_t * const kRRCint, + uint8_t * const kUPenc); // internal prototypes @@ -1392,6 +1402,64 @@ rrc_ue_process_securityModeCommand( ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_securityModeFailure; } + +#if 1 // wilson 2016-01-05 config PDCP security mode +#if defined(ENABLE_SECURITY) + uint8_t *kRRCenc = NULL; + uint8_t *kUPenc = NULL; + uint8_t *kRRCint = NULL; + pdcp_t *pdcp_p = NULL; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; + + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, + ctxt_pP->enb_flag, DCCH, SRB_FLAG_YES); + h_rc = hashtable_get(pdcp_coll_p, key, (void**) &pdcp_p); + + if (h_rc == HASH_TABLE_OK) { + LOG_D(RRC, "PDCP_COLL_KEY_VALUE() returns valid key = %d\n", key); + + LOG_D(RRC, "driving kRRCenc, kRRCint and kUPenc from KeNB=" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x\n", + UE_rrc_inst[ctxt_pP->module_id].kenb[0], UE_rrc_inst[ctxt_pP->module_id].kenb[1], UE_rrc_inst[ctxt_pP->module_id].kenb[2], UE_rrc_inst[ctxt_pP->module_id].kenb[3], + UE_rrc_inst[ctxt_pP->module_id].kenb[4], UE_rrc_inst[ctxt_pP->module_id].kenb[5], UE_rrc_inst[ctxt_pP->module_id].kenb[6], UE_rrc_inst[ctxt_pP->module_id].kenb[7], + UE_rrc_inst[ctxt_pP->module_id].kenb[8], UE_rrc_inst[ctxt_pP->module_id].kenb[9], UE_rrc_inst[ctxt_pP->module_id].kenb[10], UE_rrc_inst[ctxt_pP->module_id].kenb[11], + UE_rrc_inst[ctxt_pP->module_id].kenb[12], UE_rrc_inst[ctxt_pP->module_id].kenb[13], UE_rrc_inst[ctxt_pP->module_id].kenb[14], UE_rrc_inst[ctxt_pP->module_id].kenb[15], + UE_rrc_inst[ctxt_pP->module_id].kenb[16], UE_rrc_inst[ctxt_pP->module_id].kenb[17], UE_rrc_inst[ctxt_pP->module_id].kenb[18], UE_rrc_inst[ctxt_pP->module_id].kenb[19], + UE_rrc_inst[ctxt_pP->module_id].kenb[20], UE_rrc_inst[ctxt_pP->module_id].kenb[21], UE_rrc_inst[ctxt_pP->module_id].kenb[22], UE_rrc_inst[ctxt_pP->module_id].kenb[23], + UE_rrc_inst[ctxt_pP->module_id].kenb[24], UE_rrc_inst[ctxt_pP->module_id].kenb[25], UE_rrc_inst[ctxt_pP->module_id].kenb[26], UE_rrc_inst[ctxt_pP->module_id].kenb[27], + UE_rrc_inst[ctxt_pP->module_id].kenb[28], UE_rrc_inst[ctxt_pP->module_id].kenb[29], UE_rrc_inst[ctxt_pP->module_id].kenb[30], UE_rrc_inst[ctxt_pP->module_id].kenb[31]); + + derive_key_rrc_enc(UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm, + UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCenc); + derive_key_rrc_int(UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm, + UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCint); + derive_key_up_enc(UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm, + UE_rrc_inst[ctxt_pP->module_id].kenb, &kUPenc); + + if (securityMode != 0xff) { + pdcp_config_set_security(ctxt_pP, pdcp_p, 0, 0, + UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm + | (UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm << 4), + kRRCenc, kRRCint, kUPenc); + } else { + LOG_W(RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", + securityMode); + } + } else { + LOG_W(RRC, "Could not get PDCP instance where key=0x%\n", key); + } + +#endif //#if defined(ENABLE_SECURITY) +#endif //#if 1 //wilson + if (securityModeCommand->criticalExtensions.present == SecurityModeCommand__criticalExtensions_PR_c1) { if (securityModeCommand->criticalExtensions.choice.c1.present == SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8) { @@ -4063,6 +4131,32 @@ void *rrc_ue_task( void *args_p ) # if defined(ENABLE_USE_MME) +#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete + case NAS_KENB_REFRESH_REQ: + memcpy((void*)UE_rrc_inst[ue_mod_id].kenb, (void*)NAS_KENB_REFRESH_REQ(msg_p).kenb, sizeof(UE_rrc_inst[ue_mod_id].kenb)); + + LOG_D(RRC, "[UE %d] Received %s: refreshed RRC::KeNB = " + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x\n", + ue_mod_id, msg_name, + UE_rrc_inst[ue_mod_id].kenb[0], UE_rrc_inst[ue_mod_id].kenb[1], UE_rrc_inst[ue_mod_id].kenb[2], UE_rrc_inst[ue_mod_id].kenb[3], + UE_rrc_inst[ue_mod_id].kenb[4], UE_rrc_inst[ue_mod_id].kenb[5], UE_rrc_inst[ue_mod_id].kenb[6], UE_rrc_inst[ue_mod_id].kenb[7], + UE_rrc_inst[ue_mod_id].kenb[8], UE_rrc_inst[ue_mod_id].kenb[9], UE_rrc_inst[ue_mod_id].kenb[10], UE_rrc_inst[ue_mod_id].kenb[11], + UE_rrc_inst[ue_mod_id].kenb[12], UE_rrc_inst[ue_mod_id].kenb[13], UE_rrc_inst[ue_mod_id].kenb[14], UE_rrc_inst[ue_mod_id].kenb[15], + UE_rrc_inst[ue_mod_id].kenb[16], UE_rrc_inst[ue_mod_id].kenb[17], UE_rrc_inst[ue_mod_id].kenb[18], UE_rrc_inst[ue_mod_id].kenb[19], + UE_rrc_inst[ue_mod_id].kenb[20], UE_rrc_inst[ue_mod_id].kenb[21], UE_rrc_inst[ue_mod_id].kenb[22], UE_rrc_inst[ue_mod_id].kenb[23], + UE_rrc_inst[ue_mod_id].kenb[24], UE_rrc_inst[ue_mod_id].kenb[25], UE_rrc_inst[ue_mod_id].kenb[26], UE_rrc_inst[ue_mod_id].kenb[27], + UE_rrc_inst[ue_mod_id].kenb[28], UE_rrc_inst[ue_mod_id].kenb[29], UE_rrc_inst[ue_mod_id].kenb[30], UE_rrc_inst[ue_mod_id].kenb[31]); + + break; +#endif + /* NAS messages */ case NAS_CELL_SELECTION_REQ: ue_mod_id = 0; /* TODO force ue_mod_id to first UE, NAS UE not virtualized yet */ diff --git a/openair3/NAS/COMMON/API/NETWORK/l2_message.h b/openair3/NAS/COMMON/API/NETWORK/l2_message.h index 02e5d87354..603f7c0d7d 100644 --- a/openair3/NAS/COMMON/API/NETWORK/l2_message.h +++ b/openair3/NAS/COMMON/API/NETWORK/l2_message.h @@ -116,6 +116,15 @@ Description Defines the messages supported by the Access Stratum sublayer #define AS_HSDUPA (1 << NET_ACCESS_HSDUPA) #define AS_EUTRAN (1 << NET_ACCESS_EUTRAN) +/* + * NAS->AS -K_eNB refresh request + * NAS request AS to refresh its KeNB key + */ +typedef struct kenb_refresh_req_s { + Byte_t kenb[32]; +} kenb_refresh_req_t; + +#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete /* * NAS->AS - Cell Information request * NAS request AS to search for a suitable cell belonging to the selected @@ -125,6 +134,7 @@ typedef struct { plmn_t plmnID; /* PLMN identifier */ Byte_t rat; /* Bitmap - set of radio access technologies */ } cell_info_req_t; +#endif /* * AS->NAS - Cell Information response diff --git a/openair3/NAS/UE/EMM/SecurityModeControl.c b/openair3/NAS/UE/EMM/SecurityModeControl.c index fd7e4c3991..fa500ad316 100755 --- a/openair3/NAS/UE/EMM/SecurityModeControl.c +++ b/openair3/NAS/UE/EMM/SecurityModeControl.c @@ -72,6 +72,8 @@ Description Defines the security mode control EMM procedure executed by the #include "secu_defs.h" #include "msc.h" +#include "nas_itti_messaging.h" + /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ /****************************************************************************/ @@ -293,7 +295,9 @@ int emm_proc_security_mode_command(int native_ksi, int ksi, _emm_data.security->selected_algorithms.encryption = seea; _emm_data.security->selected_algorithms.integrity = seia; - +#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete + nas_itti_kenb_refresh_req(_security_data.kenb.value); +#endif } /* * NAS security mode command not accepted by the UE diff --git a/openair3/NAS/UE/nas_itti_messaging.c b/openair3/NAS/UE/nas_itti_messaging.c index 7b8f630b89..ff16c83ebf 100755 --- a/openair3/NAS/UE/nas_itti_messaging.c +++ b/openair3/NAS/UE/nas_itti_messaging.c @@ -187,6 +187,41 @@ int nas_itti_protected_msg(const char *buffer, const nas_message_t *msg, const i extern unsigned char NB_eNB_INST; +#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete +int nas_itti_kenb_refresh_req(const Byte_t kenb[32]) +{ + MessageDef *message_p; + + message_p = itti_alloc_new_message(TASK_NAS_UE, NAS_KENB_REFRESH_REQ); + + memcpy(NAS_KENB_REFRESH_REQ(message_p).kenb, kenb, sizeof(NAS_KENB_REFRESH_REQ(message_p).kenb)); + + MSC_LOG_TX_MESSAGE( + MSC_NAS_UE, + MSC_RRC_UE, + NULL,0, + "0 NAS_KENB_REFRESH_REQ KeNB " + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x" + "%02x%02x%02x%02x", + kenb[0], kenb[1], kenb[2], kenb[3], + kenb[4], kenb[5], kenb[6], kenb[7], + kenb[8], kenb[9], kenb[10], kenb[11], + kenb[12], kenb[13], kenb[14], kenb[15], + kenb[16], kenb[17], kenb[18], kenb[19], + kenb[20], kenb[21], kenb[22], kenb[23], + kenb[24], kenb[25], kenb[26], kenb[27], + kenb[28], kenb[29], kenb[30], kenb[31]); + + return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + 0 /* TODO to be virtualized */, message_p); +} +#endif + int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat) { MessageDef *message_p; diff --git a/openair3/NAS/UE/nas_itti_messaging.h b/openair3/NAS/UE/nas_itti_messaging.h index 9ea80f63c0..dc8d41a239 100755 --- a/openair3/NAS/UE/nas_itti_messaging.h +++ b/openair3/NAS/UE/nas_itti_messaging.h @@ -54,6 +54,11 @@ int nas_itti_protected_msg( # if defined(NAS_BUILT_IN_UE) + +#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete +int nas_itti_kenb_refresh_req(const Byte_t kenb[32]); +#endif + int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat); int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t s_tmsi, plmn_t plmnID, Byte_t *data_pP, uint32_t lengthP); From fe2b7d80d3f43845e3e1a0404f92a9d1a4a77c7e Mon Sep 17 00:00:00 2001 From: "Wilson W.K. Thong" Date: Mon, 2 May 2016 23:13:30 +0800 Subject: [PATCH 02/60] removed 'wilson' from the codes --- openair2/COMMON/as_message.h | 2 -- openair2/COMMON/rrc_messages_def.h | 2 -- openair2/COMMON/rrc_messages_types.h | 4 ---- openair2/RRC/LITE/defs.h | 4 ---- openair2/RRC/LITE/rrc_UE.c | 4 ---- openair3/NAS/COMMON/API/NETWORK/l2_message.h | 2 -- openair3/NAS/UE/EMM/SecurityModeControl.c | 2 -- openair3/NAS/UE/nas_itti_messaging.c | 2 -- openair3/NAS/UE/nas_itti_messaging.h | 2 -- 9 files changed, 24 deletions(-) diff --git a/openair2/COMMON/as_message.h b/openair2/COMMON/as_message.h index 5f7f6f3fa9..976a398061 100644 --- a/openair2/COMMON/as_message.h +++ b/openair2/COMMON/as_message.h @@ -220,7 +220,6 @@ typedef struct broadcast_info_ind_s { #define AS_HSDUPA (1 << NET_ACCESS_HSDUPA) #define AS_EUTRAN (1 << NET_ACCESS_EUTRAN) -#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete /* * NAS->AS -K_eNB refresh request * NAS request AS to refresh its KeNB key @@ -228,7 +227,6 @@ typedef struct broadcast_info_ind_s { typedef struct kenb_refresh_req_s { Byte_t kenb[32]; } kenb_refresh_req_t; -#endif /* * NAS->AS - Cell Information request diff --git a/openair2/COMMON/rrc_messages_def.h b/openair2/COMMON/rrc_messages_def.h index d521eab0ff..83cd8558d4 100644 --- a/openair2/COMMON/rrc_messages_def.h +++ b/openair2/COMMON/rrc_messages_def.h @@ -64,9 +64,7 @@ MESSAGE_DEF(RRC_STATE_IND, MESSAGE_PRIORITY_MED, RrcStateInd, MESSAGE_DEF(RRC_CONFIGURATION_REQ, MESSAGE_PRIORITY_MED, RrcConfigurationReq, rrc_configuration_req) // UE: NAS -> RRC messages -#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete MESSAGE_DEF(NAS_KENB_REFRESH_REQ, MESSAGE_PRIORITY_MED, NasKenbRefreshReq, nas_kenb_refresh_req) -#endif MESSAGE_DEF(NAS_CELL_SELECTION_REQ, MESSAGE_PRIORITY_MED, NasCellSelectionReq, nas_cell_selection_req) MESSAGE_DEF(NAS_CONN_ESTABLI_REQ, MESSAGE_PRIORITY_MED, NasConnEstabliReq, nas_conn_establi_req) MESSAGE_DEF(NAS_UPLINK_DATA_REQ, MESSAGE_PRIORITY_MED, NasUlDataReq, nas_ul_data_req) diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 908510d94b..1befc4a676 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -70,9 +70,7 @@ typedef UL_DCCH_Message_t RrcUlDcchMessage; #define RRC_CONFIGURATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_configuration_req -#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete #define NAS_KENB_REFRESH_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_kenb_refresh_req -#endif #define NAS_CELL_SELECTION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_cell_selection_req #define NAS_CONN_ESTABLI_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_establi_req #define NAS_UPLINK_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_ul_data_req @@ -186,9 +184,7 @@ typedef struct RrcConfigurationReq_s { } RrcConfigurationReq; // UE: NAS -> RRC messages -#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete typedef kenb_refresh_req_t NasKenbRefreshReq; -#endif typedef cell_info_req_t NasCellSelectionReq; typedef nas_establish_req_t NasConnEstabliReq; typedef ul_info_transfer_req_t NasUlDataReq; diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index e34c532990..b15b70b815 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -182,11 +182,7 @@ typedef enum HO_STATE_e { #define PAYLOAD_SIZE_MAX 1024 #define RRC_BUF_SIZE 255 #define UNDEF_SECURITY_MODE 0xff -#if 1 // wilson 2016-05-01 let RRC security mode command to return OK instead of failed #define NO_SECURITY_MODE 0x20 -#else -#define NO_SECURITY_MODE 0x33 -#endif #define CBA_OFFSET 0xfff4 // #define NUM_MAX_CBA_GROUP 4 // in the platform_constants diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index 51c7aa076d..d666e54684 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -1403,7 +1403,6 @@ rrc_ue_process_securityModeCommand( } -#if 1 // wilson 2016-01-05 config PDCP security mode #if defined(ENABLE_SECURITY) uint8_t *kRRCenc = NULL; uint8_t *kUPenc = NULL; @@ -1458,7 +1457,6 @@ rrc_ue_process_securityModeCommand( } #endif //#if defined(ENABLE_SECURITY) -#endif //#if 1 //wilson if (securityModeCommand->criticalExtensions.present == SecurityModeCommand__criticalExtensions_PR_c1) { if (securityModeCommand->criticalExtensions.choice.c1.present == SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8) { @@ -4131,7 +4129,6 @@ void *rrc_ue_task( void *args_p ) # if defined(ENABLE_USE_MME) -#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete case NAS_KENB_REFRESH_REQ: memcpy((void*)UE_rrc_inst[ue_mod_id].kenb, (void*)NAS_KENB_REFRESH_REQ(msg_p).kenb, sizeof(UE_rrc_inst[ue_mod_id].kenb)); @@ -4155,7 +4152,6 @@ void *rrc_ue_task( void *args_p ) UE_rrc_inst[ue_mod_id].kenb[28], UE_rrc_inst[ue_mod_id].kenb[29], UE_rrc_inst[ue_mod_id].kenb[30], UE_rrc_inst[ue_mod_id].kenb[31]); break; -#endif /* NAS messages */ case NAS_CELL_SELECTION_REQ: diff --git a/openair3/NAS/COMMON/API/NETWORK/l2_message.h b/openair3/NAS/COMMON/API/NETWORK/l2_message.h index 603f7c0d7d..9c349b8d06 100644 --- a/openair3/NAS/COMMON/API/NETWORK/l2_message.h +++ b/openair3/NAS/COMMON/API/NETWORK/l2_message.h @@ -124,7 +124,6 @@ typedef struct kenb_refresh_req_s { Byte_t kenb[32]; } kenb_refresh_req_t; -#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete /* * NAS->AS - Cell Information request * NAS request AS to search for a suitable cell belonging to the selected @@ -134,7 +133,6 @@ typedef struct { plmn_t plmnID; /* PLMN identifier */ Byte_t rat; /* Bitmap - set of radio access technologies */ } cell_info_req_t; -#endif /* * AS->NAS - Cell Information response diff --git a/openair3/NAS/UE/EMM/SecurityModeControl.c b/openair3/NAS/UE/EMM/SecurityModeControl.c index fa500ad316..b3f2b6f8a8 100755 --- a/openair3/NAS/UE/EMM/SecurityModeControl.c +++ b/openair3/NAS/UE/EMM/SecurityModeControl.c @@ -295,9 +295,7 @@ int emm_proc_security_mode_command(int native_ksi, int ksi, _emm_data.security->selected_algorithms.encryption = seea; _emm_data.security->selected_algorithms.integrity = seia; -#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete nas_itti_kenb_refresh_req(_security_data.kenb.value); -#endif } /* * NAS security mode command not accepted by the UE diff --git a/openair3/NAS/UE/nas_itti_messaging.c b/openair3/NAS/UE/nas_itti_messaging.c index ff16c83ebf..a28c7394b2 100755 --- a/openair3/NAS/UE/nas_itti_messaging.c +++ b/openair3/NAS/UE/nas_itti_messaging.c @@ -187,7 +187,6 @@ int nas_itti_protected_msg(const char *buffer, const nas_message_t *msg, const i extern unsigned char NB_eNB_INST; -#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete int nas_itti_kenb_refresh_req(const Byte_t kenb[32]) { MessageDef *message_p; @@ -220,7 +219,6 @@ int nas_itti_kenb_refresh_req(const Byte_t kenb[32]) return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + 0 /* TODO to be virtualized */, message_p); } -#endif int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat) { diff --git a/openair3/NAS/UE/nas_itti_messaging.h b/openair3/NAS/UE/nas_itti_messaging.h index dc8d41a239..a9db232d70 100755 --- a/openair3/NAS/UE/nas_itti_messaging.h +++ b/openair3/NAS/UE/nas_itti_messaging.h @@ -55,9 +55,7 @@ int nas_itti_protected_msg( # if defined(NAS_BUILT_IN_UE) -#if 1 // wilson 2016-05-02 add new message to update kenb in RRC after NAS SMC complete int nas_itti_kenb_refresh_req(const Byte_t kenb[32]); -#endif int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat); From 7e2c8e39f820a0dc76d340ec290ab8a26f9ea747 Mon Sep 17 00:00:00 2001 From: "Wilson W.K. Thong" Date: Tue, 3 May 2016 01:32:48 +0800 Subject: [PATCH 03/60] fixed oaisim build failed with the new KeNB refresh request message from NAS -> AS --- openair3/NAS/UE/EMM/SecurityModeControl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair3/NAS/UE/EMM/SecurityModeControl.c b/openair3/NAS/UE/EMM/SecurityModeControl.c index b3f2b6f8a8..9f4186412e 100755 --- a/openair3/NAS/UE/EMM/SecurityModeControl.c +++ b/openair3/NAS/UE/EMM/SecurityModeControl.c @@ -72,7 +72,9 @@ Description Defines the security mode control EMM procedure executed by the #include "secu_defs.h" #include "msc.h" +#if defined(NAS_BUILT_IN_UE) #include "nas_itti_messaging.h" +#endif /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -295,7 +297,9 @@ int emm_proc_security_mode_command(int native_ksi, int ksi, _emm_data.security->selected_algorithms.encryption = seea; _emm_data.security->selected_algorithms.integrity = seia; +#if defined(NAS_BUILT_IN_UE) nas_itti_kenb_refresh_req(_security_data.kenb.value); +#endif } /* * NAS security mode command not accepted by the UE From 19c81e741e61956cb0c49ddc2c7d65872efb1101 Mon Sep 17 00:00:00 2001 From: "Wilson W.K. Thong" Date: Sun, 18 Sep 2016 15:34:47 +0800 Subject: [PATCH 04/60] fixed hard-code DRB-ID<->LC-ID mapping (DRB-ID = LC-ID - 2) so they are not fully configurable fixed hard-code default DRB-ID (1) so it is now fully configurable (cherry picked from commit 4499124853b8985c3f157721997125370f1ca475) Conflicts: openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c Conflicts: openair2/LAYER2/PDCP_v10.1.0/pdcp.c --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 64 ++++++++- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 20 ++- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 28 +++- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 10 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h | 12 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c | 7 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h | 4 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c | 4 +- openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c | 15 ++- openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h | 10 +- .../RLC/UM_v9.3.0/rlc_um_control_primitives.c | 18 ++- .../RLC/UM_v9.3.0/rlc_um_control_primitives.h | 14 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c | 20 +-- openair2/LAYER2/RLC/rlc.h | 13 +- openair2/LAYER2/RLC/rlc_mac.c | 20 ++- openair2/LAYER2/RLC/rlc_rrc.c | 122 +++++++++++++----- openair2/RRC/LITE/defs.h | 3 + openair2/RRC/LITE/rrc_UE.c | 22 +++- openair2/RRC/LITE/rrc_eNB.c | 8 +- 19 files changed, 323 insertions(+), 91 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 3779adbbc9..7f9017201a 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1065,6 +1065,7 @@ rrc_pdcp_config_asn1_req ( #ifdef Rel10 ,PMCH_InfoList_r9_t* const pmch_InfoList_r9_pP #endif + ,rb_id_t *const defaultDRB // 2016-05-28 wilson : remember the default DRB ) //----------------------------------------------------------------------------- { @@ -1086,6 +1087,10 @@ rrc_pdcp_config_asn1_req ( hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; +#ifndef ASTRI_FIX // 2016-05-28 wilson : remember the default DRB + hash_key_t key_defaultDRB = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_defaultDRB_rc; +#endif #ifdef Rel10 int i,j; MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL; @@ -1106,7 +1111,11 @@ rrc_pdcp_config_asn1_req ( srb_id = srb2add_list_pP->list.array[cnt]->srb_Identity; srb_toaddmod_p = srb2add_list_pP->list.array[cnt]; rlc_type = RLC_MODE_AM; +#if 0 lc_id = srb_id;// + 2; +#else // 2016-05-27 wilson : fixing the LC-id <-> SRB-id mapping + lc_id = srb_id; +#endif key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_YES); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); @@ -1186,8 +1195,23 @@ rrc_pdcp_config_asn1_req ( drb_toaddmod_p = drb2add_list_pP->list.array[cnt]; drb_id = drb_toaddmod_p->drb_Identity;// + drb_id_offset; - +#ifdef ASTRI_FIX lc_id = drb_id + 2; +#else // 2016-05-27 wilson : fixing the mapping between LC-id and DRB-id + if (drb_toaddmod_p->logicalChannelIdentity) { + lc_id = *(drb_toaddmod_p->logicalChannelIdentity); + } else { + LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" logicalChannelIdentity is missing in DRB-ToAddMod information element!\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); + continue; + } + + if (lc_id == 1 || lc_id == 2) { + LOG_E(RLC, PROTOCOL_CTXT_FMT" logicalChannelIdentity = %d is invalid in RRC message when adding DRB!\n", PROTOCOL_CTXT_ARGS(ctxt_pP), lc_id); + continue; + } +#endif + DevCheck4(drb_id < maxDRB, drb_id, maxDRB, ctxt_pP->module_id, ctxt_pP->rnti); key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); @@ -1203,6 +1227,22 @@ rrc_pdcp_config_asn1_req ( pdcp_p = calloc(1, sizeof(pdcp_t)); h_rc = hashtable_insert(pdcp_coll_p, key, pdcp_p); +#ifndef ASTRI_FIX + if ((defaultDRB != NULL) && (*defaultDRB == drb_id)) { + key_defaultDRB = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag); + h_defaultDRB_rc = hashtable_insert(pdcp_coll_p, key_defaultDRB, pdcp_p); + } else { + h_defaultDRB_rc = HASH_TABLE_OK; // do not trigger any error handling if this is not a default DRB + } + + if (h_defaultDRB_rc != HASH_TABLE_OK) { + LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD ADD default DRB key 0x%"PRIx64" FAILED\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), + key_defaultDRB); + free(pdcp_p); + return TRUE; + } else +#endif if (h_rc != HASH_TABLE_OK) { LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD ADD key 0x%"PRIx64" FAILED\n", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), @@ -1297,7 +1337,9 @@ rrc_pdcp_config_asn1_req ( for (cnt=0; cntlist.count; cnt++) { pdrb_id_p = drb2release_list_pP->list.array[cnt]; drb_id = *pdrb_id_p; +#if 0 // 2016-05-27 wilson : fixing the hard-coded mapping between DRB-id <-> LC-id lc_id = drb_id + 2; +#endif key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_NO); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); @@ -1308,6 +1350,10 @@ rrc_pdcp_config_asn1_req ( continue; } +#ifndef ASTRI_FIX // 2016-05-27 wilson : fixing the hard-coded mapping between DRB-id <-> LC-id + lc_id = pdcp_p->lcid; +#endif + action = CONFIG_ACTION_REMOVE; pdcp_config_req_asn1 ( ctxt_pP, @@ -1326,6 +1372,22 @@ rrc_pdcp_config_asn1_req ( kRRCint_pP, kUPenc_pP); h_rc = hashtable_remove(pdcp_coll_p, key); + +#ifndef ASTRI_FIX // 2016-05-28 wilson : remember the default DRB + if ((defaultDRB != NULL) && (*defaultDRB == drb_id)) { + // this is the default DRB being removed, although this is not allowed in standard + key_defaultDRB = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag); + h_defaultDRB_rc = hashtable_get(pdcp_coll_p, key_defaultDRB, (void**)&pdcp_p); + + if (h_defaultDRB_rc == HASH_TABLE_OK) { + h_defaultDRB_rc = hashtable_remove(pdcp_coll_p, key_defaultDRB); + } else { + LOG_E(PDCP, PROTOCOL_CTXT_FMT" PDCP REMOVE FAILED default DRB\n", PROTOCOL_CTXT_ARGS(ctxt_pP)); + } + } else { + key_defaultDRB = HASH_TABLE_OK; // do not trigger any error handling if this is not a default DRB + } +#endif } } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 52322b1348..5f9e3f397a 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -279,6 +279,7 @@ public_pdcp(void rrc_pdcp_config_req ( * \param[in] kRRCenc RRC encryption key * \param[in] kRRCint RRC integrity key * \param[in] kUPenc User-Plane encryption key +* \param[in] defaultDRB Default DRB ID * \return A status about the processing, OK or error code. */ public_pdcp( @@ -294,6 +295,7 @@ public_pdcp( #ifdef Rel10 ,PMCH_InfoList_r9_t *pmch_InfoList_r9 #endif + ,rb_id_t *const defaultDRB // 2016-05-28 wilson : remember the default DRB )); /*! \fn boolean_t pdcp_config_req_asn1 (const protocol_ctxt_t* const ctxt_pP, srb_flag_t srb_flagP, uint32_t action, rb_id_t rb_id, uint8_t rb_sn, uint8_t rb_report, uint16_t header_compression_profile, uint8_t security_mode) @@ -467,12 +469,28 @@ protected_pdcp(unsigned char pdcp_input_sdu_buffer[MAX_IP_PACKET_SIZE]; protected_pdcp(sdu_size_t pdcp_input_index_header;) protected_pdcp(sdu_size_t pdcp_input_sdu_size_read;) protected_pdcp(sdu_size_t pdcp_input_sdu_remaining_size_to_read;) + #define PDCP_COLL_KEY_VALUE(mODULE_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \ ((hash_key_t)mODULE_iD | \ (((hash_key_t)(rNTI)) << 8) | \ (((hash_key_t)(iS_eNB)) << 24) | \ (((hash_key_t)(rB_iD)) << 25) | \ - (((hash_key_t)(iS_sRB)) << 33)) + (((hash_key_t)(iS_sRB)) << 33) | \ + (((hash_key_t)(0x55)) << 34)) + +#ifndef ASTRI_FIX // 2016-05-28 wilson : for remeber the default DRB + +// hash key to the same PDCP as indexed by PDCP_COLL_KEY_VALUE(... rB_iD, iS_sRB=0) where rB_iD +// is the default DRB ID. The hidden code 0x55 indicates the key is indexed by (rB_iD,is_sRB) +// whereas the hidden code 0xaa indicates the key is for default DRB only +#define PDCP_COLL_KEY_DEFAULT_DRB_VALUE(mODULE_iD, rNTI, iS_eNB) \ + ((hash_key_t)mODULE_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(0xff)) << 25) | \ + (((hash_key_t)(0x00)) << 33) | \ + (((hash_key_t)(0xaa)) << 34)) +#endif // service id max val is maxServiceCount = 16 (asn1_constants.h) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 390ad5a48d..8dea985345 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -75,6 +75,7 @@ extern int otg_enabled; #ifdef PDCP_USE_NETLINK #include #include +#include "NETWORK_DRIVER/UE_IP/constant.h" extern char nl_rx_buf[NL_MAX_PAYLOAD]; extern struct sockaddr_nl nas_src_addr, nas_dest_addr; @@ -194,7 +195,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) ret = sendmsg(nas_sock_fd,&nas_msg_tx,0); if (ret<0) { - LOG_D(PDCP, "[PDCP_FIFOS] sendmsg returns %d (errno: %d)\n", ret, errno); + LOG_E(PDCP, "[PDCP_FIFOS] sendmsg returns %d (errno: %d)\n", ret, errno); MSC_LOG_TX_MESSAGE_FAILED( (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, @@ -499,6 +500,10 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ctxt.frame = ctxt_cpy.frame; ctxt.enb_flag = ctxt_cpy.enb_flag; +#ifdef PDCP_DEBUG + LOG_I(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d\n", pdcp_read_header_g.rb_id); +#endif + if (ctxt_cpy.enb_flag) { ctxt.module_id = 0; rab_id = pdcp_read_header_g.rb_id % maxDRB; @@ -594,11 +599,26 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) } } else { // enb_flag if (rab_id != 0) { - rab_id = rab_id % maxDRB; - key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); +#ifndef ASTRI_FIX // 2016-05-30 wilson : fix hard-code default DRB ID + if (rab_id == UE_IP_DEFAULT_RAB_ID) { + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + } else +#endif + { + rab_id = rab_id % maxDRB; + LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + } if (h_rc == HASH_TABLE_OK) { +#ifndef ASTRI_FIX // 2016-05-30 wilson : fix default DRB-ID to be configurable + rab_id = pdcp_p->rb_id; +#endif #ifdef PDCP_DEBUG LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n", ctxt.frame, diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index fd8279579d..8d45ac9582 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -120,7 +120,8 @@ config_req_rlc_am ( const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, rlc_am_info_t * const config_am_pP, - const rb_id_t rb_idP + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC ) { rlc_union_t *rlc_union_p = NULL; @@ -142,7 +143,7 @@ config_req_rlc_am ( config_am_pP->t_reordering, config_am_pP->t_status_prohibit); rlc_am_init(ctxt_pP, l_rlc_p); - rlc_am_set_debug_infos(ctxt_pP, l_rlc_p, srb_flagP, rb_idP); + rlc_am_set_debug_infos(ctxt_pP, l_rlc_p, srb_flagP, rb_idP, chan_idP); rlc_am_configure(ctxt_pP, l_rlc_p, config_am_pP->max_retx_threshold, config_am_pP->poll_pdu, @@ -167,7 +168,8 @@ void config_req_rlc_am_asn1 ( const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const struct RLC_Config__am * const config_am_pP, - const rb_id_t rb_idP) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP) // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC { rlc_union_t *rlc_union_p = NULL; rlc_am_entity_t *l_rlc_p = NULL; @@ -208,7 +210,7 @@ void config_req_rlc_am_asn1 ( t_StatusProhibit_tab[config_am_pP->dl_AM_RLC.t_StatusProhibit]); rlc_am_init(ctxt_pP, l_rlc_p); - rlc_am_set_debug_infos(ctxt_pP, l_rlc_p, srb_flagP, rb_idP); + rlc_am_set_debug_infos(ctxt_pP, l_rlc_p, srb_flagP, rb_idP, chan_idP); rlc_am_configure(ctxt_pP, l_rlc_p, maxRetxThreshold_tab[config_am_pP->ul_AM_RLC.maxRetxThreshold], pollPDU_tab[config_am_pP->ul_AM_RLC.pollPDU], diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h index 70cbb3b12e..df9f8d6c88 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h @@ -135,31 +135,35 @@ public_rlc_am(void rlc_am_release ( * @{ */ -/*! \fn void config_req_rlc_am (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, rlc_am_info_t * config_amP, rb_id_t rb_idP) +/*! \fn void config_req_rlc_am (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, rlc_am_info_t * config_amP, rb_id_t rb_idP, logical_chan_id_t chan_idP) * \brief Configure the UL and DL parameters of the RLC AM * \param[in] ctxt_pP Running context. * \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). * \param[in] config_amP Configuration parameters for RLC AM instance. * \param[in] rb_idP Radio bearer identifier. +* \param[in] chan_idP Transport channel identifier. */ public_rlc_am(void config_req_rlc_am ( const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const rlc_am_info_t * const config_amP, - const rb_id_t rb_idP);) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC -/*! \fn void config_req_rlc_am_asn1 (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, struct RLC_Config__am * config_amP, rb_id_t rb_idP) +/*! \fn void config_req_rlc_am_asn1 (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, logical_chan_id_t chan_idP) * \brief Configure the UL and DL parameters of the RLC AM with the asn1c autogenerated pameters structs * \param[in] ctxt_pP Running context. * \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). * \param[in] config_amP Configuration parameters for RLC AM instance. * \param[in] rb_idP Radio bearer identifier. +* \param[in] chan_idP Transport channel identifier. */ public_rlc_am(void config_req_rlc_am_asn1 ( const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const struct RLC_Config__am * const config_amP, - const rb_id_t rb_idP);) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC /** @} */ diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c index 81645f06fe..5dcdbc68d1 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c @@ -253,10 +253,13 @@ rlc_am_set_debug_infos( const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *const rlc_pP, const srb_flag_t srb_flagP, - const rb_id_t rb_idP) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP) // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC) { - rlc_pP->rb_id = rb_idP; +#ifndef ASTRI_FIX // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC) + rlc_pP->channel_id = chan_idP; +#endif if (srb_flagP) { rlc_pP->is_data_plane = 0; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h index ed2f7f2936..f3e38b6bd2 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h @@ -112,13 +112,15 @@ public_rlc_am_init( void rlc_am_configure(const protocol_ctxt_t* const ctxtP, const uint32_t t_reorderingP, const uint32_t t_status_prohibitP);) + /*! \fn void rlc_am_set_debug_infos(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP) * \brief Set informations that will be displayed in traces, helping the debug process. * \param[in] ctxtP Running context. * \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). * \param[in] rb_idP Radio bearer identifier. +* \param[in] chan_idP Transport channel identifier. */ -public_rlc_am_init( void rlc_am_set_debug_infos(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP);) +public_rlc_am_init( void rlc_am_set_debug_infos(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, const logical_chan_id_t chan_idP /*2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC)*/);) /** @} */ #endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c index 13f96e1f3f..719ba2c241 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c @@ -705,8 +705,8 @@ void rlc_am_v9_3_0_test_tx_rx() rlc_am_init(&g_am_tx, g_frame); rlc_am_init(&g_am_rx, g_frame); - rlc_am_set_debug_infos(&g_am_tx, g_frame, 0, 0, 0, 1); - rlc_am_set_debug_infos(&g_am_rx, g_frame, 1, 1, 1, 1); + rlc_am_set_debug_infos(&g_am_tx, g_frame, 0, 0, 0, 1, 1 /* LC-id = DRB-id */); + rlc_am_set_debug_infos(&g_am_rx, g_frame, 1, 1, 1, 1, 1 /* LC-id = DRB-id */); rlc_am_configure(&g_am_tx, g_frame, max_retx_threshold, poll_pdu, poll_byte, t_poll_retransmit, t_reordering, t_status_prohibit); rlc_am_configure(&g_am_rx, g_frame, max_retx_threshold, poll_pdu, poll_byte, t_poll_retransmit, t_reordering, t_status_prohibit); diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c index 6b1b487286..533730ce68 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c @@ -36,7 +36,8 @@ void config_req_rlc_tm ( const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const rlc_tm_info_t * const config_tmP, - const rb_id_t rb_idP + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP ) { rlc_union_t *rlc_union_p = NULL; @@ -55,7 +56,11 @@ void config_req_rlc_tm ( rlc_tm_init(ctxt_pP, rlc_p); rlc_p->protocol_state = RLC_DATA_TRANSFER_READY_STATE; - rlc_tm_set_debug_infos(ctxt_pP, rlc_p, rb_idP, srb_flagP); +#ifdef ASTRI_FIX + rlc_tm_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP); // 2016-05-27 wilson : fix incorrect argument ordering! +#else + rlc_tm_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP, chan_idP); // 2016-05-27 wilson : fix DRB-id <-> LC-id mapping +#endif rlc_tm_configure(ctxt_pP, rlc_p, config_tmP->is_uplink_downlink); } else { LOG_E(RLC, PROTOCOL_RLC_TM_CTXT_FMT" CONFIG_REQ RB %u RLC NOT FOUND\n", @@ -151,9 +156,11 @@ void rlc_tm_set_debug_infos( const protocol_ctxt_t* const ctxt_pP, rlc_tm_entity_t * const rlcP, const srb_flag_t srb_flagP, - const rb_id_t rb_idP) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP) // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping { - rlcP->rb_id = rb_idP; + rlcP->rb_id = rb_idP; + rlcP->channel_id = chan_idP; if (srb_flagP) { rlcP->is_data_plane = 0; diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h index 48322c98b8..ecd23a2c2f 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h @@ -80,13 +80,14 @@ typedef volatile struct rlc_tm_info_s { * \param[in] srb_flagP Flag to indicate SRB (1) or DRB (0) * \param[in] config_tmP Configuration parameters for RLC TM instance. * \param[in] rb_idP Radio bearer identifier. -* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). +* \param[in] chan_idP Transport channel identifier. */ public_rlc_tm_init( void config_req_rlc_tm ( const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const rlc_tm_info_t * const config_tmP, - const rb_id_t rb_idP);) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping /*! \fn void rlc_tm_init (const protocol_ctxt_t* const ctxt_pP, rlc_tm_entity_t * const rlcP) * \brief Initialize a RLC TM protocol instance, initialize all variables, lists, allocate buffers for making this instance ready to be configured with protocol configuration parameters. After this initialization the RLC TM protocol instance will be in RLC_NULL_STATE state. @@ -127,11 +128,14 @@ protected_rlc_tm_init(void rlc_tm_configure( * \param[in] rlcP RLC TM protocol instance pointer. * \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). * \param[in] rb_idP Radio bearer identifier. +* \param[in] chan_idP Transport channel identifier */ protected_rlc_tm_init(void rlc_tm_set_debug_infos( const protocol_ctxt_t* const ctxt_pP, rlc_tm_entity_t * const rlcP, const srb_flag_t srb_flagP, - const rb_id_t rb_idP);) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP);) /*2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC)*/ + /** @} */ # endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c index a91e384a55..990399c940 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c @@ -47,7 +47,8 @@ void config_req_rlc_um ( const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const rlc_um_info_t * const config_um_pP, - const rb_id_t rb_idP) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP) { rlc_union_t *rlc_union_p = NULL; rlc_um_entity_t *rlc_p = NULL; @@ -68,7 +69,7 @@ void config_req_rlc_um ( rlc_um_init(ctxt_pP, rlc_p); if (rlc_um_fsm_notify_event (ctxt_pP, rlc_p, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { - rlc_um_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP); + rlc_um_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP, chan_idP); rlc_um_configure( ctxt_pP, rlc_p, @@ -94,7 +95,8 @@ void config_req_rlc_um_asn1 ( const mbms_service_id_t mbms_service_idP, const UL_UM_RLC_t * const ul_rlc_pP, const DL_UM_RLC_t * const dl_rlc_pP, - const rb_id_t rb_idP) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP) { uint32_t ul_sn_FieldLength = 0; uint32_t dl_sn_FieldLength = 0; @@ -142,7 +144,7 @@ void config_req_rlc_um_asn1 ( if (rlc_um_fsm_notify_event (ctxt_pP, rlc_p, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { - rlc_um_set_debug_infos(ctxt_pP,rlc_p, srb_flagP, rb_idP); + rlc_um_set_debug_infos(ctxt_pP,rlc_p, srb_flagP, rb_idP, chan_idP); if (ul_rlc_pP != NULL) { switch (ul_rlc_pP->sn_FieldLength) { @@ -423,14 +425,16 @@ void rlc_um_configure( void rlc_um_set_debug_infos( const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, - const srb_flag_t srb_flagP, - const rb_id_t rb_idP) + const srb_flag_t srb_flagP, + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping { LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [SET DEBUG INFOS] rb_id %d srb_flag %d\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), rb_idP, srb_flagP); - rlc_pP->rb_id = rb_idP; + rlc_pP->rb_id = rb_idP; + rlc_pP->channel_id = chan_idP; // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping if (srb_flagP) { rlc_pP->is_data_plane = 0; diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h index b9a5166ed2..18dd656024 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h @@ -84,12 +84,14 @@ typedef volatile struct { * \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). * \param[in] config_umP Configuration parameters for RLC UM instance. * \param[in] rb_idP Radio bearer identifier. +* \param[in] chan_idP Transport channel identifier. */ public_rlc_um_control_primitives( void config_req_rlc_um ( const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const rlc_um_info_t * const config_umP, - const rb_id_t rb_idP);) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping /*! \fn void config_req_rlc_um_asn1 ( * const protocol_ctxt_t* const ctxt_pP, @@ -109,6 +111,7 @@ public_rlc_um_control_primitives( void config_req_rlc_um ( * \param[in] ul_rlc_pP Configuration parameters for RLC UM UL instance. * \param[in] dl_rlc_pP Configuration parameters for RLC UM DL instance. * \param[in] rb_idP Radio bearer identifier. +* \param[in] chan_idP Transport channel identifier. */ public_rlc_um_control_primitives( void config_req_rlc_um_asn1 ( const protocol_ctxt_t* const ctxt_pP, @@ -118,7 +121,8 @@ public_rlc_um_control_primitives( void config_req_rlc_um_asn1 ( const mbms_service_id_t mbms_service_idP, const UL_UM_RLC_t * const ul_rlc_pP, const DL_UM_RLC_t * const dl_rlc_pP, - const rb_id_t rb_idP);) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping /*! \fn void rlc_um_init (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP) * \brief Initialize a RLC UM protocol instance, initialize all variables, lists, allocate buffers for making this instance ready to be configured with protocol configuration parameters. After this initialization the RLC UM protocol instance will be in RLC_NULL_STATE state. @@ -176,13 +180,15 @@ protected_rlc_um_control_primitives(void rlc_um_configure( * \brief Set debug informations for a RLC UM protocol instance, these informations are only for trace purpose. * \param[in] ctxtP Running context. * \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] rb_idP Radio bearer identifier. * \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). +* \param[in] rb_idP Radio bearer identifier. +* \param[in] chan_idP Transport channel identifier. */ protected_rlc_um_control_primitives(void rlc_um_set_debug_infos( const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const srb_flag_t srb_flagP, - const rb_id_t rb_idP);) + const rb_id_t rb_idP, + const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping /** @} */ # endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c index 04afcff0ff..ce613be23e 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c @@ -195,8 +195,8 @@ void rlc_um_v9_3_0_test_windows_10() rlc_um_init(&um1); rlc_um_init(&um2); - rlc_um_set_debug_infos(&um1, g_frame, 0, 0, 0, 1); - rlc_um_set_debug_infos(&um2, g_frame, 1, 1, 1, 1); + rlc_um_set_debug_infos(&um1, g_frame, 0, 0, 0, 1, 1 /*LC-id = RAB-id*/); + rlc_um_set_debug_infos(&um2, g_frame, 1, 1, 1, 1, 1 /*LC-id = RAB-id*/); rlc_um_configure(&um1, g_frame, timer_reordering, sn_field_length, sn_field_length, is_mXch); rlc_um_configure(&um2, g_frame, timer_reordering, sn_field_length, sn_field_length, is_mXch); @@ -249,8 +249,8 @@ void rlc_um_v9_3_0_test_windows_5() rlc_um_init(&um1); rlc_um_init(&um2); - rlc_um_set_debug_infos(&um1, g_frame, 0, 0, 0, 1); - rlc_um_set_debug_infos(&um2, g_frame, 1, 1, 1, 1); + rlc_um_set_debug_infos(&um1, g_frame, 0, 0, 0, 1, 1 /* LC-id = DRB-id */); + rlc_um_set_debug_infos(&um2, g_frame, 1, 1, 1, 1, 1 /* LC-id = DRB-id */); rlc_um_configure(&um1, g_frame, timer_reordering, sn_field_length, sn_field_length, is_mXch); rlc_um_configure(&um2, g_frame, timer_reordering, sn_field_length, sn_field_length, is_mXch); @@ -621,8 +621,8 @@ void rlc_um_v9_3_0_test_reordering(uint32_t sn_field_lengthP) um_info.is_mXch = 0; srand (0); - config_req_rlc_um (&um_tx, 0,0,0, &um_info, 0, SIGNALLING_RADIO_BEARER); - config_req_rlc_um (&um_rx, 0,1,1, &um_info, 1, SIGNALLING_RADIO_BEARER); + config_req_rlc_um (&um_tx, 0,0,0, &um_info, 0, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); + config_req_rlc_um (&um_rx, 0,1,1, &um_info, 1, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); rlc_um_display_rx_window(&um_tx); @@ -743,8 +743,8 @@ void rlc_um_v9_3_0_test_tx_rx_10(void) um_info.is_mXch = 0; srand (0); - config_req_rlc_um (&um_tx, 0,0,0, &um_info, 0, SIGNALLING_RADIO_BEARER); - config_req_rlc_um (&um_rx, 0,1,1, &um_info, 1, SIGNALLING_RADIO_BEARER); + config_req_rlc_um (&um_tx, 0,0,0, &um_info, 0, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); + config_req_rlc_um (&um_rx, 0,1,1, &um_info, 1, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); rlc_um_display_rx_window(&um_tx); @@ -1072,8 +1072,8 @@ void rlc_um_v9_3_0_test_tx_rx_5(void) um_info.is_mXch = 0; srand (0); - config_req_rlc_um (&um_tx, 0,0,0, &um_info, 0, SIGNALLING_RADIO_BEARER); - config_req_rlc_um (&um_rx, 0,1,1, &um_info, 1, SIGNALLING_RADIO_BEARER); + config_req_rlc_um (&um_tx, 0,0,0, &um_info, 0, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); + config_req_rlc_um (&um_rx, 0,1,1, &um_info, 1, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); rlc_um_display_rx_window(&um_tx); diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index 72fde0b746..525e75a4d9 100755 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -269,7 +269,18 @@ public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_eNB[NUMBER_OF_eNB_MAX][NB_RB_ (((hash_key_t)(rNTI)) << 8) | \ (((hash_key_t)(iS_eNB)) << 24) | \ (((hash_key_t)(rB_iD)) << 25) | \ - (((hash_key_t)(iS_sRB)) << 33)) + (((hash_key_t)(iS_sRB)) << 33) | \ + (((hash_key_t)(0x05)) << 34)) + +// index to the same RLC entity as RLC_COLL_KEY_VALUE(), but using LC_id instead +// the hidden last key indicates if this is a hash-key with RB_id (0x05) or LC_id (0x0a) +#define RLC_COLL_KEY_LCID_VALUE(eNB_iD, rNTI, iS_eNB, lC_iD, iS_sRB) \ + ((hash_key_t)eNB_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(lC_iD)) << 25) | \ + (((hash_key_t)(iS_sRB)) << 33) | \ + (((hash_key_t)(0x0a)) << 34)) // service id max val is maxServiceCount = 16 (asn1_constants.h) diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index 3bde40888f..2f347cd227 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -136,7 +136,7 @@ tbs_size_t mac_rlc_data_req( { //----------------------------------------------------------------------------- struct mac_data_req data_request; - rb_id_t rb_id = 0; + // rb_id_t rb_id = 0; // 2016-05-27 wilson : not needed after DRB-id <-> LC-id mapping fix rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_mbms_id_t *mbms_id_p = NULL; rlc_union_t *rlc_union_p = NULL; @@ -179,6 +179,7 @@ tbs_size_t mac_rlc_data_req( return (tbs_size_t)0; } } else { +#ifdef ASTRI_FIX // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping if (channel_idP > 2) { rb_id = channel_idP - 2; } else { @@ -186,6 +187,9 @@ tbs_size_t mac_rlc_data_req( } key = RLC_COLL_KEY_VALUE(module_idP, rntiP, enb_flagP, rb_id, srb_flag); +#else + key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); +#endif } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -194,7 +198,7 @@ tbs_size_t mac_rlc_data_req( rlc_mode = rlc_union_p->mode; } else { rlc_mode = RLC_MODE_NONE; - AssertFatal (0 , "RLC not configured rb id %u lcid %u RNTI %x!\n", rb_id, channel_idP, rntiP); + AssertFatal (0 , "RLC not configured lcid %u RNTI %x!\n", channel_idP, rntiP); } switch (rlc_mode) { @@ -244,7 +248,7 @@ void mac_rlc_data_ind ( crc_t *crcs_pP) { //----------------------------------------------------------------------------- - rb_id_t rb_id = 0; + // rb_id_t rb_id = 0; // 2016-05-27 wilson : not needed after DRB-id <-> LC-id mapping fix rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_mbms_id_t *mbms_id_p = NULL; rlc_union_t *rlc_union_p = NULL; @@ -294,6 +298,7 @@ void mac_rlc_data_ind ( return; } } else { +#ifdef ASTRI_FIX // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping if (channel_idP > 2) { rb_id = channel_idP - 2; } else { @@ -301,6 +306,9 @@ void mac_rlc_data_ind ( } key = RLC_COLL_KEY_VALUE(module_idP, rntiP, enb_flagP, rb_id, srb_flag); +#else + key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); +#endif } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -350,7 +358,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind( mac_rlc_status_resp_t mac_rlc_status_resp; struct mac_status_ind tx_status; struct mac_status_resp status_resp; - rb_id_t rb_id = 0; + // rb_id_t rb_id = 0; // 2016-05-27 wilson : not needed after DRB-id <-> LC-id mapping fix rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_mbms_id_t *mbms_id_p = NULL; rlc_union_t *rlc_union_p = NULL; @@ -399,6 +407,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind( key = RLC_COLL_KEY_MBMS_VALUE(module_idP, rntiP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); } else { +#ifdef ASTRI_FIX // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping if (channel_idP > 2) { rb_id = channel_idP - 2; } else { @@ -406,6 +415,9 @@ mac_rlc_status_resp_t mac_rlc_status_ind( } key = RLC_COLL_KEY_VALUE(module_idP, rntiP, enb_flagP, rb_id, srb_flag); +#else + key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); +#endif } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index 9919cc0f70..aba2ab411f 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -104,7 +104,11 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP if (srb2add_listP != NULL) { for (cnt=0; cntlist.count; cnt++) { rb_id = srb2add_listP->list.array[cnt]->srb_Identity; +#if 0 lc_id = rb_id + 2; +#else // 2016-05-26 wilson : fixing the LC-id<->SRB-id mapping for SRB + lc_id = rb_id; +#endif LOG_D(RLC, "Adding SRB %d, rb_id %d\n",srb2add_listP->list.array[cnt]->srb_Identity,rb_id); srb_toaddmod_p = srb2add_listP->list.array[cnt]; @@ -125,7 +129,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP ctxt_pP, SRB_FLAG_YES, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.am, - rb_id); + rb_id, lc_id); } else { LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", PROTOCOL_CTXT_ARGS(ctxt_pP), @@ -144,7 +148,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.ul_UM_RLC, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.dl_UM_RLC, - rb_id); + rb_id, lc_id); } else { LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", PROTOCOL_CTXT_ARGS(ctxt_pP), @@ -163,7 +167,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_UL.ul_UM_RLC, NULL, - rb_id); + rb_id, lc_id); } else { LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", PROTOCOL_CTXT_ARGS(ctxt_pP), @@ -182,7 +186,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, NULL, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_DL.dl_UM_RLC, - rb_id); + rb_id, lc_id); } else { LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", PROTOCOL_CTXT_ARGS(ctxt_pP), @@ -211,7 +215,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, NULL, // TO DO DEFAULT CONFIG NULL, // TO DO DEFAULT CONFIG - rb_id); + rb_id, lc_id); } else { LOG_D(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", PROTOCOL_CTXT_ARGS(ctxt_pP), @@ -232,7 +236,22 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP drb_toaddmod_p = drb2add_listP->list.array[cnt]; drb_id = drb_toaddmod_p->drb_Identity; +#if 0 lc_id = drb_id + 2; +#else // 2016-05-26 wilson : fixing the LC-id <-> DRB-id mapping + if (drb_toaddmod_p->logicalChannelIdentity) { + lc_id = *drb_toaddmod_p->logicalChannelIdentity; + } else { + LOG_E(RLC, PROTOCOL_CTXT_FMT" logicalChannelIdentity is missing from drb-ToAddMod information element!\n", PROTOCOL_CTXT_ARGS(ctxt_pP)); + continue; + } + + if (lc_id == 1 || lc_id == 2) { + LOG_E(RLC, PROTOCOL_CTXT_FMT" logicalChannelIdentity = %d is invalid in RRC message when adding DRB!\n", PROTOCOL_CTXT_ARGS(ctxt_pP), lc_id); + continue; + } + +#endif LOG_I(RLC, "Adding DRB %d, lc_id %d\n",drb_id,lc_id); @@ -249,7 +268,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP ctxt_pP, SRB_FLAG_NO, &drb_toaddmod_p->rlc_Config->choice.am, - drb_id); + drb_id, lc_id); } break; @@ -264,7 +283,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, &drb_toaddmod_p->rlc_Config->choice.um_Bi_Directional.ul_UM_RLC, &drb_toaddmod_p->rlc_Config->choice.um_Bi_Directional.dl_UM_RLC, - drb_id); + drb_id, lc_id); } break; @@ -279,7 +298,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, &drb_toaddmod_p->rlc_Config->choice.um_Uni_Directional_UL.ul_UM_RLC, NULL, - drb_id); + drb_id, lc_id); } break; @@ -294,7 +313,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, NULL, &drb_toaddmod_p->rlc_Config->choice.um_Uni_Directional_DL.dl_UM_RLC, - drb_id); + drb_id, lc_id); } break; @@ -378,7 +397,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP mbms_service_id, NULL, &dl_um_rlc, - rb_id); + rb_id, lc_id); } } } @@ -459,6 +478,10 @@ rlc_op_status_t rrc_rlc_remove_rlc ( logical_chan_id_t lcid = 0; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; +#ifndef ASTRI_FIX // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping + hash_key_t key_lcid = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_lcid_rc; +#endif rlc_union_t *rlc_union_p = NULL; #ifdef Rel10 rlc_mbms_id_t *mbms_id_p = NULL; @@ -502,23 +525,51 @@ rlc_op_status_t rrc_rlc_remove_rlc ( h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); if (h_rc == HASH_TABLE_OK) { - h_rc = hashtable_remove(rlc_coll_p, key); - LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u] RELEASED %s\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - (srb_flagP) ? "SRB" : "DRB"); - } else if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) { - LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u] RELEASE : RLC NOT FOUND %s\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - (srb_flagP) ? "SRB" : "DRB"); +#ifndef ASTRI_FIX // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping + // also remove the hash-key created by LC-id + switch (rlc_union_p->mode) { + case RLC_MODE_AM: + lcid = rlc_union_p->rlc.am.channel_id; + break; + case RLC_MODE_UM: + lcid = rlc_union_p->rlc.um.channel_id; + break; + case RLC_MODE_TM: + lcid = rlc_union_p->rlc.tm.channel_id; + break; + default: + LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %u] RLC mode is unknown!\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), + (srb_flagP) ? "SRB" : "DRB", + rb_idP); + } + key_lcid = RLC_COLL_KEY_LCID_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, lcid, srb_flagP); + h_lcid_rc = hashtable_get(rlc_coll_p, key_lcid, (void**)&rlc_union_p); } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %u] RELEASE : INTERNAL ERROR %s\n", + h_lcid_rc = HASH_TABLE_KEY_NOT_EXISTS; + } + + if ((h_rc == HASH_TABLE_OK) && (h_lcid_rc == HASH_TABLE_OK)) { + h_lcid_rc = hashtable_remove(rlc_coll_p, key_lcid); +#endif + h_rc = hashtable_remove(rlc_coll_p, key); + LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u LCID %d] RELEASED %s\n", PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", - rb_idP, + rb_idP, lcid, + (srb_flagP) ? "SRB" : "DRB"); + } else if ((h_rc == HASH_TABLE_KEY_NOT_EXISTS) || (h_lcid_rc == HASH_TABLE_KEY_NOT_EXISTS)) { + LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u LCID %d] RELEASE : RLC NOT FOUND %s, by RB-ID=%d, by LC-ID=%d\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), + (srb_flagP) ? "SRB" : "DRB", + rb_idP, lcid, + (srb_flagP) ? "SRB" : "DRB", + h_rc, h_lcid_rc); + } else { + LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %u LCID %d] RELEASE : INTERNAL ERROR %s\n", + PROTOCOL_CTXT_ARGS(ctxt_pP), + (srb_flagP) ? "SRB" : "DRB", + rb_idP, lcid, (srb_flagP) ? "SRB" : "DRB"); } @@ -536,6 +587,10 @@ rlc_union_t* rrc_rlc_add_rlc ( //----------------------------------------------------------------------------- hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; +#if 1 // 2016-05-26 wilson hash_key to the same RLC entity but indexed by LC_id instead of RB_id + hash_key_t key_lcid = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_lcid_rc; +#endif rlc_union_t *rlc_union_p = NULL; #ifdef Rel10 rlc_mbms_id_t *mbms_id_p = NULL; @@ -576,6 +631,9 @@ rlc_union_t* rrc_rlc_add_rlc ( #endif { key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); +#ifndef ASTRI_FIX // 2016-05-26 wilson : fix DRB-id <-> LC-id mapping + key_lcid = RLC_COLL_KEY_LCID_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, chan_idP, srb_flagP); +#endif } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -591,8 +649,11 @@ rlc_union_t* rrc_rlc_add_rlc ( } else if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) { rlc_union_p = calloc(1, sizeof(rlc_union_t)); h_rc = hashtable_insert(rlc_coll_p, key, rlc_union_p); +#ifndef ASTRI_FIX // 2016-05-26 wilson + h_lcid_rc = hashtable_insert(rlc_coll_p, key_lcid, rlc_union_p); +#endif - if (h_rc == HASH_TABLE_OK) { + if ((h_rc == HASH_TABLE_OK) && (h_lcid_rc == HASH_TABLE_OK)) { #ifdef Rel10 if (MBMS_flagP == TRUE) { @@ -613,11 +674,12 @@ rlc_union_t* rrc_rlc_add_rlc ( rlc_union_p->mode = rlc_modeP; return rlc_union_p; } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %u] rrc_rlc_add_rlc FAILED %s\n", + LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %u] rrc_rlc_add_rlc FAILED %s (add by RB_id=%d; add by LC_id=%d)\n", PROTOCOL_CTXT_ARGS(ctxt_pP), (srb_flagP) ? "SRB" : "DRB", rb_idP, - (srb_flagP) ? "SRB" : "DRB"); + (srb_flagP) ? "SRB" : "DRB", + h_rc, h_lcid_rc); free(rlc_union_p); rlc_union_p = NULL; return NULL; @@ -674,7 +736,7 @@ rlc_op_status_t rrc_rlc_config_req ( ctxt_pP, srb_flagP, &rlc_infoP.rlc.rlc_am_info, - rb_idP); + rb_idP, rb_idP); break; case RLC_MODE_UM: @@ -685,7 +747,7 @@ rlc_op_status_t rrc_rlc_config_req ( ctxt_pP, srb_flagP, &rlc_infoP.rlc.rlc_um_info, - rb_idP); + rb_idP, rb_idP); break; case RLC_MODE_TM: @@ -696,7 +758,7 @@ rlc_op_status_t rrc_rlc_config_req ( ctxt_pP, srb_flagP, &rlc_infoP.rlc.rlc_tm_info, - rb_idP); + rb_idP, rb_idP); break; default: diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index e546b52f8e..1a39020a84 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -506,6 +506,9 @@ typedef struct UE_RRC_INST_s { struct SRB_ToAddMod *SRB1_config[NB_CNX_UE]; struct SRB_ToAddMod *SRB2_config[NB_CNX_UE]; struct DRB_ToAddMod *DRB_config[NB_CNX_UE][8]; +#ifndef ASTRI_FIX + rb_id_t *defaultDRB; // 2015-05-27 wilson : remember the default DRB ID +#endif MeasObjectToAddMod_t *MeasObj[NB_CNX_UE][MAX_MEAS_OBJ]; struct ReportConfigToAddMod *ReportConfig[NB_CNX_UE][MAX_MEAS_CONFIG]; struct QuantityConfig *QuantityConfig[NB_CNX_UE]; diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index 01c1ee6ca9..cd1389fbc0 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -1060,7 +1060,7 @@ rrc_ue_process_radioResourceConfigDedicated( #ifdef Rel10 ,(PMCH_InfoList_r9_t *)NULL #endif - ); + ,NULL); // Refresh SRBs rrc_rlc_config_asn1_req(ctxt_pP, @@ -1200,6 +1200,18 @@ rrc_ue_process_radioResourceConfigDedicated( // Establish DRBs if present if (radioResourceConfigDedicated->drb_ToAddModList) { + +#ifndef ASTRI_FIX // 2016-05-28 wilson : remember the default DRB ID + if ( (UE_rrc_inst[ctxt_pP->module_id].defaultDRB == NULL) && + (radioResourceConfigDedicated->drb_ToAddModList->list.count >= 1) ) { + // configure the first DRB ID as the default DRB ID + UE_rrc_inst[ctxt_pP->module_id].defaultDRB = malloc(sizeof(rb_id_t)); + *UE_rrc_inst[ctxt_pP->module_id].defaultDRB = radioResourceConfigDedicated->drb_ToAddModList->list.array[0]->drb_Identity; + LOG_I(RRC,"[UE %d] default DRB = %d\n",ctxt_pP->module_id, *UE_rrc_inst[ctxt_pP->module_id].defaultDRB); + } + +#endif + uint8_t *kUPenc = NULL; #if defined(ENABLE_SECURITY) @@ -1231,7 +1243,7 @@ rrc_ue_process_radioResourceConfigDedicated( #ifdef Rel10 ,(PMCH_InfoList_r9_t *)NULL #endif - ); + , UE_rrc_inst[ctxt_pP->module_id].defaultDRB); // Refresh DRBs rrc_rlc_config_asn1_req(ctxt_pP, @@ -1725,7 +1737,7 @@ rrc_ue_process_mobilityControlInfo( #ifdef Rel10 ,NULL #endif - ); + ,NULL); rrc_rlc_config_asn1_req(NB_eNB_INST+ue_mod_idP, frameP,0,eNB_index, NULL,// SRB_ToAddModList @@ -1734,7 +1746,7 @@ rrc_ue_process_mobilityControlInfo( #ifdef Rel10 ,NULL #endif - ); + ,NULL); */ @@ -3906,7 +3918,7 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i #ifdef Rel10 ,&(UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9) #endif - ); + ,NULL); rrc_rlc_config_asn1_req(&ctxt, NULL,// SRB_ToAddModList diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 7f36a9b36c..428f5196f6 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -481,7 +481,7 @@ static void init_MBMS( # ifdef Rel10 , &(eNB_rrc_inst[enb_mod_idP].carrier[CC_id].mcch_message->pmch_InfoList_r9) # endif - ); + ,NULL); rrc_rlc_config_asn1_req(&ctxt, NULL, // SRB_ToAddModList @@ -3282,7 +3282,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( #ifdef Rel10 , (PMCH_InfoList_r9_t *) NULL #endif - ); + ,NULL); rrc_rlc_config_asn1_req(&ctxt, ue_context_pP->ue_context.SRB_configList, @@ -3524,7 +3524,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( #ifdef Rel10 , (PMCH_InfoList_r9_t *) NULL #endif - ); + ,NULL); // Refresh SRBs/DRBs rrc_rlc_config_asn1_req( ctxt_pP, @@ -4336,7 +4336,7 @@ rrc_eNB_decode_ccch( # ifdef Rel10 , (PMCH_InfoList_r9_t *) NULL # endif - ); + ,NULL); rrc_rlc_config_asn1_req(ctxt_pP, ue_context_p->ue_context.SRB_configList, From 6feb848ebe204653ed565d73881ecb7ef3c0d892 Mon Sep 17 00:00:00 2001 From: "Wilson W.K. Thong" Date: Sun, 18 Sep 2016 15:35:48 +0800 Subject: [PATCH 05/60] removed all 'wilson' and 'ASTRI' words from comments Conflicts: openair2/LAYER2/PDCP_v10.1.0/pdcp.c openair2/LAYER2/RLC/rlc_rrc.c --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 28 +++------------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 5 +-- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 7 +--- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 4 +-- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h | 4 +-- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c | 4 +-- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h | 2 +- openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c | 8 ++--- openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h | 4 +-- .../RLC/UM_v9.3.0/rlc_um_control_primitives.c | 4 +-- .../RLC/UM_v9.3.0/rlc_um_control_primitives.h | 6 ++-- openair2/LAYER2/RLC/rlc_mac.c | 33 ------------------- openair2/LAYER2/RLC/rlc_rrc.c | 21 +----------- openair2/RRC/LITE/defs.h | 4 +-- openair2/RRC/LITE/rrc_UE.c | 3 -- 15 files changed, 23 insertions(+), 114 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 7f9017201a..8c7abe963c 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1065,7 +1065,7 @@ rrc_pdcp_config_asn1_req ( #ifdef Rel10 ,PMCH_InfoList_r9_t* const pmch_InfoList_r9_pP #endif - ,rb_id_t *const defaultDRB // 2016-05-28 wilson : remember the default DRB + ,rb_id_t *const defaultDRB ) //----------------------------------------------------------------------------- { @@ -1087,10 +1087,8 @@ rrc_pdcp_config_asn1_req ( hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; -#ifndef ASTRI_FIX // 2016-05-28 wilson : remember the default DRB hash_key_t key_defaultDRB = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_defaultDRB_rc; -#endif #ifdef Rel10 int i,j; MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL; @@ -1111,11 +1109,7 @@ rrc_pdcp_config_asn1_req ( srb_id = srb2add_list_pP->list.array[cnt]->srb_Identity; srb_toaddmod_p = srb2add_list_pP->list.array[cnt]; rlc_type = RLC_MODE_AM; -#if 0 - lc_id = srb_id;// + 2; -#else // 2016-05-27 wilson : fixing the LC-id <-> SRB-id mapping lc_id = srb_id; -#endif key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_YES); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); @@ -1195,9 +1189,6 @@ rrc_pdcp_config_asn1_req ( drb_toaddmod_p = drb2add_list_pP->list.array[cnt]; drb_id = drb_toaddmod_p->drb_Identity;// + drb_id_offset; -#ifdef ASTRI_FIX - lc_id = drb_id + 2; -#else // 2016-05-27 wilson : fixing the mapping between LC-id and DRB-id if (drb_toaddmod_p->logicalChannelIdentity) { lc_id = *(drb_toaddmod_p->logicalChannelIdentity); } else { @@ -1210,7 +1201,6 @@ rrc_pdcp_config_asn1_req ( LOG_E(RLC, PROTOCOL_CTXT_FMT" logicalChannelIdentity = %d is invalid in RRC message when adding DRB!\n", PROTOCOL_CTXT_ARGS(ctxt_pP), lc_id); continue; } -#endif DevCheck4(drb_id < maxDRB, drb_id, maxDRB, ctxt_pP->module_id, ctxt_pP->rnti); key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO); @@ -1227,7 +1217,7 @@ rrc_pdcp_config_asn1_req ( pdcp_p = calloc(1, sizeof(pdcp_t)); h_rc = hashtable_insert(pdcp_coll_p, key, pdcp_p); -#ifndef ASTRI_FIX + // save the first configured DRB-ID as the default DRB-ID if ((defaultDRB != NULL) && (*defaultDRB == drb_id)) { key_defaultDRB = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag); h_defaultDRB_rc = hashtable_insert(pdcp_coll_p, key_defaultDRB, pdcp_p); @@ -1241,9 +1231,7 @@ rrc_pdcp_config_asn1_req ( key_defaultDRB); free(pdcp_p); return TRUE; - } else -#endif - if (h_rc != HASH_TABLE_OK) { + } else if (h_rc != HASH_TABLE_OK) { LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD ADD key 0x%"PRIx64" FAILED\n", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), key); @@ -1337,9 +1325,6 @@ rrc_pdcp_config_asn1_req ( for (cnt=0; cntlist.count; cnt++) { pdrb_id_p = drb2release_list_pP->list.array[cnt]; drb_id = *pdrb_id_p; -#if 0 // 2016-05-27 wilson : fixing the hard-coded mapping between DRB-id <-> LC-id - lc_id = drb_id + 2; -#endif key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_NO); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); @@ -1349,10 +1334,7 @@ rrc_pdcp_config_asn1_req ( drb_id); continue; } - -#ifndef ASTRI_FIX // 2016-05-27 wilson : fixing the hard-coded mapping between DRB-id <-> LC-id lc_id = pdcp_p->lcid; -#endif action = CONFIG_ACTION_REMOVE; pdcp_config_req_asn1 ( @@ -1373,9 +1355,8 @@ rrc_pdcp_config_asn1_req ( kUPenc_pP); h_rc = hashtable_remove(pdcp_coll_p, key); -#ifndef ASTRI_FIX // 2016-05-28 wilson : remember the default DRB if ((defaultDRB != NULL) && (*defaultDRB == drb_id)) { - // this is the default DRB being removed, although this is not allowed in standard + // default DRB being removed. nevertheless this shouldn't happen as removing default DRB is not allowed in standard key_defaultDRB = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag); h_defaultDRB_rc = hashtable_get(pdcp_coll_p, key_defaultDRB, (void**)&pdcp_p); @@ -1387,7 +1368,6 @@ rrc_pdcp_config_asn1_req ( } else { key_defaultDRB = HASH_TABLE_OK; // do not trigger any error handling if this is not a default DRB } -#endif } } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 5f9e3f397a..7d162d1609 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -295,7 +295,7 @@ public_pdcp( #ifdef Rel10 ,PMCH_InfoList_r9_t *pmch_InfoList_r9 #endif - ,rb_id_t *const defaultDRB // 2016-05-28 wilson : remember the default DRB + ,rb_id_t *const defaultDRB )); /*! \fn boolean_t pdcp_config_req_asn1 (const protocol_ctxt_t* const ctxt_pP, srb_flag_t srb_flagP, uint32_t action, rb_id_t rb_id, uint8_t rb_sn, uint8_t rb_report, uint16_t header_compression_profile, uint8_t security_mode) @@ -478,8 +478,6 @@ protected_pdcp(sdu_size_t pdcp_input_sdu_remaining_size_to_read;) (((hash_key_t)(iS_sRB)) << 33) | \ (((hash_key_t)(0x55)) << 34)) -#ifndef ASTRI_FIX // 2016-05-28 wilson : for remeber the default DRB - // hash key to the same PDCP as indexed by PDCP_COLL_KEY_VALUE(... rB_iD, iS_sRB=0) where rB_iD // is the default DRB ID. The hidden code 0x55 indicates the key is indexed by (rB_iD,is_sRB) // whereas the hidden code 0xaa indicates the key is for default DRB only @@ -490,7 +488,6 @@ protected_pdcp(sdu_size_t pdcp_input_sdu_remaining_size_to_read;) (((hash_key_t)(0xff)) << 25) | \ (((hash_key_t)(0x00)) << 33) | \ (((hash_key_t)(0xaa)) << 34)) -#endif // service id max val is maxServiceCount = 16 (asn1_constants.h) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 8dea985345..1cde2010f4 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -599,15 +599,12 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) } } else { // enb_flag if (rab_id != 0) { -#ifndef ASTRI_FIX // 2016-05-30 wilson : fix hard-code default DRB ID if (rab_id == UE_IP_DEFAULT_RAB_ID) { LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", ctxt.module_id, ctxt.rnti, ctxt.enb_flag); key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - } else -#endif - { + } else { rab_id = rab_id % maxDRB; LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); @@ -616,9 +613,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) } if (h_rc == HASH_TABLE_OK) { -#ifndef ASTRI_FIX // 2016-05-30 wilson : fix default DRB-ID to be configurable rab_id = pdcp_p->rb_id; -#endif #ifdef PDCP_DEBUG LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n", ctxt.frame, diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index 8d45ac9582..ff807f711e 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -121,7 +121,7 @@ config_req_rlc_am ( const srb_flag_t srb_flagP, rlc_am_info_t * const config_am_pP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC + const logical_chan_id_t chan_idP ) { rlc_union_t *rlc_union_p = NULL; @@ -169,7 +169,7 @@ void config_req_rlc_am_asn1 ( const srb_flag_t srb_flagP, const struct RLC_Config__am * const config_am_pP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC + const logical_chan_id_t chan_idP) { rlc_union_t *rlc_union_p = NULL; rlc_am_entity_t *l_rlc_p = NULL; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h index df9f8d6c88..305326113e 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h @@ -148,7 +148,7 @@ public_rlc_am(void config_req_rlc_am ( const srb_flag_t srb_flagP, const rlc_am_info_t * const config_amP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC + const logical_chan_id_t chan_idP);) /*! \fn void config_req_rlc_am_asn1 (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, logical_chan_id_t chan_idP) * \brief Configure the UL and DL parameters of the RLC AM with the asn1c autogenerated pameters structs @@ -163,7 +163,7 @@ public_rlc_am(void config_req_rlc_am_asn1 ( const srb_flag_t srb_flagP, const struct RLC_Config__am * const config_amP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC + const logical_chan_id_t chan_idP);) /** @} */ diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c index 5dcdbc68d1..1c82c1ff4b 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c @@ -254,12 +254,10 @@ rlc_am_set_debug_infos( rlc_am_entity_t *const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC) + const logical_chan_id_t chan_idP) { rlc_pP->rb_id = rb_idP; -#ifndef ASTRI_FIX // 2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC) rlc_pP->channel_id = chan_idP; -#endif if (srb_flagP) { rlc_pP->is_data_plane = 0; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h index f3e38b6bd2..342921bcc9 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h @@ -121,6 +121,6 @@ public_rlc_am_init( void rlc_am_configure(const protocol_ctxt_t* const ctxtP, * \param[in] rb_idP Radio bearer identifier. * \param[in] chan_idP Transport channel identifier. */ -public_rlc_am_init( void rlc_am_set_debug_infos(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, const logical_chan_id_t chan_idP /*2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC)*/);) +public_rlc_am_init( void rlc_am_set_debug_infos(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, const logical_chan_id_t chan_idP);) /** @} */ #endif diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c index 533730ce68..f89aa3b454 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c @@ -56,11 +56,7 @@ void config_req_rlc_tm ( rlc_tm_init(ctxt_pP, rlc_p); rlc_p->protocol_state = RLC_DATA_TRANSFER_READY_STATE; -#ifdef ASTRI_FIX - rlc_tm_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP); // 2016-05-27 wilson : fix incorrect argument ordering! -#else - rlc_tm_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP, chan_idP); // 2016-05-27 wilson : fix DRB-id <-> LC-id mapping -#endif + rlc_tm_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP, chan_idP); rlc_tm_configure(ctxt_pP, rlc_p, config_tmP->is_uplink_downlink); } else { LOG_E(RLC, PROTOCOL_RLC_TM_CTXT_FMT" CONFIG_REQ RB %u RLC NOT FOUND\n", @@ -157,7 +153,7 @@ void rlc_tm_set_debug_infos( rlc_tm_entity_t * const rlcP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping + const logical_chan_id_t chan_idP) { rlcP->rb_id = rb_idP; rlcP->channel_id = chan_idP; diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h index ecd23a2c2f..daf9b5a643 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h @@ -87,7 +87,7 @@ public_rlc_tm_init( void config_req_rlc_tm ( const srb_flag_t srb_flagP, const rlc_tm_info_t * const config_tmP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping + const logical_chan_id_t chan_idP);) /*! \fn void rlc_tm_init (const protocol_ctxt_t* const ctxt_pP, rlc_tm_entity_t * const rlcP) * \brief Initialize a RLC TM protocol instance, initialize all variables, lists, allocate buffers for making this instance ready to be configured with protocol configuration parameters. After this initialization the RLC TM protocol instance will be in RLC_NULL_STATE state. @@ -135,7 +135,7 @@ protected_rlc_tm_init(void rlc_tm_set_debug_infos( rlc_tm_entity_t * const rlcP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP);) /*2016-05-27 wilson : added this argument for storing the DRB-id <-> LC-id mapping in RLC)*/ + const logical_chan_id_t chan_idP);) /** @} */ # endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c index 990399c940..1ecf5f882a 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c @@ -427,14 +427,14 @@ void rlc_um_set_debug_infos( rlc_um_entity_t * const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping + const logical_chan_id_t chan_idP) { LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [SET DEBUG INFOS] rb_id %d srb_flag %d\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), rb_idP, srb_flagP); rlc_pP->rb_id = rb_idP; - rlc_pP->channel_id = chan_idP; // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping + rlc_pP->channel_id = chan_idP; if (srb_flagP) { rlc_pP->is_data_plane = 0; diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h index 18dd656024..af3934f662 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h @@ -91,7 +91,7 @@ public_rlc_um_control_primitives( void config_req_rlc_um ( const srb_flag_t srb_flagP, const rlc_um_info_t * const config_umP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping + const logical_chan_id_t chan_idP);) /*! \fn void config_req_rlc_um_asn1 ( * const protocol_ctxt_t* const ctxt_pP, @@ -122,7 +122,7 @@ public_rlc_um_control_primitives( void config_req_rlc_um_asn1 ( const UL_UM_RLC_t * const ul_rlc_pP, const DL_UM_RLC_t * const dl_rlc_pP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping + const logical_chan_id_t chan_idP);) /*! \fn void rlc_um_init (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP) * \brief Initialize a RLC UM protocol instance, initialize all variables, lists, allocate buffers for making this instance ready to be configured with protocol configuration parameters. After this initialization the RLC UM protocol instance will be in RLC_NULL_STATE state. @@ -189,6 +189,6 @@ protected_rlc_um_control_primitives(void rlc_um_set_debug_infos( rlc_um_entity_t * const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP);) // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping + const logical_chan_id_t chan_idP);) /** @} */ # endif diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index 2f347cd227..76dab9a6d3 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -136,7 +136,6 @@ tbs_size_t mac_rlc_data_req( { //----------------------------------------------------------------------------- struct mac_data_req data_request; - // rb_id_t rb_id = 0; // 2016-05-27 wilson : not needed after DRB-id <-> LC-id mapping fix rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_mbms_id_t *mbms_id_p = NULL; rlc_union_t *rlc_union_p = NULL; @@ -179,17 +178,7 @@ tbs_size_t mac_rlc_data_req( return (tbs_size_t)0; } } else { -#ifdef ASTRI_FIX // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping - if (channel_idP > 2) { - rb_id = channel_idP - 2; - } else { - rb_id = channel_idP; - } - - key = RLC_COLL_KEY_VALUE(module_idP, rntiP, enb_flagP, rb_id, srb_flag); -#else key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); -#endif } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -248,7 +237,6 @@ void mac_rlc_data_ind ( crc_t *crcs_pP) { //----------------------------------------------------------------------------- - // rb_id_t rb_id = 0; // 2016-05-27 wilson : not needed after DRB-id <-> LC-id mapping fix rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_mbms_id_t *mbms_id_p = NULL; rlc_union_t *rlc_union_p = NULL; @@ -298,17 +286,7 @@ void mac_rlc_data_ind ( return; } } else { -#ifdef ASTRI_FIX // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping - if (channel_idP > 2) { - rb_id = channel_idP - 2; - } else { - rb_id = channel_idP; - } - - key = RLC_COLL_KEY_VALUE(module_idP, rntiP, enb_flagP, rb_id, srb_flag); -#else key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); -#endif } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -358,7 +336,6 @@ mac_rlc_status_resp_t mac_rlc_status_ind( mac_rlc_status_resp_t mac_rlc_status_resp; struct mac_status_ind tx_status; struct mac_status_resp status_resp; - // rb_id_t rb_id = 0; // 2016-05-27 wilson : not needed after DRB-id <-> LC-id mapping fix rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_mbms_id_t *mbms_id_p = NULL; rlc_union_t *rlc_union_p = NULL; @@ -407,17 +384,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind( key = RLC_COLL_KEY_MBMS_VALUE(module_idP, rntiP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); } else { -#ifdef ASTRI_FIX // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping - if (channel_idP > 2) { - rb_id = channel_idP - 2; - } else { - rb_id = channel_idP; - } - - key = RLC_COLL_KEY_VALUE(module_idP, rntiP, enb_flagP, rb_id, srb_flag); -#else key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); -#endif } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index aba2ab411f..c6ef4a1c5d 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -104,11 +104,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP if (srb2add_listP != NULL) { for (cnt=0; cntlist.count; cnt++) { rb_id = srb2add_listP->list.array[cnt]->srb_Identity; -#if 0 - lc_id = rb_id + 2; -#else // 2016-05-26 wilson : fixing the LC-id<->SRB-id mapping for SRB lc_id = rb_id; -#endif LOG_D(RLC, "Adding SRB %d, rb_id %d\n",srb2add_listP->list.array[cnt]->srb_Identity,rb_id); srb_toaddmod_p = srb2add_listP->list.array[cnt]; @@ -236,9 +232,6 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP drb_toaddmod_p = drb2add_listP->list.array[cnt]; drb_id = drb_toaddmod_p->drb_Identity; -#if 0 - lc_id = drb_id + 2; -#else // 2016-05-26 wilson : fixing the LC-id <-> DRB-id mapping if (drb_toaddmod_p->logicalChannelIdentity) { lc_id = *drb_toaddmod_p->logicalChannelIdentity; } else { @@ -251,9 +244,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP continue; } -#endif - - LOG_I(RLC, "Adding DRB %d, lc_id %d\n",drb_id,lc_id); + LOG_D(RLC, "Adding DRB %d, lc_id %d\n",drb_id,lc_id); if (drb_toaddmod_p->rlc_Config) { @@ -478,10 +469,8 @@ rlc_op_status_t rrc_rlc_remove_rlc ( logical_chan_id_t lcid = 0; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; -#ifndef ASTRI_FIX // 2016-05-27 wilson : fixing DRB-id <-> LC-id mapping hash_key_t key_lcid = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_lcid_rc; -#endif rlc_union_t *rlc_union_p = NULL; #ifdef Rel10 rlc_mbms_id_t *mbms_id_p = NULL; @@ -525,7 +514,6 @@ rlc_op_status_t rrc_rlc_remove_rlc ( h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); if (h_rc == HASH_TABLE_OK) { -#ifndef ASTRI_FIX // 2016-05-27 wilson : fixing the DRB-id <-> LC-id mapping // also remove the hash-key created by LC-id switch (rlc_union_p->mode) { case RLC_MODE_AM: @@ -551,7 +539,6 @@ rlc_op_status_t rrc_rlc_remove_rlc ( if ((h_rc == HASH_TABLE_OK) && (h_lcid_rc == HASH_TABLE_OK)) { h_lcid_rc = hashtable_remove(rlc_coll_p, key_lcid); -#endif h_rc = hashtable_remove(rlc_coll_p, key); LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u LCID %d] RELEASED %s\n", PROTOCOL_CTXT_ARGS(ctxt_pP), @@ -587,10 +574,8 @@ rlc_union_t* rrc_rlc_add_rlc ( //----------------------------------------------------------------------------- hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; -#if 1 // 2016-05-26 wilson hash_key to the same RLC entity but indexed by LC_id instead of RB_id hash_key_t key_lcid = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_lcid_rc; -#endif rlc_union_t *rlc_union_p = NULL; #ifdef Rel10 rlc_mbms_id_t *mbms_id_p = NULL; @@ -631,9 +616,7 @@ rlc_union_t* rrc_rlc_add_rlc ( #endif { key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); -#ifndef ASTRI_FIX // 2016-05-26 wilson : fix DRB-id <-> LC-id mapping key_lcid = RLC_COLL_KEY_LCID_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, chan_idP, srb_flagP); -#endif } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -649,9 +632,7 @@ rlc_union_t* rrc_rlc_add_rlc ( } else if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) { rlc_union_p = calloc(1, sizeof(rlc_union_t)); h_rc = hashtable_insert(rlc_coll_p, key, rlc_union_p); -#ifndef ASTRI_FIX // 2016-05-26 wilson h_lcid_rc = hashtable_insert(rlc_coll_p, key_lcid, rlc_union_p); -#endif if ((h_rc == HASH_TABLE_OK) && (h_lcid_rc == HASH_TABLE_OK)) { #ifdef Rel10 diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index 1a39020a84..04d1fcc9f5 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -506,9 +506,7 @@ typedef struct UE_RRC_INST_s { struct SRB_ToAddMod *SRB1_config[NB_CNX_UE]; struct SRB_ToAddMod *SRB2_config[NB_CNX_UE]; struct DRB_ToAddMod *DRB_config[NB_CNX_UE][8]; -#ifndef ASTRI_FIX - rb_id_t *defaultDRB; // 2015-05-27 wilson : remember the default DRB ID -#endif + rb_id_t *defaultDRB; // remember the ID of the default DRB MeasObjectToAddMod_t *MeasObj[NB_CNX_UE][MAX_MEAS_OBJ]; struct ReportConfigToAddMod *ReportConfig[NB_CNX_UE][MAX_MEAS_CONFIG]; struct QuantityConfig *QuantityConfig[NB_CNX_UE]; diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index cd1389fbc0..b51b00241f 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -1201,7 +1201,6 @@ rrc_ue_process_radioResourceConfigDedicated( // Establish DRBs if present if (radioResourceConfigDedicated->drb_ToAddModList) { -#ifndef ASTRI_FIX // 2016-05-28 wilson : remember the default DRB ID if ( (UE_rrc_inst[ctxt_pP->module_id].defaultDRB == NULL) && (radioResourceConfigDedicated->drb_ToAddModList->list.count >= 1) ) { // configure the first DRB ID as the default DRB ID @@ -1210,8 +1209,6 @@ rrc_ue_process_radioResourceConfigDedicated( LOG_I(RRC,"[UE %d] default DRB = %d\n",ctxt_pP->module_id, *UE_rrc_inst[ctxt_pP->module_id].defaultDRB); } -#endif - uint8_t *kUPenc = NULL; #if defined(ENABLE_SECURITY) From 1de77c7a4e4c792b51c86954a77be03366b361bf Mon Sep 17 00:00:00 2001 From: "Wilson W.K. Thong" Date: Fri, 29 Jul 2016 17:01:00 +0800 Subject: [PATCH 06/60] changed so USRP also uses the piece of codes EXMIMO is uing in setting TA=624 when it is TDD (cherry picked from commit a75dbc4156ed4e216145f1deb81c6e04c1cddf02) --- targets/RT/USER/lte-softmodem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index ee4344cd2d..59b2604ec5 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -3163,7 +3163,7 @@ int main( int argc, char **argv ) UE[CC_id]->tx_power_max_dBm = tx_max_power[CC_id]; -#ifdef EXMIMO +#if defined(EXMIMO) || defined(OAI_USRP) // 2016-04-27 wilson also set TDD N_TA_offset with USRP //N_TA_offset if (UE[CC_id]->lte_frame_parms.frame_type == TDD) { if (UE[CC_id]->lte_frame_parms.N_RB_DL == 100) From 95077bae4f88c83bd828c8c5be71f75cf67fdbd3 Mon Sep 17 00:00:00 2001 From: "Wilson W.K. Thong" Date: Mon, 19 Sep 2016 12:01:16 +0800 Subject: [PATCH 07/60] removed words 'wilson' from src --- targets/RT/USER/lte-softmodem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 59b2604ec5..28d7620810 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -3163,7 +3163,7 @@ int main( int argc, char **argv ) UE[CC_id]->tx_power_max_dBm = tx_max_power[CC_id]; -#if defined(EXMIMO) || defined(OAI_USRP) // 2016-04-27 wilson also set TDD N_TA_offset with USRP +#if defined(EXMIMO) || defined(OAI_USRP) //N_TA_offset if (UE[CC_id]->lte_frame_parms.frame_type == TDD) { if (UE[CC_id]->lte_frame_parms.N_RB_DL == 100) From 754cab7ec44631db4bc194829e0880e1954c2b1b Mon Sep 17 00:00:00 2001 From: "Wilson W.K. Thong" Date: Mon, 19 Sep 2016 15:08:50 +0800 Subject: [PATCH 08/60] added SFN to wireshark logging output Conflicts: openair2/LAYER2/MAC/eNB_scheduler_ulsch.c openair2/LAYER2/MAC/ue_procedures.c --- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_bch.c | 1 + openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_mch.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 +- openair2/LAYER2/MAC/ra_procedures.c | 4 ++-- openair2/LAYER2/MAC/rar_tools.c | 2 +- openair2/LAYER2/MAC/ue_procedures.c | 7 ++++--- openair2/UTIL/OPT/opt.h | 2 +- openair2/UTIL/OPT/probe.c | 14 +++++++------- 10 files changed, 20 insertions(+), 18 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index c3a2aea0a5..7022333439 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -651,7 +651,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un if (opt_enabled==1) { trace_pdu(1, (uint8_t *)eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0], rrc_sdu_length, UE_id, 3, UE_RNTI(module_idP, UE_id), - eNB->subframe,0,0); + eNB->frame, eNB->subframe,0,0); LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", module_idP, CC_id, frameP, UE_RNTI(module_idP,UE_id), rrc_sdu_length); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c index f3774777a1..f4586ff9e8 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c @@ -319,6 +319,7 @@ schedule_SI( 0xffff, 4, 0xffff, + eNB->frame, eNB->subframe, 0, 0); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 61a0357691..fb8d4f3354 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -1122,7 +1122,7 @@ schedule_ue_spec( if (opt_enabled == 1) { trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS, module_idP, 3, UE_RNTI(module_idP,UE_id), - eNB->subframe,0,0); + eNB->frame, eNB->subframe,0,0); LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", module_idP, CC_id, frameP, UE_RNTI(module_idP,UE_id), TBS); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c index a6926e15ad..42189d0df2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c @@ -629,7 +629,7 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra if (opt_enabled ==1 ) { trace_pdu(1, (uint8_t *)eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload, TBS, module_idP, 6, 0xffff, // M_RNTI = 6 in wirehsark - eNB_mac_inst[module_idP].subframe,0,0); + eNB_mac_inst[module_idP].frame, eNB_mac_inst[module_idP].subframe,0,0); LOG_D(OPT,"[eNB %d][MCH] CC_id %d Frame %d : MAC PDU with size %d\n", module_idP, CC_id, frameP, TBS); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index f0ad4ee3ee..a5395c2f7c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -101,7 +101,7 @@ void rx_sdu(const module_id_t enb_mod_idP, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,1); if (opt_enabled == 1) { - trace_pdu(0, sduP,sdu_lenP, 0, 3, rntiP,subframeP, 0,0); + trace_pdu(0, sduP,sdu_lenP, 0, 3, rntiP, frameP, subframeP, 0,0); LOG_D(OPT,"[eNB %d][ULSCH] Frame %d rnti %x with size %d\n", enb_mod_idP, frameP, rntiP, sdu_lenP); } diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 669077bf4f..61289e0d36 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -280,7 +280,7 @@ void Msg1_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id if (opt_enabled) { trace_pdu(0, NULL, 0, module_idP, 2, UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex, - UE_mac_inst[module_idP].subframe, 0, UE_mac_inst[module_idP].RA_attempt_number); + UE_mac_inst[module_idP].frame, UE_mac_inst[module_idP].subframe, 0, UE_mac_inst[module_idP].RA_attempt_number); LOG_D(OPT,"[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n", module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size); } @@ -304,7 +304,7 @@ void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id if (opt_enabled) { // msg3 trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], UE_mac_inst[module_idP].RA_Msg3_size, - module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0); + module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].frame, UE_mac_inst[module_idP].subframe, 0, 0); LOG_D(OPT,"[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n", module_idP, frameP, UE_mac_inst[module_idP].crnti /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex*/, UE_mac_inst[module_idP].RA_Msg3_size); } diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index be8dc43c97..c31b50eab6 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -126,7 +126,7 @@ unsigned short fill_rar( if (opt_enabled) { trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1, - eNB_mac_inst[module_idP].subframe, 0, 0); + eNB_mac_inst[module_idP].frame, eNB_mac_inst[module_idP].subframe, 0, 0); LOG_D(OPT,"[eNB %d][RAPROC] CC_id %d RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n", module_idP, CC_id, frameP, eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti, rarh->RAPID, input_buffer_length); diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 90d227eb35..41415f2e1a 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -321,7 +321,7 @@ ue_send_sdu(module_id_t module_idP, if (opt_enabled) { trace_pdu(1, sdu, sdu_len, module_idP, 3, UE_mac_inst[module_idP].crnti, - UE_mac_inst[module_idP].subframe, 0, 0); + UE_mac_inst[module_idP].frame, UE_mac_inst[module_idP].subframe, 0, 0); LOG_D(OPT,"[UE %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n", module_idP, frameP, UE_mac_inst[module_idP].crnti, sdu_len); } @@ -499,6 +499,7 @@ void ue_decode_si(module_id_t module_idP,int CC_id,frame_t frameP, uint8_t eNB_i module_idP, 4, 0xffff, + UE_mac_inst[module_idP].frame, UE_mac_inst[module_idP].subframe, 0, 0); @@ -1498,9 +1499,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); if (opt_enabled) { - trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0); + trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].frame, UE_mac_inst[module_idP].subframe, 0, 0); LOG_D(OPT,"[UE %d][ULSCH] Frame %d trace pdu for rnti %x with size %d\n", - module_idP, UE_mac_inst[module_idP].subframe, UE_mac_inst[module_idP].crnti, buflen); + module_idP, UE_mac_inst[module_idP].frame, UE_mac_inst[module_idP].subframe, UE_mac_inst[module_idP].crnti, buflen); } } diff --git a/openair2/UTIL/OPT/opt.h b/openair2/UTIL/OPT/opt.h index bb3a099e12..8d2464641c 100644 --- a/openair2/UTIL/OPT/opt.h +++ b/openair2/UTIL/OPT/opt.h @@ -85,7 +85,7 @@ extern char in_path[100]; */ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, - int ueid, int rntiType, int rnti, uint8_t subframe, + int ueid, int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe, int oob_event, int oob_event_value); int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p); diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index eef98ae729..059a55a319 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -260,7 +260,7 @@ int opt_create_listener_socket(char *ip_address, uint16_t port) */ /* Add framing header to MAC PDU and send. */ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType, - guint16 rnti, guint16 ueid, guint16 subframeNumber, + guint16 rnti, guint16 ueid, guint16 sfnSf, guint8 isPredefinedData, guint8 retx, guint8 crcStatus, guint8 oob_event, guint8 oob_event_value, uint8_t *pdu_buffer, unsigned int pdu_buffer_size) @@ -308,7 +308,7 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType, /* Subframe number */ frameBuffer[frameOffset++] = MAC_LTE_SUBFRAME_TAG; - tmp16 = htons(subframeNumber); // frame counter : this will give an expert info as wireshark expects SF and not F + tmp16 = htons(sfnSf); // frame counter : this will give an expert info as wireshark expects SF and not F memcpy(frameBuffer+frameOffset, &tmp16, 2); frameOffset += 2; @@ -317,7 +317,7 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType, #ifdef WIRESHARK_DEV frameOffset += 2; - tmp16 = htons(subframeNumber); // subframe + tmp16 = htons(sfnSf); // subframe memcpy(frameBuffer+frameOffset, &tmp16, 2); frameOffset += 2; #endif @@ -458,7 +458,7 @@ static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context, /* Remote serveraddress (where Wireshark is running) */ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, - int ueid, int rntiType, int rnti, uint8_t subframe, int oob_event, + int ueid, int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event, int oob_event_value) { MAC_Context_Info_t pdu_context; @@ -471,7 +471,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, SendFrame(radio_type, (direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK, - rntiType, rnti, ueid, subframe, + rntiType, rnti, ueid, (sysFrameNumber<<4) + subFrameNumber, 1, 0, 1, //guint8 isPredefinedData, guint8 retx, guint8 crcStatus oob_event,oob_event_value, pdu_buffer, pdu_buffer_size); @@ -490,8 +490,8 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, pdu_context.ueid = ueid; pdu_context.isRetx = 0; pdu_context.crcStatusOK =1; - pdu_context.sysFrameNumber = subframe; - pdu_context.subFrameNumber = 0; + pdu_context.sysFrameNumber = sysFrameNumber; + pdu_context.subFrameNumber = subFrameNumber; pdu_context.subframesSinceCaptureStart = subframesSinceCaptureStart++; MAC_LTE_PCAP_WritePDU( &pdu_context, pdu_buffer, pdu_buffer_size); break; From 8ce73e5a7e16de89bfe78976434cbc7b3012edfa Mon Sep 17 00:00:00 2001 From: calvin wang Date: Tue, 27 Sep 2016 17:08:17 +0800 Subject: [PATCH 09/60] L2 stabilization BSR fertilization --- openair2/LAYER2/MAC/config.c | 23 +++ openair2/LAYER2/MAC/defs.h | 8 + openair2/LAYER2/MAC/extern.h | 2 + openair2/LAYER2/MAC/proto.h | 6 +- openair2/LAYER2/MAC/ue_procedures.c | 219 +++++++++++++++++++--------- openair2/LAYER2/MAC/vars.h | 9 ++ 6 files changed, 198 insertions(+), 69 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 2c5a0799d2..030ac7a9f3 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -76,6 +76,7 @@ void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index) // cancel all pending SRs UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + UE_mac_inst[module_idP].BSR_reporting_active=0; // stop ongoing RACH procedure @@ -235,10 +236,31 @@ rrc_mac_config_req( UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) 0; } + if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) { + if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10) { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10; + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0; + } + if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10) { + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10; + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; + } + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0; + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; + } #endif UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer); UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer); + UE_mac_inst[Mod_idP].BSR_reporting_active = 0; + LOG_D(MAC,"[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", + Mod_idP, + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF, + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF); + UE_mac_inst[Mod_idP].scheduling_info.drx_config = mac_MainConfig->drx_Config; UE_mac_inst[Mod_idP].scheduling_info.phr_config = mac_MainConfig->phr_Config; @@ -259,6 +281,7 @@ rrc_mac_config_req( UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[Mod_idP].scheduling_info.PathlossChange); + UE_mac_inst[Mod_idP].PHR_reporting_active = 0; LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", Mod_idP, (mac_MainConfig->phr_Config)?mac_MainConfig->phr_Config->present:-1, diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 713c9d967c..4edfef1677 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -983,6 +983,12 @@ typedef struct { int16_t prohibitPHR_SF; ///DL Pathloss Change in db uint16_t PathlossChange_db; + + /// default value is false + uint16_t extendedBSR_Sizes_r10; + /// default value is false + uint16_t extendedPHR_r10; + //Bj bucket usage per lcid int16_t Bj[MAX_NUM_LCID]; // Bucket size per lcid @@ -1070,6 +1076,8 @@ typedef struct { uint8_t PHR_reporting_active; /// power backoff due to power management (as allowed by P-MPRc) for this cell uint8_t power_backoff_db[NUMBER_OF_eNB_MAX]; + /// BSR report falg management + uint8_t BSR_reporting_active; /// MBSFN_Subframe Configuration struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA? /// number of subframe allocation pattern available for MBSFN sync area diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index ca847acf4c..bb37a3766f 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -53,6 +53,8 @@ extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; //extern uint32_t EBSR_Level[63]; +extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE]; +//extern uint32_t Extended_BSR_TABLE[63]; ----currently not used extern UE_MAC_INST *UE_mac_inst; extern eNB_MAC_INST *eNB_mac_inst; diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 9a0f60167d..4133d6a2eb 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -548,7 +548,7 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 \param[in] Mod_id instance of the UE \param[out] lcgid */ -int get_bsr_lcgid (module_id_t module_idP); +int get_bsr_lcgid (module_id_t module_idP, int *num_lcgid); /*! \fn uint8_t get_bsr_len (module_id_t module_idP,uint16_t bufflen); \brief determine whether the bsr is short or long assuming that the MAC pdu is built @@ -582,14 +582,14 @@ BSR_LONG * get_bsr_long(module_id_t module_idP, uint8_t bsr_len); */ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcgid); -/*! \fn locate (int *table, int size, int value) +/*! \fn locate_BsrIndexByBufferSize (int *table, int size, int value) \brief locate the BSR level in the table as defined in 36.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table. \param[in] *table Pointer to BSR table \param[in] size Size of the table \param[in] value Value of the buffer \return the index in the BSR_LEVEL table */ -uint8_t locate (const uint32_t *table, int size, int value); +uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value); /*! \fn int get_sf_periodicBSRTimer(uint8_t periodicBSR_Timer) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 90d227eb35..6fc95f55d5 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -110,13 +110,17 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; UE_mac_inst[module_idP].scheduling_info.ttiBundling=0; + UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10=0; + UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10=0; UE_mac_inst[module_idP].scheduling_info.drx_config=NULL; UE_mac_inst[module_idP].scheduling_info.phr_config=NULL; UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); + UE_mac_inst[module_idP].BSR_reporting_active = 0; UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[module_idP].scheduling_info.PathlossChange); + UE_mac_inst[module_idP].PHR_reporting_active = 0; for (i=0; i < MAX_NUM_LCID; i++) { LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",module_idP,i); @@ -296,18 +300,28 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i // initiate RA UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + // release all pucch resource + UE_mac_inst[module_idP].physicalConfigDedicated = NULL; + UE_mac_inst[module_idP].ul_active=0; + UE_mac_inst[module_idP].BSR_reporting_active=0; + + LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); return(0); } } //------------------------------------------------------------------------------ void -ue_send_sdu(module_id_t module_idP, - uint8_t CC_id, - frame_t frameP, - uint8_t* sdu, - uint16_t sdu_len, - uint8_t eNB_index) { +ue_send_sdu( + module_id_t module_idP, + uint8_t CC_id, + frame_t frameP, + uint8_t* sdu, + uint16_t sdu_len, + uint8_t eNB_index +) +//------------------------------------------------------------------------------ +{ unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; @@ -1188,17 +1202,20 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf uint8_t payload_offset=0,num_sdus=0; uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; uint16_t sdu_length_total=0; - BSR_SHORT bsr_short; + BSR_SHORT bsr_short,bsr_truncated; BSR_LONG bsr_long; BSR_SHORT *bsr_s=&bsr_short; + BSR_SHORT *bsr_t=&bsr_truncated; BSR_LONG *bsr_l=&bsr_long; POWER_HEADROOM_CMD phr; POWER_HEADROOM_CMD *phr_p=&phr; - unsigned short short_padding=0, post_padding=0; + unsigned short short_padding=0, post_padding=0, padding_len=0; int lcgid; int j; // used for padding // Compute header length - + int all_pdu_len; + int num_lcgid=0; + if (CC_id>0) { LOG_E(MAC,"Transmission on secondary CCs is not supported yet\n"); mac_xface->macphy_exit("MAC FATAL CC_id>0"); @@ -1243,8 +1260,8 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf } bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len); - - if (bsr_ce_len > 0 ) { + // retxBSR-Timer expires or periodicBSR-Timer expires and UE has data available for transmission + if ((bsr_ce_len > 0 ) && (UE_mac_inst[module_idP].BSR_reporting_active > 0)) { bsr_len = bsr_ce_len + bsr_header_len; LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n", module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen); @@ -1338,8 +1355,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len+=3; dtch_header_len_last=3; + all_pdu_len = bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total; if ((UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) && - ((bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total) <= buflen)) { + (all_pdu_len <= buflen)) { // optimize the dtch header lenght //if ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] > 128) && @@ -1357,7 +1375,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ENB_FLAG_NO, MBMS_FLAG_NO, // eNB_index lcid, - buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total); + buflen-all_pdu_len); LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[%d] %d)\n", module_idP,frameP, lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len, @@ -1390,31 +1408,54 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len -= 3; } } - - lcgid= get_bsr_lcgid(module_idP); - if (lcgid < 0 ) { + lcgid= get_bsr_lcgid(module_idP, &num_lcgid); + + if (num_lcgid == 0 ) { bsr_s = NULL; - bsr_l = NULL ; - } else if ((lcgid ==MAX_NUM_LCGID) && (bsr_ce_len == sizeof(BSR_LONG))) { - bsr_s = NULL; - bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; - bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; - bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; - bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; - LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); - } else if (bsr_ce_len == sizeof(BSR_SHORT)) { + bsr_t = NULL; bsr_l = NULL; - bsr_s->LCGID = lcgid; - bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; - LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", + } else if (num_lcgid == 1){ + if (bsr_ce_len == sizeof(BSR_SHORT)){ + bsr_l = NULL; + bsr_t = NULL; + bsr_s->LCGID = lcgid; + bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; + LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", + module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); + } else { + bsr_s = NULL; + bsr_t = NULL; + bsr_l = NULL; + } + } else if (num_lcgid > 1) { + if (bsr_ce_len == sizeof(BSR_LONG)){ + bsr_t = NULL; + bsr_s = NULL; + bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; + bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; + bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; + bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; + LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); + } else if (bsr_ce_len == sizeof(BSR_SHORT)){ + bsr_l = NULL; + bsr_s = NULL; + bsr_t->LCGID = lcgid; + bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; + LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); + } else { + bsr_s = NULL; + bsr_t = NULL; + bsr_l = NULL; + } } else { bsr_s = NULL; + bsr_t = NULL; bsr_l = NULL; } @@ -1444,12 +1485,14 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len_last-=1; dtch_header_len= (dtch_header_len >0)? dtch_header_len - dtch_header_len_last : dtch_header_len; } - - if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) <= 2) { - short_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; + // 1-bit padding or 2-bit padding special padding subheader + padding_len = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; + if (padding_len <= 2) { + short_padding = padding_len; + // only add padding header post_padding = 0; } else { - if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) == buflen) { + if (padding_len == buflen) {// nona mac pdu *access_mode=CANCELED_ACCESS; } @@ -1474,7 +1517,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_lcids, // sdu lcid phr_p, // power headroom NULL, // crnti - NULL, // truncated bsr + bsr_t, // truncated bsr bsr_s, // short bsr bsr_l, post_padding); // long_bsr @@ -1494,6 +1537,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf module_idP,payload_offset, sdu_length_total); UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + UE_mac_inst[module_idP].BSR_reporting_active=0; + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); @@ -1655,7 +1701,22 @@ ue_scheduler( // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures // outlined in Sections 5.4.4 an 5.4.5 of 36.321 - // Put this in another function + // Call BSR procedure as described in Section 5.4.5 in 36.321 + if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == get_sf_periodicBSRTimer(MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity)) { + UE_mac_inst[module_idP].BSR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF <= 0 ){ + // trigger BSR and reset the timer later when the BSR report is sent + UE_mac_inst[module_idP].BSR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].BSR_reporting_active == 0 ) { + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--; + } + + if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF <= 0){ + // trigger BSR and reset the timer later when the BSR report is sent + UE_mac_inst[module_idP].BSR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].BSR_reporting_active == 0 ) { + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--; + } // Get RLC status info and update Bj for all lcids that are active for (lcid=DCCH; lcid <= DTCH; lcid++ ) { @@ -1899,54 +1960,75 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 } #endif -int get_bsr_lcgid (module_id_t module_idP) +int get_bsr_lcgid (module_id_t module_idP, int *num_lcgid) { int lcgid, lcgid_tmp=-1; int num_active_lcgid = 0; for (lcgid = 0 ; lcgid < MAX_NUM_LCGID; lcgid++) { if (UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] > 0 ) { - lcgid_tmp = lcgid; + if (lcgid_tmp == -1){ + // first priority lcgid + lcgid_tmp = lcgid; + } num_active_lcgid+=1; } } - + *num_lcgid = num_active_lcgid; + if (num_active_lcgid == 0) { - return -1; - } else if (num_active_lcgid == 1) { - return lcgid_tmp; + return -1; // no data } else { - return MAX_NUM_LCGID; + return lcgid_tmp;//only one lcgid, report short bsr } } uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) { - int lcgid=0; uint8_t bsr_len=0, num_lcgid=0; int pdu = 0; + int long_bsr_plus_subheader_length = sizeof(BSR_LONG)+sizeof(SCH_SUBHEADER_FIXED); + int short_bsr_plus_subheader_length = sizeof(BSR_SHORT)+sizeof(SCH_SUBHEADER_FIXED); - + // check how many lcg have data to report for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) { - pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + bsr_len + 2); //2 = sizeof(SCH_SUBHEADER_SHORT) + num_lcgid ++; + pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + sizeof(SCH_SUBHEADER_SHORT)); } - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) { // long header size: adjust the header size pdu += 1; } - - // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid - - if ( (pdu > buflen) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) ) { - num_lcgid +=1; - bsr_len = (num_lcgid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; + LOG_D(MAC,"BSR Bytes %d for lcgid %d num lcgid %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid], lcgid, num_lcgid); + } + // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid + if (buflen < pdu) { + if (num_lcgid > 0) { + bsr_len = sizeof(BSR_SHORT); + } else { + bsr_len = 0; } - - LOG_D(MAC,"BSR Bytes %d for lcgid %d bsr len %d num lcgid %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid], lcgid, bsr_len, num_lcgid); + } + // padding larger then long bsr + if (buflen > (pdu + long_bsr_plus_subheader_length)) { + if (num_lcgid > 1) { + bsr_len = sizeof(BSR_LONG); + } else if (num_lcgid > 0) { + bsr_len = sizeof(BSR_SHORT); + } else { + bsr_len = 0; + } + } + // padding larger then short bsr and shorter then long bsr + if ((buflen < (pdu + long_bsr_plus_subheader_length)) && + (buflen > (pdu + short_bsr_plus_subheader_length))) { + if (num_lcgid > 0) { + bsr_len = sizeof(BSR_SHORT); + } else { + bsr_len = 0; + } } - if ( bsr_len > 0 ) LOG_D(MAC,"[UE %d] Prepare a %s (Transport Block Size %d, MAC pdu Size %d) \n", module_idP, map_int_to_str(BSR_names, bsr_len), buflen, pdu); @@ -1959,11 +2041,11 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in { mac_rlc_status_resp_t rlc_status; - boolean_t sr_pending = FALSE; + boolean_t Bsr_pending = FALSE; if ((lcg_id < 0) || (lcg_id >= MAX_NUM_LCGID) ) { - return sr_pending; + return Bsr_pending; } // fixme: need a better way to reset @@ -1979,10 +2061,15 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in 0); if (rlc_status.bytes_in_buffer > 0 ) { - sr_pending = TRUE; + //BSR trigger SR + Bsr_pending = TRUE; UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; - UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] += locate (BSR_TABLE,BSR_TABLE_SIZE, rlc_status.bytes_in_buffer); - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] = rlc_status.bytes_in_buffer; + if (UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10 == TRUE){ + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(Extended_BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); + } else { + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); + } // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); @@ -1992,10 +2079,10 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in } //} - return sr_pending; + return Bsr_pending; } -uint8_t locate (const uint32_t *table, int size, int value) +uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value) { uint8_t ju, jm, jl; @@ -2026,7 +2113,7 @@ uint8_t locate (const uint32_t *table, int size, int value) if (value == table[jl]) { return jl; - } else { + } else { return jl+1; //equally ju } diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 508c7f8c21..3020706815 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -52,6 +52,15 @@ const uint32_t BSR_TABLE[BSR_TABLE_SIZE]= {0,10,12,14,17,19,22,26,31,36,42,49,57 1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099, 16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439, 128125,150000, 300000 }; +// extended bsr table--currently not used +const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE] = {0,10,13,16,19,23,29,35,43,53,65,80,98,120,147, + 181,223,274,337,414,509,625,769,945,1162,1429, + 1757,2161,2657,3267,4017,4940,6074,7469,9185, + 11294,13888,17077,20999,25822,31752,39045,48012, + 59039,72598,89272,109774,134986,165989,204111, + 250990,308634,379519,466683,573866,705666,867737, + 1067031,1312097,1613447,1984009,2439678,3000000, + 6000000}; //uint32_t EBSR_Level[63]={0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181}; From a5210e4f4f9160730edc2b84c40a5f502de4db74 Mon Sep 17 00:00:00 2001 From: fnabet Date: Wed, 28 Sep 2016 17:36:07 +0200 Subject: [PATCH 10/60] UE L2 changes for 3GPP alignement --- openair2/LAYER2/MAC/ue_procedures.c | 31 ++++++++++++++++++- .../LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c | 3 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 90d227eb35..4547adabac 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -151,7 +151,7 @@ unsigned char *parse_header(unsigned char *mac_header, unsigned short tb_length) { - unsigned char not_done=1,num_ces=0,num_sdus=0,lcid, num_sdu_cnt; + unsigned char not_done=1,num_ces=0,num_cont_res = 0,num_padding = 0,num_sdus=0,lcid, num_sdu_cnt; unsigned char *mac_header_ptr = mac_header; unsigned short length,ce_len=0; @@ -165,6 +165,14 @@ unsigned char *parse_header(unsigned char *mac_header, lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; if (lcid < UE_CONT_RES) { + //FNA: Contention Resolution check according to Annex B of 36.321 + // if this is for CCCH then a Contention Resolution must have been parsed before + if ((lcid == 0) && (num_cont_res == 0)) { + LOG_W(MAC,"[UE] Msg4 Wrong received format: CCCH received without Contention Resolution before\n"); + // exit parsing + return NULL; + } + //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]); if (not_done==0) {// last MAC SDU, length is implicit mac_header_ptr++; @@ -196,6 +204,7 @@ unsigned char *parse_header(unsigned char *mac_header, num_sdus++; } else { // This is a control element subheader if (lcid == SHORT_PADDING) { + num_padding ++; mac_header_ptr++; } else { rx_ces[num_ces] = lcid; @@ -205,6 +214,23 @@ unsigned char *parse_header(unsigned char *mac_header, if (lcid==TIMING_ADV_CMD) { ce_len++; } else if (lcid==UE_CONT_RES) { + + // FNA: check MAC Header is one of thoses defined in Annex B of 36.321 + // Check there is only 1 Contention Resolution + if (num_cont_res) { + LOG_W(MAC,"[UE] Msg4 Wrong received format: More than 1 Contention Resolution\n"); + // exit parsing + return NULL; + + } + + // UE_CONT_RES shall never be the last subheader unless this is the only MAC subheader + if ((not_done == 0) && ((num_sdus) || (num_ces > 1) || (num_padding))) { + LOG_W(MAC,"[UE] Msg4 Wrong received format: Contention Resolution after num_ces=%d num_sdus=%d num_padding=%d\n",num_ces,num_sdus,num_padding); + // exit parsing + return NULL; + } + num_cont_res ++; ce_len+=6; } } @@ -343,6 +369,8 @@ ue_send_sdu(module_id_t module_idP, LOG_T(MAC,"\n"); #endif + if (payload_ptr != NULL) { + for (i=0; it_reordering.running) { - if ((rlc_pP->vr_x == rlc_pP->vr_r) || ((rlc_am_in_rx_window(ctxt_pP, rlc_pP, pdu_info_p->sn) == 0) && (rlc_pP->vr_x != rlc_pP->vr_mr))) { + if ((rlc_pP->vr_x == rlc_pP->vr_r) || ((rlc_am_in_rx_window(ctxt_pP, rlc_pP, rlc_pP->vr_x) == 0) && (rlc_pP->vr_x != rlc_pP->vr_mr))) { rlc_am_stop_and_reset_timer_reordering(ctxt_pP, rlc_pP); } } From b11ed995d258dd65877849947c0b08390019649e Mon Sep 17 00:00:00 2001 From: fnabet Date: Mon, 10 Oct 2016 16:22:01 +0200 Subject: [PATCH 11/60] fix build issue after merge from develop --- openair2/LAYER2/MAC/ue_procedures.c | 1 + openair2/LAYER2/RLC/rlc_rrc.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index f06582c857..4bc613ffbe 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -564,6 +564,7 @@ void ue_decode_p(module_id_t module_idP,int CC_id,frame_t frameP, uint8_t eNB_in module_idP, 4, P_RNTI, + UE_mac_inst[module_idP].frame, UE_mac_inst[module_idP].subframe, 0, 0); diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index ae091651a8..9ed5c4672e 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -216,7 +216,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP ctxt_pP, SRB_FLAG_YES, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.am, - rb_id); + rb_id,lc_id); } else { LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", PROTOCOL_CTXT_ARGS(ctxt_pP), From 138ed2fbb429efc465ed9136a80cf3a79780ce5c Mon Sep 17 00:00:00 2001 From: fnabet Date: Mon, 10 Oct 2016 17:16:01 +0200 Subject: [PATCH 12/60] [OAI-UE] fixes: 1- frame/subframe update 2- ccch discard regression --- openair2/LAYER2/MAC/ue_procedures.c | 8 -------- targets/RT/USER/lte-ue.c | 9 +++++++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 4bc613ffbe..448d2ed541 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -165,14 +165,6 @@ unsigned char *parse_header(unsigned char *mac_header, lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; if (lcid < UE_CONT_RES) { - //FNA: Contention Resolution check according to Annex B of 36.321 - // if this is for CCCH then a Contention Resolution must have been parsed before - if ((lcid == 0) && (num_cont_res == 0)) { - LOG_W(MAC,"[UE] Msg4 Wrong received format: CCCH received without Contention Resolution before\n"); - // exit parsing - return NULL; - } - //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]); if (not_done==0) {// last MAC SDU, length is implicit mac_header_ptr++; diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 1c338c3df0..81d60a3d08 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -1035,8 +1035,8 @@ void *UE_thread(void *arg) { }// start_rx_stream==0 else { - UE->proc.proc_rxtx[0].frame_rx++; - UE->proc.proc_rxtx[1].frame_rx++; + //UE->proc.proc_rxtx[0].frame_rx++; + //UE->proc.proc_rxtx[1].frame_rx++; for (int sf=0;sf<10;sf++) { for (i=0; iframe_parms.nb_antennas_rx; i++) @@ -1122,6 +1122,11 @@ void *UE_thread(void *arg) { } // increment instance count and change proc subframe/frame variables int instance_cnt_rxtx = ++proc->instance_cnt_rxtx; + if(sf == 0) + { + UE->proc.proc_rxtx[0].frame_rx++; + UE->proc.proc_rxtx[1].frame_rx++; + } proc->subframe_rx=sf; proc->subframe_tx=(sf+4)%10; proc->frame_tx = proc->frame_rx + ((proc->subframe_rx>5)?1:0); From 0705e71ffc72db255fedbf853f72332c36c402d0 Mon Sep 17 00:00:00 2001 From: hbilel Date: Wed, 12 Oct 2016 14:29:48 +0200 Subject: [PATCH 13/60] [OAI-UE] SRS feature 1- Implement SRS procedures --- cmake_targets/CMakeLists.txt | 1 + openair1/PHY/INIT/lte_init.c | 41 +++ openair1/PHY/LTE_TRANSPORT/defs.h | 2 + openair1/PHY/extern.h | 12 + openair1/PHY/impl_defs_lte.h | 4 + openair1/SCHED/Makefile.inc | 1 + openair1/SCHED/defs.h | 9 + openair1/SCHED/phy_procedures_lte_ue.c | 243 +++++++++++++++++- openair1/SCHED/srs_pc.c | 99 +++++++ openair2/RRC/LITE/MESSAGES/asn1_msg.c | 18 +- openair2/RRC/LITE/rrc_eNB.c | 2 +- ...band7.tm1.generic.oaisim.local_no_mme.conf | 10 +- targets/SIMU/USER/oaisim_functions.c | 4 +- 13 files changed, 421 insertions(+), 25 deletions(-) create mode 100644 openair1/SCHED/srs_pc.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 5e86d59378..d47389e7b4 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -931,6 +931,7 @@ set(SCHED_SRC ${OPENAIR1_DIR}/SCHED/phy_mac_stub.c ${OPENAIR1_DIR}/SCHED/pucch_pc.c ${OPENAIR1_DIR}/SCHED/pusch_pc.c + ${OPENAIR1_DIR}/SCHED/srs_pc.c ) add_library(SCHED_LIB ${SCHED_SRC}) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index a2e4fa8747..d358329b63 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -489,6 +489,26 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *eNB) } + if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) { + if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SchedulingRequestConfig_PR_setup) { + + eNB->soundingrs_ul_config_dedicated[UE_id].duration = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration; + eNB->soundingrs_ul_config_dedicated[UE_id].cyclicShift = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; + eNB->soundingrs_ul_config_dedicated[UE_id].freqDomainPosition = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; + eNB->soundingrs_ul_config_dedicated[UE_id].srs_Bandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; + eNB->soundingrs_ul_config_dedicated[UE_id].srs_ConfigIndex = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; + eNB->soundingrs_ul_config_dedicated[UE_id].srs_HoppingBandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth; + eNB->soundingrs_ul_config_dedicated[UE_id].transmissionComb = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; + + + LOG_D(PHY,"soundingrs_ul_config_dedicated.srs_ConfigIndex %d\n",eNB->soundingrs_ul_config_dedicated[UE_id].srs_ConfigIndex); + + } + + LOG_D(PHY,"------------------------------------------------------------\n"); + + } + eNB->physicalConfigDedicated[UE_id] = NULL; } } @@ -859,6 +879,27 @@ void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, } + if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) { + + if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SchedulingRequestConfig_PR_setup) { + + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].duration = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].cyclicShift = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].freqDomainPosition = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_Bandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_HoppingBandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].transmissionComb = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; + + + LOG_D(PHY,"soundingrs_ul_config_dedicated.srs_ConfigIndex %d\n",phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex); + } + + LOG_D(PHY,"------------------------------------------------------------\n"); + + } + + #ifdef CBA if (physicalConfigDedicated->pusch_CBAConfigDedicated_vlola) { diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h index 26e2d40460..be6cd4f5a0 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/defs.h @@ -341,6 +341,8 @@ typedef struct { int16_t Po_PUSCH; /// PHR - current power headroom (based on last PUSCH transmission) int16_t PHR; + /// Po_SRS - target output power for SRS + int16_t Po_SRS; /// num active cba group uint8_t num_active_cba_groups; /// num dci found for cba diff --git a/openair1/PHY/extern.h b/openair1/PHY/extern.h index 867f980e5f..2ce2d03ff5 100755 --- a/openair1/PHY/extern.h +++ b/openair1/PHY/extern.h @@ -118,5 +118,17 @@ extern char eNB_timing[2][20]; extern int16_t unscrambling_lut[65536*16]; extern uint8_t scrambling_lut[65536*16]; +extern unsigned short msrsb_6_40[8][4]; +extern unsigned short msrsb_41_60[8][4]; +extern unsigned short msrsb_61_80[8][4]; +extern unsigned short msrsb_81_110[8][4]; +extern unsigned short Nb_6_40[8][4]; +extern unsigned short Nb_41_60[8][4]; +extern unsigned short Nb_61_80[8][4]; +extern unsigned short Nb_81_110[8][4]; + +extern uint16_t hundred_times_log10_NPRB[100]; +extern uint8_t alpha_lut[8]; + #endif /*__PHY_EXTERN_H__ */ diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index bed2057800..6813fe058f 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -319,6 +319,10 @@ typedef struct { uint16_t srs_ConfigIndex; /// Parameter: \f$n^\text{CS}_\text{SRS}\f$. See TS 36.211 (5.5.3.1). \vr{[0..7]} \note the specification sais it is an enumerated value. uint8_t cyclicShift; + // Parameter: cell srs subframe for internal implementation + uint8_t srsCellSubframe; + // Parameter: ue srs subframe for internal implementation + uint8_t srsUeSubframe; } SOUNDINGRS_UL_CONFIG_DEDICATED; /// UplinkPowerControlDedicated Information Element from 36.331 RRC spec diff --git a/openair1/SCHED/Makefile.inc b/openair1/SCHED/Makefile.inc index e3fd877e5d..559d3dca32 100644 --- a/openair1/SCHED/Makefile.inc +++ b/openair1/SCHED/Makefile.inc @@ -3,3 +3,4 @@ SCHED_OBJS += $(TOP_DIR)/SCHED/phy_procedures_lte_ue.o SCHED_OBJS += $(TOP_DIR)/SCHED/phy_procedures_lte_eNb.o SCHED_OBJS += $(TOP_DIR)/SCHED/pusch_pc.o SCHED_OBJS += $(TOP_DIR)/SCHED/pucch_pc.o +SCHED_OBJS += $(TOP_DIR)/SCHED/srs_pc.o diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h index f9ebd3b3b0..10a0cf6e4b 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/defs.h @@ -444,6 +444,15 @@ int8_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,ui */ void pusch_power_cntl(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag); +/*! \brief This function implements the power control mechanism for SRS from 36.213. + @param phy_vars_ue PHY variables + @param proc Pointer to proc descriptor + @param eNB_id Index of eNB + @param j index of type of PUSCH (SPS, Normal, Msg3) + @returns Transmit power + */ +void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t *pnb_rb_srs, uint8_t abstraction_flag); + int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id, uint8_t eNB_index); #ifdef LOCALIZATION diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 5fa9f9f2f5..f15e4768c0 100755 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -205,6 +205,7 @@ unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb int gain_dB = power_dBm - power_max_dBm; double gain_lin; + LOG_I(PHY,"Get Tx Amp; Gain[dB]: %d, AMP: %d\n",gain_dB,AMP); if (gain_dB < -20) return(AMP/10); @@ -385,6 +386,180 @@ uint8_t is_SR_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) return(0); } +void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset) +{ + if(TDD == frameType) + { + if(isrs<10) + { + mac_xface->macphy_exit("2 ms SRS periodicity not supported"); + } + + if((isrs>9)&&(isrs<15)) + { + *psrsPeriodicity=5; + *psrsOffset=isrs-10; + } + if((isrs>14)&&(isrs<25)) + { + *psrsPeriodicity=10; + *psrsOffset=isrs-15; + } + if((isrs>24)&&(isrs<45)) + { + *psrsPeriodicity=20; + *psrsOffset=isrs-25; + } + if((isrs>44)&&(isrs<85)) + { + *psrsPeriodicity=40; + *psrsOffset=isrs-45; + } + if((isrs>84)&&(isrs<165)) + { + *psrsPeriodicity=80; + *psrsOffset=isrs-85; + } + if((isrs>164)&&(isrs<325)) + { + *psrsPeriodicity=160; + *psrsOffset=isrs-165; + } + if((isrs>324)&&(isrs<645)) + { + *psrsPeriodicity=320; + *psrsOffset=isrs-325; + } + + if(isrs>644) + { + mac_xface->macphy_exit("Isrs out of range"); + } + + } + else + { + if(isrs<2) + { + *psrsPeriodicity=2; + *psrsOffset=isrs; + } + if((isrs>1)&&(isrs<7)) + { + *psrsPeriodicity=5; + *psrsOffset=isrs-2; + } + if((isrs>6)&&(isrs<17)) + { + *psrsPeriodicity=10; + *psrsOffset=isrs-7; + } + if((isrs>16)&&(isrs<37)) + { + *psrsPeriodicity=20; + *psrsOffset=isrs-17; + } + if((isrs>36)&&(isrs<77)) + { + *psrsPeriodicity=40; + *psrsOffset=isrs-37; + } + if((isrs>76)&&(isrs<157)) + { + *psrsPeriodicity=80; + *psrsOffset=isrs-77; + } + if((isrs>156)&&(isrs<317)) + { + *psrsPeriodicity=160; + *psrsOffset=isrs-157; + } + if((isrs>316)&&(isrs<637)) + { + *psrsPeriodicity=320; + *psrsOffset=isrs-317; + } + if(isrs>636) + { + mac_xface->macphy_exit("Isrs out of range"); + } + } +} + +void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) +{ + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + int frame_tx = proc->frame_tx; + int subframe_tx = proc->subframe_tx; + uint8_t isSubframeSRS = 0; // SRS Cell Occasion + uint8_t isSubframeSRSTx = 0; // SRS UE Occasion + + SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; + + // check for SRS opportunity + pSoundingrs_ul_config_dedicated->srsUeSubframe = 0; + pSoundingrs_ul_config_dedicated->srsCellSubframe = 0; + if(frame_parms->soundingrs_ul_config_common.enabled_flag) + { + + LOG_D(PHY," SRS SUBFRAMECONFIG: %d, Isrs: %d \n", frame_parms->soundingrs_ul_config_common.srs_SubframeConfig, pSoundingrs_ul_config_dedicated->srs_ConfigIndex); + + uint8_t TSFC; + uint16_t deltaTSFC; // bitmap + uint8_t srs_SubframeConfig; + uint16_t srsPeriodicity; + uint16_t srsOffset; + + // table resuming TSFC (Period) and deltaSFC (offset) + const uint16_t deltaTSFCTabType1[15][2] = { {1,1},{1,2},{2,2},{1,5},{2,5},{4,5},{8,5},{3,5},{12,5},{1,10},{2,10},{4,10},{8,10},{351,10},{383,10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD + const uint16_t deltaTSFCTabType2[14][2] = { {2,5},{6,5},{10,5},{18,5},{14,5},{22,5},{26,5},{30,5},{70,10},{74,10},{194,10},{326,10},{586,10},{210,10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD + + srs_SubframeConfig = frame_parms->soundingrs_ul_config_common.srs_SubframeConfig; + if (FDD == frame_parms->frame_type) + { + // srs_SubframeConfig =< 14 + deltaTSFC = deltaTSFCTabType1[srs_SubframeConfig][0]; + TSFC = deltaTSFCTabType1[srs_SubframeConfig][1]; + } + else + { + // srs_SubframeConfig =< 13 + deltaTSFC = deltaTSFCTabType2[srs_SubframeConfig][0]; + TSFC = deltaTSFCTabType2[srs_SubframeConfig][1]; + } + + LOG_D(PHY," ISTDD: %d, TSFC: %d, deltaTSFC: %d, AbsSubframeTX: %d\n", frame_parms->frame_type, TSFC, deltaTSFC, (((int)frame_tx*10)+(int)subframe_tx)); + + // Sounding reference signal subframes are the subframes satisfying ns/2 mod TSFC (- deltaTSFC + uint16_t tmp = (subframe_tx % TSFC); + if((1<srsCellSubframe = 1; + } + + + compute_srs_pos(frame_parms->frame_type, pSoundingrs_ul_config_dedicated->srs_ConfigIndex, &srsPeriodicity, &srsOffset); + + // transmit SRS if the four following constraints are respected: + // - UE is configured to transmit SRS + // - SRS are configured in current subframe + // - UE is configured to send SRS in this subframe + // - CQI is not scheduled in PUCCH transmission - TO BE ADDED + // - simultaneous transmission of SRS and ACKNACK is authorised - TO BE CHECKED + if( isSubframeSRS && + (((10*frame_tx+subframe_tx) % srsPeriodicity) == srsOffset) + //(! is_pucch_per_cqi_report)) + ) + { + isSubframeSRSTx = 1; + pSoundingrs_ul_config_dedicated->srsUeSubframe = 1; + } + LOG_D(PHY," isSubframeSRS: %d, isSubframeSRSTx: %d \n", isSubframeSRS, isSubframeSRSTx); + } +} + uint16_t get_n1_pucch(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t eNB_id, @@ -1086,6 +1261,49 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB } // subframe_scheduling_flag==1 } +void ue_srs_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) +{ + + //LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + //int8_t frame_tx = proc->frame_tx; + int8_t subframe_tx = proc->subframe_tx; + int16_t tx_amp; + int16_t Po_SRS; + uint8_t nb_rb_srs; + + SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; + uint8_t isSrsTxOccasion = pSoundingrs_ul_config_dedicated->srsUeSubframe; + + if(isSrsTxOccasion) + { + ue->generate_ul_signal[eNB_id] = 1; + if (ue->mac_enabled==1) + { + srs_power_cntl(ue,proc,eNB_id, (uint8_t*)(&nb_rb_srs), abstraction_flag); + Po_SRS = ue->ulsch[eNB_id]->Po_SRS; + } + else + { + Po_SRS = ue->tx_power_max_dBm; + } + +#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) + tx_amp = get_tx_amp(Po_SRS, + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + nb_rb_srs); +#else + tx_amp = AMP; +#endif + LOG_I(PHY,"SRS PROC; TX_MAX_POWER %d, Po_SRS %d, NB_RB_UL %d, NB_RB_SRS %d TX_AMPL %d\n",ue->tx_power_max_dBm, + Po_SRS, + ue->frame_parms.N_RB_UL, + nb_rb_srs, + tx_amp); + + generate_srs_tx(ue, eNB_id, tx_amp, subframe_tx); + } +} void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { @@ -1103,6 +1321,9 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin int tx_amp; int8_t Po_PUCCH; + SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; + uint8_t isShortenPucch = pSoundingrs_ul_config_dedicated->srsCellSubframe; + bundling_flag = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; if ((frame_parms->frame_type==FDD) || @@ -1175,19 +1396,21 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin #endif if (SR_payload>0) { - LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 1a/1b payload %d,%d (with SR for PUSCH), n1_pucch %d, Po_PUCCH, amp %d\n", + LOG_I(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 1a/1b payload %d,%d (with SR for PUSCH), shorten_pucch %d, n1_pucch %d, Po_PUCCH, amp %d\n", Mod_id, ue->dlsch[eNB_id][0]->rnti, + isShortenPucch, frame_tx, subframe_tx, pucch_ack_payload[0],pucch_ack_payload[1], ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex, Po_PUCCH, tx_amp); } else { - LOG_D(PHY,"[UE %d][PDSCH %x] Frame %d subframe %d Generating PUCCH 1a/1b, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n", + LOG_I(PHY,"[UE %d][PDSCH %x] Frame %d subframe %d Generating PUCCH 1a/1b, shorten_pucch %d, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n", Mod_id, ue->dlsch[eNB_id][0]->rnti, frame_tx, subframe_tx, + isShortenPucch, n1_pucch,pucch_ack_payload[0],pucch_ack_payload[1],SR_payload, Po_PUCCH, tx_amp); @@ -1201,7 +1424,7 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin format, &ue->pucch_config_dedicated[eNB_id], n1_pucch, - 1, // shortened format + isShortenPucch, // shortened format pucch_ack_payload, tx_amp, subframe_tx); @@ -1236,10 +1459,11 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin #else tx_amp = AMP; #endif - LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 1 (SR for PUSCH), n1_pucch %d, Po_PUCCH %d\n", + LOG_I(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 1 (SR for PUSCH), shorten_pucch %d, n1_pucch %d, Po_PUCCH %d\n", Mod_id, ue->dlsch[eNB_id][0]->rnti, frame_tx, subframe_tx, + isShortenPucch, ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex, Po_PUCCH); @@ -1251,7 +1475,7 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin pucch_format1, &ue->pucch_config_dedicated[eNB_id], ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex, - 1, // shortened format + isShortenPucch, // shortened format pucch_ack_payload, // this is ignored anyway, we just need a pointer tx_amp, subframe_tx); @@ -1306,8 +1530,13 @@ void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,ui } - if (ue->UE_mode[eNB_id] == PUSCH) { // check if we need to use PUCCH 1a/1b - ue_pucch_procedures(ue,proc,eNB_id,abstraction_flag); + if (ue->UE_mode[eNB_id] == PUSCH) { + // check cell srs subframe and ue srs subframe + ue_compute_srs_occasion(ue,proc,eNB_id); + // check if we need to use PUCCH 1a/1b + ue_pucch_procedures(ue,proc,eNB_id,abstraction_flag); + // check if we need to use SRS + ue_srs_procedures(ue,proc,eNB_id,abstraction_flag); } // UE_mode==PUSCH diff --git a/openair1/SCHED/srs_pc.c b/openair1/SCHED/srs_pc.c new file mode 100644 index 0000000000..dc9b8fef46 --- /dev/null +++ b/openair1/SCHED/srs_pc.c @@ -0,0 +1,99 @@ +/******************************************************************************* + OpenAirInterface + Copyright(c) 1999 - 2014 Eurecom + + OpenAirInterface is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + + OpenAirInterface is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OpenAirInterface.The full GNU General Public License is + included in this distribution in the file called "COPYING". If not, + see . + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr + + Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE + + *******************************************************************************/ + +/*! \file srs_pc.c + * \brief Implementation of UE SRS Power Control procedures from 36.213 LTE specifications (Section + * \author H. Bilel + * \date 2016 + * \version 0.1 + * \company TCL + * \email: haithem.bilel@alcatelOneTouch.com + * \note + * \warning + */ + +#include "PHY/defs.h" +#include "PHY/LTE_TRANSPORT/proto.h" +#include "PHY/extern.h" + +void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t *pnb_rb_srs, uint8_t abstraction_flag) +{ + + int16_t PL; + int8_t P_opusch; + int8_t Psrs_offset; + int16_t P_srs; + int16_t f_pusch; + uint8_t alpha; + uint8_t Msrs = 0; + + + SOUNDINGRS_UL_CONFIG_DEDICATED *psoundingrs_ul_config_dedicated = &ue->soundingrs_ul_config_dedicated[eNB_id]; + LTE_DL_FRAME_PARMS *pframe_parms = &ue->frame_parms; + + uint8_t Bsrs = psoundingrs_ul_config_dedicated->srs_Bandwidth; + uint8_t Csrs = pframe_parms->soundingrs_ul_config_common.srs_BandwidthConfig; + LOG_I(PHY," SRS Power Control; AbsSubframe %d.%d, eNB_id %d, srs_Bandwidth %d, srs_BandwidthConfig %d \n",proc->frame_tx,proc->subframe_tx,eNB_id,Bsrs,Csrs); + + if (pframe_parms->N_RB_UL < 41) + { + Msrs = Nb_6_40[Csrs][Bsrs]; + } + else if (pframe_parms->N_RB_UL < 61) + { + Msrs = Nb_41_60[Csrs][Bsrs]; + } + else if (pframe_parms->N_RB_UL < 81) + { + Msrs = Nb_61_80[Csrs][Bsrs]; + } + else if (pframe_parms->N_RB_UL <111) + { + Msrs = Nb_81_110[Csrs][Bsrs]; + } + + // SRS Power control 36.213 5.1.3.1 + // P_srs = P_srs_offset+ 10log10(Msrs) + P_opusch(j) + alpha*PL + f(i)) + + Psrs_offset = (ue->ul_power_control_dedicated[eNB_id].pSRS_Offset - 3); + P_opusch = ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; + f_pusch = ue->ulsch[eNB_id]->f_pusch; + alpha = alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]; + PL = get_PL(ue->Mod_id,ue->CC_id,eNB_id); + + LOG_I(PHY," SRS Power Control; eNB_id %d, p0_NominalPUSCH %d, alpha %d \n",eNB_id,P_opusch,alpha); + LOG_I(PHY," SRS Power Control; eNB_id %d, pSRS_Offset %d, Msrs %d, PL %d, f_pusch %d \n",eNB_id,Psrs_offset,Msrs,PL,f_pusch); + + P_srs = P_opusch + Psrs_offset + f_pusch; + P_srs += (((int32_t)alpha * (int32_t)PL) + hundred_times_log10_NPRB[Msrs-1])/100 ; + + ue->ulsch[eNB_id]->Po_SRS = P_srs; + pnb_rb_srs[0] = Msrs; + LOG_I(PHY," SRS Power Control; eNB_id %d, P_srs[dBm] %d\n",eNB_id,P_srs); +} diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index 13cfae80da..e0556b92bf 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -1496,7 +1496,7 @@ do_RRCConnectionSetup( physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH)); physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH)); physicalConfigDedicated2->cqi_ReportConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig)); - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = NULL;//CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo)); physicalConfigDedicated2->schedulingRequestConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->schedulingRequestConfig)); #ifdef CBA @@ -1582,19 +1582,17 @@ do_RRCConnectionSetup( */ //soundingRS-UL-ConfigDedicated - /* physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup; - assign_enum(&physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth, - SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0); - assign_enum(&physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth, - SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0); + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth = + SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0; + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth = + SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition=0; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.duration=1; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=1; + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=45; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb=0; - assign_enum(&physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift, - SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0); - */ + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift= + SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0; //AntennaInfoDedicated diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 5807ababf2..517e354164 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -2621,7 +2621,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH = CALLOC(1, sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH)); physicalConfigDedicated2->cqi_ReportConfig = NULL; //CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig)); - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = NULL; //CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); physicalConfigDedicated2->antennaInfo = CALLOC(1, sizeof(*physicalConfigDedicated2->antennaInfo)); physicalConfigDedicated2->schedulingRequestConfig = CALLOC(1, sizeof(*physicalConfigDedicated2->schedulingRequestConfig)); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.generic.oaisim.local_no_mme.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.generic.oaisim.local_no_mme.conf index ef7c1cc19c..a79cb2cae6 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.generic.oaisim.local_no_mme.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.generic.oaisim.local_no_mme.conf @@ -62,11 +62,11 @@ eNBs = pusch_nDMRS1 = 0; phich_duration = "NORMAL"; phich_resource = "ONESIXTH"; - srs_enable = "DISABLE"; - /* srs_BandwidthConfig =; - srs_SubframeConfig =; - srs_ackNackST =; - srs_MaxUpPts =;*/ + srs_enable = "ENABLE"; + srs_BandwidthConfig =2; + srs_SubframeConfig =13; + srs_ackNackST ="DISABLE"; + srs_MaxUpPts ="DISABLE"; pusch_p0_Nominal = -108; pusch_alpha = "AL1"; diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index 2b19e30a9b..c493086963 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -1283,7 +1283,7 @@ void init_openair1(void) for (UE_id=0; UE_idtx_power_max_dBm=23; + PHY_vars_UE_g[UE_id][CC_id]->tx_power_max_dBm=10; PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB=100; @@ -1525,7 +1525,7 @@ void update_ocm() //calc_path_loss (enb_data[eNB_id], ue_data[UE_id], eNB2UE[eNB_id][UE_id], oai_emulation.environment_system_config,0); UE2eNB[UE_id][eNB_id][CC_id]->path_loss_dB = eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB; // if (frame % 50 == 0) - LOG_I(OCM,"Path loss (CCid %d) between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f, angle %f\n", + LOG_D(OCM,"Path loss (CCid %d) between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f, angle %f\n", CC_id,eNB_id,enb_data[eNB_id]->x,enb_data[eNB_id]->y,UE_id,ue_data[UE_id]->x,ue_data[UE_id]->y, eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB, eNB2UE[eNB_id][UE_id][CC_id]->aoa); //double dx, dy, distance; From 9d5621e65cae7e830bfce656dc04434ccbc260b6 Mon Sep 17 00:00:00 2001 From: fnabet Date: Wed, 12 Oct 2016 17:47:31 +0200 Subject: [PATCH 14/60] [OAI-UE] SRS feature 1- Implement SRS procedures 2- Implement SRS procedures part2 --- openair1/PHY/INIT/lte_init.c | 3 ++- openair1/PHY/impl_defs_lte.h | 2 ++ openair1/SCHED/phy_procedures_lte_ue.c | 11 ++++++----- openair1/SCHED/srs_pc.c | 9 +++++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index d358329b63..cb299110f5 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -881,8 +881,9 @@ void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) { + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 0; if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SchedulingRequestConfig_PR_setup) { - + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 1; phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].duration = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration; phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].cyclicShift = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].freqDomainPosition = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index 6813fe058f..4ec446cd5f 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -319,6 +319,8 @@ typedef struct { uint16_t srs_ConfigIndex; /// Parameter: \f$n^\text{CS}_\text{SRS}\f$. See TS 36.211 (5.5.3.1). \vr{[0..7]} \note the specification sais it is an enumerated value. uint8_t cyclicShift; + // Parameter: ue srs subframe for internal implementation + uint8_t srsConfigDedicatedSetup; // Parameter: cell srs subframe for internal implementation uint8_t srsCellSubframe; // Parameter: ue srs subframe for internal implementation diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index f15e4768c0..9670df5b4a 100755 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -502,7 +502,7 @@ void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id if(frame_parms->soundingrs_ul_config_common.enabled_flag) { - LOG_D(PHY," SRS SUBFRAMECONFIG: %d, Isrs: %d \n", frame_parms->soundingrs_ul_config_common.srs_SubframeConfig, pSoundingrs_ul_config_dedicated->srs_ConfigIndex); + LOG_I(PHY," SRS SUBFRAMECONFIG: %d, Isrs: %d \n", frame_parms->soundingrs_ul_config_common.srs_SubframeConfig, pSoundingrs_ul_config_dedicated->srs_ConfigIndex); uint8_t TSFC; uint16_t deltaTSFC; // bitmap @@ -528,8 +528,6 @@ void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id TSFC = deltaTSFCTabType2[srs_SubframeConfig][1]; } - LOG_D(PHY," ISTDD: %d, TSFC: %d, deltaTSFC: %d, AbsSubframeTX: %d\n", frame_parms->frame_type, TSFC, deltaTSFC, (((int)frame_tx*10)+(int)subframe_tx)); - // Sounding reference signal subframes are the subframes satisfying ns/2 mod TSFC (- deltaTSFC uint16_t tmp = (subframe_tx % TSFC); if((1<srsCellSubframe = 1; } + LOG_I(PHY," ISTDD: %d, TSFC: %d, deltaTSFC: %d, AbsSubframeTX: %d.%d, srsCellSubframe: %d \n", frame_parms->frame_type, TSFC, deltaTSFC, frame_tx, subframe_tx, pSoundingrs_ul_config_dedicated->srsCellSubframe); - + if(pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup) + { compute_srs_pos(frame_parms->frame_type, pSoundingrs_ul_config_dedicated->srs_ConfigIndex, &srsPeriodicity, &srsOffset); // transmit SRS if the four following constraints are respected: @@ -556,7 +556,8 @@ void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id isSubframeSRSTx = 1; pSoundingrs_ul_config_dedicated->srsUeSubframe = 1; } - LOG_D(PHY," isSubframeSRS: %d, isSubframeSRSTx: %d \n", isSubframeSRS, isSubframeSRSTx); + LOG_I(PHY," isSubframeSRS: %d, isSubframeSRSTx: %d \n", isSubframeSRS, isSubframeSRSTx); + } } } diff --git a/openair1/SCHED/srs_pc.c b/openair1/SCHED/srs_pc.c index dc9b8fef46..3ec5f00f9a 100644 --- a/openair1/SCHED/srs_pc.c +++ b/openair1/SCHED/srs_pc.c @@ -59,7 +59,7 @@ void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t uint8_t Bsrs = psoundingrs_ul_config_dedicated->srs_Bandwidth; uint8_t Csrs = pframe_parms->soundingrs_ul_config_common.srs_BandwidthConfig; - LOG_I(PHY," SRS Power Control; AbsSubframe %d.%d, eNB_id %d, srs_Bandwidth %d, srs_BandwidthConfig %d \n",proc->frame_tx,proc->subframe_tx,eNB_id,Bsrs,Csrs); + LOG_I(PHY," SRS Power Control; AbsSubframe %d.%d, eNB_id %d, N_RB_UL %d, srs_Bandwidth %d, srs_BandwidthConfig %d \n",proc->frame_tx,proc->subframe_tx,eNB_id,pframe_parms->N_RB_UL,Bsrs,Csrs); if (pframe_parms->N_RB_UL < 41) { @@ -88,12 +88,13 @@ void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t PL = get_PL(ue->Mod_id,ue->CC_id,eNB_id); LOG_I(PHY," SRS Power Control; eNB_id %d, p0_NominalPUSCH %d, alpha %d \n",eNB_id,P_opusch,alpha); - LOG_I(PHY," SRS Power Control; eNB_id %d, pSRS_Offset %d, Msrs %d, PL %d, f_pusch %d \n",eNB_id,Psrs_offset,Msrs,PL,f_pusch); + LOG_I(PHY," SRS Power Control; eNB_id %d, pSRS_Offset[dB] %d, Msrs %d, PL %d, f_pusch %d \n",eNB_id,Psrs_offset,Msrs,PL,f_pusch); P_srs = P_opusch + Psrs_offset + f_pusch; P_srs += (((int32_t)alpha * (int32_t)PL) + hundred_times_log10_NPRB[Msrs-1])/100 ; - ue->ulsch[eNB_id]->Po_SRS = P_srs; + ue->ulsch[eNB_id]->Po_SRS = P_srs < ue->tx_power_max_dBm ? P_srs:ue->tx_power_max_dBm; // MIN(PcMax,Psrs) + pnb_rb_srs[0] = Msrs; - LOG_I(PHY," SRS Power Control; eNB_id %d, P_srs[dBm] %d\n",eNB_id,P_srs); + LOG_I(PHY," SRS Power Control; eNB_id %d, P_srs[dBm] %d, P_cmax[dBm] %d, Psrs[dBm] %d\n",eNB_id,P_srs,ue->tx_power_max_dBm,ue->ulsch[eNB_id]->Po_SRS); } From 9938bd5d05e52c1d41b940f5445ae17f2d57d62e Mon Sep 17 00:00:00 2001 From: fnabet Date: Tue, 18 Oct 2016 16:15:49 +0200 Subject: [PATCH 15/60] [OAI-UE] SRS feature 1- Implement SRS procedures 2- Implement SRS procedures part2 3- Implement SRS: SRS valid on CMW --- openair1/PHY/LTE_TRANSPORT/dci.c | 2 +- openair1/PHY/LTE_TRANSPORT/group_hopping.c | 6 ++ openair1/PHY/LTE_TRANSPORT/srs_modulation.c | 70 +++++++++------------ openair1/PHY/impl_defs_lte.h | 5 ++ openair1/SCHED/phy_procedures_lte_ue.c | 42 ++++++++----- openair1/SCHED/srs_pc.c | 26 +++++--- 6 files changed, 86 insertions(+), 65 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index ac081f840b..49966f9910 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -2865,7 +2865,7 @@ void dci_decoding_procedure0(LTE_UE_PDCCH **pdcch_vars, } } - LOG_D(PHY,"DCI decoding CRNTI [format_c: %d, nCCE[subframe: %d]: %d ]\n",format_c, subframe, pdcch_vars[eNB_id]->nCCE[subframe]); + LOG_D(PHY,"DCI decoding CRNTI [format: %d, nCCE[subframe: %d]: %d ], AggregationLevel %d \n",format_c, subframe, pdcch_vars[eNB_id]->nCCE[subframe],L2); // memcpy(&dci_alloc[*dci_cnt].dci_pdu[0],dci_decoded_output,sizeof_bytes); diff --git a/openair1/PHY/LTE_TRANSPORT/group_hopping.c b/openair1/PHY/LTE_TRANSPORT/group_hopping.c index 64c0830386..ed3cb11c08 100644 --- a/openair1/PHY/LTE_TRANSPORT/group_hopping.c +++ b/openair1/PHY/LTE_TRANSPORT/group_hopping.c @@ -50,6 +50,8 @@ void generate_grouphop(LTE_DL_FRAME_PARMS *frame_parms) // This is from Section 5.5.1.3 uint32_t fss_pusch = frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; + uint32_t fss_pucch = frame_parms->Nid_cell; + x2 = frame_parms->Nid_cell/30; #ifdef DEBUG_GROUPHOP printf("[PHY] GroupHop:"); @@ -57,7 +59,10 @@ void generate_grouphop(LTE_DL_FRAME_PARMS *frame_parms) for (ns=0; ns<20; ns++) { if (frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled == 0) + { frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[ns] = fss_pusch%30; + frame_parms->pucch_config_common.grouphop[ns] = fss_pucch%30; + } else { if ((ns&3) == 0) { s = lte_gold_generic(&x1,&x2,reset); @@ -65,6 +70,7 @@ void generate_grouphop(LTE_DL_FRAME_PARMS *frame_parms) } frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[ns] = (((uint8_t*)&s)[ns&3]+fss_pusch)%30; + frame_parms->pucch_config_common.grouphop[ns] = (((uint8_t*)&s)[ns&3]+fss_pucch)%30; } #ifdef DEBUG_GROUPHOP diff --git a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c b/openair1/PHY/LTE_TRANSPORT/srs_modulation.c index cb5d653909..8f2ad8907a 100644 --- a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/srs_modulation.c @@ -137,11 +137,10 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue, LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; - int32_t *txdataF = ue->common_vars.txdataF[0]; + int32_t **txdataF = ue->common_vars.txdataF; uint16_t msrsb=0,Nb=0,nb,b,msrs0=0,k,Msc_RS,Msc_RS_idx,carrier_pos,symbol_offset; uint16_t *Msc_idx_ptr; int32_t k0; - uint32_t T_SFC; uint32_t subframe_offset; uint8_t Bsrs = soundingrs_ul_config_dedicated->srs_Bandwidth; uint8_t Csrs = frame_parms->soundingrs_ul_config_common.srs_BandwidthConfig; @@ -149,6 +148,16 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue, uint8_t n_RRC = soundingrs_ul_config_dedicated->freqDomainPosition; uint8_t kTC = soundingrs_ul_config_dedicated->transmissionComb; + // u is the PUCCH sequence-group number defined in Section 5.5.1.3 + // ν is the base sequence number defined in Section 5.5.1.4 + uint32_t u=frame_parms->pucch_config_common.grouphop[1+(subframe<<1)];; + uint32_t v=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; + + LOG_D(PHY,"SRS root sequence: u %d, v %d\n",u,v); + LOG_D(PHY,"CommonSrsConfig: Csrs %d, Ssrs %d, AnSrsSimultan %d \n",Csrs,Ssrs,frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission); + LOG_D(PHY,"DedicatedSrsConfig: Bsrs %d, bhop %d, nRRC %d, Isrs %d, kTC %d, n_SRS %d\n",Bsrs,soundingrs_ul_config_dedicated->srs_HoppingBandwidth,n_RRC + ,soundingrs_ul_config_dedicated->srs_ConfigIndex,kTC + ,soundingrs_ul_config_dedicated->cyclicShift); if (frame_parms->N_RB_UL < 41) { msrs0 = msrsb_6_40[Csrs][0]; @@ -169,7 +178,7 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue, } Msc_RS = msrsb * 6; - k0 = (((frame_parms->N_RB_UL>>1)-(msrs0>>1))*12) + kTC; + k0 = ( ( (int16_t)(frame_parms->N_RB_UL>>1) - (int16_t)(msrs0>>1) ) * 12 ) + kTC; nb = (4*n_RRC/msrsb)%Nb; for (b=0; b<=Bsrs; b++) { @@ -208,53 +217,32 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue, msg("generate_srs_tx: Msc_RS = %d, Msc_RS_idx = %d\n",Msc_RS, Msc_RS_idx); #endif - T_SFC = (Ssrs<=7 ? 5 : 10); + carrier_pos = (frame_parms->first_carrier_offset + k0); + if (carrier_pos>frame_parms->ofdm_symbol_size) { + carrier_pos -= frame_parms->ofdm_symbol_size; + } + uint16_t nsymb = (frame_parms->Ncp==0) ? 14:12; + symbol_offset = (int)frame_parms->ofdm_symbol_size*((subframe*nsymb)+(nsymb-1)); - if ((1<<(subframe%T_SFC))&transmission_offset_tdd[Ssrs]) { - -#ifndef IFFT_FPGA_UE - carrier_pos = (frame_parms->first_carrier_offset + k0) % frame_parms->ofdm_symbol_size; //msg("carrier_pos = %d\n",carrier_pos); + //subframe_offset = subframe*frame_parms->symbols_per_tti*frame_parms->ofdm_symbol_size; + //symbol_offset = subframe_offset+(frame_parms->symbols_per_tti-1)*frame_parms->ofdm_symbol_size; - subframe_offset = subframe*frame_parms->symbols_per_tti*frame_parms->ofdm_symbol_size; - symbol_offset = subframe_offset+(frame_parms->symbols_per_tti-1)*frame_parms->ofdm_symbol_size; + int32_t *txptr; + txptr = &txdataF[0][symbol_offset]; for (k=0; k>15); - ((short*) txdataF)[2*(symbol_offset + carrier_pos)+1] = (short) (((int32_t) amp * (int32_t) ul_ref_sigs[0][0][Msc_RS_idx][(k<<1)+1])>>15); - carrier_pos+=2; + int32_t real = ((int32_t) amp * (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][k<<1]) >> 15; + int32_t imag = ((int32_t) amp * (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][(k<<1)+1]) >> 15; + txptr[carrier_pos] = (real&0xFFFF) + ((imag<<16)&0xFFFF0000); + + + carrier_pos = carrier_pos+2; if (carrier_pos >= frame_parms->ofdm_symbol_size) - carrier_pos=1; + carrier_pos=carrier_pos-frame_parms->ofdm_symbol_size; } -#else - carrier_pos = (frame_parms->N_RB_UL*12/2 + k0) % (frame_parms->N_RB_UL*12); - //msg("carrier_pos = %d\n",carrier_pos); - - subframe_offset = subframe*frame_parms->symbols_per_tti*frame_parms->N_RB_UL*12; - symbol_offset = subframe_offset+(frame_parms->symbols_per_tti-1)*frame_parms->N_RB_UL*12; - - for (k=0; k= 0) && (ul_ref_sigs[0][0][Msc_RS_idx][(k<<1)+1] >= 0)) - txdataF[symbol_offset+carrier_pos] = (int32_t) 4; - else if ((ul_ref_sigs[0][0][Msc_RS_idx][k<<1] >= 0) && (ul_ref_sigs[0][0][Msc_RS_idx][(k<<1)+1] < 0)) - txdataF[symbol_offset+carrier_pos] = (int32_t) 2; - else if ((ul_ref_sigs[0][0][Msc_RS_idx][k<<1] < 0) && (ul_ref_sigs[0][0][Msc_RS_idx][(k<<1)+1] >= 0)) - txdataF[symbol_offset+carrier_pos] = (int32_t) 3; - else if ((ul_ref_sigs[0][0][Msc_RS_idx][k<<1] < 0) && (ul_ref_sigs[0][0][Msc_RS_idx][(k<<1)+1] < 0)) - txdataF[symbol_offset+carrier_pos] = (int32_t) 1; - - carrier_pos+=2; - - if (carrier_pos >= frame_parms->N_RB_UL*12) - carrier_pos=0; - } - -#endif - // write_output("srs_txF.m","srstxF",&txdataF[symbol_offset],512,1,1); - } - return(0); } diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index 4ec446cd5f..30dbff7b86 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -148,6 +148,11 @@ typedef struct { uint8_t nCS_AN; /// Parameter: \f$N^{(1)}_\text{PUCCH}\f$ see TS 36.213 (10.1). \vr{[0..2047]} uint16_t n1PUCCH_AN; + + /// group hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. + uint8_t grouphop[20]; + /// sequence hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. + uint8_t seqhop[20]; } PUCCH_CONFIG_COMMON; /// UL-ReferenceSignalsPUSCH from 36.331 RRC spec diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 9670df5b4a..f3ed4ec645 100755 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -205,7 +205,6 @@ unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb int gain_dB = power_dBm - power_max_dBm; double gain_lin; - LOG_I(PHY,"Get Tx Amp; Gain[dB]: %d, AMP: %d\n",gain_dB,AMP); if (gain_dB < -20) return(AMP/10); @@ -492,17 +491,19 @@ void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id int frame_tx = proc->frame_tx; int subframe_tx = proc->subframe_tx; uint8_t isSubframeSRS = 0; // SRS Cell Occasion - uint8_t isSubframeSRSTx = 0; // SRS UE Occasion SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; // check for SRS opportunity pSoundingrs_ul_config_dedicated->srsUeSubframe = 0; pSoundingrs_ul_config_dedicated->srsCellSubframe = 0; + + ue->ulsch[eNB_id]->srs_active = 0; + ue->ulsch[eNB_id]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)- ue->ulsch[eNB_id]->srs_active; if(frame_parms->soundingrs_ul_config_common.enabled_flag) { - LOG_I(PHY," SRS SUBFRAMECONFIG: %d, Isrs: %d \n", frame_parms->soundingrs_ul_config_common.srs_SubframeConfig, pSoundingrs_ul_config_dedicated->srs_ConfigIndex); + LOG_D(PHY," SRS SUBFRAMECONFIG: %d, Isrs: %d \n", frame_parms->soundingrs_ul_config_common.srs_SubframeConfig, pSoundingrs_ul_config_dedicated->srs_ConfigIndex); uint8_t TSFC; uint16_t deltaTSFC; // bitmap @@ -536,12 +537,14 @@ void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id isSubframeSRS = 1; pSoundingrs_ul_config_dedicated->srsCellSubframe = 1; } - LOG_I(PHY," ISTDD: %d, TSFC: %d, deltaTSFC: %d, AbsSubframeTX: %d.%d, srsCellSubframe: %d \n", frame_parms->frame_type, TSFC, deltaTSFC, frame_tx, subframe_tx, pSoundingrs_ul_config_dedicated->srsCellSubframe); - + LOG_D(PHY," ISTDD: %d, TSFC: %d, deltaTSFC: %d, AbsSubframeTX: %d.%d, srsCellSubframe: %d \n", frame_parms->frame_type, TSFC, deltaTSFC, frame_tx, subframe_tx, pSoundingrs_ul_config_dedicated->srsCellSubframe); + LOG_D(PHY," SrsDedicatedSetup: %d \n",pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup); if(pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup) { compute_srs_pos(frame_parms->frame_type, pSoundingrs_ul_config_dedicated->srs_ConfigIndex, &srsPeriodicity, &srsOffset); + LOG_D(PHY," srsPeriodicity: %d srsOffset: %d isSubframeSRS %d \n",srsPeriodicity,srsOffset,isSubframeSRS); + // transmit SRS if the four following constraints are respected: // - UE is configured to transmit SRS // - SRS are configured in current subframe @@ -553,11 +556,12 @@ void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id //(! is_pucch_per_cqi_report)) ) { - isSubframeSRSTx = 1; pSoundingrs_ul_config_dedicated->srsUeSubframe = 1; + ue->ulsch[eNB_id]->srs_active = 1; + ue->ulsch[eNB_id]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)- ue->ulsch[eNB_id]->srs_active; } - LOG_I(PHY," isSubframeSRS: %d, isSubframeSRSTx: %d \n", isSubframeSRS, isSubframeSRSTx); } + LOG_D(PHY," srsCellSubframe: %d, srsUeSubframe: %d, Nsymb-pusch: %d \n", pSoundingrs_ul_config_dedicated->srsCellSubframe, pSoundingrs_ul_config_dedicated->srsUeSubframe, ue->ulsch[eNB_id]->Nsymb_pusch); } } @@ -1289,14 +1293,21 @@ void ue_srs_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8 } #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) + if (ue->mac_enabled==1) + { tx_amp = get_tx_amp(Po_SRS, ue->tx_power_max_dBm, ue->frame_parms.N_RB_UL, nb_rb_srs); + } + else + { + tx_amp = AMP; + } #else tx_amp = AMP; #endif - LOG_I(PHY,"SRS PROC; TX_MAX_POWER %d, Po_SRS %d, NB_RB_UL %d, NB_RB_SRS %d TX_AMPL %d\n",ue->tx_power_max_dBm, + LOG_D(PHY,"SRS PROC; TX_MAX_POWER %d, Po_SRS %d, NB_RB_UL %d, NB_RB_SRS %d TX_AMPL %d\n",ue->tx_power_max_dBm, Po_SRS, ue->frame_parms.N_RB_UL, nb_rb_srs, @@ -1323,7 +1334,7 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin int8_t Po_PUCCH; SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; - uint8_t isShortenPucch = pSoundingrs_ul_config_dedicated->srsCellSubframe; + uint8_t isShortenPucch = (pSoundingrs_ul_config_dedicated->srsCellSubframe && frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission); bundling_flag = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; @@ -1397,9 +1408,10 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin #endif if (SR_payload>0) { - LOG_I(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 1a/1b payload %d,%d (with SR for PUSCH), shorten_pucch %d, n1_pucch %d, Po_PUCCH, amp %d\n", + LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 1a/1b payload %d,%d (with SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH, amp %d\n", Mod_id, ue->dlsch[eNB_id][0]->rnti, + frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, isShortenPucch, frame_tx, subframe_tx, pucch_ack_payload[0],pucch_ack_payload[1], @@ -1407,10 +1419,11 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin Po_PUCCH, tx_amp); } else { - LOG_I(PHY,"[UE %d][PDSCH %x] Frame %d subframe %d Generating PUCCH 1a/1b, shorten_pucch %d, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n", + LOG_D(PHY,"[UE %d][PDSCH %x] Frame %d subframe %d Generating PUCCH 1a/1b, an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n", Mod_id, ue->dlsch[eNB_id][0]->rnti, frame_tx, subframe_tx, + frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, isShortenPucch, n1_pucch,pucch_ack_payload[0],pucch_ack_payload[1],SR_payload, Po_PUCCH, @@ -1460,10 +1473,11 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin #else tx_amp = AMP; #endif - LOG_I(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 1 (SR for PUSCH), shorten_pucch %d, n1_pucch %d, Po_PUCCH %d\n", + LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 1 (SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d\n", Mod_id, ue->dlsch[eNB_id][0]->rnti, frame_tx, subframe_tx, + frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, isShortenPucch, ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex, Po_PUCCH); @@ -1526,14 +1540,14 @@ void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,ui } if (ue->UE_mode[eNB_id] != PRACH) { + // check cell srs subframe and ue srs subframe. This has an impact on pusch encoding + ue_compute_srs_occasion(ue,proc,eNB_id); ue_ulsch_uespec_procedures(ue,proc,eNB_id,abstraction_flag); } if (ue->UE_mode[eNB_id] == PUSCH) { - // check cell srs subframe and ue srs subframe - ue_compute_srs_occasion(ue,proc,eNB_id); // check if we need to use PUCCH 1a/1b ue_pucch_procedures(ue,proc,eNB_id,abstraction_flag); // check if we need to use SRS diff --git a/openair1/SCHED/srs_pc.c b/openair1/SCHED/srs_pc.c index 3ec5f00f9a..461d230975 100644 --- a/openair1/SCHED/srs_pc.c +++ b/openair1/SCHED/srs_pc.c @@ -46,7 +46,8 @@ void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t { int16_t PL; - int8_t P_opusch; + int8_t p0_NominalPUSCH; + int8_t p0_UE_PUSCH; int8_t Psrs_offset; int16_t P_srs; int16_t f_pusch; @@ -59,7 +60,7 @@ void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t uint8_t Bsrs = psoundingrs_ul_config_dedicated->srs_Bandwidth; uint8_t Csrs = pframe_parms->soundingrs_ul_config_common.srs_BandwidthConfig; - LOG_I(PHY," SRS Power Control; AbsSubframe %d.%d, eNB_id %d, N_RB_UL %d, srs_Bandwidth %d, srs_BandwidthConfig %d \n",proc->frame_tx,proc->subframe_tx,eNB_id,pframe_parms->N_RB_UL,Bsrs,Csrs); + LOG_D(PHY," SRS Power Control; AbsSubframe %d.%d, eNB_id %d, N_RB_UL %d, srs_Bandwidth %d, srs_BandwidthConfig %d \n",proc->frame_tx,proc->subframe_tx,eNB_id,pframe_parms->N_RB_UL,Bsrs,Csrs); if (pframe_parms->N_RB_UL < 41) { @@ -81,20 +82,27 @@ void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t // SRS Power control 36.213 5.1.3.1 // P_srs = P_srs_offset+ 10log10(Msrs) + P_opusch(j) + alpha*PL + f(i)) - Psrs_offset = (ue->ul_power_control_dedicated[eNB_id].pSRS_Offset - 3); - P_opusch = ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; + p0_NominalPUSCH = ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; + p0_UE_PUSCH = ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH; + Psrs_offset = (ue->ul_power_control_dedicated[eNB_id].pSRS_Offset - 3); + + f_pusch = ue->ulsch[eNB_id]->f_pusch; alpha = alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]; PL = get_PL(ue->Mod_id,ue->CC_id,eNB_id); - LOG_I(PHY," SRS Power Control; eNB_id %d, p0_NominalPUSCH %d, alpha %d \n",eNB_id,P_opusch,alpha); - LOG_I(PHY," SRS Power Control; eNB_id %d, pSRS_Offset[dB] %d, Msrs %d, PL %d, f_pusch %d \n",eNB_id,Psrs_offset,Msrs,PL,f_pusch); + LOG_D(PHY," SRS Power Control; eNB_id %d, p0_NominalPUSCH %d, p0_UE_PUSCH %d, alpha %d \n",eNB_id,p0_NominalPUSCH,p0_UE_PUSCH,alpha); + LOG_D(PHY," SRS Power Control; eNB_id %d, pSRS_Offset[dB] %d, Msrs %d, PL %d, f_pusch %d \n",eNB_id,Psrs_offset,Msrs,PL,f_pusch); - P_srs = P_opusch + Psrs_offset + f_pusch; + P_srs = (p0_NominalPUSCH + p0_UE_PUSCH) + Psrs_offset + f_pusch; P_srs += (((int32_t)alpha * (int32_t)PL) + hundred_times_log10_NPRB[Msrs-1])/100 ; - ue->ulsch[eNB_id]->Po_SRS = P_srs < ue->tx_power_max_dBm ? P_srs:ue->tx_power_max_dBm; // MIN(PcMax,Psrs) + ue->ulsch[eNB_id]->Po_SRS = P_srs; + if(ue->ulsch[eNB_id]->Po_SRS > ue->tx_power_max_dBm) + { + ue->ulsch[eNB_id]->Po_SRS = ue->tx_power_max_dBm; + } pnb_rb_srs[0] = Msrs; - LOG_I(PHY," SRS Power Control; eNB_id %d, P_srs[dBm] %d, P_cmax[dBm] %d, Psrs[dBm] %d\n",eNB_id,P_srs,ue->tx_power_max_dBm,ue->ulsch[eNB_id]->Po_SRS); + LOG_D(PHY," SRS Power Control; eNB_id %d, Psrs_pc[dBm] %d, Pcmax[dBm] %d, Psrs[dBm] %d\n",eNB_id,P_srs,ue->tx_power_max_dBm,ue->ulsch[eNB_id]->Po_SRS); } From d8defff0fa8c2fe29c3d98b48fd1fc2b28cb0095 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 20 Oct 2016 06:32:33 -0700 Subject: [PATCH 16/60] periodic cqi procedures --- openair1/PHY/INIT/lte_init.c | 31 ++- openair1/PHY/LTE_TRANSPORT/proto.h | 18 ++ openair1/PHY/LTE_TRANSPORT/pucch.c | 14 +- openair1/PHY/LTE_TRANSPORT/uci_tools.c | 2 + openair1/PHY/impl_defs_lte.h | 14 +- openair1/SCHED/defs.h | 4 + openair1/SCHED/phy_procedures_lte_ue.c | 244 +++++++++++++++++- .../LAYER2/MAC/eNB_scheduler_primitives.c | 2 +- 8 files changed, 317 insertions(+), 12 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 3fb1d0c26b..268e2dcabd 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -742,7 +742,8 @@ void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, phy_vars_ue->dlsch_received_last[eNB_id]=0; phy_vars_ue->dlsch_fer[eNB_id]=0; - + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; if (physicalConfigDedicated) { LOG_D(PHY,"[UE %d] Received physicalConfigDedicated from eNB %d\n",Mod_id, eNB_id); @@ -852,6 +853,31 @@ void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, } + if (physicalConfigDedicated->cqi_ReportConfig) { + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic) { + // configure PUSCH CQI reporting + phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic; + if ((phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm12) && + (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm30) && + (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm31)) + LOG_E(PHY,"Unsupported Aperiodic CQI Feedback Mode : %d\n",phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic); + } + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic) { + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_setup) { + // configure PUCCH CQI reporting + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex; + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex; + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex) + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex; + } + else if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_release) { + // handle release + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; + } + } + } + #ifdef CBA if (physicalConfigDedicated->pusch_CBAConfigDedicated_vlola) { @@ -868,6 +894,9 @@ void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, return; } + // fill cqi parameters for periodic CQI reporting + get_cqipmiri_params(phy_vars_ue,eNB_id); + } void phy_config_cba_rnti (module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uint8_t index, rnti_t cba_rnti, uint8_t cba_group_id, uint8_t num_active_cba_groups) diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 86bc3723af..7906d4bdd2 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -1445,6 +1445,9 @@ int32_t generate_ue_ulsch_params_from_rar(PHY_VARS_UE *phy_vars_ue, uint8_t eNB_id); double sinr_eff_cqi_calc(PHY_VARS_UE *phy_vars_ue, uint8_t eNB_id); + +uint8_t sinr2cqi(double sinr,uint8_t trans_mode); + int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *PHY_vars_eNB, eNB_rxtx_proc_t *proc, void *dci_pdu, @@ -1712,6 +1715,21 @@ void generate_pucch1x(int32_t **txdataF, int16_t amp, uint8_t subframe); +void generate_pucch2x(int32_t **txdataF, + LTE_DL_FRAME_PARMS *fp, + uint8_t ncs_cell[20][7], + PUCCH_FMT_t fmt, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint16_t n2_pucch, + uint8_t shortened_format, + uint16_t *payload, + int A, + int B2, + int16_t amp, + uint8_t subframe, + uint16_t rnti); + + void generate_pucch_emul(PHY_VARS_UE *phy_vars_ue, UE_rxtx_proc_t *proc, PUCCH_FMT_t format, diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index c0c54b9782..8ecde3747b 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -460,10 +460,13 @@ inline void pucch2x_modulation(uint8_t *btilde,int16_t *d,int16_t amp) { } + + uint32_t pucch_code[13] = {0xFFFFF,0x5A933,0x10E5A,0x6339C,0x73CE0, 0xFFC00,0xD8E64,0x4F6B0,0x218EC,0x1B746, 0x0FFFF,0x33FFF,0x3FFFC}; + void generate_pucch2x(int32_t **txdataF, LTE_DL_FRAME_PARMS *fp, uint8_t ncs_cell[20][7], @@ -471,7 +474,7 @@ void generate_pucch2x(int32_t **txdataF, PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, uint16_t n2_pucch, uint8_t shortened_format, - uint32_t *payload, + uint16_t *payload, int A, int B2, int16_t amp, @@ -559,10 +562,13 @@ void generate_pucch2x(int32_t **txdataF, nprime = (n2_pucch < 12*NRB2) ? n2_pucch % 12 : (n2_pucch+Ncs1 + 1)%12; - else + else { nprime = (n2_pucch < 12*NRB2) ? ((12*(nprime+1)) % 13)-1 : (10-n2_pucch)%12; + if (shortened_format == 1) + N_UL_symb--; + } //loop over symbols in slot for (l=0; lcqi_report_config[eNB_id].CQI_ReportPeriodic; + int cqi_PMI_ConfigIndex = cqirep->cqi_PMI_ConfigIndex; + + if (ue->frame_parms.frame_type == FDD) { + if (cqi_PMI_ConfigIndex <= 1) { // 2 ms CQI_PMI period + cqirep->Npd = 2; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex; + } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period + cqirep->Npd = 5; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-1; + } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period + cqirep->Npd = 10; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-6; + } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period + cqirep->Npd = 20; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-16; + } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period + cqirep->Npd = 40; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-36; + } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period + cqirep->Npd = 80; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-76; + } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period + cqirep->Npd = 160; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-156; + } + else if (cqi_PMI_ConfigIndex > 317) { + + if (cqi_PMI_ConfigIndex <= 349) { // 32 ms CQI_PMI period + cqirep->Npd = 32; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-316; + } + else if (cqi_PMI_ConfigIndex <= 413) { // 64 ms CQI_PMI period + cqirep->Npd = 64; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-349; + } + else if (cqi_PMI_ConfigIndex <= 541) { // 128 ms CQI_PMI period + cqirep->Npd = 128; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-413; + } + } + } + else { // TDD + if (cqi_PMI_ConfigIndex == 0) { // all UL subframes + cqirep->Npd = 1; + cqirep->N_OFFSET_CQI = 0; + } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period + cqirep->Npd = 5; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-1; + } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period + cqirep->Npd = 10; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-6; + } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period + cqirep->Npd = 20; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-16; + } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period + cqirep->Npd = 40; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-36; + } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period + cqirep->Npd = 80; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-76; + } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period + cqirep->Npd = 160; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-156; + } + } +} + +uint8_t is_cqi_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) +{ + int subframe = proc->subframe_tx; + int frame = proc->frame_tx; + CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic; + + LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d Checking for CQI TXOp (cqi_ConfigIndex %d)\n", + ue->Mod_id,ue->pdcch_vars[eNB_id]->crnti,frame,subframe, + cqirep->cqi_PMI_ConfigIndex); + + if (((10*frame + subframe) % cqirep->Npd) == cqirep->N_OFFSET_CQI) + return(1); + else + return(0); +} +uint8_t is_ri_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) +{ + + + int subframe = proc->subframe_tx; + int frame = proc->frame_tx; + CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic; + int log2Mri = cqirep->ri_ConfigIndex/161; + int N_OFFSET_RI = cqirep->ri_ConfigIndex % 161; + + LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d Checking for RI TXOp (ri_ConfigIndex %d)\n", + ue->Mod_id,ue->pdcch_vars[eNB_id]->crnti,frame,subframe, + cqirep->ri_ConfigIndex); + + if (((10*frame + subframe + cqirep->N_OFFSET_CQI - N_OFFSET_RI) % (cqirep->Npd<transmission_mode[eNB_id]<4)|| + (ue->transmission_mode[eNB_id]==7)) { // Mode 1-0 feedback + // 4-bit CQI message + *len=4; + return(sinr2cqi((double)ue->measurements.wideband_cqi_avg[eNB_id], + ue->transmission_mode[eNB_id])); + } + else { // Mode 1-1 feedback, later + *len=0; + // 2-antenna ports RI=1, 6 bits (2 PMI, 4 CQI) + + // 2-antenna ports RI=2, 8 bits (1 PMI, 7 CQI/DIFF CQI) + return(0); + } +} + + +int16_t get_pucch2_ri(PHY_VARS_UE *ue,int eNB_id) { + + return(1); +} + void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { uint8_t pucch_ack_payload[2]; - uint8_t n1_pucch; + uint8_t n1_pucch,n2_pucch; ANFBmode_t bundling_flag; PUCCH_FMT_t format; + uint8_t SR_payload; + uint16_t CQI_payload; + uint16_t RI_payload; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int frame_tx=proc->frame_tx; int subframe_tx=proc->subframe_tx; @@ -1210,7 +1344,7 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin #endif } } else if (SR_payload==1) { // no ACK/NAK but SR is triggered by MAC - + if (ue->mac_enabled == 1) { Po_PUCCH = pucch_power_cntl(ue,proc,subframe_tx,eNB_id,pucch_format1); } @@ -1258,6 +1392,107 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin } } // SR_Payload==1 + + // PUCCH 2x + + if (ue->generate_ul_signal[eNB_id] == 0) { // we have not generated ACK/NAK/SR in this subframe + + n2_pucch = ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex; + // only use format2 for now, i.e. now ACK/NAK - CQI multiplexing + format = pucch_format2; + + // Periodic CQI report + if ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0)&& + (is_cqi_TXOp(ue,proc,eNB_id)==1)){ + + if (ue->mac_enabled == 1) { + Po_PUCCH = pucch_power_cntl(ue,proc,subframe_tx,eNB_id,format); + } + else { + Po_PUCCH = ue->tx_power_max_dBm; + } + ue->tx_power_dBm[subframe_tx] = Po_PUCCH; + ue->tx_total_RE[subframe_tx] = 12; + +#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) + tx_amp = get_tx_amp(Po_PUCCH, + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + 1); +#else + tx_amp = AMP; +#endif + LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 2 (CQI), n2_pucch %d, Po_PUCCH %d\n", + Mod_id, + ue->dlsch[eNB_id][0]->rnti, + frame_tx, subframe_tx, + n2_pucch, + Po_PUCCH); + + int len; + // get the payload : < 12 bits, returned in len + CQI_payload = get_pucch2_cqi(ue,eNB_id,&len); + generate_pucch2x(ue->common_vars.txdataF, + &ue->frame_parms, + ue->ncs_cell, + format, + &ue->pucch_config_dedicated[eNB_id], + n2_pucch, + 1, // shortened format + &CQI_payload, + len, // A + 0, // B2 not needed + tx_amp, + subframe_tx, + ue->pdcch_vars[eNB_id]->crnti); + + } + // Periodic RI report + else if ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0) && + (is_ri_TXOp(ue,proc,eNB_id)==1)){ + + if (ue->mac_enabled == 1) { + Po_PUCCH = pucch_power_cntl(ue,proc,subframe_tx,eNB_id,format); + } + else { + Po_PUCCH = ue->tx_power_max_dBm; + } + ue->tx_power_dBm[subframe_tx] = Po_PUCCH; + ue->tx_total_RE[subframe_tx] = 12; + +#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) + tx_amp = get_tx_amp(Po_PUCCH, + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + 1); +#else + tx_amp = AMP; +#endif + LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d Generating PUCCH 2 (RI), n2_pucch %d, Po_PUCCH %d\n", + Mod_id, + ue->dlsch[eNB_id][0]->rnti, + frame_tx, subframe_tx, + n2_pucch, + Po_PUCCH); + + RI_payload = get_pucch2_ri(ue,eNB_id); + + generate_pucch2x(ue->common_vars.txdataF, + &ue->frame_parms, + ue->ncs_cell, + format, + &ue->pucch_config_dedicated[eNB_id], + n2_pucch, + 1, // shortened format + &RI_payload, + 1, // A + 0, // B2 not needed + tx_amp, + subframe_tx, + ue->pdcch_vars[eNB_id]->crnti); + + } + } } void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type) { @@ -1299,7 +1534,10 @@ void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,ui } if (ue->UE_mode[eNB_id] == PUSCH) { // check if we need to use PUCCH 1a/1b - ue_pucch_procedures(ue,proc,eNB_id,abstraction_flag); + + ue_pucch_procedures(ue,proc,eNB_id,abstraction_flag); + + } // UE_mode==PUSCH diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 7946fdf663..2107ad0f9a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -1006,7 +1006,7 @@ void dump_CCE_table(int *CCE_table,const int nCCE,const unsigned short rnti,cons for (i=0;i Date: Fri, 21 Oct 2016 18:26:50 +0800 Subject: [PATCH 17/60] modify BSR code according comments --- openair2/LAYER2/MAC/config.c | 2 +- openair2/LAYER2/MAC/defs.h | 2 +- openair2/LAYER2/MAC/proto.h | 4 +- openair2/LAYER2/MAC/ra_procedures.c | 2 +- openair2/LAYER2/MAC/ue_procedures.c | 206 ++++++++++++---------------- 5 files changed, 90 insertions(+), 126 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 030ac7a9f3..90889d6381 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -233,7 +233,7 @@ rrc_mac_config_req( if (mac_MainConfig->ext1 && mac_MainConfig->ext1->sr_ProhibitTimer_r9) { UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) *mac_MainConfig->ext1->sr_ProhibitTimer_r9; } else { - UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) 0; + UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = 0; } if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) { diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 4edfef1677..8f0d4f5951 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -941,7 +941,7 @@ typedef enum { typedef struct { /// buffer status for each lcgid uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology - /// keep the number of bytes in rlc buffer for each lcid + /// keep the number of bytes in rlc buffer for each lcgid uint16_t BSR_bytes[MAX_NUM_LCGID]; /// buffer status for each lcid uint8_t LCID_status[MAX_NUM_LCID]; diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 4133d6a2eb..0bc3eb00ec 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -548,7 +548,7 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 \param[in] Mod_id instance of the UE \param[out] lcgid */ -int get_bsr_lcgid (module_id_t module_idP, int *num_lcgid); +int get_bsr_lcgid (module_id_t module_idP); /*! \fn uint8_t get_bsr_len (module_id_t module_idP,uint16_t bufflen); \brief determine whether the bsr is short or long assuming that the MAC pdu is built @@ -556,7 +556,7 @@ int get_bsr_lcgid (module_id_t module_idP, int *num_lcgid); \param[in] bufflen size of phy transport block \param[out] bsr_len size of bsr control element */ -uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen); +uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen); /*! \fn BSR_SHORT * get_bsr_short(module_id_t module_idP, uint8_t bsr_len) \brief get short bsr level diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 669077bf4f..e60dfc6292 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -399,7 +399,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, 1); //post_padding return(&UE_mac_inst[module_idP].RA_prach_resources); - } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DCCH] > 0) { + } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > 0) { // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 6fc95f55d5..97b7e433c4 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -133,7 +133,7 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1; } - UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=0; + UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=LCID_EMPTY; } #ifdef CBA @@ -1202,10 +1202,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf uint8_t payload_offset=0,num_sdus=0; uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; uint16_t sdu_length_total=0; - BSR_SHORT bsr_short,bsr_truncated; + BSR_SHORT bsr_short; BSR_LONG bsr_long; BSR_SHORT *bsr_s=&bsr_short; - BSR_SHORT *bsr_t=&bsr_truncated; BSR_LONG *bsr_l=&bsr_long; POWER_HEADROOM_CMD phr; POWER_HEADROOM_CMD *phr_p=&phr; @@ -1214,7 +1213,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf int j; // used for padding // Compute header length int all_pdu_len; - int num_lcgid=0; if (CC_id>0) { LOG_E(MAC,"Transmission on secondary CCs is not supported yet\n"); @@ -1249,18 +1247,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len=(buflen > 128 ) ? 3 : 2 ; //sizeof(SCH_SUBHEADER_LONG)-1 : sizeof(SCH_SUBHEADER_SHORT); bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); - phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; - if (phr_ce_len > 0) { - phr_len = phr_ce_len + phr_header_len; - LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", - module_idP, phr_len, phr_ce_len, phr_header_len, buflen); - } else { - phr_len=0; - } - - bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len); - // retxBSR-Timer expires or periodicBSR-Timer expires and UE has data available for transmission + bsr_ce_len = get_bsr_len (module_idP, eNB_index, frameP, buflen); + // retxBSR-Timer expires or periodicBSR-Timer expires and Regular BSR trigger if ((bsr_ce_len > 0 ) && (UE_mac_inst[module_idP].BSR_reporting_active > 0)) { bsr_len = bsr_ce_len + bsr_header_len; LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n", @@ -1272,6 +1261,15 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf //bsr_len = bsr_ce_len + bsr_header_len; } + phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; + if (phr_ce_len > 0) { + phr_len = phr_ce_len + phr_header_len; + LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", + module_idP, phr_len, phr_ce_len, phr_header_len, buflen); + } else { + phr_len=0; + } + // check for UL bandwidth requests and add SR control element // check for UL bandwidth requests and add SR control element @@ -1305,8 +1303,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_lcids[0] = DCCH; LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); num_sdus = 1; - update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); + //update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); //header_len +=2; + UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] = LCID_EMPTY; } else { dcch_header_len=0; num_sdus = 0; @@ -1345,6 +1344,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf num_sdus++; //update_bsr(module_idP, frameP, DCCH1); //dcch_header_len +=2; // include dcch1 + UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] = LCID_EMPTY; } else { dcch1_header_len =0; } @@ -1379,7 +1379,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[%d] %d)\n", module_idP,frameP, lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len, - lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcid]); + lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); if (rlc_status.bytes_in_buffer > 0) { sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, @@ -1400,62 +1400,54 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len_last --; } num_sdus++; - UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); + //UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); } else { dtch_header_len -= 3; } + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; } else { // no rlc pdu : generate the dummy header dtch_header_len -= 3; } } - lcgid= get_bsr_lcgid(module_idP, &num_lcgid); + lcgid= get_bsr_lcgid(module_idP); - if (num_lcgid == 0 ) { + if (lcgid < 0 ) { bsr_s = NULL; - bsr_t = NULL; + bsr_l = NULL ; + } else if ((lcgid ==MAX_NUM_LCGID) && (bsr_ce_len == sizeof(BSR_LONG))) { + bsr_s = NULL; + bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; + bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; + bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; + bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; + + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID0] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID1] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID2] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID3] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] = 0; + + LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); + } else if (bsr_ce_len == sizeof(BSR_SHORT)) { bsr_l = NULL; - } else if (num_lcgid == 1){ - if (bsr_ce_len == sizeof(BSR_SHORT)){ - bsr_l = NULL; - bsr_t = NULL; - bsr_s->LCGID = lcgid; - bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; - LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", - module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); - } else { - bsr_s = NULL; - bsr_t = NULL; - bsr_l = NULL; - } - } else if (num_lcgid > 1) { - if (bsr_ce_len == sizeof(BSR_LONG)){ - bsr_t = NULL; - bsr_s = NULL; - bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; - bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; - bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; - bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; - LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); - } else if (bsr_ce_len == sizeof(BSR_SHORT)){ - bsr_l = NULL; - bsr_s = NULL; - bsr_t->LCGID = lcgid; - bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; - LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", + bsr_s->LCGID = lcgid; + bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; + + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; + + LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); - } else { - bsr_s = NULL; - bsr_t = NULL; - bsr_l = NULL; - } } else { bsr_s = NULL; - bsr_t = NULL; bsr_l = NULL; } @@ -1517,7 +1509,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_lcids, // sdu lcid phr_p, // power headroom NULL, // crnti - bsr_t, // truncated bsr + NULL, // truncated bsr bsr_s, // short bsr bsr_l, post_padding); // long_bsr @@ -1719,7 +1711,7 @@ ue_scheduler( } // Get RLC status info and update Bj for all lcids that are active - for (lcid=DCCH; lcid <= DTCH; lcid++ ) { + for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++ ) { if ((lcid == 0) ||(UE_mac_inst[module_idP].logicalChannelConfig[lcid])) { // meausre the Bj if ((directionP == SF_UL)&& (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) { @@ -1740,6 +1732,8 @@ ue_scheduler( if (update_bsr(module_idP,frameP, eNB_indexP, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) { UE_mac_inst[module_idP].scheduling_info.SR_pending= 1; + // Regular BSR trigger + UE_mac_inst[module_idP].BSR_reporting_active = 1; LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d SR for PUSCH is pending for LCGID %d with BSR level %d (%d bytes in RLC)\n", module_idP, frameP,subframeP,UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], @@ -1960,75 +1954,49 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 } #endif -int get_bsr_lcgid (module_id_t module_idP, int *num_lcgid) +int get_bsr_lcgid (module_id_t module_idP) { int lcgid, lcgid_tmp=-1; int num_active_lcgid = 0; for (lcgid = 0 ; lcgid < MAX_NUM_LCGID; lcgid++) { if (UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] > 0 ) { - if (lcgid_tmp == -1){ - // first priority lcgid - lcgid_tmp = lcgid; - } + lcgid_tmp = lcgid; num_active_lcgid+=1; } } - *num_lcgid = num_active_lcgid; - + if (num_active_lcgid == 0) { - return -1; // no data + return -1; + } else if (num_active_lcgid == 1) { + return lcgid_tmp; } else { - return lcgid_tmp;//only one lcgid, report short bsr + return MAX_NUM_LCGID; } } -uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) +uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen) { - int lcgid=0; - uint8_t bsr_len=0, num_lcgid=0; + int lcid; + uint8_t bsr_len=0, num_lcid=0; int pdu = 0; - int long_bsr_plus_subheader_length = sizeof(BSR_LONG)+sizeof(SCH_SUBHEADER_FIXED); - int short_bsr_plus_subheader_length = sizeof(BSR_SHORT)+sizeof(SCH_SUBHEADER_FIXED); + mac_rlc_status_resp_t rlc_status; - // check how many lcg have data to report - for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) { - num_lcgid ++; - pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + sizeof(SCH_SUBHEADER_SHORT)); + for (lcid=DCCH; lcid 0 ) { + pdu += rlc_status.bytes_in_buffer + sizeof(SCH_SUBHEADER_SHORT) + bsr_len; + if (rlc_status.bytes_in_buffer > 128 ) { + pdu += 1; //sizeof(SCH_SUBHEADER_LONG) + } } - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) { // long header size: adjust the header size - pdu += 1; - } - LOG_D(MAC,"BSR Bytes %d for lcgid %d num lcgid %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid], lcgid, num_lcgid); - } - // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid - if (buflen < pdu) { - if (num_lcgid > 0) { - bsr_len = sizeof(BSR_SHORT); - } else { - bsr_len = 0; - } - } - // padding larger then long bsr - if (buflen > (pdu + long_bsr_plus_subheader_length)) { - if (num_lcgid > 1) { - bsr_len = sizeof(BSR_LONG); - } else if (num_lcgid > 0) { - bsr_len = sizeof(BSR_SHORT); - } else { - bsr_len = 0; - } - } - // padding larger then short bsr and shorter then long bsr - if ((buflen < (pdu + long_bsr_plus_subheader_length)) && - (buflen > (pdu + short_bsr_plus_subheader_length))) { - if (num_lcgid > 0) { - bsr_len = sizeof(BSR_SHORT); - } else { - bsr_len = 0; + if ( (pdu > buflen) && (rlc_status.bytes_in_buffer > 0 ) ) { + num_lcid +=1; + bsr_len = (num_lcid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; } + LOG_D(MAC,"LC buffer Bytes %d for lcid %d bsr len %d num lcid %d\n", rlc_status.bytes_in_buffer, lcid, bsr_len, num_lcid); } + if ( bsr_len > 0 ) LOG_D(MAC,"[UE %d] Prepare a %s (Transport Block Size %d, MAC pdu Size %d) \n", module_idP, map_int_to_str(BSR_names, bsr_len), buflen, pdu); @@ -2036,16 +2004,15 @@ uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) return bsr_len; } - boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcg_id) { mac_rlc_status_resp_t rlc_status; - boolean_t Bsr_pending = FALSE; + boolean_t sr_pending = FALSE; if ((lcg_id < 0) || (lcg_id >= MAX_NUM_LCGID) ) { - return Bsr_pending; + return sr_pending; } // fixme: need a better way to reset @@ -2062,14 +2029,11 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in if (rlc_status.bytes_in_buffer > 0 ) { //BSR trigger SR - Bsr_pending = TRUE; + sr_pending = TRUE; UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] = rlc_status.bytes_in_buffer; - if (UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10 == TRUE){ - UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(Extended_BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); - } else { - UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); - } + // sum lcid buffer which has same lcgid + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer; + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); @@ -2079,7 +2043,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in } //} - return Bsr_pending; + return sr_pending; } uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value) From 15e299bd114bc7ec181793834f5a6d6a486387c7 Mon Sep 17 00:00:00 2001 From: fnabet Date: Fri, 21 Oct 2016 15:09:42 +0200 Subject: [PATCH 18/60] [OAI-UE] Authetification XOR Algo for usim test --- openair2/RRC/LITE/MESSAGES/asn1_msg.c | 6 +- openair3/NAS/TOOLS/usim_data.c | 1 + openair3/NAS/UE/API/USIM/usim_api.c | 193 +++++++++++++++++- openair3/NAS/UE/API/USIM/usim_api.h | 5 + openair3/NAS/UE/EMM/Authentication.c | 11 +- .../UE/EMM/SAP/EmmDeregisteredNormalService.c | 10 +- openair3/NAS/UE/EMM/emm_main.c | 2 + targets/RT/USER/lte-softmodem.c | 7 + 8 files changed, 231 insertions(+), 4 deletions(-) diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index e0556b92bf..3fe10c92f8 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -117,6 +117,7 @@ typedef struct xer_sprint_string_s { } xer_sprint_string_t; extern unsigned char NB_eNB_INST; +extern uint8_t usim_test; uint16_t two_tier_hexagonal_cellIds[7] = {0,1,2,4,5,7,8}; uint16_t two_tier_hexagonal_adjacent_cellIds[7][6] = {{1,2,4,5,7,8}, // CellId 0 @@ -1268,7 +1269,10 @@ uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uin rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension=CALLOC(1, sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension)); - rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity=2; + if(usim_test == 0) + rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 2; + else + rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 1; rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME = NULL;//calloc(1,sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME)); diff --git a/openair3/NAS/TOOLS/usim_data.c b/openair3/NAS/TOOLS/usim_data.c index 1835f0b8b1..126ff4f78c 100644 --- a/openair3/NAS/TOOLS/usim_data.c +++ b/openair3/NAS/TOOLS/usim_data.c @@ -227,6 +227,7 @@ int main (int argc, const char* argv[]) usim_data.imsi.u.num.digit13 = 3; usim_data.imsi.u.num.digit14 = 4; usim_data.imsi.u.num.digit15 = 0xF; + usim_data.usimtestmode = 1; // set usim in test mode in order to get the CMW500 K key #endif /* * Ciphering and Integrity Keys diff --git a/openair3/NAS/UE/API/USIM/usim_api.c b/openair3/NAS/UE/API/USIM/usim_api.c index b0ccbf9504..df7d22db8e 100644 --- a/openair3/NAS/UE/API/USIM/usim_api.c +++ b/openair3/NAS/UE/API/USIM/usim_api.c @@ -79,6 +79,7 @@ Description Implements the API used by the NAS layer to read/write #define USIM_API_K_SIZE 16 //#define USIM_API_K_VALUE "fec86ba6eb707ed08905757b1bb44b8f" #define USIM_API_K_VALUE "8BAF473F2F8FD09487CCCBD7097C6862" +#define TEST_USIM_API_K_VALUE "000102030405060708090a0b0c0d0e0f" // CMW500 K key static uint8_t _usim_api_k[USIM_API_K_SIZE]; @@ -143,7 +144,14 @@ int usim_api_read(usim_data_t* data) } /* initialize the subscriber authentication security key */ - _usim_api_hex_string_to_hex_value(_usim_api_k, USIM_API_K_VALUE, USIM_API_K_SIZE); + if(data->usimtestmode == 0) + { + _usim_api_hex_string_to_hex_value(_usim_api_k, USIM_API_K_VALUE, USIM_API_K_SIZE); + } + else + { + _usim_api_hex_string_to_hex_value(_usim_api_k, TEST_USIM_API_K_VALUE, USIM_API_K_SIZE); + } free(path); LOG_FUNC_RETURN (RETURNok); @@ -188,6 +196,189 @@ int usim_api_write(const usim_data_t* data) LOG_FUNC_RETURN (RETURNok); } +/**************************************************************************** + ** ** + ** Name: usim_api_authenticate_test() ** + ** ** + ** Description: Performs mutual authentication of the USIM to the network,** + ** checking whether authentication token AUTN can be accep- ** + ** ted. If so, returns an authentication response RES and ** + ** the ciphering and integrity keys. ** + ** In case of synch failure, returns a re-synchronization ** + ** token AUTS. ** + ** ** + ** Key Generation for Test USIM based on 34.108 ** + ** ** + ** Authentication and key generating function algorithms are ** + ** specified in 3GPP TS 35.206. ** + ** ** + ** Inputs: rand_pP: Random challenge number ** + ** autn_pP: Authentication token ** + ** AUTN = (SQN xor AK) || AMF || MAC ** + ** 48 16 64 bits ** + ** Others: Security key ** + ** ** + ** Outputs: auts_pP: Re-synchronization token ** + ** res_pP: Authentication response ** + ** ck_pP: Ciphering key ** + ** ik_pP Integrity key ** + ** ** + ** Return: RETURNerror, RETURNok ** + ** Others: None ** + ** ** + ***************************************************************************/ +int usim_api_authenticate_test(const OctetString* rand_pP, const OctetString* autn_pP, + OctetString* auts_pP, OctetString* res_pP, + OctetString* ck_pP, OctetString* ik_pP) +{ + LOG_FUNC_IN; + + int rc; + int i; + + LOG_TRACE(INFO, "USIM-API - rand :%s",dump_octet_string(rand_pP)); + LOG_TRACE(INFO, "USIM-API - autn :%s",dump_octet_string(autn_pP)); + + //step1: XDOUT = RAND xor K + // RES = XDOUT + for (i=0; ivalue[i] = rand_pP->value[i] ^ _usim_api_k[i]; + } + + //step2: res = f2(xdout,n) + // ck = f3(xdout) + // ik = f4(xdout) + // ak = f5(xdout) + u8 ak[USIM_API_AK_SIZE]; + for (i=0; i<15; i++) + { + ck_pP->value[i] = res_pP->value[i+1]; + } + ck_pP->value[15] = res_pP->value[0]; + + for (i=0; i<14; i++) + { + ik_pP->value[i] = res_pP->value[i+2]; + } + ik_pP->value[14] = res_pP->value[0]; + ik_pP->value[15] = res_pP->value[1]; + + for (i=0; ivalue[i+3]; + } + LOG_TRACE(INFO, "USIM-API - res(f2) :%s",dump_octet_string(res_pP)); + LOG_TRACE(INFO, "USIM-API - ck(f3) :%s",dump_octet_string(ck_pP)); + LOG_TRACE(INFO, "USIM-API - ik(f4) :%s",dump_octet_string(ik_pP)); + LOG_TRACE(INFO, "USIM-API - ak(f5) : %02X%02X%02X%02X%02X%02X", + ak[0],ak[1],ak[2],ak[3],ak[4],ak[5]); + + //step3: concatenate SQN with AMP SQN||AMF + // SQN = AUTN xor ak + u8 sqn[USIM_API_SQN_SIZE]; + for (i = 0; i < USIM_API_SQN_SIZE; i++) { + sqn[i] = autn_pP->value[i] ^ ak[i]; + } + LOG_TRACE(INFO, "USIM-API - Retrieved SQN %02X%02X%02X%02X%02X%02X", + sqn[0],sqn[1],sqn[2],sqn[3],sqn[4],sqn[5]); + LOG_TRACE(INFO, "USIM-API - Retrieved AMF %02X%02X", + autn_pP->value[USIM_API_SQN_SIZE],autn_pP->value[USIM_API_SQN_SIZE+1]); + +#define USIM_API_XMAC_SIZE 8 + u8 cdout[USIM_API_XMAC_SIZE]; + for (i = 0; i < USIM_API_XMAC_SIZE; i++) + { + if(i < USIM_API_SQN_SIZE) + { + cdout[i] = sqn[i]; + } + else + { + cdout[i] = autn_pP->value[i]; + } + } + LOG_TRACE(INFO, "USIM-API - Retrieved CDOUT %02X%02X%02X%02X%02X%02X%02X%02X", + cdout[0],cdout[1],cdout[2],cdout[3],cdout[4],cdout[5],cdout[6],cdout[7]); + + //step4:calculate XMAC from cdout and xdout + u8 xmac[USIM_API_XMAC_SIZE]; + for(i = 0; i < USIM_API_XMAC_SIZE; i++) + { + xmac[i] = res_pP->value[i] ^ cdout[i]; + } + LOG_TRACE(INFO, + "USIM-API - Computed XMAC %02X%02X%02X%02X%02X%02X%02X%02X", + xmac[0],xmac[1],xmac[2],xmac[3], + xmac[4],xmac[5],xmac[6],xmac[7]); + + /* Compare the XMAC with the MAC included in AUTN */ +#define USIM_API_AMF_SIZE 2 + + if ( memcmp(xmac, &autn_pP->value[USIM_API_SQN_SIZE + USIM_API_AMF_SIZE], + USIM_API_XMAC_SIZE) != 0 ) { + LOG_TRACE(INFO, + "USIM-API - Comparing the XMAC with the MAC included in AUTN Failed"); + rc = RETURNerror; + //LOG_FUNC_RETURN (RETURNerror); + } else { + LOG_TRACE(INFO, + "USIM-API - Comparing the XMAC with the MAC included in AUTN Succeeded"); + /* Verify that the received sequence number SQN is in the correct range */ + rc = _usim_api_check_sqn(*(uint32_t*)(sqn), sqn[USIM_API_SQN_SIZE - 1]); + } + + + if (rc != RETURNok) { + /* Synchronisation failure; compute the AUTS parameter */ + + /* Concealed value of the counter SQNms in the USIM: + * Conc(SQNMS) = SQNMS ⊕ f5*K(RAND) */ + f5star(_usim_api_k, rand_pP->value, ak); + + + u8 sqn_ms[USIM_API_SQNMS_SIZE]; + memset(sqn_ms, 0, USIM_API_SQNMS_SIZE); + + //#define USIM_API_SQN_MS_SIZE 3 + printf("_usim_api_data.sqn_ms %p\n",_usim_api_data.sqn_ms); + for (i = 0; i < USIM_API_SQNMS_SIZE; i++) { + //#warning "LG:BUG HERE TODO" + printf("i %d: ((uint8_t*)(_usim_api_data.sqn_ms))[USIM_API_SQNMS_SIZE - i] %d\n",i, ((uint8_t*)(_usim_api_data.sqn_ms))[USIM_API_SQNMS_SIZE - i]); + sqn_ms[USIM_API_SQNMS_SIZE - i] = + ((uint8_t*)(_usim_api_data.sqn_ms))[USIM_API_SQNMS_SIZE - i]; + } + + u8 sqnms[USIM_API_SQNMS_SIZE]; + + for (i = 0; i < USIM_API_SQNMS_SIZE; i++) { + sqnms[i] = sqn_ms[i] ^ ak[i]; + } + + LOG_TRACE(DEBUG, "USIM-API - SQNms %02X%02X%02X%02X%02X%02X", + sqnms[0],sqnms[1],sqnms[2],sqnms[3],sqnms[4],sqnms[5]); + + /* Synchronisation message authentication code: + * MACS = f1*K(SQNMS || RAND || AMF) */ +#define USIM_API_MACS_SIZE USIM_API_XMAC_SIZE + u8 macs[USIM_API_MACS_SIZE]; + f1star(_usim_api_k, rand_pP->value, sqn_ms, + &rand_pP->value[USIM_API_SQN_SIZE], macs); + LOG_TRACE(DEBUG, "USIM-API - MACS %02X%02X%02X%02X%02X%02X%02X%02X", + macs[0],macs[1],macs[2],macs[3], + macs[4],macs[5],macs[6],macs[7]); + + /* Synchronisation authentication token: + * AUTS = Conc(SQNMS) || MACS */ + memcpy(&auts_pP->value[0], sqnms, USIM_API_SQNMS_SIZE); + memcpy(&auts_pP->value[USIM_API_SQNMS_SIZE], macs, USIM_API_MACS_SIZE); + auts_pP->length = USIM_API_SQNMS_SIZE + USIM_API_MACS_SIZE; + LOG_FUNC_RETURN (RETURNerror); + } + + LOG_FUNC_RETURN (RETURNok); +} + /**************************************************************************** ** ** ** Name: usim_api_authenticate() ** diff --git a/openair3/NAS/UE/API/USIM/usim_api.h b/openair3/NAS/UE/API/USIM/usim_api.h index f7e85f95e7..fd4b3e3301 100644 --- a/openair3/NAS/UE/API/USIM/usim_api.h +++ b/openair3/NAS/UE/API/USIM/usim_api.h @@ -334,6 +334,8 @@ typedef struct { usim_epsloci_t epsloci; /* Non-Access Stratum configuration */ usim_nasconfig_t nasconfig; + /* usim test mode */ + uint8_t usimtestmode; } usim_data_t; /****************************************************************************/ @@ -351,5 +353,8 @@ int usim_api_write(const usim_data_t* data); int usim_api_authenticate(const OctetString* rand, const OctetString* autn, OctetString* auts, OctetString* res, OctetString* ck, OctetString* ik); +int usim_api_authenticate_test(const OctetString* rand, const OctetString* autn, + OctetString* auts, OctetString* res, + OctetString* ck, OctetString* ik); #endif /* __USIM_API_H__*/ diff --git a/openair3/NAS/UE/EMM/Authentication.c b/openair3/NAS/UE/EMM/Authentication.c index 6285534450..96f28d7e86 100755 --- a/openair3/NAS/UE/EMM/Authentication.c +++ b/openair3/NAS/UE/EMM/Authentication.c @@ -86,6 +86,8 @@ extern void *_emm_service_t3417_handler(void *); extern void *_emm_detach_t3421_handler(void *); extern void *_emm_tau_t3430_handler(void *); +extern uint8_t usim_test; + /****************************************************************************/ /******************* L O C A L D E F I N I T I O N S *******************/ /****************************************************************************/ @@ -240,7 +242,14 @@ int emm_proc_authentication_request(int native_ksi, int ksi, * of the core network by means of the received AUTN parameter and * request the USIM to compute RES, CK and IK for given RAND */ - rc = usim_api_authenticate(rand, autn, &auts, &res, &ck, &ik); + if(usim_test == 0) + { + rc = usim_api_authenticate(rand, autn, &auts, &res, &ck, &ik); + } + else + { + rc = usim_api_authenticate_test(rand, autn, &auts, &res, &ck, &ik); // XOR algo for autentication on usim test mode + } } if (rc != RETURNok) { diff --git a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredNormalService.c b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredNormalService.c index 25924fd9f2..167c80ee51 100755 --- a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredNormalService.c +++ b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredNormalService.c @@ -62,6 +62,7 @@ Description Implements the EPS Mobility Management procedures executed /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ /****************************************************************************/ +extern uint8_t usim_test; /****************************************************************************/ /******************* L O C A L D E F I N I T I O N S *******************/ @@ -116,7 +117,14 @@ int EmmDeregisteredNormalService(const emm_reg_t *evt) /* * Initiate the attach procedure for EPS services */ - rc = emm_proc_attach(EMM_ATTACH_TYPE_EPS); + if(usim_test == 0) + { + rc = emm_proc_attach(EMM_ATTACH_TYPE_EPS); + } + else + { + rc = emm_proc_attach(EMM_ATTACH_TYPE_IMSI); // CMW500 IMSI initial attach expected + } break; case _EMMREG_ATTACH_REQ: diff --git a/openair3/NAS/UE/EMM/emm_main.c b/openair3/NAS/UE/EMM/emm_main.c index dbeacaa149..3ec9aa5cac 100755 --- a/openair3/NAS/UE/EMM/emm_main.c +++ b/openair3/NAS/UE/EMM/emm_main.c @@ -59,6 +59,7 @@ Description Defines the EPS Mobility Management procedure call manager, /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ /****************************************************************************/ +extern uint8_t usim_test; /****************************************************************************/ /******************* L O C A L D E F I N I T I O N S *******************/ @@ -166,6 +167,7 @@ void emm_main_initialize(emm_indication_callback_t cb, const char *imei) /* * Get USIM application data */ + _usim_data.usimtestmode = usim_test; if ( usim_api_read(&_usim_data) != RETURNok ) { /* The USIM application may not be present or not valid */ LOG_TRACE(WARNING, "EMM-MAIN - Failed to read USIM application data"); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index d055eea3ad..ba4988cbfa 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -212,6 +212,7 @@ char rf_config_file[1024]; int chain_offset=0; int phy_test = 0; +uint8_t usim_test = 0; char ref[128] = "internal"; @@ -387,6 +388,7 @@ void help (void) { printf(" --loop-memory get softmodem (UE) to loop through memory instead of acquiring from HW\n"); printf(" --mmapped-dma sets flag for improved EXMIMO UE performance\n"); printf(" --single-thread runs lte-softmodem in only one thread\n"); + printf(" --usim-test use XOR autentication algo in case of test usim mode\n"); printf(" -C Set the downlink frequency for all component carriers\n"); printf(" -d Enable soft scope and L1 and L2 stats (Xforms)\n"); printf(" -F Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n"); @@ -693,6 +695,7 @@ static void get_options (int argc, char **argv) LONG_OPTION_DUMP_FRAME, LONG_OPTION_LOOPMEMORY, LONG_OPTION_PHYTEST, + LONG_OPTION_USIMTEST, LONG_OPTION_MMAPPED_DMA, LONG_OPTION_SINGLE_THREAD, #if T_TRACER @@ -719,6 +722,7 @@ static void get_options (int argc, char **argv) {"ue-dump-frame", no_argument, NULL, LONG_OPTION_DUMP_FRAME}, {"loop-memory", required_argument, NULL, LONG_OPTION_LOOPMEMORY}, {"phy-test", no_argument, NULL, LONG_OPTION_PHYTEST}, + {"usim-test", no_argument, NULL, LONG_OPTION_USIMTEST}, {"mmapped-dma", no_argument, NULL, LONG_OPTION_MMAPPED_DMA}, {"single-thread", no_argument, NULL, LONG_OPTION_SINGLE_THREAD}, #if T_TRACER @@ -818,6 +822,9 @@ static void get_options (int argc, char **argv) phy_test = 1; break; + case LONG_OPTION_USIMTEST: + usim_test = 1; + break; case LONG_OPTION_MMAPPED_DMA: mmapped_dma = 1; break; From 0277475bef1d06cc8926a7d7ec740fff70823c2b Mon Sep 17 00:00:00 2001 From: ROBERT Benoit Date: Tue, 25 Oct 2016 17:47:58 +0200 Subject: [PATCH 19/60] during 'harmony' developments initialisation of some --phy-test parameters were removed --- targets/RT/USER/lte-softmodem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 117beb68d7..1692c2164f 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1608,6 +1608,11 @@ int main( int argc, char **argv ) PHY_vars_eNB_g[0][CC_id] = init_lte_eNB(frame_parms[CC_id],0,frame_parms[CC_id]->Nid_cell,abstraction_flag); PHY_vars_eNB_g[0][CC_id]->CC_id = CC_id; + PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc=0x1fff; + PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs=target_dl_mcs; + PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb=6; + PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs=target_ul_mcs; + if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0; else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1; From 2ace4029f37a323c0238cd0bfd87b2b4cdf1b226 Mon Sep 17 00:00:00 2001 From: ROBERT Benoit Date: Tue, 25 Oct 2016 18:09:59 +0200 Subject: [PATCH 20/60] Update 3gpplte_turbo_decoder_sse_8bit.c maximum frame length is 6144 --- openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c index b56aae4598..1343aee07c 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c @@ -486,7 +486,7 @@ void compute_beta8(llr_t* alpha,llr_t* beta,llr_t *m_11,llr_t* m_10,unsigned sho #endif - if (frame_length > 6143) { + if (frame_length > 6144) { LOG_E(PHY,"compute_beta: frame_length %d\n",frame_length); return; } From 7e6a74d5be20128ab47cc9bfc8a1fd647b7e83d4 Mon Sep 17 00:00:00 2001 From: calvin wang Date: Wed, 26 Oct 2016 13:21:26 +0800 Subject: [PATCH 21/60] change debug info --- openair2/LAYER2/MAC/ue_procedures.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 97b7e433c4..8773186382 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -1422,6 +1422,12 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; + LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID0] = 0; UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID1] = 0; UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID2] = 0; @@ -1430,12 +1436,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] = 0; UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] = 0; UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] = 0; - - LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); } else if (bsr_ce_len == sizeof(BSR_SHORT)) { bsr_l = NULL; bsr_s->LCGID = lcgid; From 6644204765a129610a4b8ec035c5ff90250d077c Mon Sep 17 00:00:00 2001 From: calvin wang Date: Thu, 27 Oct 2016 11:47:17 +0800 Subject: [PATCH 22/60] add BSR trigger code for interoperability test --- openair2/LAYER2/MAC/defs.h | 4 ++++ openair2/LAYER2/MAC/ue_procedures.c | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index e3be4bad6d..d38ca05362 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -947,6 +947,10 @@ typedef struct { uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology /// keep the number of bytes in rlc buffer for each lcgid uint16_t BSR_bytes[MAX_NUM_LCGID]; +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + /// after multiplexing buffer remain for each lcid + uint16_t LCID_buffer_remain[MAX_NUM_LCID]; +#endif /// buffer status for each lcid uint8_t LCID_status[MAX_NUM_LCID]; /// SR pending as defined in 36.321 diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 082b61445f..c24702b3b5 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -1356,6 +1356,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf //update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); //header_len +=2; UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] = LCID_EMPTY; +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] = rlc_status.bytes_in_buffer-sdu_lengths[0]; +#endif } else { dcch_header_len=0; num_sdus = 0; @@ -1391,10 +1394,13 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_length_total += sdu_lengths[num_sdus]; sdu_lcids[num_sdus] = DCCH1; LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH1\n",module_idP,sdu_lengths[num_sdus]); - num_sdus++; //update_bsr(module_idP, frameP, DCCH1); //dcch_header_len +=2; // include dcch1 UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] = LCID_EMPTY; +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] = rlc_status.bytes_in_buffer-sdu_lengths[num_sdus]; +#endif + num_sdus++; } else { dcch1_header_len =0; } @@ -1449,6 +1455,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len --; dtch_header_len_last --; } +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = rlc_status.bytes_in_buffer-sdu_lengths[num_sdus]; +#endif num_sdus++; //UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); } else { @@ -2077,7 +2086,11 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in lcid, 0); - if (rlc_status.bytes_in_buffer > 0 ) { + if ((rlc_status.bytes_in_buffer > 0 ) +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + && (rlc_status.bytes_in_buffer > UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]) +#endif + ){ //BSR trigger SR sr_pending = TRUE; UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; From 4eb3774a743dc17c1d746f21de0290bb0553c22b Mon Sep 17 00:00:00 2001 From: hbilel Date: Fri, 28 Oct 2016 09:56:31 +0200 Subject: [PATCH 23/60] [OAI-UE] add featureGroup to UeCapability (only for usim test mode) --- openair2/RRC/LITE/MESSAGES/asn1_msg.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index fb8f2a426f..d212415461 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -2663,6 +2663,21 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) // UE_EUTRA_Capability->measParameters.bandListEUTRA.list.count = 0; // no measurements on other bands // UE_EUTRA_Capability->featureGroupIndicators // null + + // featureGroup is mandatory for CMW tests + // featureGroup is filled only for usim-test mode + BIT_STRING_t *bit_string; + uint32_t featrG; + bit_string = CALLOC(1, sizeof(*bit_string)); + featrG = 0x04000800; + if(usim_test == 0) + { + bit_string->buf = &featrG; + bit_string->size = 4; + bit_string->bits_unused = 0; + UE_EUTRA_Capability->featureGroupIndicators = bit_string; + } + // UE_EUTRA_Capability->interRAT_Parameters // null } else { From 81837312cb54fcab47fdb0952728f9c063985c33 Mon Sep 17 00:00:00 2001 From: hbilel Date: Thu, 3 Nov 2016 15:29:33 +0100 Subject: [PATCH 24/60] [OAI-UE] RRCConnectionReconf fixes 1- SRB2 fix 2- attach accept, support type of list 0 with number of element = 1 --- openair2/RRC/LITE/MESSAGES/asn1_msg.c | 2 +- openair2/RRC/LITE/rrc_UE.c | 242 ++++++++++++++++++++++++-- openair3/NAS/UE/EMM/SAP/emm_recv.c | 11 +- 3 files changed, 238 insertions(+), 17 deletions(-) diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index d212415461..7d2fc3a3d8 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -2670,7 +2670,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) uint32_t featrG; bit_string = CALLOC(1, sizeof(*bit_string)); featrG = 0x04000800; - if(usim_test == 0) + if(usim_test == 1) { bit_string->buf = &featrG; bit_string->size = 4; diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index a41a664c18..1b22ae5d0b 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -817,6 +817,7 @@ rrc_ue_process_measConfig( } } + LOG_I(RRC,"call rrc_mac_config_req \n"); rrc_mac_config_req(ctxt_pP->module_id,0,ENB_FLAG_NO,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, @@ -963,6 +964,199 @@ rrc_ue_process_measConfig( } } + +void +rrc_ue_update_radioResourceConfigDedicated(RadioResourceConfigDedicated_t* radioResourceConfigDedicated, + const protocol_ctxt_t* const ctxt_pP, + uint8_t eNB_index) +{ + PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL; + + physicalConfigDedicated2 = CALLOC(1,sizeof(*physicalConfigDedicated2)); + physicalConfigDedicated2->pdsch_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->pdsch_ConfigDedicated)); + physicalConfigDedicated2->pusch_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->pusch_ConfigDedicated)); + physicalConfigDedicated2->pucch_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->pucch_ConfigDedicated)); + physicalConfigDedicated2->cqi_ReportConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig)); + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); + physicalConfigDedicated2->schedulingRequestConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->schedulingRequestConfig)); + physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo)); + + physicalConfigDedicated2->uplinkPowerControlDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated)); + physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH)); + physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH)); + + // Update pdsch_ConfigDedicated + if(radioResourceConfigDedicated->physicalConfigDedicated->pdsch_ConfigDedicated != NULL) + { + LOG_I(RRC,"Update pdsch_ConfigDedicated config \n"); + + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pdsch_ConfigDedicated == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pdsch_ConfigDedicated = CALLOC(1,sizeof(PDSCH_ConfigDedicated_t)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pdsch_ConfigDedicated, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->pdsch_ConfigDedicated, + sizeof(physicalConfigDedicated2->pdsch_ConfigDedicated)); + } + else + { + LOG_I(RRC,"Keep old config for pdsch_ConfigDedicated\n"); + } + + // Update pusch_ConfigDedicated + if(radioResourceConfigDedicated->physicalConfigDedicated->pusch_ConfigDedicated != NULL) + { + LOG_I(RRC,"Update pusch_ConfigDedicated config \n"); + + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pusch_ConfigDedicated == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pusch_ConfigDedicated = CALLOC(1,sizeof(PUSCH_ConfigDedicated_t)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pusch_ConfigDedicated, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->pusch_ConfigDedicated, + sizeof(physicalConfigDedicated2->pusch_ConfigDedicated)); + } + else + { + LOG_I(RRC,"Keep old config for pusch_ConfigDedicated\n"); + } + + // Update pucch_ConfigDedicated + if(radioResourceConfigDedicated->physicalConfigDedicated->pucch_ConfigDedicated != NULL) + { + LOG_I(RRC,"Update pucch_ConfigDedicated config \n"); + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pucch_ConfigDedicated == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pucch_ConfigDedicated = CALLOC(1,sizeof(PUCCH_ConfigDedicated_t)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->pucch_ConfigDedicated, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->pucch_ConfigDedicated, + sizeof(physicalConfigDedicated2->pucch_ConfigDedicated)); + } + else + { + LOG_I(RRC,"Keep old config for pucch_ConfigDedicated\n"); + } + + // Update cqi_ReportConfig + if(radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig != NULL) + { + LOG_I(RRC,"Update cqi_ReportConfig config \n"); + + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig = CALLOC(1,sizeof(CQI_ReportConfig_t)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->cqi_ReportConfig, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->cqi_ReportConfig, + sizeof(physicalConfigDedicated2->cqi_ReportConfig)); + } + else + { + LOG_I(RRC,"Keep old config for cqi_ReportConfig\n"); + } + + // Update schedulingRequestConfig + if(radioResourceConfigDedicated->physicalConfigDedicated->schedulingRequestConfig != NULL) + { + LOG_I(RRC,"Update schedulingRequestConfig config \n"); + + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->schedulingRequestConfig == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->schedulingRequestConfig = CALLOC(1,sizeof(SchedulingRequestConfig_t)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->schedulingRequestConfig, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->schedulingRequestConfig, + sizeof(physicalConfigDedicated2->schedulingRequestConfig)); + } + else + { + LOG_I(RRC,"Keep old config for schedulingRequestConfig\n"); + } + + // Update soundingRS_UL_ConfigDedicated + if(radioResourceConfigDedicated->physicalConfigDedicated->soundingRS_UL_ConfigDedicated != NULL) + { + LOG_I(RRC,"Update soundingRS_UL_ConfigDedicated config \n"); + + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->soundingRS_UL_ConfigDedicated == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(SoundingRS_UL_ConfigDedicated_t)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->soundingRS_UL_ConfigDedicated, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->soundingRS_UL_ConfigDedicated, + sizeof(physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); + } + else + { + LOG_I(RRC,"Keep old config for soundingRS_UL_ConfigDedicated\n"); + } + + // Update antennaInfo + if(radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo != NULL) + { + LOG_I(RRC,"Update antennaInfo config \n"); + + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo = CALLOC(1,sizeof(struct PhysicalConfigDedicated__antennaInfo)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->antennaInfo, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->antennaInfo, + sizeof(physicalConfigDedicated2->antennaInfo)); + } + else + { + LOG_I(RRC,"Keep old config for antennaInfo\n"); + } + + + // Update uplinkPowerControlDedicated + if(radioResourceConfigDedicated->physicalConfigDedicated->uplinkPowerControlDedicated != NULL) + { + LOG_I(RRC,"Update uplinkPowerControlDedicated config \n"); + + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->uplinkPowerControlDedicated == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->uplinkPowerControlDedicated = CALLOC(1,sizeof(UplinkPowerControlDedicated_t)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->uplinkPowerControlDedicated, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->uplinkPowerControlDedicated, + sizeof(physicalConfigDedicated2->uplinkPowerControlDedicated)); + } + else + { + LOG_I(RRC,"Keep old config for uplinkPowerControlDedicated\n"); + } + + // Update tpc_PDCCH_ConfigPUCCH + if(radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUCCH != NULL) + { + LOG_I(RRC,"Update tpc_PDCCH_ConfigPUCCH config \n"); + + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUCCH == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUCCH = CALLOC(1,sizeof(TPC_PDCCH_Config_t)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUCCH, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUCCH, + sizeof(physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH)); + } + else + { + LOG_I(RRC,"Keep old config for tpc_PDCCH_ConfigPUCCH\n"); + } + + // Update tpc_PDCCH_ConfigPUSCH + if(radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUSCH != NULL) + { + LOG_I(RRC,"Update tpc_PDCCH_ConfigPUSCH config \n"); + + if(UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUSCH == NULL) + UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUSCH = CALLOC(1,sizeof(TPC_PDCCH_Config_t)); + + memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]->tpc_PDCCH_ConfigPUSCH, + (char*)radioResourceConfigDedicated->physicalConfigDedicated->tpc_PDCCH_ConfigPUSCH, + sizeof(physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH)); + + } + else + { + LOG_I(RRC,"Keep old config for tpc_PDCCH_ConfigPUSCH\n"); + } + +} //----------------------------------------------------------------------------- void rrc_ue_process_radioResourceConfigDedicated( @@ -983,11 +1177,17 @@ rrc_ue_process_radioResourceConfigDedicated( // Save physicalConfigDedicated if present if (radioResourceConfigDedicated->physicalConfigDedicated) { + LOG_I(RRC,"Save physicalConfigDedicated if present \n"); + if (UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index]) { +#if 1 + rrc_ue_update_radioResourceConfigDedicated(radioResourceConfigDedicated, ctxt_pP, eNB_index); +#else memcpy((char*)UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],(char*)radioResourceConfigDedicated->physicalConfigDedicated, sizeof(struct PhysicalConfigDedicated)); - +#endif } else { + LOG_I(RRC,"Init physicalConfigDedicated UE_rrc_inst to radioResourceConfigDedicated->physicalConfigDedicated\n"); UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index] = radioResourceConfigDedicated->physicalConfigDedicated; } } @@ -1105,7 +1305,7 @@ rrc_ue_process_radioResourceConfigDedicated( SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; } - LOG_D(RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 eNB %d) --->][MAC_UE][MOD %02d][]\n", + LOG_I(RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 eNB %d) --->][MAC_UE][MOD %02d][]\n", ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); rrc_mac_config_req(ctxt_pP->module_id,0,ENB_FLAG_NO,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, @@ -1160,7 +1360,7 @@ rrc_ue_process_radioResourceConfigDedicated( SRB2_logicalChannelConfig = &SRB2_logicalChannelConfig_defaultValue; } - LOG_D(RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", + LOG_I(RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", ctxt_pP->frame, ctxt_pP->module_id, eNB_index, @@ -1267,7 +1467,7 @@ rrc_ue_process_radioResourceConfigDedicated( UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id] = radioResourceConfigDedicated->drb_ToAddModList->list.array[i]; rrc_ue_establish_drb(ctxt_pP->module_id,ctxt_pP->frame,eNB_index,radioResourceConfigDedicated->drb_ToAddModList->list.array[i]); // MAC/PHY Configuration - LOG_D(RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (DRB %d eNB %d) --->][MAC_UE][MOD %02d][]\n", + LOG_I(RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (DRB %d eNB %d) --->][MAC_UE][MOD %02d][]\n", ctxt_pP->frame, ctxt_pP->module_id, radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity, eNB_index, @@ -1825,7 +2025,7 @@ rrc_ue_process_mobilityControlInfo( UE_rrc_inst[ue_mod_idP].DRB_config[eNB_index][0] = NULL; */ //Synchronisation to DL of target cell - LOG_D(RRC, + LOG_I(RRC, "HO: Reset PDCP and RLC for configured RBs.. \n[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); @@ -2685,7 +2885,7 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod = siPeriod_int[sib1->schedulingInfoList.list.array[0]->si_Periodicity]; UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize = siWindowLength_int[sib1->si_WindowLength]; - LOG_D( RRC, "[FRAME unknown][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB1 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n", + LOG_I( RRC, "[FRAME unknown][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB1 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n", ctxt_pP->module_id, eNB_index, ctxt_pP->module_id ); rrc_mac_config_req(ctxt_pP->module_id, 0, ENB_FLAG_NO, 0, eNB_index, @@ -3499,7 +3699,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB13 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index ); dump_sib13( UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index] ); // adding here function to store necessary parameters for using in decode_MCCH_Message + maybe transfer to PHY layer - LOG_D( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB13 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n", + LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB13 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n", ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); rrc_mac_config_req(ctxt_pP->module_id,0,ENB_FLAG_NO,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, @@ -3956,7 +4156,7 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i { protocol_ctxt_t ctxt; - LOG_D(RRC,"[UE %d] Frame %d : Number of MCH(s) in the MBSFN Sync Area %d is %d\n", + LOG_I(RRC,"[UE %d] Frame %d : Number of MCH(s) in the MBSFN Sync Area %d is %d\n", ue_mod_idP, frameP, mbsfn_sync_area, UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9.list.count); // store to MAC/PHY necessary parameters for receiving MTCHs rrc_mac_config_req(ue_mod_idP,0,ENB_FLAG_NO,0,eNB_index, @@ -4301,12 +4501,26 @@ void *rrc_ue_task( void *args_p ) /* Transfer data to PDCP */ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0,0); - rrc_data_req (&ctxt, - DCCH, - rrc_mui++, - SDU_CONFIRM_NO, - length, buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + + // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2) + if(UE_rrc_inst[ue_mod_id].SRB2_config[0] == NULL) + { + rrc_data_req (&ctxt, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + length, buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + } + else + { + rrc_data_req (&ctxt, + DCCH1, + rrc_mui++, + SDU_CONFIRM_NO, + length, buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + } break; } diff --git a/openair3/NAS/UE/EMM/SAP/emm_recv.c b/openair3/NAS/UE/EMM/SAP/emm_recv.c index 32e8e1ec30..6162b5ea2b 100644 --- a/openair3/NAS/UE/EMM/SAP/emm_recv.c +++ b/openair3/NAS/UE/EMM/SAP/emm_recv.c @@ -137,8 +137,15 @@ int emm_recv_attach_accept(attach_accept_msg *msg, int *emm_cause) /* * Message checking */ - if (msg->tailist.typeoflist != - TRACKING_AREA_IDENTITY_LIST_ONE_PLMN_CONSECUTIVE_TACS) { + // supported cases: + // typeoflist = 1 Or + // typeoflist = 0 and numberofelements = 1 (ie numberofelements equal to zero see 3gpp 24.301 9.9.3.33.1) + LOG_D(NAS,"attach accept type of list: %d, number of element: %d\n",msg->tailist.typeoflist, msg->tailist.numberofelements); + if (!( (msg->tailist.typeoflist == TRACKING_AREA_IDENTITY_LIST_ONE_PLMN_CONSECUTIVE_TACS) || + ((msg->tailist.typeoflist == 0) && ( (msg->tailist.numberofelements + 1) == 1)) + ) + ) + { /* Only list of TACs belonging to one PLMN with consecutive * TAC values is supported */ *emm_cause = EMM_CAUSE_IE_NOT_IMPLEMENTED; From 9fbbd0678a236ea9e7878f83fe7327dd29b26854 Mon Sep 17 00:00:00 2001 From: hbilel Date: Thu, 3 Nov 2016 15:53:06 +0100 Subject: [PATCH 25/60] [OAI-UE] attach accept fix --- openair3/NAS/UE/EMM/SAP/emm_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair3/NAS/UE/EMM/SAP/emm_recv.c b/openair3/NAS/UE/EMM/SAP/emm_recv.c index 6162b5ea2b..a79a14d9c1 100644 --- a/openair3/NAS/UE/EMM/SAP/emm_recv.c +++ b/openair3/NAS/UE/EMM/SAP/emm_recv.c @@ -142,7 +142,7 @@ int emm_recv_attach_accept(attach_accept_msg *msg, int *emm_cause) // typeoflist = 0 and numberofelements = 1 (ie numberofelements equal to zero see 3gpp 24.301 9.9.3.33.1) LOG_D(NAS,"attach accept type of list: %d, number of element: %d\n",msg->tailist.typeoflist, msg->tailist.numberofelements); if (!( (msg->tailist.typeoflist == TRACKING_AREA_IDENTITY_LIST_ONE_PLMN_CONSECUTIVE_TACS) || - ((msg->tailist.typeoflist == 0) && ( (msg->tailist.numberofelements + 1) == 1)) + ((msg->tailist.typeoflist == 0) && ( msg->tailist.numberofelements == 0)) ) ) { From 8750acebbcf3c13de3d35a21f196b2f4e0f89c09 Mon Sep 17 00:00:00 2001 From: GabrirelCouturier Date: Mon, 7 Nov 2016 10:50:05 +0100 Subject: [PATCH 26/60] [OAI-UE] fix for issue#14: segmentation fault in turbo decoder --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 33 +++++++++++++++++++++ openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c | 12 +++++++- openair1/SCHED/phy_procedures_lte_ue.c | 4 +-- openair1/SCHED/pucch_pc.c | 4 +-- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index aa2daf8ebb..3624d67af1 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -1260,6 +1260,11 @@ int generate_eNB_dlsch_params_from_dci(int frame, dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][NPRB-1]; } + else + { + LOG_E(PHY,"DL Received HarqReTx round=%d mcs=%d rballoc=%d rv=%d \n", + dlsch0_harq->round,mcs,rballoc,rv); + } dlsch[0]->current_harq_pid = harq_pid; @@ -4143,6 +4148,20 @@ int generate_ue_dlsch_params_from_dci(int frame, dlsch0_harq->DCINdi = ndi; + // this a retransmission + if(dlsch0_harq->round) + { + // compare old TBS to new TBS + if(dlsch0_harq->TBS != TBStable[get_I_TBS(mcs)][NPRB-1]) + { + // this is an eNB issue + // retransmisison but old and new TBS are different !!! + // work around, consider it as a new transmission + LOG_E(PHY,"Format1A Retransmission but TBS are different: consider it as new transmission !!! \n"); + dlsch0_harq->round = 0; + } + } + dlsch0_harq->mcs = mcs; if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) { dlsch0_harq->TBS = TBStable[mcs][NPRB-1]; @@ -4452,6 +4471,20 @@ int generate_ue_dlsch_params_from_dci(int frame, dlsch0_harq->mcs = mcs; + // this a retransmission + if(dlsch0_harq->round) + { + // compare old TBS to new TBS + if(dlsch0_harq->TBS != TBStable[get_I_TBS(mcs)][NPRB-1]) + { + // this is an eNB issue + // retransmisison but old and new TBS are different !!! + // work around, consider it as a new transmission + LOG_E(PHY,"Format1 Retransmission but TBS are different: consider it as new transmission !!! \n"); + dlsch0_harq->round = 0; + } + } + dlsch0_harq->TBS = TBStable[get_I_TBS(mcs)][NPRB-1]; if (mcs <= 28) dlsch0_harq->Qm = get_Qm(mcs); diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c index f4ab4c0924..c7cd5ab52f 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c @@ -249,7 +249,12 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue, tc = phy_threegpplte_turbo_decoder16; } else - tc = phy_threegpplte_turbo_decoder8; + { + AssertFatal (harq_process->TBS >= 256 , "Mismatch flag nbRB=%d TBS=%d mcs=%d Qm=%d RIV=%d round=%d \n", + harq_process->nb_rb, harq_process->TBS,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round); + tc = phy_threegpplte_turbo_decoder8; + } + // nb_rb = dlsch->nb_rb; @@ -448,6 +453,11 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue, #if 1 if (err_flag == 0) { + if (llr8_flag) { + AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n", + Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round); + } + start_meas(dlsch_turbo_decoding_stats); ret = tc (&harq_process->d[r][96], diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 756f13f923..55e7686462 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -2579,7 +2579,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint if (generate_ue_dlsch_params_from_dci(frame_rx, subframe_rx, (void *)&dci_alloc_rx[i].dci_pdu, - SI_RNTI, + P_RNTI, dci_alloc_rx[i].format, &ue->dlsch_SI[eNB_id], &ue->frame_parms, @@ -3072,7 +3072,7 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, subframe_rx, harq_pid, pdsch==PDSCH?1:0, - dlsch0->harq_processes[harq_pid]->nb_rb>10?1:0); + dlsch0->harq_processes[harq_pid]->TBS>256?1:0); stop_meas(&ue->dlsch_decoding_stats); } diff --git a/openair1/SCHED/pucch_pc.c b/openair1/SCHED/pucch_pc.c index 5afd57e6a0..2795fe65a9 100644 --- a/openair1/SCHED/pucch_pc.c +++ b/openair1/SCHED/pucch_pc.c @@ -88,7 +88,7 @@ int8_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,ui } if (pucch_fmt!=pucch_format1) { - LOG_I(PHY,"[UE %d][PDSCH %x] frame %d, subframe %d: Po_PUCCH %d dBm : Po_NOMINAL_PUCCH %d dBm, PL %d dB, g_pucch %d dB\n", + LOG_D(PHY,"[UE %d][PDSCH %x] frame %d, subframe %d: Po_PUCCH %d dBm : Po_NOMINAL_PUCCH %d dBm, PL %d dB, g_pucch %d dB\n", ue->Mod_id, ue->dlsch[eNB_id][0]->rnti,proc->frame_tx,subframe, Po_PUCCH, @@ -96,7 +96,7 @@ int8_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,ui get_PL(ue->Mod_id,ue->CC_id,eNB_id), ue->dlsch[eNB_id][0]->g_pucch); } else { - LOG_I(PHY,"[UE %d][SR %x] frame %d, subframe %d: Po_PUCCH %d dBm : Po_NOMINAL_PUCCH %d dBm, PL %d dB g_pucch %d dB\n", + LOG_D(PHY,"[UE %d][SR %x] frame %d, subframe %d: Po_PUCCH %d dBm : Po_NOMINAL_PUCCH %d dBm, PL %d dB g_pucch %d dB\n", ue->Mod_id, ue->dlsch[eNB_id][0]->rnti,proc->frame_tx,subframe, Po_PUCCH, From 5e94d108a194506e62b5d95bde4b0faf4398be41 Mon Sep 17 00:00:00 2001 From: GabrirelCouturier Date: Mon, 7 Nov 2016 11:01:25 +0100 Subject: [PATCH 27/60] [OAI-UE] fix for issue#18: Cell sync issue --- openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c | 15 ++++++++------- openair1/PHY/LTE_TRANSPORT/initial_sync.c | 7 +++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c index 6ebd8948cf..d713cc0163 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c @@ -102,7 +102,7 @@ int lte_est_freq_offset(int **dl_ch_estimates, { int ch_offset, omega, dl_ch_shift; - struct complex16 *omega_cpx; + struct complex16 omega_cpx; double phase_offset; int freq_offset_est; unsigned char aa; @@ -142,9 +142,8 @@ int lte_est_freq_offset(int **dl_ch_estimates, // printf("Computing freq_offset\n"); omega = dot_product(dl_ch,dl_ch_prev,(frame_parms->N_RB_DL/2 - 1)*12,dl_ch_shift); //omega = dot_product(dl_ch,dl_ch_prev,frame_parms->ofdm_symbol_size,15); - omega_cpx = (struct complex16*) ω - - // printf("omega (%d,%d)\n",omega_cpx->r,omega_cpx->i); + omega_cpx.r = ((struct complex16*) &omega)->r; + omega_cpx.i = ((struct complex16*) &omega)->i; dl_ch = (int16_t *)&dl_ch_estimates[aa][(((frame_parms->N_RB_DL/2) + 1)*12) + ch_offset]; @@ -155,10 +154,12 @@ int lte_est_freq_offset(int **dl_ch_estimates, // calculate omega = angle(conj(dl_ch)*dl_ch_prev)) omega = dot_product(dl_ch,dl_ch_prev,((frame_parms->N_RB_DL/2) - 1)*12,dl_ch_shift); - omega_cpx->r += ((struct complex16*) &omega)->r; - omega_cpx->i += ((struct complex16*) &omega)->i; + + omega_cpx.r += ((struct complex16*) &omega)->r; + omega_cpx.i += ((struct complex16*) &omega)->i; + // phase_offset += atan2((double)omega_cpx->i,(double)omega_cpx->r); - phase_offset += atan2((double)omega_cpx->i,(double)omega_cpx->r); + phase_offset += atan2((double)omega_cpx.i,(double)omega_cpx.r); // LOG_I(PHY,"omega (%d,%d) -> %f\n",omega_cpx->r,omega_cpx->i,phase_offset); } diff --git a/openair1/PHY/LTE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_TRANSPORT/initial_sync.c index 661fe96be8..91374078c0 100644 --- a/openair1/PHY/LTE_TRANSPORT/initial_sync.c +++ b/openair1/PHY/LTE_TRANSPORT/initial_sync.c @@ -462,6 +462,13 @@ int initial_sync(PHY_VARS_UE *ue, runmode_t mode) } } + /* Consider this is a false detection if the offset is > 1000 Hz */ + if( (abs(ue->common_vars.freq_offset) > 1000) && (ret == 0) ) + { + ret=-1; + LOG_E(HW,"Ignore MIB with high freq offset [%d Hz] estimation \n",ue->common_vars.freq_offset); + } + if (ret==0) { // PBCH found so indicate sync to higher layers and configure frame parameters //#ifdef DEBUG_INITIAL_SYNCH From 048b5384dd30aec8246020f0e1c30d5b8dd1970a Mon Sep 17 00:00:00 2001 From: fnabet Date: Mon, 7 Nov 2016 11:22:11 +0100 Subject: [PATCH 28/60] [OAI-UE] revert commit 8236206c and 9672b410 "BSR-stabilization + rebase from oai1B" --- openair2/LAYER2/MAC/config.c | 25 +--- openair2/LAYER2/MAC/defs.h | 14 +-- openair2/LAYER2/MAC/extern.h | 2 - openair2/LAYER2/MAC/proto.h | 6 +- openair2/LAYER2/MAC/ra_procedures.c | 2 +- openair2/LAYER2/MAC/ue_procedures.c | 184 +++++++++------------------- openair2/LAYER2/MAC/vars.h | 9 -- 7 files changed, 66 insertions(+), 176 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index d46b761bd0..3fbcadafbb 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -69,7 +69,6 @@ void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index) // cancel all pending SRs UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; - UE_mac_inst[module_idP].BSR_reporting_active=0; // stop ongoing RACH procedure @@ -226,34 +225,13 @@ rrc_mac_config_req( if (mac_MainConfig->ext1 && mac_MainConfig->ext1->sr_ProhibitTimer_r9) { UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) *mac_MainConfig->ext1->sr_ProhibitTimer_r9; } else { - UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = 0; + UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) 0; } - if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) { - if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10) { - UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10; - } else { - UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0; - } - if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10) { - UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10; - } else { - UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; - } - } else { - UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0; - UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; - } #endif UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer); UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer); - UE_mac_inst[Mod_idP].BSR_reporting_active = 0; - LOG_D(MAC,"[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", - Mod_idP, - UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF, - UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF); - UE_mac_inst[Mod_idP].scheduling_info.drx_config = mac_MainConfig->drx_Config; UE_mac_inst[Mod_idP].scheduling_info.phr_config = mac_MainConfig->phr_Config; @@ -274,7 +252,6 @@ rrc_mac_config_req( UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[Mod_idP].scheduling_info.PathlossChange); - UE_mac_inst[Mod_idP].PHR_reporting_active = 0; LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", Mod_idP, (mac_MainConfig->phr_Config)?mac_MainConfig->phr_Config->present:-1, diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index d38ca05362..2235c3e1c4 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -945,12 +945,8 @@ typedef enum { typedef struct { /// buffer status for each lcgid uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology - /// keep the number of bytes in rlc buffer for each lcgid + /// keep the number of bytes in rlc buffer for each lcid uint16_t BSR_bytes[MAX_NUM_LCGID]; -#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 - /// after multiplexing buffer remain for each lcid - uint16_t LCID_buffer_remain[MAX_NUM_LCID]; -#endif /// buffer status for each lcid uint8_t LCID_status[MAX_NUM_LCID]; /// SR pending as defined in 36.321 @@ -991,12 +987,6 @@ typedef struct { int16_t prohibitPHR_SF; ///DL Pathloss Change in db uint16_t PathlossChange_db; - - /// default value is false - uint16_t extendedBSR_Sizes_r10; - /// default value is false - uint16_t extendedPHR_r10; - //Bj bucket usage per lcid int16_t Bj[MAX_NUM_LCID]; // Bucket size per lcid @@ -1084,8 +1074,6 @@ typedef struct { uint8_t PHR_reporting_active; /// power backoff due to power management (as allowed by P-MPRc) for this cell uint8_t power_backoff_db[NUMBER_OF_eNB_MAX]; - /// BSR report falg management - uint8_t BSR_reporting_active; /// MBSFN_Subframe Configuration struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA? /// number of subframe allocation pattern available for MBSFN sync area diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index 4276c342cf..8726cb1349 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -46,8 +46,6 @@ extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; //extern uint32_t EBSR_Level[63]; -extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE]; -//extern uint32_t Extended_BSR_TABLE[63]; ----currently not used extern UE_MAC_INST *UE_mac_inst; extern eNB_MAC_INST *eNB_mac_inst; diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 248f918dc1..59d6c352fe 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -551,7 +551,7 @@ int get_bsr_lcgid (module_id_t module_idP); \param[in] bufflen size of phy transport block \param[out] bsr_len size of bsr control element */ -uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen); +uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen); /*! \fn BSR_SHORT * get_bsr_short(module_id_t module_idP, uint8_t bsr_len) \brief get short bsr level @@ -577,14 +577,14 @@ BSR_LONG * get_bsr_long(module_id_t module_idP, uint8_t bsr_len); */ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcgid); -/*! \fn locate_BsrIndexByBufferSize (int *table, int size, int value) +/*! \fn locate (int *table, int size, int value) \brief locate the BSR level in the table as defined in 36.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table. \param[in] *table Pointer to BSR table \param[in] size Size of the table \param[in] value Value of the buffer \return the index in the BSR_LEVEL table */ -uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value); +uint8_t locate (const uint32_t *table, int size, int value); /*! \fn int get_sf_periodicBSRTimer(uint8_t periodicBSR_Timer) diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 3b5734756d..30137fab33 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -391,7 +391,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, 1); //post_padding return(&UE_mac_inst[module_idP].RA_prach_resources); - } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > 0) { + } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DCCH] > 0) { // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index c24702b3b5..d5958f6e5e 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -102,17 +102,13 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; UE_mac_inst[module_idP].scheduling_info.ttiBundling=0; - UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10=0; - UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10=0; UE_mac_inst[module_idP].scheduling_info.drx_config=NULL; UE_mac_inst[module_idP].scheduling_info.phr_config=NULL; UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); - UE_mac_inst[module_idP].BSR_reporting_active = 0; UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[module_idP].scheduling_info.PathlossChange); - UE_mac_inst[module_idP].PHR_reporting_active = 0; for (i=0; i < MAX_NUM_LCID; i++) { LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",module_idP,i); @@ -125,7 +121,7 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1; } - UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=LCID_EMPTY; + UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=0; } #ifdef CBA @@ -310,28 +306,18 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i // initiate RA UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; - // release all pucch resource - UE_mac_inst[module_idP].physicalConfigDedicated = NULL; - UE_mac_inst[module_idP].ul_active=0; - UE_mac_inst[module_idP].BSR_reporting_active=0; - - LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); return(0); } } //------------------------------------------------------------------------------ void -ue_send_sdu( - module_id_t module_idP, - uint8_t CC_id, - frame_t frameP, - uint8_t* sdu, - uint16_t sdu_len, - uint8_t eNB_index -) -//------------------------------------------------------------------------------ -{ +ue_send_sdu(module_id_t module_idP, + uint8_t CC_id, + frame_t frameP, + uint8_t* sdu, + uint16_t sdu_len, + uint8_t eNB_index) { unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; @@ -1258,12 +1244,11 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf BSR_LONG *bsr_l=&bsr_long; POWER_HEADROOM_CMD phr; POWER_HEADROOM_CMD *phr_p=&phr; - unsigned short short_padding=0, post_padding=0, padding_len=0; + unsigned short short_padding=0, post_padding=0; int lcgid; int j; // used for padding // Compute header length - int all_pdu_len; - + if (CC_id>0) { LOG_E(MAC,"Transmission on secondary CCs is not supported yet\n"); mac_xface->macphy_exit("MAC FATAL CC_id>0"); @@ -1297,10 +1282,19 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len=(buflen > 128 ) ? 3 : 2 ; //sizeof(SCH_SUBHEADER_LONG)-1 : sizeof(SCH_SUBHEADER_SHORT); bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); + phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; - bsr_ce_len = get_bsr_len (module_idP, eNB_index, frameP, buflen); - // retxBSR-Timer expires or periodicBSR-Timer expires and Regular BSR trigger - if ((bsr_ce_len > 0 ) && (UE_mac_inst[module_idP].BSR_reporting_active > 0)) { + if (phr_ce_len > 0) { + phr_len = phr_ce_len + phr_header_len; + LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", + module_idP, phr_len, phr_ce_len, phr_header_len, buflen); + } else { + phr_len=0; + } + + bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len); + + if (bsr_ce_len > 0 ) { bsr_len = bsr_ce_len + bsr_header_len; LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n", module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen); @@ -1311,15 +1305,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf //bsr_len = bsr_ce_len + bsr_header_len; } - phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; - if (phr_ce_len > 0) { - phr_len = phr_ce_len + phr_header_len; - LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", - module_idP, phr_len, phr_ce_len, phr_header_len, buflen); - } else { - phr_len=0; - } - // check for UL bandwidth requests and add SR control element // check for UL bandwidth requests and add SR control element @@ -1353,12 +1338,8 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_lcids[0] = DCCH; LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); num_sdus = 1; - //update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); + update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); //header_len +=2; - UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] = LCID_EMPTY; -#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] = rlc_status.bytes_in_buffer-sdu_lengths[0]; -#endif } else { dcch_header_len=0; num_sdus = 0; @@ -1394,13 +1375,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_length_total += sdu_lengths[num_sdus]; sdu_lcids[num_sdus] = DCCH1; LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH1\n",module_idP,sdu_lengths[num_sdus]); + num_sdus++; //update_bsr(module_idP, frameP, DCCH1); //dcch_header_len +=2; // include dcch1 - UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] = LCID_EMPTY; -#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] = rlc_status.bytes_in_buffer-sdu_lengths[num_sdus]; -#endif - num_sdus++; } else { dcch1_header_len =0; } @@ -1411,9 +1388,8 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len+=3; dtch_header_len_last=3; - all_pdu_len = bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total; if ((UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) && - (all_pdu_len <= buflen)) { + ((bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total) <= buflen)) { // optimize the dtch header lenght //if ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] > 128) && @@ -1431,11 +1407,11 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ENB_FLAG_NO, MBMS_FLAG_NO, // eNB_index lcid, - buflen-all_pdu_len); + buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total); LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[%d] %d)\n", module_idP,frameP, lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len, - lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); + lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcid]); if (rlc_status.bytes_in_buffer > 0) { sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, @@ -1455,20 +1431,16 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len --; dtch_header_len_last --; } -#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = rlc_status.bytes_in_buffer-sdu_lengths[num_sdus]; -#endif num_sdus++; - //UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); + UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); } else { dtch_header_len -= 3; } - UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; } else { // no rlc pdu : generate the dummy header dtch_header_len -= 3; } } - + lcgid= get_bsr_lcgid(module_idP); if (lcgid < 0 ) { @@ -1480,29 +1452,15 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; - LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); - - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID0] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID1] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID2] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID3] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] = 0; } else if (bsr_ce_len == sizeof(BSR_SHORT)) { bsr_l = NULL; bsr_s->LCGID = lcgid; bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; - - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; - LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); } else { @@ -1536,14 +1494,12 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len_last-=1; dtch_header_len= (dtch_header_len >0)? dtch_header_len - dtch_header_len_last : dtch_header_len; } - // 1-bit padding or 2-bit padding special padding subheader - padding_len = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; - if (padding_len <= 2) { - short_padding = padding_len; - // only add padding header + + if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) <= 2) { + short_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; post_padding = 0; } else { - if (padding_len == buflen) {// nona mac pdu + if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) == buflen) { *access_mode=CANCELED_ACCESS; } @@ -1588,9 +1544,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf module_idP,payload_offset, sdu_length_total); UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; - UE_mac_inst[module_idP].BSR_reporting_active=0; - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); @@ -1752,25 +1705,10 @@ ue_scheduler( // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures // outlined in Sections 5.4.4 an 5.4.5 of 36.321 - // Call BSR procedure as described in Section 5.4.5 in 36.321 - if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == get_sf_periodicBSRTimer(MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity)) { - UE_mac_inst[module_idP].BSR_reporting_active = 1; - } else if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF <= 0 ){ - // trigger BSR and reset the timer later when the BSR report is sent - UE_mac_inst[module_idP].BSR_reporting_active = 1; - } else if (UE_mac_inst[module_idP].BSR_reporting_active == 0 ) { - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--; - } - - if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF <= 0){ - // trigger BSR and reset the timer later when the BSR report is sent - UE_mac_inst[module_idP].BSR_reporting_active = 1; - } else if (UE_mac_inst[module_idP].BSR_reporting_active == 0 ) { - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--; - } + // Put this in another function // Get RLC status info and update Bj for all lcids that are active - for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++ ) { + for (lcid=DCCH; lcid <= DTCH; lcid++ ) { if ((lcid == 0) ||(UE_mac_inst[module_idP].logicalChannelConfig[lcid])) { // meausre the Bj if ((directionP == SF_UL)&& (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) { @@ -1791,8 +1729,6 @@ ue_scheduler( if (update_bsr(module_idP,frameP, eNB_indexP, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) { UE_mac_inst[module_idP].scheduling_info.SR_pending= 1; - // Regular BSR trigger - UE_mac_inst[module_idP].BSR_reporting_active = 1; LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d SR for PUSCH is pending for LCGID %d with BSR level %d (%d bytes in RLC)\n", module_idP, frameP,subframeP,UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], @@ -2034,26 +1970,31 @@ int get_bsr_lcgid (module_id_t module_idP) } } -uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen) +uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) { - int lcid; - uint8_t bsr_len=0, num_lcid=0; - int pdu = 0; - mac_rlc_status_resp_t rlc_status; - for (lcid=DCCH; lcid 0 ) { - pdu += rlc_status.bytes_in_buffer + sizeof(SCH_SUBHEADER_SHORT) + bsr_len; - if (rlc_status.bytes_in_buffer > 128 ) { - pdu += 1; //sizeof(SCH_SUBHEADER_LONG) - } + int lcgid=0; + uint8_t bsr_len=0, num_lcgid=0; + int pdu = 0; + + + for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) { + pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + bsr_len + 2); //2 = sizeof(SCH_SUBHEADER_SHORT) } - if ( (pdu > buflen) && (rlc_status.bytes_in_buffer > 0 ) ) { - num_lcid +=1; - bsr_len = (num_lcid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; + + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) { // long header size: adjust the header size + pdu += 1; } - LOG_D(MAC,"LC buffer Bytes %d for lcid %d bsr len %d num lcid %d\n", rlc_status.bytes_in_buffer, lcid, bsr_len, num_lcid); + + // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid + + if ( (pdu > buflen) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) ) { + num_lcgid +=1; + bsr_len = (num_lcgid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; + } + + LOG_D(MAC,"BSR Bytes %d for lcgid %d bsr len %d num lcgid %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid], lcgid, bsr_len, num_lcgid); } if ( bsr_len > 0 ) @@ -2063,6 +2004,7 @@ uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,ui return bsr_len; } + boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcg_id) { @@ -2086,17 +2028,11 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in lcid, 0); - if ((rlc_status.bytes_in_buffer > 0 ) -#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 - && (rlc_status.bytes_in_buffer > UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]) -#endif - ){ - //BSR trigger SR + if (rlc_status.bytes_in_buffer > 0 ) { sr_pending = TRUE; UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; - // sum lcid buffer which has same lcgid + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] += locate (BSR_TABLE,BSR_TABLE_SIZE, rlc_status.bytes_in_buffer); UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer; - UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); @@ -2109,7 +2045,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in return sr_pending; } -uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value) +uint8_t locate (const uint32_t *table, int size, int value) { uint8_t ju, jm, jl; @@ -2140,7 +2076,7 @@ uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value) if (value == table[jl]) { return jl; - } else { + } else { return jl+1; //equally ju } diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 236439c6e5..83d159f910 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -45,15 +45,6 @@ const uint32_t BSR_TABLE[BSR_TABLE_SIZE]= {0,10,12,14,17,19,22,26,31,36,42,49,57 1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099, 16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439, 128125,150000, 300000 }; -// extended bsr table--currently not used -const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE] = {0,10,13,16,19,23,29,35,43,53,65,80,98,120,147, - 181,223,274,337,414,509,625,769,945,1162,1429, - 1757,2161,2657,3267,4017,4940,6074,7469,9185, - 11294,13888,17077,20999,25822,31752,39045,48012, - 59039,72598,89272,109774,134986,165989,204111, - 250990,308634,379519,466683,573866,705666,867737, - 1067031,1312097,1613447,1984009,2439678,3000000, - 6000000}; //uint32_t EBSR_Level[63]={0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181}; From d56c651081874c69a42bba2956356514e3f847b2 Mon Sep 17 00:00:00 2001 From: fnabet Date: Mon, 7 Nov 2016 11:57:02 +0100 Subject: [PATCH 29/60] Reapply BSR changes --- openair2/LAYER2/MAC/config.c | 25 +++- openair2/LAYER2/MAC/defs.h | 14 ++- openair2/LAYER2/MAC/extern.h | 2 + openair2/LAYER2/MAC/proto.h | 6 +- openair2/LAYER2/MAC/ra_procedures.c | 2 +- openair2/LAYER2/MAC/ue_procedures.c | 182 +++++++++++++++++++--------- openair2/LAYER2/MAC/vars.h | 9 ++ 7 files changed, 175 insertions(+), 65 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 3fbcadafbb..d46b761bd0 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -69,6 +69,7 @@ void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index) // cancel all pending SRs UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + UE_mac_inst[module_idP].BSR_reporting_active=0; // stop ongoing RACH procedure @@ -225,13 +226,34 @@ rrc_mac_config_req( if (mac_MainConfig->ext1 && mac_MainConfig->ext1->sr_ProhibitTimer_r9) { UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) *mac_MainConfig->ext1->sr_ProhibitTimer_r9; } else { - UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) 0; + UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = 0; } + if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) { + if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10) { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10; + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0; + } + if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10) { + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10; + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; + } + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0; + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; + } #endif UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer); UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer); + UE_mac_inst[Mod_idP].BSR_reporting_active = 0; + LOG_D(MAC,"[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", + Mod_idP, + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF, + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF); + UE_mac_inst[Mod_idP].scheduling_info.drx_config = mac_MainConfig->drx_Config; UE_mac_inst[Mod_idP].scheduling_info.phr_config = mac_MainConfig->phr_Config; @@ -252,6 +274,7 @@ rrc_mac_config_req( UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[Mod_idP].scheduling_info.PathlossChange); + UE_mac_inst[Mod_idP].PHR_reporting_active = 0; LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", Mod_idP, (mac_MainConfig->phr_Config)?mac_MainConfig->phr_Config->present:-1, diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 2235c3e1c4..d38ca05362 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -945,8 +945,12 @@ typedef enum { typedef struct { /// buffer status for each lcgid uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology - /// keep the number of bytes in rlc buffer for each lcid + /// keep the number of bytes in rlc buffer for each lcgid uint16_t BSR_bytes[MAX_NUM_LCGID]; +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + /// after multiplexing buffer remain for each lcid + uint16_t LCID_buffer_remain[MAX_NUM_LCID]; +#endif /// buffer status for each lcid uint8_t LCID_status[MAX_NUM_LCID]; /// SR pending as defined in 36.321 @@ -987,6 +991,12 @@ typedef struct { int16_t prohibitPHR_SF; ///DL Pathloss Change in db uint16_t PathlossChange_db; + + /// default value is false + uint16_t extendedBSR_Sizes_r10; + /// default value is false + uint16_t extendedPHR_r10; + //Bj bucket usage per lcid int16_t Bj[MAX_NUM_LCID]; // Bucket size per lcid @@ -1074,6 +1084,8 @@ typedef struct { uint8_t PHR_reporting_active; /// power backoff due to power management (as allowed by P-MPRc) for this cell uint8_t power_backoff_db[NUMBER_OF_eNB_MAX]; + /// BSR report falg management + uint8_t BSR_reporting_active; /// MBSFN_Subframe Configuration struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA? /// number of subframe allocation pattern available for MBSFN sync area diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index 8726cb1349..4276c342cf 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -46,6 +46,8 @@ extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; //extern uint32_t EBSR_Level[63]; +extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE]; +//extern uint32_t Extended_BSR_TABLE[63]; ----currently not used extern UE_MAC_INST *UE_mac_inst; extern eNB_MAC_INST *eNB_mac_inst; diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 59d6c352fe..248f918dc1 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -551,7 +551,7 @@ int get_bsr_lcgid (module_id_t module_idP); \param[in] bufflen size of phy transport block \param[out] bsr_len size of bsr control element */ -uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen); +uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen); /*! \fn BSR_SHORT * get_bsr_short(module_id_t module_idP, uint8_t bsr_len) \brief get short bsr level @@ -577,14 +577,14 @@ BSR_LONG * get_bsr_long(module_id_t module_idP, uint8_t bsr_len); */ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcgid); -/*! \fn locate (int *table, int size, int value) +/*! \fn locate_BsrIndexByBufferSize (int *table, int size, int value) \brief locate the BSR level in the table as defined in 36.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table. \param[in] *table Pointer to BSR table \param[in] size Size of the table \param[in] value Value of the buffer \return the index in the BSR_LEVEL table */ -uint8_t locate (const uint32_t *table, int size, int value); +uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value); /*! \fn int get_sf_periodicBSRTimer(uint8_t periodicBSR_Timer) diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 30137fab33..3b5734756d 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -391,7 +391,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, 1); //post_padding return(&UE_mac_inst[module_idP].RA_prach_resources); - } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DCCH] > 0) { + } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > 0) { // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index d5958f6e5e..c24702b3b5 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -102,13 +102,17 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; UE_mac_inst[module_idP].scheduling_info.ttiBundling=0; + UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10=0; + UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10=0; UE_mac_inst[module_idP].scheduling_info.drx_config=NULL; UE_mac_inst[module_idP].scheduling_info.phr_config=NULL; UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); + UE_mac_inst[module_idP].BSR_reporting_active = 0; UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[module_idP].scheduling_info.PathlossChange); + UE_mac_inst[module_idP].PHR_reporting_active = 0; for (i=0; i < MAX_NUM_LCID; i++) { LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",module_idP,i); @@ -121,7 +125,7 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1; } - UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=0; + UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=LCID_EMPTY; } #ifdef CBA @@ -306,18 +310,28 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i // initiate RA UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + // release all pucch resource + UE_mac_inst[module_idP].physicalConfigDedicated = NULL; + UE_mac_inst[module_idP].ul_active=0; + UE_mac_inst[module_idP].BSR_reporting_active=0; + + LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); return(0); } } //------------------------------------------------------------------------------ void -ue_send_sdu(module_id_t module_idP, - uint8_t CC_id, - frame_t frameP, - uint8_t* sdu, - uint16_t sdu_len, - uint8_t eNB_index) { +ue_send_sdu( + module_id_t module_idP, + uint8_t CC_id, + frame_t frameP, + uint8_t* sdu, + uint16_t sdu_len, + uint8_t eNB_index +) +//------------------------------------------------------------------------------ +{ unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; @@ -1244,11 +1258,12 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf BSR_LONG *bsr_l=&bsr_long; POWER_HEADROOM_CMD phr; POWER_HEADROOM_CMD *phr_p=&phr; - unsigned short short_padding=0, post_padding=0; + unsigned short short_padding=0, post_padding=0, padding_len=0; int lcgid; int j; // used for padding // Compute header length - + int all_pdu_len; + if (CC_id>0) { LOG_E(MAC,"Transmission on secondary CCs is not supported yet\n"); mac_xface->macphy_exit("MAC FATAL CC_id>0"); @@ -1282,19 +1297,10 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len=(buflen > 128 ) ? 3 : 2 ; //sizeof(SCH_SUBHEADER_LONG)-1 : sizeof(SCH_SUBHEADER_SHORT); bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); - phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; - if (phr_ce_len > 0) { - phr_len = phr_ce_len + phr_header_len; - LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", - module_idP, phr_len, phr_ce_len, phr_header_len, buflen); - } else { - phr_len=0; - } - - bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len); - - if (bsr_ce_len > 0 ) { + bsr_ce_len = get_bsr_len (module_idP, eNB_index, frameP, buflen); + // retxBSR-Timer expires or periodicBSR-Timer expires and Regular BSR trigger + if ((bsr_ce_len > 0 ) && (UE_mac_inst[module_idP].BSR_reporting_active > 0)) { bsr_len = bsr_ce_len + bsr_header_len; LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n", module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen); @@ -1305,6 +1311,15 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf //bsr_len = bsr_ce_len + bsr_header_len; } + phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; + if (phr_ce_len > 0) { + phr_len = phr_ce_len + phr_header_len; + LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", + module_idP, phr_len, phr_ce_len, phr_header_len, buflen); + } else { + phr_len=0; + } + // check for UL bandwidth requests and add SR control element // check for UL bandwidth requests and add SR control element @@ -1338,8 +1353,12 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_lcids[0] = DCCH; LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); num_sdus = 1; - update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); + //update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); //header_len +=2; + UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] = LCID_EMPTY; +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] = rlc_status.bytes_in_buffer-sdu_lengths[0]; +#endif } else { dcch_header_len=0; num_sdus = 0; @@ -1375,9 +1394,13 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_length_total += sdu_lengths[num_sdus]; sdu_lcids[num_sdus] = DCCH1; LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH1\n",module_idP,sdu_lengths[num_sdus]); - num_sdus++; //update_bsr(module_idP, frameP, DCCH1); //dcch_header_len +=2; // include dcch1 + UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] = LCID_EMPTY; +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] = rlc_status.bytes_in_buffer-sdu_lengths[num_sdus]; +#endif + num_sdus++; } else { dcch1_header_len =0; } @@ -1388,8 +1411,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len+=3; dtch_header_len_last=3; + all_pdu_len = bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total; if ((UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) && - ((bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total) <= buflen)) { + (all_pdu_len <= buflen)) { // optimize the dtch header lenght //if ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] > 128) && @@ -1407,11 +1431,11 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ENB_FLAG_NO, MBMS_FLAG_NO, // eNB_index lcid, - buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total); + buflen-all_pdu_len); LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[%d] %d)\n", module_idP,frameP, lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len, - lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcid]); + lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); if (rlc_status.bytes_in_buffer > 0) { sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, @@ -1431,16 +1455,20 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len --; dtch_header_len_last --; } +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = rlc_status.bytes_in_buffer-sdu_lengths[num_sdus]; +#endif num_sdus++; - UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); + //UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); } else { dtch_header_len -= 3; } + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; } else { // no rlc pdu : generate the dummy header dtch_header_len -= 3; } } - + lcgid= get_bsr_lcgid(module_idP); if (lcgid < 0 ) { @@ -1452,15 +1480,29 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; + LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); + + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID0] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID1] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID2] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID3] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] = 0; } else if (bsr_ce_len == sizeof(BSR_SHORT)) { bsr_l = NULL; bsr_s->LCGID = lcgid; bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; + + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; + LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); } else { @@ -1494,12 +1536,14 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len_last-=1; dtch_header_len= (dtch_header_len >0)? dtch_header_len - dtch_header_len_last : dtch_header_len; } - - if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) <= 2) { - short_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; + // 1-bit padding or 2-bit padding special padding subheader + padding_len = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; + if (padding_len <= 2) { + short_padding = padding_len; + // only add padding header post_padding = 0; } else { - if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) == buflen) { + if (padding_len == buflen) {// nona mac pdu *access_mode=CANCELED_ACCESS; } @@ -1544,6 +1588,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf module_idP,payload_offset, sdu_length_total); UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + UE_mac_inst[module_idP].BSR_reporting_active=0; + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); @@ -1705,10 +1752,25 @@ ue_scheduler( // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures // outlined in Sections 5.4.4 an 5.4.5 of 36.321 - // Put this in another function + // Call BSR procedure as described in Section 5.4.5 in 36.321 + if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == get_sf_periodicBSRTimer(MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity)) { + UE_mac_inst[module_idP].BSR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF <= 0 ){ + // trigger BSR and reset the timer later when the BSR report is sent + UE_mac_inst[module_idP].BSR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].BSR_reporting_active == 0 ) { + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--; + } + + if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF <= 0){ + // trigger BSR and reset the timer later when the BSR report is sent + UE_mac_inst[module_idP].BSR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].BSR_reporting_active == 0 ) { + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--; + } // Get RLC status info and update Bj for all lcids that are active - for (lcid=DCCH; lcid <= DTCH; lcid++ ) { + for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++ ) { if ((lcid == 0) ||(UE_mac_inst[module_idP].logicalChannelConfig[lcid])) { // meausre the Bj if ((directionP == SF_UL)&& (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) { @@ -1729,6 +1791,8 @@ ue_scheduler( if (update_bsr(module_idP,frameP, eNB_indexP, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) { UE_mac_inst[module_idP].scheduling_info.SR_pending= 1; + // Regular BSR trigger + UE_mac_inst[module_idP].BSR_reporting_active = 1; LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d SR for PUSCH is pending for LCGID %d with BSR level %d (%d bytes in RLC)\n", module_idP, frameP,subframeP,UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], @@ -1970,31 +2034,26 @@ int get_bsr_lcgid (module_id_t module_idP) } } -uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) +uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen) { - - int lcgid=0; - uint8_t bsr_len=0, num_lcgid=0; + int lcid; + uint8_t bsr_len=0, num_lcid=0; int pdu = 0; + mac_rlc_status_resp_t rlc_status; - - for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) { - pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + bsr_len + 2); //2 = sizeof(SCH_SUBHEADER_SHORT) + for (lcid=DCCH; lcid 0 ) { + pdu += rlc_status.bytes_in_buffer + sizeof(SCH_SUBHEADER_SHORT) + bsr_len; + if (rlc_status.bytes_in_buffer > 128 ) { + pdu += 1; //sizeof(SCH_SUBHEADER_LONG) + } } - - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) { // long header size: adjust the header size - pdu += 1; + if ( (pdu > buflen) && (rlc_status.bytes_in_buffer > 0 ) ) { + num_lcid +=1; + bsr_len = (num_lcid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; } - - // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid - - if ( (pdu > buflen) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) ) { - num_lcgid +=1; - bsr_len = (num_lcgid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; - } - - LOG_D(MAC,"BSR Bytes %d for lcgid %d bsr len %d num lcgid %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid], lcgid, bsr_len, num_lcgid); + LOG_D(MAC,"LC buffer Bytes %d for lcid %d bsr len %d num lcid %d\n", rlc_status.bytes_in_buffer, lcid, bsr_len, num_lcid); } if ( bsr_len > 0 ) @@ -2004,7 +2063,6 @@ uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) return bsr_len; } - boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcg_id) { @@ -2028,11 +2086,17 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in lcid, 0); - if (rlc_status.bytes_in_buffer > 0 ) { + if ((rlc_status.bytes_in_buffer > 0 ) +#if 0 //calvin for BSR test,current buffer greater then previous one, or buffer from 0 to !0 + && (rlc_status.bytes_in_buffer > UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]) +#endif + ){ + //BSR trigger SR sr_pending = TRUE; UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; - UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] += locate (BSR_TABLE,BSR_TABLE_SIZE, rlc_status.bytes_in_buffer); + // sum lcid buffer which has same lcgid UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer; + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); @@ -2045,7 +2109,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in return sr_pending; } -uint8_t locate (const uint32_t *table, int size, int value) +uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value) { uint8_t ju, jm, jl; @@ -2076,7 +2140,7 @@ uint8_t locate (const uint32_t *table, int size, int value) if (value == table[jl]) { return jl; - } else { + } else { return jl+1; //equally ju } diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 83d159f910..236439c6e5 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -45,6 +45,15 @@ const uint32_t BSR_TABLE[BSR_TABLE_SIZE]= {0,10,12,14,17,19,22,26,31,36,42,49,57 1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099, 16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439, 128125,150000, 300000 }; +// extended bsr table--currently not used +const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE] = {0,10,13,16,19,23,29,35,43,53,65,80,98,120,147, + 181,223,274,337,414,509,625,769,945,1162,1429, + 1757,2161,2657,3267,4017,4940,6074,7469,9185, + 11294,13888,17077,20999,25822,31752,39045,48012, + 59039,72598,89272,109774,134986,165989,204111, + 250990,308634,379519,466683,573866,705666,867737, + 1067031,1312097,1613447,1984009,2439678,3000000, + 6000000}; //uint32_t EBSR_Level[63]={0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181}; From ea4f2948fd87cfe61477b3637e83c5069fd931de Mon Sep 17 00:00:00 2001 From: GabrirelCouturier Date: Wed, 9 Nov 2016 16:58:11 +0100 Subject: [PATCH 30/60] [OAI-UE] fix for issue#19: DCI0 detction with wrong RIV --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 3624d67af1..fc307655dd 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -6384,8 +6384,10 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, if (rballoc > RIV_max) { - LOG_E(PHY,"frame %d, subframe %d, rnti %x, format %d: FATAL ERROR: generate_ue_ulsch_params_from_dci, rb_alloc > RIV_max\n", - proc->frame_rx, subframe, rnti, dci_format); + LOG_E(PHY,"frame %d, subframe %d, rnti %x, format %d: FATAL ERROR: generate_ue_ulsch_params_from_dci, rb_alloc[%d] > RIV_max[%d]\n", + proc->frame_rx, subframe, rnti, dci_format,rballoc,RIV_max); + LOG_E(PHY,"Wrong DCI0 detection, do not transmit PUSCH for HARQID: %d\n",harq_pid); + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; return(-1); } From 09f149d86b44ffccf956879ed2988446339ae572 Mon Sep 17 00:00:00 2001 From: calvin wang Date: Fri, 11 Nov 2016 18:01:39 +0800 Subject: [PATCH 31/60] Stabilization UE BSR feature --- openair2/LAYER2/MAC/config.c | 34 ++- openair2/LAYER2/MAC/defs.h | 27 ++- openair2/LAYER2/MAC/extern.h | 2 + openair2/LAYER2/MAC/proto.h | 4 +- openair2/LAYER2/MAC/ra_procedures.c | 2 +- openair2/LAYER2/MAC/ue_procedures.c | 341 +++++++++++++++++++++------- openair2/LAYER2/MAC/vars.h | 9 + 7 files changed, 329 insertions(+), 90 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 3fbcadafbb..2a6390740c 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -69,7 +69,10 @@ void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index) // cancel all pending SRs UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; - + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR]=0; + UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR]=0; + UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR]=0; + UE_mac_inst[module_idP].retxBSRTimer_expires_flag = 0; // stop ongoing RACH procedure // discard explicitly signaled ra_PreambleIndex and ra_RACH_MaskIndex, if any @@ -228,10 +231,34 @@ rrc_mac_config_req( UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) 0; } + if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) { + if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10) { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10; + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0; + } + if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10) { + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10; + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; + } + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0; + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; + } #endif - UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer); - UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer); + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = 0xFFFF; + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = 0xFFFF; + UE_mac_inst[Mod_idP].BSR_reporting_active[REGULAR_BSR]=0; + UE_mac_inst[Mod_idP].BSR_reporting_active[PADDING_BSR]=0; + UE_mac_inst[Mod_idP].BSR_reporting_active[PERIODIC_BSR]=0; + UE_mac_inst[Mod_idP].retxBSRTimer_expires_flag = 0; + LOG_D(MAC,"[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", + Mod_idP, + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF, + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF); + UE_mac_inst[Mod_idP].scheduling_info.drx_config = mac_MainConfig->drx_Config; UE_mac_inst[Mod_idP].scheduling_info.phr_config = mac_MainConfig->phr_Config; @@ -252,6 +279,7 @@ rrc_mac_config_req( UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[Mod_idP].scheduling_info.PathlossChange); + UE_mac_inst[Mod_idP].PHR_reporting_active = 0; LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", Mod_idP, (mac_MainConfig->phr_Config)?mac_MainConfig->phr_Config->present:-1, diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 2235c3e1c4..bfaaa3ca1d 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -336,6 +336,14 @@ typedef struct { #define SHORT_BSR 29 /*!\brief LCID of long BSR for ULSCH */ #define LONG_BSR 30 +/*!\brief first level bsr type for ULSCH: Regular BSR,Padding BSR,Periodic BSR*/ +#define BSR_TYPE_FIRST_LEVEL 3 +/*!\brief first level bsr type states*/ +typedef enum { + REGULAR_BSR =0, + PADDING_BSR, + PERIODIC_BSR +} UE_FIRST_LEVEL_BSR_TYPE; /*! \brief Downlink SCH PDU Structure */ typedef struct { @@ -945,8 +953,10 @@ typedef enum { typedef struct { /// buffer status for each lcgid uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology - /// keep the number of bytes in rlc buffer for each lcid + /// keep the number of bytes in rlc buffer for each lcgid uint16_t BSR_bytes[MAX_NUM_LCGID]; + /// after multiplexing buffer remain for each lcid + uint16_t LCID_buffer_remain[MAX_NUM_LCID]; /// buffer status for each lcid uint8_t LCID_status[MAX_NUM_LCID]; /// SR pending as defined in 36.321 @@ -958,11 +968,11 @@ typedef struct { /// retxBSR-Timer, default value is sf2560 uint16_t retxBSR_Timer; /// retxBSR_SF, number of subframe before triggering a regular BSR - int16_t retxBSR_SF; + int16_t retxBSR_SF; // if value equal oxFFFF means counters are NOT active /// periodicBSR-Timer, default to infinity uint16_t periodicBSR_Timer; /// periodicBSR_SF, number of subframe before triggering a periodic BSR - int16_t periodicBSR_SF; + int16_t periodicBSR_SF; // if value equal oxFFFF means counters are NOT active /// default value is 0: not configured uint16_t sr_ProhibitTimer; /// sr ProhibitTime running @@ -987,6 +997,12 @@ typedef struct { int16_t prohibitPHR_SF; ///DL Pathloss Change in db uint16_t PathlossChange_db; + + /// default value is false + uint16_t extendedBSR_Sizes_r10; + /// default value is false + uint16_t extendedPHR_r10; + //Bj bucket usage per lcid int16_t Bj[MAX_NUM_LCID]; // Bucket size per lcid @@ -1074,6 +1090,11 @@ typedef struct { uint8_t PHR_reporting_active; /// power backoff due to power management (as allowed by P-MPRc) for this cell uint8_t power_backoff_db[NUMBER_OF_eNB_MAX]; + /// BSR report falg management + uint8_t BSR_reporting_active[BSR_TYPE_FIRST_LEVEL]; + /// retxBSR-Timer expires flag + uint8_t retxBSRTimer_expires_flag; + /// MBSFN_Subframe Configuration struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA? /// number of subframe allocation pattern available for MBSFN sync area diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index 8726cb1349..4276c342cf 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -46,6 +46,8 @@ extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; //extern uint32_t EBSR_Level[63]; +extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE]; +//extern uint32_t Extended_BSR_TABLE[63]; ----currently not used extern UE_MAC_INST *UE_mac_inst; extern eNB_MAC_INST *eNB_mac_inst; diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 59d6c352fe..94f1d3448c 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -545,13 +545,13 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 */ int get_bsr_lcgid (module_id_t module_idP); -/*! \fn uint8_t get_bsr_len (module_id_t module_idP,uint16_t bufflen); +/*! \fn int get_bsr_type (module_id_t module_idP,uint16_t bufflen); \brief determine whether the bsr is short or long assuming that the MAC pdu is built \param[in] Mod_id instance of the UE \param[in] bufflen size of phy transport block \param[out] bsr_len size of bsr control element */ -uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen); +int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen); /*! \fn BSR_SHORT * get_bsr_short(module_id_t module_idP, uint8_t bsr_len) \brief get short bsr level diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 30137fab33..3b5734756d 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -391,7 +391,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, 1); //post_padding return(&UE_mac_inst[module_idP].RA_prach_resources); - } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DCCH] > 0) { + } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > 0) { // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index d5958f6e5e..56d4524d7d 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -102,13 +102,22 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; UE_mac_inst[module_idP].scheduling_info.ttiBundling=0; + UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10=0; + UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10=0; UE_mac_inst[module_idP].scheduling_info.drx_config=NULL; UE_mac_inst[module_idP].scheduling_info.phr_config=NULL; - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); + // set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW. + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = 0xFFFF; + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = 0xFFFF; + + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR]=0; + UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR]=0; + UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR]=0; + UE_mac_inst[module_idP].retxBSRTimer_expires_flag = 0; UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[module_idP].scheduling_info.PathlossChange); + UE_mac_inst[module_idP].PHR_reporting_active = 0; for (i=0; i < MAX_NUM_LCID; i++) { LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",module_idP,i); @@ -121,7 +130,7 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1; } - UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=0; + UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=LCID_EMPTY; } #ifdef CBA @@ -306,6 +315,14 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i // initiate RA UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + // release all pucch resource + UE_mac_inst[module_idP].physicalConfigDedicated = NULL; + UE_mac_inst[module_idP].ul_active=0; + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR]=0; + UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR]=0; + UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR]=0; + UE_mac_inst[module_idP].retxBSRTimer_expires_flag = 0; + LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); return(0); } } @@ -1230,7 +1247,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf mac_rlc_status_resp_t rlc_status; uint8_t dcch_header_len=0,dcch1_header_len=0,dtch_header_len=0,dtch_header_len_last=0; uint8_t dcch_header_len_tmp=0, dtch_header_len_tmp=0; - uint8_t bsr_header_len=0, bsr_ce_len=0, bsr_len=0; + uint8_t bsr_len=0; uint8_t phr_header_len=0, phr_ce_len=0,phr_len=0; uint8_t lcid=0; uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -1238,17 +1255,20 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf uint8_t payload_offset=0,num_sdus=0; uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; uint16_t sdu_length_total=0; - BSR_SHORT bsr_short; + BSR_SHORT bsr_short,bsr_truncated; BSR_LONG bsr_long; BSR_SHORT *bsr_s=&bsr_short; BSR_LONG *bsr_l=&bsr_long; + BSR_SHORT *bsr_t=&bsr_truncated; POWER_HEADROOM_CMD phr; POWER_HEADROOM_CMD *phr_p=&phr; - unsigned short short_padding=0, post_padding=0; + unsigned short short_padding=0, post_padding=0, padding_len=0; int lcgid; int j; // used for padding // Compute header length - + int all_pdu_len; + int bsr_type=0; + if (CC_id>0) { LOG_E(MAC,"Transmission on secondary CCs is not supported yet\n"); mac_xface->macphy_exit("MAC FATAL CC_id>0"); @@ -1280,10 +1300,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dcch1_header_len=2;//sizeof(SCH_SUBHEADER_SHORT); // hypo length,in case of long header skip the padding byte dtch_header_len=(buflen > 128 ) ? 3 : 2 ; //sizeof(SCH_SUBHEADER_LONG)-1 : sizeof(SCH_SUBHEADER_SHORT); - bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); - phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; + phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; if (phr_ce_len > 0) { phr_len = phr_ce_len + phr_header_len; LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", @@ -1292,19 +1311,21 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf phr_len=0; } - bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len); - - if (bsr_ce_len > 0 ) { - bsr_len = bsr_ce_len + bsr_header_len; - LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n", - module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen); + bsr_type = get_bsr_type(module_idP, eNB_index, frameP, buflen-phr_len); + if (bsr_type == LONG_BSR) { + bsr_len = sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_LONG);; + LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (bsr_type%d) buff_len %d\n", + module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_type, buflen); + } else if ((bsr_type == SHORT_BSR) || (bsr_type == TRUNCATED_BSR)) { + bsr_len = sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_SHORT);; + LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (bsr_type%d) buff_len %d\n", + module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_type, buflen); } else { bsr_len=0; //LOG_D(MAC,"[UE %d] Empty buffers, send a long BSR to reset the bsr at eNB \n ",Mod_id); // bsr_ce_len = sizeof(BSR_LONG); //bsr_len = bsr_ce_len + bsr_header_len; } - // check for UL bandwidth requests and add SR control element // check for UL bandwidth requests and add SR control element @@ -1338,8 +1359,14 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_lcids[0] = DCCH; LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); num_sdus = 1; - update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); + //update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); //header_len +=2; + UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] = LCID_EMPTY; + if (rlc_status.bytes_in_buffer > sdu_lengths[0]) { + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] = rlc_status.bytes_in_buffer-sdu_lengths[0]; + } else { + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] = 0; + } } else { dcch_header_len=0; num_sdus = 0; @@ -1375,9 +1402,16 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_length_total += sdu_lengths[num_sdus]; sdu_lcids[num_sdus] = DCCH1; LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH1\n",module_idP,sdu_lengths[num_sdus]); - num_sdus++; //update_bsr(module_idP, frameP, DCCH1); //dcch_header_len +=2; // include dcch1 + UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] = LCID_EMPTY; + if (rlc_status.bytes_in_buffer > sdu_lengths[num_sdus]) { + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] = rlc_status.bytes_in_buffer-sdu_lengths[num_sdus]; + } else { + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] = 0; + } + + num_sdus++; } else { dcch1_header_len =0; } @@ -1388,8 +1422,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len+=3; dtch_header_len_last=3; + all_pdu_len = bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total; if ((UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) && - ((bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total) <= buflen)) { + (all_pdu_len <= buflen)) { // optimize the dtch header lenght //if ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] > 128) && @@ -1407,65 +1442,99 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ENB_FLAG_NO, MBMS_FLAG_NO, // eNB_index lcid, - buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total); + buflen-all_pdu_len); LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[%d] %d)\n", module_idP,frameP, lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len, - lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcid]); + lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); if (rlc_status.bytes_in_buffer > 0) { - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, // eNB_index - lcid, - (char *)&ulsch_buff[sdu_length_total]); - - //adjust dtch header - LOG_D(MAC,"[UE %d] TX Got %d bytes for DTCH\n",module_idP,sdu_lengths[num_sdus]); - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) { - dtch_header_len --; - dtch_header_len_last --; - } - num_sdus++; - UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, // eNB_index + lcid, + (char *)&ulsch_buff[sdu_length_total]); + + //adjust dtch header + LOG_D(MAC,"[UE %d] TX Got %d bytes for DTCH\n",module_idP,sdu_lengths[num_sdus]); + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + if (sdu_lengths[num_sdus] < 128) { + dtch_header_len --; + dtch_header_len_last --; + } + if (rlc_status.bytes_in_buffer > sdu_lengths[num_sdus]) { + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = rlc_status.bytes_in_buffer-sdu_lengths[num_sdus]; + } else { + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = 0; + } + + //UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); + num_sdus++; } else { - dtch_header_len -= 3; + dtch_header_len -= 3; } + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; } else { // no rlc pdu : generate the dummy header dtch_header_len -= 3; } } - + lcgid= get_bsr_lcgid(module_idP); if (lcgid < 0 ) { bsr_s = NULL; - bsr_l = NULL ; - } else if ((lcgid ==MAX_NUM_LCGID) && (bsr_ce_len == sizeof(BSR_LONG))) { + bsr_l = NULL; + bsr_t = NULL; + } else if ((lcgid ==MAX_NUM_LCGID) && (bsr_type == LONG_BSR)) { bsr_s = NULL; + bsr_t = NULL; bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; + LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); - } else if (bsr_ce_len == sizeof(BSR_SHORT)) { + + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID0] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID1] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID2] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID3] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] = 0; + } else if (bsr_type == SHORT_BSR) { bsr_l = NULL; + bsr_t = NULL; bsr_s->LCGID = lcgid; bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; + LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; + } else if (bsr_type == TRUNCATED_BSR) { + bsr_l = NULL; + bsr_s = NULL; + bsr_t->LCGID = lcgid; + bsr_t->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; + + LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", + module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; } else { bsr_s = NULL; bsr_l = NULL; + bsr_t = NULL; } // build PHR and update the timers @@ -1494,12 +1563,14 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len_last-=1; dtch_header_len= (dtch_header_len >0)? dtch_header_len - dtch_header_len_last : dtch_header_len; } - - if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) <= 2) { - short_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; + // 1-bit padding or 2-bit padding special padding subheader + padding_len = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; + if (padding_len <= 2) { + short_padding = padding_len; + // only add padding header post_padding = 0; } else { - if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) == buflen) { + if (padding_len == buflen) {// nona mac pdu *access_mode=CANCELED_ACCESS; } @@ -1524,7 +1595,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_lcids, // sdu lcid phr_p, // power headroom NULL, // crnti - NULL, // truncated bsr + bsr_t, // truncated bsr bsr_s, // short bsr bsr_l, post_padding); // long_bsr @@ -1544,6 +1615,14 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf module_idP,payload_offset, sdu_length_total); UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR]=0; + UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR]=0; + UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR]=0; + if (bsr_type > 0) { //if bsr trigger, reset two timer + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); + UE_mac_inst[module_idP].retxBSRTimer_expires_flag = 0; + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); @@ -1572,7 +1651,7 @@ ue_scheduler( const int CC_id) //------------------------------------------------------------------------------ { - + int periodicBSR_Timer_infinity_value; int lcid; // lcid index int TTI= 1; int bucketsizeduration = -1; @@ -1705,10 +1784,35 @@ ue_scheduler( // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures // outlined in Sections 5.4.4 an 5.4.5 of 36.321 - // Put this in another function + // Call BSR procedure as described in Section 5.4.5 in 36.321 + periodicBSR_Timer_infinity_value = get_sf_periodicBSRTimer(MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity); + if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != (int16_t)periodicBSR_Timer_infinity_value) { + if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF <= 0 ) { + /* + periodicBSR-Timer expires, in which case the BSR is referred below to as "Periodic BSR". + */ + UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR] = 1; + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = periodicBSR_Timer_infinity_value; + } else { + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--; + } + } + + if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != (int16_t)0xFFFF) { + if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF <= 0){ + /* retxBSR-Timer expires and the UE has data available for transmission for any of the logical channels which belong + to a LCG, in which case the BSR is referred below to as "Regular BSR" + */ + UE_mac_inst[module_idP].retxBSRTimer_expires_flag = 1; + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = (int16_t)0xFFFF; + + } else { + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--; + } + } // Get RLC status info and update Bj for all lcids that are active - for (lcid=DCCH; lcid <= DTCH; lcid++ ) { + for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++ ) { if ((lcid == 0) ||(UE_mac_inst[module_idP].logicalChannelConfig[lcid])) { // meausre the Bj if ((directionP == SF_UL)&& (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) { @@ -1727,6 +1831,12 @@ ue_scheduler( } } + if (lcid == DCCH) { + LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d Pending data for SRB1=%d for LCGID %d \n", + module_idP, frameP,subframeP,UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], + UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); + } + if (update_bsr(module_idP,frameP, eNB_indexP, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) { UE_mac_inst[module_idP].scheduling_info.SR_pending= 1; LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d SR for PUSCH is pending for LCGID %d with BSR level %d (%d bytes in RLC)\n", @@ -1970,41 +2080,108 @@ int get_bsr_lcgid (module_id_t module_idP) } } -uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) +int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen) { - - int lcgid=0; - uint8_t bsr_len=0, num_lcgid=0; + int bsr_type=0; + int lcid,lcgid; int pdu = 0; - - + mac_rlc_status_resp_t rlc_status; + int long_bsr_size=sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_LONG); + int short_bsr_size=sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_SHORT); + int bsr_group_id[MAX_NUM_LCGID]; + int lcg_report_num=0; + for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) { - pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + bsr_len + 2); //2 = sizeof(SCH_SUBHEADER_SHORT) + bsr_group_id[lcgid] = 0; + } + + for (lcid=DCCH; lcid 0 ) { + /* retxBSR-Timer expires and the UE has data available for transmission for any of the logical channels which belong + to a LCG, in which case the BSR is referred below to as "Regular BSR" + */ + if (UE_mac_inst[module_idP].retxBSRTimer_expires_flag == 1) { + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 1; + } + pdu += rlc_status.bytes_in_buffer + sizeof(SCH_SUBHEADER_SHORT); + if (rlc_status.bytes_in_buffer > 128 ) { + pdu += 1; //sizeof(SCH_SUBHEADER_LONG) + } + /* UL data, for a logical channel which belongs to a LCG, becomes available for transmission in the RLC entity + either the data belongs to a logical channel with higher priority than the priorities of the logical channels + which belong to any LCG and for which data is already available for transmission + */ + if (rlc_status.bytes_in_buffer > UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]) { + bsr_group_id[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] ++; + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 1; + } } - - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) { // long header size: adjust the header size - pdu += 1; + } + + /* or there is no data available for transmission for any of the logical channels which belong to a LCG, + in which case the BSR is referred below to as "Regular BSR" + if (pdu == 0) { + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 1; + } + */ + + // computed how many LCG has data available for transmission + for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { + if (bsr_group_id[lcgid] > 0) { + lcg_report_num ++; } - - // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid - - if ( (pdu > buflen) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) ) { - num_lcgid +=1; - bsr_len = (num_lcgid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; - } - - LOG_D(MAC,"BSR Bytes %d for lcgid %d bsr len %d num lcgid %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid], lcgid, bsr_len, num_lcgid); + } + /* + UL resources are allocated and number of padding bits is equal to or larger than the size of the Buffer Status + Report MAC control element plus its subheader, in which case the BSR is referred below to as "Padding BSR" + */ + if ((pdu > 0) && ((pdu+long_bsr_size) <= buflen)) { + UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR] = 1; } - if ( bsr_len > 0 ) - LOG_D(MAC,"[UE %d] Prepare a %s (Transport Block Size %d, MAC pdu Size %d) \n", - module_idP, map_int_to_str(BSR_names, bsr_len), buflen, pdu); + /* For Regular and Periodic BSR + - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Long BSR; + - else report Short BSR. + */ + if ((UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] == 1) + || (UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR] == 1)) { + if (lcg_report_num > 1) { + bsr_type = LONG_BSR; + } else { + bsr_type = SHORT_BSR; + } + } + /* For Padding BSR: + - if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader: + - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission; + - else report Short BSR. + - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR. + */ + if (UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR] == 1) { + if (((pdu + short_bsr_size) <= buflen)&&(buflen<(pdu + long_bsr_size))) { + if (lcg_report_num > 1) { + bsr_type = TRUNCATED_BSR; + } else { + bsr_type = SHORT_BSR; + } + } else if ((pdu + long_bsr_size) <= buflen) { + if (lcg_report_num > 1) { + bsr_type = LONG_BSR; + } else { + bsr_type = SHORT_BSR; + } + } + } - return bsr_len; + if ( bsr_type > 0 ) { + LOG_D(MAC, "[UE %d] bsr_type %d (Transport Block Size %d, MAC pdu len %d) lcg_report_num %d\n", + module_idP, bsr_type, buflen, pdu, lcg_report_num); + } + + return bsr_type; } - boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcg_id) { @@ -2029,10 +2206,12 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in 0); if (rlc_status.bytes_in_buffer > 0 ) { + //BSR trigger SR sr_pending = TRUE; UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; - UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] += locate (BSR_TABLE,BSR_TABLE_SIZE, rlc_status.bytes_in_buffer); + // sum lcid buffer which has same lcgid UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer; + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); @@ -2045,7 +2224,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in return sr_pending; } -uint8_t locate (const uint32_t *table, int size, int value) +uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value) { uint8_t ju, jm, jl; @@ -2144,7 +2323,7 @@ int get_sf_periodicBSRTimer(uint8_t sf_offset) case MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity: default: - return -1; + return 0xFFFF; break; } } diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 83d159f910..236439c6e5 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -45,6 +45,15 @@ const uint32_t BSR_TABLE[BSR_TABLE_SIZE]= {0,10,12,14,17,19,22,26,31,36,42,49,57 1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099, 16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439, 128125,150000, 300000 }; +// extended bsr table--currently not used +const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE] = {0,10,13,16,19,23,29,35,43,53,65,80,98,120,147, + 181,223,274,337,414,509,625,769,945,1162,1429, + 1757,2161,2657,3267,4017,4940,6074,7469,9185, + 11294,13888,17077,20999,25822,31752,39045,48012, + 59039,72598,89272,109774,134986,165989,204111, + 250990,308634,379519,466683,573866,705666,867737, + 1067031,1312097,1613447,1984009,2439678,3000000, + 6000000}; //uint32_t EBSR_Level[63]={0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181}; From 6097e0516f44f018b15b412944a9c18c38daa8f4 Mon Sep 17 00:00:00 2001 From: calvin wang Date: Mon, 14 Nov 2016 11:10:33 +0800 Subject: [PATCH 32/60] fix build error --- openair2/LAYER2/MAC/proto.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 94f1d3448c..3733b27336 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -577,14 +577,14 @@ BSR_LONG * get_bsr_long(module_id_t module_idP, uint8_t bsr_len); */ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcgid); -/*! \fn locate (int *table, int size, int value) +/*! \fn locate_BsrIndexByBufferSize (int *table, int size, int value) \brief locate the BSR level in the table as defined in 36.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table. \param[in] *table Pointer to BSR table \param[in] size Size of the table \param[in] value Value of the buffer \return the index in the BSR_LEVEL table */ -uint8_t locate (const uint32_t *table, int size, int value); +uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value); /*! \fn int get_sf_periodicBSRTimer(uint8_t periodicBSR_Timer) From 3bd591bfec6abfb7939595b188a826488bd33bf5 Mon Sep 17 00:00:00 2001 From: calvin wang Date: Tue, 15 Nov 2016 18:41:46 +0800 Subject: [PATCH 33/60] change bsr trigger --- openair2/LAYER2/MAC/defs.h | 2 ++ openair2/LAYER2/MAC/ue_procedures.c | 39 +++++++++++++++++++---------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index bfaaa3ca1d..c44144d8e7 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -957,6 +957,8 @@ typedef struct { uint16_t BSR_bytes[MAX_NUM_LCGID]; /// after multiplexing buffer remain for each lcid uint16_t LCID_buffer_remain[MAX_NUM_LCID]; + /// sum of all lcid buffer size + uint16_t All_lcid_buffer_size_lastTTI; /// buffer status for each lcid uint8_t LCID_status[MAX_NUM_LCID]; /// SR pending as defined in 36.321 diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 56d4524d7d..d9888b0ba5 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -316,8 +316,6 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; // release all pucch resource - UE_mac_inst[module_idP].physicalConfigDedicated = NULL; - UE_mac_inst[module_idP].ul_active=0; UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR]=0; UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR]=0; UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR]=0; @@ -1313,11 +1311,11 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_type = get_bsr_type(module_idP, eNB_index, frameP, buflen-phr_len); if (bsr_type == LONG_BSR) { - bsr_len = sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_LONG);; + bsr_len = sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_LONG); LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (bsr_type%d) buff_len %d\n", module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_type, buflen); } else if ((bsr_type == SHORT_BSR) || (bsr_type == TRUNCATED_BSR)) { - bsr_len = sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_SHORT);; + bsr_len = sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_SHORT); LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (bsr_type%d) buff_len %d\n", module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_type, buflen); } else { @@ -1457,7 +1455,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf MBMS_FLAG_NO, // eNB_index lcid, (char *)&ulsch_buff[sdu_length_total]); - + //adjust dtch header LOG_D(MAC,"[UE %d] TX Got %d bytes for DTCH\n",module_idP,sdu_lengths[num_sdus]); sdu_lcids[num_sdus] = lcid; @@ -1517,8 +1515,8 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_s->LCGID = lcgid; bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; - LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", - module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); + LOG_I(MAC,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%[UE %d] Frame %d SubFrame %d,report SHORT BSR with level %d for LCGID %d\n", + module_idP, frameP, subframe, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; } else if (bsr_type == TRUNCATED_BSR) { @@ -2068,6 +2066,7 @@ int get_bsr_lcgid (module_id_t module_idP) if (UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] > 0 ) { lcgid_tmp = lcgid; num_active_lcgid+=1; + printf("////////////////////////////////lcgid %d, BSR %d\n",lcgid,UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]); } } @@ -2090,7 +2089,8 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 int short_bsr_size=sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_SHORT); int bsr_group_id[MAX_NUM_LCGID]; int lcg_report_num=0; - + int new_data_arrived_flag=0; + for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { bsr_group_id[lcgid] = 0; } @@ -2112,13 +2112,23 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 either the data belongs to a logical channel with higher priority than the priorities of the logical channels which belong to any LCG and for which data is already available for transmission */ - if (rlc_status.bytes_in_buffer > UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]) { + if (rlc_status.bytes_in_buffer > UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]) { bsr_group_id[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] ++; + new_data_arrived_flag = 1; UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 1; } } } - + +/* + // one lcid buffer increased and all lcid buffer increased + if ((new_data_arrived_flag == 1) && (pdu > UE_mac_inst[module_idP].scheduling_info.All_lcid_buffer_size_lastTTI)) { + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 1; + } +*/ + + UE_mac_inst[module_idP].scheduling_info.All_lcid_buffer_size_lastTTI = pdu; + /* or there is no data available for transmission for any of the logical channels which belong to a LCG, in which case the BSR is referred below to as "Regular BSR" if (pdu == 0) { @@ -2130,6 +2140,7 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { if (bsr_group_id[lcgid] > 0) { lcg_report_num ++; + printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@lcgid bsr %d > 0\n",lcgid); } } /* @@ -2150,6 +2161,7 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 bsr_type = LONG_BSR; } else { bsr_type = SHORT_BSR; + printf("-----------------------------------REGULAR_BSR or PERIODIC_BSR bsr trigger short bsr\n"); } } /* For Padding BSR: @@ -2170,12 +2182,13 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 bsr_type = LONG_BSR; } else { bsr_type = SHORT_BSR; + printf("+++++++++++++++++++++++++++++++++++padding bsr trigger short bsr\n"); } } } if ( bsr_type > 0 ) { - LOG_D(MAC, "[UE %d] bsr_type %d (Transport Block Size %d, MAC pdu len %d) lcg_report_num %d\n", + LOG_I(MAC, "[UE %d] bsr_type %d (Transport Block Size %d, MAC pdu len %d) lcg_report_num %d\n", module_idP, bsr_type, buflen, pdu, lcg_report_num); } @@ -2213,8 +2226,8 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer; UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr - LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", - module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); + LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d,lcid %d rlc buffer %d byte)\n", + module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, lcid,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); } else { UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY; } From f0f34c029b4718069ea3ed2379df0f309ac7b4a2 Mon Sep 17 00:00:00 2001 From: hbilel Date: Tue, 15 Nov 2016 16:13:24 +0100 Subject: [PATCH 34/60] BSR fixes with CMW500 --- openair2/LAYER2/MAC/config.c | 4 +- openair2/LAYER2/MAC/defs.h | 5 +- openair2/LAYER2/MAC/ue_procedures.c | 219 +++++++++++++++++++++++----- 3 files changed, 191 insertions(+), 37 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index d46b761bd0..bca0149791 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -245,8 +245,8 @@ rrc_mac_config_req( UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; } #endif - UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer); - UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer); + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; UE_mac_inst[Mod_idP].BSR_reporting_active = 0; LOG_D(MAC,"[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index d38ca05362..336f3f1039 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -133,6 +133,7 @@ /*!\brief maximum value for channel quality indicator */ #define MAX_CQI_VALUE 15 +#define MAC_UE_BSR_TIMER_NOT_RUNNING (0xFFFF) #define LCID_EMPTY 0 #define LCID_NOT_EMPTY 1 @@ -962,11 +963,11 @@ typedef struct { /// retxBSR-Timer, default value is sf2560 uint16_t retxBSR_Timer; /// retxBSR_SF, number of subframe before triggering a regular BSR - int16_t retxBSR_SF; + uint16_t retxBSR_SF; /// periodicBSR-Timer, default to infinity uint16_t periodicBSR_Timer; /// periodicBSR_SF, number of subframe before triggering a periodic BSR - int16_t periodicBSR_SF; + uint16_t periodicBSR_SF; /// default value is 0: not configured uint16_t sr_ProhibitTimer; /// sr ProhibitTime running diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index c24702b3b5..c2701c5f39 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -91,7 +91,7 @@ void ue_init_mac(module_id_t module_idP) // default values as deined in 36.331 sec 9.2.2 LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP); //UE_mac_inst[module_idP].scheduling_info.macConfig=NULL; - UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer= MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; + UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer= MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf10240; UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer=MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity; UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; @@ -106,8 +106,8 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10=0; UE_mac_inst[module_idP].scheduling_info.drx_config=NULL; UE_mac_inst[module_idP].scheduling_info.phr_config=NULL; - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; UE_mac_inst[module_idP].BSR_reporting_active = 0; UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); @@ -308,14 +308,16 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i // notify RRC to relase PUCCH/SRS // clear any configured dl/ul // initiate RA + if (UE_mac_inst[module_idP].scheduling_info.SR_pending){ + // release all pucch resource + UE_mac_inst[module_idP].physicalConfigDedicated = NULL; + UE_mac_inst[module_idP].ul_active=0; + UE_mac_inst[module_idP].BSR_reporting_active=0; + + LOG_I(MAC,"[UE %d] Release all SRs \n", module_idP); + } UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; - // release all pucch resource - UE_mac_inst[module_idP].physicalConfigDedicated = NULL; - UE_mac_inst[module_idP].ul_active=0; - UE_mac_inst[module_idP].BSR_reporting_active=0; - - LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); return(0); } } @@ -1259,10 +1261,16 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf POWER_HEADROOM_CMD phr; POWER_HEADROOM_CMD *phr_p=&phr; unsigned short short_padding=0, post_padding=0, padding_len=0; - int lcgid; int j; // used for padding // Compute header length int all_pdu_len; + int lcg_id = 0; + int lcg_id_bsr_short = 0; + int num_lcg_id_with_data = 0; + + LOG_D(MAC,"[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n", + module_idP, frameP, subframe, buflen); + if (CC_id>0) { LOG_E(MAC,"Transmission on secondary CCs is not supported yet\n"); @@ -1295,10 +1303,83 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dcch1_header_len=2;//sizeof(SCH_SUBHEADER_SHORT); // hypo length,in case of long header skip the padding byte dtch_header_len=(buflen > 128 ) ? 3 : 2 ; //sizeof(SCH_SUBHEADER_LONG)-1 : sizeof(SCH_SUBHEADER_SHORT); - bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); + bsr_header_len = 0; phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); + while (lcg_id < MAX_NUM_LCGID) { + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]){ + num_lcg_id_with_data ++; + lcg_id_bsr_short = lcg_id; + } + lcg_id ++; + } + + if (num_lcg_id_with_data){ + LOG_I(MAC,"[UE %d] MAC Tx data pending at frame%d subframe %d nb LCG =%d LCG0 bytes=%d BSR Trigger status =%d TBS=%d\n", + module_idP, frameP, subframe, num_lcg_id_with_data, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0],UE_mac_inst[module_idP].BSR_reporting_active, buflen); + + } + // ReTxBSR-Timer expires, trigger BSR + if ((num_lcg_id_with_data) && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF == 0)){ + + // If the UE has data to transmit, trigger a BSR + UE_mac_inst[module_idP].BSR_reporting_active = 1; + + LOG_I(MAC,"[UE %d] MAC BSR Triggered ReTxBSR Timer expiry at frame%d subframe %d TBS=%d\n", + module_idP, frameP, subframe, buflen); + + } + // periodicBSR-Timer expires, trigger BSR + if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer != MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity) + && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == 0)){ + // Trigger BSR + UE_mac_inst[module_idP].BSR_reporting_active = 1; + + LOG_I(MAC,"[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n", + module_idP, frameP, subframe, buflen); + + } + + //Compute BSR Length + if (UE_mac_inst[module_idP].BSR_reporting_active){ + if (buflen >= 4){ + if (num_lcg_id_with_data <= 1){ + bsr_ce_len = sizeof(BSR_SHORT); //1 byte + } + else{ + bsr_ce_len = sizeof(BSR_LONG); //3 bytes + } + + bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); + // Reset Periodic and ReTx BSR Timer + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); + + LOG_I(MAC,"[UE %d] MAC ReTx BSR Timer Reset =%d\n", + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF); + + if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer != MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity){ + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); + + LOG_I(MAC,"[UE %d] MAC Periodic BSR Timer Reset =%d\n", + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF); + + } + + LOG_I(MAC,"[UE %d] MAC BSR Triggered !! bsr (ce%d,hdr%d) buff_len %d\n", + module_idP, bsr_ce_len, bsr_header_len, buflen); + + } + else { + // Cancel Regular and Periodic BSR if Grant is smaller than 4 bytes + UE_mac_inst[module_idP].BSR_reporting_active = 0; + bsr_header_len = 0; + } + } + bsr_len = bsr_ce_len + bsr_header_len; +#if 0 bsr_ce_len = get_bsr_len (module_idP, eNB_index, frameP, buflen); + + // retxBSR-Timer expires or periodicBSR-Timer expires and Regular BSR trigger if ((bsr_ce_len > 0 ) && (UE_mac_inst[module_idP].BSR_reporting_active > 0)) { bsr_len = bsr_ce_len + bsr_header_len; @@ -1310,6 +1391,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf // bsr_ce_len = sizeof(BSR_LONG); //bsr_len = bsr_ce_len + bsr_header_len; } +#endif phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; if (phr_ce_len > 0) { @@ -1336,9 +1418,22 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf MBMS_FLAG_NO, // eNB_index DCCH, (buflen-dcch_header_len-bsr_len-phr_len)); - LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to " - "send (Transport Block size %d, mac header len %d)\n", - module_idP,frameP, rlc_status.bytes_in_buffer,buflen,dcch_header_len); + LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RLC SRB1 has %d bytes to " + "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d)\n", + module_idP,frameP, rlc_status.bytes_in_buffer,buflen,bsr_len,phr_len,sdu_length_total,dcch_header_len); + + /* Update BSR : substract transmitted data */ + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] >= rlc_status.bytes_in_buffer){ + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] -= rlc_status.bytes_in_buffer; + } + else if (rlc_status.bytes_in_buffer){ + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data to transmit=%d for LCID%d\n", + module_idP,frameP,subframe, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]], + UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH], + rlc_status.bytes_in_buffer,DCCH); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] = 0; + } sdu_lengths[0] += mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, @@ -1351,7 +1446,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf sdu_length_total += sdu_lengths[0]; sdu_lcids[0] = DCCH; - LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); + LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU TX Got %d bytes for SRB1\n",module_idP,sdu_lengths[0]); num_sdus = 1; //update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); //header_len +=2; @@ -1379,9 +1474,22 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf DCCH1, (buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-sdu_length_total)); - LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH1 -> ULSCH, RRC message has %d bytes to" - " send (Transport Block size %d, mac header len %d)\n", - module_idP,frameP, rlc_status.bytes_in_buffer,buflen,dcch1_header_len); + LOG_D(MAC,"[UE %d] Frame %d subframe %d: UL-DCCH1 -> ULSCH, RLC SRB2 has %d bytes to" + " send (Transport Block size %d BSR size=%d PHR=%d SRB1 Hdr %d SDU Length Total %d , mac header len %d)\n", + module_idP,frameP, subframe, rlc_status.bytes_in_buffer,buflen,bsr_len,phr_len,dcch_header_len,sdu_length_total,dcch1_header_len); + + /* Update BSR : substract transmitted data */ + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] >= rlc_status.bytes_in_buffer){ + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] -= rlc_status.bytes_in_buffer; + } + else if (rlc_status.bytes_in_buffer){ + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data to transmit=%d for LCID%d\n", + module_idP,frameP,subframe, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]], + UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1], + rlc_status.bytes_in_buffer,DCCH1); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] = 0; + } sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, @@ -1393,7 +1501,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf (char *)&ulsch_buff[sdu_lengths[num_sdus]]); sdu_length_total += sdu_lengths[num_sdus]; sdu_lcids[num_sdus] = DCCH1; - LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH1\n",module_idP,sdu_lengths[num_sdus]); + LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU Got %d bytes for SRB2\n",module_idP,sdu_lengths[num_sdus]); //update_bsr(module_idP, frameP, DCCH1); //dcch_header_len +=2; // include dcch1 UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] = LCID_EMPTY; @@ -1438,6 +1546,19 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); if (rlc_status.bytes_in_buffer > 0) { + /* Update BSR : substract transmitted data */ + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] >= rlc_status.bytes_in_buffer){ + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] -= rlc_status.bytes_in_buffer; + } + else { + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data to transmit=%d for LCID%d\n", + module_idP,frameP,subframe, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], + UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], + rlc_status.bytes_in_buffer,lcid); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] = 0; + } + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_index, @@ -1469,12 +1590,18 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf } } - lcgid= get_bsr_lcgid(module_idP); + //lcgid= get_bsr_lcgid(module_idP); - if (lcgid < 0 ) { + // Compute BSR Values + for (lcg_id=0;lcg_idBuffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; @@ -1497,14 +1624,14 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] = 0; } else if (bsr_ce_len == sizeof(BSR_SHORT)) { bsr_l = NULL; - bsr_s->LCGID = lcgid; - bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; + bsr_s->LCGID = lcg_id_bsr_short; + bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_short]; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id_bsr_short] = 0; + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_short] = 0; LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", - module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); + module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_short],lcg_id_bsr_short); } else { bsr_s = NULL; bsr_l = NULL; @@ -1589,8 +1716,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; UE_mac_inst[module_idP].BSR_reporting_active=0; - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); @@ -1753,6 +1878,23 @@ ue_scheduler( // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures // outlined in Sections 5.4.4 an 5.4.5 of 36.321 // Call BSR procedure as described in Section 5.4.5 in 36.321 + + // TODO : Fix Periodic and ReTx BSR Timers + // First check ReTxBSR Timer because it is always configured +#if 1 + // Decrement ReTxBSR Timer if it is running and not null + if ((UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != MAC_UE_BSR_TIMER_NOT_RUNNING) + && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != 0)){ + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF --; + } + + // Decrement Periodic Timer if it is running and not null + if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != MAC_UE_BSR_TIMER_NOT_RUNNING) + && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != 0)){ + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF --; + } + +#else if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == get_sf_periodicBSRTimer(MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity)) { UE_mac_inst[module_idP].BSR_reporting_active = 1; } else if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF <= 0 ){ @@ -1768,6 +1910,7 @@ ue_scheduler( } else if (UE_mac_inst[module_idP].BSR_reporting_active == 0 ) { UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--; } +#endif // Get RLC status info and update Bj for all lcids that are active for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++ ) { @@ -2053,12 +2196,22 @@ uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,ui num_lcid +=1; bsr_len = (num_lcid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; } + else if (rlc_status.bytes_in_buffer) { + LOG_I(MAC,"pdu smaller than TBS! pdu=%d TBS=%d lcid=%d rlc buffer=%d bsr len=%d num lcid=%d\n",pdu,buflen,lcid,rlc_status.bytes_in_buffer,bsr_len, num_lcid); + } LOG_D(MAC,"LC buffer Bytes %d for lcid %d bsr len %d num lcid %d\n", rlc_status.bytes_in_buffer, lcid, bsr_len, num_lcid); } if ( bsr_len > 0 ) - LOG_D(MAC,"[UE %d] Prepare a %s (Transport Block Size %d, MAC pdu Size %d) \n", - module_idP, map_int_to_str(BSR_names, bsr_len), buflen, pdu); + { + LOG_D(MAC,"[UE %d] Prepare a %s (Transport Block Size %d, MAC pdu Size %d) \n", + module_idP, map_int_to_str(BSR_names, bsr_len), buflen, pdu); + } + else if (rlc_status.bytes_in_buffer){ + LOG_I(MAC,"[UE %d] UL Transport Block size is 0 while RLC has pending data=%d pdu=%d\n", + module_idP, rlc_status.bytes_in_buffer,pdu); + + } return bsr_len; } @@ -2098,8 +2251,8 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer; UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr - LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", - module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); + LOG_D(MAC,"[UE %d] SR Triggered BSR level %d (LCID %d LCGID %d, rlc buffer=%d byte Total BO=%d)\n", + module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcid,lcg_id, rlc_status.bytes_in_buffer, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); } else { UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY; } From 69ccc900e89ddea4711d86861aec4d7452d9dfbb Mon Sep 17 00:00:00 2001 From: fnabet Date: Wed, 16 Nov 2016 18:24:04 +0100 Subject: [PATCH 35/60] fix BSR long size and fill --- openair2/LAYER2/MAC/defs.h | 9 ++++----- openair2/LAYER2/MAC/ue_procedures.c | 8 +++----- targets/SIMU/USER/oaisim.c | 2 ++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 336f3f1039..82907eb40a 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -223,11 +223,10 @@ typedef struct { typedef BSR_SHORT BSR_TRUNCATED; /*!\brief mac control element: long buffer status report for all logical channel group ID*/ typedef struct { - uint32_t Buffer_size3:6; - uint32_t Buffer_size2:6; - uint32_t Buffer_size1:6; - uint32_t Buffer_size0:6; - uint32_t padding:8; + uint8_t Buffer_size3:6; + uint8_t Buffer_size2:6; + uint8_t Buffer_size1:6; + uint8_t Buffer_size0:6; } __attribute__((__packed__))BSR_LONG; #define BSR_LONG_SIZE (sizeof(BSR_LONG)) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index c2701c5f39..65bb4c09aa 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -1147,8 +1147,6 @@ unsigned char generate_ulsch_header(uint8_t *mac_header, *(ce_ptr) = (long_bsr->Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4); *(ce_ptr + 1) = ((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr->Buffer_size2 & 0x3C) >> 2); *(ce_ptr + 2) = ((long_bsr->Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F); - /* Padding */ - *(ce_ptr + 3) = 0; ce_ptr += BSR_LONG_SIZE; // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); @@ -1347,7 +1345,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_ce_len = sizeof(BSR_SHORT); //1 byte } else{ - bsr_ce_len = sizeof(BSR_LONG); //3 bytes + bsr_ce_len = BSR_LONG_SIZE; //3 bytes } bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); @@ -1601,7 +1599,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_s = NULL; bsr_l = NULL ; //TO DO : compute padding or truncated BSR - } else if (bsr_ce_len == sizeof(BSR_LONG)) { + } else if (bsr_ce_len == BSR_LONG_SIZE) { bsr_s = NULL; bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; @@ -2194,7 +2192,7 @@ uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,ui } if ( (pdu > buflen) && (rlc_status.bytes_in_buffer > 0 ) ) { num_lcid +=1; - bsr_len = (num_lcid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; + bsr_len = (num_lcid >= 2 ) ? BSR_LONG_SIZE : sizeof(BSR_SHORT) ; } else if (rlc_status.bytes_in_buffer) { LOG_I(MAC,"pdu smaller than TBS! pdu=%d TBS=%d lcid=%d rlc buffer=%d bsr len=%d num lcid=%d\n",pdu,buflen,lcid,rlc_status.bytes_in_buffer,bsr_len, num_lcid); diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 79cd2fcc38..f136c605f8 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -122,6 +122,8 @@ char smbv_ip[16]; //#define K 2 /* averaging coefficient */ //#define TARGET_SF_TIME_NS 1000000 /* 1ms = 1000000 ns */ +uint8_t usim_test = 0; + frame_t frame = 0; char stats_buffer[16384]; channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs]; From 319ae6fbbf7034c96e600dabde81fcd0ef474a51 Mon Sep 17 00:00:00 2001 From: calvin wang Date: Fri, 18 Nov 2016 16:44:18 +0800 Subject: [PATCH 36/60] fix bsr report inaccurate value --- openair2/LAYER2/MAC/config.c | 53 +++++++------ openair2/LAYER2/MAC/defs.h | 8 +- openair2/LAYER2/MAC/proto.h | 6 +- openair2/LAYER2/MAC/ue_procedures.c | 115 +++++++++++++++++----------- 4 files changed, 109 insertions(+), 73 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 2a6390740c..86062edfa9 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -1,24 +1,31 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ +/******************************************************************************* + OpenAirInterface + Copyright(c) 1999 - 2014 Eurecom + OpenAirInterface is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + + OpenAirInterface is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OpenAirInterface.The full GNU General Public License is + included in this distribution in the file called "COPYING". If not, + see . + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr + + Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE + +*******************************************************************************/ /*! \file config.c * \brief UE and eNB configuration performed by RRC or as a consequence of RRC procedures * \author Navid Nikaein and Raymond Knopp @@ -73,6 +80,7 @@ void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index) UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR]=0; UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR]=0; UE_mac_inst[module_idP].retxBSRTimer_expires_flag = 0; + UE_mac_inst[module_idP].periodBSRTimer_expires_flag = 0; // stop ongoing RACH procedure // discard explicitly signaled ra_PreambleIndex and ra_RACH_MaskIndex, if any @@ -247,12 +255,13 @@ rrc_mac_config_req( UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0; } #endif - UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = 0xFFFF; - UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = 0xFFFF; + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; UE_mac_inst[Mod_idP].BSR_reporting_active[REGULAR_BSR]=0; UE_mac_inst[Mod_idP].BSR_reporting_active[PADDING_BSR]=0; UE_mac_inst[Mod_idP].BSR_reporting_active[PERIODIC_BSR]=0; UE_mac_inst[Mod_idP].retxBSRTimer_expires_flag = 0; + UE_mac_inst[Mod_idP].periodBSRTimer_expires_flag = 0; LOG_D(MAC,"[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", Mod_idP, diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index c44144d8e7..426ebc610e 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -133,6 +133,8 @@ /*!\brief maximum value for channel quality indicator */ #define MAX_CQI_VALUE 15 +//if value equal oxFFFF means counters are NOT active +#define MAC_UE_BSR_TIMER_NOT_RUNNING (0xFFFF) #define LCID_EMPTY 0 #define LCID_NOT_EMPTY 1 @@ -226,7 +228,6 @@ typedef struct { uint32_t Buffer_size2:6; uint32_t Buffer_size1:6; uint32_t Buffer_size0:6; - uint32_t padding:8; } __attribute__((__packed__))BSR_LONG; #define BSR_LONG_SIZE (sizeof(BSR_LONG)) @@ -345,6 +346,7 @@ typedef enum { PERIODIC_BSR } UE_FIRST_LEVEL_BSR_TYPE; + /*! \brief Downlink SCH PDU Structure */ typedef struct { int8_t payload[8][SCH_PAYLOAD_SIZE_MAX]; @@ -1096,7 +1098,9 @@ typedef struct { uint8_t BSR_reporting_active[BSR_TYPE_FIRST_LEVEL]; /// retxBSR-Timer expires flag uint8_t retxBSRTimer_expires_flag; - + /// periodBSR-Timer expires flag + uint8_t periodBSRTimer_expires_flag; + /// MBSFN_Subframe Configuration struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA? /// number of subframe allocation pattern available for MBSFN sync area diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 3733b27336..69dc7baade 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -538,14 +538,14 @@ UE_L2_STATE_t ue_scheduler( */ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen); -/*! \fn int get_bsr_lcgid (module_id_t module_idP); +/*! \fn int update_bsr_and_get_bsr_lcgid (module_id_t module_idP); \brief determine the lcgid for the bsr \param[in] Mod_id instance of the UE \param[out] lcgid */ -int get_bsr_lcgid (module_id_t module_idP); +int update_bsr_and_get_bsr_lcgid (module_id_t module_idP); -/*! \fn int get_bsr_type (module_id_t module_idP,uint16_t bufflen); +/*! \fn int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen); \brief determine whether the bsr is short or long assuming that the MAC pdu is built \param[in] Mod_id instance of the UE \param[in] bufflen size of phy transport block diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index d9888b0ba5..4d21762924 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -91,7 +91,7 @@ void ue_init_mac(module_id_t module_idP) // default values as deined in 36.331 sec 9.2.2 LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP); //UE_mac_inst[module_idP].scheduling_info.macConfig=NULL; - UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer= MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; + UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer= MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf10240; UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer=MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity; UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; @@ -107,13 +107,14 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.drx_config=NULL; UE_mac_inst[module_idP].scheduling_info.phr_config=NULL; // set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW. - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = 0xFFFF; - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = 0xFFFF; + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR]=0; UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR]=0; UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR]=0; UE_mac_inst[module_idP].retxBSRTimer_expires_flag = 0; + UE_mac_inst[module_idP].periodBSRTimer_expires_flag = 0; UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[module_idP].scheduling_info.PathlossChange); @@ -320,6 +321,7 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR]=0; UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR]=0; UE_mac_inst[module_idP].retxBSRTimer_expires_flag = 0; + UE_mac_inst[module_idP].periodBSRTimer_expires_flag = 0; LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); return(0); } @@ -1359,12 +1361,25 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf num_sdus = 1; //update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); //header_len +=2; + // update LCID remain buffer UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] = LCID_EMPTY; if (rlc_status.bytes_in_buffer > sdu_lengths[0]) { UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] = rlc_status.bytes_in_buffer-sdu_lengths[0]; } else { UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] = 0; } + // update LCGID buffer, in order to get right BSR value + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > sdu_lengths[0]) { + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] -= sdu_lengths[0]; + } else { + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] = 0; + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data to transmit=%d for LCID%d\n", + module_idP,frameP,subframe, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]], + UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH], + rlc_status.bytes_in_buffer,DCCH); + } + } else { dcch_header_len=0; num_sdus = 0; @@ -1408,7 +1423,11 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf } else { UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] = 0; } - + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] > sdu_lengths[num_sdus]) { + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] -= sdu_lengths[num_sdus]; + } else { + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] = 0; + } num_sdus++; } else { dcch1_header_len =0; @@ -1416,7 +1435,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len=0; dtch_header_len_last=0; - for (lcid=NB_RB_MAX-1; lcid>=DTCH ; lcid--){ + for (lcid=MAX_NUM_LCID-1; lcid>=DTCH ; lcid--){ dtch_header_len+=3; dtch_header_len_last=3; @@ -1469,7 +1488,13 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf } else { UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = 0; } - + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] > sdu_lengths[num_sdus]) { + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] -= sdu_lengths[num_sdus]; + } else { + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] = 0; + } + printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~rlc_status.bytes_in_buffer %d,sdu_lengths[num_sdus] %d buflen %d all_pdu_len %d\n" + ,rlc_status.bytes_in_buffer ,sdu_lengths[num_sdus],buflen, all_pdu_len); //UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); num_sdus++; } else { @@ -1481,13 +1506,13 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf } } - lcgid= get_bsr_lcgid(module_idP); + lcgid= update_bsr_and_get_bsr_lcgid(module_idP); if (lcgid < 0 ) { bsr_s = NULL; bsr_l = NULL; bsr_t = NULL; - } else if ((lcgid ==MAX_NUM_LCGID) && (bsr_type == LONG_BSR)) { + } else if (bsr_type == LONG_BSR) { bsr_s = NULL; bsr_t = NULL; bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; @@ -1500,15 +1525,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); - - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID0] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID1] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID2] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID3] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] = 0; } else if (bsr_type == SHORT_BSR) { bsr_l = NULL; bsr_t = NULL; @@ -1517,8 +1533,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf LOG_I(MAC,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%[UE %d] Frame %d SubFrame %d,report SHORT BSR with level %d for LCGID %d\n", module_idP, frameP, subframe, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; } else if (bsr_type == TRUNCATED_BSR) { bsr_l = NULL; bsr_s = NULL; @@ -1527,8 +1541,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; } else { bsr_s = NULL; bsr_l = NULL; @@ -1620,6 +1632,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); UE_mac_inst[module_idP].retxBSRTimer_expires_flag = 0; + UE_mac_inst[module_idP].periodBSRTimer_expires_flag = 0; } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); @@ -1789,7 +1802,7 @@ ue_scheduler( /* periodicBSR-Timer expires, in which case the BSR is referred below to as "Periodic BSR". */ - UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR] = 1; + UE_mac_inst[module_idP].periodBSRTimer_expires_flag = 1; UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = periodicBSR_Timer_infinity_value; } else { UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--; @@ -2057,16 +2070,18 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 } #endif -int get_bsr_lcgid (module_id_t module_idP) +//AFTER transmission update BSR value, and get witch LCGID have BSR +int update_bsr_and_get_bsr_lcgid (module_id_t module_idP) { int lcgid, lcgid_tmp=-1; int num_active_lcgid = 0; for (lcgid = 0 ; lcgid < MAX_NUM_LCGID; lcgid++) { + // update BSR value, then ue can reprot correct value + UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid]); if (UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] > 0 ) { lcgid_tmp = lcgid; num_active_lcgid+=1; - printf("////////////////////////////////lcgid %d, BSR %d\n",lcgid,UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]); } } @@ -2087,12 +2102,12 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 mac_rlc_status_resp_t rlc_status; int long_bsr_size=sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_LONG); int short_bsr_size=sizeof(SCH_SUBHEADER_FIXED)+sizeof(BSR_SHORT); - int bsr_group_id[MAX_NUM_LCGID]; - int lcg_report_num=0; + int lcgid_have_bsr_report_flag[MAX_NUM_LCGID]; + int num_lcg_id_with_data=0; int new_data_arrived_flag=0; for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { - bsr_group_id[lcgid] = 0; + lcgid_have_bsr_report_flag[lcgid] = 0; } for (lcid=DCCH; lcid 128 ) { @@ -2113,43 +2133,46 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 which belong to any LCG and for which data is already available for transmission */ if (rlc_status.bytes_in_buffer > UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]) { - bsr_group_id[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] ++; + lcgid_have_bsr_report_flag[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] = 1; new_data_arrived_flag = 1; - UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 1; } } } -/* // one lcid buffer increased and all lcid buffer increased if ((new_data_arrived_flag == 1) && (pdu > UE_mac_inst[module_idP].scheduling_info.All_lcid_buffer_size_lastTTI)) { UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 1; } -*/ - UE_mac_inst[module_idP].scheduling_info.All_lcid_buffer_size_lastTTI = pdu; - - /* or there is no data available for transmission for any of the logical channels which belong to a LCG, - in which case the BSR is referred below to as "Regular BSR" - if (pdu == 0) { + /* empty buffer, report 0 bsr reset eNB buffer + */ + if ((pdu == 0) && (UE_mac_inst[module_idP].scheduling_info.All_lcid_buffer_size_lastTTI > 0)) { UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 1; } - */ - // computed how many LCG has data available for transmission + UE_mac_inst[module_idP].scheduling_info.All_lcid_buffer_size_lastTTI = pdu; + + // computed how many LCGID has data available for transmission for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { - if (bsr_group_id[lcgid] > 0) { - lcg_report_num ++; - printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@lcgid bsr %d > 0\n",lcgid); + if (lcgid_have_bsr_report_flag[lcgid] == 1) { + num_lcg_id_with_data ++; + printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@lcgid %d have bsr report\n",lcgid); } } /* UL resources are allocated and number of padding bits is equal to or larger than the size of the Buffer Status Report MAC control element plus its subheader, in which case the BSR is referred below to as "Padding BSR" - */ if ((pdu > 0) && ((pdu+long_bsr_size) <= buflen)) { UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR] = 1; } + */ + + if ((pdu+long_bsr_size) <= buflen) { + UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR] = 0; + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 0; + UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] = 0; + //printf("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&ping test\n"); + } /* For Regular and Periodic BSR - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Long BSR; @@ -2157,7 +2180,7 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 */ if ((UE_mac_inst[module_idP].BSR_reporting_active[REGULAR_BSR] == 1) || (UE_mac_inst[module_idP].BSR_reporting_active[PERIODIC_BSR] == 1)) { - if (lcg_report_num > 1) { + if (num_lcg_id_with_data > 1) { bsr_type = LONG_BSR; } else { bsr_type = SHORT_BSR; @@ -2172,13 +2195,13 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 */ if (UE_mac_inst[module_idP].BSR_reporting_active[PADDING_BSR] == 1) { if (((pdu + short_bsr_size) <= buflen)&&(buflen<(pdu + long_bsr_size))) { - if (lcg_report_num > 1) { + if (num_lcg_id_with_data > 1) { bsr_type = TRUNCATED_BSR; } else { bsr_type = SHORT_BSR; } } else if ((pdu + long_bsr_size) <= buflen) { - if (lcg_report_num > 1) { + if (num_lcg_id_with_data > 1) { bsr_type = LONG_BSR; } else { bsr_type = SHORT_BSR; @@ -2189,7 +2212,7 @@ int get_bsr_type (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint1 if ( bsr_type > 0 ) { LOG_I(MAC, "[UE %d] bsr_type %d (Transport Block Size %d, MAC pdu len %d) lcg_report_num %d\n", - module_idP, bsr_type, buflen, pdu, lcg_report_num); + module_idP, bsr_type, buflen, pdu, num_lcg_id_with_data); } return bsr_type; From 7f74065484a6f30e82116fc65e0931698b0cfb38 Mon Sep 17 00:00:00 2001 From: GabrirelCouturier Date: Fri, 18 Nov 2016 15:22:11 +0100 Subject: [PATCH 37/60] BSR fixes for ping --- openair2/LAYER2/MAC/ue_procedures.c | 162 +++++++++++++++++----------- 1 file changed, 102 insertions(+), 60 deletions(-) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 65bb4c09aa..cad41c86a5 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -1313,20 +1313,23 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf } if (num_lcg_id_with_data){ - LOG_I(MAC,"[UE %d] MAC Tx data pending at frame%d subframe %d nb LCG =%d LCG0 bytes=%d BSR Trigger status =%d TBS=%d\n", - module_idP, frameP, subframe, num_lcg_id_with_data, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0],UE_mac_inst[module_idP].BSR_reporting_active, buflen); + LOG_D(MAC,"[UE %d] MAC Tx data pending at frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", + module_idP, + frameP, + subframe, + num_lcg_id_with_data, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], + UE_mac_inst[module_idP].BSR_reporting_active, buflen); } - // ReTxBSR-Timer expires, trigger BSR - if ((num_lcg_id_with_data) && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF == 0)){ - - // If the UE has data to transmit, trigger a BSR - UE_mac_inst[module_idP].BSR_reporting_active = 1; - - LOG_I(MAC,"[UE %d] MAC BSR Triggered ReTxBSR Timer expiry at frame%d subframe %d TBS=%d\n", - module_idP, frameP, subframe, buflen); - + //Restart ReTxBSR Timer at new grant indication (36.321) + if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != MAC_UE_BSR_TIMER_NOT_RUNNING){ + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); } + // periodicBSR-Timer expires, trigger BSR if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer != MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity) && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == 0)){ @@ -1342,6 +1345,17 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf if (UE_mac_inst[module_idP].BSR_reporting_active){ if (buflen >= 4){ if (num_lcg_id_with_data <= 1){ + + // If there are no data to transmit Set LCGID short to the group of the first DTCH configured else it will be SRB + if (num_lcg_id_with_data == 0) { + for (lcid=DTCH; lcid < MAX_NUM_LCID; lcid++) { + if (UE_mac_inst[module_idP].logicalChannelConfig[lcid] != NULL) { + lcg_id_bsr_short = UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]; + break; + } + } + } + bsr_ce_len = sizeof(BSR_SHORT); //1 byte } else{ @@ -1417,31 +1431,33 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf DCCH, (buflen-dcch_header_len-bsr_len-phr_len)); LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RLC SRB1 has %d bytes to " - "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d)\n", - module_idP,frameP, rlc_status.bytes_in_buffer,buflen,bsr_len,phr_len,sdu_length_total,dcch_header_len); + "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", + module_idP,frameP, rlc_status.bytes_in_buffer,buflen,bsr_len,phr_len,sdu_length_total,dcch_header_len,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]]); - /* Update BSR : substract transmitted data */ - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] >= rlc_status.bytes_in_buffer){ - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] -= rlc_status.bytes_in_buffer; - } - else if (rlc_status.bytes_in_buffer){ - LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data to transmit=%d for LCID%d\n", - module_idP,frameP,subframe, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]], - UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH], - rlc_status.bytes_in_buffer,DCCH); - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] = 0; - } - sdu_lengths[0] += mac_rlc_data_req(module_idP, + sdu_lengths[0] += mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_index, frameP, - ENB_FLAG_NO, + ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, (char *)&ulsch_buff[sdu_lengths[0]]); + /* Update BSR : substract transmitted data */ + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] >= sdu_lengths[0]){ + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] -= sdu_lengths[0]; + } + else { + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data transmitted=%d for LCID%d\n", + module_idP,frameP,subframe, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]], + UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH], + sdu_lengths[0],DCCH); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] = 0; + } + + sdu_length_total += sdu_lengths[0]; sdu_lcids[0] = DCCH; LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU TX Got %d bytes for SRB1\n",module_idP,sdu_lengths[0]); @@ -1473,23 +1489,10 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf (buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-sdu_length_total)); LOG_D(MAC,"[UE %d] Frame %d subframe %d: UL-DCCH1 -> ULSCH, RLC SRB2 has %d bytes to" - " send (Transport Block size %d BSR size=%d PHR=%d SRB1 Hdr %d SDU Length Total %d , mac header len %d)\n", - module_idP,frameP, subframe, rlc_status.bytes_in_buffer,buflen,bsr_len,phr_len,dcch_header_len,sdu_length_total,dcch1_header_len); + " send (Transport Block size %d BSR size=%d PHR=%d SRB1 Hdr %d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", + module_idP,frameP, subframe, rlc_status.bytes_in_buffer,buflen,bsr_len,phr_len,dcch_header_len,sdu_length_total,dcch1_header_len,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]]); - /* Update BSR : substract transmitted data */ - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] >= rlc_status.bytes_in_buffer){ - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] -= rlc_status.bytes_in_buffer; - } - else if (rlc_status.bytes_in_buffer){ - LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data to transmit=%d for LCID%d\n", - module_idP,frameP,subframe, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]], - UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1], - rlc_status.bytes_in_buffer,DCCH1); - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] = 0; - } - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_index, frameP, @@ -1497,6 +1500,20 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf MBMS_FLAG_NO, DCCH1, (char *)&ulsch_buff[sdu_lengths[num_sdus]]); + + /* Update BSR : substract transmitted data */ + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] >= sdu_lengths[num_sdus]){ + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] -= sdu_lengths[num_sdus]; + } + else { + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data transmitted=%d for LCID%d\n", + module_idP,frameP,subframe, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]], + UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1], + sdu_lengths[num_sdus],DCCH1); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] = 0; + } + sdu_length_total += sdu_lengths[num_sdus]; sdu_lcids[num_sdus] = DCCH1; LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU Got %d bytes for SRB2\n",module_idP,sdu_lengths[num_sdus]); @@ -1513,7 +1530,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf dtch_header_len=0; dtch_header_len_last=0; - for (lcid=NB_RB_MAX-1; lcid>=DTCH ; lcid--){ + for (lcid=MAX_NUM_LCID-1; lcid>=DTCH ; lcid--){ dtch_header_len+=3; dtch_header_len_last=3; @@ -1521,6 +1538,8 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf if ((UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) && (all_pdu_len <= buflen)) { + AssertFatal (UE_mac_inst[module_idP].logicalChannelConfig[lcid] != NULL, "LCID (%d) is not active!\n", lcid); + // optimize the dtch header lenght //if ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] > 128) && /* if (((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] >= 128) && @@ -1539,23 +1558,10 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf lcid, buflen-all_pdu_len); - LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[%d] %d)\n", - module_idP,frameP, lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len, - lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); + LOG_D(MAC,"[UE %d] Frame %d subframe %d: UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte before Tx=%d)\n", + module_idP,frameP, subframe,lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); if (rlc_status.bytes_in_buffer > 0) { - /* Update BSR : substract transmitted data */ - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] >= rlc_status.bytes_in_buffer){ - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] -= rlc_status.bytes_in_buffer; - } - else { - LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data to transmit=%d for LCID%d\n", - module_idP,frameP,subframe, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], - UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], - rlc_status.bytes_in_buffer,lcid); - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] = 0; - } sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, @@ -1566,8 +1572,21 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf lcid, (char *)&ulsch_buff[sdu_length_total]); + /* Update BSR : substract transmitted data */ + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] >= sdu_lengths[num_sdus]){ + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] -= sdu_lengths[num_sdus]; + } + else { + LOG_I(MAC, "[UE %d] Frame %d Subframe %d: WARNING Buffer occupancy =%d for LCGID%d is lower than data transmitted=%d for LCID%d\n", + module_idP,frameP,subframe, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], + UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], + sdu_lengths[num_sdus],lcid); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] = 0; + } + //adjust dtch header - LOG_D(MAC,"[UE %d] TX Got %d bytes for DTCH\n",module_idP,sdu_lengths[num_sdus]); + LOG_D(MAC,"[UE %d] Frame %d Subframe %d TX Got %d bytes for DTCH%d New BSR bytes=%d\n",module_idP,frameP,subframe,sdu_lengths[num_sdus],lcid,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); sdu_lcids[num_sdus] = lcid; sdu_length_total += sdu_lengths[num_sdus]; if (sdu_lengths[num_sdus] < 128) { @@ -1595,6 +1614,15 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); } + if (bsr_ce_len) { + //Print updated BSR when sent + LOG_D(MAC,"[UE %d] Frame %d Subframe %d TX BSR size=%d BSR0=%d BSR1=%d BSR2=%d BSR3=%d\n",module_idP,frameP,subframe,bsr_ce_len, + UE_mac_inst[module_idP].scheduling_info.BSR[0], + UE_mac_inst[module_idP].scheduling_info.BSR[1], + UE_mac_inst[module_idP].scheduling_info.BSR[2], + UE_mac_inst[module_idP].scheduling_info.BSR[3]); + } + if (bsr_ce_len == 0 ) { bsr_s = NULL; bsr_l = NULL ; @@ -1751,6 +1779,8 @@ ue_scheduler( // int8_t lcg_id; struct RACH_ConfigCommon *rach_ConfigCommon = (struct RACH_ConfigCommon *)NULL; protocol_ctxt_t ctxt; + int num_lcid_with_data = 0; + #if defined(ENABLE_ITTI) MessageDef *msg_p; const char *msg_name; @@ -1931,6 +1961,8 @@ ue_scheduler( } if (update_bsr(module_idP,frameP, eNB_indexP, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) { + // TO DO: implement first BSR trigger criteria based on new data become available + num_lcid_with_data ++; UE_mac_inst[module_idP].scheduling_info.SR_pending= 1; // Regular BSR trigger UE_mac_inst[module_idP].BSR_reporting_active = 1; @@ -1942,6 +1974,16 @@ ue_scheduler( } } + // Trigger Regular BSR if ReTxBSR Timer has expired and UE has data for transmission + if ((num_lcid_with_data) && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF == 0)) { + + UE_mac_inst[module_idP].BSR_reporting_active = 1; + + LOG_D(MAC,"[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d subframe %d\n", + module_idP, frameP, subframeP); + + } + // UE has no valid phy config dedicated || no valid/released SR if ((UE_mac_inst[module_idP].physicalConfigDedicated == NULL)) { // cancel all pending SRs From 9c4cee34f0778222c8fffc75e19f6bccfc9b7150 Mon Sep 17 00:00:00 2001 From: GabrirelCouturier Date: Mon, 21 Nov 2016 11:30:24 +0100 Subject: [PATCH 38/60] [OAI-UE] several fixes in OAI-UE 1- implement max harq retrans 2- bug in harqId > 1 for dci format 1A 3- wrong G computation 4- bug in harq UL for scheduling flag 5- initial sync, limit freq offset to 150Hz --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 74 ++++++++++++++++--- openair1/PHY/LTE_TRANSPORT/defs.h | 7 +- openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c | 11 ++- openair1/PHY/LTE_TRANSPORT/initial_sync.c | 2 +- openair1/PHY/LTE_TRANSPORT/phich.c | 42 +++++++++-- openair1/PHY/LTE_TRANSPORT/ulsch_coding.c | 15 ++++ openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c | 8 +- openair1/SCHED/phy_procedures_lte_ue.c | 20 ++++- openair2/UTIL/LOG/vcd_signal_dumper.c | 4 + openair2/UTIL/LOG/vcd_signal_dumper.h | 4 + 10 files changed, 161 insertions(+), 26 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index da678088fd..c55290adf8 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -36,7 +36,10 @@ #include "PHY/vars.h" #endif #include "assertions.h" - + +#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/defs.h" + //#define DEBUG_DCI uint32_t localRIV2alloc_LUT6[32]; @@ -3922,10 +3925,10 @@ int generate_ue_dlsch_params_from_dci(int frame, dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; } else { - if (harq_pid>1) { - LOG_E(PHY,"Format 1A: harq_pid > 1\n"); - return(-1); - } + //if (harq_pid>1) { + // LOG_E(PHY,"Format 1A: harq_pid > 1\n"); + // return(-1); + //} dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; NPRB = RIV2nb_rb_LUT25[rballoc]; @@ -5552,7 +5555,8 @@ int generate_ue_dlsch_params_from_dci(int frame, #ifdef DEBUG_DCI - if (dlsch[0]) { + if (dlsch[0] && (dlsch[0]->rnti != 0xffff)) { + printf("dci_format:%d \n",dci_format); printf("PDSCH dlsch0 UE: rnti %x\n",dlsch[0]->rnti); printf("PDSCH dlsch0 UE: NBRB %d\n",dlsch0_harq->nb_rb); printf("PDSCH dlsch0 UE: rballoc %x\n",dlsch0_harq->rb_alloc_even[0]); @@ -6396,7 +6400,11 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, if ((rnti >= cba_rnti) && (rnti < p_rnti)) ulsch->harq_processes[harq_pid]->subframe_cba_scheduling_flag = 1; //+=1 this indicates the number of dci / cba group: not supported in the data struct else - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + //LOG_I(PHY,"[HARQ-UL harqId: %d] DCI0 ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + + } ulsch->harq_processes[harq_pid]->TPC = TPC; @@ -6426,7 +6434,41 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, ulsch->harq_processes[harq_pid]->round = 0; } else { // ulsch->harq_processes[harq_pid]->Ndi = 0; - // ulsch->harq_processes[harq_pid]->round++; // This is done in phich RX + //ulsch->harq_processes[harq_pid]->round++; // This is done in phich RX + + //#ifdef DEBUG_PHICH + //LOG_I(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d Adaptative Retrans, NDI not toggled => Nack. maxHARQ_Tx %d \n", + // ue->Mod_id,harq_pid, + // proc->frame_rx, + // subframe, + // UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx); + //#endif + + + ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; + ulsch->harq_processes[harq_pid]->round++; + //LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); + + + if (ulsch->harq_processes[harq_pid]->round >= UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) + { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + ulsch->harq_processes[harq_pid]->round = 0; + ulsch->harq_processes[harq_pid]->status = IDLE; + //LOG_I(PHY," PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); + //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + } + else + { + // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + uint8_t rv_table[4] = {0, 2, 3, 1}; + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); + } + } } @@ -6476,7 +6518,16 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, if (cqi_req == 1) { - ulsch->O_RI = 1; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table + + if( (AntennaInfoDedicated__transmissionMode_tm3 == transmission_mode) || (AntennaInfoDedicated__transmissionMode_tm4 == transmission_mode) ) + { + ulsch->O_RI = 1; + } + else + { + ulsch->O_RI = 0; + } + //ulsch->O_RI = 0; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table switch(transmission_mode) { // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling @@ -7039,12 +7090,15 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, #ifdef DEBUG_DCI printf("Format 0 DCI : ulsch (ue): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); printf("Format 0 DCI :ulsch (ue): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); + printf("Format 0 DCI :ulsch (ue): rballoc %d\n",rballoc); printf("Format 0 DCI :ulsch (ue): harq_pid %d\n",harq_pid); + printf("Format 0 DCI :ulsch (ue): first_tx %d\n",ulsch->harq_processes[harq_pid]->first_tx); + printf("Format 0 DCI :ulsch (ue): DCINdi %d\n",ulsch->harq_processes[harq_pid]->DCINdi); printf("Format 0 DCI :ulsch (ue): round %d\n",ulsch->harq_processes[harq_pid]->round); printf("Format 0 DCI :ulsch (ue): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); printf("Format 0 DCI :ulsch (ue): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); printf("Format 0 DCI :ulsch (ue): O %d\n",ulsch->O); - + printf("Format 0 DCI :ulsch (ue): cqiReq %d\n",cqi_req); if (frame_parms->frame_type == TDD) printf("Format 0 DCI :ulsch (ue): O_ACK/DAI %d/%d\n",ulsch->harq_processes[harq_pid]->O_ACK,dai); else diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h index 026ba40340..f8d36d3bd4 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/defs.h @@ -227,6 +227,11 @@ typedef struct { uint8_t control_only; /// Flag to indicate that this is a calibration ULSCH (i.e. no MAC SDU and filled with TDD calibration information) // int calibration_flag; + /// Number of soft channel bits + uint32_t G; + + // decode phich + uint8_t decode_phich; } LTE_UL_UE_HARQ_t; typedef struct { @@ -278,7 +283,7 @@ typedef struct { /// SRS active flag uint8_t srs_active; /// Pointers to 8 HARQ processes for the ULSCH - LTE_UL_UE_HARQ_t *harq_processes[8]; + LTE_UL_UE_HARQ_t *harq_processes[9]; /// Pointer to CQI data uint8_t o[MAX_CQI_BYTES]; /// Length of CQI data (bits) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c index c7cd5ab52f..4a80110b22 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c @@ -619,7 +619,11 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue, harq_process->errors[harq_process->round]++; harq_process->round++; - // LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round); + + if(is_crnti) + { + LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for subframe %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round,harq_process->TBS); + } // printf("Rate: [UE %d] DLSCH: Setting NACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round); if (harq_process->round >= dlsch->Mdlharq) { harq_process->status = SCH_IDLE; @@ -632,7 +636,10 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue, dlsch->harq_ack[subframe].ack = 1; dlsch->harq_ack[subframe].harq_id = harq_pid; dlsch->harq_ack[subframe].send_harq_status = 1; - LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round); + if(is_crnti) + { + LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round,harq_process->TBS); + } } diff --git a/openair1/PHY/LTE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_TRANSPORT/initial_sync.c index 91374078c0..663978e92c 100644 --- a/openair1/PHY/LTE_TRANSPORT/initial_sync.c +++ b/openair1/PHY/LTE_TRANSPORT/initial_sync.c @@ -463,7 +463,7 @@ int initial_sync(PHY_VARS_UE *ue, runmode_t mode) } /* Consider this is a false detection if the offset is > 1000 Hz */ - if( (abs(ue->common_vars.freq_offset) > 1000) && (ret == 0) ) + if( (abs(ue->common_vars.freq_offset) > 150) && (ret == 0) ) { ret=-1; LOG_E(HW,"Ignore MIB with high freq offset [%d Hz] estimation \n",ue->common_vars.freq_offset); diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 6b66ee0282..dc46f0505c 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -34,6 +34,10 @@ #include "PHY/extern.h" #include "SCHED/defs.h" #include "defs.h" + +#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/defs.h" + #ifndef USER_MODE #include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h" #endif @@ -1375,15 +1379,30 @@ void rx_phich(PHY_VARS_UE *ue, subframe, HI16, nseq_PHICH, - ngroup_PHICH); + ngroup_PHICH, + UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx); //#endif - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + // ulsch->harq_processes[harq_pid]->Ndi = 0; ulsch->harq_processes[harq_pid]->round++; - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; + + if (ulsch->harq_processes[harq_pid]->round >= UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) + { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + ulsch->harq_processes[harq_pid]->round = 0; + ulsch->harq_processes[harq_pid]->status = IDLE; + //LOG_I(PHY,"PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); + //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + } + else + { + // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); + } } @@ -1405,11 +1424,22 @@ void rx_phich(PHY_VARS_UE *ue, //#endif } + // LOG_I(PHY,"[HARQ-UL harqId: %d] subframe_scheduling_flag = %d \n",harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag); + + // Incase of adaptive retransmission, PHICH is always decoded as ACK (at least with OAI-eNB) + // Workaround: + // rely only on DCI0 decoding and check if NDI has toggled + // save current harq_processes content in temporary struct + // harqId-8 corresponds to the temporary struct. In total we have 8 harq process(0 ..7) + 1 temporary harq process() + ulsch->harq_processes[8] = ulsch->harq_processes[harq_pid]; + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag =0; ulsch->harq_processes[harq_pid]->status = IDLE; ulsch->harq_processes[harq_pid]->round = 0; // inform MAC? ue->ulsch_Msg3_active[eNB_id] = 0; + + //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH ACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); } } diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c index 53eaa849fd..48048bf5de 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c @@ -498,6 +498,21 @@ uint32_t ulsch_encoding(uint8_t *a, G = G - Q_RI - Q_CQI; + ulsch->harq_processes[harq_pid]->G = G; + +/* + LOG_I(PHY,"ULSCH Encoding G %d, Q_RI %d (O_RI%d, Msc_initial %d, Nsymb_initial%d, beta_offset_ri_times8 %d), Q_CQI %d \n",G,Q_RI,ulsch->O_RI,ulsch->harq_processes[harq_pid]->Msc_initial,ulsch->harq_processes[harq_pid]->Nsymb_initial,ulsch->beta_offset_ri_times8,Q_CQI); + + LOG_I(PHY,"ulsch_decoding (Nid_cell %d, rnti %x): harq_pid %d round %d, RV %d, mcs %d, O_RI %d, O_ACK %d, G %d\n", + frame_parms->Nid_cell,ulsch->rnti, + harq_pid, + ulsch->harq_processes[harq_pid]->round, + ulsch->harq_processes[harq_pid]->rvidx, + ulsch->harq_processes[harq_pid]->mcs, + ulsch->O_RI, + ulsch->harq_processes[harq_pid]->O_ACK, + G); +*/ if ((int)G < 0) { LOG_E(PHY,"FATAL: ulsch_coding.c G < 0 (%d) : Q_RI %d, Q_CQI %d, O %d, betaCQI_times8 %d)\n",G,Q_RI,Q_CQI,ulsch->O,ulsch->beta_offset_cqi_times8); diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c index 80168dd3c5..02323d6ccd 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c @@ -424,15 +424,17 @@ void ulsch_modulation(int32_t **txdataF, Q_m = get_Qm_ul(ulsch->harq_processes[harq_pid]->mcs); - G = (int)ulsch->harq_processes[harq_pid]->nb_rb * (12 * Q_m) * (ulsch->Nsymb_pusch); + //G = (int)ulsch->harq_processes[harq_pid]->nb_rb * (12 * Q_m) * (ulsch->Nsymb_pusch); + + G = ulsch->harq_processes[harq_pid]->G; // Mapping nsymb = (frame_parms->Ncp==0) ? 14:12; Msc_PUSCH = ulsch->harq_processes[harq_pid]->nb_rb*12; #ifdef DEBUG_ULSCH_MODULATION - printf("ulsch_modulation.c: Doing modulation (rnti %x,x2 %x) for G=%d bits, harq_pid %d , nb_rb %d, Q_m %d, Nsymb_pusch %d (nsymb %d), subframe %d\n", - ulsch->rnti,x2,G,harq_pid,ulsch->harq_processes[harq_pid]->nb_rb,Q_m, ulsch->Nsymb_pusch,nsymb,subframe); + LOG_D(PHY,"ulsch_modulation.c: Doing modulation (rnti %x,x2 %x) for G=%d bits, harq_pid %d , nb_rb %d, Q_m %d, Nsymb_pusch %d (nsymb %d), subframe %d\n", + ulsch->rnti,x2,G,harq_pid,ulsch->harq_processes[harq_pid]->nb_rb,Q_m, ulsch->Nsymb_pusch,nsymb,subframe); #endif // scrambling (Note the placeholding bits are handled in ulsch_coding.c directly!) diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 55e7686462..92eee4a99d 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -1213,7 +1213,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB ue->generate_ul_signal[eNB_id] = 1; // deactivate service request - ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + // ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; ack_status = get_ack(&ue->frame_parms, ue->dlsch[eNB_id][0]->harq_ack, @@ -3089,22 +3089,27 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, if (ret == (1+dlsch0->max_turbo_iterations)) { *dlsch_errors=*dlsch_errors+1; - + if(dlsch0->rnti != 0xffff) + { LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d DLSCH in error (rv %d,mcs %d,TBS %d)\n", ue->Mod_id,dlsch0->rnti, harq_pid,frame_rx,subframe_rx, dlsch0->harq_processes[harq_pid]->rvidx, dlsch0->harq_processes[harq_pid]->mcs, dlsch0->harq_processes[harq_pid]->TBS); + } } else { + if(dlsch0->rnti != 0xffff) + { LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d: Received DLSCH (rv %d,mcs %d,TBS %d)\n", ue->Mod_id,dlsch0->rnti, harq_pid,frame_rx,subframe_rx, dlsch0->harq_processes[harq_pid]->rvidx, dlsch0->harq_processes[harq_pid]->mcs, dlsch0->harq_processes[harq_pid]->TBS); + } #ifdef DEBUG_DLSCH int j; @@ -3293,6 +3298,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin // do procedures for C-RNTI if (ue->dlsch[eNB_id][0]->active == 1) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, eNB_id, @@ -3302,9 +3308,11 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ue->pdcch_vars[eNB_id]->num_pdcch_symbols, ue->frame_parms.symbols_per_tti>>1, abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); } // do procedures for SI-RNTI if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, eNB_id, @@ -3314,10 +3322,12 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ue->pdcch_vars[eNB_id]->num_pdcch_symbols, ue->frame_parms.symbols_per_tti>>1, abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); } // do procedures for SI-RNTI if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, eNB_id, @@ -3327,10 +3337,12 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ue->pdcch_vars[eNB_id]->num_pdcch_symbols, ue->frame_parms.symbols_per_tti>>1, abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT); } // do procedures for RA-RNTI if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, eNB_id, @@ -3340,6 +3352,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ue->pdcch_vars[eNB_id]->num_pdcch_symbols, ue->frame_parms.symbols_per_tti>>1, abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); } if (subframe_select(&ue->frame_parms,subframe_rx) != SF_S) { // do front-end processing for second slot, and first symbol of next subframe @@ -3375,6 +3388,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin // do procedures for C-RNTI if (ue->dlsch[eNB_id][0]->active == 1) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, eNB_id, @@ -3393,7 +3407,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin &ue->dlsch_errors[eNB_id], mode, abstraction_flag); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); } else { diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.c b/openair2/UTIL/LOG/vcd_signal_dumper.c index 226f8f0754..d367ec7766 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.c +++ b/openair2/UTIL/LOG/vcd_signal_dumper.c @@ -240,6 +240,10 @@ const char* eurecomFunctionsNames[] = { "rx_pdcch", "dci_decoding", "rx_phich", + "pdsch_procedures", + "pdsch_procedures_si", + "pdsch_procedures_p", + "pdsch_procedures_ra", "phy_ue_config_sib2", "macxface_phy_config_sib1_eNB", "macxface_phy_config_sib2_eNB", diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.h b/openair2/UTIL/LOG/vcd_signal_dumper.h index 81a5fb083d..1e03e95002 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.h +++ b/openair2/UTIL/LOG/vcd_signal_dumper.h @@ -214,6 +214,10 @@ typedef enum { VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PHICH, + VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, + VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, + VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, + VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_CONFIG_SIB2, VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_CONFIG_SIB1_ENB, VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_CONFIG_SIB2_ENB, From 33e89e3e9f41c8fa1e83c5f7591b3d66a8e0b085 Mon Sep 17 00:00:00 2001 From: GabrirelCouturier Date: Thu, 24 Nov 2016 10:54:37 +0100 Subject: [PATCH 39/60] [OAI-UE] fix for issue#32 1- timing Advance fix 2- harq UL fix --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 49 ++++++++++--------- openair1/PHY/LTE_TRANSPORT/phich.c | 15 ++++-- openair1/PHY/LTE_TRANSPORT/ulsch_coding.c | 2 +- openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c | 3 +- openair1/SCHED/phy_procedures_lte_ue.c | 22 +++++++-- 5 files changed, 59 insertions(+), 32 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index c55290adf8..107fa042a6 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -6444,29 +6444,30 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, // UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx); //#endif - - ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; - ulsch->harq_processes[harq_pid]->round++; - //LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); - - - if (ulsch->harq_processes[harq_pid]->round >= UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) + if (ulsch->harq_processes[harq_pid]->round > 0) // NACK detected on phich { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - ulsch->harq_processes[harq_pid]->round = 0; - ulsch->harq_processes[harq_pid]->status = IDLE; - //LOG_I(PHY," PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); - //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); - } - else - { - // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - uint8_t rv_table[4] = {0, 2, 3, 1}; - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); + // ulsch->harq_processes[harq_pid]->round++; already done on phich_rx + ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; + // LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); + + if (ulsch->harq_processes[harq_pid]->round >= UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) + { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + ulsch->harq_processes[harq_pid]->round = 0; + ulsch->harq_processes[harq_pid]->status = IDLE; + //LOG_I(PHY," PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); + //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + } + else + { + // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + uint8_t rv_table[4] = {0, 2, 3, 1}; + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); + } } } @@ -7087,7 +7088,8 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, // ulsch->n_DMRS2 = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; -#ifdef DEBUG_DCI + #ifdef DEBUG_DCI + printf("Format 0 DCI : ulsch (ue): AbsSubframe %d.%d\n",proc->frame_rx,subframe); printf("Format 0 DCI : ulsch (ue): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); printf("Format 0 DCI :ulsch (ue): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); printf("Format 0 DCI :ulsch (ue): rballoc %d\n",rballoc); @@ -7106,6 +7108,7 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, printf("Format 0 DCI :ulsch (ue): Nsymb_pusch %d\n",ulsch->Nsymb_pusch); printf("Format 0 DCI :ulsch (ue): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); + printf("Format 0 DCI :ulsch (ue): phich status %d\n",ulsch->harq_processes[harq_pid]->status); #else UNUSED_VARIABLE(dai); #endif diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index dc46f0505c..2d07ba948a 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -1386,11 +1386,20 @@ void rx_phich(PHY_VARS_UE *ue, // ulsch->harq_processes[harq_pid]->Ndi = 0; ulsch->harq_processes[harq_pid]->round++; - if (ulsch->harq_processes[harq_pid]->round >= UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) + if ( ulsch->harq_processes[harq_pid]->round >= (UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx - 1) ) { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - ulsch->harq_processes[harq_pid]->round = 0; + // this is last push re transmission + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + + // disable phich decoding since it is the last retransmission ulsch->harq_processes[harq_pid]->status = IDLE; + + //ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + //ulsch->harq_processes[harq_pid]->round = 0; + //LOG_I(PHY,"PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); } diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c index 48048bf5de..6d2d6232cb 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c @@ -503,7 +503,7 @@ uint32_t ulsch_encoding(uint8_t *a, /* LOG_I(PHY,"ULSCH Encoding G %d, Q_RI %d (O_RI%d, Msc_initial %d, Nsymb_initial%d, beta_offset_ri_times8 %d), Q_CQI %d \n",G,Q_RI,ulsch->O_RI,ulsch->harq_processes[harq_pid]->Msc_initial,ulsch->harq_processes[harq_pid]->Nsymb_initial,ulsch->beta_offset_ri_times8,Q_CQI); - LOG_I(PHY,"ulsch_decoding (Nid_cell %d, rnti %x): harq_pid %d round %d, RV %d, mcs %d, O_RI %d, O_ACK %d, G %d\n", + LOG_I(PHY,"ULSCH Encoding (Nid_cell %d, rnti %x): harq_pid %d round %d, RV %d, mcs %d, O_RI %d, O_ACK %d, G %d\n", frame_parms->Nid_cell,ulsch->rnti, harq_pid, ulsch->harq_processes[harq_pid]->round, diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c index 02323d6ccd..ee9bfc53cd 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c @@ -424,9 +424,8 @@ void ulsch_modulation(int32_t **txdataF, Q_m = get_Qm_ul(ulsch->harq_processes[harq_pid]->mcs); - //G = (int)ulsch->harq_processes[harq_pid]->nb_rb * (12 * Q_m) * (ulsch->Nsymb_pusch); + G = (int)ulsch->harq_processes[harq_pid]->nb_rb * (12 * Q_m) * (ulsch->Nsymb_pusch); - G = ulsch->harq_processes[harq_pid]->G; // Mapping nsymb = (frame_parms->Ncp==0) ? 14:12; diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 92eee4a99d..6e7354f883 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -944,9 +944,18 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc) { #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)//this is the EXPRESS MIMO case ulsch_start = (ue->rx_offset+subframe_tx*frame_parms->samples_per_tti- - ue->hw_timing_advance- - ue->timing_advance- - ue->N_TA_offset+5)%(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); + ue->hw_timing_advance- + ue->timing_advance- + ue->N_TA_offset+5); + //LOG_E(PHY,"ul-signal [subframe: %d, ulsch_start %d]\n",subframe_tx, ulsch_start); + + if(ulsch_start < 0) + ulsch_start = ulsch_start + (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); + + if (ulsch_start > (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti)) + ulsch_start = ulsch_start % (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); + + //LOG_E(PHY,"ul-signal [subframe: %d, ulsch_start %d]\n",subframe_tx, ulsch_start); #else //this is the normal case ulsch_start = (frame_parms->samples_per_tti*subframe_tx)-ue->N_TA_offset; //-ue->timing_advance; #endif //else EXMIMO @@ -1214,6 +1223,13 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB // deactivate service request // ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + LOG_D(PHY,"Generating PUSCH (Abssubframe: %d.%d): harq-Id: %d, round: %d, MaxReTrans: %d \n",frame_tx,subframe_tx,harq_pid,ue->ulsch[eNB_id]->harq_processes[harq_pid]->round,UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx); + if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round >= (UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx - 1)) + { + LOG_D(PHY,"PUSCH MAX Retransmission acheived ==> send last pusch (%d) \n"); + ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + ue->ulsch[eNB_id]->harq_processes[harq_pid]->round = 0; + } ack_status = get_ack(&ue->frame_parms, ue->dlsch[eNB_id][0]->harq_ack, From b0b472e035c9eb5a95b29f1917777c1c750f7505 Mon Sep 17 00:00:00 2001 From: hbilel Date: Thu, 24 Nov 2016 18:17:21 +0100 Subject: [PATCH 40/60] BSR fixes on CMW500 --- openair2/LAYER2/MAC/config.c | 1 + openair2/LAYER2/MAC/ue_procedures.c | 33 +++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 46ded848b1..2ec37a423e 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -188,6 +188,7 @@ rrc_mac_config_req( else { UE_mac_inst[Mod_idP].scheduling_info.LCGID[logicalChannelIdentity] = MAX_NUM_LCGID; } + UE_mac_inst[Mod_idP].scheduling_info.LCID_buffer_remain[logicalChannelIdentity] = 0; } else { LOG_E(MAC,"[CONFIG][UE %d] LCID %d NULL ul_SpecificParameters\n",Mod_idP,logicalChannelIdentity); mac_xface->macphy_exit("NULL ul_SpecificParameters"); diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index b25aab9442..a4c77c2cda 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -128,6 +128,7 @@ void ue_init_mac(module_id_t module_idP) } UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=LCID_EMPTY; + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0; } #ifdef CBA @@ -1504,6 +1505,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU Got %d bytes for SRB2\n",module_idP,sdu_lengths[num_sdus]); //dcch_header_len +=2; // include dcch1 UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] = LCID_EMPTY; + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] -= sdu_lengths[num_sdus]; /* Update BSR : substract transmitted data */ if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] >= sdu_lengths[num_sdus]){ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] -= sdu_lengths[num_sdus]; @@ -1653,7 +1655,18 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf if (bsr_ce_len) { //Print updated BSR when sent - LOG_D(MAC,"[UE %d] Frame %d Subframe %d TX BSR size=%d BSR0=%d BSR1=%d BSR2=%d BSR3=%d\n",module_idP,frameP,subframe,bsr_ce_len, + LOG_D(MAC,"[UE %d] Remaining Buffer after Tx frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", + module_idP, + frameP, + subframe, + num_lcg_id_with_data, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], + UE_mac_inst[module_idP].BSR_reporting_active, buflen); + + LOG_D(MAC,"[UE %d] Frame %d Subframe %d TX BSR Regular or Periodic size=%d BSR0=%d BSR1=%d BSR2=%d BSR3=%d\n",module_idP,frameP,subframe,bsr_ce_len, UE_mac_inst[module_idP].scheduling_info.BSR[0], UE_mac_inst[module_idP].scheduling_info.BSR[1], UE_mac_inst[module_idP].scheduling_info.BSR[2], @@ -2309,6 +2322,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subfra uint8_t array_index = 0; // Reset All BSR Infos + lcid_bytes_in_buffer[0] = 0; for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) { // Reset transmission status @@ -2316,7 +2330,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subfra UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY; } - for (lcgid=0; lcid < MAX_NUM_LCGID; lcgid++) + for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++) { // Reset Buffer Info UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]=0; @@ -2344,6 +2358,8 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subfra if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC,"[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d subframe %d\n", + module_idP, lcid,lcgid,rlc_status.bytes_in_buffer,frameP,subframeP); UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; //Update BSR_bytes and position in lcid_reordered_array only if Group is defined @@ -2381,6 +2397,9 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subfra // Check whether a regular BSR can be triggered according to the first cases in 36.321 if (num_lcid_with_data) { + LOG_D(MAC,"[UE %d] PDCCH Tick at frame %d subframe %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n", + module_idP, frameP, subframeP,num_lcid_with_data,lcid_reordered_array[0],lcid_reordered_array[1],lcid_reordered_array[2]); + for (array_index=0; array_index < num_lcid_with_data; array_index++) { lcid = lcid_reordered_array[array_index]; @@ -2395,8 +2414,8 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subfra { bsr_regular_triggered = TRUE; - LOG_D(MAC,"[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d data become available at frame %d subframe %d\n", - module_idP, lcid,frameP, subframeP); + LOG_D(MAC,"[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d subframe %d\n", + module_idP, lcid,UE_mac_inst[module_idP].scheduling_info.LCGID[lcid],frameP, subframeP); break; } @@ -2407,8 +2426,10 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subfra { bsr_regular_triggered = TRUE; - LOG_D(MAC,"[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d subframe %d\n", - module_idP, frameP, subframeP); + if ((UE_mac_inst[module_idP].BSR_reporting_active & BSR_TRIGGER_REGULAR) == 0) { + LOG_I(MAC,"[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d subframe %d\n", + module_idP, frameP, subframeP); + } } } From eb711645d0a5530c19fbb33126f4d2881ff97843 Mon Sep 17 00:00:00 2001 From: hbilel Date: Thu, 24 Nov 2016 18:26:23 +0100 Subject: [PATCH 41/60] fix issue#33 : RLC AM BO --- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index 427d7c8a02..85104b940c 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -53,6 +53,7 @@ rlc_am_get_buffer_occupancy_in_bytes ( uint32_t header_overhead; // priority of control trafic + rlc_pP->status_buffer_occupancy = 0; if (rlc_pP->status_requested) { if (rlc_pP->t_status_prohibit.running == 0) { #if TRACE_RLC_AM_BO @@ -64,7 +65,7 @@ rlc_am_get_buffer_occupancy_in_bytes ( } #endif - return ((15 + rlc_pP->num_nack_sn*(10+1) + rlc_pP->num_nack_so*(15+15+1) + 7) >> 3); + rlc_pP->status_buffer_occupancy = ((15 + rlc_pP->num_nack_sn*(10+1) + rlc_pP->num_nack_so*(15+15+1) + 7) >> 3); } } From 6e21152facb0eb5b6498ec59d9af1aa69b5bb7a4 Mon Sep 17 00:00:00 2001 From: GabrirelCouturier Date: Mon, 28 Nov 2016 10:21:01 +0100 Subject: [PATCH 42/60] [OAI-UE] fixes for issue#35 issue#36 issue#37 1-issue#35: miss dci detection 2-issue#36: ack/nack on pusch are badly encoded 3-issue#37: ack/nack are sent on pucch instead of pusch --- openair1/PHY/CODING/lte_segmentation.c | 2 +- openair1/PHY/LTE_TRANSPORT/dci.c | 8 ++-- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 14 +++++- openair1/PHY/LTE_TRANSPORT/phich.c | 5 ++- openair1/PHY/LTE_TRANSPORT/ulsch_coding.c | 2 +- openair1/SCHED/phy_procedures_lte_ue.c | 53 +++++++++++++++++++---- 6 files changed, 65 insertions(+), 19 deletions(-) diff --git a/openair1/PHY/CODING/lte_segmentation.c b/openair1/PHY/CODING/lte_segmentation.c index 746344a6ac..04056c4c9e 100644 --- a/openair1/PHY/CODING/lte_segmentation.c +++ b/openair1/PHY/CODING/lte_segmentation.c @@ -60,7 +60,7 @@ int lte_segmentation(unsigned char *input_buffer, } if ((*C)>MAX_NUM_DLSCH_SEGMENTS) { - msg("lte_segmentation.c: too many segments %d\n",*C); + LOG_E(PHY,"lte_segmentation.c: too many segments %d, B %d, L %d, Bprime %d\n",*C,B,L,Bprime); return(-1); } diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index bd2f162312..38cfc2c8c9 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -3248,7 +3248,7 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, SI_RNTI, ra_rnti, P_RNTI, - 3, + 0, format1A, format1A, format1A, @@ -3277,7 +3277,7 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, SI_RNTI, ra_rnti, P_RNTI, - 2, + 1, format1A, format1A, format1A, @@ -3310,7 +3310,7 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, SI_RNTI, ra_rnti, P_RNTI, - 1, + 2, format1A, format1A, format1A, @@ -3339,7 +3339,7 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, SI_RNTI, ra_rnti, P_RNTI, - 0, + 3, format1A, format1A, format1A, diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 107fa042a6..92836ebcf9 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -4456,6 +4456,7 @@ int generate_ue_dlsch_params_from_dci(int frame, dlsch0_harq->status = ACTIVE; dlsch0_harq->DCINdi = ndi; + dlsch[0]->harq_ack[subframe].send_harq_status = 1; if (dlsch0_harq->first_tx==1) { LOG_D(PHY,"[PDSCH %x/%d] Format 1 DCI First TX: Clearing flag\n"); dlsch0_harq->first_tx = 0; @@ -5556,7 +5557,7 @@ int generate_ue_dlsch_params_from_dci(int frame, #ifdef DEBUG_DCI if (dlsch[0] && (dlsch[0]->rnti != 0xffff)) { - printf("dci_format:%d \n",dci_format); + printf("dci_format:%d Abssubframe: %d.%d \n",dci_format,frame,subframe); printf("PDSCH dlsch0 UE: rnti %x\n",dlsch[0]->rnti); printf("PDSCH dlsch0 UE: NBRB %d\n",dlsch0_harq->nb_rb); printf("PDSCH dlsch0 UE: rballoc %x\n",dlsch0_harq->rb_alloc_even[0]); @@ -6231,13 +6232,22 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, uint8_t harq_pid; uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - ANFBmode_t AckNackFBMode = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; + ANFBmode_t AckNackFBMode; LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; // LTE_UE_DLSCH_t **dlsch = ue->dlsch[0]; PHY_MEASUREMENTS *meas = &ue->measurements; LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; // uint32_t current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; + if(frame_parms->frame_type == TDD) + { + AckNackFBMode = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; + } + else + { + AckNackFBMode = 1; // 1: multiplexing for FDD + } + uint32_t cqi_req; uint32_t dai=0; uint32_t cshift; diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 2d07ba948a..9a32876602 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -1050,7 +1050,6 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, // This routine demodulates the PHICH and updates PUSCH/ULSCH parameters - void rx_phich(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t subframe, @@ -1085,8 +1084,10 @@ void rx_phich(PHY_VARS_UE *ue, if (!ulsch) return; + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX Status: %d \n",ue->Mod_id,harq_pid,proc->frame_rx,subframe, ulsch->harq_processes[harq_pid]->status); + if (ulsch->harq_processes[harq_pid]->status == ACTIVE) { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX ACTIVE\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX ACTIVE\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c index 6d2d6232cb..fe4e05747a 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c @@ -501,7 +501,7 @@ uint32_t ulsch_encoding(uint8_t *a, ulsch->harq_processes[harq_pid]->G = G; /* - LOG_I(PHY,"ULSCH Encoding G %d, Q_RI %d (O_RI%d, Msc_initial %d, Nsymb_initial%d, beta_offset_ri_times8 %d), Q_CQI %d \n",G,Q_RI,ulsch->O_RI,ulsch->harq_processes[harq_pid]->Msc_initial,ulsch->harq_processes[harq_pid]->Nsymb_initial,ulsch->beta_offset_ri_times8,Q_CQI); + LOG_I(PHY,"ULSCH Encoding G %d, Q_RI %d (O_RI%d, Msc_initial %d, Nsymb_initial%d, beta_offset_ri_times8 %d), Q_CQI %d, Q_ACK %d \n",G,Q_RI,ulsch->O_RI,ulsch->harq_processes[harq_pid]->Msc_initial,ulsch->harq_processes[harq_pid]->Nsymb_initial,ulsch->beta_offset_ri_times8,Q_CQI,Q_ACK); LOG_I(PHY,"ULSCH Encoding (Nid_cell %d, rnti %x): harq_pid %d round %d, RV %d, mcs %d, O_RI %d, O_ACK %d, G %d\n", frame_parms->Nid_cell,ulsch->rnti, diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 6e7354f883..5dc629b90b 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -61,6 +61,9 @@ fifo_dump_emos_UE emos_dump_UE; # include "intertask_interface.h" #endif +#include "PHY/defs.h" + +#include "PHY/CODING/extern.h" #define DLSCH_RB_ALLOC 0x1fbf // skip DC RB (total 23/25 RBs) #define DLSCH_RB_ALLOC_12 0x0aaa // skip DC RB (total 23/25 RBs) @@ -1026,6 +1029,15 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc) { } #endif #endif + /* + only for debug + LOG_I(PHY,"ul-signal [subframe: %d, ulsch_start %d, TA: %d, rxOffset: %d, timing_advance: %d, hw_timing_advance: %d]\n",subframe_tx, ulsch_start, ue->N_TA_offset, ue->rx_offset, ue->timing_advance, ue->hw_timing_advance); + if( (crash == 1) && (subframe_tx == 0) ) + { + LOG_E(PHY,"***** DUMP TX Signal [ulsch_start %d] *****\n",ulsch_start); + write_output("txBuff.m","txSignal",&ue->common_vars.txdata[aa][ulsch_start],frame_parms->samples_per_tti,1,1); + } + */ } //nb_antennas_tx @@ -1242,6 +1254,27 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB + + if (ack_status > 0) { + + // check if we received a PDSCH at subframe_tx - 4 + // ==> send ACK/NACK on PUSCH + if( (ue->dlsch[eNB_id][0]->harq_ack[proc->subframe_rx].send_harq_status) == 1) + { + ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK = 1; + } + else + { + ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK = 0; + } + LOG_D(PHY,"[UE %d][PDSCH %x] Frame %d subframe %d Generating ACK (%d,%d) for %d bits on PUSCH\n", + Mod_id, + ue->ulsch[eNB_id]->rnti, + frame_tx,subframe_tx, + ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1], + ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK); + } + #ifdef DEBUG_PHY_PROC LOG_D(PHY, "[UE %d][PUSCH %d] Frame %d subframe %d Generating PUSCH : first_rb %d, nb_rb %d, round %d, mcs %d, rv %d, cyclic_shift %d (cyclic_shift_common %d,n_DMRS2 %d,n_PRS %d), ACK (%d,%d), O_ACK %d\n", @@ -1260,15 +1293,6 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK); #endif - if (ack_status > 0) { - LOG_D(PHY,"[UE %d][PDSCH %x] Frame %d subframe %d Generating ACK (%d,%d) for %d bits on PUSCH\n", - Mod_id, - ue->ulsch[eNB_id]->rnti, - frame_tx,subframe_tx, - ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK); - } - @@ -1535,6 +1559,17 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ACK/NACK and SR using the shortened PUCCH format. This shortened PUCCH format shall be used in a cell specific SRS subframe even if the UE does not transmit SRS in that subframe */ + + int harq_pid = subframe2harq_pid(&ue->frame_parms, + frame_tx, + subframe_tx); + + if(ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag) + { + LOG_D(PHY,"PUSCH is programmed on this subframe [pid %d] AbsSuframe %d.%d ==> Skip PUCCH transmission \n",harq_pid,frame_tx,subframe_tx); + return; + } + uint8_t isShortenPucch = (pSoundingrs_ul_config_dedicated->srsCellSubframe && frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission); bundling_flag = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; From ca2aeaccb87894f36d51a59ac5fb0da90f160d02 Mon Sep 17 00:00:00 2001 From: hbilel Date: Mon, 28 Nov 2016 10:36:46 +0100 Subject: [PATCH 43/60] BSR and MAC multiplexing fixes --- openair2/LAYER2/MAC/defs.h | 8 +- openair2/LAYER2/MAC/ue_procedures.c | 524 ++++++++++++------------- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 1 + 3 files changed, 261 insertions(+), 272 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index de9071525d..cb1b2e4917 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -133,12 +133,18 @@ /*!\brief maximum value for channel quality indicator */ #define MAX_CQI_VALUE 15 -//if value equal oxFFFF means counters are NOT active +/*!\brief value for indicating BSR Timer is not running */ #define MAC_UE_BSR_TIMER_NOT_RUNNING (0xFFFF) #define LCID_EMPTY 0 #define LCID_NOT_EMPTY 1 +/*!\brief minimum RLC PDU size to be transmitted = min RLC Status PDU or RLC UM PDU SN 5 bits */ +#define MIN_RLC_PDU_SIZE (2) + +/*!\brief minimum MAC data needed for transmitting 1 min RLC PDU size + 1 byte MAC subHeader */ +#define MIN_MAC_HDR_RLC_SIZE (1 + MIN_RLC_PDU_SIZE) + /* * eNB part */ diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index a4c77c2cda..c90dd5857c 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -1245,13 +1245,12 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf { mac_rlc_status_resp_t rlc_status; - uint8_t dcch_header_len=0,dcch1_header_len=0,dtch_header_len=0,dtch_header_len_last=0; - uint8_t dcch_header_len_tmp=0, dtch_header_len_tmp=0; - //TO DO -// uint8_t total_rlc_pdu_header_len=0, rlc_pdu_header_len_last=0 ; + uint8_t total_rlc_pdu_header_len=0, rlc_pdu_header_len_last=0 ; + uint16_t buflen_remain = 0; uint8_t bsr_len=0,bsr_ce_len=0,bsr_header_len=0; uint8_t phr_header_len=0, phr_ce_len=0,phr_len=0; uint8_t lcid=0; + boolean_t is_lcid_processed = FALSE; uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t payload_offset=0,num_sdus=0; @@ -1267,7 +1266,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf unsigned short short_padding=0, post_padding=0, padding_len=0; int j; // used for padding // Compute header length - int all_pdu_len; int lcg_id = 0; int lcg_id_bsr_trunc = 0; int highest_priority = 16; @@ -1304,10 +1302,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf } #endif - dcch_header_len=2;//sizeof(SCH_SUBHEADER_SHORT); - dcch1_header_len=2;//sizeof(SCH_SUBHEADER_SHORT); - // hypo length,in case of long header skip the padding byte - dtch_header_len=(buflen > 128 ) ? 3 : 2 ; //sizeof(SCH_SUBHEADER_LONG)-1 : sizeof(SCH_SUBHEADER_SHORT); bsr_header_len = 0; phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); @@ -1385,258 +1379,233 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf // check for UL bandwidth requests and add SR control element // Check for DCCH first +// TO DO: Unrool the loop to do it at least once to avoid the if num_sdu +for (lcid=DCCH; lcid < DTCH ; lcid++) { + if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) { - if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] == LCID_NOT_EMPTY) { + is_lcid_processed = FALSE; - //It is not necessary to get RLC status again, it was done in ue_scheduler and stored - //for sanity keep it and check, to be removed if OK - rlc_status = mac_rlc_status_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, // eNB_index - DCCH, - (buflen-dcch_header_len-bsr_len-phr_len)); + //Multiplex all available DCCH RLC PDUs considering to multiplex the last PDU each time for maximize the data + //Adjust at the end of the loop + while ((!is_lcid_processed) && (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) { - AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d\n", - DCCH,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH],rlc_status.bytes_in_buffer); + buflen_remain = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total + 1); - LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RLC SRB1 has %d bytes to " - "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", - module_idP,frameP, UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH],buflen,bsr_len,phr_len,sdu_length_total,dcch_header_len,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]]); + rlc_status = mac_rlc_status_ind(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, // eNB_index + lcid, + buflen_remain); + + AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d\n", + lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer); + + if (rlc_status.bytes_in_buffer > 0) { - sdu_lengths[0] += mac_rlc_data_req(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - DCCH, - (char *)&ulsch_buff[sdu_lengths[0]]); + LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RLC SRB%d has %d bytes to " + "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", + module_idP,frameP, lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],buflen,bsr_len,phr_len,sdu_length_total,total_rlc_pdu_header_len,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); - AssertFatal (UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] >= sdu_lengths[0], "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", - DCCH,sdu_lengths[0],UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH]); + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + lcid, + (char *)&ulsch_buff[sdu_length_total]); + + + AssertFatal (UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= sdu_lengths[num_sdus], "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", + lcid,sdu_lengths[num_sdus],UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]); - sdu_length_total += sdu_lengths[0]; - sdu_lcids[0] = DCCH; - LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU TX Got %d bytes for SRB1\n",module_idP,sdu_lengths[0]); - num_sdus = 1; - //header_len +=2; - // update LCID remain buffer - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH] -= sdu_lengths[0]; - /* Update BSR : substract transmitted data */ - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] >= sdu_lengths[0]){ - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] -= sdu_lengths[0] ; - } - else { - LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data transmitted=%d for LCID%d\n", - module_idP,frameP,subframe, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]], - UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH], - sdu_lengths[0],DCCH); - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] = 0; - } + sdu_length_total += sdu_lengths[num_sdus]; + sdu_lcids[num_sdus] = lcid; + LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU TX Got %d bytes for SRB%d\n",module_idP,sdu_lengths[num_sdus],lcid); + //header_len +=2; + // update LCID remain buffer + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] -= sdu_lengths[num_sdus]; + /* Update BSR : substract transmitted data */ + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] >= sdu_lengths[num_sdus]){ + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] -= sdu_lengths[num_sdus] ; + } + else { + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data transmitted=%d for LCID%d\n", + module_idP,frameP,subframe, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], + UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], + sdu_lengths[num_sdus],lcid); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] = 0; + } - //Update the number of LCGID with data as BSR shall reflect status after BSR transmission - if ((num_lcg_id_with_data > 1) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] == 0)) - { - num_lcg_id_with_data --; - // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1 - if ((bsr_len) && (num_lcg_id_with_data == 1)) - { - bsr_ce_len = sizeof(BSR_SHORT); - bsr_len = bsr_ce_len + bsr_header_len; - } + //Update the number of LCGID with data as BSR shall reflect status after BSR transmission + if ((num_lcg_id_with_data > 1) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] == 0)) + { + num_lcg_id_with_data --; + // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1 + if ((bsr_len) && (num_lcg_id_with_data == 1)) + { + bsr_ce_len = sizeof(BSR_SHORT); + bsr_len = bsr_ce_len + bsr_header_len; + } - } + } - UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] = LCID_EMPTY; + //Update total MAC Header size for RLC PDUs and save last one + total_rlc_pdu_header_len += rlc_pdu_header_len_last; + + if (buflen == (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1)) { + //No more remaining TBS after this PDU + //exit the function + rlc_pdu_header_len_last = 1; + is_lcid_processed = TRUE; + } + else { + rlc_pdu_header_len_last = (sdu_lengths[num_sdus] > 128 ) ? 3 : 2 ; + + //Change to 1 byte if it does not fit in the TBS, ie last PDU + if (buflen <= (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total)) { + rlc_pdu_header_len_last = 1; + is_lcid_processed = TRUE; + } + + //Update number of SDU + num_sdus ++; + } + + + } //end if (rlc_status.bytes_in_buffer > 0) + else { + // Switch to next LCID or exit the whole loop + is_lcid_processed = TRUE; + } } - else { - dcch_header_len=0; - num_sdus = 0; - } + + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; + } +} + + +// Now Check for DTCH first +// TO DO: do it according to Logical Channel Prioritization if at least 2 DTCH +for (lcid=DTCH; lcid < MAX_NUM_LCID ; lcid++) { +if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) { + + is_lcid_processed = FALSE; + + //Multiplex all available DTCH RLC PDUs considering to multiplex the last PDU each time for maximize the data + //Adjust at the end of the loop + while ((!is_lcid_processed) && (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) { + + buflen_remain = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total + 1); + + rlc_status = mac_rlc_status_ind(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, // eNB_index + lcid, + buflen_remain); + + AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d\n", + lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer); + + if (rlc_status.bytes_in_buffer > 0) { + + + LOG_D(MAC, "[UE %d] Frame %d : UL-DTCH -> ULSCH, RLC LCID%d has %d bytes to " + "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", + module_idP,frameP, lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],buflen,bsr_len,phr_len,sdu_length_total,total_rlc_pdu_header_len,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); + + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + lcid, + (char *)&ulsch_buff[sdu_length_total]); + + + AssertFatal (UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= sdu_lengths[num_sdus], "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", + lcid,sdu_lengths[num_sdus],UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]); - // if the RLC AM is used, then RLC will only provide 2 bytes for ACK - // in this case, we sould add bsr + sdu_length_total += sdu_lengths[num_sdus]; + sdu_lcids[num_sdus] = lcid; + LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU TX Got %d bytes for LCID%d\n",module_idP,sdu_lengths[num_sdus],lcid); + //header_len +=2; + // update LCID remain buffer + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] -= sdu_lengths[num_sdus]; + /* Update BSR : substract transmitted data */ + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] >= sdu_lengths[num_sdus]){ + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] -= sdu_lengths[num_sdus] ; + } + else { + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data transmitted=%d for LCID%d\n", + module_idP,frameP,subframe, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], + UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], + sdu_lengths[num_sdus],lcid); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] = 0; + } - // DCCH1 - if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] == LCID_NOT_EMPTY) { + //Update the number of LCGID with data as BSR shall reflect status after BSR transmission + if ((num_lcg_id_with_data > 1) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] == 0)) + { + num_lcg_id_with_data --; + // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1 + if ((bsr_len) && (num_lcg_id_with_data == 1)) + { + bsr_ce_len = sizeof(BSR_SHORT); + bsr_len = bsr_ce_len + bsr_header_len; + } - //It is not necessary to get RLC status again, it was done in ue_scheduler and stored - //for sanity keep it and check, to be removed if OK - rlc_status = mac_rlc_status_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, // eNB_index - DCCH1, - (buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-sdu_length_total)); + } - AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d\n", - DCCH1,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1],rlc_status.bytes_in_buffer); + //Update total MAC Header size for RLC PDUs and save last one + total_rlc_pdu_header_len += rlc_pdu_header_len_last; - LOG_D(MAC,"[UE %d] Frame %d subframe %d: UL-DCCH1 -> ULSCH, RLC SRB2 has %d bytes to" - " send (Transport Block size %d BSR size=%d PHR=%d SRB1 Hdr %d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", - module_idP,frameP, subframe, UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1],buflen,bsr_len,phr_len,dcch_header_len,sdu_length_total,dcch1_header_len,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]]); + if (buflen == (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1)) { + //No more remaining TBS after this PDU + //exit the function + rlc_pdu_header_len_last = 1; + is_lcid_processed = TRUE; + } + else { + rlc_pdu_header_len_last = (sdu_lengths[num_sdus] > 128 ) ? 3 : 2 ; - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - DCCH1, - (char *)&ulsch_buff[sdu_lengths[num_sdus]]); + //Change to 1 byte if it does not fit in the TBS, ie last PDU + if (buflen <= (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total)) { + rlc_pdu_header_len_last = 1; + is_lcid_processed = TRUE; + } - AssertFatal (UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] >= sdu_lengths[num_sdus], "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", - DCCH1,sdu_lengths[num_sdus],UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1]); + //Update number of SDU + num_sdus ++; + } - sdu_length_total += sdu_lengths[num_sdus]; - sdu_lcids[num_sdus] = DCCH1; - LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU Got %d bytes for SRB2\n",module_idP,sdu_lengths[num_sdus]); - //dcch_header_len +=2; // include dcch1 - UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] = LCID_EMPTY; - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[DCCH1] -= sdu_lengths[num_sdus]; - /* Update BSR : substract transmitted data */ - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] >= sdu_lengths[num_sdus]){ - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] -= sdu_lengths[num_sdus]; - } - else { - LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Buffer occupancy =%d for LCGID%d is lower than data transmitted=%d for LCID%d\n", - module_idP,frameP,subframe, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]], - UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1], - sdu_lengths[num_sdus],DCCH1); - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] = 0; - } + } //end if (rlc_status.bytes_in_buffer > 0) + else { + // Switch to next LCID or exit the whole loop + is_lcid_processed = TRUE; + } + } - //Update the number of LCGID with data as BSR shall reflect status after BSR transmission - if ((num_lcg_id_with_data > 1) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH1]] == 0)) - { - num_lcg_id_with_data --; - // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1 - if ((bsr_len) && (num_lcg_id_with_data == 1)) - { - bsr_ce_len = sizeof(BSR_SHORT); - bsr_len = bsr_ce_len + bsr_header_len; - } - } - - num_sdus++; - - } else { - dcch1_header_len =0; - } - - - dtch_header_len=0; - dtch_header_len_last=0; - for (lcid=DTCH; lcid < MAX_NUM_LCID ; lcid++){ - dtch_header_len+=3; - dtch_header_len_last=3; - - all_pdu_len = bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total; - if ((UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) && - (all_pdu_len <= buflen)) { - - AssertFatal (UE_mac_inst[module_idP].logicalChannelConfig[lcid] != NULL, "LCID (%d) is not active!\n", lcid); - - // optimize the dtch header lenght - //if ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] > 128) && - /* if (((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] >= 128) && - ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH]+bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len) > buflen)&& - buflen >=128 )) - dtch_header_len = 3;//sizeof(SCH_SUBHEADER_LONG); - else - dtch_header_len = 2;//sizeof(SCH_SUBHEADER_SHORT); - */ - //It is not necessary to get RLC status again, it was done in ue_scheduler and stored - //for sanity keep it and check, to be removed if OK - rlc_status = mac_rlc_status_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, // eNB_index - lcid, - buflen-all_pdu_len); - - AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d\n", - lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer); - - LOG_D(MAC,"[UE %d] Frame %d subframe %d: UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte before Tx=%d)\n", - module_idP,frameP, subframe,lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); - - if (rlc_status.bytes_in_buffer > 0) { - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, // eNB_index - lcid, - (char *)&ulsch_buff[sdu_length_total]); - - AssertFatal (UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= sdu_lengths[num_sdus], "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", - lcid,sdu_lengths[num_sdus],UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]); - - - //adjust dtch header - LOG_D(MAC,"[UE %d] Frame %d Subframe %d TX Got %d bytes for DTCH%d New BSR bytes=%d\n",module_idP,frameP,subframe,sdu_lengths[num_sdus],lcid,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) { - dtch_header_len --; - dtch_header_len_last --; - } - - /* Update BSR : substract transmitted data */ - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] -= sdu_lengths[num_sdus]; - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] >= sdu_lengths[num_sdus]){ - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] -= sdu_lengths[num_sdus]; - } - else { - LOG_I(MAC, "[UE %d] Frame %d Subframe %d: WARNING Buffer occupancy =%d for LCGID%d is lower than data transmitted=%d for LCID%d\n", - module_idP,frameP,subframe, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], - UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], - sdu_lengths[num_sdus],lcid); - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] = 0; - } - - //Update the number of LCGID with data as BSR shall reflect status after BSR transmission - if ((num_lcg_id_with_data > 1) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] == 0)) - { - num_lcg_id_with_data --; - // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1 - if ((bsr_len) && (num_lcg_id_with_data == 1)) - { - bsr_ce_len = sizeof(BSR_SHORT); - bsr_len = bsr_ce_len + bsr_header_len; - } - } - - - num_sdus++; - - } else { - dtch_header_len -= 3; - } - UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; - } else { // no rlc pdu : generate the dummy header - dtch_header_len -= 3; - } - } + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; + } +} //lcgid= get_bsr_lcgid(module_idP); @@ -1687,28 +1656,22 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf LOG_T(MAC,"[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n", module_idP,frameP,bsr_s, bsr_l, phr_p); - if (dtch_header_len == 0 ) - dtch_header_len_last =0; - - // adjust the header length - dcch_header_len_tmp = dcch_header_len; - dtch_header_len_tmp = dtch_header_len; - - if (dtch_header_len==0) { - dcch_header_len = (dcch_header_len>0)? 1: dcch_header_len; - } else { - dtch_header_len_last-=1; - dtch_header_len= (dtch_header_len >0)? dtch_header_len - dtch_header_len_last : dtch_header_len; - } // Check BSR padding: it is done after PHR according to Logical Channel Prioritization order + // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 /* For Padding BSR: - if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader: - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission; - else report Short BSR. - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR. */ - padding_len = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; + if (sdu_length_total) { + padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); + } + else { + padding_len = buflen - (bsr_len + phr_len); + } + if ((padding_len) && (bsr_len == 0)) { @@ -1766,7 +1729,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; - LOG_D(MAC, "[UE %d] Frame %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, + LOG_I(MAC, "[UE %d] Frame %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], @@ -1781,7 +1744,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_t->LCGID = lcg_id_bsr_trunc; bsr_t->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc]; - LOG_D(MAC,"[UE %d] Frame %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", + LOG_I(MAC,"[UE %d] Frame %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", module_idP, frameP, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); } @@ -1791,31 +1754,49 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf bsr_s->LCGID = lcg_id_bsr_trunc; bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc]; - LOG_D(MAC,"[UE %d] Frame %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", + LOG_I(MAC,"[UE %d] Frame %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", module_idP, frameP, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); } } - // 1-bit padding or 2-bit padding special padding subheader - padding_len = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; +// 1-bit padding or 2-bit padding special padding subheader +// Check for max padding size, ie MAC Hdr for last RLC PDU = 1 + if (sdu_length_total) { + padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); + } + else { + padding_len = buflen - (bsr_len + phr_len); + } + if (padding_len <= 2) { short_padding = padding_len; // only add padding header post_padding = 0; - } else { + //update total MAC Hdr size for RLC data + if (sdu_length_total) { + rlc_pdu_header_len_last = 1; + total_rlc_pdu_header_len ++; + } + } + else if (sdu_length_total) { + total_rlc_pdu_header_len += rlc_pdu_header_len_last; + post_padding = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); + // If by adding MAC Hdr for last RLC PDU the padding is 0 then set MAC Hdr for last RLC PDU = 1 and compute 1 or 2 byte padding + if (post_padding == 0) { + total_rlc_pdu_header_len -= rlc_pdu_header_len_last; + padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); + short_padding = padding_len; + total_rlc_pdu_header_len ++; + } + } + else { if (padding_len == buflen) {// nona mac pdu *access_mode=CANCELED_ACCESS; } short_padding = 0; - if (dtch_header_len==0) { - dcch_header_len = dcch_header_len_tmp; - } else { - dtch_header_len= dtch_header_len_tmp; - } - - post_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total -1 ; + post_padding = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); } // Generate header @@ -1834,11 +1815,13 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf post_padding); // long_bsr LOG_D(MAC, - "[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, dcch_header_len %d, dtch_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n", - module_idP,buflen, sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],payload_offset, dcch_header_len, dtch_header_len, + "[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, total_rlc_pdu_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n", + module_idP,buflen, sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],payload_offset, total_rlc_pdu_header_len, short_padding,post_padding, bsr_len, phr_len,buflen-sdu_length_total-payload_offset); // cycle through SDUs and place in ulsch_buffer - memcpy(&ulsch_buffer[payload_offset],ulsch_buff,sdu_length_total); + if (sdu_length_total) { + memcpy(&ulsch_buffer[payload_offset],ulsch_buff,sdu_length_total); + } // fill remainder of DLSCH with random data for (j=0; j<(buflen-sdu_length_total-payload_offset); j++) { @@ -1852,10 +1835,13 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf /* Actions when a BSR is sent */ if (bsr_ce_len) { + LOG_D(MAC,"[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n", + module_idP, bsr_ce_len, bsr_header_len, buflen); + // Reset ReTx BSR Timer UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); - LOG_I(MAC,"[UE %d] MAC ReTx BSR Timer Reset =%d\n", + LOG_D(MAC,"[UE %d] MAC ReTx BSR Timer Reset =%d\n", UE_mac_inst[module_idP].scheduling_info.retxBSR_SF); // Reset Periodic Timer except when BSR is truncated @@ -1863,15 +1849,11 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf { UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); - LOG_I(MAC,"[UE %d] MAC Periodic BSR Timer Reset =%d\n", + LOG_D(MAC,"[UE %d] MAC Periodic BSR Timer Reset =%d\n", UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF); } - LOG_I(MAC,"[UE %d] MAC BSR Triggered !! bsr (ce%d,hdr%d) buff_len %d\n", - module_idP, bsr_ce_len, bsr_header_len, buflen); - - // Reset BSR Trigger flags UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index 85104b940c..ded7dc0783 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -341,6 +341,7 @@ rlc_am_get_pdus ( if (pdu) { list_add_tail_eurecom (pdu, &rlc_pP->pdus_to_mac_layer); rlc_pP->status_requested = 0; + rlc_pP->status_buffer_occupancy = 0; rlc_am_start_timer_status_prohibit(ctxt_pP, rlc_pP); return; } From 710a246596aee5063facd0106a6935a64edaea12 Mon Sep 17 00:00:00 2001 From: hbilel Date: Mon, 28 Nov 2016 10:55:00 +0100 Subject: [PATCH 44/60] enhance BSR log --- openair2/LAYER2/MAC/ue_procedures.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index c90dd5857c..1ba0fa092d 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -1729,7 +1729,7 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; - LOG_I(MAC, "[UE %d] Frame %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, + LOG_I(MAC, "[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP,subframe, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], @@ -1744,8 +1744,8 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) bsr_t->LCGID = lcg_id_bsr_trunc; bsr_t->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc]; - LOG_I(MAC,"[UE %d] Frame %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", - module_idP, frameP, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); + LOG_I(MAC,"[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", + module_idP, frameP, subframe, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); } else @@ -1754,8 +1754,8 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) bsr_s->LCGID = lcg_id_bsr_trunc; bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc]; - LOG_I(MAC,"[UE %d] Frame %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", - module_idP, frameP, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); + LOG_I(MAC,"[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", + module_idP, frameP, subframe, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); } } From b80ce3510e205423e8f2cb4508c74f9f997609c7 Mon Sep 17 00:00:00 2001 From: GabrirelCouturier Date: Mon, 28 Nov 2016 19:27:25 +0100 Subject: [PATCH 45/60] BSR and MAC UL encoding fixes --- openair2/LAYER2/MAC/defs.h | 4 +- openair2/LAYER2/MAC/ue_procedures.c | 166 ++++++++++++++++------------ 2 files changed, 97 insertions(+), 73 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index cb1b2e4917..86fc367f51 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -959,9 +959,9 @@ typedef struct { /// buffer status for each lcgid uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology /// keep the number of bytes in rlc buffer for each lcgid - uint16_t BSR_bytes[MAX_NUM_LCGID]; + int32_t BSR_bytes[MAX_NUM_LCGID]; /// after multiplexing buffer remain for each lcid - uint16_t LCID_buffer_remain[MAX_NUM_LCID]; + int32_t LCID_buffer_remain[MAX_NUM_LCID]; /// sum of all lcid buffer size uint16_t All_lcid_buffer_size_lastTTI; /// buffer status for each lcid diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 1ba0fa092d..0413cfe524 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -1162,50 +1162,67 @@ unsigned char generate_ulsch_header(uint8_t *mac_header, LOG_T(MAC,"[UE] sdu subheader %d (lcid %d, %d bytes)\n",i,sdu_lcids[i],sdu_lengths[i]); #endif - if ((first_element>0)) { - mac_header_ptr->E = 1; -#ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); -#endif - mac_header_ptr+=last_size; - // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - } else { - first_element=1; - + if ((i == (num_sdus - 1)) && ((short_padding) || (post_padding == 0))) { + if (first_element>0) { + mac_header_ptr->E = 1; + #ifdef DEBUG_HEADER_PARSING + LOG_D(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + #endif + mac_header_ptr+=last_size; + } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = sdu_lcids[i]; } + else { + if ((first_element>0)) { + mac_header_ptr->E = 1; + #ifdef DEBUG_HEADER_PARSING + LOG_D(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + #endif + mac_header_ptr+=last_size; + // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + } else { + first_element=1; - if (sdu_lengths[i] < 128) { - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R = 0; // 3 - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L = (unsigned char)sdu_lengths[i]; - last_size=2; -#ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] short sdu\n"); - LOG_T(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n", - ((uint16_t*)mac_header_ptr)[0], - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L); -#endif - } else { - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->R = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F = 1; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB = ((unsigned short) sdu_lengths[i]>>8)&0x7f; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB = (unsigned short) sdu_lengths[i]&0xff; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->padding = 0x00; - last_size=3; -#ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] long sdu\n"); -#endif + } + + if (sdu_lengths[i] < 128) { + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R = 0; // 3 + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F = 0; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID = sdu_lcids[i]; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L = (unsigned char)sdu_lengths[i]; + last_size=2; + #ifdef DEBUG_HEADER_PARSING + LOG_D(MAC,"[UE] short sdu\n"); + LOG_T(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n", + ((uint16_t*)mac_header_ptr)[0], + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R, + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E, + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID, + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F, + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L); + #endif + } else { + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->R = 0; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F = 1; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->LCID = sdu_lcids[i]; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB = ((unsigned short) sdu_lengths[i]>>8)&0x7f; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB = (unsigned short) sdu_lengths[i]&0xff; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->padding = 0x00; + last_size=3; + #ifdef DEBUG_HEADER_PARSING + LOG_D(MAC,"[UE] long sdu\n"); + #endif + } } } @@ -1223,6 +1240,7 @@ unsigned char generate_ulsch_header(uint8_t *mac_header, //mac_header_ptr=last_size; // FIXME: should be ++ } + if ((ce_ptr-mac_header_control_elements) > 0) { memcpy((void*)mac_header_ptr,mac_header_control_elements,ce_ptr-mac_header_control_elements); mac_header_ptr+=(unsigned char)(ce_ptr-mac_header_control_elements); @@ -1249,7 +1267,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf uint16_t buflen_remain = 0; uint8_t bsr_len=0,bsr_ce_len=0,bsr_header_len=0; uint8_t phr_header_len=0, phr_ce_len=0,phr_len=0; - uint8_t lcid=0; + uint8_t lcid=0,lcid_rlc_pdu_count=0; boolean_t is_lcid_processed = FALSE; uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -1384,12 +1402,13 @@ for (lcid=DCCH; lcid < DTCH ; lcid++) { if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) { is_lcid_processed = FALSE; + lcid_rlc_pdu_count = 0; //Multiplex all available DCCH RLC PDUs considering to multiplex the last PDU each time for maximize the data //Adjust at the end of the loop - while ((!is_lcid_processed) && (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) { + while ((!is_lcid_processed) && (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) { - buflen_remain = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total + 1); + buflen_remain = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti, @@ -1400,8 +1419,8 @@ for (lcid=DCCH; lcid < DTCH ; lcid++) { lcid, buflen_remain); - AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d\n", - lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer); + AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d RLC PDU nb=%d Frame %d Subrame %d\n", + lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer,lcid_rlc_pdu_count,frameP,subframe); if (rlc_status.bytes_in_buffer > 0) { @@ -1458,9 +1477,6 @@ for (lcid=DCCH; lcid < DTCH ; lcid++) { } - //Update total MAC Header size for RLC PDUs and save last one - total_rlc_pdu_header_len += rlc_pdu_header_len_last; - if (buflen == (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1)) { //No more remaining TBS after this PDU //exit the function @@ -1475,17 +1491,20 @@ for (lcid=DCCH; lcid < DTCH ; lcid++) { rlc_pdu_header_len_last = 1; is_lcid_processed = TRUE; } - - //Update number of SDU - num_sdus ++; } + //Update number of SDU + num_sdus ++; + + //Update total MAC Header size for RLC PDUs and save last one + total_rlc_pdu_header_len += rlc_pdu_header_len_last; } //end if (rlc_status.bytes_in_buffer > 0) else { // Switch to next LCID or exit the whole loop is_lcid_processed = TRUE; } + lcid_rlc_pdu_count ++; } UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; @@ -1499,12 +1518,13 @@ for (lcid=DTCH; lcid < MAX_NUM_LCID ; lcid++) { if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) { is_lcid_processed = FALSE; + lcid_rlc_pdu_count = 0; //Multiplex all available DTCH RLC PDUs considering to multiplex the last PDU each time for maximize the data //Adjust at the end of the loop - while ((!is_lcid_processed) && (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) { + while ((!is_lcid_processed) && (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) { - buflen_remain = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total + 1); + buflen_remain = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti, @@ -1515,8 +1535,8 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) lcid, buflen_remain); - AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d\n", - lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer); + AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d RLC PDU nb=%d Frame %d Subrame %d\n", + lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer,lcid_rlc_pdu_count,frameP,subframe); if (rlc_status.bytes_in_buffer > 0) { @@ -1535,6 +1555,9 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) lcid, (char *)&ulsch_buff[sdu_length_total]); + AssertFatal (sdu_lengths[num_sdus] < MAX_ULSCH_PAYLOAD_BYTES, "LCID=%d RLC PDU size = %d is too big\n", + lcid,sdu_lengths[num_sdus]); + AssertFatal (UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= sdu_lengths[num_sdus], "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", lcid,sdu_lengths[num_sdus],UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]); @@ -1573,9 +1596,6 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) } - //Update total MAC Header size for RLC PDUs and save last one - total_rlc_pdu_header_len += rlc_pdu_header_len_last; - if (buflen == (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1)) { //No more remaining TBS after this PDU //exit the function @@ -1590,17 +1610,20 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) rlc_pdu_header_len_last = 1; is_lcid_processed = TRUE; } - - //Update number of SDU - num_sdus ++; } + //Update number of SDU + num_sdus ++; + + //Update total MAC Header size for RLC PDUs and save last one + total_rlc_pdu_header_len += rlc_pdu_header_len_last; } //end if (rlc_status.bytes_in_buffer > 0) else { // Switch to next LCID or exit the whole loop is_lcid_processed = TRUE; } + lcid_rlc_pdu_count ++; } UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; @@ -1666,7 +1689,7 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR. */ if (sdu_length_total) { - padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); + padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - rlc_pdu_header_len_last + sdu_length_total + 1); } else { padding_len = buflen - (bsr_len + phr_len); @@ -1762,7 +1785,7 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) // 1-bit padding or 2-bit padding special padding subheader // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 if (sdu_length_total) { - padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); + padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - rlc_pdu_header_len_last + sdu_length_total + 1); } else { padding_len = buflen - (bsr_len + phr_len); @@ -1774,12 +1797,11 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) post_padding = 0; //update total MAC Hdr size for RLC data if (sdu_length_total) { + total_rlc_pdu_header_len = total_rlc_pdu_header_len - rlc_pdu_header_len_last + 1; rlc_pdu_header_len_last = 1; - total_rlc_pdu_header_len ++; - } + } } else if (sdu_length_total) { - total_rlc_pdu_header_len += rlc_pdu_header_len_last; post_padding = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); // If by adding MAC Hdr for last RLC PDU the padding is 0 then set MAC Hdr for last RLC PDU = 1 and compute 1 or 2 byte padding if (post_padding == 0) { @@ -1824,8 +1846,10 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) } // fill remainder of DLSCH with random data - for (j=0; j<(buflen-sdu_length_total-payload_offset); j++) { - ulsch_buffer[payload_offset+sdu_length_total+j] = (char)(taus()&0xff); + if (post_padding) { + for (j=0; j<(buflen-sdu_length_total-payload_offset); j++) { + ulsch_buffer[payload_offset+sdu_length_total+j] = (char)(taus()&0xff); + } } LOG_D(MAC,"[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", module_idP,payload_offset, sdu_length_total); @@ -2295,7 +2319,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subfra uint8_t lcgid; uint8_t num_lcid_with_data = 0; // for LCID with data only if LCGID is defined uint16_t lcgid_buffer_remain[MAX_NUM_LCGID] = {0,0,0,0}; - uint16_t lcid_bytes_in_buffer[MAX_NUM_LCID]; + int32_t lcid_bytes_in_buffer[MAX_NUM_LCID]; /* Array for ordering LCID with data per decreasing priority order */ uint8_t lcid_reordered_array[MAX_NUM_LCID]= {MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID}; From ea7c0e1b36656de02bf1185ab9cd77786e0cd143 Mon Sep 17 00:00:00 2001 From: hbilel Date: Tue, 29 Nov 2016 15:26:57 +0100 Subject: [PATCH 46/60] reduce BSR logging --- openair2/LAYER2/MAC/ue_procedures.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 0413cfe524..28520802c7 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -1752,7 +1752,7 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; - LOG_I(MAC, "[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP,subframe, + LOG_D(MAC, "[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP,subframe, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], @@ -1767,7 +1767,7 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) bsr_t->LCGID = lcg_id_bsr_trunc; bsr_t->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc]; - LOG_I(MAC,"[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", + LOG_D(MAC,"[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", module_idP, frameP, subframe, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); } @@ -1777,7 +1777,7 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) bsr_s->LCGID = lcg_id_bsr_trunc; bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc]; - LOG_I(MAC,"[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", + LOG_D(MAC,"[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", module_idP, frameP, subframe, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); } } From bc032392c9e7c9fc2e97d4f4905d00e9bb7f19d0 Mon Sep 17 00:00:00 2001 From: fnabet Date: Mon, 5 Dec 2016 16:51:27 +0100 Subject: [PATCH 47/60] add workarounds for OAI issues --- openair2/LAYER2/MAC/ue_procedures.c | 37 ++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 28520802c7..886ccff238 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -70,6 +70,8 @@ #define DEBUG_HEADER_PARSING 1 #define ENABLE_MAC_PAYLOAD_DEBUG 1 +extern uint8_t usim_test; + /* #ifndef USER_MODE #define msg debug_msg @@ -1408,6 +1410,13 @@ for (lcid=DCCH; lcid < DTCH ; lcid++) { //Adjust at the end of the loop while ((!is_lcid_processed) && (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) { + // Workaround for issue in OAI eNB or EPC which are not able to process SRB2 message multiplexed with SRB1 on the same MAC PDU + if ((usim_test == 0) && (lcid == DCCH1) && (lcid_rlc_pdu_count == 0) && (num_sdus)) { + + // Skip SRB2 multiplex if at least one SRB1 SDU is already multiplexed + break; + } + buflen_remain = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); rlc_status = mac_rlc_status_ind(module_idP, @@ -1419,8 +1428,21 @@ for (lcid=DCCH; lcid < DTCH ; lcid++) { lcid, buflen_remain); + // Workaround for BO issue in RLC AM ReTx : RLC BO can not be bigger than stored MAC BO + if (UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] < rlc_status.bytes_in_buffer) { + + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Inconsistent BO! for LCID=%d MAC=%d RLC=%d RLC PDU nb=%d\n", + module_idP,frameP,subframe, + lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer,lcid_rlc_pdu_count); + + // Skip multiplexing for the LCID + break; + } + + /* AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d RLC PDU nb=%d Frame %d Subrame %d\n", lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer,lcid_rlc_pdu_count,frameP,subframe); + */ if (rlc_status.bytes_in_buffer > 0) { @@ -1535,8 +1557,21 @@ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) lcid, buflen_remain); - AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d RLC PDU nb=%d Frame %d Subrame %d\n", + // Workaround for BO issue in RLC AM ReTx : RLC BO can not be bigger than stored MAC BO + if (UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] < rlc_status.bytes_in_buffer) { + + LOG_I(MAC, "[UE %d] Frame %d Subframe%d: WARNING Inconsistent BO! for LCID=%d MAC=%d RLC=%d RLC PDU nb=%d\n", + module_idP,frameP,subframe, + lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer,lcid_rlc_pdu_count); + + // Skip multiplexing for the LCID + break; + } + + /* + AssertFatal ( UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] >= rlc_status.bytes_in_buffer, "Inconsistent BO! for LCID=%d MAC=%d RLC=%d RLC PDU nb=%d Frame %d Subrame %d\n", lcid,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid],rlc_status.bytes_in_buffer,lcid_rlc_pdu_count,frameP,subframe); + */ if (rlc_status.bytes_in_buffer > 0) { From bd30471076e9624c9c3041fb138fba87e9f8248e Mon Sep 17 00:00:00 2001 From: gabrielC Date: Thu, 8 Dec 2016 11:07:38 +0100 Subject: [PATCH 48/60] [OAI-UE] merge com4Innov branch to integration branch --- cmake_targets/CMakeLists.txt | 4 +- openair1/PHY/defs.h | 2 +- openair2/COMMON/commonDef.h | 2 +- openair2/LAYER2/MAC/ue_procedures.c | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 2 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c | 18 +++++- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h | 2 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c | 8 +-- openair2/LAYER2/RLC/rlc_mac.c | 2 +- openair2/NETWORK_DRIVER/UE_IP/common.c | 5 +- openair3/NAS/COMMON/EMM/MSG/AttachAccept.c | 3 +- .../COMMON/EMM/MSG/AuthenticationRequest.c | 2 +- .../NAS/COMMON/EMM/MSG/SecurityModeCommand.c | 2 + .../NAS/COMMON/EMM/MSG/SecurityModeComplete.c | 5 +- openair3/NAS/COMMON/IES/EmergencyNumberList.c | 54 ++++++++++++++---- openair3/NAS/COMMON/IES/EmergencyNumberList.h | 10 +++- openair3/NAS/COMMON/IES/MobileIdentity.c | 15 +++-- openair3/NAS/COMMON/IES/MobileIdentity.h | 57 ++++++++++++++++++- openair3/NAS/UE/EMM/SAP/emm_asDef.h | 1 + openair3/NAS/UE/EMM/SAP/emm_recv.c | 4 +- openair3/NAS/UE/EMM/SAP/emm_send.c | 29 ++++++++++ openair3/NAS/UE/EMM/SecurityModeControl.c | 3 +- openair3/NAS/UE/EMM/emm_proc.h | 2 +- targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c | 4 +- 24 files changed, 194 insertions(+), 44 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 07d92a1b05..891001ecbc 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -644,7 +644,7 @@ add_boolean_option(ENABLE_USE_CPU_EXECUTION_TIME True "Add data in vcd traces: d add_boolean_option(ENABLE_VCD True "always true now, time measurements of proc calls and var displays") add_boolean_option(ENABLE_VCD_FIFO True "time measurements of proc calls and var displays sent to FIFO (one more thread)") add_boolean_option(HARD_RT False "???") -add_boolean_option(LINUX False "used in weird memcpy() in pdcp.c ???") +add_boolean_option(LINUX True "used in weird memcpy() in pdcp.c ???") add_boolean_option(LINUX_LIST False "used only in lists.c: either use OAI implementation of lists or Linux one (should be True, but it is False") add_boolean_option(LOG_NO_THREAD True "Disable thread for log, seems always set to true") add_boolean_option(OPENAIR_LTE True "Seems legacy: keep it to true") @@ -727,7 +727,7 @@ add_boolean_option(TRACE_RLC_UM_TX_STATUS False "TRACE for RLC UM, TO BE CHANGE ########################## # PDCP LAYER OPTIONS ########################## -add_boolean_option(PDCP_USE_NETLINK False "For eNB, PDCP communicate with a NETLINK socket if connected to network driver, else could use a RT-FIFO") +add_boolean_option(PDCP_USE_NETLINK True "For eNB, PDCP communicate with a NETLINK socket if connected to network driver, else could use a RT-FIFO") add_boolean_option(PDCP_USE_NETLINK_QUEUES False "When PDCP_USE_NETLINK is true, incoming IP packets are stored in queues") add_boolean_option(LINK_ENB_PDCP_TO_IP_DRIVER False "For eNB, PDCP communicate with a IP driver") add_boolean_option(LINK_ENB_PDCP_TO_GTPV1U True "For eNB, PDCP communicate with GTP-U protocol (eNB<->S-GW)") diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 375efa5fea..0e69265d20 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -656,7 +656,7 @@ typedef struct { /// \brief Total gains with bypassed RF gain stage (ExpressMIMO2/Lime) uint32_t rx_gain_byp[4]; /// \brief Current transmit power - int8_t tx_power_dBm[10]; + int16_t tx_power_dBm[10]; /// \brief Total number of REs in current transmission int tx_total_RE[10]; /// \brief Maximum transmit power diff --git a/openair2/COMMON/commonDef.h b/openair2/COMMON/commonDef.h index cfd5d68e40..ae1bdaf994 100644 --- a/openair2/COMMON/commonDef.h +++ b/openair2/COMMON/commonDef.h @@ -119,7 +119,7 @@ typedef struct { Byte_t digit14:4; Byte_t digit13:4; #define EVEN_PARITY 0 -#define ODD_PARITY 1 +#define ODD_PARITY 0xf Byte_t parity:4; Byte_t digit15:4; } num; diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 886ccff238..642475a063 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -1356,7 +1356,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf // Trigger BSR Periodic UE_mac_inst[module_idP].BSR_reporting_active |= BSR_TRIGGER_PERIODIC; - LOG_I(MAC,"[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n", + LOG_D(MAC,"[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n", module_idP, frameP, subframe, buflen); } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 17808c03ff..fedef42b60 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -493,7 +493,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ctxt.enb_flag = ctxt_cpy.enb_flag; #ifdef PDCP_DEBUG - LOG_I(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d\n", pdcp_read_header_g.rb_id); + LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d\n", pdcp_read_header_g.rb_id); #endif if (ctxt_cpy.enb_flag) { diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c index 3232399d10..51440d0bfa 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -426,7 +426,7 @@ rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, void *argP, struct mac_data_ind //----------------------------------------------------------------------------- struct mac_status_resp -rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, uint16_t tbs_sizeP, struct mac_status_ind tx_statusP) +rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, uint16_t tbs_sizeP, struct mac_status_ind tx_statusP,const eNB_flag_t enb_flagP) { struct mac_status_resp status_resp; uint16_t sdu_size = 0; @@ -434,6 +434,7 @@ rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP int32_t diff_time=0; rlc_um_entity_t *rlc_p = NULL; mem_block_t *mb_p = NULL; + unsigned int max_li_overhead = 0; status_resp.buffer_occupancy_in_pdus = 0; status_resp.buffer_occupancy_in_bytes = 0; @@ -453,7 +454,20 @@ rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP if ((status_resp.buffer_occupancy_in_bytes > 0) && ((mb_p = list_get_head(&rlc_p->input_sdus)) != NULL)) { - status_resp.buffer_occupancy_in_bytes += rlc_p->tx_header_min_length_in_bytes; + //Fix on full Header size + if (enb_flagP == ENB_FLAG_NO) + { + // compute Length Indicator overhead to inform MAC of maximum full RLC PDU size according to stored SDUs + // For UE scheduler + // Could be useful for eNB: to be checked + if (rlc_p->input_sdus.nb_elements <= 1) { + max_li_overhead = 0; + } else { + unsigned int num_li = rlc_p->input_sdus.nb_elements - 1; + max_li_overhead = num_li + (num_li >> 1) + (num_li & 1); + } + } + status_resp.buffer_occupancy_in_bytes += (rlc_p->tx_header_min_length_in_bytes + max_li_overhead); status_resp.buffer_occupancy_in_pdus = rlc_p->input_sdus.nb_elements; diff_time = ctxt_pP->frame - ((struct rlc_um_tx_sdu_management *)mb_p->data)->sdu_creation_time; diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h index d87f1e29d0..5951eaf149 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h @@ -186,7 +186,7 @@ protected_rlc_um( void rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, rlc_ * \param[in] tx_statusP Transmission status given by MAC on previous MAC transmission of the PDU. * \return The maximum number of bytes that can be served by RLC instance to MAC. */ -public_rlc_um( struct mac_status_resp rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, uint16_t tbs_sizeP, struct mac_status_ind tx_statusP);) +public_rlc_um( struct mac_status_resp rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, uint16_t tbs_sizeP, struct mac_status_ind tx_statusP, const eNB_flag_t enb_flagP);) /*! \fn struct mac_data_req rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP) * \brief Gives PDUs to lower layer MAC. diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c index c9a82e12f6..92f18e72d7 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c @@ -471,9 +471,9 @@ void rlc_um_v9_3_0_test_exchange_pdus(rlc_um_entity_t *um_txP, memset(&mac_rlc_status_resp_tx, 0, sizeof(struct mac_status_resp)); memset(&mac_rlc_status_resp_rx, 0, sizeof(struct mac_status_resp)); - mac_rlc_status_resp_tx = rlc_um_mac_status_indication(um_txP, g_frame, 1, bytes_txP, tx_status); + mac_rlc_status_resp_tx = rlc_um_mac_status_indication(um_txP, g_frame, 1, bytes_txP, tx_status,ENB_FLAG_YES); data_request_tx = rlc_um_mac_data_request(um_txP, g_frame); - mac_rlc_status_resp_rx = rlc_um_mac_status_indication(um_rxP, g_frame, 0, bytes_rxP, tx_status); + mac_rlc_status_resp_rx = rlc_um_mac_status_indication(um_rxP, g_frame, 0, bytes_rxP, tx_status,ENB_FLAG_YES); data_request_rx = rlc_um_mac_data_request(um_rxP, g_frame); @@ -517,9 +517,9 @@ void rlc_um_v9_3_0_test_exchange_delayed_pdus(rlc_um_entity_t *um_txP, memset(&mac_rlc_status_resp_tx, 0, sizeof(struct mac_status_resp)); memset(&mac_rlc_status_resp_rx, 0, sizeof(struct mac_status_resp)); - mac_rlc_status_resp_tx = rlc_um_mac_status_indication(um_txP, g_frame, 1, bytes_txP, tx_status); + mac_rlc_status_resp_tx = rlc_um_mac_status_indication(um_txP, g_frame, 1, bytes_txP, tx_status,ENB_FLAG_YES); data_request_tx = rlc_um_mac_data_request(um_txP, g_frame); - mac_rlc_status_resp_rx = rlc_um_mac_status_indication(um_rxP, g_frame, 0, bytes_rxP, tx_status); + mac_rlc_status_resp_rx = rlc_um_mac_status_indication(um_rxP, g_frame, 0, bytes_rxP, tx_status,ENB_FLAG_YES); data_request_rx = rlc_um_mac_data_request(um_rxP, g_frame); diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index 6462bb9abb..d59b187dc7 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -406,7 +406,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind( break; case RLC_MODE_UM: - status_resp = rlc_um_mac_status_indication(&ctxt, &rlc_union_p->rlc.um, tb_sizeP, tx_status); + status_resp = rlc_um_mac_status_indication(&ctxt, &rlc_union_p->rlc.um, tb_sizeP, tx_status, enb_flagP); mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; mac_rlc_status_resp.pdus_in_buffer = status_resp.buffer_occupancy_in_pdus; mac_rlc_status_resp.head_sdu_creation_time = status_resp.head_sdu_creation_time; diff --git a/openair2/NETWORK_DRIVER/UE_IP/common.c b/openair2/NETWORK_DRIVER/UE_IP/common.c index 6bef269de8..8696801597 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/common.c +++ b/openair2/NETWORK_DRIVER/UE_IP/common.c @@ -99,7 +99,8 @@ ue_ip_common_class_wireless2ip( hard_header_len = ue_ip_dev[instP]->hard_header_len; skb_set_mac_header(skb_p, 0); - + skb_set_network_header(skb_p, hard_header_len); +skb_p->mark = rb_idP; //printk("[NAC_COMMIN_RECEIVE]: Packet Type %d (%d,%d)",skb_p->pkt_type,PACKET_HOST,PACKET_BROADCAST); skb_p->pkt_type = PACKET_HOST; @@ -344,7 +345,7 @@ void ue_ip_common_wireless2ip(struct nlmsghdr *nlh_pP) ue_ip_common_class_wireless2ip(pdcph_p->data_size, (unsigned char *)NLMSG_DATA(nlh_pP) + UE_IP_PDCPH_SIZE, - pdcph_p->inst, + 1, //pdcph_p->inst, pdcph_p->rb_id); } diff --git a/openair3/NAS/COMMON/EMM/MSG/AttachAccept.c b/openair3/NAS/COMMON/EMM/MSG/AttachAccept.c index cec2d16977..248540dff3 100644 --- a/openair3/NAS/COMMON/EMM/MSG/AttachAccept.c +++ b/openair3/NAS/COMMON/EMM/MSG/AttachAccept.c @@ -188,10 +188,11 @@ int decode_attach_accept(attach_accept_msg *attach_accept, uint8_t *buffer, uint default: errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI; + LOG_TRACE(WARNING, "DECODE_UNEXPECTED_IEI %x (4 bits)", ieiDecoded); return TLV_DECODE_UNEXPECTED_IEI; } } - + LOG_TRACE(WARNING, "DECODED %d\n", decoded); return decoded; } diff --git a/openair3/NAS/COMMON/EMM/MSG/AuthenticationRequest.c b/openair3/NAS/COMMON/EMM/MSG/AuthenticationRequest.c index fac93c5df3..3e0bffde2d 100644 --- a/openair3/NAS/COMMON/EMM/MSG/AuthenticationRequest.c +++ b/openair3/NAS/COMMON/EMM/MSG/AuthenticationRequest.c @@ -38,7 +38,7 @@ int decode_authentication_request(authentication_request_msg *authentication_req CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len); /* Decoding mandatory fields */ - if ((decoded_result = decode_u8_nas_key_set_identifier(&authentication_request->naskeysetidentifierasme, 0, *(buffer + decoded) >> 4, len - decoded)) < 0) + if ((decoded_result = decode_u8_nas_key_set_identifier(&authentication_request->naskeysetidentifierasme, 0, *(buffer + decoded), len - decoded)) < 0) return decoded_result; decoded++; diff --git a/openair3/NAS/COMMON/EMM/MSG/SecurityModeCommand.c b/openair3/NAS/COMMON/EMM/MSG/SecurityModeCommand.c index aeec3d4024..c89a9f5bb7 100644 --- a/openair3/NAS/COMMON/EMM/MSG/SecurityModeCommand.c +++ b/openair3/NAS/COMMON/EMM/MSG/SecurityModeCommand.c @@ -72,6 +72,8 @@ int decode_security_mode_command(security_mode_command_msg *security_mode_comman decoded += decoded_result; /* Set corresponding mask to 1 in presencemask */ security_mode_command->presencemask |= SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT; + LOG_I(NAS," SECURITY MODE COMMAND: IMEISV_REQUEST: %d \n",security_mode_command->imeisvrequest); + break; case SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_IEI: diff --git a/openair3/NAS/COMMON/EMM/MSG/SecurityModeComplete.c b/openair3/NAS/COMMON/EMM/MSG/SecurityModeComplete.c index f10401d09a..80ceeb34d7 100644 --- a/openair3/NAS/COMMON/EMM/MSG/SecurityModeComplete.c +++ b/openair3/NAS/COMMON/EMM/MSG/SecurityModeComplete.c @@ -76,8 +76,11 @@ int encode_security_mode_complete(security_mode_complete_msg *security_mode_comp /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SECURITY_MODE_COMPLETE_MINIMUM_LENGTH, len); + LOG_I(NAS,"SECURITY MODE COMMAND COMPLETE: presencemask: %d \n",security_mode_complete->presencemask); + if ((security_mode_complete->presencemask & SECURITY_MODE_COMPLETE_IMEISV_PRESENT) == SECURITY_MODE_COMPLETE_IMEISV_PRESENT) { + LOG_I(NAS,"SECURITY MODE COMMAND COMPLETE: encode imeisv \n"); if ((encode_result = encode_mobile_identity(&security_mode_complete->imeisv, SECURITY_MODE_COMPLETE_IMEISV_IEI, buffer + encoded, len - @@ -87,7 +90,7 @@ int encode_security_mode_complete(security_mode_complete_msg *security_mode_comp else encoded += encode_result; } - + LOG_I(NAS,"SECURITY MODE COMMAND COMPLETE done !!! \n"); return encoded; } diff --git a/openair3/NAS/COMMON/IES/EmergencyNumberList.c b/openair3/NAS/COMMON/IES/EmergencyNumberList.c index 39b59ef0ca..9330fdc312 100644 --- a/openair3/NAS/COMMON/IES/EmergencyNumberList.c +++ b/openair3/NAS/COMMON/IES/EmergencyNumberList.c @@ -41,10 +41,24 @@ int decode_emergency_number_list(EmergencyNumberList *emergencynumberlist, uint8 ielen = *(buffer + decoded); decoded++; CHECK_LENGTH_DECODER(len - decoded, ielen); - emergencynumberlist->lengthofemergency = *(buffer + decoded); - decoded++; - emergencynumberlist->emergencyservicecategoryvalue = *(buffer + decoded) & 0x1f; - decoded++; + int information_element_index = 0; + while ((decoded < ielen) && (information_element_index < EMERGENCY_NUMBER_LIST_MAX_NUMBER_INFORMATION)) { + emergencynumberlist->emergency_number_information[information_element_index].lengthofemergency = *(buffer + decoded); + decoded++; + emergencynumberlist->emergency_number_information[information_element_index].emergencyservicecategoryvalue = *(buffer + decoded) & 0x1f; + decoded++; + int remaining_len = emergencynumberlist->emergency_number_information[information_element_index].lengthofemergency - 1; + int digit_index = 0; + while (remaining_len > 0) { + emergencynumberlist->emergency_number_information[information_element_index].bcd_digits[digit_index++] = *(buffer + decoded); + decoded++; + remaining_len --; + } + while (digit_index < EMERGENCY_NUMBER_LIST_MAX_2DIGITS) { + emergencynumberlist->emergency_number_information[information_element_index].bcd_digits[digit_index++] = 0xFF; + } + information_element_index++; + } #if defined (NAS_DEBUG) dump_emergency_number_list_xml(emergencynumberlist, iei); #endif @@ -67,11 +81,16 @@ int encode_emergency_number_list(EmergencyNumberList *emergencynumberlist, uint8 lenPtr = (buffer + encoded); encoded ++; - *(buffer + encoded) = emergencynumberlist->lengthofemergency; - encoded++; - *(buffer + encoded) = 0x00 | - (emergencynumberlist->emergencyservicecategoryvalue & 0x1f); - encoded++; + for ( int ie_index = 0; ie_index < emergencynumberlist->num_emergency_elements; ie_index++) { + *(buffer + encoded) = emergencynumberlist->emergency_number_information[ie_index].lengthofemergency; + encoded++; + *(buffer + encoded) = 0x00 | + (emergencynumberlist->emergency_number_information[ie_index].emergencyservicecategoryvalue & 0x1f); + encoded++; + for (int bcd2_index = 0; bcd2_index < (emergencynumberlist->emergency_number_information[ie_index].lengthofemergency - 1); bcd2_index++) { + *(buffer + encoded) = emergencynumberlist->emergency_number_information[ie_index].bcd_digits[bcd2_index]; + } + } *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; } @@ -83,9 +102,20 @@ void dump_emergency_number_list_xml(EmergencyNumberList *emergencynumberlist, ui if (iei > 0) /* Don't display IEI if = 0 */ printf(" 0x%X\n", iei); - - printf(" %u\n", emergencynumberlist->lengthofemergency); - printf(" %u\n", emergencynumberlist->emergencyservicecategoryvalue); + for ( int ie_index = 0; ie_index < emergencynumberlist->num_emergency_elements; ie_index++) { + printf(" %u\n", emergencynumberlist->emergency_number_information[ie_index].lengthofemergency); + printf(" %u\n", emergencynumberlist->emergency_number_information[ie_index].emergencyservicecategoryvalue); + for (int bcd2_index = 0; bcd2_index < (emergencynumberlist->emergency_number_information[ie_index].lengthofemergency - 1); bcd2_index++) { + uint8_t bcd1 = emergencynumberlist->emergency_number_information[ie_index].bcd_digits[bcd2_index] & 0x0f; + uint8_t bcd2 = (emergencynumberlist->emergency_number_information[ie_index].bcd_digits[bcd2_index] & 0xf0) >> 4; + if (bcd1 < 10) { + printf(" %u\n", (bcd2_index*2)+1, bcd1, (bcd2_index*2)+1); + if (bcd2 < 10) { + printf(" %u\n", (bcd2_index*2)+2, bcd2, (bcd2_index*2)+2); + } + } + } + } printf("\n"); } diff --git a/openair3/NAS/COMMON/IES/EmergencyNumberList.h b/openair3/NAS/COMMON/IES/EmergencyNumberList.h index d2fd149dc0..ab47c1ff06 100644 --- a/openair3/NAS/COMMON/IES/EmergencyNumberList.h +++ b/openair3/NAS/COMMON/IES/EmergencyNumberList.h @@ -32,8 +32,14 @@ #define EMERGENCY_NUMBER_LIST_MAXIMUM_LENGTH 50 typedef struct EmergencyNumberList_tag { - uint8_t lengthofemergency; - uint8_t emergencyservicecategoryvalue:5; + uint8_t num_emergency_elements; + struct { + uint8_t lengthofemergency; + uint8_t emergencyservicecategoryvalue:5; +#define EMERGENCY_NUMBER_LIST_MAX_2DIGITS 6 + uint8_t bcd_digits[EMERGENCY_NUMBER_LIST_MAX_2DIGITS]; // length to be fixed +#define EMERGENCY_NUMBER_LIST_MAX_NUMBER_INFORMATION 2 + } emergency_number_information[EMERGENCY_NUMBER_LIST_MAX_NUMBER_INFORMATION]; } EmergencyNumberList; int encode_emergency_number_list(EmergencyNumberList *emergencynumberlist, uint8_t iei, uint8_t *buffer, uint32_t len); diff --git a/openair3/NAS/COMMON/IES/MobileIdentity.c b/openair3/NAS/COMMON/IES/MobileIdentity.c index 7ab30011ce..59cf4dc44f 100644 --- a/openair3/NAS/COMMON/IES/MobileIdentity.c +++ b/openair3/NAS/COMMON/IES/MobileIdentity.c @@ -575,6 +575,8 @@ static int encode_imei_mobile_identity(ImeiMobileIdentity_t *imei, uint8_t *buff static int encode_imeisv_mobile_identity(ImeisvMobileIdentity_t *imeisv, uint8_t *buffer) { uint32_t encoded = 0; + LOG_I(NAS,"SECURITY MODE COMMAND COMPLETE: encode_imeisv_mobile_identity \n"); + *(buffer + encoded) = 0x00 | (imeisv->digit1 << 4) | (imeisv->oddeven << 3) | (imeisv->typeofidentity); encoded++; @@ -590,12 +592,15 @@ static int encode_imeisv_mobile_identity(ImeisvMobileIdentity_t *imeisv, uint8_t encoded++; *(buffer + encoded) = 0x00 | (imeisv->digit13 << 4) | imeisv->digit12; encoded++; + *(buffer + encoded) = 0x00 | (imeisv->digit15 << 4) | imeisv->digit14; + encoded++; + *(buffer + encoded) = 0x00 | (imeisv->parity << 4) | imeisv->digit16; - if (imeisv->oddeven != MOBILE_IDENTITY_EVEN) { - *(buffer + encoded) = 0x00 | (imeisv->digit15 << 4) | imeisv->digit14; - } else { - *(buffer + encoded) = 0xf0 | imeisv->digit14; - } + //if (imeisv->oddeven != MOBILE_IDENTITY_EVEN) { + // *(buffer + encoded) = 0x00 | (imeisv->digit15 << 4) | imeisv->digit14; + //} else { + // *(buffer + encoded) = 0xf0 | imeisv->digit14; + //} encoded++; return encoded; diff --git a/openair3/NAS/COMMON/IES/MobileIdentity.h b/openair3/NAS/COMMON/IES/MobileIdentity.h index 8d1c5cdbe5..9c082c12df 100644 --- a/openair3/NAS/COMMON/IES/MobileIdentity.h +++ b/openair3/NAS/COMMON/IES/MobileIdentity.h @@ -73,8 +73,63 @@ typedef struct { uint8_t mbmssessionid; } TmgiMobileIdentity_t; +typedef struct imeisv_s{ + uint8_t digit1:4; + uint8_t oddeven:1; + uint8_t typeofidentity:3; + uint8_t digit2:4; + uint8_t digit3:4; + uint8_t digit4:4; + uint8_t digit5:4; + uint8_t digit6:4; + uint8_t digit7:4; + uint8_t digit8:4; + uint8_t digit9:4; + uint8_t digit10:4; + uint8_t digit11:4; + uint8_t digit12:4; + uint8_t digit13:4; + uint8_t digit14:4; + uint8_t digit15:4; + uint8_t digit16:4; +#define EVEN_PARITY 0 +#define ODD_PARITY 1 + uint8_t parity:4; +} imeisv_t; + +#if 0 +typedef struct imeisv_s { + uint8_t length; + union { + struct { + uint8_t tac2:4; + uint8_t tac1:4; + uint8_t tac4:4; + uint8_t tac3:4; + uint8_t tac6:4; + uint8_t tac5:4; + uint8_t tac8:4; + uint8_t tac7:4; + uint8_t snr2:4; + uint8_t snr1:4; + uint8_t snr4:4; + uint8_t snr3:4; + uint8_t snr6:4; + uint8_t snr5:4; + uint8_t svn2:4; + uint8_t svn1:4; +#define EVEN_PARITY 0 +#define ODD_PARITY 1 + uint8_t parity:4; + } num; +#define IMEISV_BCD8_SIZE 9 + uint8_t value[IMEISV_BCD8_SIZE]; + } u; +} imeisv_t; +#endif + typedef ImsiMobileIdentity_t ImeiMobileIdentity_t; -typedef ImsiMobileIdentity_t ImeisvMobileIdentity_t; +typedef imeisv_t ImeisvMobileIdentity_t; typedef ImsiMobileIdentity_t TmsiMobileIdentity_t; typedef ImsiMobileIdentity_t NoMobileIdentity_t; diff --git a/openair3/NAS/UE/EMM/SAP/emm_asDef.h b/openair3/NAS/UE/EMM/SAP/emm_asDef.h index bf0e6f6c37..69ea979b63 100644 --- a/openair3/NAS/UE/EMM/SAP/emm_asDef.h +++ b/openair3/NAS/UE/EMM/SAP/emm_asDef.h @@ -120,6 +120,7 @@ typedef struct emm_as_security_s { uint8_t ucs2; uint8_t uia; /* Replayed UMTS integrity algorithms */ uint8_t gea; /* Replayed GPRS encryption algorithms */ + uint8_t imeisv_request; uint8_t umts_present; uint8_t gprs_present; diff --git a/openair3/NAS/UE/EMM/SAP/emm_recv.c b/openair3/NAS/UE/EMM/SAP/emm_recv.c index a79a14d9c1..60b504f1ce 100644 --- a/openair3/NAS/UE/EMM/SAP/emm_recv.c +++ b/openair3/NAS/UE/EMM/SAP/emm_recv.c @@ -472,13 +472,15 @@ int emm_recv_security_mode_command(security_mode_command_msg *msg, * Message processing */ /* Execute the security mode control procedure initiated by the network */ + LOG_I(NAS,"Execute the security mode control procedure initiated by the network: imeisvrequest %d\n",msg->imeisvrequest); rc = emm_proc_security_mode_command( msg->naskeysetidentifier.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, msg->naskeysetidentifier.naskeysetidentifier, msg->selectednassecurityalgorithms.typeofcipheringalgorithm, msg->selectednassecurityalgorithms.typeofintegrityalgorithm, msg->replayeduesecuritycapabilities.eea, - msg->replayeduesecuritycapabilities.eia); + msg->replayeduesecuritycapabilities.eia, + msg->imeisvrequest & 0x7); LOG_FUNC_RETURN (rc); } diff --git a/openair3/NAS/UE/EMM/SAP/emm_send.c b/openair3/NAS/UE/EMM/SAP/emm_send.c index 7e13d03c7b..e960b85848 100644 --- a/openair3/NAS/UE/EMM/SAP/emm_send.c +++ b/openair3/NAS/UE/EMM/SAP/emm_send.c @@ -855,6 +855,35 @@ int emm_send_security_mode_complete(const emm_as_security_t *msg, /* Mandatory - Message type */ emm_msg->messagetype = SECURITY_MODE_COMPLETE; + if(msg->imeisv_request) + { + // configure imeisv param + emm_msg->presencemask |= SECURITY_MODE_COMPLETE_IMEISV_PRESENT; + + // 33 85 76 02 05 26 84 01 F1 + emm_msg->imeisv.imeisv; + emm_msg->imeisv.imeisv.digit1 = 0x3; + emm_msg->imeisv.imeisv.oddeven = 0x0; + emm_msg->imeisv.imeisv.typeofidentity = 0x3; + emm_msg->imeisv.imeisv.digit2 = 0x5; + emm_msg->imeisv.imeisv.digit3 = 0x7; + emm_msg->imeisv.imeisv.digit4 = 0x4; + emm_msg->imeisv.imeisv.digit5 = 0x7; + emm_msg->imeisv.imeisv.digit6 = 0x3; + emm_msg->imeisv.imeisv.digit7 = 0x0; + emm_msg->imeisv.imeisv.digit8 = 0x4; + emm_msg->imeisv.imeisv.digit9 = 0x0; + emm_msg->imeisv.imeisv.digit10 = 0x0; + emm_msg->imeisv.imeisv.digit11 = 0x7; + emm_msg->imeisv.imeisv.digit12 = 0x0; + emm_msg->imeisv.imeisv.digit13 = 0x5; + emm_msg->imeisv.imeisv.digit14 = 0x3; + emm_msg->imeisv.imeisv.digit15 = 0x0; + emm_msg->imeisv.imeisv.digit16 = 0x0; + emm_msg->imeisv.imeisv.parity = ODD_PARITY; + + size += SECURITY_MODE_COMPLETE_MAXIMUM_LENGTH; + } LOG_FUNC_RETURN (size); } diff --git a/openair3/NAS/UE/EMM/SecurityModeControl.c b/openair3/NAS/UE/EMM/SecurityModeControl.c index 7d19808481..f27eb7b4af 100644 --- a/openair3/NAS/UE/EMM/SecurityModeControl.c +++ b/openair3/NAS/UE/EMM/SecurityModeControl.c @@ -146,7 +146,7 @@ static void _security_release(emm_security_context_t *ctx); ** ** ***************************************************************************/ int emm_proc_security_mode_command(int native_ksi, int ksi, - int seea, int seia, int reea, int reia) + int seea, int seia, int reea, int reia, int imeisv_request) { LOG_FUNC_IN; @@ -329,6 +329,7 @@ int emm_proc_security_mode_command(int native_ksi, int ksi, emm_sap.u.emm_as.u.security.guti = _emm_data.guti; emm_sap.u.emm_as.u.security.ueid = 0; emm_sap.u.emm_as.u.security.msgType = EMM_AS_MSG_TYPE_SMC; + emm_sap.u.emm_as.u.security.imeisv_request = imeisv_request; emm_sap.u.emm_as.u.security.emm_cause = emm_cause; /* Setup EPS NAS security data */ emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx, diff --git a/openair3/NAS/UE/EMM/emm_proc.h b/openair3/NAS/UE/EMM/emm_proc.h index e6a3ae0cdd..60f71f11c2 100644 --- a/openair3/NAS/UE/EMM/emm_proc.h +++ b/openair3/NAS/UE/EMM/emm_proc.h @@ -174,7 +174,7 @@ int emm_proc_authentication_delete(void); * -------------------------------------------------------------------------- */ int emm_proc_security_mode_command(int native_ksi, int ksi, int seea, int seia, - int reea, int reia); + int reea, int reia,int imeisv_request); /* *--------------------------------------------------------------------------- diff --git a/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c b/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c index 0c1500fd5e..dc395281dc 100644 --- a/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c +++ b/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c @@ -188,9 +188,9 @@ void pdcp_rlc_test_exchange_pdus(rlc_um_entity_t *um_txP, memset(&mac_rlc_status_resp_tx, 0, sizeof(struct mac_status_resp)); memset(&mac_rlc_status_resp_rx, 0, sizeof(struct mac_status_resp)); - mac_rlc_status_resp_tx = rlc_um_mac_status_indication(um_txP, bytes_txP, tx_status); + mac_rlc_status_resp_tx = rlc_um_mac_status_indication(um_txP, bytes_txP, tx_status, ENB_FLAG_YES); data_request_tx = rlc_um_mac_data_request(um_txP); - mac_rlc_status_resp_rx = rlc_um_mac_status_indication(um_rxP, bytes_rxP, tx_status); + mac_rlc_status_resp_rx = rlc_um_mac_status_indication(um_rxP, bytes_rxP, tx_status, ENB_FLAG_YES); data_request_rx = rlc_um_mac_data_request(um_rxP); From 179ff736584b6dfd5956bc5c3b1a2033bb3af035 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 8 Dec 2016 16:47:30 +0100 Subject: [PATCH 49/60] integration fix: use old CMakeLists.txt Another way to set those two variables has to be used for the specific UE case (use a sub CMakeLists.txt, see in build_oai). --- cmake_targets/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 891001ecbc..07d92a1b05 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -644,7 +644,7 @@ add_boolean_option(ENABLE_USE_CPU_EXECUTION_TIME True "Add data in vcd traces: d add_boolean_option(ENABLE_VCD True "always true now, time measurements of proc calls and var displays") add_boolean_option(ENABLE_VCD_FIFO True "time measurements of proc calls and var displays sent to FIFO (one more thread)") add_boolean_option(HARD_RT False "???") -add_boolean_option(LINUX True "used in weird memcpy() in pdcp.c ???") +add_boolean_option(LINUX False "used in weird memcpy() in pdcp.c ???") add_boolean_option(LINUX_LIST False "used only in lists.c: either use OAI implementation of lists or Linux one (should be True, but it is False") add_boolean_option(LOG_NO_THREAD True "Disable thread for log, seems always set to true") add_boolean_option(OPENAIR_LTE True "Seems legacy: keep it to true") @@ -727,7 +727,7 @@ add_boolean_option(TRACE_RLC_UM_TX_STATUS False "TRACE for RLC UM, TO BE CHANGE ########################## # PDCP LAYER OPTIONS ########################## -add_boolean_option(PDCP_USE_NETLINK True "For eNB, PDCP communicate with a NETLINK socket if connected to network driver, else could use a RT-FIFO") +add_boolean_option(PDCP_USE_NETLINK False "For eNB, PDCP communicate with a NETLINK socket if connected to network driver, else could use a RT-FIFO") add_boolean_option(PDCP_USE_NETLINK_QUEUES False "When PDCP_USE_NETLINK is true, incoming IP packets are stored in queues") add_boolean_option(LINK_ENB_PDCP_TO_IP_DRIVER False "For eNB, PDCP communicate with a IP driver") add_boolean_option(LINK_ENB_PDCP_TO_GTPV1U True "For eNB, PDCP communicate with GTP-U protocol (eNB<->S-GW)") From e4a84606b94bcf26a9b076f6bfaa785d0d670327 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 8 Dec 2016 17:09:39 +0100 Subject: [PATCH 50/60] integration fix: send SRS configuration to UE only if SRS active Manually testing with the Samsung Galaxy Note 4 failed, probably because the phone didn't like to receive SRS configuration. Let's send it only if activated. --- openair2/RRC/LITE/MESSAGES/asn1_msg.c | 30 ++++++++++++++++----------- openair2/RRC/LITE/MESSAGES/asn1_msg.h | 2 ++ openair2/RRC/LITE/rrc_eNB.c | 1 + 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index 7d2fc3a3d8..b4290e8b9d 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -1388,6 +1388,7 @@ uint8_t do_RRCConnectionSetup( const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, + int CC_id, uint8_t* const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, @@ -1492,7 +1493,10 @@ do_RRCConnectionSetup( physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH)); physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH)); physicalConfigDedicated2->cqi_ReportConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig)); - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); + if (enb_properties.properties[ctxt_pP->module_id]->srs_enable[CC_id]) + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); + else + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = NULL; physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo)); physicalConfigDedicated2->schedulingRequestConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->schedulingRequestConfig)); #ifdef CBA @@ -1578,17 +1582,19 @@ do_RRCConnectionSetup( */ //soundingRS-UL-ConfigDedicated - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth = - SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth = - SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition=0; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.duration=1; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=45; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb=0; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift= - SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0; + if (enb_properties.properties[ctxt_pP->module_id]->srs_enable[CC_id]) { + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup; + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth = + SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0; + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth = + SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0; + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition=0; + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.duration=1; + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=45; + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb=0; + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift= + SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0; + } //AntennaInfoDedicated diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.h b/openair2/RRC/LITE/MESSAGES/asn1_msg.h index 661914ea6e..881a778030 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.h @@ -133,6 +133,7 @@ do_RRCConnectionReconfigurationComplete( PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting (PUCCH format 2/2a/2b) or SRS. @param ctxt_pP Running context @param ue_context_pP UE context +@param CC_id Component Carrier ID @param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU @param transmission_mode Transmission mode for UE (1-9) @param UE_id UE index for this message @@ -144,6 +145,7 @@ uint8_t do_RRCConnectionSetup( const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, + int CC_id, uint8_t* const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 747522e01b..08d50da39c 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -3743,6 +3743,7 @@ rrc_eNB_generate_RRCConnectionSetup( eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size = do_RRCConnectionSetup(ctxt_pP, ue_context_pP, + CC_id, (uint8_t*) eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.Payload, (fp->nb_antennas_tx_eNB==2)?2:1, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), From 497e89d97e88b6ffddc138c024243c26ad9be73e Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 8 Dec 2016 17:48:56 +0100 Subject: [PATCH 51/60] integration fix: bugfix: wrong enum used --- openair1/PHY/INIT/lte_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 3fcc37f6bd..035410eb25 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -483,7 +483,7 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *eNB) } if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) { - if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SchedulingRequestConfig_PR_setup) { + if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { eNB->soundingrs_ul_config_dedicated[UE_id].duration = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration; eNB->soundingrs_ul_config_dedicated[UE_id].cyclicShift = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; @@ -876,7 +876,7 @@ void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) { phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 0; - if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SchedulingRequestConfig_PR_setup) { + if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 1; phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].duration = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration; phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].cyclicShift = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; From 752ceb19221001ec18d22425157beae83a2436ba Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 8 Dec 2016 17:49:56 +0100 Subject: [PATCH 52/60] integration fix: remove compilation warnings --- openair1/PHY/LTE_TRANSPORT/srs_modulation.c | 2 +- openair3/NAS/UE/EMM/SAP/emm_send.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c b/openair1/PHY/LTE_TRANSPORT/srs_modulation.c index 15561e6b28..7e29d998a1 100644 --- a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/srs_modulation.c @@ -133,7 +133,7 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue, uint16_t msrsb=0,Nb=0,nb,b,msrs0=0,k,Msc_RS,Msc_RS_idx,carrier_pos,symbol_offset; uint16_t *Msc_idx_ptr; int32_t k0; - uint32_t subframe_offset; + //uint32_t subframe_offset; uint8_t Bsrs = soundingrs_ul_config_dedicated->srs_Bandwidth; uint8_t Csrs = frame_parms->soundingrs_ul_config_common.srs_BandwidthConfig; uint8_t Ssrs = frame_parms->soundingrs_ul_config_common.srs_SubframeConfig; diff --git a/openair3/NAS/UE/EMM/SAP/emm_send.c b/openair3/NAS/UE/EMM/SAP/emm_send.c index e960b85848..554c556932 100644 --- a/openair3/NAS/UE/EMM/SAP/emm_send.c +++ b/openair3/NAS/UE/EMM/SAP/emm_send.c @@ -861,7 +861,6 @@ int emm_send_security_mode_complete(const emm_as_security_t *msg, emm_msg->presencemask |= SECURITY_MODE_COMPLETE_IMEISV_PRESENT; // 33 85 76 02 05 26 84 01 F1 - emm_msg->imeisv.imeisv; emm_msg->imeisv.imeisv.digit1 = 0x3; emm_msg->imeisv.imeisv.oddeven = 0x0; emm_msg->imeisv.imeisv.typeofidentity = 0x3; From 46b2ee9577073261163349f03057f2587186b955 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 8 Dec 2016 17:51:02 +0100 Subject: [PATCH 53/60] integration fix: attempt to clarify ODD_PARITY This may need to be refined. The variable ODD_PARITY is defined at various places, with different values, causing compilation warnings. It's wrong to define a variable with different values. A new variable is created, specific to IMEI case: IMEI_ODD_PARITY. Maybe ODD_PARITY should also have 0xf as value, and so maybe only one variable is necessary. To be checked at some point... --- openair2/COMMON/commonDef.h | 2 +- openair3/NAS/COMMON/IES/MobileIdentity.h | 4 ++-- openair3/NAS/UE/EMM/SAP/emm_send.c | 2 +- openair3/NAS/UE/EMM/emm_main.c | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openair2/COMMON/commonDef.h b/openair2/COMMON/commonDef.h index ae1bdaf994..cfd5d68e40 100644 --- a/openair2/COMMON/commonDef.h +++ b/openair2/COMMON/commonDef.h @@ -119,7 +119,7 @@ typedef struct { Byte_t digit14:4; Byte_t digit13:4; #define EVEN_PARITY 0 -#define ODD_PARITY 0xf +#define ODD_PARITY 1 Byte_t parity:4; Byte_t digit15:4; } num; diff --git a/openair3/NAS/COMMON/IES/MobileIdentity.h b/openair3/NAS/COMMON/IES/MobileIdentity.h index 9c082c12df..72abcb9ed4 100644 --- a/openair3/NAS/COMMON/IES/MobileIdentity.h +++ b/openair3/NAS/COMMON/IES/MobileIdentity.h @@ -93,7 +93,7 @@ typedef struct imeisv_s{ uint8_t digit15:4; uint8_t digit16:4; #define EVEN_PARITY 0 -#define ODD_PARITY 1 +#define IMEI_ODD_PARITY 0xf uint8_t parity:4; } imeisv_t; @@ -119,7 +119,7 @@ typedef struct imeisv_s { uint8_t svn2:4; uint8_t svn1:4; #define EVEN_PARITY 0 -#define ODD_PARITY 1 +#define IMEI_ODD_PARITY 0xf uint8_t parity:4; } num; #define IMEISV_BCD8_SIZE 9 diff --git a/openair3/NAS/UE/EMM/SAP/emm_send.c b/openair3/NAS/UE/EMM/SAP/emm_send.c index 554c556932..e3fc4fa7f9 100644 --- a/openair3/NAS/UE/EMM/SAP/emm_send.c +++ b/openair3/NAS/UE/EMM/SAP/emm_send.c @@ -879,7 +879,7 @@ int emm_send_security_mode_complete(const emm_as_security_t *msg, emm_msg->imeisv.imeisv.digit14 = 0x3; emm_msg->imeisv.imeisv.digit15 = 0x0; emm_msg->imeisv.imeisv.digit16 = 0x0; - emm_msg->imeisv.imeisv.parity = ODD_PARITY; + emm_msg->imeisv.imeisv.parity = IMEI_ODD_PARITY; size += SECURITY_MODE_COMPLETE_MAXIMUM_LENGTH; } diff --git a/openair3/NAS/UE/EMM/emm_main.c b/openair3/NAS/UE/EMM/emm_main.c index 82946a634e..2eb4d8fa24 100644 --- a/openair3/NAS/UE/EMM/emm_main.c +++ b/openair3/NAS/UE/EMM/emm_main.c @@ -40,6 +40,7 @@ Description Defines the EPS Mobility Management procedure call manager, #include "emm_main.h" #include "nas_log.h" #include "emmData.h" +#include "MobileIdentity.h" #include "memory.h" #include "usim_api.h" @@ -919,7 +920,7 @@ static int _emm_main_get_imei(imei_t *imei, const char *imei_str) int len = strlen(imei_str); if (len % 2) { - imei->u.num.parity = ODD_PARITY; + imei->u.num.parity = IMEI_ODD_PARITY; } else { imei->u.num.parity = EVEN_PARITY; } From 8db3583b09d8be1ef5e95a146fa7f1c3c014821a Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 9 Dec 2016 17:47:29 +0100 Subject: [PATCH 54/60] integration fix: add usim_test to at_nas --- openair3/NAS/UE/UEprocess.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair3/NAS/UE/UEprocess.c b/openair3/NAS/UE/UEprocess.c index 248633c3a1..20af58dac6 100644 --- a/openair3/NAS/UE/UEprocess.c +++ b/openair3/NAS/UE/UEprocess.c @@ -71,6 +71,8 @@ static void _nas_signal_handler(int signal); static void _nas_clean(int usr_fd, int net_fd); +uint8_t usim_test = 0; + /****************************************************************************/ /****************** E X P O R T E D F U N C T I O N S ******************/ /****************************************************************************/ From 0a9d013f59c24f7f56c1629ef02e494f3442fc05 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 9 Dec 2016 17:47:49 +0100 Subject: [PATCH 55/60] integration fix: LOG_I/LOG_D do not exist when compiling at_nas_ue Use LOG_TRACE instead. --- openair3/NAS/COMMON/EMM/MSG/SecurityModeCommand.c | 2 +- openair3/NAS/COMMON/EMM/MSG/SecurityModeComplete.c | 6 +++--- openair3/NAS/COMMON/IES/MobileIdentity.c | 2 +- openair3/NAS/UE/EMM/SAP/emm_recv.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openair3/NAS/COMMON/EMM/MSG/SecurityModeCommand.c b/openair3/NAS/COMMON/EMM/MSG/SecurityModeCommand.c index c89a9f5bb7..a1a34f9495 100644 --- a/openair3/NAS/COMMON/EMM/MSG/SecurityModeCommand.c +++ b/openair3/NAS/COMMON/EMM/MSG/SecurityModeCommand.c @@ -72,7 +72,7 @@ int decode_security_mode_command(security_mode_command_msg *security_mode_comman decoded += decoded_result; /* Set corresponding mask to 1 in presencemask */ security_mode_command->presencemask |= SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT; - LOG_I(NAS," SECURITY MODE COMMAND: IMEISV_REQUEST: %d \n",security_mode_command->imeisvrequest); + LOG_TRACE(INFO," SECURITY MODE COMMAND: IMEISV_REQUEST: %d \n",security_mode_command->imeisvrequest); break; diff --git a/openair3/NAS/COMMON/EMM/MSG/SecurityModeComplete.c b/openair3/NAS/COMMON/EMM/MSG/SecurityModeComplete.c index 80ceeb34d7..3258134feb 100644 --- a/openair3/NAS/COMMON/EMM/MSG/SecurityModeComplete.c +++ b/openair3/NAS/COMMON/EMM/MSG/SecurityModeComplete.c @@ -76,11 +76,11 @@ int encode_security_mode_complete(security_mode_complete_msg *security_mode_comp /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SECURITY_MODE_COMPLETE_MINIMUM_LENGTH, len); - LOG_I(NAS,"SECURITY MODE COMMAND COMPLETE: presencemask: %d \n",security_mode_complete->presencemask); + LOG_TRACE(INFO,"SECURITY MODE COMMAND COMPLETE: presencemask: %d \n",security_mode_complete->presencemask); if ((security_mode_complete->presencemask & SECURITY_MODE_COMPLETE_IMEISV_PRESENT) == SECURITY_MODE_COMPLETE_IMEISV_PRESENT) { - LOG_I(NAS,"SECURITY MODE COMMAND COMPLETE: encode imeisv \n"); + LOG_TRACE(INFO,"SECURITY MODE COMMAND COMPLETE: encode imeisv \n"); if ((encode_result = encode_mobile_identity(&security_mode_complete->imeisv, SECURITY_MODE_COMPLETE_IMEISV_IEI, buffer + encoded, len - @@ -90,7 +90,7 @@ int encode_security_mode_complete(security_mode_complete_msg *security_mode_comp else encoded += encode_result; } - LOG_I(NAS,"SECURITY MODE COMMAND COMPLETE done !!! \n"); + LOG_TRACE(INFO,"SECURITY MODE COMMAND COMPLETE done !!! \n"); return encoded; } diff --git a/openair3/NAS/COMMON/IES/MobileIdentity.c b/openair3/NAS/COMMON/IES/MobileIdentity.c index 59cf4dc44f..4651fa0047 100644 --- a/openair3/NAS/COMMON/IES/MobileIdentity.c +++ b/openair3/NAS/COMMON/IES/MobileIdentity.c @@ -575,7 +575,7 @@ static int encode_imei_mobile_identity(ImeiMobileIdentity_t *imei, uint8_t *buff static int encode_imeisv_mobile_identity(ImeisvMobileIdentity_t *imeisv, uint8_t *buffer) { uint32_t encoded = 0; - LOG_I(NAS,"SECURITY MODE COMMAND COMPLETE: encode_imeisv_mobile_identity \n"); + LOG_TRACE(INFO,"SECURITY MODE COMMAND COMPLETE: encode_imeisv_mobile_identity \n"); *(buffer + encoded) = 0x00 | (imeisv->digit1 << 4) | (imeisv->oddeven << 3) | (imeisv->typeofidentity); diff --git a/openair3/NAS/UE/EMM/SAP/emm_recv.c b/openair3/NAS/UE/EMM/SAP/emm_recv.c index 60b504f1ce..0ad41b09d8 100644 --- a/openair3/NAS/UE/EMM/SAP/emm_recv.c +++ b/openair3/NAS/UE/EMM/SAP/emm_recv.c @@ -140,7 +140,7 @@ int emm_recv_attach_accept(attach_accept_msg *msg, int *emm_cause) // supported cases: // typeoflist = 1 Or // typeoflist = 0 and numberofelements = 1 (ie numberofelements equal to zero see 3gpp 24.301 9.9.3.33.1) - LOG_D(NAS,"attach accept type of list: %d, number of element: %d\n",msg->tailist.typeoflist, msg->tailist.numberofelements); + LOG_TRACE(DEBUG,"attach accept type of list: %d, number of element: %d\n",msg->tailist.typeoflist, msg->tailist.numberofelements); if (!( (msg->tailist.typeoflist == TRACKING_AREA_IDENTITY_LIST_ONE_PLMN_CONSECUTIVE_TACS) || ((msg->tailist.typeoflist == 0) && ( msg->tailist.numberofelements == 0)) ) @@ -472,7 +472,7 @@ int emm_recv_security_mode_command(security_mode_command_msg *msg, * Message processing */ /* Execute the security mode control procedure initiated by the network */ - LOG_I(NAS,"Execute the security mode control procedure initiated by the network: imeisvrequest %d\n",msg->imeisvrequest); + LOG_TRACE(INFO,"Execute the security mode control procedure initiated by the network: imeisvrequest %d\n",msg->imeisvrequest); rc = emm_proc_security_mode_command( msg->naskeysetidentifier.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, msg->naskeysetidentifier.naskeysetidentifier, From a574c3d31bc4c7b13c3831e162b97acf10715242 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 12 Dec 2016 09:22:01 +0100 Subject: [PATCH 56/60] integration fix: wrong license --- openair1/SCHED/srs_pc.c | 48 +++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/openair1/SCHED/srs_pc.c b/openair1/SCHED/srs_pc.c index 461d230975..98049b2ed0 100644 --- a/openair1/SCHED/srs_pc.c +++ b/openair1/SCHED/srs_pc.c @@ -1,31 +1,23 @@ -/******************************************************************************* - OpenAirInterface - Copyright(c) 1999 - 2014 Eurecom - - OpenAirInterface is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - - OpenAirInterface is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OpenAirInterface.The full GNU General Public License is - included in this distribution in the file called "COPYING". If not, - see . - - Contact Information - OpenAirInterface Admin: openair_admin@eurecom.fr - OpenAirInterface Tech : openair_tech@eurecom.fr - OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr - - Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE - - *******************************************************************************/ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ /*! \file srs_pc.c * \brief Implementation of UE SRS Power Control procedures from 36.213 LTE specifications (Section From 5976ea4a95a585b78674ac89b14394cf3e96d6ce Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 12 Dec 2016 09:22:50 +0100 Subject: [PATCH 57/60] hotfix: attempt for a better gitlab CI setup Not sure it's the right thing to do, but this commit should reduce fake builds. --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aa11892fa6..15c44aed22 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,4 +34,5 @@ job1: - sshpass -p "$OAI_PASS" rsync -az -e "ssh -o StrictHostKeyChecking=no " --rsync-path="mkdir -p $NFS_TEST_RESULTS_DIR && rsync" $OPENAIR_DIR/cmake_targets/autotests/log $OAI_USER@localhost:$NFS_TEST_RESULTS_DIR - sshpass -p "$OAI_PASS" rsync -az -e "ssh -o StrictHostKeyChecking=no " --rsync-path="mkdir -p $EXTERNAL_SHARE_DIR && rsync" $OPENAIR_DIR/cmake_targets/autotests/log $OAI_USER@localhost:$EXTERNAL_SHARE_DIR - cat $OPENAIR_DIR/cmake_targets/autotests/log/results_autotests.xml - when: manual + only: + - triggers From e04e8a62cc3e35221d5150c56c5be38d8defe8ab Mon Sep 17 00:00:00 2001 From: hbilel Date: Mon, 12 Dec 2016 11:45:22 +0100 Subject: [PATCH 58/60] remove mac-struct usage from phy --- openair1/PHY/INIT/lte_init.c | 8 ++++++++ openair1/PHY/LTE_TRANSPORT/dci_tools.c | 4 ++-- openair1/PHY/LTE_TRANSPORT/defs.h | 2 ++ openair1/PHY/LTE_TRANSPORT/phich.c | 6 +++--- openair1/SCHED/phy_procedures_lte_ue.c | 4 ++-- openair2/LAYER2/MAC/config.c | 1 + openair2/PHY_INTERFACE/defs.h | 3 +++ 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 035410eb25..c10e4dd3c1 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -746,6 +746,14 @@ void phy_config_dedicated_scell_eNB(uint8_t Mod_id, } #endif +void phy_config_harq_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, + uint16_t max_harq_tx ) +{ + + PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; + phy_vars_ue->ulsch[eNB_id]->Mlimit = max_harq_tx; +} + void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, struct PhysicalConfigDedicated *physicalConfigDedicated ) { diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 92836ebcf9..e73bb94d41 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -6451,7 +6451,7 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, // ue->Mod_id,harq_pid, // proc->frame_rx, // subframe, - // UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx); + // ulsch->Mlimit); //#endif if (ulsch->harq_processes[harq_pid]->round > 0) // NACK detected on phich @@ -6460,7 +6460,7 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; // LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); - if (ulsch->harq_processes[harq_pid]->round >= UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) + if (ulsch->harq_processes[harq_pid]->round >= ulsch->Mlimit) //UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) { ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; ulsch->harq_processes[harq_pid]->round = 0; diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h index f8d36d3bd4..c41df6c931 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/defs.h @@ -346,6 +346,8 @@ typedef struct { uint8_t num_cba_dci[10]; /// allocated CBA RNTI uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; + /// UL max-harq-retransmission + uint8_t Mlimit; } LTE_UE_ULSCH_t; typedef struct { diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 9a32876602..c7cc188893 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -1381,13 +1381,13 @@ void rx_phich(PHY_VARS_UE *ue, HI16, nseq_PHICH, ngroup_PHICH, - UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx); + ulsch->Mlimit); //#endif // ulsch->harq_processes[harq_pid]->Ndi = 0; ulsch->harq_processes[harq_pid]->round++; - if ( ulsch->harq_processes[harq_pid]->round >= (UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx - 1) ) + if ( ulsch->harq_processes[harq_pid]->round >= (ulsch->Mlimit - 1) ) { // this is last push re transmission ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; @@ -1402,7 +1402,7 @@ void rx_phich(PHY_VARS_UE *ue, //ulsch->harq_processes[harq_pid]->round = 0; //LOG_I(PHY,"PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); - //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->Mlimit, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); } else { diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 5dc629b90b..883099be30 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -1235,8 +1235,8 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB // deactivate service request // ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - LOG_D(PHY,"Generating PUSCH (Abssubframe: %d.%d): harq-Id: %d, round: %d, MaxReTrans: %d \n",frame_tx,subframe_tx,harq_pid,ue->ulsch[eNB_id]->harq_processes[harq_pid]->round,UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx); - if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round >= (UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx - 1)) + LOG_D(PHY,"Generating PUSCH (Abssubframe: %d.%d): harq-Id: %d, round: %d, MaxReTrans: %d \n",frame_tx,subframe_tx,harq_pid,ue->ulsch[eNB_id]->harq_processes[harq_pid]->round,ue->ulsch[eNB_id]->Mlimit); + if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round >= (ue->ulsch[eNB_id]->Mlimit - 1)) { LOG_D(PHY,"PUSCH MAX Retransmission acheived ==> send last pusch (%d) \n"); ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 2ec37a423e..e4252ed500 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -221,6 +221,7 @@ rrc_mac_config_req( } else { UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx = (uint16_t) MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; } + mac_xface->phy_config_harq_ue(Mod_idP,0,eNB_index,UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx); if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) { UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = (uint16_t) mac_MainConfig->ul_SCH_Config->retxBSR_Timer; diff --git a/openair2/PHY_INTERFACE/defs.h b/openair2/PHY_INTERFACE/defs.h index 8c711e971d..aeab9dfe66 100644 --- a/openair2/PHY_INTERFACE/defs.h +++ b/openair2/PHY_INTERFACE/defs.h @@ -185,6 +185,9 @@ typedef struct { void (*phy_config_dedicated_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, struct PhysicalConfigDedicated *physicalConfigDedicated); + /// PHY-Config-harq UE + void (*phy_config_harq_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, + uint16_t max_harq_tx); /// Configure Common PHY parameters from SIB1 void (*phy_config_sib1_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, TDD_Config_t *tdd_config, From e0bf855fbf38f1e2373f6b9b36d1c45acbe5f9a8 Mon Sep 17 00:00:00 2001 From: hbilel Date: Mon, 12 Dec 2016 12:12:27 +0100 Subject: [PATCH 59/60] initialize max retans tx Mlimit --- openair1/PHY/INIT/defs.h | 12 ++++++++++++ openair1/PHY/LTE_TRANSPORT/ulsch_coding.c | 2 ++ openair2/LAYER2/MAC/main.c | 1 + 3 files changed, 15 insertions(+) diff --git a/openair1/PHY/INIT/defs.h b/openair1/PHY/INIT/defs.h index 1874c4e8c7..2b65bebc8d 100644 --- a/openair1/PHY/INIT/defs.h +++ b/openair1/PHY/INIT/defs.h @@ -206,7 +206,19 @@ void phy_config_dedicated_ue(module_id_t Mod_id, uint8_t CH_index, struct PhysicalConfigDedicated *physicalConfigDedicated); +/*! +\fn void phy_config_harq_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t CH_index, + uint16_t max_harq_tx) +\brief Configure UE UL max harq Tx. +\details Invoked upon reception of RRCConnectionSetup or RRCConnectionReconfiguration from eNB. +@param Mod_id Instance ID for eNB +@param CC_id Component Carrier index +@param CH_index Index of eNB for this configuration +@param max_harq_tx max harq tx information + */ +void phy_config_harq_ue(module_id_t Mod_id,int CC_id,uint8_t CH_index, + uint16_t max_harq_tx); /** \brief Configure UE MBSFN common parameters. \details Invoked upon reception of SIB13 from eNB. diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c index fe4e05747a..4559aaa326 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c @@ -140,6 +140,8 @@ LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) if (ulsch) { memset(ulsch,0,sizeof(LTE_UE_ULSCH_t)); + ulsch->Mlimit = 4; + for (i=0; i<8; i++) { ulsch->harq_processes[i] = (LTE_UL_UE_HARQ_t *)malloc16(sizeof(LTE_UL_UE_HARQ_t)); diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c index 0fe9d63b6f..203bd3f36f 100644 --- a/openair2/LAYER2/MAC/main.c +++ b/openair2/LAYER2/MAC/main.c @@ -527,6 +527,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer,ui mac_xface->phy_config_dedicated_eNB = phy_config_dedicated_eNB; mac_xface->phy_config_dedicated_ue = phy_config_dedicated_ue; + mac_xface->phy_config_harq_ue = phy_config_harq_ue; mac_xface->get_lte_frame_parms = get_lte_frame_parms; mac_xface->get_mu_mimo_mode = get_mu_mimo_mode; From 17aefade3fece7f4e0fdbbb84c1e8fc8c236ace0 Mon Sep 17 00:00:00 2001 From: hbilel Date: Mon, 12 Dec 2016 12:48:48 +0100 Subject: [PATCH 60/60] remove temporary harq process for ue (ul) --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 6 +++--- openair1/PHY/LTE_TRANSPORT/defs.h | 2 +- openair1/PHY/LTE_TRANSPORT/phich.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index e73bb94d41..a1c118529a 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -6453,11 +6453,11 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, // subframe, // ulsch->Mlimit); //#endif - +/* if (ulsch->harq_processes[harq_pid]->round > 0) // NACK detected on phich { // ulsch->harq_processes[harq_pid]->round++; already done on phich_rx - ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; + // ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; // LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); if (ulsch->harq_processes[harq_pid]->round >= ulsch->Mlimit) //UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) @@ -6479,7 +6479,7 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); } } - +*/ } } diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h index c41df6c931..442fd82167 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/defs.h @@ -283,7 +283,7 @@ typedef struct { /// SRS active flag uint8_t srs_active; /// Pointers to 8 HARQ processes for the ULSCH - LTE_UL_UE_HARQ_t *harq_processes[9]; + LTE_UL_UE_HARQ_t *harq_processes[8]; /// Pointer to CQI data uint8_t o[MAX_CQI_BYTES]; /// Length of CQI data (bits) diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index c7cc188893..989567ca34 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -1441,7 +1441,7 @@ void rx_phich(PHY_VARS_UE *ue, // rely only on DCI0 decoding and check if NDI has toggled // save current harq_processes content in temporary struct // harqId-8 corresponds to the temporary struct. In total we have 8 harq process(0 ..7) + 1 temporary harq process() - ulsch->harq_processes[8] = ulsch->harq_processes[harq_pid]; + //ulsch->harq_processes[8] = ulsch->harq_processes[harq_pid]; ulsch->harq_processes[harq_pid]->subframe_scheduling_flag =0; ulsch->harq_processes[harq_pid]->status = IDLE;