changed the naming of mch to m1u in the gtpu class

master
Francisco Paisana 5 years ago
parent 2512e0fd79
commit e8487211e4

@ -160,7 +160,7 @@ public:
rx_multisocket_handler(rx_multisocket_handler&&) = delete; rx_multisocket_handler(rx_multisocket_handler&&) = delete;
rx_multisocket_handler(const rx_multisocket_handler&) = delete; rx_multisocket_handler(const rx_multisocket_handler&) = delete;
rx_multisocket_handler& operator=(const rx_multisocket_handler&) = delete; rx_multisocket_handler& operator=(const rx_multisocket_handler&) = delete;
rx_multisocket_handler& operator=(const rx_multisocket_handler&&) = delete; rx_multisocket_handler& operator=(rx_multisocket_handler&&) = delete;
~rx_multisocket_handler(); ~rx_multisocket_handler();
void stop(); void stop();

@ -347,8 +347,8 @@ public:
class stack_interface_gtpu_lte class stack_interface_gtpu_lte
{ {
public: public:
virtual void add_gtpu_socket(int fd) = 0; virtual void add_gtpu_s1u_socket_handler(int fd) = 0;
virtual void add_gtpu_mch_socket(int fd) = 0; virtual void add_gtpu_m1u_socket_handler(int fd) = 0;
}; };
} // namespace srsenb } // namespace srsenb

@ -96,8 +96,8 @@ public:
/* STACK-S1AP interface*/ /* STACK-S1AP interface*/
void add_mme_socket(int fd) override; void add_mme_socket(int fd) override;
void remove_mme_socket(int fd) override; void remove_mme_socket(int fd) override;
void add_gtpu_socket(int fd) override; void add_gtpu_s1u_socket_handler(int fd) override;
void add_gtpu_mch_socket(int fd) override; void add_gtpu_m1u_socket_handler(int fd) override;
private: private:
static const int STACK_MAIN_THREAD_PRIO = -1; // Use default high-priority below UHD static const int STACK_MAIN_THREAD_PRIO = -1; // Use default high-priority below UHD

@ -19,23 +19,22 @@
* *
*/ */
#include <string.h>
#include <map> #include <map>
#include <string.h>
#include "common_enb.h"
#include "srslte/common/buffer_pool.h" #include "srslte/common/buffer_pool.h"
#include "srslte/common/log.h" #include "srslte/common/log.h"
#include "common_enb.h"
#include "srslte/common/threads.h" #include "srslte/common/threads.h"
#include "srslte/srslte.h"
#include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/enb_interfaces.h"
#include "srslte/srslte.h"
#ifndef SRSENB_GTPU_H #ifndef SRSENB_GTPU_H
#define SRSENB_GTPU_H #define SRSENB_GTPU_H
namespace srsenb { namespace srsenb {
class gtpu : public gtpu_interface_rrc, public gtpu_interface_pdcp class gtpu final : public gtpu_interface_rrc, public gtpu_interface_pdcp
{ {
public: public:
gtpu(); gtpu();
@ -51,20 +50,19 @@ public:
void stop(); void stop();
// gtpu_interface_rrc // gtpu_interface_rrc
void add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t teid_out, uint32_t *teid_in); void add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t teid_out, uint32_t* teid_in) override;
void rem_bearer(uint16_t rnti, uint32_t lcid); void rem_bearer(uint16_t rnti, uint32_t lcid) override;
void rem_user(uint16_t rnti); void rem_user(uint16_t rnti) override;
// gtpu_interface_pdcp // gtpu_interface_pdcp
void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu); void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) override;
// stack interface // stack interface
void handle_gtpu_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); void handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr);
void handle_gtpu_mch_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); void handle_gtpu_m1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr);
private: private:
static const int THREAD_PRIO = 65; static const int GTPU_PORT = 2152;
static const int GTPU_PORT = 2152;
srslte::byte_buffer_pool* pool = nullptr; srslte::byte_buffer_pool* pool = nullptr;
stack_interface_gtpu_lte* stack = nullptr; stack_interface_gtpu_lte* stack = nullptr;
@ -76,15 +74,15 @@ private:
srslte::log* gtpu_log = nullptr; srslte::log* gtpu_log = nullptr;
// Class to create // Class to create
class mch_handler class m1u_handler
{ {
public: public:
explicit mch_handler(gtpu* gtpu_) : parent(gtpu_) {} explicit m1u_handler(gtpu* gtpu_) : parent(gtpu_) {}
~mch_handler(); ~m1u_handler();
mch_handler(const mch_handler&) = delete; m1u_handler(const m1u_handler&) = delete;
mch_handler(mch_handler&&) = delete; m1u_handler(m1u_handler&&) = delete;
mch_handler& operator=(const mch_handler&) = delete; m1u_handler& operator=(const m1u_handler&) = delete;
mch_handler& operator=(mch_handler&&) = delete; m1u_handler& operator=(m1u_handler&&) = delete;
bool init(std::string m1u_multiaddr_, std::string m1u_if_addr_); bool init(std::string m1u_multiaddr_, std::string m1u_if_addr_);
void handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); void handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr);
@ -99,15 +97,13 @@ private:
int m1u_sd = -1; int m1u_sd = -1;
int lcid_counter = 0; int lcid_counter = 0;
}; };
m1u_handler m1u;
// MCH thread insteance
mch_handler mch;
typedef struct { typedef struct {
uint32_t teids_in[SRSENB_N_RADIO_BEARERS]; uint32_t teids_in[SRSENB_N_RADIO_BEARERS];
uint32_t teids_out[SRSENB_N_RADIO_BEARERS]; uint32_t teids_out[SRSENB_N_RADIO_BEARERS];
uint32_t spgw_addrs[SRSENB_N_RADIO_BEARERS]; uint32_t spgw_addrs[SRSENB_N_RADIO_BEARERS];
}bearer_map; } bearer_map;
std::map<uint16_t, bearer_map> rnti_bearers; std::map<uint16_t, bearer_map> rnti_bearers;
// Socket file descriptor // Socket file descriptor
@ -120,11 +116,10 @@ private:
/**************************************************************************** /****************************************************************************
* TEID to RNIT/LCID helper functions * TEID to RNIT/LCID helper functions
***************************************************************************/ ***************************************************************************/
void teidin_to_rntilcid(uint32_t teidin, uint16_t *rnti, uint16_t *lcid); void teidin_to_rntilcid(uint32_t teidin, uint16_t* rnti, uint16_t* lcid);
void rntilcid_to_teidin(uint16_t rnti, uint16_t lcid, uint32_t *teidin); void rntilcid_to_teidin(uint16_t rnti, uint16_t lcid, uint32_t* teidin);
}; };
} // namespace srsenb } // namespace srsenb
#endif // SRSENB_GTPU_H #endif // SRSENB_GTPU_H

@ -243,22 +243,22 @@ void enb_stack_lte::remove_mme_socket(int fd)
rx_sockets->remove_socket(fd); rx_sockets->remove_socket(fd);
} }
void enb_stack_lte::add_gtpu_socket(int fd) void enb_stack_lte::add_gtpu_s1u_socket_handler(int fd)
{ {
auto gtpu_rx_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) { auto gtpu_s1u_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) {
auto task_handler = [this, from](task_t* t) { gtpu.handle_gtpu_rx_packet(std::move(t->pdu), from); }; auto task_handler = [this, &from](task_t* t) { gtpu.handle_gtpu_s1u_rx_packet(std::move(t->pdu), from); };
pending_tasks.push(gtpu_queue_id, task_t{task_handler, std::move(pdu)}); pending_tasks.push(gtpu_queue_id, task_t{task_handler, std::move(pdu)});
}; };
rx_sockets->add_socket_pdu_handler(fd, gtpu_rx_handler); rx_sockets->add_socket_pdu_handler(fd, gtpu_s1u_handler);
} }
void enb_stack_lte::add_gtpu_mch_socket(int fd) void enb_stack_lte::add_gtpu_m1u_socket_handler(int fd)
{ {
auto gtpu_mch_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) { auto gtpu_m1u_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) {
auto task_handler = [this, from](task_t* t) { gtpu.handle_gtpu_mch_rx_packet(std::move(t->pdu), from); }; auto task_handler = [this, &from](task_t* t) { gtpu.handle_gtpu_m1u_rx_packet(std::move(t->pdu), from); };
pending_tasks.push(gtpu_queue_id, task_t{task_handler, std::move(pdu)}); pending_tasks.push(gtpu_queue_id, task_t{task_handler, std::move(pdu)});
}; };
rx_sockets->add_socket_pdu_handler(fd, gtpu_mch_handler); rx_sockets->add_socket_pdu_handler(fd, gtpu_m1u_handler);
} }
} // namespace srsenb } // namespace srsenb

@ -694,12 +694,12 @@ int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_t* dl_sched_res)
mch.mtch_sched[0].lcid, mch.mtch_sched[mch.num_mtch_sched - 1].stop, mch.mtch_sched[0].lcid, mch.mtch_sched[mch.num_mtch_sched - 1].stop,
tti); tti);
phy_h->set_mch_period_stop(mch.mtch_sched[mch.num_mtch_sched - 1].stop); phy_h->set_mch_period_stop(mch.mtch_sched[mch.num_mtch_sched - 1].stop);
for(uint32_t i = 0; i < mch.num_mtch_sched; i++) { for (uint32_t i = 0; i < mch.num_mtch_sched; i++) {
mch.pdu[i].lcid = srslte::sch_subh::MCH_SCHED_INFO; mch.pdu[i].lcid = srslte::sch_subh::MCH_SCHED_INFO;
// mch.mtch_sched[i].lcid = 1+i; // m1u.mtch_sched[i].lcid = 1+i;
} }
mch.pdu[mch.num_mtch_sched].lcid = 0; mch.pdu[mch.num_mtch_sched].lcid = 0;
mch.pdu[mch.num_mtch_sched].nbytes = current_mcch_length; mch.pdu[mch.num_mtch_sched].nbytes = current_mcch_length;
dl_sched_res->pdsch[0].dci.rnti = SRSLTE_MRNTI; dl_sched_res->pdsch[0].dci.rnti = SRSLTE_MRNTI;

