eNB_scheduler.c 33.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */
21
22

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

30
 */
31

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

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

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

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

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

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

55
#if defined(FLEXRAN_AGENT_SB_IF)
56
//Agent-related headers
57
58
59
#include "flexran_agent_extern.h"
#include "flexran_agent_mac.h"
#include "flexran_agent_mac_proto.h"
60
#endif
61

62
63
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
64
65
#endif

66
67
#define ENABLE_MAC_PAYLOAD_DEBUG
#define DEBUG_eNB_SCHEDULER 1
68
//efine ENABLE_ENB_AGENT_DL_SCHEDULER
69
//#define DISABLE_SF_TRIGGER
70
//#define DISABLE_CONT_STATS
71

72
73
//#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
86



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

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

108
#if defined(FLEXRAN_AGENT_SB_IF)
109
  Protocol__FlexranMessage *msg;
110
#endif
111

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
119
    DCI_pdu[CC_id] = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
    mbsfn_status[CC_id]=0;
120
121
    // clear vrb_map
    memset(eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map,0,100);
knopp's avatar
   
knopp committed
122
  }
123

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

  while (i>=0) {
128
129
    rnti = UE_RNTI(module_idP, i);
    CC_id = UE_PCCID(module_idP, i);
130
    if ((frameP==0)&&(subframeP==0))
131
132
133
      LOG_I(MAC,"UE  rnti %x : %s, PHR %d dB\n", rnti, 
	    UE_list->UE_sched_ctrl[i].ul_out_of_sync==0 ? "in synch" : "out of sync",
	    UE_list->UE_template[CC_id][i].phr_info);
134

135
    next_i= UE_list->next[i];
136

137
138
139
    PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]=-63;
    if (i==UE_list->head)
      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]); 
140
141
    // increment this, it is cleared when we receive an sdu
    eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].ul_inactivity_timer++;
142
143

    eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].cqi_req_timer++;
144
    
145

