rlcmac: Move create_pkt_ctrl_ack() to tbf base class
The code to generate a PKT CTRL ACK is the same for a DL TBF and an UL TBF. Move it to the generic base class in order to be able to generate it for a DL TBF in a follow up patch. Change-Id: I767696b445842ebc32b35c320273b13f63076ca4
This commit is contained in:
parent
bab234c2ea
commit
e0ec0a3fcc
|
@ -27,3 +27,14 @@ void gprs_rlcmac_tbf_constructor(struct gprs_rlcmac_tbf *tbf,
|
||||||
void gprs_rlcmac_tbf_destructor(struct gprs_rlcmac_tbf *tbf);
|
void gprs_rlcmac_tbf_destructor(struct gprs_rlcmac_tbf *tbf);
|
||||||
|
|
||||||
void gprs_rlcmac_tbf_free(struct gprs_rlcmac_tbf *tbf);
|
void gprs_rlcmac_tbf_free(struct gprs_rlcmac_tbf *tbf);
|
||||||
|
|
||||||
|
struct msgb *gprs_rlcmac_tbf_create_pkt_ctrl_ack(const struct gprs_rlcmac_tbf *tbf);
|
||||||
|
|
||||||
|
#define LOGPTBF(tbf, lvl, fmt, args...) \
|
||||||
|
LOGP(g_rlcmac_log_cat[tbf->direction == GPRS_RLCMAC_TBF_DIR_DL ? \
|
||||||
|
OSMO_GPRS_RLCMAC_LOGC_TBFDL : \
|
||||||
|
OSMO_GPRS_RLCMAC_LOGC_TBFUL], \
|
||||||
|
lvl, "TBF(%s:NR-%" PRIu8 ":TLLI-%08x) " fmt, \
|
||||||
|
tbf->direction == GPRS_RLCMAC_TBF_DIR_DL ? "DL" : "UL", \
|
||||||
|
tbf->nr, tbf->gre->tlli, \
|
||||||
|
## args)
|
||||||
|
|
|
@ -54,7 +54,6 @@ bool gprs_rlcmac_ul_tbf_dummy_rts(const struct gprs_rlcmac_ul_tbf *ul_tbf, const
|
||||||
|
|
||||||
struct msgb *gprs_rlcmac_ul_tbf_data_create(struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_rlcmac_rts_block_ind *bi);
|
struct msgb *gprs_rlcmac_ul_tbf_data_create(struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_rlcmac_rts_block_ind *bi);
|
||||||
struct msgb *gprs_rlcmac_ul_tbf_dummy_create(const struct gprs_rlcmac_ul_tbf *ul_tbf);
|
struct msgb *gprs_rlcmac_ul_tbf_dummy_create(const struct gprs_rlcmac_ul_tbf *ul_tbf);
|
||||||
struct msgb *gprs_rlcmac_ul_tbf_create_pkt_ctrl_ack(const struct gprs_rlcmac_ul_tbf *ul_tbf);
|
|
||||||
|
|
||||||
int gprs_rlcmac_ul_tbf_handle_pkt_ul_ack_nack(struct gprs_rlcmac_ul_tbf *ul_tbf,
|
int gprs_rlcmac_ul_tbf_handle_pkt_ul_ack_nack(struct gprs_rlcmac_ul_tbf *ul_tbf,
|
||||||
const RlcMacDownlink_t *dl_block);
|
const RlcMacDownlink_t *dl_block);
|
||||||
|
|
|
@ -198,13 +198,13 @@ static struct msgb *sched_select_ctrl_msg(const struct gprs_rlcmac_rts_block_ind
|
||||||
if (tbfs->poll_ul_ack) {
|
if (tbfs->poll_ul_ack) {
|
||||||
LOGRLCMAC(LOGL_DEBUG, "(ts=%u,fn=%u,usf=%u) Tx Pkt Control Ack (UL ACK/NACK poll)\n",
|
LOGRLCMAC(LOGL_DEBUG, "(ts=%u,fn=%u,usf=%u) Tx Pkt Control Ack (UL ACK/NACK poll)\n",
|
||||||
bi->ts, bi->fn, bi->usf);
|
bi->ts, bi->fn, bi->usf);
|
||||||
msg = gprs_rlcmac_ul_tbf_create_pkt_ctrl_ack(tbfs->poll_ul_ack);
|
msg = gprs_rlcmac_tbf_create_pkt_ctrl_ack(ul_tbf_as_tbf(tbfs->poll_ul_ack));
|
||||||
/* Last UL message, freeing */
|
/* Last UL message, freeing */
|
||||||
gprs_rlcmac_ul_tbf_free(tbfs->poll_ul_ack);
|
gprs_rlcmac_ul_tbf_free(tbfs->poll_ul_ack);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if (tbfs->poll_ul_ass) {
|
if (tbfs->poll_ul_ass) {
|
||||||
msg = gprs_rlcmac_ul_tbf_create_pkt_ctrl_ack(tbfs->poll_ul_ass);
|
msg = gprs_rlcmac_tbf_create_pkt_ctrl_ack(ul_tbf_as_tbf(tbfs->poll_ul_ass));
|
||||||
if (msg)
|
if (msg)
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,14 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <osmocom/core/bitvec.h>
|
||||||
|
#include <osmocom/core/msgb.h>
|
||||||
|
#include <osmocom/gsm/protocol/gsm_04_08.h>
|
||||||
|
|
||||||
#include <osmocom/gprs/rlcmac/tbf.h>
|
#include <osmocom/gprs/rlcmac/tbf.h>
|
||||||
#include <osmocom/gprs/rlcmac/tbf_ul.h>
|
#include <osmocom/gprs/rlcmac/tbf_ul.h>
|
||||||
|
#include <osmocom/gprs/rlcmac/gre.h>
|
||||||
|
#include <osmocom/gprs/rlcmac/rlcmac_enc.h>
|
||||||
|
|
||||||
void gprs_rlcmac_tbf_constructor(struct gprs_rlcmac_tbf *tbf,
|
void gprs_rlcmac_tbf_constructor(struct gprs_rlcmac_tbf *tbf,
|
||||||
enum gprs_rlcmac_tbf_direction direction,
|
enum gprs_rlcmac_tbf_direction direction,
|
||||||
|
@ -41,3 +47,38 @@ void gprs_rlcmac_tbf_free(struct gprs_rlcmac_tbf *tbf)
|
||||||
gprs_rlcmac_ul_tbf_free(tbf_as_ul_tbf(tbf));
|
gprs_rlcmac_ul_tbf_free(tbf_as_ul_tbf(tbf));
|
||||||
/* else: TODO dl_tbf not yet implemented */
|
/* else: TODO dl_tbf not yet implemented */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct msgb *gprs_rlcmac_tbf_create_pkt_ctrl_ack(const struct gprs_rlcmac_tbf *tbf)
|
||||||
|
{
|
||||||
|
struct msgb *msg;
|
||||||
|
struct bitvec bv;
|
||||||
|
RlcMacUplink_t ul_block;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
OSMO_ASSERT(tbf);
|
||||||
|
|
||||||
|
msg = msgb_alloc(GSM_MACBLOCK_LEN, "pkt_ctrl_ack");
|
||||||
|
if (!msg)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Initialize a bit vector that uses allocated msgb as the data buffer. */
|
||||||
|
bv = (struct bitvec){
|
||||||
|
.data = msgb_put(msg, GSM_MACBLOCK_LEN),
|
||||||
|
.data_len = GSM_MACBLOCK_LEN,
|
||||||
|
};
|
||||||
|
bitvec_unhex(&bv, GPRS_RLCMAC_DUMMY_VEC);
|
||||||
|
|
||||||
|
gprs_rlcmac_enc_prepare_pkt_ctrl_ack(&ul_block, tbf->gre->tlli);
|
||||||
|
rc = osmo_gprs_rlcmac_encode_uplink(&bv, &ul_block);
|
||||||
|
if (rc < 0) {
|
||||||
|
LOGPTBF(tbf, LOGL_ERROR, "Encoding of Packet Control ACK failed (%d)\n", rc);
|
||||||
|
goto free_ret;
|
||||||
|
}
|
||||||
|
LOGPTBF(tbf, LOGL_DEBUG, "Tx Packet Control Ack\n");
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
|
||||||
|
free_ret:
|
||||||
|
msgb_free(msg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -310,41 +310,6 @@ free_ret:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct msgb *gprs_rlcmac_ul_tbf_create_pkt_ctrl_ack(const struct gprs_rlcmac_ul_tbf *ul_tbf)
|
|
||||||
{
|
|
||||||
struct msgb *msg;
|
|
||||||
struct bitvec bv;
|
|
||||||
RlcMacUplink_t ul_block;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
OSMO_ASSERT(ul_tbf);
|
|
||||||
|
|
||||||
msg = msgb_alloc(GSM_MACBLOCK_LEN, "pkt_ctrl_ack");
|
|
||||||
if (!msg)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Initialize a bit vector that uses allocated msgb as the data buffer. */
|
|
||||||
bv = (struct bitvec){
|
|
||||||
.data = msgb_put(msg, GSM_MACBLOCK_LEN),
|
|
||||||
.data_len = GSM_MACBLOCK_LEN,
|
|
||||||
};
|
|
||||||
bitvec_unhex(&bv, GPRS_RLCMAC_DUMMY_VEC);
|
|
||||||
|
|
||||||
gprs_rlcmac_enc_prepare_pkt_ctrl_ack(&ul_block, ul_tbf->tbf.gre->tlli);
|
|
||||||
rc = osmo_gprs_rlcmac_encode_uplink(&bv, &ul_block);
|
|
||||||
if (rc < 0) {
|
|
||||||
LOGPTBFUL(ul_tbf, LOGL_ERROR, "Encoding of Packet Control ACK failed (%d)\n", rc);
|
|
||||||
goto free_ret;
|
|
||||||
}
|
|
||||||
LOGPTBFUL(ul_tbf, LOGL_DEBUG, "Tx Packet Control Ack\n");
|
|
||||||
|
|
||||||
return msg;
|
|
||||||
|
|
||||||
free_ret:
|
|
||||||
msgb_free(msg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool gprs_rlcmac_ul_tbf_have_data(const struct gprs_rlcmac_ul_tbf *ul_tbf)
|
bool gprs_rlcmac_ul_tbf_have_data(const struct gprs_rlcmac_ul_tbf *ul_tbf)
|
||||||
{
|
{
|
||||||
return (ul_tbf->llc_tx_msg && msgb_length(ul_tbf->llc_tx_msg) > 0) ||
|
return (ul_tbf->llc_tx_msg && msgb_length(ul_tbf->llc_tx_msg) > 0) ||
|
||||||
|
|
Loading…
Reference in New Issue