@ -30,7 +30,7 @@
using namespace srslte; using namespace srslte;
namespace srsenb { namespace srsenb {
gtpu::gtpu() : mch(this) gtpu::gtpu() : m1u(this)
{ {
pthread_mutex_init(&mutex, nullptr); pthread_mutex_init(&mutex, nullptr);
} }
@ -79,12 +79,12 @@ bool gtpu::init(std::string gtp_bind_addr_,
return false; return false;
} }
stack->add_gtpu_socket(fd); stack->add_gtpu_s1u_socket_handler(fd);
// Start MCH socket if enabled // Start MCH socket if enabled
enable_mbsfn = enable_mbsfn_; enable_mbsfn = enable_mbsfn_;
if (enable_mbsfn) { if (enable_mbsfn) {
if (not mch.init(m1u_multiaddr_, m1u_if_addr_)) { if (not m1u.init(m1u_multiaddr_, m1u_if_addr_)) {
return false; return false;
} }
} }
@ -192,7 +192,7 @@ void gtpu::rem_user(uint16_t rnti)
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
void gtpu::handle_gtpu_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) void gtpu::handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr)
{ {
gtpu_log->debug("Received %d bytes from S1-U interface\n", pdu->N_bytes); gtpu_log->debug("Received %d bytes from S1-U interface\n", pdu->N_bytes);
@ -204,7 +204,7 @@ void gtpu::handle_gtpu_rx_packet(srslte::unique_byte_buffer_t pdu, const sockadd
switch (header.message_type) { switch (header.message_type) {
case GTPU_MSG_ECHO_REQUEST: case GTPU_MSG_ECHO_REQUEST:
// Echo request - send response // Echo request - send response
echo_response(from.sin_addr.s_addr, from.sin_port, header.seq_number); echo_response(addr.sin_addr.s_addr, addr.sin_port, header.seq_number);
break; break;
case GTPU_MSG_DATA_PDU: { case GTPU_MSG_DATA_PDU: {
uint16_t rnti = 0; uint16_t rnti = 0;
@ -235,9 +235,9 @@ void gtpu::handle_gtpu_rx_packet(srslte::unique_byte_buffer_t pdu, const sockadd
} }
} }
void gtpu::handle_gtpu_mch_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) void gtpu::handle_gtpu_m1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr)
{ {
mch.handle_rx_packet(std::move(pdu), addr); m1u.handle_rx_packet(std::move(pdu), addr);
} }
void gtpu::echo_response(in_addr_t addr, in_port_t port, uint16_t seq) void gtpu::echo_response(in_addr_t addr, in_port_t port, uint16_t seq)
@ -281,10 +281,10 @@ void gtpu::rntilcid_to_teidin(uint16_t rnti, uint16_t lcid, uint32_t *teidin)
} }
/**************************************************************************** /****************************************************************************
* Class to run the MCH thread * Class to handle MCH packet handling
***************************************************************************/ ***************************************************************************/
gtpu::mch_handler::~mch_handler() gtpu::m1u_handler::~m1u_handler()
{ {
if (initiated) { if (initiated) {
close(m1u_sd); close(m1u_sd);
@ -292,7 +292,7 @@ gtpu::mch_handler::~mch_handler()
} }
} }
bool gtpu::mch_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr_) bool gtpu::m1u_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr_)
{ {
m1u_multiaddr = std::move(m1u_multiaddr_); m1u_multiaddr = std::move(m1u_multiaddr_);
m1u_if_addr = std::move(m1u_if_addr_); m1u_if_addr = std::move(m1u_if_addr_);
@ -300,9 +300,8 @@ bool gtpu::mch_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr
gtpu_log = parent->gtpu_log; gtpu_log = parent->gtpu_log;
// Set up sink socket // Set up sink socket
struct sockaddr_in bindaddr { struct sockaddr_in bindaddr = {};
}; m1u_sd = socket(AF_INET, SOCK_DGRAM, 0);
m1u_sd = socket(AF_INET, SOCK_DGRAM, 0);
if (m1u_sd < 0) { if (m1u_sd < 0) {
gtpu_log->error("Failed to create M1-U sink socket\n"); gtpu_log->error("Failed to create M1-U sink socket\n");
return false; return false;
@ -333,12 +332,12 @@ bool gtpu::mch_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr
lcid_counter = 1; lcid_counter = 1;
// Register socket in stack rx sockets thread // Register socket in stack rx sockets thread
parent->stack->add_gtpu_mch_socket(m1u_sd); parent->stack->add_gtpu_m1u_socket_handler(m1u_sd);
return true; return true;
} }
void gtpu::mch_handler::handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) void gtpu::m1u_handler::handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr)
{ {
gtpu_log->debug("Received %d bytes from M1-U interface\n", pdu->N_bytes); gtpu_log->debug("Received %d bytes from M1-U interface\n", pdu->N_bytes);

Loading…
Cancel
Save