mirror of https://github.com/PentHertz/srsLTE.git
simplify SDU allocation and remove unneeded checks
This commit is contained in:
parent
69e948bd5e
commit
a3d95c8370
|
@ -85,7 +85,6 @@ private:
|
||||||
bool allocate_sdu(uint32_t lcid, srslte::sch_pdu *pdu, int max_sdu_sz);
|
bool allocate_sdu(uint32_t lcid, srslte::sch_pdu *pdu, int max_sdu_sz);
|
||||||
bool sched_sdu(logical_channel_config_t* ch, int* sdu_space, int max_sdu_sz);
|
bool sched_sdu(logical_channel_config_t* ch, int* sdu_space, int max_sdu_sz);
|
||||||
|
|
||||||
const static int MIN_RLC_SDU_LEN = 2;
|
|
||||||
const static int MAX_NOF_SUBHEADERS = 20;
|
const static int MAX_NOF_SUBHEADERS = 20;
|
||||||
|
|
||||||
std::vector<logical_channel_config_t> logical_channels;
|
std::vector<logical_channel_config_t> logical_channels;
|
||||||
|
|
|
@ -169,15 +169,12 @@ uint8_t* mux::pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logical Channel Procedure
|
// Logical Channel Procedure
|
||||||
bool is_rar = false;
|
|
||||||
|
|
||||||
payload->clear();
|
payload->clear();
|
||||||
pdu_msg.init_tx(payload, pdu_sz, true);
|
pdu_msg.init_tx(payload, pdu_sz, true);
|
||||||
|
|
||||||
// MAC control element for C-RNTI or data from UL-CCCH
|
// MAC control element for C-RNTI or data from UL-CCCH
|
||||||
if (!allocate_sdu(0, &pdu_msg, pdu_sz)) {
|
if (!allocate_sdu(0, &pdu_msg, pdu_sz)) {
|
||||||
if (pending_crnti_ce) {
|
if (pending_crnti_ce) {
|
||||||
is_rar = true;
|
|
||||||
if (pdu_msg.new_subh()) {
|
if (pdu_msg.new_subh()) {
|
||||||
if (!pdu_msg.get()->set_c_rnti(pending_crnti_ce)) {
|
if (!pdu_msg.get()->set_c_rnti(pending_crnti_ce)) {
|
||||||
Warning("Pending C-RNTI CE could not be inserted in MAC PDU\n");
|
Warning("Pending C-RNTI CE could not be inserted in MAC PDU\n");
|
||||||
|
@ -188,7 +185,6 @@ uint8_t* mux::pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz)
|
||||||
if (pending_crnti_ce) {
|
if (pending_crnti_ce) {
|
||||||
Warning("Pending C-RNTI CE was not inserted because message was for CCCH\n");
|
Warning("Pending C-RNTI CE was not inserted because message was for CCCH\n");
|
||||||
}
|
}
|
||||||
is_rar = true;
|
|
||||||
}
|
}
|
||||||
pending_crnti_ce = 0;
|
pending_crnti_ce = 0;
|
||||||
|
|
||||||
|
@ -308,45 +304,44 @@ bool mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_sz)
|
||||||
{
|
{
|
||||||
bool sdu_added = false;
|
bool sdu_added = false;
|
||||||
int sdu_space = max_sdu_sz;
|
int sdu_space = max_sdu_sz;
|
||||||
int sdu_len = rlc->get_buffer_state(lcid);
|
int buffer_state = rlc->get_buffer_state(lcid);
|
||||||
|
|
||||||
|
while (buffer_state > 0 && sdu_space > 0) { // there is pending SDU to allocate
|
||||||
|
int requested_sdu_len = SRSLTE_MIN(buffer_state, max_sdu_sz);
|
||||||
|
|
||||||
while (sdu_len > 0 && sdu_space >= MIN_RLC_SDU_LEN) { // there is pending SDU to allocate
|
|
||||||
int buffer_state = sdu_len;
|
|
||||||
if (sdu_len > max_sdu_sz && max_sdu_sz >= 0) {
|
|
||||||
sdu_len = max_sdu_sz;
|
|
||||||
}
|
|
||||||
if (sdu_len > sdu_space || max_sdu_sz < 0) {
|
|
||||||
sdu_len = sdu_space;
|
|
||||||
}
|
|
||||||
if (sdu_len >= MIN_RLC_SDU_LEN) {
|
|
||||||
if (pdu_msg->new_subh()) { // there is space for a new subheader
|
if (pdu_msg->new_subh()) { // there is space for a new subheader
|
||||||
sdu_len = pdu_msg->get()->set_sdu(lcid, sdu_len, rlc);
|
int sdu_len = pdu_msg->get()->set_sdu(lcid, requested_sdu_len, rlc);
|
||||||
if (sdu_len > 0) { // new SDU could be added
|
if (sdu_len > 0) { // new SDU could be added
|
||||||
Debug("SDU: allocated lcid=%d, rlc_buffer=%d, allocated=%d/%d, max_sdu_sz=%d, remaining=%d\n",
|
Debug("SDU: allocated lcid=%d, rlc_buffer=%d, request_sdu_len=%d, allocated=%d/%d, max_sdu_sz=%d, "
|
||||||
lcid, buffer_state, sdu_len, sdu_space, max_sdu_sz, pdu_msg->rem_size());
|
"remaining=%d\n",
|
||||||
|
lcid,
|
||||||
|
buffer_state,
|
||||||
|
requested_sdu_len,
|
||||||
|
sdu_len,
|
||||||
|
sdu_space,
|
||||||
|
max_sdu_sz,
|
||||||
|
pdu_msg->rem_size());
|
||||||
sdu_space -= sdu_len;
|
sdu_space -= sdu_len;
|
||||||
sdu_added = true;
|
sdu_added = true;
|
||||||
|
|
||||||
sdu_len = rlc->get_buffer_state(lcid);
|
buffer_state = rlc->get_buffer_state(lcid);
|
||||||
} else {
|
} else {
|
||||||
Warning("SDU: rlc_buffer=%d, allocated=%d/%d, remaining=%d\n",
|
Warning("SDU: rlc_buffer=%d, requested_sdu_len=%d, allocated=%d/%d, remaining=%d\n",
|
||||||
buffer_state, sdu_len, sdu_space, pdu_msg->rem_size());
|
buffer_state,
|
||||||
|
requested_sdu_len,
|
||||||
|
sdu_len,
|
||||||
|
sdu_space,
|
||||||
|
pdu_msg->rem_size());
|
||||||
pdu_msg->del_subh();
|
pdu_msg->del_subh();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Warning("Couldn't add new MAC subheader (rlc_buffer=%d, allocated=%d/%d, remaining=%d)\n",
|
Debug("Couldn't add new MAC subheader (rlc_buffer=%d, requested_sdu_len=%d, sdu_space=%d, remaining=%d)\n",
|
||||||
buffer_state,
|
buffer_state,
|
||||||
sdu_len,
|
requested_sdu_len,
|
||||||
sdu_space,
|
|
||||||
pdu_msg->rem_size());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Warning("Remaining SDU len too low (%d<%d) max_sdu_sz=%d, sdu_space=%d, remaining=%d\n",
|
|
||||||
sdu_len,
|
|
||||||
MIN_RLC_SDU_LEN,
|
|
||||||
max_sdu_sz,
|
|
||||||
sdu_space,
|
sdu_space,
|
||||||
pdu_msg->rem_size());
|
pdu_msg->rem_size());
|
||||||
|
// prevent endless loop
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sdu_added;
|
return sdu_added;
|
||||||
|
|
Loading…
Reference in New Issue