IF_Module_L2_primitives_NB_IoT.c 3.68 KB
Newer Older
1
#include "IF_Module_L2_primitives_NB_IoT.h"
2
#include "LAYER2/MAC/proto_NB_IoT.h"
3
#include "LAYER2/MAC/extern_NB_IoT.h"
Nick Ho's avatar
Nick Ho committed
4 5


Nick Ho's avatar
Nick Ho committed
6
// Sched_INFO as a input for the scheduler
7
void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
8
{
AlanLi's avatar
AlanLi committed
9
    int i=0;
10
    uint32_t abs_subframe;
AlanLi's avatar
AlanLi committed
11
    Sched_Rsp_NB_IoT_t *SCHED_info = &mac_inst->Sched_INFO;;
12
    //UE_TEMPLATE_NB_IoT *UE_info;
13

14 15
    /* Disable uplink RX function for now

Nick Ho's avatar
Nick Ho committed
16
      //If there is a preamble, do the initiate RA procedure
AlanLi's avatar
AlanLi committed
17
      if(UL_INFO->NRACH.number_of_initial_scs_detected>0)
18
        {
AlanLi's avatar
AlanLi committed
19
          for(i=0;i<UL_INFO->NRACH.number_of_initial_scs_detected;i++)
20
            {
Nick Ho's avatar
Nick Ho committed
21
              // initiate_ra here, some useful inforamtion : 
AlanLi's avatar
AlanLi committed
22 23
              //(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc
              //(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance
24
              init_RA_NB_IoT(mac_inst,
AlanLi's avatar
AlanLi committed
25 26
                             (UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc,
                             (UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.nrach_ce_level,
27 28
                             UL_INFO->frame,
                             //timing_offset = Timing_advance * 16
AlanLi's avatar
AlanLi committed
29
                             (UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance*16
30 31
                             );

Nick Ho's avatar
Nick Ho committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45

            }
        }

        // crc indication if there is error for this round UL transmission

        if(UL_INFO->crc_ind.number_of_crcs>0)
        {
          for(i=0;i<UL_INFO->crc_ind.number_of_crcs;i++)
          {
            if((UL_INFO->crc_ind.crc_pdu_list+i)->crc_indication_rel8.crc_flag == 0)
            {
              //unsuccessfully received this UE PDU
              //UE_info = get_ue_from_rnti(mac_inst,((UL_INFO->crc_ind.crc_pdu_list)+i)->rx_ue_information.rnti);
46
              //UE_info->HARQ_round++;
47
            }
Nick Ho's avatar
Nick Ho committed
48
          }
49
        }
Nick Ho's avatar
Nick Ho committed
50

51
        //If there is a Uplink SDU which needs to send to MAC
Nick Ho's avatar
Nick Ho committed
52

Nick Ho's avatar
Nick Ho committed
53
        if(UL_INFO->RX_NPUSCH.number_of_pdus>0)
54
          {
Nick Ho's avatar
Nick Ho committed
55
            for(i=0;i<UL_INFO->RX_NPUSCH.number_of_pdus;i++)
56
              {
57
                //For MSG3, Normal Uplink Data, NAK
58 59 60 61 62 63
                rx_sdu_NB_IoT(UL_INFO->module_id,
                              UL_INFO->CC_id,
                              UL_INFO->frame,
                              UL_INFO->subframe,
                              (UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.rnti,
                              (UL_INFO->RX_NPUSCH.rx_pdu_list+i)->data,
Nick Ho's avatar
Nick Ho committed
64 65
                              (UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_indication_rel8.length
                             );
66 67

              }
68 69

          }
70

71
          */
72 73 74 75 76 77 78 79
    
    if(UL_INFO->hypersfn==1 && UL_INFO->frame==0)
    {
      LOG_I(MAC,"IF L2 hypersfn:%d frame: %d ,subframe: %d \n",UL_INFO->hypersfn,UL_INFO->frame,UL_INFO->subframe);
    }
    
    abs_subframe = UL_INFO->hypersfn*10240+UL_INFO->frame*10+UL_INFO->subframe +4;
    //abs_subframe = UL_INFO->frame*10+UL_INFO->subframe +4;
80

Nick Ho's avatar
Nick Ho committed
81
    //LOG_I(MAC,"Enter scheduler in subframe %d\n",abs_subframe);
Nick Ho's avatar
Nick Ho committed
82
    //scheduler here
83
    //Schedule subframe should be next four subframe, means that UL_INFO->frame*10+UL_INFO->subframe + 4
AlanLi's avatar
AlanLi committed
84
    
85
    eNB_dlsch_ulsch_scheduler_NB_IoT(mac_inst,abs_subframe);
AlanLi's avatar
AlanLi committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99
    mac_inst->if_inst_NB_IoT->schedule_response(&mac_inst->Sched_INFO);

    /*
    free(SCHED_info->TX_req->tx_request_body.tx_pdu_list);
    free(SCHED_info->HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list);
    free(SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list);
    free(SCHED_info->UL_req->ul_config_request_body.ul_config_pdu_list);
    
    free(SCHED_info->TX_req);
    free(SCHED_info->HI_DCI0_req);
    free(SCHED_info->DL_req);
    free(SCHED_info->UL_req);
    */
}