diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index d46ed07bbb..09859133cc 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -613,8 +613,11 @@ function start_epc { echo "############################################################" echo "echo \"cd /opt/hss_sim0609\"" > $LOC_EPC_VM_CMDS echo "cd /opt/hss_sim0609" >> $LOC_EPC_VM_CMDS - echo "echo \"sudo daemon --unsafe --name=simulated_hss --chdir=/opt/hss_sim0609 ./starthss_real\"" >> $LOC_EPC_VM_CMDS - echo "sudo daemon --unsafe --name=simulated_hss --chdir=/opt/hss_sim0609 ./starthss_real" >> $LOC_EPC_VM_CMDS + echo "sudo rm -f hss.log" >> $LOC_EPC_VM_CMDS + #echo "echo \"sudo daemon --unsafe --name=simulated_hss --chdir=/opt/hss_sim0609 ./starthss_real\"" >> $LOC_EPC_VM_CMDS + #echo "sudo daemon --unsafe --name=simulated_hss --chdir=/opt/hss_sim0609 ./starthss_real" >> $LOC_EPC_VM_CMDS + echo "echo \"screen -dm -S simulated_hss ./starthss_real\"" >> $LOC_EPC_VM_CMDS + echo "sudo su -c \"screen -dm -S simulated_hss ./starthss_real\"" >> $LOC_EPC_VM_CMDS echo "echo \"cd /opt/ltebox/tools/\"" >> $LOC_EPC_VM_CMDS echo "cd /opt/ltebox/tools/" >> $LOC_EPC_VM_CMDS @@ -870,9 +873,9 @@ function start_l2_sim_ue { echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread $LOC_NB_UES --nokrnmod 1 --log_config.global_log_options level,nocolor --noS1\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread 1 --nokrnmod 1 --log_config.global_log_options level,nocolor --noS1\" > ./my-lte-softmodem-run.sh " >> $1 else - echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread $LOC_NB_UES --nokrnmod 1 --log_config.global_log_options level,nocolor\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread 1 --nokrnmod 1 --log_config.global_log_options level,nocolor\" > ./my-lte-softmodem-run.sh " >> $1 fi echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1 echo "cat ./my-lte-softmodem-run.sh" >> $1 @@ -905,8 +908,9 @@ function start_l2_sim_ue { else echo "L2-SIM UE is sync'ed w/ eNB" fi - local max_interfaces_to_check=1 - if [ $LOC_S1_CONFIGURATION -eq 0 ]; then max_interfaces_to_check=$LOC_NB_UES; fi + local max_interfaces_to_check=$LOC_NB_UES + #local max_interfaces_to_check=1 + #if [ $LOC_S1_CONFIGURATION -eq 0 ]; then max_interfaces_to_check=$LOC_NB_UES; fi local j="1" while [ $j -le $max_interfaces_to_check ] do @@ -2214,15 +2218,41 @@ function run_test_on_vm { if [ $S1_NOS1_CFG -eq 1 ] then - get_ue_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR 1 echo "############################################################" echo "${CN_CONFIG} : Pinging the EPC from UE(s)" echo "############################################################" - PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_epc.log - ping_epc_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $REAL_EPC_IP_ADDR $PING_LOG_FILE 1 0 - scp -o StrictHostKeyChecking=no ubuntu@$UE_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC - check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20 + echo " --- Sequentially ---" + local j="1" + while [ $j -le $INT_NB_UES ] + do + PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_epc_seq_from_ue${j}.log + ping_epc_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $REAL_EPC_IP_ADDR $PING_LOG_FILE ${j} 0 + scp -o StrictHostKeyChecking=no ubuntu@$UE_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC + check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20 + j=$[$j+1] + done + if [ $INT_NB_UES -gt 1 ] + then + echo " --- In parallel ---" + j="1" + while [ $j -le $INT_NB_UES ] + do + PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_epc_para_from_ue${j}.log + ping_epc_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $REAL_EPC_IP_ADDR $PING_LOG_FILE ${j} 1 + j=$[$j+1] + done + sleep 25 + j="1" + while [ $j -le $INT_NB_UES ] + do + PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_epc_para_from_ue${j}.log + scp -o StrictHostKeyChecking=no ubuntu@$UE_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC + tail -3 $ARCHIVES_LOC/$PING_LOG_FILE + check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20 + j=$[$j+1] + done + fi else get_enb_noS1_ip_addr $ENB_VM_CMDS $ENB_VM_IP_ADDR @@ -2267,10 +2297,38 @@ function run_test_on_vm { echo "############################################################" echo "${CN_CONFIG} : Pinging the UE(s) from EPC" echo "############################################################" - PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_ue.log - ping_ue_ip_addr $EPC_VM_CMDS $EPC_VM_IP_ADDR $UE_IP_ADDR $PING_LOG_FILE 0 - scp -o StrictHostKeyChecking=no ubuntu@$EPC_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC - check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20 + echo " --- Sequentially ---" + local j="1" + while [ $j -le $INT_NB_UES ] + do + get_ue_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $j + PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_from_epc_seq_ue${j}.log + ping_ue_ip_addr $EPC_VM_CMDS $EPC_VM_IP_ADDR $UE_IP_ADDR $PING_LOG_FILE 0 + scp -o StrictHostKeyChecking=no ubuntu@$EPC_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC + check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20 + j=$[$j+1] + done + if [ $INT_NB_UES -gt 1 ] + then + echo " --- In parallel ---" + j="1" + while [ $j -le $INT_NB_UES ] + do + get_ue_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $j + PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_from_epc_para_ue${j}.log + ping_ue_ip_addr $EPC_VM_CMDS $EPC_VM_IP_ADDR $UE_IP_ADDR $PING_LOG_FILE 1 + j=$[$j+1] + done + sleep 25 + j="1" + while [ $j -le $INT_NB_UES ] + do + PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_from_epc_para_ue${j}.log + scp -o StrictHostKeyChecking=no ubuntu@$EPC_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC + check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20 + j=$[$j+1] + done + fi else echo "############################################################" echo "${CN_CONFIG} : Pinging the UE(s) from eNB" @@ -2310,7 +2368,7 @@ function run_test_on_vm { fi fi - if [ $S1_NOS1_CFG -eq 2 ] + if [ $S1_NOS1_CFG -eq 0 ] then get_enb_noS1_ip_addr $ENB_VM_CMDS $ENB_VM_IP_ADDR echo "############################################################" diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index dfb5578ba6..9b4aba46c3 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -58,7 +58,7 @@ struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)}; int nas_sock_fd[MAX_MOBILES_PER_ENB]; -int nas_sock_mbms_fd[8]; +int nas_sock_mbms_fd; struct msghdr nas_msg_tx; struct msghdr nas_msg_rx; @@ -95,21 +95,20 @@ static int tun_alloc(char *dev) { } -int netlink_init_mbms_tun(char *ifprefix, int num_if) { +int netlink_init_mbms_tun(char *ifprefix) { int ret; char ifname[64]; - int i= num_if-1; - sprintf(ifname, "oaitun_%.3s%d",ifprefix,i+1); - nas_sock_mbms_fd[i] = tun_alloc(ifname); + sprintf(ifname, "oaitun_%.3s1",ifprefix); // added "1": for historical reasons + nas_sock_mbms_fd = tun_alloc(ifname); - if (nas_sock_mbms_fd[i] == -1) { + if (nas_sock_mbms_fd == -1) { printf("[NETLINK] Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno)); exit(1); } - printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_mbms_fd[i]); - ret = fcntl(nas_sock_mbms_fd[i],F_SETFL,O_NONBLOCK); + printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_mbms_fd); + ret = fcntl(nas_sock_mbms_fd,F_SETFL,O_NONBLOCK); if (ret == -1) { printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); @@ -123,7 +122,7 @@ int netlink_init_mbms_tun(char *ifprefix, int num_if) { nas_src_addr.nl_family = AF_NETLINK; nas_src_addr.nl_pid = 1;//getpid(); /* self pid */ nas_src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(nas_sock_mbms_fd[i], (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); + ret = bind(nas_sock_mbms_fd, (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); memset(&nas_dest_addr, 0, sizeof(nas_dest_addr)); nas_dest_addr.nl_family = AF_NETLINK; nas_dest_addr.nl_pid = 0; /* For Linux Kernel */ @@ -165,7 +164,8 @@ int netlink_init_tun(char *ifprefix, int num_if) { exit(1); } - printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_fd[i]); + printf("[NETLINK]Opened socket %s with fd nas_sock_fd[%d]=%d\n", + ifname, i, nas_sock_fd[i]); ret = fcntl(nas_sock_fd[i],F_SETFL,O_NONBLOCK); if (ret == -1) { diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h index 02f7925d93..e6159199d4 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h @@ -63,6 +63,6 @@ void clear_eNB_transport_info(uint8_t); void clear_UE_transport_info(uint8_t); int netlink_init(void); int netlink_init_tun(char *ifsuffix, int num_if); -int netlink_init_mbms_tun(char *ifsuffix, int num_if); +int netlink_init_mbms_tun(char *ifsuffix); #endif /* EMU_PROTO_H_ */ diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index d240e35a87..7c3b536de2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1496,38 +1496,33 @@ schedule_ulsch_rnti(module_id_t module_idP, if (status >= RRC_CONNECTED && UE_sched_ctrl_ptr->cqi_req_timer > 30) { if (UE_sched_ctrl_ptr->cqi_received == 0) { - if (NFAPI_MODE != NFAPI_MONOLITHIC) { - cqi_req = 0; - } else { - cqi_req = 1; - LOG_D(MAC,"Setting CQI_REQ (timer %d)\n",UE_sched_ctrl_ptr->cqi_req_timer); + cqi_req = 1; + LOG_D(MAC, + "Setting CQI_REQ (timer %d)\n", + UE_sched_ctrl_ptr->cqi_req_timer); - /* TDD: to be safe, do not ask CQI in special Subframes:36.213/7.2.3 CQI definition */ - if (cc[CC_id].tdd_Config) { - switch (cc[CC_id].tdd_Config->subframeAssignment) { - case 1: - if(subframeP == 1 || subframeP == 6) { - cqi_req=0; - } + /* TDD: to be safe, do not ask CQI in special + * Subframes:36.213/7.2.3 CQI definition */ + if (cc[CC_id].tdd_Config) { + switch (cc[CC_id].tdd_Config->subframeAssignment) { + case 1: + if (subframeP == 1 || subframeP == 6) + cqi_req = 0; + break; - break; + case 3: + if (subframeP == 1) + cqi_req = 0; + break; - case 3: - if(subframeP == 1) { - cqi_req=0; - } - - break; - - default: - LOG_E(MAC," TDD config not supported\n"); - break; - } + default: + LOG_E(MAC, " TDD config not supported\n"); + break; } + } - if(cqi_req == 1) { - UE_sched_ctrl_ptr->cqi_req_flag |= 1 << sched_subframeP; - } + if (cqi_req == 1) { + UE_sched_ctrl_ptr->cqi_req_flag |= 1 << sched_subframeP; } } else { LOG_D(MAC,"Clearing CQI request timer\n"); diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 8518cba14c..1205851915 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -2158,7 +2158,7 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) { if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { //Substitute with a static value for the MAC layer abstraction (phy_stub mode) - phr_p->PH = 40; + phr_p->PH = 60; } else { phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index); } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 254d741ae8..b0e6143de1 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -2299,14 +2299,14 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { netlink_init_tun("ue",num_if); if (IS_SOFTMODEM_NOS1) nas_config(1, 1, 2, "ue"); - netlink_init_mbms_tun("uem",num_if); + netlink_init_mbms_tun("uem"); nas_config_mbms(1, 2, 2, "uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if(ENB_NAS_USE_TUN) { netlink_init_tun("enb",1); nas_config(1, 1, 1, "enb"); if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){ - netlink_init_mbms_tun("enm",1); + netlink_init_mbms_tun("enm"); nas_config_mbms(1, 2, 1, "enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } @@ -2318,7 +2318,7 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { }else{ if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){ LOG_W(PDCP, "ENB pdcp will use tun interface for MBMS\n"); - netlink_init_mbms_tun("enm",1); + netlink_init_mbms_tun("enm"); nas_config_mbms_s1(1, 2, 1, "enm"); }else LOG_E(PDCP, "ENB pdcp will not use tun interface\n"); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index a441ff220e..d203408e55 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -77,7 +77,7 @@ extern struct iovec nas_iov_rx; extern int nas_sock_fd[MAX_MOBILES_PER_ENB]; -extern int nas_sock_mbms_fd[8]; +extern int nas_sock_mbms_fd; extern int mbms_rab_id; @@ -133,7 +133,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { } else if (UE_NAS_USE_TUN) { //ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); if(rb_id == mbms_rab_id){ - ret = write(nas_sock_mbms_fd[0], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); + ret = write(nas_sock_mbms_fd, &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); LOG_I(PDCP,"[PDCP_FIFOS] ret %d TRIED TO PUSH MBMS DATA TO rb_id %d handle %d sizeToWrite %d\n",ret,rb_id,nas_sock_fd[ctxt_pP->module_id],sizeToWrite); } else @@ -299,7 +299,7 @@ int pdcp_fifo_read_input_mbms_sdus_fromtun (const protocol_ctxt_t *const ctxt_p do { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_MBMS_FIFO_READ, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_MBMS_FIFO_READ_BUFFER, 1 ); - len = read(UE_NAS_USE_TUN?nas_sock_mbms_fd[0]:nas_sock_mbms_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD); + len = read(nas_sock_mbms_fd, &nl_rx_buf, NL_MAX_PAYLOAD); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_MBMS_FIFO_READ_BUFFER, 0 ); if (len<=0) continue; diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 14974c2e15..bf2bbf7429 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -1,14 +1,29 @@ +/* + * 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.1 (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 + */ -//#include "openair1/PHY/defs.h" -//#include "openair2/PHY_INTERFACE/IF_Module.h" -//#include "openair1/PHY/extern.h" #include "openair2/LAYER2/MAC/mac_extern.h" #include "openair2/LAYER2/MAC/mac.h" #include "openair2/LAYER2/MAC/mac_proto.h" -//#include "openair2/LAYER2/MAC/vars.h" #include "openair1/SCHED_UE/sched_UE.h" #include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h" -//#include "common/ran_context.h" #include "openair2/PHY_INTERFACE/phy_stub_UE.h" #include "openair2/ENB_APP/L1_paramdef.h" #include "openair2/ENB_APP/enb_paramdef.h" @@ -16,14 +31,12 @@ #include "common/config/config_load_configmodule.h" #include "common/config/config_userapi.h" -//#define DEADLINE_SCHEDULER 1 - - -extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind); -extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); extern int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); -void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port); - +void configure_nfapi_pnf(char *vnf_ip_addr, + int vnf_p5_port, + char *pnf_ip_addr, + int pnf_p7_port, + int vnf_p7_port); UL_IND_t *UL_INFO = NULL; nfapi_tx_request_pdu_t* tx_request_pdu_list = NULL; @@ -31,8 +44,6 @@ nfapi_dl_config_request_t* dl_config_req = NULL; nfapi_ul_config_request_t* ul_config_req = NULL; nfapi_hi_dci0_request_t* hi_dci0_req = NULL; -//extern uint8_t nfapi_pnf; -//UL_IND_t *UL_INFO; extern nfapi_tx_request_pdu_t* tx_request_pdu[1023][10][10]; //extern int timer_subframe; //extern int timer_frame; @@ -42,1010 +53,1057 @@ extern uint16_t sf_ahead; void Msg1_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id); void Msg3_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id); +void fill_rx_indication_UE_MAC(module_id_t Mod_id, + int frame, + int subframe, + UL_IND_t *UL_INFO, + uint8_t *ulsch_buffer, + uint16_t buflen, + uint16_t rnti, + int index) { + nfapi_rx_indication_pdu_t *pdu; + int timing_advance_update; + pthread_mutex_lock(&fill_ul_mutex.rx_mutex); -void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t* UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, int index) -{ - nfapi_rx_indication_pdu_t *pdu; + UL_INFO->rx_ind.sfn_sf = frame << 4 | subframe; + UL_INFO->rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; + UL_INFO->rx_ind.vendor_extension = ul_config_req->vendor_extension; - int timing_advance_update; + pdu = &UL_INFO->rx_ind.rx_indication_body + .rx_pdu_list[UL_INFO->rx_ind.rx_indication_body.number_of_pdus]; + // pdu = &UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[index]; + // pdu->rx_ue_information.handle = eNB->ulsch[UE_id]->handle; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.rnti = rnti; + pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + pdu->rx_indication_rel8.length = buflen; + pdu->rx_indication_rel8.offset = 1; + pdu->rx_indication_rel9.tl.tag = NFAPI_RX_INDICATION_REL9_TAG; + pdu->rx_indication_rel9.timing_advance_r9 = 0; - // pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); - // change for mutiple UE's simulation. - pthread_mutex_lock(&fill_ul_mutex.rx_mutex); + // ulsch_buffer is necessary to keep its value. + pdu->data = malloc(buflen); + memcpy(pdu->data, ulsch_buffer, buflen); + // estimate timing advance for MAC + timing_advance_update = 0; // Don't know what to put here + pdu->rx_indication_rel8.timing_advance = timing_advance_update; + int SNRtimes10 = 640; - UL_INFO->rx_ind.sfn_sf = frame<<4| subframe; - UL_INFO->rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; - UL_INFO->rx_ind.vendor_extension = ul_config_req->vendor_extension; - - - pdu = &UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[UL_INFO->rx_ind.rx_indication_body.number_of_pdus]; - //pdu = &UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[index]; - - // pdu->rx_ue_information.handle = eNB->ulsch[UE_id]->handle; - pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; - pdu->rx_ue_information.rnti = rnti; - pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; - //pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3; - pdu->rx_indication_rel8.length = buflen; - pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation - - // ulsch_buffer is necessary to keep its value. - //pdu->data = ulsch_buffer; - pdu->data = malloc(buflen); - memcpy(pdu->data,ulsch_buffer,buflen); - // estimate timing advance for MAC - //sync_pos = lte_est_timing_advance_pusch(eNB,UE_id); - timing_advance_update = 0; // Don't know what to put here - pdu->rx_indication_rel8.timing_advance = timing_advance_update; - - int SNRtimes10 = 640; - - if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0; - else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255; - else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5; - - - UL_INFO->rx_ind.rx_indication_body.number_of_pdus++; - UL_INFO->rx_ind.sfn_sf = frame<<4 | subframe; - // pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); - // change for mutiple UE's simulation. - pthread_mutex_unlock(&fill_ul_mutex.rx_mutex); - + if (SNRtimes10 < -640) + pdu->rx_indication_rel8.ul_cqi = 0; + else if (SNRtimes10 > 635) + pdu->rx_indication_rel8.ul_cqi = 255; + else + pdu->rx_indication_rel8.ul_cqi = (640 + SNRtimes10) / 5; + UL_INFO->rx_ind.rx_indication_body.number_of_pdus++; + UL_INFO->rx_ind.sfn_sf = frame << 4 | subframe; + pthread_mutex_unlock(&fill_ul_mutex.rx_mutex); } -void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti) { - - - // change for mutiple UE's simulation. - //pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); +void fill_sr_indication_UE_MAC(int Mod_id, + int frame, + int subframe, + UL_IND_t *UL_INFO, + uint16_t rnti) { pthread_mutex_lock(&fill_ul_mutex.sr_mutex); - nfapi_sr_indication_t *sr_ind = &UL_INFO->sr_ind; - nfapi_sr_indication_body_t *sr_ind_body = &sr_ind->sr_indication_body; - nfapi_sr_indication_pdu_t *pdu = &sr_ind_body->sr_pdu_list[sr_ind_body->number_of_srs]; - UL_INFO->sr_ind.vendor_extension = ul_config_req->vendor_extension; + nfapi_sr_indication_t *sr_ind = &UL_INFO->sr_ind; + nfapi_sr_indication_body_t *sr_ind_body = &sr_ind->sr_indication_body; + nfapi_sr_indication_pdu_t *pdu = &sr_ind_body->sr_pdu_list[sr_ind_body->number_of_srs]; + UL_INFO->sr_ind.vendor_extension = ul_config_req->vendor_extension; - //nfapi_sr_indication_pdu_t *pdu = &UL_INFO->sr_ind.sr_indication_body.sr_pdu_list[UL_INFO->rx_ind.rx_indication_body.number_of_pdus]; - - sr_ind->sfn_sf = frame<<4|subframe; + sr_ind->sfn_sf = frame << 4 | subframe; sr_ind->header.message_id = NFAPI_RX_SR_INDICATION; sr_ind_body->tl.tag = NFAPI_SR_INDICATION_BODY_TAG; - pdu->instance_length = 0; // don't know what to do with this + pdu->instance_length = 0; // don't know what to do with this // pdu->rx_ue_information.handle = handle; - pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; - pdu->rx_ue_information.rnti = rnti; //UE_mac_inst[Mod_id].crnti - - - // dependency from PHY not sure how to substitute this. Should we hardcode it? - //int SNRtimes10 = dB_fixed_times10(stat) - 200;//(10*eNB->measurements.n0_power_dB[0]); - int SNRtimes10 = 640; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.rnti = rnti; // UE_mac_inst[Mod_id].crnti pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; - - - if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0; - else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi=255; - else pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5; pdu->ul_cqi_information.channel = 0; - //UL_INFO->rx_ind.rx_indication_body.number_of_pdus++; + int SNRtimes10 = 640; + if (SNRtimes10 < -640) + pdu->ul_cqi_information.ul_cqi = 0; + else if (SNRtimes10 > 635) + pdu->ul_cqi_information.ul_cqi = 255; + else + pdu->ul_cqi_information.ul_cqi = (640 + SNRtimes10) / 5; + + // UL_INFO->rx_ind.rx_indication_body.number_of_pdus++; sr_ind_body->number_of_srs++; - // change for mutiple UE's simulation. - // pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); pthread_mutex_unlock(&fill_ul_mutex.sr_mutex); } - -void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti) { - - // change for mutiple UE's simulation. - //pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); +void fill_crc_indication_UE_MAC(int Mod_id, + int frame, + int subframe, + UL_IND_t *UL_INFO, + uint8_t crc_flag, + int index, + uint16_t rnti) { pthread_mutex_lock(&fill_ul_mutex.crc_mutex); - // REMEMBER HAVE EXCHANGED THE FOLLOWING TWO LINES HERE! - nfapi_crc_indication_pdu_t *pdu = &UL_INFO->crc_ind.crc_indication_body.crc_pdu_list[UL_INFO->crc_ind.crc_indication_body.number_of_crcs]; + nfapi_crc_indication_pdu_t *pdu = + &UL_INFO->crc_ind.crc_indication_body + .crc_pdu_list[UL_INFO->crc_ind.crc_indication_body.number_of_crcs]; - UL_INFO->crc_ind.sfn_sf = frame<<4| subframe; - UL_INFO->crc_ind.vendor_extension = ul_config_req->vendor_extension; - UL_INFO->crc_ind.header.message_id = NFAPI_CRC_INDICATION; + UL_INFO->crc_ind.sfn_sf = frame << 4 | subframe; + UL_INFO->crc_ind.vendor_extension = ul_config_req->vendor_extension; + UL_INFO->crc_ind.header.message_id = NFAPI_CRC_INDICATION; UL_INFO->crc_ind.crc_indication_body.tl.tag = NFAPI_CRC_INDICATION_BODY_TAG; - pdu->instance_length = 0; // don't know what to do with this - // pdu->rx_ue_information.handle = handle; - pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->instance_length = 0; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; - //pdu->rx_ue_information.rnti = UE_mac_inst[Mod_id].crnti; - pdu->rx_ue_information.rnti = rnti; - pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; - pdu->crc_indication_rel8.crc_flag = crc_flag; + pdu->rx_ue_information.rnti = rnti; + pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; + pdu->crc_indication_rel8.crc_flag = crc_flag; UL_INFO->crc_ind.crc_indication_body.number_of_crcs++; - LOG_D(PHY, "%s() rnti:%04x pdus:%d\n", __FUNCTION__, pdu->rx_ue_information.rnti, UL_INFO->crc_ind.crc_indication_body.number_of_crcs); + LOG_D(PHY, + "%s() rnti:%04x pdus:%d\n", + __FUNCTION__, + pdu->rx_ue_information.rnti, + UL_INFO->crc_ind.crc_indication_body.number_of_crcs); - // change for mutiple UE's simulation. - // pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); pthread_mutex_unlock(&fill_ul_mutex.crc_mutex); } -void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI) { +void fill_rach_indication_UE_MAC(int Mod_id, + int frame, + int subframe, + UL_IND_t *UL_INFO, + uint8_t ra_PreambleIndex, + uint16_t ra_RNTI) { + LOG_D(MAC, "fill_rach_indication_UE_MAC 1 \n"); - LOG_D(MAC, "fill_rach_indication_UE_MAC 1 \n"); + pthread_mutex_lock(&fill_ul_mutex.rach_mutex); - // change for mutiple UE's simulation. - // pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); - pthread_mutex_lock(&fill_ul_mutex.rach_mutex); + UL_INFO->rach_ind.rach_indication_body.number_of_preambles = 1; - // memory allocation and free memory of UL_INFO are done in UE_phy_stub_single_thread_rxn_txnp4. - // UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t)); + UL_INFO->rach_ind.header.message_id = NFAPI_RACH_INDICATION; + UL_INFO->rach_ind.sfn_sf = frame << 4 | subframe; + UL_INFO->rach_ind.vendor_extension = NULL; - UL_INFO->rach_ind.rach_indication_body.number_of_preambles = 1; + UL_INFO->rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; - //eNB->UL_INFO.rach_ind.preamble_list = &eNB->preamble_list[0]; - UL_INFO->rach_ind.header.message_id = NFAPI_RACH_INDICATION; - UL_INFO->rach_ind.sfn_sf = frame<<4 | subframe; - UL_INFO->rach_ind.vendor_extension = NULL; + const int np = UL_INFO->rach_ind.rach_indication_body.number_of_preambles; + UL_INFO->rach_ind.rach_indication_body.preamble_list = + calloc(np, sizeof(nfapi_preamble_pdu_t)); + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.tl.tag = + NFAPI_PREAMBLE_REL8_TAG; + UL_INFO->rach_ind.rach_indication_body.preamble_list[0] + .preamble_rel8.timing_advance = 0; // Not sure about that - UL_INFO->rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; + // The two following should get extracted from the call to + // get_prach_resources(). + UL_INFO->rach_ind.rach_indication_body.preamble_list[0] + .preamble_rel8.preamble = ra_PreambleIndex; + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti = + ra_RNTI; + // UL_INFO->rach_ind.rach_indication_body.number_of_preambles++; + UL_INFO->rach_ind.rach_indication_body.preamble_list[0] + .preamble_rel13.rach_resource_type = 0; + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].instance_length = 0; - UL_INFO->rach_ind.rach_indication_body.preamble_list = (nfapi_preamble_pdu_t*)malloc(UL_INFO->rach_ind.rach_indication_body.number_of_preambles*sizeof(nfapi_preamble_pdu_t)); - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance = 0; // Not sure about that + LOG_I(PHY, + "UE Filling NFAPI indication for RACH : TA %d, Preamble %d, rnti %x, " + "rach_resource_type %d\n", + UL_INFO->rach_ind.rach_indication_body.preamble_list[0] + .preamble_rel8.timing_advance, + UL_INFO->rach_ind.rach_indication_body.preamble_list[0] + .preamble_rel8.preamble, + UL_INFO->rach_ind.rach_indication_body.preamble_list[0] + .preamble_rel8.rnti, + UL_INFO->rach_ind.rach_indication_body.preamble_list[0] + .preamble_rel13.rach_resource_type); - //The two following should get extracted from the call to get_prach_resources(). - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble = ra_PreambleIndex; - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti = ra_RNTI; - //UL_INFO->rach_ind.rach_indication_body.number_of_preambles++; - - - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel13.rach_resource_type = 0; - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].instance_length = 0; - - - LOG_E(PHY,"\n\n\n\nDJP - this needs to be sent to VNF **********************************************\n\n\n\n"); - LOG_E(PHY,"UE Filling NFAPI indication for RACH : TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance, - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble, - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti, - UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel13.rach_resource_type); - - // This function is currently defined only in the nfapi-RU-RAU-split so we should call it when we merge - // with that branch. - oai_nfapi_rach_ind(&UL_INFO->rach_ind); - free(UL_INFO->rach_ind.rach_indication_body.preamble_list); - - // memory allocation and free memory of UL_INFO are done in UE_phy_stub_single_thread_rxn_txnp4. - //free(UL_INFO); - - //} - // change for mutiple UE's simulation. - // pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); - pthread_mutex_unlock(&fill_ul_mutex.rach_mutex); + // This function is currently defined only in the nfapi-RU-RAU-split so we + // should call it when we merge with that branch. + oai_nfapi_rach_ind(&UL_INFO->rach_ind); + free(UL_INFO->rach_ind.rach_indication_body.preamble_list); + pthread_mutex_unlock(&fill_ul_mutex.rach_mutex); } -void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint16_t frame,uint8_t subframe, UL_IND_t *UL_INFO, uint16_t rnti) { +void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, + uint16_t frame, + uint8_t subframe, + UL_IND_t *UL_INFO, + uint16_t rnti) { + pthread_mutex_lock(&fill_ul_mutex.cqi_mutex); + nfapi_cqi_indication_pdu_t *pdu = + &UL_INFO->cqi_ind.cqi_indication_body + .cqi_pdu_list[UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis]; + nfapi_cqi_indication_raw_pdu_t *raw_pdu = + &UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list + [UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis]; - // change for mutiple UE's simulation. - //pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); - pthread_mutex_lock(&fill_ul_mutex.cqi_mutex); - nfapi_cqi_indication_pdu_t *pdu = &UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list[UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis]; - nfapi_cqi_indication_raw_pdu_t *raw_pdu = &UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list[UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis]; + UL_INFO->cqi_ind.sfn_sf = frame << 4 | subframe; + // because of nfapi_vnf.c:733, set message id to 0, not + // NFAPI_RX_CQI_INDICATION; + UL_INFO->cqi_ind.header.message_id = 0; + UL_INFO->cqi_ind.cqi_indication_body.tl.tag = NFAPI_CQI_INDICATION_BODY_TAG; - pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; - pdu->rx_ue_information.rnti = rnti; - // Since we assume that CRC flag is always 0 (ACK) I guess that data_offset should always be 0. - pdu->cqi_indication_rel9.data_offset = 0; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.rnti = rnti; + // Since we assume that CRC flag is always 0 (ACK) I guess that data_offset + // should always be 0. + pdu->cqi_indication_rel8.data_offset = 0; - // by default set O to rank 1 value - //pdu->cqi_indication_rel9.length = (ulsch_harq->Or1>>3) + ((ulsch_harq->Or1&7) > 0 ? 1 : 0); - // Not useful field for our case - pdu->cqi_indication_rel9.tl.tag = NFAPI_CQI_INDICATION_REL9_TAG; - pdu->cqi_indication_rel9.length = 0; - pdu->cqi_indication_rel9.ri[0] = 0; + pdu->cqi_indication_rel8.tl.tag = NFAPI_CQI_INDICATION_REL8_TAG; + pdu->cqi_indication_rel8.length = 1; + pdu->cqi_indication_rel8.ri = 0; - - pdu->cqi_indication_rel9.timing_advance = 0; - pdu->cqi_indication_rel9.number_of_cc_reported = 1; + pdu->cqi_indication_rel8.timing_advance = 0; + // pdu->cqi_indication_rel8.number_of_cc_reported = 1; + pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; pdu->ul_cqi_information.channel = 1; // PUSCH - // Not sure how to substitute this. This should be the actual CQI value? So can - // we hardcode it to a specific value? - //memcpy((void*)raw_pdu->pdu,ulsch_harq->o,pdu->cqi_indication_rel9.length); - raw_pdu->pdu[0] = 7; - - + // eNB_scheduler_primitives.c:4839: the upper four bits seem to be the CQI + const int cqi = 15; + raw_pdu->pdu[0] = cqi << 4; UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis++; - // change for mutiple UE's simulation. - //pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); pthread_mutex_unlock(&fill_ul_mutex.cqi_mutex); } -void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti) -{ - - // change for mutiple UE's simulation. - //pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); +void fill_ulsch_harq_indication_UE_MAC( + int Mod_id, + int frame, + int subframe, + UL_IND_t *UL_INFO, + nfapi_ul_config_ulsch_harq_information *harq_information, + uint16_t rnti) { pthread_mutex_lock(&fill_ul_mutex.harq_mutex); - nfapi_harq_indication_pdu_t *pdu = &UL_INFO->harq_ind.harq_indication_body.harq_pdu_list[UL_INFO->harq_ind.harq_indication_body.number_of_harqs]; - int i; + nfapi_harq_indication_pdu_t *pdu = + &UL_INFO->harq_ind.harq_indication_body.harq_pdu_list + [UL_INFO->harq_ind.harq_indication_body.number_of_harqs]; UL_INFO->harq_ind.header.message_id = NFAPI_HARQ_INDICATION; - UL_INFO->harq_ind.sfn_sf = frame<<4|subframe; - UL_INFO->harq_ind.vendor_extension = ul_config_req->vendor_extension; + UL_INFO->harq_ind.sfn_sf = frame << 4 | subframe; + UL_INFO->harq_ind.vendor_extension = ul_config_req->vendor_extension; - UL_INFO->harq_ind.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; + UL_INFO->harq_ind.harq_indication_body.tl.tag = + NFAPI_HARQ_INDICATION_BODY_TAG; - pdu->instance_length = 0; // don't know what to do with this + pdu->instance_length = 0; // don't know what to do with this // pdu->rx_ue_information.handle = handle; - pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; - pdu->rx_ue_information.rnti = rnti; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.rnti = rnti; // For now we consider only FDD - //if (eNB->frame_parms.frame_type == FDD) { - pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; - pdu->harq_indication_fdd_rel13.mode = 0; - pdu->harq_indication_fdd_rel13.number_of_ack_nack = harq_information->harq_information_rel10.harq_size; + // if (eNB->frame_parms.frame_type == FDD) { + pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; + pdu->harq_indication_fdd_rel13.mode = 0; + pdu->harq_indication_fdd_rel13.number_of_ack_nack = + harq_information->harq_information_rel10.harq_size; - // Could this be wrong? Is the number_of_ack_nack field equivalent to O_ACK? - //pdu->harq_indication_fdd_rel13.number_of_ack_nack = ulsch_harq->O_ACK; + // Could this be wrong? Is the number_of_ack_nack field equivalent to O_ACK? + // pdu->harq_indication_fdd_rel13.number_of_ack_nack = ulsch_harq->O_ACK; - for (i=0;iharq_information_rel10.harq_size;i++) { - - pdu->harq_indication_fdd_rel13.harq_tb_n[i] = 1; // Assuming always an ACK (No NACK or DTX) - - } + for (int i = 0; i < harq_information->harq_information_rel10.harq_size; i++) { + pdu->harq_indication_fdd_rel13.harq_tb_n[i] = 1; // Assume always ACK (No NACK or DTX) + } UL_INFO->harq_ind.harq_indication_body.number_of_harqs++; - // change for mutiple UE's simulation. - //pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); - pthread_mutex_unlock(&fill_ul_mutex.harq_mutex);} - + pthread_mutex_unlock(&fill_ul_mutex.harq_mutex); +} void fill_uci_harq_indication_UE_MAC(int Mod_id, int frame, int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_harq_information *harq_information, - uint16_t rnti - /*uint8_t tdd_mapping_mode, - uint16_t tdd_multiplexing_mask*/) { - - - // change for mutiple UE's simulation. - //pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + uint16_t rnti) { pthread_mutex_lock(&fill_ul_mutex.harq_mutex); - nfapi_harq_indication_t *ind = &UL_INFO->harq_ind; + nfapi_harq_indication_t *ind = &UL_INFO->harq_ind; nfapi_harq_indication_body_t *body = &ind->harq_indication_body; - nfapi_harq_indication_pdu_t *pdu = &body->harq_pdu_list[UL_INFO->harq_ind.harq_indication_body.number_of_harqs]; + nfapi_harq_indication_pdu_t *pdu = + &body->harq_pdu_list[UL_INFO->harq_ind.harq_indication_body + .number_of_harqs]; - UL_INFO->harq_ind.vendor_extension = ul_config_req->vendor_extension; + UL_INFO->harq_ind.vendor_extension = ul_config_req->vendor_extension; - ind->sfn_sf = frame<<4|subframe; + ind->sfn_sf = frame << 4 | subframe; ind->header.message_id = NFAPI_HARQ_INDICATION; body->tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; - pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; - pdu->instance_length = 0; // don't know what to do with this - // pdu->rx_ue_information.handle = handle; - pdu->rx_ue_information.rnti = rnti; + pdu->instance_length = 0; // don't know what to do with this + pdu->rx_ue_information.rnti = rnti; pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; int SNRtimes10 = 640; - - if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0; - else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi=255; - else pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5; + if (SNRtimes10 < -640) + pdu->ul_cqi_information.ul_cqi = 0; + else if (SNRtimes10 > 635) + pdu->ul_cqi_information.ul_cqi = 255; + else + pdu->ul_cqi_information.ul_cqi = (640 + SNRtimes10) / 5; pdu->ul_cqi_information.channel = 0; - if(harq_information->harq_information_rel9_fdd.tl.tag == NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG){ - if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) && - (harq_information->harq_information_rel9_fdd.harq_size == 1)) { - - pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; + if (harq_information->harq_information_rel9_fdd.tl.tag + == NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG) { + if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) + && (harq_information->harq_information_rel9_fdd.harq_size == 1)) { + pdu->harq_indication_fdd_rel13.tl.tag = + NFAPI_HARQ_INDICATION_FDD_REL13_TAG; pdu->harq_indication_fdd_rel13.mode = 0; pdu->harq_indication_fdd_rel13.number_of_ack_nack = 1; - //AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); - pdu->harq_indication_fdd_rel13.harq_tb_n[0] = 1; // Assuming always an ACK (No NACK or DTX) + // AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, + // "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); + pdu->harq_indication_fdd_rel13.harq_tb_n[0] = + 1; // Assuming always an ACK (No NACK or DTX) - - } - else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) && - (harq_information->harq_information_rel9_fdd.harq_size == 2)) { - pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; + } else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) + && (harq_information->harq_information_rel9_fdd.harq_size + == 2)) { + pdu->harq_indication_fdd_rel13.tl.tag = + NFAPI_HARQ_INDICATION_FDD_REL13_TAG; pdu->harq_indication_fdd_rel13.mode = 0; pdu->harq_indication_fdd_rel13.number_of_ack_nack = 2; - pdu->harq_indication_fdd_rel13.harq_tb_n[0] = 1; // Assuming always an ACK (No NACK or DTX) - pdu->harq_indication_fdd_rel13.harq_tb_n[1] = 1; // Assuming always an ACK (No NACK or DTX) - + pdu->harq_indication_fdd_rel13.harq_tb_n[0] = + 1; // Assuming always an ACK (No NACK or DTX) + pdu->harq_indication_fdd_rel13.harq_tb_n[1] = + 1; // Assuming always an ACK (No NACK or DTX) } - }else if(harq_information->harq_information_rel10_tdd.tl.tag == NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG ){ - if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 0) && - (harq_information->harq_information_rel10_tdd.harq_size == 1)) { - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.mode = 0; - pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; - - } else if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 1) && - (harq_information->harq_information_rel10_tdd.harq_size == 2)) { - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.mode = 0; - pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; - pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = 1; - - } - } else AssertFatal(1==0,"only format 1a/b for now, received \n"); + } else if (harq_information->harq_information_rel10_tdd.tl.tag + == NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG) { + if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 0) + && (harq_information->harq_information_rel10_tdd.harq_size == 1)) { + pdu->harq_indication_tdd_rel13.tl.tag = + NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.mode = 0; + pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; + } else if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 1) + && (harq_information->harq_information_rel10_tdd.harq_size + == 2)) { + pdu->harq_indication_tdd_rel13.tl.tag = + NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.mode = 0; + pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; + pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = 1; + } + } else + AssertFatal(1 == 0, "only format 1a/b for now, received \n"); UL_INFO->harq_ind.harq_indication_body.number_of_harqs++; - LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.number_of_harqs:%d\n", UL_INFO->harq_ind.harq_indication_body.number_of_harqs); - // change for mutiple UE's simulation. - //pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + LOG_D(PHY, + "Incremented eNB->UL_INFO.harq_ind.number_of_harqs:%d\n", + UL_INFO->harq_ind.harq_indication_body.number_of_harqs); pthread_mutex_unlock(&fill_ul_mutex.harq_mutex); - } - void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, - nfapi_ul_config_request_pdu_t *ul_config_pdu, - uint16_t frame,uint8_t subframe,uint8_t srs_present, int index) -{ - + nfapi_ul_config_request_pdu_t *ul_config_pdu, + uint16_t frame, + uint8_t subframe, + uint8_t srs_present, + int index) { if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) { - LOG_D(PHY,"Applying UL config for UE, rnti %x for frame %d, subframe %d\n", - (ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8).rnti,frame,subframe); - uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32))); + LOG_D(PHY, + "Applying UL config for UE, rnti %x for frame %d, subframe %d\n", + (ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8).rnti, + frame, + subframe); + uint8_t ulsch_buffer[5477] __attribute__((aligned(32))); uint16_t buflen = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size; uint16_t rnti = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti; - uint8_t access_mode=SCHEDULED_ACCESS; - if(buflen>0){ - if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case - LOG_D(MAC, "handle_nfapi_ul_pdu_UE_MAC 2.2, Mod_id:%d, SFN/SF: %d/%d \n", Mod_id, frame, subframe); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); - fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index); - Msg3_transmitted(Mod_id, 0, frame, 0); - // Modification - UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; - UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + uint8_t access_mode = SCHEDULED_ACCESS; + if (buflen > 0) { + if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case + LOG_D(MAC, + "handle_nfapi_ul_pdu_UE_MAC 2.2, Mod_id:%d, SFN/SF: %d/%d \n", + Mod_id, + frame, + subframe); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, + frame, + subframe, + UL_INFO, + UE_mac_inst[Mod_id].RA_prach_resources.Msg3, + buflen, + rnti, + index); + Msg3_transmitted(Mod_id, 0, frame, 0); + // Modification + UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; - // This should be done after the reception of the respective hi_dci0 - //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; - } - else { - ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); - fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index); - } + // This should be done after the reception of the respective hi_dci0 + // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } else { + ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, + frame, + subframe, + UL_INFO, + ulsch_buffer, + buflen, + rnti, + index); + } } } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) { + // AssertFatal((UE_id = + // find_ulsch(ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, + // "No available UE ULSCH for rnti + // %x\n",ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti); + uint8_t ulsch_buffer[5477] __attribute__((aligned(32))); + uint16_t buflen = + ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.size; + nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = + &ul_config_pdu->ulsch_harq_pdu.harq_information; + uint16_t rnti = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; + uint8_t access_mode = SCHEDULED_ACCESS; + if (buflen > 0) { + if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, + frame, + subframe, + UL_INFO, + UE_mac_inst[Mod_id].RA_prach_resources.Msg3, + buflen, + rnti, + index); + Msg3_transmitted(Mod_id, 0, frame, 0); + // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + // Modification + UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } else { + ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, + frame, + subframe, + UL_INFO, + ulsch_buffer, + buflen, + rnti, + index); + } + } + if (ulsch_harq_information != NULL) + fill_ulsch_harq_indication_UE_MAC( + Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); - //AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, - // "No available UE ULSCH for rnti %x\n",ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti); - uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32))); - uint16_t buflen = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.size; - nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = &ul_config_pdu->ulsch_harq_pdu.harq_information; - uint16_t rnti = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; - uint8_t access_mode=SCHEDULED_ACCESS; - if(buflen>0){ - if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); - fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index); - Msg3_transmitted(Mod_id, 0, frame, 0); - //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; - // Modification - UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; - UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; - } - else { - ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); - fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index); - } + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) { + uint8_t ulsch_buffer[5477] __attribute__((aligned(32))); + uint16_t buflen = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size; - } - if(ulsch_harq_information!=NULL) - fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); + uint16_t rnti = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; + uint8_t access_mode = SCHEDULED_ACCESS; + if (buflen > 0) { + if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, + frame, + subframe, + UL_INFO, + UE_mac_inst[Mod_id].RA_prach_resources.Msg3, + buflen, + rnti, + index); + Msg3_transmitted(Mod_id, 0, frame, 0); + // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + // Modification + UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } else { + ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, + frame, + subframe, + UL_INFO, + ulsch_buffer, + buflen, + rnti, + index); + } + } + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) { + uint8_t ulsch_buffer[5477] __attribute__((aligned(32))); + uint16_t buflen = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size; + nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = + &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information; + uint16_t rnti = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; + uint8_t access_mode = SCHEDULED_ACCESS; + if (buflen > 0) { + if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, + frame, + subframe, + UL_INFO, + UE_mac_inst[Mod_id].RA_prach_resources.Msg3, + buflen, + rnti, + index); + Msg3_transmitted(Mod_id, 0, frame, 0); + // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + // Modification + UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } else { + ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, + frame, + subframe, + UL_INFO, + ulsch_buffer, + buflen, + rnti, + index); + } + } + + if (ulsch_harq_information != NULL) + fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) { + uint16_t rnti = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti; + + nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_harq_pdu.harq_information; + if (ulsch_harq_information != NULL) + fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) { + AssertFatal(1 == 0, "NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE not handled yet\n"); + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE) { + AssertFatal(1 == 0, + "NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE not handled yet\n"); + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE) { + AssertFatal(1 == 0, + "NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE not handled yet\n"); + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) { + uint16_t rnti = + ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti; + + if (ue_get_SR(Mod_id, 0, frame, 0, rnti, subframe)) + fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); + + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) { + // AssertFatal((UE_id = + // find_uci(rel8->rnti,proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0, + // "No available UE UCI for rnti + // %x\n",ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti); + + uint16_t rnti = + ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti; + + // We fill the sr_indication only if ue_get_sr() would normally instruct PHY + // to send a SR. + if (ue_get_SR(Mod_id, 0, frame, 0, rnti, subframe)) + fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); + + nfapi_ul_config_harq_information *ulsch_harq_information = + &ul_config_pdu->uci_sr_harq_pdu.harq_information; + if (ulsch_harq_information != NULL) + fill_uci_harq_indication_UE_MAC( + Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) { - uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32))); - uint16_t buflen = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size; - - uint16_t rnti = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; - uint8_t access_mode=SCHEDULED_ACCESS; - if(buflen>0){ - if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); - fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index); - Msg3_transmitted(Mod_id, 0, frame, 0); - //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; - // Modification - UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; - UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; - } - else { - ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); - fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index); - } - } - fill_ulsch_cqi_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); - - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) { - - uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32))); - uint16_t buflen = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size; - nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information; - - uint16_t rnti = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; - uint8_t access_mode=SCHEDULED_ACCESS; - if(buflen>0){ - if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); - fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index); - Msg3_transmitted(Mod_id, 0, frame, 0); - //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; - // Modification - UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; - UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; - } - else { - ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); - fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index); - } - } - - if(ulsch_harq_information!=NULL) - fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); - fill_ulsch_cqi_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); - - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) { - - uint16_t rnti = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti; - - nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_harq_pdu.harq_information; - if(ulsch_harq_information != NULL) - fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO,ulsch_harq_information, rnti); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) { - AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE not handled yet\n"); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE) { - AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE not handled yet\n"); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE) { - AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE not handled yet\n"); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) { - - uint16_t rnti = ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti; - - if (ue_get_SR(Mod_id ,0,frame, 0, rnti, subframe)) - fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); - - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) { - //AssertFatal((UE_id = find_uci(rel8->rnti,proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0, - // "No available UE UCI for rnti %x\n",ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti); - - uint16_t rnti = ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti; - - // We fill the sr_indication only if ue_get_sr() would normally instruct PHY to send a SR. - if (ue_get_SR(Mod_id ,0,frame, 0, rnti, subframe)) - fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO,rnti); - - nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_sr_harq_pdu.harq_information; - if (ulsch_harq_information != NULL) - fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO,ulsch_harq_information, rnti); - - } - } - - - - - -int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int timer_subframe, module_id_t Mod_id) -{ - //if (req!=NULL){ // && req->ul_config_request_body.ul_config_pdu_list !=NULL){ - LOG_D(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n", - __FUNCTION__, - NFAPI_SFNSF2DEC(req->sfn_sf), - req->ul_config_request_body.number_of_pdus, - req->ul_config_request_body.rach_prach_frequency_resources, - req->ul_config_request_body.srs_present - ); +int ul_config_req_UE_MAC(nfapi_ul_config_request_t *req, + int timer_frame, + int timer_subframe, + module_id_t Mod_id) { + LOG_D(PHY, + "[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d " + "rach_prach_frequency_resources:%d srs_present:%u\n", + __FUNCTION__, + NFAPI_SFNSF2DEC(req->sfn_sf), + req->ul_config_request_body.number_of_pdus, + req->ul_config_request_body.rach_prach_frequency_resources, + req->ul_config_request_body.srs_present); int sfn = NFAPI_SFNSF2SFN(req->sfn_sf); int sf = NFAPI_SFNSF2SF(req->sfn_sf); + LOG_D(MAC, + "ul_config_req_UE_MAC() TOTAL NUMBER OF UL_CONFIG PDUs: %d, SFN/SF: " + "%d/%d \n", + req->ul_config_request_body.number_of_pdus, + timer_frame, + timer_subframe); - LOG_D(MAC, "ul_config_req_UE_MAC() TOTAL NUMBER OF UL_CONFIG PDUs: %d, SFN/SF: %d/%d \n", req->ul_config_request_body.number_of_pdus, timer_frame, timer_subframe); - - - - for (int i=0;iul_config_request_body.number_of_pdus;i++) - { - - if ( - (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) || - (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) || - (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) || - (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) || - (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].uci_cqi_harq_pdu.ue_information.ue_information_rel8.rnti == UE_mac_inst[Mod_id].crnti) || - (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].uci_sr_pdu.ue_information.ue_information_rel8.rnti == UE_mac_inst[Mod_id].crnti) || - (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].uci_cqi_sr_harq_pdu.ue_information.ue_information_rel8.rnti == UE_mac_inst[Mod_id].crnti) - ) - { - - handle_nfapi_ul_pdu_UE_MAC(Mod_id,&req->ul_config_request_body.ul_config_pdu_list[i],sfn,sf,req->ul_config_request_body.srs_present, i); - - } - else - { - //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n", __FUNCTION__, i, ul_config_pdu_list[i].pdu_type); + const rnti_t rnti = UE_mac_inst[Mod_id].crnti; + for (int i = 0; i < req->ul_config_request_body.number_of_pdus; i++) { + nfapi_ul_config_request_pdu_t* pdu = &req->ul_config_request_body.ul_config_pdu_list[i]; + const int pdu_type = pdu->pdu_type; + if ( (pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE + && pdu->ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) + || (pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE + && pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) + || (pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE + && pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) + || (pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE + && pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) + || (pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE + && pdu->uci_cqi_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) + || (pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE + && pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti) + || (pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE + && pdu->uci_cqi_sr_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) { + handle_nfapi_ul_pdu_UE_MAC( + Mod_id, pdu, sfn, sf, req->ul_config_request_body.srs_present, i); + } else { + // NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n", + // __FUNCTION__, i, ul_config_pdu_list[i].pdu_type); } } -// } - return 0; } +int tx_req_UE_MAC(nfapi_tx_request_t *req) { + LOG_D(PHY, + "%s() SFN/SF:%d/%d PDUs:%d\n", + __FUNCTION__, + NFAPI_SFNSF2SFN(req->sfn_sf), + NFAPI_SFNSF2SF(req->sfn_sf), + req->tx_request_body.number_of_pdus); - -int tx_req_UE_MAC(nfapi_tx_request_t* req) -{ - - LOG_D(PHY,"%s() SFN/SF:%d/%d PDUs:%d\n", __FUNCTION__, NFAPI_SFNSF2SFN(req->sfn_sf), NFAPI_SFNSF2SF(req->sfn_sf), req->tx_request_body.number_of_pdus); - - - for (int i=0; itx_request_body.number_of_pdus; i++) - { - LOG_D(PHY,"%s() SFN/SF:%d/%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n", + for (int i = 0; i < req->tx_request_body.number_of_pdus; i++) { + LOG_D(PHY, + "%s() SFN/SF:%d/%d number_of_pdus:%d [PDU:%d] pdu_length:%d " + "pdu_index:%d num_segments:%d\n", __FUNCTION__, - NFAPI_SFNSF2SFN(req->sfn_sf), NFAPI_SFNSF2SF(req->sfn_sf), + NFAPI_SFNSF2SFN(req->sfn_sf), + NFAPI_SFNSF2SF(req->sfn_sf), req->tx_request_body.number_of_pdus, i, req->tx_request_body.tx_pdu_list[i].pdu_length, req->tx_request_body.tx_pdu_list[i].pdu_index, - req->tx_request_body.tx_pdu_list[i].num_segments - ); - - } + req->tx_request_body.tx_pdu_list[i].num_segments); + } return 0; } - -int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) //, nfapi_tx_request_pdu_t* tx_request_pdu_list) -{ - //if (req!=NULL && tx_request_pdu_list!=NULL){ +int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) { int sfn = NFAPI_SFNSF2SFN(req->sfn_sf); int sf = NFAPI_SFNSF2SF(req->sfn_sf); - //Mod_id = 0; // Currently static (only for one UE) but this should change. - /*struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - L1_rxtx_proc_t *proc = &eNB->proc.L1_proc;*/ nfapi_dl_config_request_pdu_t* dl_config_pdu_list = req->dl_config_request_body.dl_config_pdu_list; - nfapi_dl_config_request_pdu_t *dl_config_pdu_tmp; - //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d sfn_sf:%d DCI:%d PDU:%d\n", __FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, NFAPI_SFNSF2DEC(req->sfn_sf), req->dl_config_request_body.number_dci, req->dl_config_request_body.number_pdu); - - - - //LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%d%d dl_pdu:%d tx_req:%d hi_dci0:%d ul_cfg:%d num_pdcch_symbols:%d\n", - // frame,subframe,number_dl_pdu,TX_req->tx_request_body.number_of_pdus,number_hi_dci0_pdu,number_ul_pdu, eNB->pdcch_vars[subframe&1].num_pdcch_symbols); - - for (int i=0;idl_config_request_body.number_pdu;i++) - { - //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size); - //LOG_E(MAC, "dl_config_req_UE_MAC 2 Received real ones: sfn/sf:%d.%d PDU[%d] size:%d\n", sfn, sf, i, dl_config_pdu_list[i].pdu_size); - - if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) - { - if (dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 1) { - // C-RNTI (Normal DLSCH case) - dl_config_pdu_tmp = &dl_config_pdu_list[i+1]; - if (dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && UE_mac_inst[Mod_id].crnti == dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti){ - - /*nfapi_tx_request_pdu_t *ptr = tx_request_pdu_list; - ptr += dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index*(sizeof(nfapi_tx_request_pdu_t)); - nfapi_tx_request_pdu_t temp; - memset(&temp, 0, sizeof(nfapi_tx_request_pdu_t)); - //if (!memcmp(&temp, ptr, sizeof(temp)) ... - if( *(char*)ptr != 0){ - //if(tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data!= NULL && tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length >0){ - */ - - // to avoid unexpected error , add check pdu_index is more than 0. - if((dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index >= 0) &&(dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1)){ - //if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){ - - LOG_E(MAC, "dl_config_req_UE_MAC 2 Received data: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d, tx_req_num_elems: %d \n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index, tx_req_num_elems); - - ue_send_sdu(Mod_id, 0, sfn, sf, - tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, - tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length, - 0); - i++; - } - else{ - LOG_E(MAC,"dl_config_req_UE_MAC 2: Problem with receiving data: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index); - i++; - } - } - else { - LOG_E(MAC,"[UE %d] Frame %d, subframe %d : DLSCH PDU from NFAPI not for this UE \n",Mod_id, sfn,sf); - i++; - } - } - else if (dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 2) { - dl_config_pdu_tmp = &dl_config_pdu_list[i+1]; - if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFF && UE_mac_inst[Mod_id].UE_mode[0] != NOT_SYNCHED){ //&& UE_mac_inst[Mod_id].UE_mode[0] != NOT_SYNCHED - - if(dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1){ - //if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){ - ue_decode_si(Mod_id, 0, sfn, 0, - tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, - tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); - i++; - } - else{ - LOG_E(MAC,"dl_config_req_UE_MAC 3: Problem with receiving SI: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index); - i++; - } - } - else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFE){ - // P_RNTI case - //pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data; - - if (dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1){ - //if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){ - ue_decode_p(Mod_id, 0, sfn, 0, - tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, - tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); - i++; - } - else{ - LOG_E(MAC,"dl_config_req_UE_MAC: Problem with receiving Paging: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index); - i++; - } - } - else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { - // RA-RNTI case - LOG_E(MAC,"dl_config_req_UE_MAC 4 Received RAR? \n"); - // RNTI parameter not actually used. Provided only to comply with existing function definition. - // Not sure about parameters to fill the preamble index. - //rnti_t c_rnti = UE_mac_inst[Mod_id].crnti; - rnti_t ra_rnti = UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI; - if ((UE_mac_inst[Mod_id].UE_mode[0] != PUSCH) && - (UE_mac_inst[Mod_id].RA_prach_resources.Msg3!=NULL) && (ra_rnti== dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti) && - //(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL)) { - (dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1)) { - LOG_E(MAC,"dl_config_req_UE_MAC 5 Received RAR, PreambleIndex: %d \n", UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex); - ue_process_rar(Mod_id, 0, sfn, - ra_rnti, //RA-RNTI - tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, - &dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //t-crnti - UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex, - tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data); - UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE; - UE_mac_inst[Mod_id].first_ULSCH_Tx = 1; //Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first ULSCH Txon for the UE) - } - i++; - } - else { - LOG_E(MAC,"[UE %d] Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI 2\n",Mod_id, sfn, sf); - i++; - } - - } - } - else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_BCH_PDU_TYPE) - { - // BCH case - // Last parameter is 1 if first time synchronization and zero otherwise. Not sure which value to put - // for our case. - //LOG_E(MAC,"dl_config_req_UE_MAC 4 Received MIB: sfn/sf: %d.%d \n", sfn, sf); - if(UE_mac_inst[Mod_id].UE_mode[0] == NOT_SYNCHED){ - dl_phy_sync_success(Mod_id,sfn,0, 1); - LOG_E(MAC,"dl_config_req_UE_MAC 5 Received MIB: UE_mode: %d, sfn/sf: %d.%d\n", UE_mac_inst[Mod_id].UE_mode[0], sfn, sf); - UE_mac_inst[Mod_id].UE_mode[0]=PRACH; - } - else - dl_phy_sync_success(Mod_id,sfn,0, 0); - - } - - else - { - //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_config_pdu_list[i].pdu_type); - } - } - - return 0; - -} - - -int hi_dci0_req_UE_MAC(nfapi_hi_dci0_request_t* req, module_id_t Mod_id) -{ - if (req!=NULL && req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){ - LOG_D(PHY,"[UE-PHY_STUB] hi dci0 request sfn_sf:%d number_of_dci:%d number_of_hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi); - - - - for (int i=0; ihi_dci0_request_body.number_of_dci + req->hi_dci0_request_body.number_of_hi; i++) - { - LOG_D(PHY,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d]\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); - - if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) - { - LOG_D(PHY,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_DCI_PDU_TYPE not used \n", NFAPI_SFNSF2DEC(req->sfn_sf), i); - - } - else if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) - { - //LOG_I(MAC,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); - - nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu = &req->hi_dci0_request_body.hi_dci0_pdu_list[i]; - - // This is meaningful only after ACKnowledging the first ULSCH Txon (i.e. Msg3) - if(hi_dci0_req_pdu->hi_pdu.hi_pdu_rel8.hi_value == 1 && UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ - //LOG_I(MAC,"[UE-PHY_STUB] HI_DCI0_REQ 2 sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); - //UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; - //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + for (int i = 0; i < req->dl_config_request_body.number_pdu; i++) { + if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) { + const rnti_t rnti = dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti; + const int rnti_type = dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type; + /* We assume the DCI DL PDU is followed by the DLSCH (the standard is + * more free), so advance by one more and directly process the + * following DLSCH PDU */ + i++; + AssertFatal(i < req->dl_config_request_body.number_pdu, + "Need PDU following DCI at index %d, but not found\n", + i); + nfapi_dl_config_request_pdu_t *dl_config_pdu_tmp = &dl_config_pdu_list[i]; + if (dl_config_pdu_tmp->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { + LOG_E(MAC, "expected DLSCH PDU at index %d\n", i); + continue; } + if (rnti != dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti) { + LOG_I(MAC, + "%s(): sfn/sf %d DLSCH PDU RNTI %x does not match DCI RNTI %x\n", + __func__, + NFAPI_SFNSF2DEC(req->sfn_sf), + rnti, + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti); + continue; + } + const int pdu_index = dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index; + if (pdu_index < 0 && pdu_index >= tx_req_num_elems) { + LOG_E(MAC, + "dl_config_req_UE_MAC 2: Problem with receiving data: " + "sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", + NFAPI_SFNSF2DEC(req->sfn_sf), + i, + dl_config_pdu_list[i].pdu_size, + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index); + continue; + } + if (rnti_type == 1) { + // C-RNTI (Normal DLSCH case) + if (UE_mac_inst[Mod_id].crnti != rnti) { + LOG_D(MAC, + "sfn/sf %d/%d DCI not for UE %d/RNTI %x but for RNTI %x, " + "skipping\n", + sfn, sf, Mod_id, UE_mac_inst[Mod_id].crnti, rnti); + continue; + } - } - else - { - LOG_E(PHY,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - unknown pdu type:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type); + LOG_D(MAC, + "%s() Received data: sfn/sf:%d PDU[%d] " + "size:%d, TX_PDU index: %d, tx_req_num_elems: %d \n", + __func__, + NFAPI_SFNSF2DEC(req->sfn_sf), + i, + dl_config_pdu_list[i].pdu_size, + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index, + tx_req_num_elems); + ue_send_sdu(Mod_id, 0, sfn, sf, + tx_request_pdu_list[pdu_index].segments[0].segment_data, + tx_request_pdu_list[pdu_index].segments[0].segment_length, + 0); + } else if (rnti_type == 2) { + if (rnti == 0xFFFF) { /* SI-RNTI */ + if (UE_mac_inst[Mod_id].UE_mode[0] == NOT_SYNCHED) { + /* this check is in the code before refactoring, but I don't know + * why. Leave it in here for the moment */ + continue; + } + + ue_decode_si(Mod_id, 0, sfn, 0, + tx_request_pdu_list[pdu_index].segments[0].segment_data, + tx_request_pdu_list[pdu_index].segments[0].segment_length); + } else if (rnti == 0xFFFE) { /* PI-RNTI */ + LOG_I(MAC, "%s() Received paging message: sfn/sf:%d PDU[%d]\n", + __func__, NFAPI_SFNSF2DEC(req->sfn_sf), i); + ue_decode_p(Mod_id, 0, sfn, 0, + tx_request_pdu_list[pdu_index].segments[0].segment_data, + tx_request_pdu_list[pdu_index].segments[0].segment_length); + } else if (rnti == 0x0002) { /* RA-RNTI */ + LOG_E(MAC, "%s(): Received RAR?\n", __func__); + // RNTI parameter not actually used. Provided only to comply with + // existing function definition. Not sure about parameters to fill + // the preamble index. + const rnti_t ra_rnti = UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI; + DevAssert(ra_rnti == 0x0002); + if (UE_mac_inst[Mod_id].UE_mode[0] != PUSCH + && UE_mac_inst[Mod_id].RA_prach_resources.Msg3 != NULL + && ra_rnti == dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti) { + LOG_E(MAC, + "dl_config_req_UE_MAC 5 Received RAR, PreambleIndex: %d \n", + UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex); + ue_process_rar(Mod_id, 0, sfn, + ra_rnti, //RA-RNTI + tx_request_pdu_list[pdu_index].segments[0].segment_data, + &dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //t-crnti + UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex, + tx_request_pdu_list[pdu_index].segments[0].segment_data); + UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE; + // Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first + // ULSCH Txon for the UE) + UE_mac_inst[Mod_id].first_ULSCH_Tx = 1; + } + } else { + LOG_W(MAC, "can not handle special RNTI %x\n", rnti); + } + } + } else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_BCH_PDU_TYPE) { + // BCH case: Last parameter is 1 if first time synchronization and zero + // otherwise. Not sure which value to put for our case. + if (UE_mac_inst[Mod_id].UE_mode[0] == NOT_SYNCHED){ + dl_phy_sync_success(Mod_id, sfn, 0, 1); + LOG_E(MAC, + "%s(): Received MIB: UE_mode: %d, sfn/sf: %d.%d\n", + __func__, + UE_mac_inst[Mod_id].UE_mode[0], + sfn, + sf); + UE_mac_inst[Mod_id].UE_mode[0] = PRACH; + } else { + dl_phy_sync_success(Mod_id, sfn, 0, 0); + } } } + return 0; +} +int hi_dci0_req_UE_MAC(nfapi_hi_dci0_request_t *req, module_id_t Mod_id) { + if (req != NULL && req->hi_dci0_request_body.hi_dci0_pdu_list != NULL) { + LOG_D(PHY, + "[UE-PHY_STUB] hi dci0 request sfn_sf:%d number_of_dci:%d " + "number_of_hi:%d\n", + NFAPI_SFNSF2DEC(req->sfn_sf), + req->hi_dci0_request_body.number_of_dci, + req->hi_dci0_request_body.number_of_hi); + + for (int i = 0; i < req->hi_dci0_request_body.number_of_dci + + req->hi_dci0_request_body.number_of_hi; + i++) { + LOG_D(PHY, + "[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d]\n", + NFAPI_SFNSF2DEC(req->sfn_sf), + i); + + if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type + == NFAPI_HI_DCI0_DCI_PDU_TYPE) { + LOG_D(PHY, + "[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - " + "NFAPI_HI_DCI0_DCI_PDU_TYPE\n", + NFAPI_SFNSF2DEC(req->sfn_sf), + i); + const nfapi_hi_dci0_dci_pdu_rel8_t *dci = + &req->hi_dci0_request_body.hi_dci0_pdu_list[i].dci_pdu.dci_pdu_rel8; + if (dci->rnti != UE_mac_inst[Mod_id].crnti) + continue; + const int sfn = NFAPI_SFNSF2SFN(req->sfn_sf); + const int sf = NFAPI_SFNSF2SF(req->sfn_sf); + if (dci->cqi_csi_request) + fill_ulsch_cqi_indication_UE_MAC(Mod_id, sfn, sf, UL_INFO, dci->rnti); + } else if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type + == NFAPI_HI_DCI0_HI_PDU_TYPE) { + nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu = + &req->hi_dci0_request_body.hi_dci0_pdu_list[i]; + + // This is meaningful only after ACKnowledging the first ULSCH Txon + // (i.e. Msg3) + if (hi_dci0_req_pdu->hi_pdu.hi_pdu_rel8.hi_value == 1 + && UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { + // LOG_I(MAC,"[UE-PHY_STUB] HI_DCI0_REQ 2 sfn_sf:%d PDU[%d] - + // NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); + // UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } + + } else { + LOG_E(PHY, + "[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - unknown pdu " + "type:%d\n", + NFAPI_SFNSF2DEC(req->sfn_sf), + i, + req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type); + } + } } - return 0; } +// The following set of memcpy functions should be getting called as callback +// functions from pnf_p7_subframe_ind. +int memcpy_dl_config_req(nfapi_pnf_p7_config_t *pnf_p7, + nfapi_dl_config_request_t *req) { + dl_config_req = (nfapi_dl_config_request_t *)malloc(sizeof(nfapi_dl_config_request_t)); + // UE_mac_inst[Mod_id].dl_config_req->header = req->header; + dl_config_req->sfn_sf = req->sfn_sf; + dl_config_req->vendor_extension = req->vendor_extension; + dl_config_req->dl_config_request_body.number_dci = req->dl_config_request_body.number_dci; + dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols; + dl_config_req->dl_config_request_body.number_pdsch_rnti = req->dl_config_request_body.number_pdsch_rnti; + dl_config_req->dl_config_request_body.number_pdu = req->dl_config_request_body.number_pdu; -// The following set of memcpy functions should be getting called as callback functions from -// pnf_p7_subframe_ind. -int memcpy_dl_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) -{ + dl_config_req->dl_config_request_body.tl.tag = req->dl_config_request_body.tl.tag; + dl_config_req->dl_config_request_body.tl.length = req->dl_config_request_body.tl.length; - //for (Mod_id=0; Mod_idheader = req->header; - dl_config_req->sfn_sf = req->sfn_sf; - - dl_config_req->vendor_extension = req->vendor_extension; - - dl_config_req->dl_config_request_body.number_dci = req->dl_config_request_body.number_dci; - dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols; - dl_config_req->dl_config_request_body.number_pdsch_rnti = req->dl_config_request_body.number_pdsch_rnti; - dl_config_req->dl_config_request_body.number_pdu = req->dl_config_request_body.number_pdu; - - dl_config_req->dl_config_request_body.tl.tag = req->dl_config_request_body.tl.tag; - dl_config_req->dl_config_request_body.tl.length = req->dl_config_request_body.tl.length; - - dl_config_req->dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*) calloc(req->dl_config_request_body.number_pdu, sizeof(nfapi_dl_config_request_pdu_t)); - for(int i=0; idl_config_request_body.number_pdu; i++) { - dl_config_req->dl_config_request_body.dl_config_pdu_list[i] = req->dl_config_request_body.dl_config_pdu_list[i]; - } - - //} - - return 0; + dl_config_req->dl_config_request_body.dl_config_pdu_list = + calloc(req->dl_config_request_body.number_pdu, + sizeof(nfapi_dl_config_request_pdu_t)); + for (int i = 0; i < dl_config_req->dl_config_request_body.number_pdu; i++) { + dl_config_req->dl_config_request_body.dl_config_pdu_list[i] = + req->dl_config_request_body.dl_config_pdu_list[i]; + } + return 0; } -int memcpy_ul_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req) -{ +int memcpy_ul_config_req(nfapi_pnf_p7_config_t *pnf_p7, + nfapi_ul_config_request_t *req) { + ul_config_req = malloc(sizeof(nfapi_ul_config_request_t)); - //for (Mod_id=0; Mod_idsfn_sf = req->sfn_sf; + ul_config_req->vendor_extension = req->vendor_extension; - ul_config_req = (nfapi_ul_config_request_t*)malloc(sizeof(nfapi_ul_config_request_t)); + ul_config_req->ul_config_request_body.number_of_pdus = req->ul_config_request_body.number_of_pdus; + ul_config_req->ul_config_request_body.rach_prach_frequency_resources = req->ul_config_request_body.rach_prach_frequency_resources; + ul_config_req->ul_config_request_body.srs_present = req->ul_config_request_body.srs_present; - ul_config_req->sfn_sf = req->sfn_sf; - ul_config_req->vendor_extension = req->vendor_extension; + ul_config_req->ul_config_request_body.tl.tag = req->ul_config_request_body.tl.tag; + ul_config_req->ul_config_request_body.tl.length = req->ul_config_request_body.tl.length; + ul_config_req->ul_config_request_body.ul_config_pdu_list = + calloc(req->ul_config_request_body.number_of_pdus, + sizeof(nfapi_ul_config_request_pdu_t)); + for (int i = 0; i < ul_config_req->ul_config_request_body.number_of_pdus; i++) { + ul_config_req->ul_config_request_body.ul_config_pdu_list[i] = + req->ul_config_request_body.ul_config_pdu_list[i]; + } - ul_config_req->ul_config_request_body.number_of_pdus = req->ul_config_request_body.number_of_pdus; - ul_config_req->ul_config_request_body.rach_prach_frequency_resources = req->ul_config_request_body.rach_prach_frequency_resources; - ul_config_req->ul_config_request_body.srs_present = req->ul_config_request_body.srs_present; - - ul_config_req->ul_config_request_body.tl.tag = req->ul_config_request_body.tl.tag; - ul_config_req->ul_config_request_body.tl.length = req->ul_config_request_body.tl.length; - - //LOG_D(MAC, "memcpy_ul_config_req 1 #ofULPDUs: %d \n", UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.number_of_pdus); //req->ul_config_request_body.number_of_pdus); - ul_config_req->ul_config_request_body.ul_config_pdu_list = (nfapi_ul_config_request_pdu_t*) malloc(req->ul_config_request_body.number_of_pdus*sizeof(nfapi_ul_config_request_pdu_t)); - for(int i=0; iul_config_request_body.number_of_pdus; i++) { - ul_config_req->ul_config_request_body.ul_config_pdu_list[i] = req->ul_config_request_body.ul_config_pdu_list[i]; - } - //} - - return 0; + return 0; } +int memcpy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) { + tx_req_num_elems = req->tx_request_body.number_of_pdus; + tx_request_pdu_list = calloc(tx_req_num_elems, sizeof(nfapi_tx_request_pdu_t)); + for (int i = 0; i < tx_req_num_elems; i++) { + tx_request_pdu_list[i].num_segments = req->tx_request_body.tx_pdu_list[i].num_segments; + tx_request_pdu_list[i].pdu_index = req->tx_request_body.tx_pdu_list[i].pdu_index; + tx_request_pdu_list[i].pdu_length = req->tx_request_body.tx_pdu_list[i].pdu_length; + for (int j = 0; j < req->tx_request_body.tx_pdu_list[i].num_segments; j++) { + tx_request_pdu_list[i].segments[j].segment_length = req->tx_request_body.tx_pdu_list[i].segments[j].segment_length; + if (tx_request_pdu_list[i].segments[j].segment_length > 0) { + tx_request_pdu_list[i].segments[j].segment_data = calloc( + tx_request_pdu_list[i].segments[j].segment_length, sizeof(uint8_t)); + memcpy(tx_request_pdu_list[i].segments[j].segment_data, + req->tx_request_body.tx_pdu_list[i].segments[j].segment_data, + tx_request_pdu_list[i].segments[j].segment_length); + } + } + } - - -int memcpy_tx_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req) -{ - - tx_req_num_elems = req->tx_request_body.number_of_pdus; - tx_request_pdu_list = (nfapi_tx_request_pdu_t*) calloc(tx_req_num_elems, sizeof(nfapi_tx_request_pdu_t)); - for (int i=0; itx_request_body.tx_pdu_list[i].num_segments; - tx_request_pdu_list[i].pdu_index = req->tx_request_body.tx_pdu_list[i].pdu_index; - tx_request_pdu_list[i].pdu_length = req->tx_request_body.tx_pdu_list[i].pdu_length; - for (int j=0; jtx_request_body.tx_pdu_list[i].num_segments; j++){ - //*tx_request_pdu_list[i].segments[j].segment_data = *req->tx_request_body.tx_pdu_list[i].segments[j].segment_data; - tx_request_pdu_list[i].segments[j].segment_length = req->tx_request_body.tx_pdu_list[i].segments[j].segment_length; - if(tx_request_pdu_list[i].segments[j].segment_length > 0){ - tx_request_pdu_list[i].segments[j].segment_data = (uint8_t*)malloc(tx_request_pdu_list[i].segments[j].segment_length*sizeof (uint8_t)); - memcpy(tx_request_pdu_list[i].segments[j].segment_data, req->tx_request_body.tx_pdu_list[i].segments[j].segment_data, tx_request_pdu_list[i].segments[j].segment_length); - } - } - - } - - return 0; + return 0; } -int memcpy_hi_dci0_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req) -{ +int memcpy_hi_dci0_req(nfapi_pnf_p7_config_t *pnf_p7, + nfapi_hi_dci0_request_t *req) { + hi_dci0_req = (nfapi_hi_dci0_request_t *)malloc(sizeof(nfapi_hi_dci0_request_t)); - //if(req!=0){ + hi_dci0_req->sfn_sf = req->sfn_sf; + hi_dci0_req->vendor_extension = req->vendor_extension; - //for (Mod_id=0; Mod_idhi_dci0_request_body.number_of_dci = req->hi_dci0_request_body.number_of_dci; + hi_dci0_req->hi_dci0_request_body.number_of_hi = req->hi_dci0_request_body.number_of_hi; + hi_dci0_req->hi_dci0_request_body.sfnsf = req->hi_dci0_request_body.sfnsf; - hi_dci0_req->sfn_sf = req->sfn_sf; - hi_dci0_req->vendor_extension = req->vendor_extension; + // UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.tl = + // req->hi_dci0_request_body.tl; + hi_dci0_req->hi_dci0_request_body.tl.tag = req->hi_dci0_request_body.tl.tag; + hi_dci0_req->hi_dci0_request_body.tl.length = req->hi_dci0_request_body.tl.length; - hi_dci0_req->hi_dci0_request_body.number_of_dci = req->hi_dci0_request_body.number_of_dci; - hi_dci0_req->hi_dci0_request_body.number_of_hi = req->hi_dci0_request_body.number_of_hi; - hi_dci0_req->hi_dci0_request_body.sfnsf = req->hi_dci0_request_body.sfnsf; + int total_pdus = hi_dci0_req->hi_dci0_request_body.number_of_dci + + hi_dci0_req->hi_dci0_request_body.number_of_hi; - //UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.tl = req->hi_dci0_request_body.tl; - hi_dci0_req->hi_dci0_request_body.tl.tag = req->hi_dci0_request_body.tl.tag; - hi_dci0_req->hi_dci0_request_body.tl.length = req->hi_dci0_request_body.tl.length; + hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = + calloc(total_pdus, sizeof(nfapi_hi_dci0_request_pdu_t)); - int total_pdus = hi_dci0_req->hi_dci0_request_body.number_of_dci + hi_dci0_req->hi_dci0_request_body.number_of_hi; - - hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = (nfapi_hi_dci0_request_pdu_t*) malloc(total_pdus*sizeof(nfapi_hi_dci0_request_pdu_t)); - - for(int i=0; ihi_dci0_request_body.hi_dci0_pdu_list[i] = req->hi_dci0_request_body.hi_dci0_pdu_list[i]; - //LOG_I(MAC, "Original hi_dci0 req. type:%d, Copy type: %d \n",req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type, UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type); - } - - //} - return 0; + for (int i = 0; i < total_pdus; i++) { + hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i] = req->hi_dci0_request_body.hi_dci0_pdu_list[i]; + // LOG_I(MAC, "Original hi_dci0 req. type:%d, Copy type: %d + // \n",req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type, + // UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type); + } + return 0; } - - void UE_config_stub_pnf(void) { - int j; + int j; paramdef_t L1_Params[] = L1PARAMS_DESC; - paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0}; + paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST, NULL, 0}; - config_getlist( &L1_ParamList,L1_Params,sizeof(L1_Params)/sizeof(paramdef_t), NULL); + config_getlist(&L1_ParamList, L1_Params, sizeof(L1_Params) / sizeof(paramdef_t), NULL); if (L1_ParamList.numelt > 0) { - for (j=0; jemm_data->security->selected_algorithms.encryption = seea; user->emm_data->security->selected_algorithms.integrity = seia; #if defined(NAS_BUILT_IN_UE) - nas_itti_kenb_refresh_req(security_data->kenb.value); + nas_itti_kenb_refresh_req(security_data->kenb.value, user->ueid); #endif } diff --git a/openair3/NAS/UE/nas_itti_messaging.c b/openair3/NAS/UE/nas_itti_messaging.c index 55566700d7..885ebbdd81 100644 --- a/openair3/NAS/UE/nas_itti_messaging.c +++ b/openair3/NAS/UE/nas_itti_messaging.c @@ -100,7 +100,7 @@ int nas_itti_protected_msg(const char *buffer, const nas_message_t *msg, const i extern unsigned char NB_eNB_INST; -int nas_itti_kenb_refresh_req(const Byte_t kenb[32]) { +int nas_itti_kenb_refresh_req(const Byte_t kenb[32], int user_id) { 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)); @@ -125,7 +125,7 @@ int nas_itti_kenb_refresh_req(const Byte_t kenb[32]) { 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); + return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + user_id, message_p); } int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat, int user_id) { diff --git a/openair3/NAS/UE/nas_itti_messaging.h b/openair3/NAS/UE/nas_itti_messaging.h index d958317e5a..967bbb3059 100644 --- a/openair3/NAS/UE/nas_itti_messaging.h +++ b/openair3/NAS/UE/nas_itti_messaging.h @@ -48,7 +48,7 @@ int nas_itti_protected_msg( # if defined(NAS_BUILT_IN_UE) -int nas_itti_kenb_refresh_req(const Byte_t kenb[32]); +int nas_itti_kenb_refresh_req(const Byte_t kenb[32], int user_id); int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat, int user_id); diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 5a8afc2358..75ed018434 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -88,7 +88,7 @@ extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *), unsigned char _multicast_group, char *multicast_ifname); extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind); -extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind); +extern int oai_nfapi_cqi_indication(nfapi_cqi_indication_t *cqi_ind); extern int oai_nfapi_harq_indication(nfapi_harq_indication_t *harq_ind); extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind); extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); @@ -992,6 +992,19 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) phy_stub_ticking->num_single_thread[ue_thread_id] = -1; UE = rtd->UE; + UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t)); + UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_rx_indication_pdu_t)); + UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; + UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_crc_indication_pdu_t)); + UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0; + UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_harq_indication_pdu_t)); + UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0; + UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_sr_indication_pdu_t)); + UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0; + UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_cqi_indication_pdu_t)); + UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_cqi_indication_raw_pdu_t)); + UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0; + if(ue_thread_id == 0) { phy_stub_ticking->ticking_var = -1; proc->subframe_rx=proc->sub_frame_start; @@ -1064,20 +1077,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) initRefTimes(t3); pickTime(current); updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)");*/ - // Not sure whether we should put the memory allocation here and not sure how much memory - //we should allocate for each subframe cycle. - UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t)); - UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = (nfapi_rx_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_rx_indication_pdu_t)); - UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; - UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = (nfapi_crc_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_crc_indication_pdu_t)); - UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0; - UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = (nfapi_harq_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_harq_indication_pdu_t)); - UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0; - UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = (nfapi_sr_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_sr_indication_pdu_t)); - UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0; - UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = (nfapi_cqi_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_cqi_indication_pdu_t)); - UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = (nfapi_cqi_indication_raw_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_cqi_indication_raw_pdu_t)); - UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0; if (pthread_mutex_lock(&phy_stub_ticking->mutex_single_thread) != 0) { LOG_E( MAC, "[SCHED][UE] error locking mutex for ue_thread_id %d (mutex_single_thread)\n",ue_thread_id); @@ -1253,6 +1252,11 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; } + if (UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis > 0) { + oai_nfapi_cqi_indication(&UL_INFO->cqi_ind); + UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0; + } + if(UL_INFO->harq_ind.harq_indication_body.number_of_harqs>0) { //LOG_D(MAC, "ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs); oai_nfapi_harq_indication(&UL_INFO->harq_ind); @@ -1267,30 +1271,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0; } - // Free UL_INFO messages - //if(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list != NULL){ - free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list); - UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL; - //} - //if(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list != NULL){ - free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list); - UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL; - //} - //if(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list !=NULL){ - free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list); - UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL; - //} - //if(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list!=NULL){ - free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list); - UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL; - //} - free(UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list); - UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = NULL; - free(UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list); - UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = NULL; - free(UL_INFO); - UL_INFO = NULL; - // De-allocate memory of nfapi requests copies before next subframe round if(dl_config_req!=NULL) { if(dl_config_req->vendor_extension!=NULL) { @@ -1308,6 +1288,13 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) } if(tx_request_pdu_list!=NULL) { + for (int i = 0; i < tx_req_num_elems; i++) { + for (int j = 0; j < tx_request_pdu_list[i].num_segments; j++) { + free(tx_request_pdu_list[i].segments[j].segment_data); + tx_request_pdu_list[i].segments[j].segment_data = NULL; + } + } + tx_req_num_elems = 0; free(tx_request_pdu_list); tx_request_pdu_list = NULL; } @@ -1334,6 +1321,22 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) } } + // Free UL_INFO messages + free(UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list); + UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = NULL; + free(UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list); + UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = NULL; + free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list); + UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL; + free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list); + UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL; + free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list); + UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL; + free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list); + UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL; + free(UL_INFO); + UL_INFO = NULL; + // thread finished free(arg); return &UE_thread_rxtx_retval;