gNB_scheduler_phytest.c 7.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * 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.0  (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
 */

/*! \file gNB_scheduler_phytest.c
 * \brief gNB scheduling procedures in phy_test mode
 * \author  Guy De Souza
 * \date 07/2018
 * \email: desouza@eurecom.fr
 * \version 1.0
 * @ingroup _mac
 */

#include "nr_mac_gNB.h"
Guy De Souza's avatar
Guy De Souza committed
32
#include "SCHED_NR/sched_nr.h"
Guy De Souza's avatar
Guy De Souza committed
33
34
#include "PHY/NR_TRANSPORT/nr_dlsch.h"
#include "PHY/NR_TRANSPORT/nr_dci.h"
35
36
37
38

extern RAN_CONTEXT_t RC;

/*Scheduling of DLSCH with associated DCI in common search space
Guy De Souza's avatar
Guy De Souza committed
39
 * current version has only a DCI for type 1 PDCCH for C_RNTI*/
40
41
42
43
44
45
void nr_schedule_css_dlsch_phytest(module_id_t   module_idP,
                                   frame_t       frameP,
                                   sub_frame_t   subframeP)
{
  uint8_t  CC_id;

Guy De Souza's avatar
Guy De Souza committed
46
  gNB_MAC_INST                        *nr_mac      = RC.nrmac[module_idP];
yilmazt's avatar
yilmazt committed
47
  //NR_COMMON_channels_t                *cc           = nr_mac->common_channels;
48
  nfapi_nr_dl_config_request_body_t   *dl_req;
Guy De Souza's avatar
Guy De Souza committed
49
50
  nfapi_nr_dl_config_request_pdu_t  *dl_config_dci_pdu;
  nfapi_nr_dl_config_request_pdu_t  *dl_config_dlsch_pdu;
Guy De Souza's avatar
Guy De Souza committed
51
  nfapi_tx_request_pdu_t            *TX_req;
knopp's avatar
knopp committed
52
53
  nfapi_nr_config_request_t *cfg = &nr_mac->config[0];

Guy De Souza's avatar
Guy De Souza committed
54
  uint16_t sfn_sf = frameP << 4 | subframeP;
Guy De Souza's avatar
Guy De Souza committed
55
  uint16_t rnti = 0x1234;
knopp's avatar
knopp committed
56
  int dl_carrier_bandwidth = cfg->rf_config.dl_carrier_bandwidth.value;
57

knopp's avatar
knopp committed
58
59
60
61
  // everything here is hard-coded to 30 kHz
  int scs = kHz30;
  int mu = 1;
  int slots_per_frame = 10 * (1<<mu);
62
63
64
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
    LOG_I(MAC, "Scheduling common search space DCI type 1 for CC_id %d\n",CC_id);

knopp's avatar
knopp committed
65
66


67

Guy De Souza's avatar
Guy De Souza committed
68
    dl_req = &nr_mac->DL_req[CC_id].dl_config_request_body;
Guy De Souza's avatar
Guy De Souza committed
69
70
71
72
    dl_config_dci_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
    memset((void*)dl_config_dci_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t));
    dl_config_dci_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE;
    dl_config_dci_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dci_dl_pdu));
73

Guy De Souza's avatar
Guy De Souza committed
74
75
76
77
78
79
80
81
    dl_config_dlsch_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu+1];
    memset((void*)dl_config_dlsch_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t));
    dl_config_dlsch_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE;
    dl_config_dlsch_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dlsch_pdu));

    nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_dci_pdu->dci_dl_pdu.dci_dl_pdu_rel15;
    nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_dci_pdu->dci_dl_pdu.pdcch_params_rel15;
    nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15;
Guy De Souza's avatar
Guy De Souza committed
82
83

    dlsch_pdu_rel15->start_prb = 0;
Guy De Souza's avatar
Guy De Souza committed
84
    dlsch_pdu_rel15->n_prb = 50;
85
    dlsch_pdu_rel15->start_symbol = 2;
86
    dlsch_pdu_rel15->nb_symbols = 10;
Guy De Souza's avatar
Guy De Souza committed
87
    dlsch_pdu_rel15->rnti = rnti;
Guy De Souza's avatar
Guy De Souza committed
88
89
    dlsch_pdu_rel15->nb_layers =1;
    dlsch_pdu_rel15->nb_codewords = 1;
90
    dlsch_pdu_rel15->mcs_idx = 9;
Guy De Souza's avatar
Guy De Souza committed
91
92
    dlsch_pdu_rel15->ndi = 1;
    dlsch_pdu_rel15->redundancy_version = 0;
Guy De Souza's avatar
Guy De Souza committed
93

knopp's avatar
knopp committed
94
95
96
97
    nr_configure_css_dci_from_mib(params_rel15,
				  scs, scs, nr_FR1, 0, 0,
				  slots_per_frame,
				  dl_carrier_bandwidth);
98

Guy De Souza's avatar
Guy De Souza committed
99
    pdu_rel15->frequency_domain_assignment = get_RIV(dlsch_pdu_rel15->start_prb, dlsch_pdu_rel15->n_prb, cfg->rf_config.dl_carrier_bandwidth.value);
