From b298d3d3f95306b41d9c1b13b01f665876edf74a Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 3 Apr 2018 12:16:22 +0200 Subject: [PATCH 1/5] add missing const keyword to log_filter's members --- lib/include/srslte/common/log.h | 8 ++++---- lib/include/srslte/common/log_filter.h | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/include/srslte/common/log.h b/lib/include/srslte/common/log.h index 7d8f0a8cd..b47f79d90 100644 --- a/lib/include/srslte/common/log.h +++ b/lib/include/srslte/common/log.h @@ -129,13 +129,13 @@ public: virtual void debug(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; // Same with hex dump - virtual void error_hex(uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) + virtual void error_hex(const uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) {error("error_hex not implemented.\n");} - virtual void warning_hex(uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) + virtual void warning_hex(const uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) {error("warning_hex not implemented.\n");} - virtual void info_hex(uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) + virtual void info_hex(const uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) {error("info_hex not implemented.\n");} - virtual void debug_hex(uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) + virtual void debug_hex(const uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) {error("debug_hex not implemented.\n");} protected: diff --git a/lib/include/srslte/common/log_filter.h b/lib/include/srslte/common/log_filter.h index ea739082a..1296fbbbd 100644 --- a/lib/include/srslte/common/log_filter.h +++ b/lib/include/srslte/common/log_filter.h @@ -57,16 +57,16 @@ public: void init(std::string layer, logger *logger_, bool tti=false); - void console(const char * message, ...); - void error(const char * message, ...); - void warning(const char * message, ...); - void info(const char * message, ...); - void debug(const char * message, ...); - - void error_hex(const uint8_t *hex, int size, const char * message, ...); - void warning_hex(const uint8_t *hex, int size, const char * message, ...); - void info_hex(const uint8_t *hex, int size, const char * message, ...); - void debug_hex(const uint8_t *hex, int size, const char * message, ...); + void console(const char * message, ...) __attribute__ ((format (printf, 2, 3))); + void error(const char * message, ...) __attribute__ ((format (printf, 2, 3))); + void warning(const char * message, ...) __attribute__ ((format (printf, 2, 3))); + void info(const char * message, ...) __attribute__ ((format (printf, 2, 3))); + void debug(const char * message, ...) __attribute__ ((format (printf, 2, 3))); + + void error_hex(const uint8_t *hex, int size, const char * message, ...) __attribute__((format (printf, 4, 5))); + void warning_hex(const uint8_t *hex, int size, const char * message, ...) __attribute__((format (printf, 4, 5))); + void info_hex(const uint8_t *hex, int size, const char * message, ...) __attribute__((format (printf, 4, 5))); + void debug_hex(const uint8_t *hex, int size, const char * message, ...) __attribute__((format (printf, 4, 5))); class time_itf { public: From 319f47336392ec1ccd496274f749de33430453f5 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 4 Apr 2018 12:15:10 +0200 Subject: [PATCH 2/5] fix remaining printf warnings --- srsenb/src/enb.cc | 2 +- srsepc/src/hss/hss.cc | 3 ++- srsepc/src/mme/mme_gtpc.cc | 13 +++++++------ srsepc/src/mme/s1ap.cc | 7 ++++--- srsepc/src/spgw/spgw.cc | 7 ++++--- srsue/src/ue_base.cc | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index 85cda6185..e91aea7bf 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -296,7 +296,7 @@ void enb::handle_rf_msg(srslte_rf_error_t error) str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); str.erase(std::remove(str.begin(), str.end(), '\r'), str.end()); str.push_back('\n'); - rf_log.info(str.c_str()); + rf_log.info("%s\n", str.c_str()); } } diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index d9a55960b..9a8db0e3a 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -28,6 +28,7 @@ #include #include #include +#include // for printing uint64_t #include "srsepc/hdr/hss/hss.h" #include "srslte/common/security.h" @@ -564,7 +565,7 @@ hss::increment_sqn(uint64_t imsi) sqn++; - m_hss_log->debug("Incremented SQN (IMSI: %015lu) SQN: %d\n", imsi, sqn); + m_hss_log->debug("Incremented SQN (IMSI: %" PRIu64 ") SQN: %" PRIu64 "\n", imsi, sqn); for(int i = 0; i < 6; i++){ ue_ctx->sqn[i] = p[5-i]; diff --git a/srsepc/src/mme/mme_gtpc.cc b/srsepc/src/mme/mme_gtpc.cc index 1f53338c0..7c30bfa3b 100644 --- a/srsepc/src/mme/mme_gtpc.cc +++ b/srsepc/src/mme/mme_gtpc.cc @@ -25,6 +25,7 @@ */ #include +#include // for printing uint64_t #include "srslte/asn1/gtpc.h" #include "srsepc/hdr/mme/mme_gtpc.h" #include "srsepc/hdr/mme/s1ap.h" @@ -115,10 +116,10 @@ mme_gtpc::send_create_session_request(uint64_t imsi) cs_req->sender_f_teid.teid = get_new_ctrl_teid(); cs_req->sender_f_teid.ipv4 = m_mme_gtpc_ip; - m_mme_gtpc_log->info("Next MME control TEID: %lu \n", m_next_ctrl_teid); - m_mme_gtpc_log->info("Allocated MME control TEID: %lu \n", cs_req->sender_f_teid.teid); - m_mme_gtpc_log->console("Creating Session Response -- IMSI: %015lu \n", imsi); - m_mme_gtpc_log->console("Creating Session Response -- MME control TEID: %lu \n", cs_req->sender_f_teid.teid); + m_mme_gtpc_log->info("Next MME control TEID: %d\n", m_next_ctrl_teid); + m_mme_gtpc_log->info("Allocated MME control TEID: %d\n", cs_req->sender_f_teid.teid); + m_mme_gtpc_log->console("Creating Session Response -- IMSI: %" PRIu64 "\n", imsi); + m_mme_gtpc_log->console("Creating Session Response -- MME control TEID: %d\n", cs_req->sender_f_teid.teid); // APN strncpy(cs_req->apn, m_s1ap->m_s1ap_args.mme_apn.c_str(), sizeof(cs_req->apn)-1); @@ -185,7 +186,7 @@ mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu) } uint64_t imsi = id_it->second; - m_mme_gtpc_log->info("MME GTPC Ctrl TEID %d, IMSI %d\n", cs_resp_pdu->header.teid, imsi); + m_mme_gtpc_log->info("MME GTPC Ctrl TEID %" PRIu64 ", IMSI %" PRIu64 "\n", cs_resp_pdu->header.teid, imsi); //Get S-GW Control F-TEID srslte::gtp_fteid_t sgw_ctr_fteid; @@ -309,7 +310,7 @@ mme_gtpc::handle_modify_bearer_response(srslte::gtpc_pdu *mb_resp_pdu) void mme_gtpc::send_delete_session_request(uint64_t imsi) { - m_mme_gtpc_log->info("Sending GTP-C Delete Session Request request. IMSI %d\n",imsi); + m_mme_gtpc_log->info("Sending GTP-C Delete Session Request request. IMSI %" PRIu64 "\n",imsi); srslte::gtpc_pdu del_req_pdu; srslte::gtp_fteid_t sgw_ctr_fteid; srslte::gtp_fteid_t mme_ctr_fteid; diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 639725ee5..ccd2536c1 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -26,6 +26,7 @@ #include #include +#include // for printing uint64_t #include "srslte/common/bcd_helpers.h" #include "srsepc/hdr/mme/s1ap.h" #include "srslte/asn1/gtpc.h" @@ -486,7 +487,7 @@ s1ap::delete_ue_ctx(uint64_t imsi) ue_ctx_t *ue_ctx = find_ue_ctx_from_imsi(imsi); if(ue_ctx == NULL) { - m_s1ap_log->info("Cannot delete UE context, UE not found. IMSI: %d\n", imsi); + m_s1ap_log->info("Cannot delete UE context, UE not found. IMSI: %" PRIu64 "\n", imsi); return false; } @@ -528,8 +529,8 @@ s1ap::activate_eps_bearer(uint64_t imsi, uint8_t ebi) ue_ecm_ctx_t * ecm_ctx = &ue_ctx_it->second->ecm_ctx; if (ecm_ctx->erabs_ctx[ebi].state != ERAB_CTX_SETUP) { - m_s1ap_log->error("Could not be activate EPS Bearer, bearer in wrong state: MME S1AP Id %d, EPS Bearer id %d, state %d\n",mme_ue_s1ap_id,ebi,ecm_ctx->erabs_ctx[ebi].state); - m_s1ap_log->console("Could not be activate EPS Bearer, bearer in wrong state: MME S1AP Id %d, EPS Bearer id %d\n",mme_ue_s1ap_id,ebi,ecm_ctx->erabs_ctx[ebi].state); + m_s1ap_log->error("Could not be activate EPS Bearer, bearer in wrong state: MME S1AP Id %d, EPS Bearer id %d, state %d\n", mme_ue_s1ap_id, ebi, ecm_ctx->erabs_ctx[ebi].state); + m_s1ap_log->console("Could not be activate EPS Bearer, bearer in wrong state: MME S1AP Id %d, EPS Bearer id %d, state %d\n", mme_ue_s1ap_id, ebi, ecm_ctx->erabs_ctx[ebi].state); return; } diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index eec7bb4ec..cbd3e524b 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -33,6 +33,7 @@ #include #include #include +#include // for printing uint64_t #include "srsepc/hdr/spgw/spgw.h" #include "srsepc/hdr/mme/mme_gtpc.h" #include "srslte/upper/gtpu.h" @@ -401,7 +402,7 @@ spgw::handle_s1u_pdu(srslte::byte_buffer_t *msg) int n = write(m_sgi_if, msg->msg, msg->N_bytes); if(n<0) { - m_spgw_log->error("Could not write to TUN interface.\n",n); + m_spgw_log->error("Could not write to TUN interface.\n"); } else { @@ -444,8 +445,8 @@ spgw::create_gtp_ctx(struct srslte::gtpc_create_session_request *cs_req) //in_addr_t ue_ip = inet_addr("172.16.0.2"); uint8_t default_bearer_id = 5; - m_spgw_log->console("SPGW: Allocated Ctrl TEID %d\n", spgw_uplink_ctrl_teid); - m_spgw_log->console("SPGW: Allocated User TEID %d\n", spgw_uplink_user_teid); + m_spgw_log->console("SPGW: Allocated Ctrl TEID %" PRIu64 "\n", spgw_uplink_ctrl_teid); + m_spgw_log->console("SPGW: Allocated User TEID %" PRIu64 "\n", spgw_uplink_user_teid); struct in_addr ue_ip_; ue_ip_.s_addr=ue_ip; m_spgw_log->console("SPGW: Allocate UE IP %s\n", inet_ntoa(ue_ip_)); diff --git a/srsue/src/ue_base.cc b/srsue/src/ue_base.cc index c4b4a2a52..b3fc56132 100644 --- a/srsue/src/ue_base.cc +++ b/srsue/src/ue_base.cc @@ -104,7 +104,7 @@ void ue_base::handle_rf_msg(srslte_rf_error_t error) str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); str.erase(std::remove(str.begin(), str.end(), '\r'), str.end()); str.push_back('\n'); - rf_log.info(str.c_str()); + rf_log.info("%s\n", str.c_str()); } } From e7a268d79bf2e94f9b961ebff3624be5adae2a10 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 4 Apr 2018 12:20:32 +0200 Subject: [PATCH 3/5] fix SIMD compile issue on NEON --- lib/include/srslte/phy/utils/simd.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/include/srslte/phy/utils/simd.h b/lib/include/srslte/phy/utils/simd.h index 66295f2ce..f6d7a0a44 100644 --- a/lib/include/srslte/phy/utils/simd.h +++ b/lib/include/srslte/phy/utils/simd.h @@ -706,7 +706,11 @@ static inline void srslte_simd_cf_storeu(float *re, float *im, simd_cf_t simdreg } static inline simd_f_t srslte_simd_cf_re(simd_cf_t in) { +#ifdef HAVE_NEON + simd_f_t out = in.val[0]; +#else simd_f_t out = in.re; +#endif /*HAVE_NEON*/ #ifndef LV_HAVE_AVX512 #ifdef LV_HAVE_AVX2 /* Permute for AVX registers (mis SSE registers) */ From 8a831379c161f3970ae8203aac17260eda0cfdec Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 4 Apr 2018 15:52:36 +0200 Subject: [PATCH 4/5] fix RLC AM SDU reset --- lib/src/upper/rlc_am.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index 2537ee48c..407d912ea 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -127,10 +127,10 @@ void rlc_am::reset() pthread_mutex_lock(&mutex); reordering_timeout.reset(); if(tx_sdu) { - pool->deallocate(tx_sdu); + tx_sdu->reset(); } if(rx_sdu) { - pool->deallocate(rx_sdu); + rx_sdu->reset(); } vt_a = 0; From d42316fb68bc3ef4a31bd1d404b4dd5c46e66d35 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 4 Apr 2018 17:31:33 +0200 Subject: [PATCH 5/5] fix RLC AM reset again to dealloc SDUs --- lib/src/upper/rlc_am.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index 407d912ea..895fd74b8 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -127,10 +127,12 @@ void rlc_am::reset() pthread_mutex_lock(&mutex); reordering_timeout.reset(); if(tx_sdu) { - tx_sdu->reset(); + pool->deallocate(tx_sdu); + tx_sdu = NULL; } if(rx_sdu) { - rx_sdu->reset(); + pool->deallocate(rx_sdu); + rx_sdu = NULL; } vt_a = 0;