146
    if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) {
147
	//mac_remove_ue(module_idP, i, frameP, subframeP);
148
      //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future
149
#if defined(FLEXRAN_AGENT_SB_IF)
150
      if (mac_agent_registered[module_idP]) {
151
152
153
	agent_mac_xface[module_idP]->flexran_agent_notify_ue_state_change(module_idP,
									  rnti,
									  PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
154
      }
155
#endif
156
    }
157
158
    else {
      // check uplink failure
Florian Kaltenberger's avatar
Florian Kaltenberger committed
159
160
161
162
163
164
165
      if ((UE_list->UE_sched_ctrl[i].ul_failure_timer>0)&&
	  (UE_list->UE_sched_ctrl[i].ul_out_of_sync==0)) {
	LOG_D(MAC,"UE %d rnti %x: UL Failure timer %d \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);
	if (UE_list->UE_sched_ctrl[i].ra_pdcch_order_sent==0) {
	  UE_list->UE_sched_ctrl[i].ra_pdcch_order_sent=1;
	  
	  // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe)
166
	  LOG_D(MAC,"UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d) \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);	    
Florian Kaltenberger's avatar
Florian Kaltenberger committed
167
168
	  DLSCH_dci = (void *)UE_list->UE_template[CC_id][i].DLSCH_DCI[0];
	  *(uint32_t*)DLSCH_dci = 0;
169
170
	  if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
	    switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
Florian Kaltenberger's avatar
Florian Kaltenberger committed
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
	    case 6:
	      ((DCI1A_1_5MHz_TDD_1_6_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_1_5MHz_TDD_1_6_t*)DLSCH_dci)->rballoc = 31;
	      size_bytes = sizeof(DCI1A_1_5MHz_TDD_1_6_t);
	      size_bits  = sizeof_DCI1A_1_5MHz_TDD_1_6_t;
	      break;
	    case 25:
	      ((DCI1A_5MHz_TDD_1_6_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_5MHz_TDD_1_6_t*)DLSCH_dci)->rballoc = 511;
	      size_bytes = sizeof(DCI1A_5MHz_TDD_1_6_t);
	      size_bits  = sizeof_DCI1A_5MHz_TDD_1_6_t;
	      break;
	    case 50:
	      ((DCI1A_10MHz_TDD_1_6_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_10MHz_TDD_1_6_t*)DLSCH_dci)->rballoc = 2047;
	      size_bytes = sizeof(DCI1A_10MHz_TDD_1_6_t);
	      size_bits  = sizeof_DCI1A_10MHz_TDD_1_6_t;
	      break;
	    case 100:
	      ((DCI1A_20MHz_TDD_1_6_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_20MHz_TDD_1_6_t*)DLSCH_dci)->rballoc = 8191;
	      size_bytes = sizeof(DCI1A_20MHz_TDD_1_6_t);
	      size_bits  = sizeof_DCI1A_20MHz_TDD_1_6_t;
	      break;
195
	    }
Florian Kaltenberger's avatar
Florian Kaltenberger committed
196
197
	  }
	  else { // FDD
198
	    switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
Florian Kaltenberger's avatar
Florian Kaltenberger committed
199
200
201
202
203
204
	    case 6:
	      ((DCI1A_1_5MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_1_5MHz_FDD_t*)DLSCH_dci)->rballoc = 31;
	      size_bytes = sizeof(DCI1A_1_5MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_1_5MHz_FDD_t;
	      break;
205
206
207
208
209
210
	    case 15:/*
	      ((DCI1A_2_5MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_2_5MHz_FDD_t*)DLSCH_dci)->rballoc = 31;
	      size_bytes = sizeof(DCI1A_1_5MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_1_5MHz_FDD_t;*/
	      break;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
211
212
213
214
215
216
217
218
219
220
221
	    case 25:
	      ((DCI1A_5MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_5MHz_FDD_t*)DLSCH_dci)->rballoc = 511;
	      size_bytes = sizeof(DCI1A_5MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_5MHz_FDD_t;
	      break;
	    case 50:
	      ((DCI1A_10MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_10MHz_FDD_t*)DLSCH_dci)->rballoc = 2047;
	      size_bytes = sizeof(DCI1A_10MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_10MHz_FDD_t;
222
		break;
223
224
225
226
227
228
	    case 75:
	      /*	      ((DCI1A_15MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_15MHz_FDD_t*)DLSCH_dci)->rballoc = 2047;
	      size_bytes = sizeof(DCI1A_10MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_10MHz_FDD_t;*/
		break;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
229
230
231
232
233
234
	    case 100:
	      ((DCI1A_20MHz_FDD_t*)DLSCH_dci)->type = 1;
	      ((DCI1A_20MHz_FDD_t*)DLSCH_dci)->rballoc = 8191;
	      size_bytes = sizeof(DCI1A_20MHz_FDD_t);
	      size_bits  = sizeof_DCI1A_20MHz_FDD_t;
	      break;
235
236
	    }
	  }
Florian Kaltenberger's avatar
Florian Kaltenberger committed
237
238
239
240
241
242
243
244
245
	  
	  add_ue_spec_dci(DCI_pdu[CC_id],
			  DLSCH_dci,
			  rnti,
			    size_bytes,
			  process_ue_cqi (module_idP,i),//aggregation,
			  size_bits,
			  format1A,
			  0);
246
	}
Florian Kaltenberger's avatar
Florian Kaltenberger committed
247
	else { // ra_pdcch_sent==1
248
	  LOG_D(MAC,"UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);	    	    
Florian Kaltenberger's avatar
Florian Kaltenberger committed
249
250
	  if ((UE_list->UE_sched_ctrl[i].ul_failure_timer % 40) == 0)
	    UE_list->UE_sched_ctrl[i].ra_pdcch_order_sent=0; // resend every 4 frames	      
251
	}
252
253
254
255
256
      
	UE_list->UE_sched_ctrl[i].ul_failure_timer++;
	// check threshold
	if (UE_list->UE_sched_ctrl[i].ul_failure_timer > 200) {
	  // inform RRC of failure and clear timer
257
	  LOG_I(MAC,"UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);
258
259
260
261
	  mac_eNB_rrc_ul_failure(module_idP,CC_id,frameP,subframeP,rnti);
	  UE_list->UE_sched_ctrl[i].ul_failure_timer=0;
	  UE_list->UE_sched_ctrl[i].ul_out_of_sync=1;
	}
Florian Kaltenberger's avatar
Florian Kaltenberger committed
262
263
264
      }
    } // ul_failure_timer>0
    
265
    i = next_i;
knopp's avatar
   
knopp committed
266
  }
267

268
#if defined(ENABLE_ITTI)
269

270
  do {
271
272
    // Checks if a message has been sent to MAC sub-task
    itti_poll_msg (TASK_MAC_ENB, &msg_p);
273

274
275
276
    if (msg_p != NULL) {
      msg_name = ITTI_MSG_NAME (msg_p);
      instance = ITTI_MSG_INSTANCE (msg_p);
277

278
279
280
281
      switch (ITTI_MSG_ID(msg_p)) {
      case MESSAGE_TEST:
        LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p));
        break;
282

283
284
285
286
      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);
287

288
289
        // TODO process BCCH data req.
        break;
290

291
292
293
294
      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);
295

296
297
        // TODO process CCCH data req.
        break;
298
299
300

#ifdef Rel10

301
302
303
304
      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);
305

306
307
308
        // TODO process MCCH data req.
        break;
#endif
309

310
311
312
      default:
        LOG_E(MAC, "Received unexpected message %s\n", msg_name);
        break;
gauthier's avatar
gauthier committed
313
      }
314
315
316
317

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

320
321
#endif

gauthier's avatar
gauthier committed
322
  // clear DCI and BCCH contents before scheduling
323
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
324
325
    DCI_pdu[CC_id]->Num_common_dci  = 0;
    DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
326

327

328
#ifdef Rel10
329
    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
330
#endif
331

knopp's avatar
   
knopp committed
332
333
    eNB_mac_inst[module_idP].frame    = frameP;
    eNB_mac_inst[module_idP].subframe = subframeP;
334
335


knopp's avatar
   
knopp committed
336
  }
