Commit b7857a50 authored by Thomas Laurent's avatar Thomas Laurent
Browse files

try to fix CUDA, and fix infinite loop in nr UE uplink data collect

parent 7e158447
......@@ -255,6 +255,7 @@ macro(add_list_string_option name val helpstr)
endif()
endmacro(add_list_string_option)
# this function should produce the same value as the macro MAKE_VERSION defined in the C code (file types.h)
function(make_version VERSION_VALUE)
math(EXPR RESULT "0")
foreach (ARG ${ARGN})
......@@ -311,13 +312,13 @@ endif()
add_definitions("-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP")
set(commonOpts "-pipe -Wno-packed-bitfield-compat -fPIC -Wall -fno-strict-aliasing -rdynamic")
set(MKVER "'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)'")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=gnu99 -funroll-loops -D${MKVER}")
"${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=gnu99 -funroll-loops")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=c++11 -D${MKVER}")
"${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=c++11")
# cuda compiler bug (limitation) on complex macro definition
if (CUDA_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCUDA_FLAG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_FLAG")
......@@ -336,7 +337,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ggdb3 -Wl,-rpath -Wl,${C
# set a flag for changes in the source code
# these changes are related to hardcoded path to include .h files
set(debugOpt "-ggdb3 -DMALLOC_CHECK_=3 -fno-delete-null-pointer-checks")
set(CMAKE_C_FLAGS_DEBUG "${debugOpt} -Og")
set(CMAKE_C_FLAGS_DEBUG "${debugOpt} -O0")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${debugOpt} -O2")
set(CMAKE_C_FLAGS_RELEASE "-O3")
......@@ -3491,7 +3492,7 @@ endfunction(make_driver name dir src)
# nashmesh module
################
list(APPEND nasmesh_src device.c common.c ioctl.c classifier.c tool.c mesh.c)
set(module_cc_opt "${module_cc_opt} -DNAS_NETLINK -DPDCP_USE_NETLINK -D${MKVER}")
set(module_cc_opt "${module_cc_opt} -DNAS_NETLINK -DPDCP_USE_NETLINK")
# legacy Makefile was using NAS_NETLINK flag, but other drivers the hereafter flag
# so, this cmake use OAI_NW_DRIVER_USE_NETLINK everywhere
if (OAI_NW_DRIVER_USE_NETLINK)
......
......@@ -23,6 +23,6 @@
#define __openair_TYPES_H__
#include <stdint.h>
#define MAKE_VERSION(a,b,c) ((a)*256+(b)*16+c)
#endif /*__openair_TYPES_H__ */
......@@ -1970,18 +1970,14 @@ uint8_t
nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
sub_frame_t subframe, uint8_t eNB_index,
uint8_t *ulsch_buffer, uint16_t buflen, uint8_t *access_mode) {
uint8_t total_rlc_pdu_header_len = 0;
int16_t buflen_remain = 0;
uint8_t lcid = 0;
uint16_t sdu_lengths[MAX_LCID] = { 0 };
uint8_t sdu_lcids[MAX_LCID] = { 0 };
uint16_t payload_offset = 0, num_sdus = 0;
uint8_t ulsch_sdus[MAX_ULSCH_PAYLOAD_BYTES];
uint16_t sdu_length_total = 0;
//unsigned short post_padding = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
rlc_buffer_occupancy_t lcid_buffer_occupancy_new = 0;
LOG_D(NR_MAC,
"[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n",
module_idP, frameP, subframe, buflen);
......@@ -1990,57 +1986,34 @@ nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
// Check for DCCH first
// TO DO: Multiplex in the order defined by the logical channel prioritization
int buflen_remain = buflen;
char * current_ulsch_ptr = (char*)ulsch_sdus;
for (lcid = UL_SCH_LCID_SRB1;
lcid < MAX_LCID; lcid++) {
lcid_buffer_occupancy_new = mac_rlc_get_buffer_occupancy_ind(module_idP, mac->crnti, eNB_index, frameP, subframe, ENB_FLAG_NO, lcid);
if(lcid_buffer_occupancy_new) {
buflen_remain =
buflen - (total_rlc_pdu_header_len + sdu_length_total + MAX_RLC_SDU_SUBHEADER_SIZE);
LOG_D(NR_MAC,
"[UE %d] Frame %d : UL-DXCH -> ULSCH, RLC %d has %d bytes to "
"send (Transport Block size %d SDU Length Total %d , mac header len %d, buflen_remain %d )\n", //BSR byte before Tx=%d
module_idP, frameP, lcid, lcid_buffer_occupancy_new,
buflen, sdu_length_total,
total_rlc_pdu_header_len, buflen_remain); // ,nr_ue_mac_inst->scheduling_info.BSR_bytes[nr_ue_mac_inst->scheduling_info.LCGID[lcid]]
while(buflen_remain > MAX_RLC_SDU_SUBHEADER_SIZE && lcid_buffer_occupancy_new){
sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
while ( (sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
mac->crnti,
eNB_index,
frameP,
ENB_FLAG_NO,
MBMS_FLAG_NO,
lcid,
buflen_remain-MAX_RLC_SDU_SUBHEADER_SIZE,
//Fixme: Laurent I removed MAX_RLC_SDU_SUBHEADER_SIZE because else we get out the buffer silently
buflen_remain-MAX_RLC_SDU_SUBHEADER_SIZE*2,
//Fixme: Laurent I removed MAX_RLC_SDU_SUBHEADER_SIZE*2 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);
current_ulsch_ptr , 0,
0)) > 0 ) {
AssertFatal(buflen_remain >= sdu_lengths[num_sdus],
"LCID=%d RLC has segmented %d bytes but MAC has max=%d\n",
lcid, sdu_lengths[num_sdus], buflen_remain);
AssertFatal(current_ulsch_ptr < (char*)ulsch_sdus+MAX_ULSCH_PAYLOAD_BYTES, "");
if (sdu_lengths[num_sdus]) {
sdu_length_total += sdu_lengths[num_sdus];
current_ulsch_ptr += sdu_lengths[num_sdus];
buflen_remain -= sdu_lengths[num_sdus];
buflen_remain -= MAX_RLC_SDU_SUBHEADER_SIZE;
sdu_lcids[num_sdus] = lcid;
total_rlc_pdu_header_len += MAX_RLC_SDU_SUBHEADER_SIZE; //rlc_pdu_header_len_last;
//Update number of SDU
num_sdus++;
}
/* Get updated BO after multiplexing this PDU */
// we don't recompute it if the waiting queue is much larger than our buffer
// because mac_rlc_get_buffer_occupancy_ind() cpu cost is high when waiting queu is large
if ( lcid_buffer_occupancy_new < buflen_remain+1000)
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);
}
}
}
// Generate ULSCH PDU
......
......@@ -216,8 +216,10 @@ tbs_size_t mac_rlc_data_req(
maxsize = tb_sizeP;
ret = rb->generate_pdu(rb, buffer_pP, maxsize);
} else {
LOG_E(RLC, "%s:%d:%s: fatal: data req for unknown RB, channel_idP: %d\n", __FILE__, __LINE__, __FUNCTION__, channel_idP);
exit(1);
// Laurent: the query loop was checking all possible RB, but by mac_rlc_get_buffer_occupancy_ind
// so it is more straitforward to try to get data
//LOG_E(RLC, "%s:%d:%s: fatal: data req for unknown RB, channel_idP: %d\n", __FILE__, __LINE__, __FUNCTION__, channel_idP);
//exit(1);
ret = 0;
}
......
......@@ -64,10 +64,6 @@
#include "rrc_nas_primitives.h"
#include "COMMON/platform_types.h"
#ifndef MAKE_VERSION
#define MAKE_VERSION(a,b,c) ((a)*256+(b)*16+(c))
#endif
struct rb_entity {
nasRadioBearerId_t rab_id;
nasSapId_t sapi;
......
......@@ -55,10 +55,6 @@
#include "platform_types.h"
#include "sap.h"
#ifndef MAKE_VERSION
#define MAKE_VERSION(a,b,c) ((a)*256+(b)*16+(c))
#endif
typedef struct ue_ip_priv_s {
int irq;
int rx_flags;
......
......@@ -465,7 +465,7 @@ static void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *bu
initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data), size);
}
void generateSecurityModeComplete(as_nas_info_t *initialNasMsg)
static void generateSecurityModeComplete(as_nas_info_t *initialNasMsg)
{
int size = sizeof(mm_msg_header_t);
fgs_nas_message_t nas_msg;
......@@ -532,7 +532,7 @@ void generateSecurityModeComplete(as_nas_info_t *initialNasMsg)
}
}
void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer) {
static void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer) {
//wait send RRCReconfigurationComplete and InitialContextSetupResponse
sleep(1);
int length = 0;
......@@ -625,12 +625,11 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff
}
}
void generatePduSessionEstablishRequest(as_nas_info_t *initialNasMsg){
static void generatePduSessionEstablishRequest(uicc_t * uicc, as_nas_info_t *initialNasMsg){
//wait send RegistrationComplete
usleep(100*150);
int size = 0;
fgs_nas_message_t nas_msg;
memset(&nas_msg, 0, sizeof(fgs_nas_message_t));
fgs_nas_message_t nas_msg={0};
// setup pdu session establishment request
uint16_t req_length = 7;
......@@ -649,8 +648,6 @@ void generatePduSessionEstablishRequest(as_nas_info_t *initialNasMsg){
MM_msg *mm_msg;
nas_stream_cipher_t stream_cipher;
uint8_t mac[4];
uint8_t nssai[]={1,0,0,1}; //Corresponding to SST:1, SD:1
uint8_t dnn[4]={0x4,0x6f,0x61,0x69}; //Corresponding to dnn:"oai"
nas_msg.header.protocol_discriminator = FGS_MOBILITY_MANAGEMENT_MESSAGE;
nas_msg.header.security_header_type = INTEGRITY_PROTECTED_AND_CIPHERED_WITH_NEW_SECU_CTX;
size += 7;
......@@ -680,11 +677,21 @@ void generatePduSessionEstablishRequest(as_nas_info_t *initialNasMsg){
mm_msg->uplink_nas_transport.requesttype = 1;
size += 3;
mm_msg->uplink_nas_transport.snssai.length = 4;
mm_msg->uplink_nas_transport.snssai.value = nssai;
size += (1+1+4);
mm_msg->uplink_nas_transport.dnn.length = 4;
mm_msg->uplink_nas_transport.dnn.value = dnn;
//Fixme: it seems there are a lot of memory errors in this: this value was on the stack,
// but pushed in a itti message to another thread
// this kind of error seems in many places in 5G NAS
mm_msg->uplink_nas_transport.snssai.value=calloc(1,4);
mm_msg->uplink_nas_transport.snssai.value[0] = uicc->nssai_sst;
mm_msg->uplink_nas_transport.snssai.value[1] = (uicc->nssai_sd>>16)&0xFF;
mm_msg->uplink_nas_transport.snssai.value[2] = (uicc->nssai_sd>>8)&0xFF;
mm_msg->uplink_nas_transport.snssai.value[3] = (uicc->nssai_sd)&0xFF;
size += (1+1+4);
int dnnSize=strlen(uicc->dnnStr);
mm_msg->uplink_nas_transport.dnn.value=calloc(1,dnnSize+1);
mm_msg->uplink_nas_transport.dnn.length = dnnSize + 1;
mm_msg->uplink_nas_transport.dnn.value[0] = dnnSize + 1;
memcpy(mm_msg->uplink_nas_transport.dnn.value+1,uicc->dnnStr, dnnSize);
size += (1+1+dnnSize+1);
// encode the message
initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
......@@ -819,7 +826,7 @@ void *nas_nrue_task(void *args_p)
as_nas_info_t pduEstablishMsg;
memset(&pduEstablishMsg, 0, sizeof(as_nas_info_t));
generatePduSessionEstablishRequest(&pduEstablishMsg);
generatePduSessionEstablishRequest(uicc, &pduEstablishMsg);
if(pduEstablishMsg.length > 0){
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ);
......
......@@ -117,9 +117,6 @@ typedef union {
} fgs_nas_message_t;
void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id);
void generateSecurityModeComplete(as_nas_info_t *initialNasMsg);
void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer);
void generatePduSessionEstablishRequest(as_nas_info_t *initialNasMsg);
void *nas_nrue_task(void *args_p);
#endif /* __NR_NAS_MSG_SIM_H__*/
......
......@@ -43,7 +43,7 @@ extern uint16_t NB_UE_INST;
{"amf", "USIM amf\n", 0, strptr:&(uicc->amfStr), defstrval:"8000", TYPE_STRING, 0 },\
{"sqn", "USIM sqn\n", 0, strptr:&(uicc->sqnStr), defstrval:"000000", TYPE_STRING, 0 },\
{"dnn", "UE dnn (apn)\n", 0, strptr:&(uicc->dnnStr), defstrval:"oai", TYPE_STRING, 0 },\
{"nssai_st", "UE nssai\n", 0, iptr:&(uicc->nssai_st), defintval:1, TYPE_INT, 0 }, \
{"nssai_sst", "UE nssai\n", 0, iptr:&(uicc->nssai_sst), defintval:1, TYPE_INT, 0 }, \
{"nssai_sd", "UE nssai\n", 0, iptr:&(uicc->nssai_sd), defintval:1, TYPE_INT, 0 }, \
};
......
......@@ -50,7 +50,7 @@ typedef struct {
char *amfStr;
char *sqnStr;
char *dnnStr;
int nssai_st;
int nssai_sst;
int nssai_sd;
uint8_t key[16];
uint8_t opc[16];
......
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