eNB_scheduler.c 34.3 KB
Newer Older
1
/*******************************************************************************
nikaeinn's avatar
nikaeinn committed
2
3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
4

nikaeinn's avatar
nikaeinn committed
5
6
7
8
    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
9
10


nikaeinn's avatar
nikaeinn committed
11
12
13
14
    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
15

nikaeinn's avatar
nikaeinn committed
16
17
18
19
    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
    included in this distribution in the file called "COPYING". If not,
    see <http://www.gnu.org/licenses/>.
20
21

  Contact Information
nikaeinn's avatar
nikaeinn committed
22
23
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
nikaeinn's avatar
nikaeinn committed
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
27

nikaeinn's avatar
nikaeinn committed
28
*******************************************************************************/
29
/*! \file eNB_scheduler.c
nikaeinn's avatar
nikaeinn committed
30
 * \brief eNB scheduler top level function operates on per subframe basis
31
32
 * \author  Navid Nikaein and Raymond Knopp
 * \date 2010 - 2014
33
 * \email: navid.nikaein@eurecom.fr
34
35
 * \version 0.5
 * @ingroup _mac
36

37
 */
38

39
#include "assertions.h"
40
41
42
43
44
45
46
47
#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
48

49
50
51
52
53
54
#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
55

56
57
#include "RRC/LITE/extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
gauthier's avatar
gauthier committed
58

59
60
//#include "LAYER2/MAC/pre_processor.c"
#include "pdcp.h"
61

62
63
64
65
//Agent-related headers
#include "ENB_APP/enb_agent_extern.h"
#include "ENB_APP/enb_agent_mac.h"

66
67
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
68
69
#endif

70
71
#define ENABLE_MAC_PAYLOAD_DEBUG
#define DEBUG_eNB_SCHEDULER 1
72
#define ENABLE_ENB_AGENT_DL_SCHEDULER
73

74
75
//#define DEBUG_HEADER_PARSING 1
//#define DEBUG_PACKET_TRACE 1
gauthier's avatar
gauthier committed
76

77
78
79
80
81
/*
  #ifndef USER_MODE
  #define msg debug_msg
  #endif
 */
gauthier's avatar
gauthier committed
82
83
84



85

86
87
88



89
90
void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP)  //, int calibration_flag) {
{
91

knopp's avatar
   
knopp committed
92
  int mbsfn_status[MAX_NUM_CCs];
93
  protocol_ctxt_t   ctxt;
94
#ifdef EXMIMO
95
  int ret;
96
#endif
97
#if defined(ENABLE_ITTI)
98
99
100
101
  MessageDef   *msg_p;
  const char   *msg_name;
  instance_t    instance;
  int           result;
102
#endif
knopp's avatar
   
knopp committed
103
  DCI_PDU *DCI_pdu[MAX_NUM_CCs];
knopp's avatar
   
knopp committed
104
  int CC_id,i,next_i;
knopp's avatar
   
knopp committed
105
  UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list;
106
  rnti_t rnti;
107

108
109
  Protocol__ProgranMessage *msg;

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

112
  start_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
gauthier's avatar
gauthier committed
113
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN);
114

115
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
116
    DCI_pdu[CC_id] = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
117
118
    DCI_pdu[CC_id]->nCCE=0;
    DCI_pdu[CC_id]->num_pdcch_symbols=1;
knopp's avatar
   
knopp committed
119
    mbsfn_status[CC_id]=0;
120
121
    // clear vrb_map
    memset(eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map,0,100);
knopp's avatar
   
knopp committed
122
  }
123

knopp's avatar
   
knopp committed
124
  // refresh UE list based on UEs dropped by PHY in previous subframe
125
126
127
  i = UE_list->head;

  while (i>=0) {
128
129
130
131
    rnti = UE_RNTI(module_idP, i);
    CC_id = UE_PCCID(module_idP, i);
    LOG_D(MAC,"UE %d: rnti %x (%p)\n", i, rnti,
          mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti));
132
    next_i= UE_list->next[i];
133

134
135
    if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) {
      mac_remove_ue(module_idP, i, frameP, subframeP);
136
137
    }
    i = next_i;
knopp's avatar
   
knopp committed
138
  }
139

140
#if defined(ENABLE_ITTI)
141

142
  do {
143
144
    // Checks if a message has been sent to MAC sub-task
    itti_poll_msg (TASK_MAC_ENB, &msg_p);
145

146
147
148
    if (msg_p != NULL) {
      msg_name = ITTI_MSG_NAME (msg_p);
      instance = ITTI_MSG_INSTANCE (msg_p);
149

150
151
152
153
      switch (ITTI_MSG_ID(msg_p)) {
      case MESSAGE_TEST:
        LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p));
        break;
154

155
156
157
158
      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);
159

160
161
        // TODO process BCCH data req.
        break;
162

163
164
165
166
      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);
167

168
169
        // TODO process CCCH data req.
        break;
170
171
172

#ifdef Rel10

173
174
175
176
      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);
177

178
179
180
        // TODO process MCCH data req.
        break;
#endif
181

182
183
184
      default:
        LOG_E(MAC, "Received unexpected message %s\n", msg_name);
        break;
gauthier's avatar
gauthier committed
185
      }
186
187
188
189

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

192
193
#endif

gauthier's avatar
gauthier committed
194
  // clear DCI and BCCH contents before scheduling
195
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
196
197
    DCI_pdu[CC_id]->Num_common_dci  = 0;
    DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
198

199

200
#ifdef Rel10
201
    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
202
#endif
203

knopp's avatar
   
knopp committed
204
205
    eNB_mac_inst[module_idP].frame    = frameP;
    eNB_mac_inst[module_idP].subframe = subframeP;
206
207


knopp's avatar
   
knopp committed
208
  }
209

gauthier's avatar
gauthier committed
210
  //if (subframeP%5 == 0)
knopp's avatar
   
knopp committed
211
  //#ifdef EXMIMO
212
  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,module_idP);
213
  pdcp_run(&ctxt);
knopp's avatar
   
knopp committed
214
  //#endif
215

216
  // check HO
217
218
  rrc_rx_tx(&ctxt,
            0, // eNB index, unused in eNB
219
            CC_id);
220
221

#ifdef Rel10
222
223

  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
224
225
226
227
    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
228
    }
229
  }
230

231
#endif
knopp's avatar
   
knopp committed
232
  // refresh UE list based on UEs dropped by PHY in previous subframe
233
  /*
knopp's avatar
   
knopp committed
234
235
236
  i=UE_list->head;
  while (i>=0) {
    next_i = UE_list->next[i];
237
    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
238
    if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) {
knopp's avatar
   
knopp committed
239
      mac_remove_ue(module_idP,i,frameP);
knopp's avatar
   
knopp committed
240
241
242
    }
    i=next_i;
  }
243
  */
244

gauthier's avatar
gauthier committed
245
  switch (subframeP) {
246
  case 0:
247

248
    // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution)
gauthier's avatar
gauthier committed
249
    // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6)
250
    // Schedule Normal DLSCH
gauthier's avatar
gauthier committed
251

knopp's avatar
knopp committed
252

253
254
    schedule_RA(module_idP,frameP,subframeP,2);

255
256

    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
257
      schedule_ulsch(module_idP,frameP,cooperation_flag,0,4);//,calibration_flag);
258
259
260
    } else if  ((mac_xface->lte_frame_parms->tdd_config == TDD) || //TDD
                (mac_xface->lte_frame_parms->tdd_config == 3) ||
                (mac_xface->lte_frame_parms->tdd_config == 6)) {
261
      //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);//,calibration_flag);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
262
    }
263
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
264
265
    schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
    fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#else
    if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
284
285
286
    break;

  case 1:
287

gauthier's avatar
gauthier committed
288
    // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6)
289
290
    // FDD, schedule normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
291
292
293
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
      case 1:
294
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
295
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
296
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
297
#endif
298
299
300
        break;

      case 6:
301
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
302
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
303
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
304
#endif
305
306
307
308
309
310
        break;

      default:
        break;
      }
    } else { //FDD
311
      schedule_ulsch(module_idP,frameP,cooperation_flag,1,5);
312
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
313
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
314
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
333
    }
334

335
    break;
336
337

  case 2:
338

gauthier's avatar
gauthier committed
339
    // TDD, nothing
340
341
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
342
      schedule_ulsch(module_idP,frameP,cooperation_flag,2,6);
343
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
344
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
345
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
364
    }
365

366
367
368
    break;

  case 3:
369

gauthier's avatar
gauthier committed
370
    // TDD Config 2, ULSCH for subframeP 7
371
372
373
    // TDD Config 2/5 normal DLSCH
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
374
375
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
376
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
377
378
379

        // no break here!
      case 5:
380
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
381
382
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
401
402
403
404
405
406
        break;

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

408
      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7);
409
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
410
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
411
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
430
    }
431

432
    break;
433
434

  case 4:
435

gauthier's avatar
gauthier committed
436
    // TDD Config 1, ULSCH for subframeP 8
437
438
439
    // TDD Config 1/2/4/5 DLSCH
    // FDD UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == 1) { // TDD
440
441
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
442
        //        schedule_RA(module_idP,frameP,subframeP);
443
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
444
445
446
447
448
449
450
451
452

        // no break here!
      case 2:

        // no break here!
      case 4:

        // no break here!
      case 5:
453
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
454
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
	fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif	
474
475
476
477
478
479
480
481
        break;

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

482
483
	//        schedule_RA(module_idP,frameP, subframeP, 0);
	schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8);
484
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
485
	schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
486
        fill_DLSCH_dci(module_idP, frameP, subframeP,   mbsfn_status);
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}     
#endif
505
      }
506
    }
507

508
509
510
511
512
513
514
    break;

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

517
    //schedule_RA(module_idP,frameP,subframeP,5);
518
    if (mac_xface->lte_frame_parms->frame_type == FDD) {
519
520
      schedule_RA(module_idP,frameP,subframeP,1);
      schedule_ulsch(module_idP,frameP,cooperation_flag,5,9);
521
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
522
523
      schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
542
543
    } else if ((mac_xface->lte_frame_parms->tdd_config == 0) || // TDD Config 0
               (mac_xface->lte_frame_parms->tdd_config == 6)) { // TDD Config 6
544
      //schedule_ulsch(module_idP,cooperation_flag,subframeP);
545
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
546
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
547
#endif
548
    } else {
549
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
550
551
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
570
    }
571

572
573
574
    break;

  case 6:
575

576
577
578
579
    // TDD Config 0,1,6 ULSCH for subframes 2,3
    // TDD Config 3,4,5 Normal DLSCH
    // FDD normal ULSCH/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
580
581
582
583
584
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
        break;

      case 1:
585
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
586
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
587
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
588
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
589
#endif
590
591
592
        break;

      case 6:
593
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
594
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
595
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
596
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
597
#endif
598
599
600
        break;

      case 5:
601
        schedule_RA(module_idP,frameP,subframeP,2);
602
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
603
604
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
623
624
625
626
        break;

      case 3:
      case 4:
627
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
628
629
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
648
649
650
651
652
653
        break;

      default:
        break;
      }
    } else { //FDD
654
      //      schedule_ulsch(module_idP,frameP,cooperation_flag,6,0);
655
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
656
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
657
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
676
    }
677

678
    break;
gauthier's avatar
gauthier committed
679

680
  case 7:
681

682
683
684
    // TDD Config 3,4,5 Normal DLSCH
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
685
686
687
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 3:
      case 4:
688
        schedule_RA(module_idP,frameP,subframeP,3);  // 3 = Msg3 subframeP, not
689
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
690
691
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
710
711
712
        break;

      case 5:
713
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
714
715
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
734
735
736
737
738
739
        break;

      default:
        break;
      }
    } else { //FDD
740
      //schedule_ulsch(module_idP,frameP,cooperation_flag,7,1);
741
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
742
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
743
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
762
    }
763

764
765
766
    break;

  case 8:
767

gauthier's avatar
gauthier committed
768
    // TDD Config 2,3,4,5 ULSCH for subframeP 2
769
770
771
    //
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
772
773
774
775
776
777
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
      case 3:
      case 4:
      case 5:

778
        //  schedule_RA(module_idP,subframeP);
779
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
780
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
781
782
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
801
802
803
804
805
806
        break;

      default:
        break;
      }
    } else { //FDD
807
      //schedule_ulsch(module_idP,frameP,cooperation_flag,8,2);
808
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
809
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
810
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
829
    }
830

831
832
833
    break;

  case 9:
834

835
836
    // TDD Config 1,3,4,6 ULSCH for subframes 3,3,3,4
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
837
838
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
839
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
840
        schedule_RA(module_idP,frameP,subframeP,7);  // 7 = Msg3 subframeP, not
841
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
842
843
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
862
863
864
865
        break;

      case 3:
      case 4:
866
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
867
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
868
869
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
888
889
890
        break;

      case 6:
891
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);
892
        //schedule_RA(module_idP,frameP,subframeP);
893
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
894
895
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
914
915
916
917
        break;

      case 2:
      case 5:
918
        //schedule_RA(module_idP,frameP,subframeP);
919
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
920
921
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
940
941
942
943
944
945
        break;

      default:
        break;
      }
    } else { //FDD
946
      //     schedule_ulsch(module_idP,frameP,cooperation_flag,9,3);
947
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
948
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
949
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
	  apply_scheduling_decisions(module_idP,
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
      }
#endif
968
    }
969

970
    break;
gauthier's avatar
gauthier committed
971

972
  }
973

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

976
  // Allocate CCEs for good after scheduling is done
977
978
  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++)
    allocate_CCEs(module_idP,CC_id,subframeP,0);
979

980
  LOG_D(MAC,"frameP %d, subframeP %d\n",frameP,subframeP);
981

982
  stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
gauthier's avatar
gauthier committed
983
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);
984

985
}
986
987
988