337
  
338
339
340
/* #ifndef DISABLE_SF_TRIGGER */
/*   //Send subframe trigger to the controller */
/*   if (mac_agent_registered[module_idP]) { */
341
/*     agent_mac_xface[module_idP]->flexran_agent_send_sf_trigger(module_idP); */
342
343
/*   } */
/* #endif */
344
  
gauthier's avatar
gauthier committed
345
  //if (subframeP%5 == 0)
knopp's avatar
   
knopp committed
346
  //#ifdef EXMIMO
347
  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, subframeP,module_idP);
348
  pdcp_run(&ctxt);
knopp's avatar
   
knopp committed
349
  //#endif
350

351
  // check HO
352
353
  rrc_rx_tx(&ctxt,
            0, // eNB index, unused in eNB
354
            CC_id);
355
356

#ifdef Rel10
357
358

  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
359
360
361
362
    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
363
    }
364
  }
365

366
#endif
knopp's avatar
   
knopp committed
367
  // refresh UE list based on UEs dropped by PHY in previous subframe
368
  /*
knopp's avatar
   
knopp committed
369
370
371
  i=UE_list->head;
  while (i>=0) {
    next_i = UE_list->next[i];
372
    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
373
    if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) {
knopp's avatar
   
knopp committed
374
      mac_remove_ue(module_idP,i,frameP);
knopp's avatar
   
knopp committed
375
376
377
    }
    i=next_i;
  }
378
  */
