Commit 1a2bc4a6 authored by rmagueta's avatar rmagueta

Merge remote-tracking branch 'origin/NR_SA_F1AP_5GRECORDS' into develop-NR_SA_F1AP_5GRECORDS-lts

# Conflicts:
#	openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c
parents 0870b93c 64e58a43
......@@ -40,6 +40,7 @@
#include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
#include <openair2/UTIL/OPT/opt.h>
//#define DEBUG_ULSCH_CODING
......@@ -256,7 +257,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
Ilbrm = 0;
Tbslbrm = 950984; //max tbs
Coderate = 0.0;
trace_NRpdu(DIRECTION_UPLINK, harq_process->a, harq_process->pusch_pdu.pusch_data.tb_size, 0, WS_C_RNTI, 0, 0, 0,0, 0);
///////////
/////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -2167,22 +2167,19 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
uint16_t buflen) {
NR_MAC_SUBHEADER_FIXED *mac_pdu_ptr = (NR_MAC_SUBHEADER_FIXED *) pdu;
unsigned char last_size = 0, i, mac_header_control_elements[16], *ce_ptr, bsr = 0;
int mac_ce_size;
uint16_t offset = 0;
LOG_D(MAC, "[UE] Generating ULSCH PDU : num_sdus %d\n", num_sdus);
#ifdef DEBUG_HEADER_PARSING
for (i = 0; i < num_sdus; i++)
for (int i = 0; i < num_sdus; i++)
LOG_D(MAC, "[UE] MAC subPDU %d (lcid %d length %d bytes \n", i, sdu_lcids[i], sdu_lengths[i]);
#endif
// Generating UL MAC subPDUs including MAC SDU and subheader
for (i = 0; i < num_sdus; i++) {
for (int i = 0; i < num_sdus; i++) {
LOG_D(MAC, "[UE] Generating UL MAC subPDUs for SDU with lenght %d ( num_sdus %d )\n", sdu_lengths[i], num_sdus);
if (sdu_lcids[i] != UL_SCH_LCID_CCCH){
......@@ -2191,23 +2188,21 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->F = 0;
((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->LCID = sdu_lcids[i];
((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->L = (unsigned char) sdu_lengths[i];
last_size = 2;
mac_pdu_ptr += sizeof(NR_MAC_SUBHEADER_SHORT);
} else {
((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->R = 0;
((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->F = 1;
((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->LCID = sdu_lcids[i];
((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->L1 = ((unsigned short) sdu_lengths[i] >> 8) & 0x7f;
((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->L2 = (unsigned short) sdu_lengths[i] & 0xff;
last_size = 3;
mac_pdu_ptr += sizeof(NR_MAC_SUBHEADER_LONG);
}
} else { // UL CCCH SDU
((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->R = 0;
((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->LCID = sdu_lcids[i];
last_size = 1;
mac_pdu_ptr->R = 0;
mac_pdu_ptr->LCID = sdu_lcids[i];
mac_pdu_ptr ++;
}
mac_pdu_ptr += last_size;
// cycle through SDUs, compute each relevant and place ulsch_buffer in
memcpy((void *) mac_pdu_ptr, (void *) sdus_payload, sdu_lengths[i]);
sdus_payload += sdu_lengths[i];
......@@ -2216,8 +2211,6 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
// Generating UL MAC subPDUs including MAC CEs (MAC CE and subheader)
ce_ptr = &mac_header_control_elements[0];
if (power_headroom) {
// MAC CE fixed subheader
mac_pdu_ptr->R = 0;
......@@ -2225,17 +2218,11 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
mac_pdu_ptr++;
// PHR MAC CE (1 octet)
((NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr)->PH = power_headroom;
((NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr)->R1 = 0;
((NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr)->PCMAX = 0; // todo
((NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr)->R2 = 0;
mac_ce_size = sizeof(NR_SINGLE_ENTRY_PHR_MAC_CE);
// Copying bytes for PHR MAC CEs to the mac pdu pointer
memcpy((void *) mac_pdu_ptr, (void *) ce_ptr, mac_ce_size);
ce_ptr += mac_ce_size;
mac_pdu_ptr += (unsigned char) mac_ce_size;
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_pdu_ptr)->PH = power_headroom;
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_pdu_ptr)->R1 = 0;
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_pdu_ptr)->PCMAX = 0; // todo
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_pdu_ptr)->R2 = 0;
mac_pdu_ptr += sizeof(NR_SINGLE_ENTRY_PHR_MAC_CE);
}
if (crnti) {
......@@ -2245,13 +2232,8 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
mac_pdu_ptr++;
// C-RNTI MAC CE (2 octets)
* (uint16_t *) ce_ptr = crnti;
mac_ce_size = sizeof(uint16_t);
// Copying bytes for CRNTI MAC CE to the mac pdu pointer
memcpy((void *) mac_pdu_ptr, (void *) ce_ptr, mac_ce_size);
ce_ptr += mac_ce_size;
mac_pdu_ptr += (unsigned char) mac_ce_size;
* (uint16_t *) mac_pdu_ptr = crnti;
mac_pdu_ptr += sizeof(uint16_t);
}
if (truncated_bsr) {
......@@ -2261,11 +2243,9 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
mac_pdu_ptr++;
// Short truncated BSR MAC CE (1 octet)
((NR_BSR_SHORT_TRUNCATED *) ce_ptr)-> Buffer_size = truncated_bsr;
((NR_BSR_SHORT_TRUNCATED *) ce_ptr)-> LcgID = 0; // todo
mac_ce_size = sizeof(NR_BSR_SHORT_TRUNCATED);
bsr = 1 ;
((NR_BSR_SHORT_TRUNCATED *) mac_pdu_ptr)-> Buffer_size = truncated_bsr;
((NR_BSR_SHORT_TRUNCATED *) mac_pdu_ptr)-> LcgID = 0; // todo
mac_pdu_ptr+= sizeof(NR_BSR_SHORT_TRUNCATED);
} else if (short_bsr) {
// MAC CE fixed subheader
mac_pdu_ptr->R = 0;
......@@ -2273,11 +2253,9 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
mac_pdu_ptr++;
// Short truncated BSR MAC CE (1 octet)
((NR_BSR_SHORT *) ce_ptr)->Buffer_size = short_bsr;
((NR_BSR_SHORT *) ce_ptr)->LcgID = 0; // todo
mac_ce_size = sizeof(NR_BSR_SHORT);
bsr = 1 ;
((NR_BSR_SHORT *) mac_pdu_ptr)->Buffer_size = short_bsr;
((NR_BSR_SHORT *) mac_pdu_ptr)->LcgID = 0; // todo
mac_pdu_ptr+= sizeof(NR_BSR_SHORT);
} else if (long_bsr) {
// MAC CE variable subheader
// todo ch 6.1.3.1. TS 38.321
......@@ -2293,36 +2271,19 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
// ((NR_BSR_LONG *) ce_ptr)->LCGID0 = 0;
// mac_ce_size = sizeof(NR_BSR_LONG); // size is variable
}
if (bsr){
// Copying bytes for BSR MAC CE to the mac pdu pointer
memcpy((void *) mac_pdu_ptr, (void *) ce_ptr, mac_ce_size);
ce_ptr += mac_ce_size;
mac_pdu_ptr += (unsigned char) mac_ce_size;
}
// compute offset before adding padding (if necessary)
offset = ((unsigned char *) mac_pdu_ptr - pdu);
uint16_t padding_bytes = 0;
// compute offset before adding padding (if necessary)
int padding_bytes = 0;
if(buflen > 0) // If the buflen is provided
padding_bytes = buflen - offset;
padding_bytes = buflen + pdu - (unsigned char *) mac_pdu_ptr;
AssertFatal(padding_bytes>=0,"");
// Compute final offset for padding
if (post_padding > 0 || padding_bytes>0) {
if (post_padding || padding_bytes>0) {
((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->R = 0;
((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->LCID = UL_SCH_LCID_PADDING;
mac_pdu_ptr++;
} else {
// no MAC subPDU with padding
}
// compute final offset
offset = ((unsigned char *) mac_pdu_ptr - pdu);
//printf("Offset %d \n", ((unsigned char *) mac_pdu_ptr - pdu));
return offset;
return (uint8_t *)mac_pdu_ptr-pdu;
}
/////////////////////////////////////
......
......@@ -2013,7 +2013,9 @@ nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
ENB_FLAG_NO,
MBMS_FLAG_NO,
lcid,
buflen_remain,
buflen_remain-MAX_RLC_SDU_SUBHEADER_SIZE,
//Fixme: Laurent I removed MAX_RLC_SDU_SUBHEADER_SIZE because else we get out the buffer silently
// the interface with nr_generate_ulsch_pdu() looks over complex and not CPU optimized
(char *)&ulsch_sdus[sdu_length_total],0,
0);
......@@ -2032,7 +2034,8 @@ nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
}
/* Get updated BO after multiplexing this PDU */
lcid_buffer_occupancy_new = mac_rlc_get_buffer_occupancy_ind(module_idP,mac->crnti,eNB_index,frameP, subframe, ENB_FLAG_NO, lcid);
lcid_buffer_occupancy_new =
mac_rlc_get_buffer_occupancy_ind(module_idP,mac->crnti,eNB_index,frameP, subframe, ENB_FLAG_NO, lcid);
buflen_remain =
buflen - (total_rlc_pdu_header_len + sdu_length_total + MAX_RLC_SDU_SUBHEADER_SIZE);
}
......
......@@ -64,10 +64,11 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
buffer[2];
header_size = 3;
}
// FIXME: DRB creation is with integrity, but we don't receive it
if ( entity->type != NR_PDCP_SRB )
entity->has_integrity=0;
/* SRBs always have MAC-I, even if integrity is not active */
if ( // FIXME: DRB creation is with integrity, but we don't receive it
// entity->has_integrity ||
if ( entity->has_integrity ||
entity->type == NR_PDCP_SRB) {
integrity_size = 4;
} else {
......
......@@ -1529,7 +1529,7 @@ static int tx_list_size(nr_rlc_entity_am_t *entity,
{
int ret = 0;
while (l != NULL) {
while (l != NULL && ret < maxsize) {
ret += compute_pdu_header_size(entity, l) + l->size;
l = l->next;
}
......
......@@ -497,7 +497,7 @@ static int tx_list_size(nr_rlc_entity_um_t *entity,
{
int ret = 0;
while (l != NULL) {
while (l != NULL && ret < maxsize) {
ret += compute_pdu_header_size(entity, l) + l->size;
l = l->next;
}
......
......@@ -323,7 +323,8 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind(
* reports '> 81338368' (table 6.1.3.1-2). Passing 100000000 is thus
* more than enough.
*/
buf_stat = rb->buffer_status(rb, 100000000);
// Fixme : Laurent reduced size for CPU saving
buf_stat = rb->buffer_status(rb, 10000000);
ret = buf_stat.status_size
+ buf_stat.retx_size
+ buf_stat.tx_size;
......
......@@ -1265,7 +1265,7 @@ nr_rrc_ue_process_masterCellGroup(
// NSA procedures
}
if(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config == NULL){
NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config = malloc(sizeof(NR_CellGroupConfig_t));
NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config = calloc(1,sizeof(NR_CellGroupConfig_t));
}
if( cellGroupConfig->rlc_BearerToReleaseList != NULL){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment