llc: Convert to C: s/m_//g
Change-Id: Ia5272841392110b87725e87a7e6824c17a70d6d1
This commit is contained in:
parent
2d92e3937f
commit
1463383505
64
src/llc.cpp
64
src/llc.cpp
|
@ -28,15 +28,15 @@ extern "C" {
|
||||||
/* reset LLC frame */
|
/* reset LLC frame */
|
||||||
void gprs_llc::reset()
|
void gprs_llc::reset()
|
||||||
{
|
{
|
||||||
m_index = 0;
|
index = 0;
|
||||||
m_length = 0;
|
length = 0;
|
||||||
|
|
||||||
memset(frame, 0x42, sizeof(frame));
|
memset(frame, 0x42, sizeof(frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
void gprs_llc::reset_frame_space()
|
void gprs_llc::reset_frame_space()
|
||||||
{
|
{
|
||||||
m_index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put an Unconfirmed Information (UI) Dummy command, see GSM 44.064, 6.4.2.2 */
|
/* Put an Unconfirmed Information (UI) Dummy command, see GSM 44.064, 6.4.2.2 */
|
||||||
|
@ -55,24 +55,24 @@ void gprs_llc::put_dummy_frame(size_t req_len)
|
||||||
|
|
||||||
/* Add further stuffing, if the requested length exceeds the minimum
|
/* Add further stuffing, if the requested length exceeds the minimum
|
||||||
* dummy command length */
|
* dummy command length */
|
||||||
if (m_length < req_len) {
|
if (length < req_len) {
|
||||||
memset(&frame[m_length], 0x2b, req_len - m_length);
|
memset(&frame[length], 0x2b, req_len - length);
|
||||||
m_length = req_len;
|
length = req_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gprs_llc::put_frame(const uint8_t *data, size_t len)
|
void gprs_llc::put_frame(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
/* only put frames when we are empty */
|
/* only put frames when we are empty */
|
||||||
OSMO_ASSERT(m_index == 0 && m_length == 0);
|
OSMO_ASSERT(index == 0 && length == 0);
|
||||||
append_frame(data, len);
|
append_frame(data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gprs_llc::append_frame(const uint8_t *data, size_t len)
|
void gprs_llc::append_frame(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
/* TODO: bounds check */
|
/* TODO: bounds check */
|
||||||
memcpy(frame + m_length, data, len);
|
memcpy(frame + length, data, len);
|
||||||
m_length += len;
|
length += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gprs_llc::init()
|
void gprs_llc::init()
|
||||||
|
@ -97,10 +97,10 @@ bool gprs_llc::is_user_data_frame(uint8_t *data, size_t len)
|
||||||
|
|
||||||
void llc_queue_init(struct gprs_llc_queue *q)
|
void llc_queue_init(struct gprs_llc_queue *q)
|
||||||
{
|
{
|
||||||
INIT_LLIST_HEAD(&q->m_queue);
|
INIT_LLIST_HEAD(&q->queue);
|
||||||
q->m_queue_size = 0;
|
q->queue_size = 0;
|
||||||
q->m_queue_octets = 0;
|
q->queue_octets = 0;
|
||||||
q->m_avg_queue_delay = 0;
|
q->avg_queue_delay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,28 +110,28 @@ void gprs_llc_queue::enqueue(struct msgb *llc_msg, const struct timespec *expire
|
||||||
|
|
||||||
osmo_static_assert(sizeof(*meta_storage) <= sizeof(llc_msg->cb), info_does_not_fit);
|
osmo_static_assert(sizeof(*meta_storage) <= sizeof(llc_msg->cb), info_does_not_fit);
|
||||||
|
|
||||||
m_queue_size += 1;
|
queue_size += 1;
|
||||||
m_queue_octets += msgb_length(llc_msg);
|
queue_octets += msgb_length(llc_msg);
|
||||||
|
|
||||||
meta_storage = (MetaInfo *)&llc_msg->cb[0];
|
meta_storage = (MetaInfo *)&llc_msg->cb[0];
|
||||||
osmo_clock_gettime(CLOCK_MONOTONIC, &meta_storage->recv_time);
|
osmo_clock_gettime(CLOCK_MONOTONIC, &meta_storage->recv_time);
|
||||||
meta_storage->expire_time = *expire_time;
|
meta_storage->expire_time = *expire_time;
|
||||||
|
|
||||||
msgb_enqueue(&m_queue, llc_msg);
|
msgb_enqueue(&queue, llc_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void llc_queue_clear(struct gprs_llc_queue *q, struct gprs_rlcmac_bts *bts)
|
void llc_queue_clear(struct gprs_llc_queue *q, struct gprs_rlcmac_bts *bts)
|
||||||
{
|
{
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
|
|
||||||
while ((msg = msgb_dequeue(&q->m_queue))) {
|
while ((msg = msgb_dequeue(&q->queue))) {
|
||||||
if (bts)
|
if (bts)
|
||||||
bts_do_rate_ctr_inc(bts, CTR_LLC_FRAME_DROPPED);
|
bts_do_rate_ctr_inc(bts, CTR_LLC_FRAME_DROPPED);
|
||||||
msgb_free(msg);
|
msgb_free(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
q->m_queue_size = 0;
|
q->queue_size = 0;
|
||||||
q->m_queue_octets = 0;
|
q->queue_octets = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void llc_queue_move_and_merge(struct gprs_llc_queue *q, struct gprs_llc_queue *o)
|
void llc_queue_move_and_merge(struct gprs_llc_queue *q, struct gprs_llc_queue *o)
|
||||||
|
@ -144,10 +144,10 @@ void llc_queue_move_and_merge(struct gprs_llc_queue *q, struct gprs_llc_queue *o
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (msg1 == NULL)
|
if (msg1 == NULL)
|
||||||
msg1 = msgb_dequeue(&q->m_queue);
|
msg1 = msgb_dequeue(&q->queue);
|
||||||
|
|
||||||
if (msg2 == NULL)
|
if (msg2 == NULL)
|
||||||
msg2 = msgb_dequeue(&o->m_queue);
|
msg2 = msgb_dequeue(&o->queue);
|
||||||
|
|
||||||
if (msg1 == NULL && msg2 == NULL)
|
if (msg1 == NULL && msg2 == NULL)
|
||||||
break;
|
break;
|
||||||
|
@ -176,15 +176,15 @@ void llc_queue_move_and_merge(struct gprs_llc_queue *q, struct gprs_llc_queue *o
|
||||||
queue_octets += msgb_length(msg);
|
queue_octets += msgb_length(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
OSMO_ASSERT(llist_empty(&q->m_queue));
|
OSMO_ASSERT(llist_empty(&q->queue));
|
||||||
OSMO_ASSERT(llist_empty(&o->m_queue));
|
OSMO_ASSERT(llist_empty(&o->queue));
|
||||||
|
|
||||||
o->m_queue_size = 0;
|
o->queue_size = 0;
|
||||||
o->m_queue_octets = 0;
|
o->queue_octets = 0;
|
||||||
|
|
||||||
llist_splice_init(&new_queue, &q->m_queue);
|
llist_splice_init(&new_queue, &q->queue);
|
||||||
q->m_queue_size = queue_size;
|
q->queue_size = queue_size;
|
||||||
q->m_queue_octets = queue_octets;
|
q->queue_octets = queue_octets;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ALPHA 0.5f
|
#define ALPHA 0.5f
|
||||||
|
@ -196,7 +196,7 @@ struct msgb *gprs_llc_queue::dequeue(const MetaInfo **info)
|
||||||
uint32_t lifetime;
|
uint32_t lifetime;
|
||||||
const MetaInfo *meta_storage;
|
const MetaInfo *meta_storage;
|
||||||
|
|
||||||
msg = msgb_dequeue(&m_queue);
|
msg = msgb_dequeue(&queue);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -205,8 +205,8 @@ struct msgb *gprs_llc_queue::dequeue(const MetaInfo **info)
|
||||||
if (info)
|
if (info)
|
||||||
*info = meta_storage;
|
*info = meta_storage;
|
||||||
|
|
||||||
m_queue_size -= 1;
|
queue_size -= 1;
|
||||||
m_queue_octets -= msgb_length(msg);
|
queue_octets -= msgb_length(msg);
|
||||||
|
|
||||||
/* take the second time */
|
/* take the second time */
|
||||||
osmo_clock_gettime(CLOCK_MONOTONIC, &tv_now);
|
osmo_clock_gettime(CLOCK_MONOTONIC, &tv_now);
|
||||||
|
@ -214,7 +214,7 @@ struct msgb *gprs_llc_queue::dequeue(const MetaInfo **info)
|
||||||
timespecsub(&tv_now, &meta_storage->recv_time, &tv_result);
|
timespecsub(&tv_now, &meta_storage->recv_time, &tv_result);
|
||||||
|
|
||||||
lifetime = tv_result.tv_sec*1000 + tv_result.tv_nsec/1000000;
|
lifetime = tv_result.tv_sec*1000 + tv_result.tv_nsec/1000000;
|
||||||
m_avg_queue_delay = m_avg_queue_delay * ALPHA + lifetime * (1-ALPHA);
|
avg_queue_delay = avg_queue_delay * ALPHA + lifetime * (1-ALPHA);
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
28
src/llc.h
28
src/llc.h
|
@ -48,8 +48,8 @@ struct gprs_llc {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t frame[LLC_MAX_LEN]; /* current DL or UL frame */
|
uint8_t frame[LLC_MAX_LEN]; /* current DL or UL frame */
|
||||||
uint16_t m_index; /* current write/read position of frame */
|
uint16_t index; /* current write/read position of frame */
|
||||||
uint16_t m_length; /* len of current DL LLC_frame, 0 == no frame */
|
uint16_t length; /* len of current DL LLC_frame, 0 == no frame */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MetaInfo {
|
struct MetaInfo {
|
||||||
|
@ -70,10 +70,10 @@ struct gprs_llc_queue {
|
||||||
void enqueue(struct msgb *llc_msg, const struct timespec *expire_time);
|
void enqueue(struct msgb *llc_msg, const struct timespec *expire_time);
|
||||||
struct msgb *dequeue(const MetaInfo **info = 0);
|
struct msgb *dequeue(const MetaInfo **info = 0);
|
||||||
#endif
|
#endif
|
||||||
uint32_t m_avg_queue_delay; /* Average delay of data going through the queue */
|
uint32_t avg_queue_delay; /* Average delay of data going through the queue */
|
||||||
size_t m_queue_size;
|
size_t queue_size;
|
||||||
size_t m_queue_octets;
|
size_t queue_octets;
|
||||||
struct llist_head m_queue; /* queued LLC DL data */
|
struct llist_head queue; /* queued LLC DL data */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -85,44 +85,44 @@ void llc_queue_move_and_merge(struct gprs_llc_queue *q, struct gprs_llc_queue *o
|
||||||
|
|
||||||
static inline uint16_t llc_chunk_size(const struct gprs_llc *llc)
|
static inline uint16_t llc_chunk_size(const struct gprs_llc *llc)
|
||||||
{
|
{
|
||||||
return llc->m_length - llc->m_index;
|
return llc->length - llc->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint16_t llc_remaining_space(const struct gprs_llc *llc)
|
static inline uint16_t llc_remaining_space(const struct gprs_llc *llc)
|
||||||
{
|
{
|
||||||
return LLC_MAX_LEN - llc->m_length;
|
return LLC_MAX_LEN - llc->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint16_t llc_frame_length(const struct gprs_llc *llc)
|
static inline uint16_t llc_frame_length(const struct gprs_llc *llc)
|
||||||
{
|
{
|
||||||
return llc->m_length;
|
return llc->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void llc_consume(struct gprs_llc *llc, size_t len)
|
static inline void llc_consume(struct gprs_llc *llc, size_t len)
|
||||||
{
|
{
|
||||||
llc->m_index += len;
|
llc->index += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void llc_consume_data(struct gprs_llc *llc, uint8_t *data, size_t len)
|
static inline void llc_consume_data(struct gprs_llc *llc, uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
/* copy and increment index */
|
/* copy and increment index */
|
||||||
memcpy(data, llc->frame + llc->m_index, len);
|
memcpy(data, llc->frame + llc->index, len);
|
||||||
llc_consume(llc, len);
|
llc_consume(llc, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool llc_fits_in_current_frame(const struct gprs_llc *llc, uint8_t chunk_size)
|
static inline bool llc_fits_in_current_frame(const struct gprs_llc *llc, uint8_t chunk_size)
|
||||||
{
|
{
|
||||||
return llc->m_length + chunk_size <= LLC_MAX_LEN;
|
return llc->length + chunk_size <= LLC_MAX_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t llc_queue_size(const struct gprs_llc_queue *q)
|
static inline size_t llc_queue_size(const struct gprs_llc_queue *q)
|
||||||
{
|
{
|
||||||
return q->m_queue_size;
|
return q->queue_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t llc_queue_octets(const struct gprs_llc_queue *q)
|
static inline size_t llc_queue_octets(const struct gprs_llc_queue *q)
|
||||||
{
|
{
|
||||||
return q->m_queue_octets;
|
return q->queue_octets;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -2528,7 +2528,7 @@ static gprs_rlcmac_ul_tbf *tbf_li_decoding(struct gprs_rlcmac_bts *bts,
|
||||||
data_msg[5] = 0x0;
|
data_msg[5] = 0x0;
|
||||||
pdch->rcv_block(data_msg, 49, *fn, &meas);
|
pdch->rcv_block(data_msg, 49, *fn, &meas);
|
||||||
|
|
||||||
OSMO_ASSERT(ul_tbf->m_llc.m_index == 43);
|
OSMO_ASSERT(ul_tbf->m_llc.index == 43);
|
||||||
|
|
||||||
return ul_tbf;
|
return ul_tbf;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue