eNB_scheduler.c 34.9 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
//Agent-related headers
nikaeinn's avatar
nikaeinn committed
63
64
65
#include "enb_agent_extern.h"
#include "enb_agent_mac.h"
#include "enb_agent_mac_proto.h"
66

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

71
72
#define ENABLE_MAC_PAYLOAD_DEBUG
#define DEBUG_eNB_SCHEDULER 1
73
#define ENABLE_ENB_AGENT_DL_SCHEDULER
74
//#define DISABLE_SF_TRIGGER
75

76
77
//#define DEBUG_HEADER_PARSING 1
//#define DEBUG_PACKET_TRACE 1
gauthier's avatar
gauthier committed
78

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



87

88
89
90



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

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

110
111
  Protocol__ProgranMessage *msg;

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

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

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

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

  while (i>=0) {
130
131
132
133
    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));
134
    next_i= UE_list->next[i];
135

136
137
    if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) {
      mac_remove_ue(module_idP, i, frameP, subframeP);
138
139
140
141
142
143
      //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future
      if (mac_agent_registered[module_idP]) {
	agent_mac_xface[module_idP]->enb_agent_notify_ue_state_change(module_idP,
								      rnti,
								      PROTOCOL__PRP_UE_STATE_CHANGE_TYPE__PRUESC_DEACTIVATED);
      }
144
145
    }
    i = next_i;
knopp's avatar
   
knopp committed
146
  }
147

148
#if defined(ENABLE_ITTI)
149

150
  do {
151
152
    // Checks if a message has been sent to MAC sub-task
    itti_poll_msg (TASK_MAC_ENB, &msg_p);
153

154
155
156
    if (msg_p != NULL) {
      msg_name = ITTI_MSG_NAME (msg_p);
      instance = ITTI_MSG_INSTANCE (msg_p);
157

158
159
160
161
      switch (ITTI_MSG_ID(msg_p)) {
      case MESSAGE_TEST:
        LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p));
        break;
162

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

168
169
        // TODO process BCCH data req.
        break;
170

171
172
173
174
      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);
175

176
177
        // TODO process CCCH data req.
        break;
178
179
180

#ifdef Rel10

181
182
183
184
      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);
185

186
187
188
        // TODO process MCCH data req.
        break;
#endif
189

190
191
192
      default:
        LOG_E(MAC, "Received unexpected message %s\n", msg_name);
        break;
gauthier's avatar
gauthier committed
193
      }
194
195
196
197

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

200
201
#endif

gauthier's avatar
gauthier committed
202
  // clear DCI and BCCH contents before scheduling
203
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
204
205
    DCI_pdu[CC_id]->Num_common_dci  = 0;
    DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
206

207

208
#ifdef Rel10
209
    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
210
#endif
211

knopp's avatar
   
knopp committed
212
213
    eNB_mac_inst[module_idP].frame    = frameP;
    eNB_mac_inst[module_idP].subframe = subframeP;
214
215


knopp's avatar
   
knopp committed
216
  }
217
218
219
220
221
222
223
224
  
#ifndef DISABLE_SF_TRIGGER
  //Send subframe trigger to the controller
  if (mac_agent_registered[module_idP]) {
    agent_mac_xface[module_idP]->enb_agent_send_sf_trigger(module_idP);
  }
#endif
  
gauthier's avatar
gauthier committed
225
  //if (subframeP%5 == 0)
knopp's avatar
   
knopp committed
226
  //#ifdef EXMIMO
227
  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,module_idP);
228
  pdcp_run(&ctxt);
knopp's avatar
   
knopp committed
229
  //#endif
230

231
  // check HO
232
233
  rrc_rx_tx(&ctxt,
            0, // eNB index, unused in eNB
234
            CC_id);
235
236

#ifdef Rel10
237
238

  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
239
240
241
242
    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
243
    }
244
  }
245

246
#endif
knopp's avatar
   
knopp committed
247
  // refresh UE list based on UEs dropped by PHY in previous subframe
248
  /*
knopp's avatar
   
knopp committed
249
250
251
  i=UE_list->head;
  while (i>=0) {
    next_i = UE_list->next[i];
252
    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
253
    if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) {
knopp's avatar
   
knopp committed
254
      mac_remove_ue(module_idP,i,frameP);
knopp's avatar
   
knopp committed
255
256
257
    }
    i=next_i;
  }
258
  */
259

gauthier's avatar
gauthier committed
260
  switch (subframeP) {
261
  case 0:
262

263
    // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution)
gauthier's avatar
gauthier committed
264
    // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6)
265
    // Schedule Normal DLSCH
gauthier's avatar
gauthier committed
266

knopp's avatar
knopp committed
267

268
269
    schedule_RA(module_idP,frameP,subframeP,2);

270
271

    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
272
      schedule_ulsch(module_idP,frameP,cooperation_flag,0,4);//,calibration_flag);
273
274
275
    } 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)) {
276
      //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);//,calibration_flag);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
277
    }
278
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
279
280
    schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
    fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
281
282
283
284
285
286
287
288
289
290
#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);
	  
291
	  apply_dl_scheduling_decisions(module_idP,
292
293
294
295
296
297
298
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
299
300
301
    break;

  case 1:
302

gauthier's avatar
gauthier committed
303
    // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6)
304
305
    // FDD, schedule normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
306
307
308
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
      case 1:
309
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
310
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
311
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
312
#endif
313
314
315
        break;

      case 6:
316
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
317
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
318
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
319
#endif
320
321
322
323
324
325
        break;

      default:
        break;
      }
    } else { //FDD
326
      schedule_ulsch(module_idP,frameP,cooperation_flag,1,5);
327
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
328
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
329
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
330
331
332
333
334
335
336
337
338
339
#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);
	  
340
	  apply_dl_scheduling_decisions(module_idP,
341
342
343
344
345
346
347
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
348
    }
349

350
    break;
351
352

  case 2:
353

gauthier's avatar
gauthier committed
354
    // TDD, nothing
355
356
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
357
      schedule_ulsch(module_idP,frameP,cooperation_flag,2,6);
358
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
359
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
360
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
361
362
363
364
365
366
367
368
369
370
#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);
	  
371
	  apply_dl_scheduling_decisions(module_idP,
372
373
374
375
376
377
378
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
379
    }
380

381
382
383
    break;

  case 3:
384

gauthier's avatar
gauthier committed
385
    // TDD Config 2, ULSCH for subframeP 7
386
387
388
    // TDD Config 2/5 normal DLSCH
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
389
390
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
391
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
392
393
394

        // no break here!
      case 5:
395
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
396
397
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
398
399
400
401
402
403
404
405
406
407
#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);
	  
408
	  apply_dl_scheduling_decisions(module_idP,
409
410
411
412
413
414
415
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
416
417
418
419
420
421
        break;

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

423
      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7);
424
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
425
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
426
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
427
428
429
430
431
432
433
434
435
436
#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);
	  
437
	  apply_dl_scheduling_decisions(module_idP,
438
439
440
441
442
443
444
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
445
    }
446

447
    break;
448
449

  case 4:
450

gauthier's avatar
gauthier committed
451
    // TDD Config 1, ULSCH for subframeP 8
452
453
454
    // TDD Config 1/2/4/5 DLSCH
    // FDD UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == 1) { // TDD
455
456
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
457
        //        schedule_RA(module_idP,frameP,subframeP);
458
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
459
460
461
462
463
464
465
466
467

        // no break here!
      case 2:

        // no break here!
      case 4:

        // no break here!
      case 5:
468
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
469
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
470
471
472
473
474
475
476
477
478
479
480
	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);
	  
481
	  apply_dl_scheduling_decisions(module_idP,
482
483
484
485
486
487
488
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif	
489
490
491
492
493
494
495
496
        break;

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

497
498
	//        schedule_RA(module_idP,frameP, subframeP, 0);
	schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8);
499
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
500
	schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
501
        fill_DLSCH_dci(module_idP, frameP, subframeP,   mbsfn_status);
502
503
504
505
506
507
508
509
510
511
#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);
	  
512
	  apply_dl_scheduling_decisions(module_idP,
513
514
515
516
517
518
519
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}     
#endif
520
      }
521
    }
522

523
524
525
526
527
528
529
    break;

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

532
    //schedule_RA(module_idP,frameP,subframeP,5);
