eNB_scheduler.c 23.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
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
72
73
#define ENABLE_MAC_PAYLOAD_DEBUG
#define DEBUG_eNB_SCHEDULER 1
//#define DEBUG_HEADER_PARSING 1
//#define DEBUG_PACKET_TRACE 1
gauthier's avatar
gauthier committed
74

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



83

84
85
void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP)  //, int calibration_flag) {
{
86

knopp's avatar
   
knopp committed
87
88
89
90
  unsigned int nprb[MAX_NUM_CCs];
  unsigned int nCCE[MAX_NUM_CCs];
  int mbsfn_status[MAX_NUM_CCs];
  uint32_t RBalloc[MAX_NUM_CCs];
91
  protocol_ctxt_t   ctxt;
92
93
94

  Protocol__ProgranMessage *msg;
  
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
  LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler (UE_list->head %d)\n",module_idP, frameP, subframeP,UE_list->head);
110

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

114
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
115
116
117
118
119
120
    DCI_pdu[CC_id] = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
    nCCE[CC_id]=0;
    nprb[CC_id]=0;
    RBalloc[CC_id]=0;
    mbsfn_status[CC_id]=0;
  }
121

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

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

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

138
#if defined(ENABLE_ITTI)
139

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

144
145
146
    if (msg_p != NULL) {
      msg_name = ITTI_MSG_NAME (msg_p);
      instance = ITTI_MSG_INSTANCE (msg_p);
147

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

153
154
155
156
      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);
157

158
159
        // TODO process BCCH data req.
        break;
160

161
162
163
164
      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);
165

166
167
        // TODO process CCCH data req.
        break;
168
169
170

#ifdef Rel10

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

176
177
178
        // TODO process MCCH data req.
        break;
#endif
179

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

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

190
191
#endif

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

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

knopp's avatar
   
knopp committed
202
203
204
    eNB_mac_inst[module_idP].frame    = frameP;
    eNB_mac_inst[module_idP].subframe = subframeP;
  }
205

gauthier's avatar
gauthier committed
206
  //if (subframeP%5 == 0)
knopp's avatar
   
knopp committed
207
  //#ifdef EXMIMO
208
  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,module_idP);
209
  pdcp_run(&ctxt);
knopp's avatar
   
knopp committed
210
  //#endif
211

212
  // check HO
213
214
  rrc_rx_tx(&ctxt,
            0, // eNB index, unused in eNB
215
            CC_id);
216
217

#ifdef Rel10
218
219

  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
220
221
222
223
    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
224
    }
225
  }
226

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

gauthier's avatar
gauthier committed
241
  switch (subframeP) {
242
  case 0:
243

244
    // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution)
gauthier's avatar
gauthier committed
245
    // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6)
246
    // Schedule Normal DLSCH
gauthier's avatar
gauthier committed
247

248
    schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE);
249
250

    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
knopp's avatar
   
knopp committed
251
      schedule_ulsch(module_idP,frameP,cooperation_flag,0,4,nCCE);//,calibration_flag);
252
253
254
    } 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)) {
knopp's avatar
   
knopp committed
255
      //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,nCCE);//,calibration_flag);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
256
    }
257

Florian Kaltenberger's avatar
Florian Kaltenberger committed
258
    // schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
259

260
    fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
261

262
263
264
    break;

  case 1:
265

gauthier's avatar
gauthier committed
266
    // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6)
267
268
    // FDD, schedule normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
      case 1:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,nCCE);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      case 6:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,nCCE);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
285
286
287
288
289
290
291
292
293
294
295
296
297
      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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
298
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
knopp's avatar
   
knopp committed
299
      schedule_ulsch(module_idP,frameP,cooperation_flag,1,5,nCCE);
300
    }
301

302
    break;
303
304

  case 2:
305

gauthier's avatar
gauthier committed
306
    // TDD, nothing
307
308
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
309
310
311
312
313
314
315
316
317
318
319
320
321
      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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
322
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
knopp's avatar
   
knopp committed
323
      schedule_ulsch(module_idP,frameP,cooperation_flag,2,6,nCCE);
324
    }
325

326
327
328
    break;

  case 3:
329

gauthier's avatar
gauthier committed
330
    // TDD Config 2, ULSCH for subframeP 7
331
332
333
    // TDD Config 2/5 normal DLSCH
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
334
335
336
337
338
339
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,nCCE);

        // no break here!
      case 5:
340
341
342
343
344
345
346
347
348
349
350
351
352
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
353
354
355
356
357
358
359
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
360
361
362
363
364
365
366
367
368
369
370
371
372
      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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
373
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
374
      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7,nCCE);
375

376
    }
377

378
    break;
379
380

  case 4:
381

gauthier's avatar
gauthier committed
382
    // TDD Config 1, ULSCH for subframeP 8
383
384
385
    // TDD Config 1/2/4/5 DLSCH
    // FDD UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == 1) { // TDD
386
387
388
389
390
391
392
393
394
395
396
397
398
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
        //        schedule_RA(module_idP,frameP,subframeP,nprb,nCCE);
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,nCCE);

        // no break here!
      case 2:

        // no break here!
      case 4:

        // no break here!
      case 5:
399
400
401
402
403
404
405
406
407
408
409
410
411
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
412
413
414
415
416
417
418
419
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
        break;

      default:
        break;
      }
    } else {
      if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
420
	//        schedule_RA(module_idP,frameP, subframeP, 0, nprb, nCCE);
421
        //  schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8, nCCE);
422
423
424
425
426
427
428
429
430
431
432
433
434
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP, frameP, subframeP, nprb, nCCE, mbsfn_status);
435
436
437
        fill_DLSCH_dci(module_idP, frameP, subframeP, RBalloc, 1, mbsfn_status);

      }
438
    }
439

440
441
442
443
444
445
446
    break;

  case 5:
    // TDD/FDD Schedule SI
    // TDD Config 0,6 ULSCH for subframes 9,3 resp.
    // TDD normal DLSCH
    // FDD normal UL/DLSCH
knopp's avatar
   
knopp committed
447
    schedule_SI(module_idP,frameP,nprb,nCCE);
448

knopp's avatar
   
knopp committed
449
    //schedule_RA(module_idP,frameP,subframeP,5,nprb,nCCE);
450
    if (mac_xface->lte_frame_parms->frame_type == FDD) {
451
      schedule_RA(module_idP,frameP,subframeP,1,nprb,nCCE);
452
      //      schedule_ulsch(module_idP,frameP,cooperation_flag,5,9,nCCE);
453
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
454

455
456
457
458
459
460
461
    } else if ((mac_xface->lte_frame_parms->tdd_config == 0) || // TDD Config 0
               (mac_xface->lte_frame_parms->tdd_config == 6)) { // TDD Config 6
      //schedule_ulsch(module_idP,cooperation_flag,subframeP,nCCE);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
    } else {
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
462
    }
463

464
465
466
    break;

  case 6:
467

468
469
470
471
    // 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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
        break;

      case 1:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,nCCE);
        //  schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      case 6:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE);
        //  schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      case 5:
        schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE);
490
491
492
493
494
495
496
497
498
499
500
501
502
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
503
504
505
506
507
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
        break;

      case 3:
      case 4:
508
509
510
511
512
513
514
515
516
517
518
519
520
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
521
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
522
523
524
525
526
527
528
        break;

      default:
        break;
      }
    } else { //FDD
      //      schedule_ulsch(module_idP,frameP,cooperation_flag,6,0,nCCE);
529
530
531
532
533
534
535
536
537
538
539
540
541
      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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
542
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
543
    }
544

545
    break;
gauthier's avatar
gauthier committed
546

547
  case 7:
548

549
550
551
    // TDD Config 3,4,5 Normal DLSCH
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
552
553
554
555
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 3:
      case 4:
        schedule_RA(module_idP,frameP,subframeP,3,nprb,nCCE);  // 3 = Msg3 subframeP, not
556
557
558
559
560
561
562
563
564
565
566
567
568
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
569
570
571
572
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
        break;

      case 5:
573
574
575
576
577
578
579
580
581
582
583
584
585
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
586
587
588
589
590
591
592
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
593
      //schedule_ulsch(module_idP,frameP,cooperation_flag,7,1,nCCE);
594
595
596
597
598
599
600
601
602
603
604
605
606
      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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
607
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
608
    }
609

610
611
612
    break;

  case 8:
613

gauthier's avatar
gauthier committed
614
    // TDD Config 2,3,4,5 ULSCH for subframeP 2
615
616
617
    //
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
618
619
620
621
622
623
624
625
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
      case 3:
      case 4:
      case 5:

        //  schedule_RA(module_idP,subframeP,nprb,nCCE);
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,nCCE);
626
627
628
629
630
631
632
633
634
635
636
637
638
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
639
640
641
642
643
644
645
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
646
      //schedule_ulsch(module_idP,frameP,cooperation_flag,8,2,nCCE);
647
648
649
650
651
652
653
654
655
656
657
658
659
      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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
660
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
661
    }
662

663
664
665
    break;

  case 9:
666

667
668
    // TDD Config 1,3,4,6 ULSCH for subframes 3,3,3,4
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
669
670
671
672
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE);
        schedule_RA(module_idP,frameP,subframeP,7,nprb,nCCE);  // 7 = Msg3 subframeP, not
673
674
675
676
677
678
679
680
681
682
683
684
685
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
686
687
688
689
690
691
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
        break;

      case 3:
      case 4:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE);
692
693
694
695
696
697
698
699
700
701
702
703
704
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
705
706
707
708
709
710
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      case 6:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,nCCE);
        //schedule_RA(module_idP,frameP,subframeP,nprb,nCCE);
711
712
713
714
715
716
717
718
719
720
721
722
723
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
724
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
725
726
727
728
729
        break;

      case 2:
      case 5:
        //schedule_RA(module_idP,frameP,subframeP,nprb,nCCE);
730
731
732
733
734
735
736
737
738
739
740
741
742
	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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
743
744
745
746
747
748
749
750
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
      //     schedule_ulsch(module_idP,frameP,cooperation_flag,9,3,nCCE);
751
752
753
754
755
756
757
758
759
760
761
762
763
      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,
								nprb,
								nCCE,
								mbsfn_status,
								msg);
	enb_agent_mac_destroy_dl_config(msg);
      }
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
764
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
765
    }
766

767
    break;
gauthier's avatar
gauthier committed
768

769
  }
770

771
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
772
    DCI_pdu[CC_id]->nCCE = nCCE[CC_id];
773
  }
774

knopp's avatar
   
knopp committed
775
  LOG_D(MAC,"frameP %d, subframeP %d nCCE %d\n",frameP,subframeP,nCCE[0]);
776

777
  stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
gauthier's avatar
gauthier committed
778
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);
779

780
}
781
782
783