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-18 03:11:31 -07:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* This file is part of srsLTE.
|
2017-05-18 03:11:31 -07:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2017-05-18 03:11:31 -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-18 03:11:31 -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 SRSLTE_PDU_QUEUE_H
|
|
|
|
#define SRSLTE_PDU_QUEUE_H
|
2017-05-18 03:11:31 -07:00
|
|
|
|
2017-05-31 14:39:17 -07:00
|
|
|
#include "srslte/common/block_queue.h"
|
|
|
|
#include "srslte/common/buffer_pool.h"
|
2019-12-16 07:04:22 -08:00
|
|
|
#include "srslte/common/log.h"
|
|
|
|
#include "srslte/common/timers.h"
|
2020-04-21 12:53:37 -07:00
|
|
|
#include "srslte/mac/pdu.h"
|
2017-05-18 03:11:31 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
/* Logical Channel Demultiplexing and MAC CE dissassemble */
|
2017-05-18 03:11:31 -07:00
|
|
|
|
|
|
|
namespace srslte {
|
|
|
|
|
|
|
|
class pdu_queue
|
|
|
|
{
|
|
|
|
public:
|
2019-12-16 07:04:22 -08:00
|
|
|
typedef enum { DCH, BCH, MCH } channel_t;
|
2017-05-18 03:11:31 -07:00
|
|
|
class process_callback
|
|
|
|
{
|
2019-12-16 07:04:22 -08:00
|
|
|
public:
|
|
|
|
virtual void process_pdu(uint8_t* buff, uint32_t len, channel_t channel) = 0;
|
2017-05-18 03:11:31 -07:00
|
|
|
};
|
|
|
|
|
2020-03-19 08:45:30 -07:00
|
|
|
pdu_queue(uint32_t pool_size = DEFAULT_POOL_SIZE) : pool(pool_size), callback(NULL) {}
|
|
|
|
void init(process_callback* callback, log_ref log_h_);
|
2017-05-18 03:11:31 -07:00
|
|
|
|
2018-04-25 04:44:58 -07:00
|
|
|
uint8_t* request(uint32_t len);
|
2017-05-18 03:11:31 -07:00
|
|
|
void deallocate(uint8_t* pdu);
|
2019-04-23 01:53:11 -07:00
|
|
|
void push(uint8_t* ptr, uint32_t len, channel_t channel = DCH);
|
2018-04-25 04:44:58 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
bool process_pdus();
|
2018-04-25 04:44:58 -07:00
|
|
|
|
2020-11-11 11:51:49 -08:00
|
|
|
void reset();
|
|
|
|
|
2017-05-18 03:11:31 -07:00
|
|
|
private:
|
2019-12-16 07:04:22 -08:00
|
|
|
const static int DEFAULT_POOL_SIZE = 64; // Number of PDU buffers in total
|
|
|
|
const static int MAX_PDU_LEN = 150 * 1024 / 8; // ~ 150 Mbps
|
2018-04-25 04:44:58 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
typedef struct {
|
|
|
|
uint8_t ptr[MAX_PDU_LEN];
|
|
|
|
uint32_t len;
|
2018-04-25 04:44:58 -07:00
|
|
|
channel_t channel;
|
2019-12-16 07:04:22 -08:00
|
|
|
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
|
|
|
|
char debug_name[128];
|
|
|
|
#endif
|
2017-06-06 11:04:19 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
} pdu_t;
|
|
|
|
|
|
|
|
block_queue<pdu_t*> pdu_q;
|
2017-05-18 03:11:31 -07:00
|
|
|
buffer_pool<pdu_t> pool;
|
2019-12-16 07:04:22 -08:00
|
|
|
|
|
|
|
process_callback* callback;
|
2020-03-19 08:45:30 -07:00
|
|
|
log_ref log_h;
|
2017-05-18 03:11:31 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace srslte
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSLTE_PDU_QUEUE_H
|