eNB_scheduler.c 34.4 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
//Agent-related headers
#include "ENB_APP/enb_agent_extern.h"
#include "ENB_APP/enb_agent_mac.h"
65
#include "LAYER2/MAC/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

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

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



86

87
88
89



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

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

109
110
  Protocol__ProgranMessage *msg;

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

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

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

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

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

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

141
#if defined(ENABLE_ITTI)
142

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

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

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

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

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

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

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

#ifdef Rel10

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

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

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

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

193
194
#endif

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

200

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

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


knopp's avatar
   
knopp committed
209
  }
210

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

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

#ifdef Rel10
223
224

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

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

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

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

knopp's avatar
knopp committed
253

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

256
257

    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
258
      schedule_ulsch(module_idP,frameP,cooperation_flag,0,4);//,calibration_flag);
259
260
261
    } 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)) {
262
      //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);//,calibration_flag);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
263
    }
264
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
265
266
    schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
    fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
267
268
269
270
271
272
273
274
275
276
#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);
	  
277
	  apply_dl_scheduling_decisions(module_idP,
278
279
280
281
282
283
284
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
285
286
287
    break;

  case 1:
288

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

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

      default:
        break;
      }
    } else { //FDD
312
      schedule_ulsch(module_idP,frameP,cooperation_flag,1,5);
313
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
314
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
315
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
316
317
318
319
320
321
322
323
324
325
#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);
	  
326
	  apply_dl_scheduling_decisions(module_idP,
327
328
329
330
331
332
333
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
334
    }
335

336
    break;
337
338

  case 2:
339

gauthier's avatar
gauthier committed
340
    // TDD, nothing
341
342
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
343
      schedule_ulsch(module_idP,frameP,cooperation_flag,2,6);
344
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
345
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
346
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
347
348
349
350
351
352
353
354
355
356
#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);
	  
357
	  apply_dl_scheduling_decisions(module_idP,
358
359
360
361
362
363
364
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
365
    }
366

367
368
369
    break;

  case 3:
370

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

        // no break here!
      case 5:
381
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
382
383
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
384
385
386
387
388
389
390
391
392
393
#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);
	  
394
	  apply_dl_scheduling_decisions(module_idP,
395
396
397
398
399
400
401
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
402
403
404
405
406
407
        break;

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

409
      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7);
410
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
411
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
412
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
413
414
415
416
417
418
419
420
421
422
#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);
	  
423
	  apply_dl_scheduling_decisions(module_idP,
424
425
426
427
428
429
430
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
431
    }
432

433
    break;
434
435

  case 4:
436

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

        // no break here!
      case 2:

        // no break here!
      case 4:

        // no break here!
      case 5:
454
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
455
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
456
457
458
459
460
461
462
463
464
465
466
	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);
	  
467
	  apply_dl_scheduling_decisions(module_idP,
468
469
470
471
472
473
474
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif	
475
476
477
478
479
480
481
482
        break;

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

483
484
	//        schedule_RA(module_idP,frameP, subframeP, 0);
	schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8);
485
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
486
	schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
487
        fill_DLSCH_dci(module_idP, frameP, subframeP,   mbsfn_status);
488
489
490
491
492
493
494
495
496
497
#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);
	  
498
	  apply_dl_scheduling_decisions(module_idP,
499
500
501
502
503
504
505
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}     
#endif
506
      }
507
    }
508

509
510
511
512
513
514
515
    break;

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

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

573
574
575
    break;

  case 6:
576

577
578
579
580
    // 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
581
582
583
584
585
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
        break;

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

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

      case 5:
602
        schedule_RA(module_idP,frameP,subframeP,2);
603
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
604
605
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
606
607
608
609
610
611
612
613
614
615
#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);
	  
616
	  apply_dl_scheduling_decisions(module_idP,
617
618
619
620
621
622
623
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
624
625
626
627
        break;

      case 3:
      case 4:
628
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
629
630
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
631
632
633
634
635
636
637
638
639
640
#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);
	  
641
	  apply_dl_scheduling_decisions(module_idP,
642
643
644
645
646
647
648
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
649
650
651
652
653
654
        break;

      default:
        break;
      }
    } else { //FDD
655
      //      schedule_ulsch(module_idP,frameP,cooperation_flag,6,0);
656
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
657
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
658
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
659
660
661
662
663
664
665
666
667
668
#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);
	  
669
	  apply_dl_scheduling_decisions(module_idP,
670
671
672
673
674
675
676
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
677
    }
678

679
    break;
gauthier's avatar
gauthier committed
680

681
  case 7:
682

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

      case 5:
714
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
715
716
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
717
718
719
720
721
722
723
724
725
726
#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);
	  
727
	  apply_dl_scheduling_decisions(module_idP,
728
729
730
731
732
733
734
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
735
736
737
738
739
740
        break;

      default:
        break;
      }
    } else { //FDD
741
      //schedule_ulsch(module_idP,frameP,cooperation_flag,7,1);
742
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
743
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
744
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
745
746
747
748
749
750
751
752
753
754
#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);
	  
755
	  apply_dl_scheduling_decisions(module_idP,
756
757
758
759
760
761
762
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
763
    }
764

765
766
767
    break;

  case 8:
768

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

779
        //  schedule_RA(module_idP,subframeP);
780
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
781
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
782
783
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
784
785
786
787
788
789
790
791
792
793
#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);
	  
794
	  apply_dl_scheduling_decisions(module_idP,
795
796
797
798
799
800
801
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
802
803
804
805
806
807
        break;

      default:
        break;
      }
    } else { //FDD
808
      //schedule_ulsch(module_idP,frameP,cooperation_flag,8,2);
809
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
810
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
811
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
812
813
814
815
816
817
818
819
820
821
#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);
	  
822
	  apply_dl_scheduling_decisions(module_idP,
823
824
825
826
827
828
829
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
830
    }
831

832
833
834
    break;

  case 9:
835

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

      case 3:
      case 4:
867
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
868
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
869
870
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
871
872
873
874
875
876
877
878
879
880
#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);
	  
881
	  apply_dl_scheduling_decisions(module_idP,
882
883
884
885
886
887
888
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
889
890
891
        break;

      case 6:
892
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);
893
        //schedule_RA(module_idP,frameP,subframeP);
894
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
895
896
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
897
898
899
900
901
902
903
904
905
906
#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);
	  
907
	  apply_dl_scheduling_decisions(module_idP,
908
909
910
911
912
913
914
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
915
916
917
918
        break;

      case 2:
      case 5:
919
        //schedule_RA(module_idP,frameP,subframeP);
920
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
921
922
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
923
924
925
926
927
928
929
930
931
932
#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);
	  
933
	  apply_dl_scheduling_decisions(module_idP,
934
935
936
937
938
939
940
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
941
942
943
944
945
946
        break;

      default:
        break;
      }
    } else { //FDD
947
      //     schedule_ulsch(module_idP,frameP,cooperation_flag,9,3);
948
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
949
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
950
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
951
952
953
954
955
956
957
958
959
960
#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);
	  
961
	  apply_dl_scheduling_decisions(module_idP,
962
963
964
965
966
967
968
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
      }
#endif
969
    }
970

971
    break;
gauthier's avatar
gauthier committed
972

973
  }
974

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

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

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

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

986
}
987
988
989