/* * Copyright 2013-2019 Software Radio Systems Limited * * This file is part of srsLTE. * * srsLTE is free software: you can redistribute it and/or modify * 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 * GNU Affero General Public License for more details. * * 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/. * */ #ifndef SRSLTE_RLC_COMMON_H #define SRSLTE_RLC_COMMON_H #include "srslte/common/block_queue.h" #include namespace srslte { /**************************************************************************** * Structs and Defines * Ref: 3GPP TS 36.322 v10.0.0 ***************************************************************************/ #define RLC_AM_WINDOW_SIZE 512 #define RLC_MAX_SDU_SIZE ((1<<11)-1) // Length of LI field is 11bits typedef enum{ RLC_FI_FIELD_START_AND_END_ALIGNED = 0, RLC_FI_FIELD_NOT_END_ALIGNED, RLC_FI_FIELD_NOT_START_ALIGNED, RLC_FI_FIELD_NOT_START_OR_END_ALIGNED, RLC_FI_FIELD_N_ITEMS, }rlc_fi_field_t; static const char rlc_fi_field_text[RLC_FI_FIELD_N_ITEMS][32] = {"Start and end aligned", "Not end aligned", "Not start aligned", "Not start or end aligned"}; enum class rlc_nr_si_field_t : unsigned { full_sdu = 0b00, first_segment = 0b01, last_segment = 0b10, neither_first_nor_last_segment = 0b11, nulltype }; inline std::string to_string(const rlc_nr_si_field_t& si) { constexpr static const char* options[] = {"Data field contains full SDU", "Data field contains first segment of SDU", "Data field contains last segment of SDU", "Data field contains neither first nor last segment of SDU"}; return enum_to_text(options, (uint32_t)rlc_nr_si_field_t::nulltype, (uint32_t)si); } static inline uint8_t operator&(rlc_nr_si_field_t lhs, int rhs) { return static_cast(static_cast::type>(lhs) & static_cast::type>(rhs)); } typedef enum{ RLC_DC_FIELD_CONTROL_PDU = 0, RLC_DC_FIELD_DATA_PDU, RLC_DC_FIELD_N_ITEMS, }rlc_dc_field_t; static const char rlc_dc_field_text[RLC_DC_FIELD_N_ITEMS][20] = {"Control PDU", "Data PDU"}; // UMD PDU Header typedef struct{ uint8_t fi; // Framing info rlc_umd_sn_size_t sn_size; // Sequence number size (5 or 10 bits) uint16_t sn; // Sequence number uint32_t N_li; // Number of length indicators uint16_t li[RLC_AM_WINDOW_SIZE]; // Array of length indicators }rlc_umd_pdu_header_t; typedef struct { rlc_nr_si_field_t si; // Segmentation info rlc_um_nr_sn_size_t sn_size; // Sequence number size (6 or 12 bits) uint16_t sn; // Sequence number uint16_t so; // Sequence offset } rlc_um_nr_pdu_header_t; // AMD PDU Header struct rlc_amd_pdu_header_t{ rlc_dc_field_t dc; // Data or control uint8_t rf; // Resegmentation flag uint8_t p; // Polling bit uint8_t fi; // Framing info uint16_t sn; // Sequence number uint8_t lsf; // Last segment flag uint16_t so; // Segment offset uint32_t N_li; // Number of length indicators uint16_t li[RLC_AM_WINDOW_SIZE]; // Array of length indicators rlc_amd_pdu_header_t(){ dc = RLC_DC_FIELD_CONTROL_PDU; rf = 0; p = 0; fi = 0; sn = 0; lsf = 0; so = 0; N_li=0; for(int i=0;i rx_pdu_resume_queue; }; } // namespace srslte #endif // SRSLTE_RLC_COMMON_H