379

gauthier's avatar
gauthier committed
380
  switch (subframeP) {
381
  case 0:
382

383
    // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution)
gauthier's avatar
gauthier committed
384
    // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6)
385
    // Schedule Normal DLSCH
gauthier's avatar
gauthier committed
386

knopp's avatar
knopp committed
387

388
389
    schedule_RA(module_idP,frameP,subframeP,2);

390

391
    if (mac_xface->frame_parms->frame_type == FDD) {  //FDD
392
      schedule_ulsch(module_idP,frameP,cooperation_flag,0,4);//,calibration_flag);
393
394
395
    } else if  ((mac_xface->frame_parms->tdd_config == TDD) || //TDD
                (mac_xface->frame_parms->tdd_config == 3) ||
                (mac_xface->frame_parms->tdd_config == 6)) {
396
      //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);//,calibration_flag);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
397
    }
398
#ifndef FLEXRAN_AGENT_SB_IF
399
400
    schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
    fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
401
402
#else
    if (mac_agent_registered[module_idP]) {                                  
403
404
405
406
407
408
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
409
	  
410
411
412
413
414
415
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
416
417
	}
#endif
418
419
420
    break;

  case 1:
421

gauthier's avatar
gauthier committed
422
    // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6)
423
    // FDD, schedule normal UL/DLSCH
424
425
    if (mac_xface->frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
426
427
      case 0:
      case 1:
428
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
429
#ifndef FLEXRAN_AGENT_SB_IF
430
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
431
#endif
432
433
434
        break;

      case 6:
435
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
436
#ifndef FLEXRAN_AGENT_SB_IF
437
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
438
#endif
439
440
441
442
443
444
        break;

      default:
        break;
      }
    } else { //FDD
445
      schedule_ulsch(module_idP,frameP,cooperation_flag,1,5);
446
#ifndef FLEXRAN_AGENT_SB_IF
447
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
448
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
449
450
#else
      if (mac_agent_registered[module_idP]) {                                  
451
452
453
454
455
456
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
457
	  
458
459
460
461
462
463
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
464
465
	}
#endif
466
    }
467

468
    break;
469
470

  case 2:
471

gauthier's avatar
gauthier committed
472
    // TDD, nothing
473
    // FDD, normal UL/DLSCH
474
    if (mac_xface->frame_parms->frame_type == FDD) {  //FDD
475
      schedule_ulsch(module_idP,frameP,cooperation_flag,2,6);
476
#ifndef FLEXRAN_AGENT_SB_IF
477
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
478
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
479
480
#else
      if (mac_agent_registered[module_idP]) {                                  
481
482
483
484
485
486
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
487
	  
488
489
490
491
492
493
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
494
495
	}
#endif
496
    }
497

498
499
500
    break;

  case 3:
501

gauthier's avatar
gauthier committed
502
    // TDD Config 2, ULSCH for subframeP 7
503
504
    // TDD Config 2/5 normal DLSCH
    // FDD, normal UL/DLSCH
505
506
    if (mac_xface->frame_parms->frame_type == TDD) {
      switch (mac_xface->frame_parms->tdd_config) {
507
      case 2:
508
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
509
510
511

        // no break here!
      case 5:
512
#ifndef FLEXRAN_AGENT_SB_IF
513
514
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
515
516
#else
	if (mac_agent_registered[module_idP]) {                                  
517
518
519
520
521
522
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
523
	  
524
525
526
527
528
529
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
530
531
	}
#endif
532
533
534
535
536
537
        break;

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

539
      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7);
540
#ifndef FLEXRAN_AGENT_SB_IF
541
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
542
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
543
544
#else
      if (mac_agent_registered[module_idP]) {                                  
545
546
547
548
549
550
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
551
	  
552
553
554
555
556
557
558
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
      }
559
#endif
560
    }
561

562
    break;
563
564

  case 4:
565

gauthier's avatar
gauthier committed
566
    // TDD Config 1, ULSCH for subframeP 8
567
568
    // TDD Config 1/2/4/5 DLSCH
    // FDD UL/DLSCH
569
570
    if (mac_xface->frame_parms->frame_type == 1) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
571
      case 1:
572
        //        schedule_RA(module_idP,frameP,subframeP);
573
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
574
575
576
577
578
579
580
581
582

        // no break here!
      case 2:

        // no break here!
      case 4:

        // no break here!
      case 5:
583
#ifndef FLEXRAN_AGENT_SB_IF
584
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
585
586
587
	fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
#else
	if (mac_agent_registered[module_idP]) {                                  
588
589
590
591
592
593
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
594
	  
595
596
597
598
599
600
	  flexran_apply_dl_scheduling_decisions(module_idP,
					       frameP,
					       subframeP,
					       mbsfn_status,
					       msg);
	  flexran_agent_mac_destroy_dl_config(msg);
601
602
	}
#endif	
603
604
605
606
607
608
        break;

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

611
	schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8);
612
#ifndef FLEXRAN_AGENT_SB_IF
613
	schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
614
        fill_DLSCH_dci(module_idP, frameP, subframeP,   mbsfn_status);
615
616
#else
	if (mac_agent_registered[module_idP]) {                                  
617
618
619
620
621
622
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
623
	  
624
625
626
627
628
629
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
630
631
	}     
#endif
632
      }
633
    }
634

635
636
637
638
639
640
641
    break;

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

644
    //schedule_RA(module_idP,frameP,subframeP,5);
645
    if (mac_xface->frame_parms->frame_type == FDD) {
646
647
      schedule_RA(module_idP,frameP,subframeP,1);
      schedule_ulsch(module_idP,frameP,cooperation_flag,5,9);
648
#ifndef FLEXRAN_AGENT_SB_IF
649
650
      schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
651
652
#else
      if (mac_agent_registered[module_idP]) {                                  
653
654
655
656
657
658
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
659
	  
660
661
662
663
664
665
	  flexran_apply_dl_scheduling_decisions(module_idP,
					  frameP,
					  subframeP,
					  mbsfn_status,
					  msg);
	  flexran_agent_mac_destroy_dl_config(msg);
666
667
	}
#endif
668
669
    } else if ((mac_xface->frame_parms->tdd_config == 0) || // TDD Config 0
               (mac_xface->frame_parms->tdd_config == 6)) { // TDD Config 6
670
      //schedule_ulsch(module_idP,cooperation_flag,subframeP);
671
#ifndef FLEXRAN_AGENT_SB_IF
672
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
673
#endif
674
    } else {
675
#ifndef FLEXRAN_AGENT_SB_IF
676
677
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
678
679
#else
      if (mac_agent_registered[module_idP]) {                                  
680
681
682
683
684
685
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
686
	  
687
688
689
690
691
692
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
693
694
	}
#endif
695
    }
696

697
698
699
    break;

  case 6:
700

701
702
703
    // TDD Config 0,1,6 ULSCH for subframes 2,3
    // TDD Config 3,4,5 Normal DLSCH
    // FDD normal ULSCH/DLSCH
704
705
    if (mac_xface->frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
706
707
708
709
      case 0:
        break;

      case 1:
710
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
711
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
712
#ifndef FLEXRAN_AGENT_SB_IF
713
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
714
#endif
715
716
717
        break;

      case 6:
718
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
719
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
720
#ifndef FLEXRAN_AGENT_SB_IF
721
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
722
#endif
723
724
725
        break;

      case 5:
726
        schedule_RA(module_idP,frameP,subframeP,2);
727
#ifndef FLEXRAN_AGENT_SB_IF
728
729
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
730
731
#else
	if (mac_agent_registered[module_idP]) {                                  
732
733
734
735
736
737
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
738
	  
739
740
741
742
743
744
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
745
746
	}
#endif
747
748
749
750
        break;

      case 3:
      case 4:
751
#ifndef FLEXRAN_AGENT_SB_IF
752
753
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
754
755
#else
	if (mac_agent_registered[module_idP]) {                                  
756
757
758
759
760
761
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
762
	  
763
764
765
766
767
768
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
769
770
	}
#endif
771
772
773
774
775
776
        break;

      default:
        break;
      }
    } else { //FDD
777
      schedule_ulsch(module_idP,frameP,cooperation_flag,6,0);
778
#ifndef FLEXRAN_AGENT_SB_IF
779
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
780
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
781
782
#else
      if (mac_agent_registered[module_idP]) {                                  
783
784
785
786
787
788
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
789
	  
790
791
792
793
794
795
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
796
797
	}
#endif
798
    }
799

800
    break;
gauthier's avatar
gauthier committed
801

802
  case 7:
803

804
805
    // TDD Config 3,4,5 Normal DLSCH
    // FDD Normal UL/DLSCH
806
807
    if (mac_xface->frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
808
809
      case 3:
      case 4:
810
        schedule_RA(module_idP,frameP,subframeP,3);  // 3 = Msg3 subframeP, not
811
#ifndef FLEXRAN_AGENT_SB_IF
812
813
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
814
815
#else
	if (mac_agent_registered[module_idP]) {                                  
816
817
818
819
820
821
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
822
	  
823
824
825
826
827
828
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
829
830
	}
#endif
831
832
833
        break;

      case 5:
834
#ifndef FLEXRAN_AGENT_SB_IF
835
836
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
837
838
#else
	if (mac_agent_registered[module_idP]) {                                  
839
840
841
842
843
844
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
845
	  
846
847
848
849
850
851
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
852
853
	}
#endif
854
855
856
857
858
859
        break;

      default:
        break;
      }
    } else { //FDD
860
      schedule_ulsch(module_idP,frameP,cooperation_flag,7,1);
861
#ifndef FLEXRAN_AGENT_SB_IF
862
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
863
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
864
865
#else
      if (mac_agent_registered[module_idP]) {                                  
866
867
868
869
870
871
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
872
	  
873
874
875
876
877
878
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
879
880
	}
#endif
881
    }
882

883
884
885
    break;

  case 8:
886

gauthier's avatar
gauthier committed
887
    // TDD Config 2,3,4,5 ULSCH for subframeP 2
888
889
    //
    // FDD Normal UL/DLSCH
890
891
    if (mac_xface->frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->frame_parms->tdd_config) {
892
893
894
895
896
      case 2:
      case 3:
      case 4:
      case 5:

897
        //  schedule_RA(module_idP,subframeP);
898
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
899
#ifndef FLEXRAN_AGENT_SB_IF
900
901
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
902
903
#else
	if (mac_agent_registered[module_idP]) {                                  
904
905
906
907
908
909
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
910
	  
911
912
913
914
915
916
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
917
918
	}
#endif
919
920
921
922
923
924
        break;

      default:
        break;
      }
    } else { //FDD
925
      schedule_ulsch(module_idP,frameP,cooperation_flag,8,2);
926
#ifndef FLEXRAN_AGENT_SB_IF
927
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
928
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
929
930
#else
      if (mac_agent_registered[module_idP]) {                                  
931
932
933
934
935
936
	  agent_mac_xface[module_idP]->flexran_agent_schedule_ue_spec(
								      module_idP,
								      frameP,                  
								      subframeP,
								      mbsfn_status,
								      &msg);
937
	  
938
939
940
941
942
943
	  flexran_apply_dl_scheduling_decisions(module_idP,
						frameP,
						subframeP,
						mbsfn_status,
						msg);
	  flexran_agent_mac_destroy_dl_config(msg);
944
945
	}
#endif
Cedric Roux's avatar