2019-04-26 12:27:38 -07:00
|
|
|
/*
|
2020-03-13 04:12:52 -07:00
|
|
|
* Copyright 2013-2020 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>
|
|
|
|
|
2018-04-01 09:08:24 -07:00
|
|
|
#include "proc_bsr.h"
|
|
|
|
#include "proc_phr.h"
|
2019-06-14 13:11:25 -07:00
|
|
|
#include "srslte/common/common.h"
|
|
|
|
#include "srslte/common/log.h"
|
|
|
|
#include "srslte/interfaces/ue_interfaces.h"
|
2020-04-21 12:53:37 -07:00
|
|
|
#include "srslte/mac/pdu.h"
|
2019-06-18 12:14:04 -07:00
|
|
|
#include <mutex>
|
2017-05-30 06:38:04 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
/* Logical Channel Multiplexing and Prioritization + Msg3 Buffer */
|
2017-05-30 06:38:04 -07:00
|
|
|
|
|
|
|
typedef struct {
|
2019-06-14 13:11:25 -07:00
|
|
|
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;
|
2019-06-14 13:11:25 -07:00
|
|
|
uint32_t BSD;
|
|
|
|
uint32_t priority;
|
2020-08-31 14:45:06 -07:00
|
|
|
int sched_len; // scheduled upper layer payload for this LCID
|
|
|
|
int buffer_len; // outstanding bytes for this LCID
|
2019-06-14 13:11:25 -07:00
|
|
|
} logical_channel_config_t;
|
2017-05-30 06:38:04 -07:00
|
|
|
|
|
|
|
namespace srsue {
|
2019-12-16 07:04:22 -08:00
|
|
|
|
2017-05-30 06:38:04 -07:00
|
|
|
class mux
|
|
|
|
{
|
|
|
|
public:
|
2020-03-19 08:45:30 -07:00
|
|
|
mux(srslte::log_ref log_);
|
2019-06-18 12:14:04 -07:00
|
|
|
~mux(){};
|
2019-12-16 07:04:22 -08: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
|
|
|
|
2020-03-18 09:00:46 -07:00
|
|
|
void step();
|
2019-06-18 12:14:04 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
bool is_pending_any_sdu();
|
|
|
|
bool is_pending_sdu(uint32_t lcid);
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2019-06-14 13:11:25 -07:00
|
|
|
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);
|
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
void msg3_flush();
|
|
|
|
bool msg3_is_transmitted();
|
|
|
|
void msg3_prepare();
|
|
|
|
bool msg3_is_pending();
|
|
|
|
bool msg3_is_empty();
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2019-06-14 13:11:25 -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:
|
2019-12-16 07:04:22 -08:00
|
|
|
bool has_logical_channel(const uint32_t& lcid);
|
|
|
|
bool pdu_move_to_msg3(uint32_t pdu_sz);
|
2020-11-09 01:50:02 -08:00
|
|
|
uint32_t allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu, int max_sdu_sz);
|
2019-12-16 07:04:22 -08:00
|
|
|
bool sched_sdu(logical_channel_config_t* ch, int* sdu_space, int max_sdu_sz);
|
2019-06-14 13:11:25 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
const static int MAX_NOF_SUBHEADERS = 20;
|
|
|
|
|
2019-06-14 13:11:25 -07:00
|
|
|
std::vector<logical_channel_config_t> logical_channels;
|
2017-10-05 07:52:02 -07:00
|
|
|
|
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
|
|
|
|
2020-03-19 08:45:30 -07:00
|
|
|
srslte::log_ref log_h;
|
2019-06-18 12:14:04 -07:00
|
|
|
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 */
|
2019-06-14 13:11:25 -07:00
|
|
|
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;
|
2019-07-06 01:32:06 -07:00
|
|
|
|
|
|
|
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
|