eNB_scheduler.c 21.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * 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
 */

22
/*! \file eNB_scheduler.c
nikaeinn's avatar
nikaeinn committed
23
 * \brief eNB scheduler top level function operates on per subframe basis
24
25
 * \author  Navid Nikaein and Raymond Knopp
 * \date 2010 - 2014
26
 * \email: navid.nikaein@eurecom.fr
27
28
 * \version 0.5
 * @ingroup _mac
29

30
 */
31

32
#include "assertions.h"
33
34
35
36
37
38
39
40
#include "PHY/defs.h"
#include "PHY/extern.h"

#include "SCHED/defs.h"
#include "SCHED/extern.h"

#include "LAYER2/MAC/defs.h"
#include "LAYER2/MAC/extern.h"
gauthier's avatar
gauthier committed
41

42
43
44
45
46
47
#include "LAYER2/MAC/proto.h"
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h"
#include "OCG.h"
#include "OCG_extern.h"
gauthier's avatar
gauthier committed
48

49
50
#include "RRC/LITE/extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
gauthier's avatar
gauthier committed
51

52
53
//#include "LAYER2/MAC/pre_processor.c"
#include "pdcp.h"
54

55
56
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
57
58
#endif

59
60
61
62
#define ENABLE_MAC_PAYLOAD_DEBUG
#define DEBUG_eNB_SCHEDULER 1
//#define DEBUG_HEADER_PARSING 1
//#define DEBUG_PACKET_TRACE 1
gauthier's avatar
gauthier committed
63

64
65
66
67
68
/*
  #ifndef USER_MODE
  #define msg debug_msg
  #endif
 */
gauthier's avatar
gauthier committed
69
70
71



72

73
74
75



76
77
void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP)  //, int calibration_flag) {
{
78

knopp's avatar
   
knopp committed
79
  int mbsfn_status[MAX_NUM_CCs];
80
  protocol_ctxt_t   ctxt;
81
#ifdef EXMIMO
Cedric Roux's avatar
Cedric Roux committed
82
  //int ret;
83
#endif
84
#if defined(ENABLE_ITTI)
85
  MessageDef   *msg_p;
86
  const char         *msg_name;
87
88
  instance_t    instance;
  int           result;
89
#endif
knopp's avatar
   
knopp committed
90
  DCI_PDU *DCI_pdu[MAX_NUM_CCs];
knopp's avatar
   
knopp committed
91
  int CC_id,i,next_i;
knopp's avatar
   
knopp committed
92
  UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list;
93
  rnti_t rnti;
94
  void         *DLSCH_dci=NULL;
95
  int size_bits=0,size_bytes=0;
96

97
  LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler (UE_list->head %d)\n",module_idP, frameP, subframeP,UE_list->head);
98

99
  start_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
gauthier's avatar
gauthier committed
100
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN);
101

102
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
103
104
    DCI_pdu[CC_id] = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
    mbsfn_status[CC_id]=0;
105
106
    // clear vrb_map
    memset(eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map,0,100);
knopp's avatar
   
knopp committed
107
  }
108

knopp's avatar
   
knopp committed
109
  // refresh UE list based on UEs dropped by PHY in previous subframe
110
111
112
  i = UE_list->head;

  while (i>=0) {
113
114
    rnti = UE_RNTI(module_idP, i);
    CC_id = UE_PCCID(module_idP, i);
115
116
117
118
    if ((frameP==0)&&(subframeP==0))
      LOG_I(MAC,"UE  rnti %x : %s\n", rnti, 
	    UE_list->UE_sched_ctrl[i].ul_out_of_sync==0 ? "in synch" : "out of sync");

119
    next_i= UE_list->next[i];
120

121
122
123
    PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]=-63;
    if (i==UE_list->head)
      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]); 
124
125
    // increment this, it is cleared when we receive an sdu
    eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].ul_inactivity_timer++;
