mirror of https://github.com/pvnis/srsRAN_4G.git
sched,nr: creation of pool of softbuffers for NR. Now the sched NR harq manages the lifetime of the softbuffer and its forwarding to the PHY
parent
1535e6b205
commit
d9336bcd9e
@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||||||
|
*
|
||||||
|
* By using this file, you agree to the terms and conditions set
|
||||||
|
* forth in the LICENSE file which can be found at the top level of
|
||||||
|
* the distribution.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRSRAN_HARQ_SOFTBUFFER_H
|
||||||
|
#define SRSRAN_HARQ_SOFTBUFFER_H
|
||||||
|
|
||||||
|
#include "srsran/adt/pool/pool_interface.h"
|
||||||
|
#include "srsran/adt/span.h"
|
||||||
|
extern "C" {
|
||||||
|
#include "srsran/phy/common/phy_common_nr.h"
|
||||||
|
#include "srsran/phy/fec/softbuffer.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace srsenb {
|
||||||
|
|
||||||
|
class tx_harq_softbuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
tx_harq_softbuffer() { bzero(&buffer, sizeof(buffer)); }
|
||||||
|
explicit tx_harq_softbuffer(uint32_t nof_prb_) { srsran_softbuffer_tx_init(&buffer, nof_prb_); }
|
||||||
|
tx_harq_softbuffer(const tx_harq_softbuffer&) = delete;
|
||||||
|
tx_harq_softbuffer(tx_harq_softbuffer&& other) noexcept
|
||||||
|
{
|
||||||
|
memcpy(&buffer, &other.buffer, sizeof(other.buffer));
|
||||||
|
bzero(&other.buffer, sizeof(other.buffer));
|
||||||
|
}
|
||||||
|
tx_harq_softbuffer& operator=(const tx_harq_softbuffer&) = delete;
|
||||||
|
tx_harq_softbuffer& operator =(tx_harq_softbuffer&& other) noexcept
|
||||||
|
{
|
||||||
|
if (this != &other) {
|
||||||
|
destroy();
|
||||||
|
memcpy(&buffer, &other.buffer, sizeof(other.buffer));
|
||||||
|
bzero(&other.buffer, sizeof(other.buffer));
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~tx_harq_softbuffer() { destroy(); }
|
||||||
|
|
||||||
|
void reset() { srsran_softbuffer_tx_reset(&buffer); }
|
||||||
|
|
||||||
|
srsran_softbuffer_tx_t& operator*() { return buffer; }
|
||||||
|
const srsran_softbuffer_tx_t& operator*() const { return buffer; }
|
||||||
|
srsran_softbuffer_tx_t* operator->() { return &buffer; }
|
||||||
|
const srsran_softbuffer_tx_t* operator->() const { return &buffer; }
|
||||||
|
srsran_softbuffer_tx_t* get() { return &buffer; }
|
||||||
|
const srsran_softbuffer_tx_t* get() const { return &buffer; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void destroy() { srsran_softbuffer_tx_free(&buffer); }
|
||||||
|
|
||||||
|
srsran_softbuffer_tx_t buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class rx_harq_softbuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
rx_harq_softbuffer() { bzero(&buffer, sizeof(buffer)); }
|
||||||
|
explicit rx_harq_softbuffer(uint32_t nof_prb_) { srsran_softbuffer_rx_init(&buffer, nof_prb_); }
|
||||||
|
rx_harq_softbuffer(const rx_harq_softbuffer&) = delete;
|
||||||
|
rx_harq_softbuffer(rx_harq_softbuffer&& other) noexcept
|
||||||
|
{
|
||||||
|
memcpy(&buffer, &other.buffer, sizeof(other.buffer));
|
||||||
|
bzero(&other.buffer, sizeof(other.buffer));
|
||||||
|
}
|
||||||
|
rx_harq_softbuffer& operator=(const rx_harq_softbuffer&) = delete;
|
||||||
|
rx_harq_softbuffer& operator =(rx_harq_softbuffer&& other) noexcept
|
||||||
|
{
|
||||||
|
if (this != &other) {
|
||||||
|
destroy();
|
||||||
|
memcpy(&buffer, &other.buffer, sizeof(other.buffer));
|
||||||
|
bzero(&other.buffer, sizeof(other.buffer));
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~rx_harq_softbuffer() { destroy(); }
|
||||||
|
|
||||||
|
void reset() { srsran_softbuffer_rx_reset(&buffer); }
|
||||||
|
void reset(uint32_t tbs_bits) { srsran_softbuffer_rx_reset_tbs(&buffer, tbs_bits); }
|
||||||
|
|
||||||
|
srsran_softbuffer_rx_t& operator*() { return buffer; }
|
||||||
|
const srsran_softbuffer_rx_t& operator*() const { return buffer; }
|
||||||
|
srsran_softbuffer_rx_t* operator->() { return &buffer; }
|
||||||
|
const srsran_softbuffer_rx_t* operator->() const { return &buffer; }
|
||||||
|
srsran_softbuffer_rx_t* get() { return &buffer; }
|
||||||
|
const srsran_softbuffer_rx_t* get() const { return &buffer; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void destroy() { srsran_softbuffer_rx_free(&buffer); }
|
||||||
|
|
||||||
|
srsran_softbuffer_rx_t buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class harq_softbuffer_pool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
harq_softbuffer_pool(const harq_softbuffer_pool&) = delete;
|
||||||
|
harq_softbuffer_pool(harq_softbuffer_pool&&) = delete;
|
||||||
|
harq_softbuffer_pool& operator=(const harq_softbuffer_pool&) = delete;
|
||||||
|
harq_softbuffer_pool& operator=(harq_softbuffer_pool&&) = delete;
|
||||||
|
|
||||||
|
void init_pool(uint32_t nof_prb, uint32_t batch_size = MAX_HARQ * 4, uint32_t thres = 0, uint32_t init_size = 0);
|
||||||
|
|
||||||
|
srsran::unique_pool_ptr<tx_harq_softbuffer> get_tx(uint32_t nof_prb);
|
||||||
|
srsran::unique_pool_ptr<rx_harq_softbuffer> get_rx(uint32_t nof_prb);
|
||||||
|
|
||||||
|
static harq_softbuffer_pool& get_instance()
|
||||||
|
{
|
||||||
|
static harq_softbuffer_pool pool;
|
||||||
|
return pool;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const static uint32_t MAX_HARQ = 16;
|
||||||
|
|
||||||
|
harq_softbuffer_pool() = default;
|
||||||
|
|
||||||
|
std::array<std::unique_ptr<srsran::obj_pool_itf<tx_harq_softbuffer> >, SRSRAN_MAX_PRB_NR> tx_pool;
|
||||||
|
std::array<std::unique_ptr<srsran::obj_pool_itf<rx_harq_softbuffer> >, SRSRAN_MAX_PRB_NR> rx_pool;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace srsenb
|
||||||
|
|
||||||
|
#endif // SRSRAN_HARQ_SOFTBUFFER_H
|
@ -0,0 +1,62 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||||||
|
*
|
||||||
|
* By using this file, you agree to the terms and conditions set
|
||||||
|
* forth in the LICENSE file which can be found at the top level of
|
||||||
|
* the distribution.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "srsenb/hdr/stack/mac/nr/harq_softbuffer.h"
|
||||||
|
#include "srsran/adt/pool/obj_pool.h"
|
||||||
|
|
||||||
|
namespace srsenb {
|
||||||
|
|
||||||
|
void harq_softbuffer_pool::init_pool(uint32_t nof_prb, uint32_t batch_size, uint32_t thres, uint32_t init_size)
|
||||||
|
{
|
||||||
|
srsran_assert(nof_prb <= SRSRAN_MAX_PRB_NR, "Invalid nof prb=%d", nof_prb);
|
||||||
|
size_t idx = nof_prb - 1;
|
||||||
|
if (tx_pool[idx] != nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (thres == 0) {
|
||||||
|
thres = batch_size;
|
||||||
|
}
|
||||||
|
if (init_size == 0) {
|
||||||
|
init_size = batch_size;
|
||||||
|
}
|
||||||
|
auto init_tx_softbuffers = [nof_prb](void* ptr) { new (ptr) tx_harq_softbuffer(nof_prb); };
|
||||||
|
auto recycle_tx_softbuffers = [](tx_harq_softbuffer& softbuffer) { softbuffer.reset(); };
|
||||||
|
tx_pool[idx].reset(new srsran::background_obj_pool<tx_harq_softbuffer>(
|
||||||
|
batch_size, thres, init_size, init_tx_softbuffers, recycle_tx_softbuffers));
|
||||||
|
|
||||||
|
auto init_rx_softbuffers = [nof_prb](void* ptr) { new (ptr) rx_harq_softbuffer(nof_prb); };
|
||||||
|
auto recycle_rx_softbuffers = [](rx_harq_softbuffer& softbuffer) { softbuffer.reset(); };
|
||||||
|
rx_pool[idx].reset(new srsran::background_obj_pool<rx_harq_softbuffer>(
|
||||||
|
batch_size, thres, init_size, init_rx_softbuffers, recycle_rx_softbuffers));
|
||||||
|
}
|
||||||
|
|
||||||
|
srsran::unique_pool_ptr<tx_harq_softbuffer> harq_softbuffer_pool::get_tx(uint32_t nof_prb)
|
||||||
|
{
|
||||||
|
srsran_assert(nof_prb <= SRSRAN_MAX_PRB_NR, "Invalid Nprb=%d", nof_prb);
|
||||||
|
size_t idx = nof_prb - 1;
|
||||||
|
if (tx_pool[idx] == nullptr) {
|
||||||
|
init_pool(nof_prb);
|
||||||
|
}
|
||||||
|
return tx_pool[idx]->make();
|
||||||
|
}
|
||||||
|
|
||||||
|
srsran::unique_pool_ptr<rx_harq_softbuffer> harq_softbuffer_pool::get_rx(uint32_t nof_prb)
|
||||||
|
{
|
||||||
|
srsran_assert(nof_prb <= SRSRAN_MAX_PRB_NR, "Invalid Nprb=%d", nof_prb);
|
||||||
|
size_t idx = nof_prb - 1;
|
||||||
|
if (rx_pool[idx] == nullptr) {
|
||||||
|
init_pool(nof_prb);
|
||||||
|
}
|
||||||
|
return rx_pool[idx]->make();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace srsenb
|
Loading…
Reference in New Issue