ff-mac-common.h 12.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
/*******************************************************************************
    OpenAirInterface
    Copyright(c) 1999 - 2015 Eurecom

    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.


    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.

    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/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr

  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE

*******************************************************************************/
/*! \file ff-mac-common.h
 * \brief this is the implementation of the Femto Forum LTE MAC Scheduler Interface Specification v1.11 
 * \author Florian Kaltenberger
 * \date March 2015
 * \version 1.0
 * \email: florian.kaltenberger@eurecom.fr
 * @ingroup _mac
 */


#ifndef FF_MAC_COMMON_H
#define FF_MAC_COMMON_H

#include <stdint.h>
#include <stdbool.h>

#if defined (__cplusplus)
extern "C" {
#endif

/**
 * Constants. See section 4.4
 */
#define MAX_SCHED_CFG_LIST    10
#define MAX_LC_LIST           10

#define MAX_RACH_LIST         30
#define MAX_DL_INFO_LIST      30
#define MAX_BUILD_DATA_LIST   30
#define MAX_BUILD_RAR_LIST    10
#define MAX_BUILD_BC_LIST     3
#define MAX_UL_INFO_LIST      30
#define MAX_DCI_LIST          30
#define MAX_PHICH_LIST        30
#define MAX_TB_LIST           2
#define MAX_RLC_PDU_LIST      30
#define MAX_NR_LCG            4
#define MAX_MBSFN_CONFIG      5
#define MAX_SI_MSG_LIST       32
#define MAX_SI_MSG_SIZE       65535

#define MAX_CQI_LIST          30
#define MAX_UE_SELECTED_SB    6		//comes from Table 7.2.1-5, 36.213
#define MAX_HL_SB             13	//comes from Table 7.2.1-3, 36.213
#define MAX_SINR_RB_LIST      100
#define MAX_SR_LIST           30
#define MAX_MAC_CE_LIST       30

#ifndef MAX_NUM_CCs
#error MAX_NUM_CCs not defined
#endif

//#define MAX_NUM_CCs           2

enum Result_e
{
  ff_SUCCESS,
  ff_FAILURE
};

enum SetupRelease_e
{
  ff_setup,
  ff_release
};

enum CeBitmap_e
{
  ff_TA		= 1 << 0,
  ff_DRX	= 1 << 1,
  ff_CR		= 1 << 2,
  /// activation/deactivation of CCs
  ff_AD		= 1 << 3
};

enum NormalExtended_e
{
  ff_normal,
  ff_extended
};

/**
 * \brief See section 4.3.1 dlDciListElement
 */
struct DlDciListElement_s
{
  uint16_t  rnti;
  uint32_t  rbBitmap;
  uint8_t   rbShift;
  uint8_t   resAlloc;
  uint16_t  tbsSize[MAX_TB_LIST];
  uint8_t   mcs[MAX_TB_LIST];
  uint8_t   ndi[MAX_TB_LIST];
  uint8_t   rv[MAX_TB_LIST];
  uint8_t   cceIndex;
  uint8_t   aggrLevel;
  uint8_t   precodingInfo;
  enum Format_e
  {
    ONE, ONE_A, ONE_B, ONE_C, ONE_D, TWO, TWO_A, TWO_B
  } format;
  uint8_t   tpc;
  uint8_t   harqProcess;
  uint8_t   dai;
  enum VrbFormat_e
  {
    VRB_DISTRIBUTED,
    VRB_LOCALIZED
  } vrbFormat;
  bool      tbSwap;
  bool      spsRelease;
  bool      pdcchOrder;
  uint8_t   preambleIndex;
  uint8_t   prachMaskIndex;
  enum Ngap_e
  {
    GAP1, GAP2
  } nGap;
  uint8_t   tbsIdx;
  uint8_t   dlPowerOffset;
  uint8_t   pdcchPowerOffset;
  /// this is the DCI field (for potential cross carrier scheduling)
  bool      cifPresent;
  uint8_t   cif;
};

/**
 * \brief See section 4.3.2 ulDciListElement
 */
struct UlDciListElement_s
{
  uint16_t  rnti;
  uint8_t   rbStart;
  uint8_t   rbLen;
  uint16_t  tbSize;
  uint8_t   mcs;
  uint8_t   ndi;
  uint8_t   cceIndex;
  uint8_t   aggrLevel;
  uint8_t   ueTxAntennaSelection;
  bool      hopping;
  uint8_t   n2Dmrs;
  int8_t    tpc;
  bool      cqiRequest;
  uint8_t   ulIndex;
  uint8_t   dai;
  uint8_t   freqHopping;
  int8_t    pdcchPowerOffset;
  /// this is the DCI field (for potential cross carrier scheduling)
  bool      cifPresent;
  uint8_t   cif;
  /// this is the carrier index where the DCI will be transmitted on
  uint8_t   servCellIndex;	//definition according to 36.331 'ServCellIndex'
};

/**
* \brief Base class for storing the values of vendor specific parameters
*/
struct VendorSpecificValue 
{ 
  uint32_t dummy;
  /*to be extended*/
};

/**
 * \brief See section 4.3.3 vendorSpecifiListElement
 */
struct VendorSpecificListElement_s
{
  uint32_t type;
  uint32_t length;
  struct VendorSpecificValue *value;
};

/**
 * \brief See section 4.3.4 logicalChannelConfigListElement
 */
struct LogicalChannelConfigListElement_s
{
  uint8_t   logicalChannelIdentity;
  uint8_t   logicalChannelGroup;

  enum Direction_e
  {
    DIR_UL,
    DIR_DL,
    DIR_BOTH
  } direction;

  enum QosBearerType_e
  {
    QBT_NON_GBR,
    QBT_GBR
  } qosBearerType;

  uint8_t   qci;
  uint64_t  eRabMaximulBitrateUl;
  uint64_t  eRabMaximulBitrateDl;
  uint64_t  eRabGuaranteedBitrateUl;
  uint64_t  eRabGuaranteedBitrateDl;
};

/**
 * \brief See section 4.3.6 rachListElement
 */
struct RachListElement_s
{
  uint16_t  rnti;
  uint16_t  estimatedSize;
  uint8_t   carrierIndex;
};

/**
 * \brief See section 4.3.7 phichListElement
 */
struct PhichListElement_s
{
  uint16_t  rnti;
  enum Phich_e
  {
    ACK, NACK
  } phich;
  uint8_t   servCellIndex;	//definition according to 36.331 'ServCellIndex'
};

/**
 * \brief See section 4.3.9 rlcPDU_ListElement
 */
struct RlcPduListElement_s
{
  uint8_t   logicalChannelIdentity;
  uint16_t  size;
};

/**
 * \brief See section 4.3.8 builDataListElement
 */
struct BuildDataListElement_s
{
  uint16_t  rnti;
  struct DlDciListElement_s dci;
  /* This is an array of CeBitmap_e enum flags. If one wants for example to signal TA in 1st TB and DRX and AD in 2nd one should:
   * ceBitmap[0] = ff_TA;  ceBitmap[1] = ff_DRX | ff_AD; */
  uint8_t ceBitmap[MAX_TB_LIST];
  uint8_t   nr_rlcPDU_List;
  struct RlcPduListElement_s rlcPduList[MAX_RLC_PDU_LIST][MAX_TB_LIST];
  uint8_t   servCellIndex;	//definition according to 36.331 'ServCellIndex'
  /* Hex content of Activation/Deactivation MAC CE */
  uint8_t	activationDeactivationCE;
};

/**
 * \brief See section 4.3.10 buildRARListElement
 */
struct BuildRarListElement_s
{
  uint16_t  rnti;
  uint32_t  grant; 
  struct DlDciListElement_s dci;
  uint8_t   carrierIndex;
};

/**
 * \brief See section 4.3.11 buildBroadcastListElement
 */
struct BuildBroadcastListElement_s
{
  enum BroadcastType_e
  {
    ff_BCCH, ff_PCCH
  } type;
  uint8_t index;
  struct DlDciListElement_s dci;
  uint8_t   carrierIndex;
};

/**
 * \brief See section 4.3.12 ulInfoListElement
 */
struct UlInfoListElement_s
{
  uint16_t  rnti;
  uint16_t  ulReception[MAX_LC_LIST+1];
  enum ReceptionStatus_e
  {
    Ok, NotOk, NotValid
  } receptionStatus;
  uint8_t   tpc;
  uint8_t   servCellIndex;	//definition according to 36.331 'ServCellIndex'
};

/**
 * \brief See section 4.3.13 srListElement
 */
struct SrListElement_s
{
  uint16_t  rnti;
};

/**
 * \brief See section 4.3.15 macCEValue
 */
struct MacCeUlValue_u
{
  uint8_t   phr;
  uint8_t   crnti;
  uint8_t   bufferStatus[MAX_NR_LCG];
};

/**
 * \brief See section 4.3.14 macCEListElement
 */
struct MacCeUlListElement_s
{
  uint16_t  rnti;
  enum MacCeType_e
  {
    ff_BSR, ff_PHR, ff_CRNTI
  } macCeType;
  struct MacCeUlValue_u macCeValue;
};

/**
 * \brief macCEDLValue (new)
 */
struct MacCeDlValue_u
{
  // timing advance value is not included here as it is supposed to be filled in by the MAC (scheduler does not care)
  // dtx CE does not have a value
  // contention resolution value should also be filled in by the MAC and not by the scheduler
  uint8_t   ActicationDeactivation;
};

/**
 * \brief macCEDLListElement (new)
 */
struct MacCeDlListElement_s
{
  uint16_t  rnti;
  enum CeBitmap_e macCeType;
  struct MacCeDlValue_u macCeValue;
};


/**
 * \brief See section 4.3.16 drxConfig
 */
struct DrxConfig_s
{
  uint8_t   onDurationTimer;
  uint16_t  drxInactivityTimer;
  uint16_t  drxRetransmissionTimer;
  uint16_t  longDrxCycle;
  uint16_t  longDrxCycleStartOffset;
  uint16_t  shortDrxCycle;
  uint8_t   drxShortCycleTimer;
};

/**
 * \brief See section 4.3.17 spsConfig
 */
struct SpsConfig_s
{
  uint16_t  semiPersistSchedIntervalUl;
  uint16_t  semiPersistSchedIntervalDl;
  uint8_t   numberOfConfSpsProcesses;
  uint8_t   n1PucchAnPersistentListSize;
  uint16_t  n1PucchAnPersistentList[4];
  uint8_t   implicitReleaseAfter;
};

/**
 * \brief See section 4.3.18 srConfig
 */
struct SrConfig_s
{
  enum SetupRelease_e action;
  uint8_t   schedInterval;
  uint8_t   dsrTransMax;
};

/**
 * \brief See section 4.3.19 cqiConfig
 */
struct CqiConfig_s
{
  enum SetupRelease_e action;
  uint16_t  cqiSchedInterval;
  uint8_t   riSchedInterval;
};

/**
 * \brief See section 4.3.20 ueCapabilities
 */
struct UeCapabilities_s
{
  bool      halfDuplex;
  bool      intraSfHopping;
  bool      type2Sb1;
  uint8_t   ueCategory;
  bool      resAllocType1;
};

/**
 * \brief See section 4.3.22 siMessageListElement
 */
struct SiMessageListElement_s
{
  uint16_t  periodicity;
  uint16_t  length;
};

/**
 * \brief See section 4.3.21 siConfiguration
 */
struct SiConfiguration_s
{
  uint16_t  sfn;
  uint16_t  sib1Length;
  uint8_t   siWindowLength;
  uint8_t   nrSI_Message_List;
  struct SiMessageListElement_s *siMessageList;
};

/**
 * \brief See section 4.3.23 dlInfoListElement
 */
struct DlInfoListElement_s
{
  uint16_t  rnti;
  uint8_t   harqProcessId;
  uint8_t nr_harqStatus;
  enum HarqStatus_e
    {
      ff_ACK, ff_NACK, ff_DTX
    } harqStatus[MAX_TB_LIST];
  uint8_t   servCellIndex;	//definition according to 36.331 'ServCellIndex'
};


/**
 * \brief Represents types of SCI reports for all CSI reporting modes. \a mode indicates which structure is held in \a report union.
 */
struct CsiReport_s
{
	uint8_t ri;

	enum CsiRepMode_e
	{
		P10, P11, P20, P21, A12, A22, A20, A30, A31
	} mode;

	union
	{
		struct A12Csi_s
		{
			uint8_t wbCqi[MAX_TB_LIST];
			uint8_t sbPmi[MAX_HL_SB];
		} A12Csi;

		struct A30Csi_s
		{
			uint8_t wbCqi;
			uint8_t sbCqi[MAX_HL_SB];
		} A30Csi;

		struct A31Csi_s
		{
			uint8_t wbCqi[MAX_TB_LIST];
			uint8_t sbCqi[MAX_HL_SB][MAX_TB_LIST];
			uint8_t wbPmi;
		} A31Csi;

		struct A20Csi_s
		{
			uint8_t wbCqi;
			uint8_t sbCqi;
			uint8_t sbList[MAX_UE_SELECTED_SB];
		} A20Csi;

		struct A22Csi_s
		{
			uint8_t wbCqi[MAX_TB_LIST];
			uint8_t sbCqi[MAX_TB_LIST];
			uint8_t wbPmi;
			uint8_t sbPmi;
			uint8_t sbList[MAX_UE_SELECTED_SB];
		} A22Csi;

		struct P10Csi_s
		{
			uint8_t wbCqi;
		} P10Csi;

		struct P11Csi_s
		{
			uint8_t wbCqi[MAX_TB_LIST];
			uint8_t wbPmi;
		} P11Csi;

		struct P20Csi_s
		{
			uint8_t wbCqi;
			uint8_t sbCqi;
			uint8_t bwPartIndex;	//range 0-3; to cover maximum number of BW parts (J)
			uint8_t sbIndex;		//range 0-3; to cover maximum number of subbands inside BW part (Nj)
		} P20Csi;

		struct P21Csi_s
		{
			uint8_t wbCqi[MAX_TB_LIST];
			uint8_t wbPmi;
			uint8_t sbCqi[MAX_TB_LIST];
			uint8_t bwPartIndex;	//range 0-3; to cover maximum number of BW parts (J)
			uint8_t sbIndex;		//range 0-3; to cover maximum number of subbands inside BW part (Nj)
		} P21Csi;
	} report;
};


/**
 * \brief Modified structure holding CSI report for single UE (for original structure see section 4.3.24 cqiListElement).
 */
struct CqiListElement_s
{
  uint16_t  rnti;
  struct CsiReport_s csiReport;
  uint8_t   servCellIndex;	//definition according to 36.331 'ServCellIndex'
};


/**
 * \brief See section 4.3.29 ulCQI
 */
struct UlCqi_s
{
  uint16_t rnti;
  uint16_t sinr[MAX_SINR_RB_LIST];
  enum UlCqiType_e
    {
      ff_SRS,
      ff_PUSCH,
      ff_PUCCH_1,
      ff_PUCCH_2,
      ff_PRACH
    } type;
    uint8_t servCellIndex;	//definition according to 36.331 'ServCellIndex'
};

/**
 * \brief See section 4.3.30 pagingInfoListElement
 */
struct PagingInfoListElement_s
{
  uint8_t   pagingIndex;
  uint16_t  pagingMessageSize;
  uint8_t   pagingSubframe;
  uint8_t   carrierIndex;
};

/**
 * \brief Describes the SCell configuration.
 */
struct ScellConfig_s
{
	/* Unique carrier identifier */
	uint8_t carrierIndex;
	/* Index of this SCell (RRC SCellIndex) */
	uint8_t	scellIndex;
	/* Indicates if cross-carrier scheduling shall be used or not on the SCell */
	bool useCrossCarrierScheduling;
	/* Index of the cell responsible for delivering scheduling for this SCell */
	uint8_t schedulingCellIndex;
	/* Starting OFDM symbol of PDSCH data region for this SCell */
	uint8_t pdschStart;
};

struct PdcchOfdmSymbolCountListElement_s
{
	/* Unique carrier identifier */
	uint8_t carrierIndex;
	/* Size of PDCCH in OFDM symbols */
	uint8_t pdcchOfdmSymbolCount;
};

#if defined (__cplusplus)
}
#endif

#endif /* FF_MAC_COMMON_H */