srsLTE/lib/include/srslte/phy/phch/ra.h

108 lines
3.3 KiB
C
Raw Normal View History

2019-04-26 12:27:38 -07:00
/*
* Copyright 2013-2019 Software Radio Systems Limited
*
2019-04-26 12:27:38 -07:00
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
2015-05-08 08:05:40 -07:00
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE 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
2015-05-08 08:05:40 -07:00
* GNU Affero General Public License for more details.
*
2015-05-08 08:05:40 -07:00
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
/******************************************************************************
* File: ra.h
*
2019-04-23 01:53:11 -07:00
* Description: Implements Resource allocation Procedures common in for DL and UL
*
* Reference: 3GPP TS 36.213 version 10.0.1 Release 10
*****************************************************************************/
2018-03-31 10:04:04 -07:00
#ifndef SRSLTE_RA_H
#define SRSLTE_RA_H
#include <stdbool.h>
#include <stdint.h>
#include "srslte/config.h"
2017-05-18 00:48:24 -07:00
#include "srslte/phy/common/phy_common.h"
/**************************************************
2019-04-23 01:53:11 -07:00
* Common structures used for Resource Allocation
**************************************************/
typedef struct SRSLTE_API {
2015-03-18 05:59:29 -07:00
srslte_mod_t mod;
2019-04-23 01:53:11 -07:00
int tbs;
int rv;
uint32_t nof_bits;
uint32_t cw_idx;
bool enabled;
2019-04-23 01:53:11 -07:00
// this is for debugging and metrics purposes
uint32_t mcs_idx;
} srslte_ra_tb_t;
typedef enum SRSLTE_API {
2019-04-23 01:53:11 -07:00
SRSLTE_RA_ALLOC_TYPE0 = 0,
SRSLTE_RA_ALLOC_TYPE1 = 1,
2015-03-18 11:14:24 -07:00
SRSLTE_RA_ALLOC_TYPE2 = 2
} srslte_ra_type_t;
typedef struct SRSLTE_API {
2014-06-17 02:11:41 -07:00
uint32_t rbg_bitmask;
2015-03-18 11:14:24 -07:00
} srslte_ra_type0_t;
typedef struct SRSLTE_API {
2014-06-17 02:11:41 -07:00
uint32_t vrb_bitmask;
uint32_t rbg_subset;
2019-04-23 01:53:11 -07:00
bool shift;
2015-03-18 11:14:24 -07:00
} srslte_ra_type1_t;
typedef struct SRSLTE_API {
uint32_t riv; // if L_crb==0, DCI message packer will take this value directly
enum { SRSLTE_RA_TYPE2_NPRB1A_2 = 0, SRSLTE_RA_TYPE2_NPRB1A_3 = 1 } n_prb1a;
enum { SRSLTE_RA_TYPE2_NG1 = 0, SRSLTE_RA_TYPE2_NG2 = 1 } n_gap;
enum { SRSLTE_RA_TYPE2_LOC = 0, SRSLTE_RA_TYPE2_DIST = 1 } mode;
2015-03-18 11:14:24 -07:00
} srslte_ra_type2_t;
2015-03-18 11:14:24 -07:00
SRSLTE_API uint32_t srslte_ra_type0_P(uint32_t nof_prb);
2019-04-23 01:53:11 -07:00
SRSLTE_API uint32_t srslte_ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1);
2015-03-18 11:14:24 -07:00
SRSLTE_API uint32_t srslte_ra_type2_n_rb_step(uint32_t nof_prb);
2019-04-23 01:53:11 -07:00
SRSLTE_API uint32_t srslte_ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1);
2015-03-18 11:14:24 -07:00
SRSLTE_API uint32_t srslte_ra_type1_N_rb(uint32_t nof_prb);
2019-04-23 01:53:11 -07:00
SRSLTE_API uint32_t srslte_ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_prb);
SRSLTE_API void
srslte_ra_type2_from_riv(uint32_t riv, uint32_t* L_crb, uint32_t* RB_start, uint32_t nof_prb, uint32_t nof_vrb);
2019-04-23 01:53:11 -07:00
SRSLTE_API int srslte_ra_tbs_idx_from_mcs(uint32_t mcs, bool is_ul);
2019-04-23 01:53:11 -07:00
SRSLTE_API srslte_mod_t srslte_ra_dl_mod_from_mcs(uint32_t mcs);
SRSLTE_API srslte_mod_t srslte_ra_dl_mod_from_mcs2(uint32_t mcs);
2019-04-23 01:53:11 -07:00
SRSLTE_API srslte_mod_t srslte_ra_ul_mod_from_mcs(uint32_t mcs);
2019-04-23 01:53:11 -07:00
SRSLTE_API int srslte_ra_mcs_from_tbs_idx(uint32_t tbs_idx, bool is_ul);
2017-09-21 03:48:09 -07:00
2019-04-23 01:53:11 -07:00
SRSLTE_API int srslte_ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb);
2017-09-21 03:48:09 -07:00
2019-04-23 01:53:11 -07:00
SRSLTE_API int srslte_ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb);
2017-09-21 03:48:09 -07:00
2019-04-23 01:53:11 -07:00
#endif // SRSLTE_RA_H