llc: Refactor code checking if PDU expired while dequeueing

The previous function name was misleading since it was checking already
for more stuff than pdu containing user data.
Rename the function and move all checks on PDU in there instead of
having it half in one place and half in the other.

Change-Id: Ia0738caa1ccab5f78c2d49db582bdce96f18600a
This commit is contained in:
Pau Espin 2023-01-26 15:09:48 +01:00
parent 0e435fa959
commit 1111aa16e6
1 changed files with 8 additions and 11 deletions

View File

@ -80,9 +80,12 @@ void llc_append_frame(struct gprs_llc *llc, const uint8_t *data, size_t len)
llc->length += len;
}
static bool llc_is_user_data_frame(const uint8_t *data, size_t len)
static bool llc_pdu_can_be_discarded(const uint8_t *data, size_t len)
{
if (len < 2)
const unsigned keep_small_thresh = 60;
/* Is the frame small, perhaps only a TCP ACK? */
if (len <= keep_small_thresh)
return false;
if ((data[0] & 0x0f) == 1 /* GPRS_SAPI_GMM */)
@ -271,7 +274,6 @@ struct msgb *llc_queue_dequeue(struct gprs_llc_queue *q)
struct gprs_rlcmac_bts *bts = q->ms->bts;
struct gprs_pcu *pcu = bts->pcu;
struct timespec hyst_delta = {0, 0};
const unsigned keep_small_thresh = 60;
enum gprs_llc_queue_prio prio;
if (pcu->vty.llc_discard_csec)
@ -306,14 +308,9 @@ struct msgb *llc_queue_dequeue(struct gprs_llc_queue *q)
/* Hysteresis mode, try to discard LLC messages until
* the low water mark has been reached */
/* Check whether to abort the hysteresis mode */
/* Is the frame small, perhaps only a TCP ACK? */
if (msg->len <= keep_small_thresh)
break;
/* Is it a GMM message? */
if (!llc_is_user_data_frame(msg->data, msg->len))
/* Check whether to abort the hysteresis mode:
* Can the PDU be discarded according to its type? */
if (!llc_pdu_can_be_discarded(msg->data, msg->len))
break;
}