126
127

    eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].cqi_req_timer++;
128
    
129
    if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) {
130
      //      mac_remove_ue(module_idP, i, frameP, subframeP);
131
    }
132
133
    else {
      // check uplink failure
Florian Kaltenberger's avatar
Florian Kaltenberger committed
134
135
136
137
138
139
140
      if ((UE_list->UE_sched_ctrl[i].ul_failure_timer>0)&&
	  (UE_list->UE_sched_ctrl[i].ul_out_of_sync==0)) {
	LOG_D(MAC,"UE %d rnti %x: UL Failure timer %d \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);
	if (UE_list->UE_sched_ctrl[i].ra_pdcch_order_sent==0) {
	  UE_list->UE_sched_ctrl[i].ra_pdcch_order_sent=1;
	  
	  // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe)
141
	  LOG_D(MAC,"UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d) \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);	    
Florian Kaltenberger's avatar
Florian Kaltenberger committed
142
143
	  DLSCH_dci = (void *)UE_list->UE_template[CC_id][i].DLSCH_DCI[0];
	  *(uint32_t*)DLSCH_dci = 0;
144
145
	  if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
	    switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
Florian Kaltenberger's avatar
Florian Kaltenberger committed
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
	    case 6:
	      ((DCI1A_1_5MHz_TDD_1_6_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_1_5MHz_TDD_1_6_t*)DLSCH_dci)->rballoc = 31;
	      size_bytes = sizeof(DCI1A_1_5MHz_TDD_1_6_t);
	      size_bits  = sizeof_DCI1A_1_5MHz_TDD_1_6_t;
	      break;
	    case 25:
	      ((DCI1A_5MHz_TDD_1_6_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_5MHz_TDD_1_6_t*)DLSCH_dci)->rballoc = 511;
	      size_bytes = sizeof(DCI1A_5MHz_TDD_1_6_t);
	      size_bits  = sizeof_DCI1A_5MHz_TDD_1_6_t;
	      break;
	    case 50:
	      ((DCI1A_10MHz_TDD_1_6_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_10MHz_TDD_1_6_t*)DLSCH_dci)->rballoc = 2047;
	      size_bytes = sizeof(DCI1A_10MHz_TDD_1_6_t);
	      size_bits  = sizeof_DCI1A_10MHz_TDD_1_6_t;
	      break;
	    case 100:
	      ((DCI1A_20MHz_TDD_1_6_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_20MHz_TDD_1_6_t*)DLSCH_dci)->rballoc = 8191;
	      size_bytes = sizeof(DCI1A_20MHz_TDD_1_6_t);
	      size_bits  = sizeof_DCI1A_20MHz_TDD_1_6_t;
	      break;
170
	    }
Florian Kaltenberger's avatar
Florian Kaltenberger committed
171
172
	  }
	  else { // FDD
173
	    switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
Florian Kaltenberger's avatar
Florian Kaltenberger committed
174
175
176
177
178
179
	    case 6:
	      ((DCI1A_1_5MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_1_5MHz_FDD_t*)DLSCH_dci)->rballoc = 31;
	      size_bytes = sizeof(DCI1A_1_5MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_1_5MHz_FDD_t;
	      break;
180
181
182
183
184
185
	    case 15:/*
	      ((DCI1A_2_5MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_2_5MHz_FDD_t*)DLSCH_dci)->rballoc = 31;
	      size_bytes = sizeof(DCI1A_1_5MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_1_5MHz_FDD_t;*/
	      break;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
186
187
188
189
190
191
192
193
194
195
196
	    case 25:
	      ((DCI1A_5MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_5MHz_FDD_t*)DLSCH_dci)->rballoc = 511;
	      size_bytes = sizeof(DCI1A_5MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_5MHz_FDD_t;
	      break;
	    case 50:
	      ((DCI1A_10MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_10MHz_FDD_t*)DLSCH_dci)->rballoc = 2047;
	      size_bytes = sizeof(DCI1A_10MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_10MHz_FDD_t;
197
		break;
198
199
200
201
202
203
	    case 75:
	      /*	      ((DCI1A_15MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_15MHz_FDD_t*)DLSCH_dci)->rballoc = 2047;
	      size_bytes = sizeof(DCI1A_10MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_10MHz_FDD_t;*/
		break;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
204
205
206
207
208
209
	    case 100:
	      ((DCI1A_20MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_20MHz_FDD_t*)DLSCH_dci)->rballoc = 8191;
	      size_bytes = sizeof(DCI1A_20MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_20MHz_FDD_t;
	      break;
210
211
	    }
	  }
Florian Kaltenberger's avatar
Florian Kaltenberger committed
212
213
214
215
216
217
218
219
220
	  
	  add_ue_spec_dci(DCI_pdu[CC_id],
			  DLSCH_dci,
			  rnti,
			    size_bytes,
			  process_ue_cqi (module_idP,i),//aggregation,
			  size_bits,
			  format1A,
			  0);
221
	}
Florian Kaltenberger's avatar
Florian Kaltenberger committed
222
	else { // ra_pdcch_sent==1
223
	  LOG_D(MAC,"UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);	    	    
Florian Kaltenberger's avatar
Florian Kaltenberger committed
224
225
	  if ((UE_list->UE_sched_ctrl[i].ul_failure_timer % 40) == 0)
	    UE_list->UE_sched_ctrl[i].ra_pdcch_order_sent=0; // resend every 4 frames	      
226
	}
227
228
229
230
231
      
	UE_list->UE_sched_ctrl[i].ul_failure_timer++;
	// check threshold
	if (UE_list->UE_sched_ctrl[i].ul_failure_timer > 200) {
	  // inform RRC of failure and clear timer
232
	  LOG_I(MAC,"UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);
233
234
235
236
	  mac_eNB_rrc_ul_failure(module_idP,CC_id,frameP,subframeP,rnti);
	  UE_list->UE_sched_ctrl[i].ul_failure_timer=0;
	  UE_list->UE_sched_ctrl[i].ul_out_of_sync=1;
	}
Florian Kaltenberger's avatar
Florian Kaltenberger committed
237
238
239
      }
    } // ul_failure_timer>0
    
240
    i = next_i;
knopp's avatar
   
knopp committed
241
  }
242

243
#if defined(ENABLE_ITTI)
244

245
  do {
246
247
    // Checks if a message has been sent to MAC sub-task
    itti_poll_msg (TASK_MAC_ENB, &msg_p);
248

249
250
251
    if (msg_p != NULL) {
      msg_name = ITTI_MSG_NAME (msg_p);
      instance = ITTI_MSG_INSTANCE (msg_p);
252

253
254
255
256
      switch (ITTI_MSG_ID(msg_p)) {
      case MESSAGE_TEST:
        LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p));
        break;
257

258
259
260
261
      case RRC_MAC_BCCH_DATA_REQ:
        LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
              msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
              RRC_MAC_BCCH_DATA_REQ (msg_p).frame, RRC_MAC_BCCH_DATA_REQ (msg_p).enb_index);
262

263
264
        // TODO process BCCH data req.
        break;
265

266
267
268
269
      case RRC_MAC_CCCH_DATA_REQ:
        LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
              msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
              RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index);
270

271
272
        // TODO process CCCH data req.
        break;
273
274
275

#ifdef Rel10

276
277
278
279
      case RRC_MAC_MCCH_DATA_REQ:
        LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d, mbsfn_sync_area %d\n",
              msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
              RRC_MAC_MCCH_DATA_REQ (msg_p).frame, RRC_MAC_MCCH_DATA_REQ (msg_p).enb_index, RRC_MAC_MCCH_DATA_REQ (msg_p).mbsfn_sync_area);
280

281
282
283
        // TODO process MCCH data req.
        break;
#endif
284

285
286
287
      default:
        LOG_E(MAC, "Received unexpected message %s\n", msg_name);
        break;
gauthier's avatar
gauthier committed
288
      }
289
290
291
292

      result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
      AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
    }
