Commit da63c3f6 authored by Melissa's avatar Melissa

Merge branch 'episys/mel/debug-thorughput-new-sa-master' into 'episys/master-sa'

Properly sending DL ACK/nACKs

See merge request aburger/openairinterface5g!113
parents 817fc792 ce12e827
......@@ -19,6 +19,8 @@
* contact@openairinterface.org
*/
#define _GNU_SOURCE // For pthread_setname_np
#include <pthread.h>
#include <openair1/PHY/impl_defs_top.h>
#include "executables/nr-uesoftmodem.h"
#include "PHY/phy_extern_nr_ue.h"
......@@ -199,31 +201,16 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot)
nfapi_nr_rach_indication_t *rach_ind = unqueue_matching(&nr_rach_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
nfapi_nr_dl_tti_request_t *dl_tti_request = get_queue(&nr_dl_tti_req_queue);
nfapi_nr_ul_dci_request_t *ul_dci_request = get_queue(&nr_ul_dci_req_queue);
LOG_D(NR_MAC, "Try to get a ul_tti_req for HARQ sfn/slot %d %d from queue with %lu items\n",
NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot),
NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot), nr_ul_tti_req_queue.num_items);
nfapi_nr_ul_tti_request_t *ul_tti_request_harq = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.active_harq_sfn_slot);
if (ul_tti_request_harq && ul_tti_request_harq->n_pdus > 0)
{
check_and_process_dci(NULL, NULL, NULL, ul_tti_request_harq);
}
LOG_D(NR_MAC, "Try to get a ul_tti_req by matching CSI active SFN %d/SLOT %d from queue with %lu items\n",
NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_uci_sfn_slot),
NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_uci_sfn_slot), nr_ul_tti_req_queue.num_items);
nfapi_nr_ul_tti_request_t *ul_tti_request_uci = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.active_uci_sfn_slot);
if (ul_tti_request_uci && ul_tti_request_uci->n_pdus > 0)
{
check_and_process_dci(NULL, NULL, NULL, ul_tti_request_uci);
}
LOG_D(NR_MAC, "Try to get a ul_tti_req by matching CRC active SFN %d/SLOT %d from queue with %lu items\n",
NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.crc_rx_ind_sfn_slot),
NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.crc_rx_ind_sfn_slot), nr_ul_tti_req_queue.num_items);
nfapi_nr_ul_tti_request_t *ul_tti_request_crc = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.crc_rx_ind_sfn_slot);
if (ul_tti_request_crc && ul_tti_request_crc->n_pdus > 0)
{
check_and_process_dci(NULL, NULL, NULL, ul_tti_request_crc);
for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) {
LOG_D(NR_MAC, "Try to get a ul_tti_req by matching CRC active SFN %d/SLOT %d from queue with %lu items\n",
NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot),
NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot), nr_ul_tti_req_queue.num_items);
nfapi_nr_ul_tti_request_t *ul_tti_request_crc = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot);
if (ul_tti_request_crc && ul_tti_request_crc->n_pdus > 0)
{
check_and_process_dci(NULL, NULL, NULL, ul_tti_request_crc);
}
}
if (rach_ind && rach_ind->number_of_pdus > 0)
......@@ -327,6 +314,13 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
int last_sfn_slot = -1;
uint16_t sfn_slot = 0;
module_id_t mod_id = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) {
mac->nr_ue_emul_l1.harq[i].active = false;
mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot = -1;
}
while (!oai_exit)
{
if (sem_wait(&sfn_slot_semaphore) != 0)
......@@ -361,8 +355,6 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n",
frame, slot);
module_id_t mod_id = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
if (get_softmodem_params()->sa && mac->mib == NULL)
{
LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n");
......@@ -417,8 +409,10 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
mac->scc_SIB->tdd_UL_DL_ConfigurationCommon,
ul_info.slot_tx, mac->frame_type))
{
LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", ul_info.slot_tx, __FUNCTION__);
nr_ue_ul_indication(&ul_info);
LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() and nr_ue_pucch_scheduler() from %s\n", ul_info.slot_tx, __FUNCTION__);
nr_ue_scheduler(NULL, &ul_info);
nr_ue_prach_scheduler(mod_id, ul_info.frame_tx, ul_info.slot_tx, ul_info.thread_id);
nr_ue_pucch_scheduler(mod_id, ul_info.frame_tx, ul_info.slot_tx, ul_info.thread_id);
check_nr_prach(mac, &ul_info, &prach_resources);
}
if (!IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) {
......
......@@ -44,13 +44,21 @@ uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end);
uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pullarray32(uint8_t **in, uint32_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pullarray32(uint8_t **values_to_pull,
uint32_t out[],
uint32_t max_num_values_to_pull,
uint32_t num_values_to_pull,
uint8_t *out_end);
uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
uint32_t pusharray32(uint32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
uint32_t pusharray32(const uint32_t *values_to_push,
uint32_t max_num_values_to_push,
uint32_t num_values_to_push,
uint8_t **out,
uint8_t *out_end);
uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
typedef uint8_t (*pack_array_elem_fn)(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end);
......
......@@ -352,25 +352,31 @@ uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **ou
return 0;
}
}
uint32_t pullarray32(uint8_t **in, uint32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) {
if(len == 0)
uint32_t pullarray32(uint8_t **values_to_pull,
uint32_t out[],
uint32_t max_num_values_to_pull,
uint32_t num_values_to_pull,
uint8_t *out_end) {
if (num_values_to_pull == 0)
return 1;
if(len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
if (num_values_to_pull > max_num_values_to_pull) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n",
__FUNCTION__, num_values_to_pull, max_num_values_to_pull);
on_error();
return 0;
}
if((end - (*in)) >= sizeof(uint32_t) * len) {
if ((out_end - (*values_to_pull)) >= sizeof(uint32_t) * num_values_to_pull) {
uint32_t idx;
for(idx = 0; idx < len; ++idx) {
if(!pull32(in, &out[idx], end))
for (idx = 0; idx < num_values_to_pull; ++idx) {
if (!pull32(values_to_pull, &out[idx], out_end))
return 0;
}
return sizeof(uint32_t) * len;
return sizeof(uint32_t) * num_values_to_pull;
} else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
on_error();
......@@ -403,25 +409,30 @@ uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t le
return 0;
}
}
uint32_t pusharray32(uint32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) {
if(len == 0)
uint32_t pusharray32(const uint32_t *values_to_push,
uint32_t max_num_values_to_push,
uint32_t num_values_to_push,
uint8_t **out,
uint8_t *out_end) {
if (num_values_to_push == 0)
return 1;
if(len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
if (num_values_to_push > max_num_values_to_push) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n",
__FUNCTION__, num_values_to_push, max_num_values_to_push);
on_error();
return 0;
}
if((end - (*out)) >= sizeof(uint32_t) * len) {
if ((out_end - (*out)) >= sizeof(uint32_t) * num_values_to_push) {
uint32_t idx;
for(idx = 0; idx < len; ++idx) {
if(!push32(in[idx], out, end))
for (idx = 0; idx < num_values_to_push; ++idx) {
if (!push32(values_to_push[idx], out, out_end))
return 0;
}
return sizeof(uint32_t) * len;
return sizeof(uint32_t) * num_values_to_push;
} else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
on_error();
......
......@@ -1893,15 +1893,23 @@ static uint8_t pack_tx_data_pdu_list_value(void *tlv, uint8_t **ppWritePackedMsg
switch(value->TLVs[i].tag) {
case 0: {
if(!pusharray32(value->TLVs[i].value.direct, 16384, value->TLVs[i].length, ppWritePackedMsg, end))
if (!pusharray32(value->TLVs[i].value.direct, sizeof(value->TLVs[i].value.direct) / sizeof(uint32_t),
value->TLVs[i].length / sizeof(uint32_t), ppWritePackedMsg, end)) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s():%d. value->TLVs[i].length %d \n",
__FUNCTION__, __LINE__, value->TLVs[i].length);
return 0;
}
break;
}
case 1: {
if(!pusharray32(value->TLVs[i].value.ptr, value->TLVs[i].length, value->TLVs[i].length, ppWritePackedMsg, end))
if (!pusharray32(value->TLVs[i].value.ptr, value->TLVs[i].length / sizeof(uint32_t),
value->TLVs[i].length / sizeof(uint32_t), ppWritePackedMsg, end)) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s():%d. value->TLVs[i].length %d \n",
__FUNCTION__, __LINE__, value->TLVs[i].length);
return 0;
}
break;
}
......@@ -3181,32 +3189,36 @@ return 1;
static uint8_t pack_nr_uci_pucch_0_1(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_nr_uci_pucch_pdu_format_0_1_t* value = (nfapi_nr_uci_pucch_pdu_format_0_1_t*)tlv;
if(!(push8(value->pduBitmap, ppWritePackedMsg, end) &&
push32(value->handle, ppWritePackedMsg, end) &&
push16(value->rnti, ppWritePackedMsg, end) &&
push8(value->pucch_format, ppWritePackedMsg, end) &&
push8(value->ul_cqi, ppWritePackedMsg, end) &&
push16(value->timing_advance, ppWritePackedMsg, end) &&
push16(value->rssi, ppWritePackedMsg, end)
))
return 0;
if (!push8(value->pduBitmap, ppWritePackedMsg, end))
return 0;
if (!push32(value->handle, ppWritePackedMsg, end))
return 0;
if (!push16(value->rnti, ppWritePackedMsg, end))
return 0;
if (!push8(value->pucch_format, ppWritePackedMsg, end))
return 0;
if (!push8(value->ul_cqi, ppWritePackedMsg, end))
return 0;
if (!push16(value->timing_advance, ppWritePackedMsg, end))
return 0;
if (!push16(value->rssi, ppWritePackedMsg, end))
return 0;
if (value->pduBitmap & 0x01) { //SR
if (!(push8(value->sr->sr_indication, ppWritePackedMsg, end) &&
push8(value->sr->sr_confidence_level, ppWritePackedMsg, end)
))
return 0;
if (!push8(value->sr->sr_indication, ppWritePackedMsg, end))
return 0;
if (!push8(value->sr->sr_confidence_level, ppWritePackedMsg, end))
return 0;
}
if (((value->pduBitmap >> 1) & 0x01)) { //HARQ
if (!(push8(value->harq->num_harq, ppWritePackedMsg, end) &&
push8(value->harq->harq_confidence_level, ppWritePackedMsg, end)
))
if (!push8(value->harq->num_harq, ppWritePackedMsg, end))
return 0;
if (!push8(value->harq->harq_confidence_level, ppWritePackedMsg, end))
return 0;
for (int i = 0; i < value->harq->num_harq; i++)
{
if (!(push8(value->harq->harq_list[i].harq_value, ppWritePackedMsg, end)
))
return 0;
if (!push8(value->harq->harq_list[i].harq_value, ppWritePackedMsg, end))
return 0;
}
}
......@@ -5533,14 +5545,18 @@ static uint8_t unpack_tx_data_pdu_list_value(uint8_t **ppReadPackedMsg, uint8_t
switch(pNfapiMsg->TLVs[i].tag) {
case 0: {
if(!pullarray32(ppReadPackedMsg, pNfapiMsg->TLVs[i].value.direct, 16384, pNfapiMsg->TLVs[i].length, end))
if (!pullarray32(ppReadPackedMsg, pNfapiMsg->TLVs[i].value.direct,
sizeof(pNfapiMsg->TLVs[i].value.direct) / sizeof(uint32_t),
pNfapiMsg->TLVs[i].length / sizeof(uint32_t), end))
return 0;
break;
}
case 1: {
if(!pullarray32(ppReadPackedMsg, pNfapiMsg->TLVs[i].value.ptr, pNfapiMsg->TLVs[i].length, pNfapiMsg->TLVs[i].length, end))
if (!pullarray32(ppReadPackedMsg,pNfapiMsg->TLVs[i].value.ptr,
pNfapiMsg->TLVs[i].length / sizeof(uint32_t),
pNfapiMsg->TLVs[i].length / sizeof(uint32_t), end))
return 0;
break;
......
This diff is collapsed.
......@@ -39,6 +39,7 @@
#include <stdbool.h>
#include "NR_SubcarrierSpacing.h"
#include "openair1/SCHED_NR_UE/harq_nr.h"
#define NR_SHORT_BSR_TABLE_SIZE 32
#define NR_LONG_BSR_TABLE_SIZE 256
......@@ -264,16 +265,26 @@ typedef struct {
uint8_t nbits;
} dci_field_t;
typedef struct {
/* The active harq sfn/slot field was created to save the
scheduled SFN/Slot transmission for the ACK/NAK. If we
do not save it, then we have to calculate it again as the
NRUE MAC layer already does in get_downlink_ack(). */
int active_dl_harq_sfn;
int active_dl_harq_slot;
int active_ul_harq_sfn_slot;
bool active;
} emul_l1_harq_t;
typedef struct {
bool expected_sib;
bool index_has_sib[16];
bool index_has_sib[NR_MAX_HARQ_PROCESSES];
bool expected_rar;
bool index_has_rar[16];
bool index_has_rar[NR_MAX_HARQ_PROCESSES];
bool expected_dci;
bool index_has_dci[16];
int active_harq_sfn_slot;
bool index_has_dci[NR_MAX_HARQ_PROCESSES];
emul_l1_harq_t harq[NR_MAX_HARQ_PROCESSES];
int active_uci_sfn_slot;
int crc_rx_ind_sfn_slot;
int num_srs;
int num_harqs;
int num_csi_reports;
......
......@@ -432,7 +432,7 @@ typedef struct {
// Defined for abstracted mode
nr_downlink_indication_t dl_info;
NR_UE_HARQ_STATUS_t dl_harq_info[16];
NR_UE_HARQ_STATUS_t dl_harq_info[NR_MAX_HARQ_PROCESSES];
nr_emulated_l1_t nr_ue_emul_l1;
......
......@@ -1334,10 +1334,18 @@ void set_harq_status(NR_UE_MAC_INST_t *mac,
// FIXME k0 != 0 currently not taken into consideration
current_harq->dl_frame = frame;
current_harq->dl_slot = slot;
mac->nr_ue_emul_l1.active_harq_sfn_slot = NFAPI_SFNSLOT2HEX(frame, (slot + data_toul_fb));
if (get_softmodem_params()->emulate_l1) {
int scs = get_softmodem_params()->numerology;
int slots_per_frame = nr_slots_per_frame[scs];
slot += data_toul_fb;
if (slot >= slots_per_frame) {
frame = (frame + 1) % 1024;
slot %= slots_per_frame;
}
}
LOG_D(NR_PHY,"Setting harq_status for harq_id %d, dl %d.%d, sched ul %d.%d\n",
harq_id, frame, slot, frame, (slot + data_toul_fb));
harq_id, current_harq->dl_frame, current_harq->dl_slot, frame, slot);
}
......@@ -1819,7 +1827,8 @@ int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int uci_size) {
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup &&
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList &&
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set_id] != NULL)) {
if (uci_size <= 2) {
// PUCCH with format0 can be up to 3 bits (2 ack/nacks + 1 sr is 3 max bits)
if (uci_size <= 3) {
pucch_resource_set_id = 0;
return (pucch_resource_set_id);
break;
......@@ -2020,11 +2029,17 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac,
sched_frame = current_harq->dl_frame;
if (sched_slot>=slots_per_frame){
sched_slot %= slots_per_frame;
sched_frame++;
sched_frame = (sched_frame + 1) % 1024;
}
AssertFatal(sched_slot < slots_per_frame, "sched_slot was calculated incorrect %d\n", sched_slot);
LOG_D(PHY,"HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d, is_common %d\n",dl_harq_pid, sched_frame,sched_slot,current_harq->dl_slot,current_harq->feedback_to_ul,current_harq->is_common);
/* check if current tx slot should transmit downlink acknowlegment */
if (sched_frame == frame && sched_slot == slot) {
if (get_softmodem_params()->emulate_l1) {
mac->nr_ue_emul_l1.harq[dl_harq_pid].active = true;
mac->nr_ue_emul_l1.harq[dl_harq_pid].active_dl_harq_sfn = frame;
mac->nr_ue_emul_l1.harq[dl_harq_pid].active_dl_harq_slot = slot;
}
if (current_harq->dai > NR_DL_MAX_DAI) {
LOG_E(MAC,"PUCCH Downlink DAI has an invalid value : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
......
......@@ -1309,9 +1309,13 @@ int nr_acknack_scheduling(int mod_id,
/* we need to find a new PUCCH occasion */
/*(Re)Inizialization of timing information*/
/* TODO: This is something of a hack. The last condition in the
if statement below was added. OAI is looking into this and is
expected to provide a solution. Without the hack, the gNB will
incorrectly schedule more than 2 ACK/nACKs in a single SFN/Slot. */
if ((pucch->frame == 0 && pucch->ul_slot == 0) ||
((pucch->frame*n_slots_frame + pucch->ul_slot) <
(frame*n_slots_frame + slot))) {
(frame * n_slots_frame + slot)) && (frame != 1023)) {
AssertFatal(pucch->sr_flag + pucch->dai_c == 0,
"expected no SR/AckNack for UE %d in %4d.%2d, but has %d/%d for %4d.%2d\n",
UE_id, frame, slot, pucch->sr_flag, pucch->dai_c, pucch->frame, pucch->ul_slot);
......
......@@ -261,9 +261,18 @@ int nr_process_mac_pdu(module_id_t module_idP,
case UL_SCH_LCID_L_TRUNCATED_BSR:
//38.321 section 6.1.3.1
//variable length
/* Several checks have been added to this function to
ensure that the casting of the pduP is possible. There seems
to be a partial PDU at the end of this buffer, so here
we gracefully ignore that by returning 0. See:
https://gitlab.eurecom.fr/oai/openairinterface5g/-/issues/534 */
if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
return 0;
mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
mac_subheader_len = 2;
if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
return 0;
mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
mac_subheader_len = 3;
}
......@@ -340,9 +349,13 @@ int nr_process_mac_pdu(module_id_t module_idP,
case UL_SCH_LCID_MULTI_ENTRY_PHR_1_OCT:
//38.321 section 6.1.3.9
// varialbe length
if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
return 0;
mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
mac_subheader_len = 2;
if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
return 0;
mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
mac_subheader_len = 3;
}
......@@ -352,9 +365,13 @@ int nr_process_mac_pdu(module_id_t module_idP,
case UL_SCH_LCID_MULTI_ENTRY_PHR_4_OCT:
//38.321 section 6.1.3.9
// varialbe length
if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
return 0;
mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
mac_subheader_len = 2;
if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
return 0;
mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
mac_subheader_len = 3;
}
......@@ -368,8 +385,12 @@ int nr_process_mac_pdu(module_id_t module_idP,
case UL_SCH_LCID_SRB1:
case UL_SCH_LCID_SRB2:
if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
return 0;
if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
//mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
return 0;
mac_subheader_len = 3;
mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *) pduP)->L1 & 0x7f) << 8)
| ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pduP)->L2 & 0xff);
......@@ -453,8 +474,12 @@ int nr_process_mac_pdu(module_id_t module_idP,
case UL_SCH_LCID_DTCH:
// check if LCID is valid at current time.
if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
return 0;
if (((NR_MAC_SUBHEADER_SHORT *)pduP)->F) {
// mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
return 0;
mac_subheader_len = 3;
mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L1 & 0x7f) << 8)
| ((uint16_t)((NR_MAC_SUBHEADER_LONG *)pduP)->L2 & 0xff);
......
......@@ -51,7 +51,12 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
if (entity->type != NR_PDCP_SRB && !(buffer[0] & 0x80)) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
/* TODO: This is something of a hack. The most significant bit
in buffer[0] should be 1 if the packet is a data packet. We are
processing malformed data packets if the most significant bit
is 0. Rather than exit(1), this hack allows us to continue for now.
We need to investigate why this hack is neccessary. */
buffer[0] |= 128;
}
if (entity->sn_size == 12) {
......
This diff is collapsed.
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