533
    if (mac_xface->lte_frame_parms->frame_type == FDD) {
534
535
      schedule_RA(module_idP,frameP,subframeP,1);
      schedule_ulsch(module_idP,frameP,cooperation_flag,5,9);
536
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
537
538
      schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
539
540
541
542
543
544
545
546
547
548
#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);
	  
549
	  apply_dl_scheduling_decisions(module_idP,
550
551
552
553
554
555
556
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
557
558
    } else if ((mac_xface->lte_frame_parms->tdd_config == 0) || // TDD Config 0
               (mac_xface->lte_frame_parms->tdd_config == 6)) { // TDD Config 6
559
      //schedule_ulsch(module_idP,cooperation_flag,subframeP);
560
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
561
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
562
#endif
563
    } else {
564
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
565
566
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
567
568
569
570
571
572
573
574
575
576
#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);
	  
577
	  apply_dl_scheduling_decisions(module_idP,
578
579
580
581
582
583
584
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
585
    }
586

587
588
589
    break;

  case 6:
590

591
592
593
594
    // 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
595
596
597
598
599
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
        break;

      case 1:
600
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
601
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
602
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
603
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
604
#endif
605
606
607
        break;

      case 6:
608
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
609
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
610
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
611
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
612
#endif
613
614
615
        break;

      case 5:
616
        schedule_RA(module_idP,frameP,subframeP,2);
617
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
618
619
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
620
621
622
623
624
625
626
627
628
629
#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);
	  
630
	  apply_dl_scheduling_decisions(module_idP,
631
632
633
634
635
636
637
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
638
639
640
641
        break;

      case 3:
      case 4:
642
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
643
644
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
645
646
647
648
649
650
651
652
653
654
#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);
	  
655
	  apply_dl_scheduling_decisions(module_idP,
656
657
658
659
660
661
662
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
663
664
665
666
667
668
        break;

      default:
        break;
      }
    } else { //FDD
669
      //      schedule_ulsch(module_idP,frameP,cooperation_flag,6,0);
670
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
671
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
672
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
673
674
675
676
677
678
679
680
681
682
#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);
	  
683
	  apply_dl_scheduling_decisions(module_idP,
684
685
686
687
688
689
690
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
691
    }
692

693
    break;
gauthier's avatar
gauthier committed
694

695
  case 7:
696

697
698
699
    // TDD Config 3,4,5 Normal DLSCH
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
700
701
702
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 3:
      case 4:
703
        schedule_RA(module_idP,frameP,subframeP,3);  // 3 = Msg3 subframeP, not
704
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
705
706
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
707
708
709
710
711
712
713
714
715
716
#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);
	  
717
	  apply_dl_scheduling_decisions(module_idP,
718
719
720
721
722
723
724
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
725
726
727
        break;

      case 5:
728
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
729
730
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
731
732
733
734
735
736
737
738
739
740
#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);
	  
741
	  apply_dl_scheduling_decisions(module_idP,
742
743
744
745
746
747
748
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
749
750
751
752
753
754
        break;

      default:
        break;
      }
    } else { //FDD
755
      //schedule_ulsch(module_idP,frameP,cooperation_flag,7,1);
756
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
757
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
758
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
759
760
761
762
763
764
765
766
767
768
#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);
	  
769
	  apply_dl_scheduling_decisions(module_idP,
770
771
772
773
774
775
776
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
777
    }
778

779
780
781
    break;

  case 8:
782

gauthier's avatar
gauthier committed
783
    // TDD Config 2,3,4,5 ULSCH for subframeP 2
784
785
786
    //
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
787
788
789
790
791
792
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
      case 3:
      case 4:
      case 5:

793
        //  schedule_RA(module_idP,subframeP);
794
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
795
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
796
797
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
798
799
800
801
802
803
804
805
806
807
#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);
	  
808
	  apply_dl_scheduling_decisions(module_idP,
809
810
811
812
813
814
815
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
816
817
818
819
820
821
        break;

      default:
        break;
      }
    } else { //FDD
822
      //schedule_ulsch(module_idP,frameP,cooperation_flag,8,2);
823
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
824
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
825
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
826
827
828
829
830
831
832
833
834
835
#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);
	  
836
	  apply_dl_scheduling_decisions(module_idP,
837
838
839
840
841
842
843
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
844
    }
845

846
847
848
    break;

  case 9:
849

850
851
    // TDD Config 1,3,4,6 ULSCH for subframes 3,3,3,4
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
852
853
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
854
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
855
        schedule_RA(module_idP,frameP,subframeP,7);  // 7 = Msg3 subframeP, not
856
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
857
858
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
859
860
861
862
863
864
865
866
867
868
#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);
	  
869
	  apply_dl_scheduling_decisions(module_idP,
870
871
872
873
874
875
876
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
877
878
879
880
        break;

      case 3:
      case 4:
881
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
882
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
883
884
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
885
886
887
888
889
890
891
892
893
894
#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);
	  
895
	  apply_dl_scheduling_decisions(module_idP,
896
897
898
899
900
901
902
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
903
904
905
        break;

      case 6:
906
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);
907
        //schedule_RA(module_idP,frameP,subframeP);
908
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
909
910
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
911
912
913
914
915
916
917
918
919
920
#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);
	  
921
	  apply_dl_scheduling_decisions(module_idP,
922
923
924
925
926
927
928
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
929
930
931
932
        break;

      case 2:
      case 5:
933
        //schedule_RA(module_idP,frameP,subframeP);
934
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
935
936
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
937
938
939
940
941
942
943
944
945
946
#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);
	  
947
	  apply_dl_scheduling_decisions(module_idP,
948
949
950
951
952
953
954
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
955
956
957
958
959
960
        break;

      default:
        break;
      }
    } else { //FDD
961
      //     schedule_ulsch(module_idP,frameP,cooperation_flag,9,3);
962
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
963
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
964
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
965
966
967
968
969
970
971
972
973
974
#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);
	  
975
	  apply_dl_scheduling_decisions(module_idP,
976
977
978
979
980
981
982
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
      }
#endif
983
    }
984

985
    break;
gauthier's avatar
gauthier committed
986

987
  }
988

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

991
  // Allocate CCEs for good after scheduling is done
992
993
  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++)
    allocate_CCEs(module_idP,CC_id,subframeP,0);
994

995
  LOG_D(MAC,"frameP %d, subframeP %d\n",frameP,subframeP);
996

997
  stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
gauthier's avatar
gauthier committed
998
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);
999

1000
}
1001
1002
1003