293
  } while(msg_p != NULL);
294

295
296
#endif

gauthier's avatar
gauthier committed
297
  // clear DCI and BCCH contents before scheduling
298
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
299
300
    DCI_pdu[CC_id]->Num_common_dci  = 0;
    DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
301

302

303
#ifdef Rel10
304
    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
305
#endif
306

knopp's avatar
   
knopp committed
307
308
    eNB_mac_inst[module_idP].frame    = frameP;
    eNB_mac_inst[module_idP].subframe = subframeP;
309
310


knopp's avatar
   
knopp committed
311
  }
312

gauthier's avatar
gauthier committed
313
  //if (subframeP%5 == 0)
knopp's avatar
   
knopp committed
314
  //#ifdef EXMIMO
315
  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, subframeP,module_idP);
316
  pdcp_run(&ctxt);
knopp's avatar
   
knopp committed
317
  //#endif
318

319
  // check HO
320
321
  rrc_rx_tx(&ctxt,
            0, // eNB index, unused in eNB
322
            CC_id);
323
324

#ifdef Rel10
325
326

  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
327
328
329
330
    if (eNB_mac_inst[module_idP].common_channels[CC_id].MBMS_flag >0) {
      start_meas(&eNB_mac_inst[module_idP].schedule_mch);
      mbsfn_status[CC_id] = schedule_MBMS(module_idP,CC_id,frameP,subframeP);
      stop_meas(&eNB_mac_inst[module_idP].schedule_mch);
knopp's avatar
   
knopp committed
331
    }
332
  }
333

334
#endif
knopp's avatar
   
knopp committed
335
  // refresh UE list based on UEs dropped by PHY in previous subframe
336
  /*
knopp's avatar
   
knopp committed
337
338
339
  i=UE_list->head;
  while (i>=0) {
    next_i = UE_list->next[i];
340
    LOG_T(MAC,"UE %d : rnti %x, stats %p\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i)));
knopp's avatar
   
knopp committed
341
    if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) {
knopp's avatar
   
knopp committed
342
      mac_remove_ue(module_idP,i,frameP);
knopp's avatar
   
knopp committed
343
344
345
    }
    i=next_i;
  }
346
  */
347

gauthier's avatar
gauthier committed
348
  switch (subframeP) {
349
  case 0:
350

351
    // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution)
gauthier's avatar
gauthier committed
352
    // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6)
353
    // Schedule Normal DLSCH
gauthier's avatar
gauthier committed
354

knopp's avatar
knopp committed
355

356
357
    schedule_RA(module_idP,frameP,subframeP,2);

358

359
    if (mac_xface->frame_parms->frame_type == FDD) {  //FDD
360
      schedule_ulsch(module_idP,frameP,cooperation_flag,0,4);//,calibration_flag);
361
362
363
    } else if  ((mac_xface->frame_parms->tdd_config == TDD) || //TDD
                (mac_xface->frame_parms->tdd_config == 3) ||
                (mac_xface->frame_parms->tdd_config == 6)) {
364
      //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);//,calibration_flag);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
365
    }
366

367
368
    schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
    fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
369

370
371
372
    break;

  case 1:
373

gauthier's avatar
gauthier committed
374
    // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6)
375
    // FDD, schedule normal UL/DLSCH
376
377
    if (mac_xface->frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
378
379
      case 0:
      case 1:
380
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
381
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
382
383
384
        break;

      case 6:
385
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
386
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
387
388
389
390
391
392
        break;

      default:
        break;
      }
    } else { //FDD
393
      schedule_ulsch(module_idP,frameP,cooperation_flag,1,5);
394
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
395
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
396
    }
397

398
    break;
399
400

  case 2:
401

gauthier's avatar
gauthier committed
402
    // TDD, nothing
403
    // FDD, normal UL/DLSCH
404
    if (mac_xface->frame_parms->frame_type == FDD) {  //FDD
405
      schedule_ulsch(module_idP,frameP,cooperation_flag,2,6);
406
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
407
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
408
    }
409

410
411
412
    break;

  case 3:
413

gauthier's avatar
gauthier committed
414
    // TDD Config 2, ULSCH for subframeP 7
415
416
    // TDD Config 2/5 normal DLSCH
    // FDD, normal UL/DLSCH
417
418
    if (mac_xface->frame_parms->frame_type == TDD) {
      switch (mac_xface->frame_parms->tdd_config) {
419
      case 2:
420
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
421
422
423

        // no break here!
      case 5:
424
425
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
426
427
428
429
430
431
        break;

      default:
        break;
      }
    } else { //FDD
432

433
      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7);
434
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
435
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
436
    }
437

438
    break;
439
440

  case 4:
441

gauthier's avatar
gauthier committed
442
    // TDD Config 1, ULSCH for subframeP 8
443
444
    // TDD Config 1/2/4/5 DLSCH
    // FDD UL/DLSCH
445
446
    if (mac_xface->frame_parms->frame_type == 1) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
447
      case 1:
448
        //        schedule_RA(module_idP,frameP,subframeP);
449
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
450
451
452
453
454
455
456
457
458

        // no break here!
      case 2:

        // no break here!
      case 4:

        // no break here!
      case 5:
knopp's avatar
knopp committed
459

460
461
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
462
463
464
465
466
467
        break;

      default:
        break;
      }
    } else {
468
      if (mac_xface->frame_parms->frame_type == FDD) {  //FDD
469

470
	schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8);
471
	schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
472
        fill_DLSCH_dci(module_idP, frameP, subframeP,   mbsfn_status);
473
      }
474
    }
475

476
477
478
479
480
481
482
    break;

  case 5:
    // TDD/FDD Schedule SI
    // TDD Config 0,6 ULSCH for subframes 9,3 resp.
    // TDD normal DLSCH
    // FDD normal UL/DLSCH
483
    schedule_SI(module_idP,frameP,subframeP);
484

485
    //schedule_RA(module_idP,frameP,subframeP,5);
486
    if (mac_xface->frame_parms->frame_type == FDD) {
487
488
489
490
      schedule_RA(module_idP,frameP,subframeP,1);
      schedule_ulsch(module_idP,frameP,cooperation_flag,5,9);
      schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
491
492
    } else if ((mac_xface->frame_parms->tdd_config == 0) || // TDD Config 0
               (mac_xface->frame_parms->tdd_config == 6)) { // TDD Config 6
493
      //schedule_ulsch(module_idP,cooperation_flag,subframeP);
494
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
495
    } else {
496
497
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
498
    }
499

500
501
502
    break;

  case 6:
503

504
505
506
    // TDD Config 0,1,6 ULSCH for subframes 2,3
    // TDD Config 3,4,5 Normal DLSCH
    // FDD normal ULSCH/DLSCH
507
508
    if (mac_xface->frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
509
510
511
512
      case 0:
        break;

      case 1:
513
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
514
515
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
516
517
518
        break;

      case 6:
519
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
520
521
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
522
523
524
        break;

      case 5:
525
526
527
        schedule_RA(module_idP,frameP,subframeP,2);
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
528
529
530
531
        break;

      case 3:
      case 4:
532
533
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
534
535
536
537
538
539
        break;

      default:
        break;
      }
    } else { //FDD
540
      schedule_ulsch(module_idP,frameP,cooperation_flag,6,0);
541
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
542
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
543
    }
544

545
    break;
gauthier's avatar
gauthier committed
546

547
  case 7:
548

549
550
    // TDD Config 3,4,5 Normal DLSCH
    // FDD Normal UL/DLSCH
551
552
    if (mac_xface->frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
553
554
      case 3:
      case 4:
555
556
557
        schedule_RA(module_idP,frameP,subframeP,3);  // 3 = Msg3 subframeP, not
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
558
559
560
        break;

      case 5:
561
562
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
563
564
565
566
567
568
        break;

      default:
        break;
      }
    } else { //FDD
569
      schedule_ulsch(module_idP,frameP,cooperation_flag,7,1);
570
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
571
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
572
    }
573

574
575
576
    break;

  case 8:
577

gauthier's avatar
gauthier committed
578
    // TDD Config 2,3,4,5 ULSCH for subframeP 2
579
580
    //
    // FDD Normal UL/DLSCH
581
582
    if (mac_xface->frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
583
584
585
586
587
      case 2:
      case 3:
      case 4:
      case 5:

588
        //  schedule_RA(module_idP,subframeP);
589
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
590
591
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
592
593
594
595
596
597
        break;

      default:
        break;
      }
    } else { //FDD
598
      schedule_ulsch(module_idP,frameP,cooperation_flag,8,2);
599
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
600
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
601
    }
602

603
604
605
    break;

  case 9:
606

607
    // TDD Config 1,3,4,6 ULSCH for subframes 3,3,3,4
608
609
    if (mac_xface->frame_parms->frame_type == TDD) {
      switch (mac_xface->frame_parms->tdd_config) {
610
      case 1:
611
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
612
613
614
        schedule_RA(module_idP,frameP,subframeP,7);  // 7 = Msg3 subframeP, not
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
615
616
617
618
        break;

      case 3:
      case 4:
619
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
620
621
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
622
623
624
        break;

      case 6:
625
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);
626
627
628
        //schedule_RA(module_idP,frameP,subframeP);
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
629
630
631
632
        break;

      case 2:
      case 5:
633
634
635
        //schedule_RA(module_idP,frameP,subframeP);
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
636
637
638
639
640
641
        break;

      default:
        break;
      }
    } else { //FDD
642
      schedule_ulsch(module_idP,frameP,cooperation_flag,9,3);
643
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
644
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
645
    }
646

647
    break;
gauthier's avatar
gauthier committed
648

649
  }
650

651
  LOG_D(MAC,"FrameP %d, subframeP %d : Scheduling CCEs\n",frameP,subframeP);
652

653
  // Allocate CCEs for good after scheduling is done
654
655
  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++)
    allocate_CCEs(module_idP,CC_id,subframeP,0);
656

657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
  /*
  int dummy=0;
  for (i=0;
       i<DCI_pdu[CC_id]->Num_common_dci+DCI_pdu[CC_id]->Num_ue_spec_dci;
       i++)
    if (DCI_pdu[CC_id]->dci_alloc[i].rnti==2)
      dummy=1;
	
  if (dummy==1)
    for (i=0;
	 i<DCI_pdu[CC_id]->Num_common_dci+DCI_pdu[CC_id]->Num_ue_spec_dci;
	 i++)
      LOG_I(MAC,"Frame %d, subframe %d: DCI %d/%d, format %d, rnti %x, NCCE %d(num_pdcch_symb %d)\n",
	    frameP,subframeP,i,DCI_pdu[CC_id]->Num_common_dci+DCI_pdu[CC_id]->Num_ue_spec_dci,
	    DCI_pdu[CC_id]->dci_alloc[i].format,
	    DCI_pdu[CC_id]->dci_alloc[i].rnti,
	    DCI_pdu[CC_id]->dci_alloc[i].firstCCE,
	    DCI_pdu[CC_id]->num_pdcch_symbols);


677
  LOG_D(MAC,"frameP %d, subframeP %d\n",frameP,subframeP);
678
  */
679

680
  stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
gauthier's avatar
gauthier committed
681
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);
682

683
}
684
685
686