bts: Drop specific functions to add values to counters
It's super annoying seeing lots of functions being called everywhere only to find out they are only incrementing a counter. Let's drop all those functions and increment the counter so people looking at code doesn't see dozens of code paths evyerwhere. Most of the commit was generated by following sh snippet: """ #!/bin/bash define_pattern="^CREATE_COUNT_ADD_INLINE" generic_func="do_rate_ctr_add" grep -r -l "${define_pattern}" . | xargs cat | grep "${define_pattern}("| tr -d ",;" | tr "()" " " | awk '{ print $2 " " $3 }' >/tmp/hello while read -r func_name ctr_name do #echo "$func_name -> $ctr_name"; files="$(grep -r -l "${func_name}(" .)" for f in $files; do echo "$f: $func_name -> $ctr_name"; sed -i "s#${func_name}(#${generic_func}(${ctr_name}, #g" $f done; done < /tmp/hello grep -r -l "void ${generic_func}" | xargs sed -i "/void ${generic_func}(CTR/d" grep -r -l "$define_pattern" | xargs sed -i "/$define_pattern/d" """ Change-Id: I966221d6f9fb9bb4f6068bf45ca2978008a0efed
This commit is contained in:
parent
2338e5318e
commit
a107f8f496
20
src/bts.h
20
src/bts.h
|
@ -320,12 +320,6 @@ public:
|
|||
/*
|
||||
* Statistics
|
||||
*/
|
||||
void rlc_dl_bytes(int bytes);
|
||||
void rlc_dl_payload_bytes(int bytes);
|
||||
void rlc_ul_bytes(int bytes);
|
||||
void rlc_ul_payload_bytes(int bytes);
|
||||
void llc_dl_bytes(int bytes);
|
||||
void llc_ul_bytes(int bytes);
|
||||
|
||||
void ms_present(int32_t n);
|
||||
int32_t ms_present_get();
|
||||
|
@ -336,6 +330,7 @@ public:
|
|||
struct rate_ctr_group *rate_counters() const;
|
||||
struct osmo_stat_item_group *stat_items() const;
|
||||
void do_rate_ctr_inc(unsigned int ctr_id);
|
||||
void do_rate_ctr_add(unsigned int ctr_id, int inc);
|
||||
|
||||
LListHead<gprs_rlcmac_tbf>& ul_tbfs();
|
||||
LListHead<gprs_rlcmac_tbf>& dl_tbfs();
|
||||
|
@ -409,17 +404,10 @@ inline void BTS::do_rate_ctr_inc(unsigned int ctr_id) {
|
|||
rate_ctr_inc(&m_ratectrs->ctr[ctr_id]);
|
||||
}
|
||||
|
||||
#define CREATE_COUNT_ADD_INLINE(func_name, ctr_name) \
|
||||
inline void BTS::func_name(int inc) {\
|
||||
rate_ctr_add(&m_ratectrs->ctr[ctr_name], inc); \
|
||||
}
|
||||
inline void BTS::do_rate_ctr_add(unsigned int ctr_id, int inc) {
|
||||
rate_ctr_add(&m_ratectrs->ctr[ctr_id], inc);
|
||||
}
|
||||
|
||||
CREATE_COUNT_ADD_INLINE(rlc_dl_bytes, CTR_RLC_DL_BYTES);
|
||||
CREATE_COUNT_ADD_INLINE(rlc_dl_payload_bytes, CTR_RLC_DL_PAYLOAD_BYTES);
|
||||
CREATE_COUNT_ADD_INLINE(rlc_ul_bytes, CTR_RLC_UL_BYTES);
|
||||
CREATE_COUNT_ADD_INLINE(rlc_ul_payload_bytes, CTR_RLC_UL_PAYLOAD_BYTES);
|
||||
CREATE_COUNT_ADD_INLINE(llc_dl_bytes, CTR_LLC_DL_BYTES);
|
||||
CREATE_COUNT_ADD_INLINE(llc_ul_bytes, CTR_LLC_UL_BYTES);
|
||||
|
||||
#define CREATE_STAT_INLINE(func_name, func_name_get, stat_name) \
|
||||
inline void BTS::func_name(int32_t val) {\
|
||||
|
|
|
@ -444,7 +444,7 @@ int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_bts *bts,
|
|||
if (!msg)
|
||||
return -ENOMEM;
|
||||
/* msg is now available */
|
||||
bts->bts->rlc_dl_bytes(msg->data_len);
|
||||
bts->bts->do_rate_ctr_add(CTR_RLC_DL_BYTES, msg->data_len);
|
||||
|
||||
/* set USF */
|
||||
OSMO_ASSERT(msgb_length(msg) > 0);
|
||||
|
|
|
@ -759,7 +759,7 @@ int gprs_rlcmac_pdch::rcv_block(uint8_t *data, uint8_t len, uint32_t fn,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
bts()->rlc_ul_bytes(len);
|
||||
bts()->do_rate_ctr_add(CTR_RLC_UL_BYTES, len);
|
||||
|
||||
LOGP(DRLCMACUL, LOGL_DEBUG, "Got RLC block, coding scheme: %s, "
|
||||
"length: %d (%d))\n", mcs_name(cs), len, cs.usedSizeUL());
|
||||
|
|
|
@ -630,14 +630,14 @@ int gprs_rlcmac_dl_tbf::create_new_bsn(const uint32_t fn, GprsCodingScheme cs)
|
|||
&m_llc, &write_offset, &num_chunks, data, is_final, &payload_written);
|
||||
|
||||
if (payload_written > 0)
|
||||
bts->rlc_dl_payload_bytes(payload_written);
|
||||
bts->do_rate_ctr_add(CTR_RLC_DL_PAYLOAD_BYTES, payload_written);
|
||||
|
||||
if (ar == Encoding::AR_NEED_MORE_BLOCKS)
|
||||
break;
|
||||
|
||||
LOGPTBFDL(this, LOGL_DEBUG, "Complete DL frame, len=%d\n", m_llc.frame_length());
|
||||
gprs_rlcmac_dl_bw(this, m_llc.frame_length());
|
||||
bts->llc_dl_bytes(m_llc.frame_length());
|
||||
bts->do_rate_ctr_add(CTR_LLC_DL_BYTES, m_llc.frame_length());
|
||||
m_llc.reset();
|
||||
|
||||
if (is_final) {
|
||||
|
|
|
@ -92,7 +92,7 @@ int gprs_rlcmac_ul_tbf::assemble_forward_llc(const gprs_rlc_data *_data)
|
|||
frame = frames + i;
|
||||
|
||||
if (frame->length) {
|
||||
bts->rlc_ul_payload_bytes(frame->length);
|
||||
bts->do_rate_ctr_add(CTR_RLC_UL_PAYLOAD_BYTES, frame->length);
|
||||
|
||||
LOGPTBFUL(this, LOGL_DEBUG, "Frame %d "
|
||||
"starts at offset %d, "
|
||||
|
@ -108,7 +108,7 @@ int gprs_rlcmac_ul_tbf::assemble_forward_llc(const gprs_rlc_data *_data)
|
|||
/* send frame to SGSN */
|
||||
LOGPTBFUL(this, LOGL_DEBUG, "complete UL frame len=%d\n", m_llc.frame_length());
|
||||
snd_ul_ud();
|
||||
bts->llc_ul_bytes(m_llc.frame_length());
|
||||
bts->do_rate_ctr_add(CTR_LLC_UL_BYTES, m_llc.frame_length());
|
||||
m_llc.reset();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue