srsLTE/srsue/hdr/stack/mac/mux.h

116 lines
3.1 KiB
C
Raw Normal View History

2019-04-26 12:27:38 -07:00
/*
* Copyright 2013-2019 Software Radio Systems Limited
2017-05-30 06:38:04 -07:00
*
2019-04-26 12:27:38 -07:00
* This file is part of srsLTE.
2017-05-30 06:38:04 -07:00
*
2019-04-26 12:27:38 -07:00
* srsLTE is free software: you can redistribute it and/or modify
2017-05-30 06:38:04 -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.
*
2019-04-26 12:27:38 -07:00
* srsLTE is distributed in the hope that it will be useful,
2017-05-30 06:38:04 -07:00
* 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/.
*
*/
2018-03-31 10:04:04 -07:00
#ifndef SRSUE_MUX_H
#define SRSUE_MUX_H
2017-05-30 06:38:04 -07:00
#include <pthread.h>
#include <vector>
#include "proc_bsr.h"
#include "proc_phr.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/common/pdu.h"
#include "srslte/interfaces/ue_interfaces.h"
2019-06-18 12:14:04 -07:00
#include <mutex>
2017-05-30 06:38:04 -07:00
/* Logical Channel Multiplexing and Prioritization + Msg3 Buffer */
typedef struct {
uint8_t lcid;
uint8_t lcg;
2019-06-18 12:14:04 -07:00
int32_t Bj;
int32_t PBR; // in kByte/s, -1 sets to infinity
uint32_t bucket_size;
uint32_t BSD;
uint32_t priority;
int sched_len;
int buffer_len;
} logical_channel_config_t;
2017-05-30 06:38:04 -07:00
namespace srsue {
class mux
{
public:
mux(srslte::log* log_);
2019-06-18 12:14:04 -07:00
~mux(){};
2017-05-30 06:38:04 -07:00
void reset();
void init(rlc_interface_mac* rlc, bsr_interface_mux* bsr_procedure, phr_proc* phr_procedure_);
2017-05-30 06:38:04 -07:00
2019-06-18 12:14:04 -07:00
void step(const uint32_t tti);
2017-05-30 06:38:04 -07:00
bool is_pending_any_sdu();
2019-04-23 01:53:11 -07:00
bool is_pending_sdu(uint32_t lcid);
uint8_t* pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz);
uint8_t* msg3_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz);
2017-05-30 06:38:04 -07:00
void msg3_flush();
bool msg3_is_transmitted();
2018-02-13 14:31:52 -08:00
void msg3_prepare();
bool msg3_is_pending();
bool msg3_is_empty();
2019-04-23 01:53:11 -07:00
void append_crnti_ce_next_tx(uint16_t crnti);
void setup_lcid(const logical_channel_config_t& config);
void print_logical_channel_state(const std::string& info);
private:
bool has_logical_channel(const uint32_t& lcid);
2017-05-30 06:38:04 -07:00
bool pdu_move_to_msg3(uint32_t pdu_sz);
bool allocate_sdu(uint32_t lcid, srslte::sch_pdu *pdu, int max_sdu_sz);
bool sched_sdu(logical_channel_config_t* ch, int* sdu_space, int max_sdu_sz);
2019-04-23 01:53:11 -07:00
const static int MAX_NOF_SUBHEADERS = 20;
std::vector<logical_channel_config_t> logical_channels;
2017-05-30 06:38:04 -07:00
// Mutex for exclusive access
2019-06-18 12:14:04 -07:00
std::mutex mutex;
2017-05-30 06:38:04 -07:00
2019-06-18 12:14:04 -07:00
srslte::log* log_h = nullptr;
rlc_interface_mac* rlc = nullptr;
bsr_interface_mux* bsr_procedure = nullptr;
phr_proc* phr_procedure = nullptr;
uint16_t pending_crnti_ce = 0;
2019-04-23 01:53:11 -07:00
2017-05-30 06:38:04 -07:00
/* Msg3 Buffer */
srslte::byte_buffer_t msg_buff;
2018-03-02 07:49:52 -08:00
2017-05-30 06:38:04 -07:00
/* PDU Buffer */
2019-06-18 12:14:04 -07:00
srslte::sch_pdu pdu_msg;
srslte::byte_buffer_t msg3_buff;
bool msg3_has_been_transmitted = false;
bool msg3_pending = false;
2017-05-30 06:38:04 -07:00
};
} // namespace srsue
2018-03-31 10:04:04 -07:00
#endif // SRSUE_MUX_H
2017-05-30 06:38:04 -07:00