Guy De Souza's avatar
Guy De Souza committed
100
    pdu_rel15->time_domain_assignment = get_SLIV(dlsch_pdu_rel15->start_symbol, dlsch_pdu_rel15->nb_symbols);
101
    pdu_rel15->vrb_to_prb_mapping = 1;
Guy De Souza's avatar
Guy De Souza committed
102
    pdu_rel15->mcs = 9;
103
    pdu_rel15->tb_scaling = 1;
104
105
106
107
    
    pdu_rel15->ra_preamble_index = 25;
    pdu_rel15->format_indicator = 1;
    pdu_rel15->ndi = 1;
Guy De Souza's avatar
Guy De Souza committed
108
109
    pdu_rel15->rv = 0;
    pdu_rel15->harq_pid = 0;
110
111
112
113
114
    pdu_rel15->dai = 2;
    pdu_rel15->tpc = 2;
    pdu_rel15->pucch_resource_indicator = 7;
    pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7;

Guy De Souza's avatar
Guy De Souza committed
115
    LOG_I(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n",
Guy De Souza's avatar
Guy De Souza committed
116
117
                pdu_rel15->frequency_domain_assignment,
                pdu_rel15->time_domain_assignment,
118
                pdu_rel15->vrb_to_prb_mapping,
Guy De Souza's avatar
Guy De Souza committed
119
                pdu_rel15->mcs,
Guy De Souza's avatar
Guy De Souza committed
120
121
122
                pdu_rel15->tb_scaling,
                pdu_rel15->ndi,
                pdu_rel15->rv);
123

Guy De Souza's avatar
Guy De Souza committed
124
    params_rel15->rnti = rnti;
125
    params_rel15->rnti_type = NFAPI_NR_RNTI_C;
126
    params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0;
Guy De Souza's avatar
Guy De Souza committed
127
    //params_rel15->aggregation_level = 1;
Hongzhi's avatar
Hongzhi committed
128
    LOG_D(MAC, "DCI type 1 params: rmsi_pdcch_config %d, rnti %d, rnti_type %d, dci_format %d\n \
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
                coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d  \n \
                ss params : nb_ss_sets_per_slot %d, first symb %d, nb_slots %d, sfn_mod2 %d, first slot %d\n",
                0,
                params_rel15->rnti,
                params_rel15->rnti_type,
                params_rel15->dci_format,
                params_rel15->mux_pattern,
                params_rel15->n_rb,
                params_rel15->n_symb,
                params_rel15->rb_offset,
                params_rel15->nb_ss_sets_per_slot,
                params_rel15->first_symbol,
                params_rel15->nb_slots,
                params_rel15->sfn_mod2,
                params_rel15->first_slot);
Guy De Souza's avatar
Guy De Souza committed
144
  nr_get_tbs(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu, *cfg);
Guy De Souza's avatar
Guy De Souza committed
145
146
147
148
149
  LOG_I(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d\n",
  dlsch_pdu_rel15->start_prb,
  dlsch_pdu_rel15->n_prb,
  dlsch_pdu_rel15->start_symbol,
  dlsch_pdu_rel15->nb_symbols,
150
  dlsch_pdu_rel15->nb_layers,
Guy De Souza's avatar
Guy De Souza committed
151
  dlsch_pdu_rel15->nb_codewords,
152
  dlsch_pdu_rel15->mcs_idx);
Guy De Souza's avatar
Guy De Souza committed
153

Guy De Souza's avatar
Guy De Souza committed
154
  dl_req->number_dci++;
Guy De Souza's avatar
Guy De Souza committed
155
156
  dl_req->number_pdsch_rnti++;
  dl_req->number_pdu+=2;
Guy De Souza's avatar
Guy De Souza committed
157
158
159
160
161
162

  TX_req = &nr_mac->TX_req[CC_id].tx_request_body.tx_pdu_list[nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus];
  TX_req->pdu_length = 6;
  TX_req->pdu_index = nr_mac->pdu_index[CC_id]++;
  TX_req->num_segments = 1;
  TX_req->segments[0].segment_length = 8;
Guy De Souza's avatar
Guy De Souza committed
163
164
165
166
167
168
169
170
171
172
  nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus++;
  nr_mac->TX_req[CC_id].sfn_sf = sfn_sf;
  nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
  nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST;

  TX_req = &nr_mac->TX_req[CC_id].tx_request_body.tx_pdu_list[nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus+1];
  TX_req->pdu_length = dlsch_pdu_rel15->transport_block_size;
  TX_req->pdu_index = nr_mac->pdu_index[CC_id]++;
  TX_req->num_segments = 1;
  TX_req->segments[0].segment_length = 8;
Guy De Souza's avatar
Guy De Souza committed
173
174
175
176
  nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus++;
  nr_mac->TX_req[CC_id].sfn_sf = sfn_sf;
  nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
  nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST;
177
178
179
    
  }
}