pespin has uploaded this change for review.
rlcmac: Support extending log categories in the future
An initial header structure and LOG defines is created in a similar way
to those already existing for libosmo-gprs-llc and sndcp.
Related: OS#5500
Change-Id: Ic9ba207cafeada1b174f1b085e0d1d9a38c66b0a
---
M include/osmocom/gprs/rlcmac/Makefile.am
M include/osmocom/gprs/rlcmac/gprs_rlcmac.h
A include/osmocom/gprs/rlcmac/rlcmac.h
A include/osmocom/gprs/rlcmac/rlcmac_private.h
M src/rlcmac/misc.c
M src/rlcmac/ts_24_008.c
M src/rlcmac/ts_44_018.c
M src/rlcmac/ts_44_060.c
8 files changed, 85 insertions(+), 60 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/75/31075/1
diff --git a/include/osmocom/gprs/rlcmac/Makefile.am b/include/osmocom/gprs/rlcmac/Makefile.am
index ab67d13..0182bfd 100644
--- a/include/osmocom/gprs/rlcmac/Makefile.am
+++ b/include/osmocom/gprs/rlcmac/Makefile.am
@@ -1,4 +1,9 @@
+noinst_HEADERS = \
+ rlcmac_private.h \
+ $(NULL)
+
rlcmac_HEADERS = \
+ rlcmac.h \
gprs_rlcmac.h \
$(NULL)
diff --git a/include/osmocom/gprs/rlcmac/gprs_rlcmac.h b/include/osmocom/gprs/rlcmac/gprs_rlcmac.h
index 2be01b2..a68267d 100644
--- a/include/osmocom/gprs/rlcmac/gprs_rlcmac.h
+++ b/include/osmocom/gprs/rlcmac/gprs_rlcmac.h
@@ -5433,5 +5433,3 @@
const uint8_t *data, size_t data_len);
int osmo_gprs_rlcmac_decode_imm_ass_ro(IA_RestOctets_t *storage,
const uint8_t *data, size_t data_len);
-
-void osmo_gprs_rlcmac_set_log_cat(int cat);
diff --git a/include/osmocom/gprs/rlcmac/rlcmac.h b/include/osmocom/gprs/rlcmac/rlcmac.h
new file mode 100644
index 0000000..0497643
--- /dev/null
+++ b/include/osmocom/gprs/rlcmac/rlcmac.h
@@ -0,0 +1,10 @@
+#pragma once
+
+/* Radio Link Control / Medium Access Control (RLCMAC) definitions from 3GPP TS 44.060 */
+
+enum osmo_gprs_rlcmac_log_cat {
+ OSMO_GPRS_RLCMAC_LOGC_RLCMAC,
+ _OSMO_GPRS_RLCMAC_LOGC_MAX,
+};
+
+void osmo_gprs_rlcmac_set_log_cat(enum osmo_gprs_rlcmac_log_cat logc, int logc_num);
diff --git a/include/osmocom/gprs/rlcmac/rlcmac_private.h b/include/osmocom/gprs/rlcmac/rlcmac_private.h
new file mode 100644
index 0000000..17bc745
--- /dev/null
+++ b/include/osmocom/gprs/rlcmac/rlcmac_private.h
@@ -0,0 +1,10 @@
+#pragma once
+
+/* RLCMAC private header */
+
+#include <osmocom/gprs/rlcmac/rlcmac.h>
+
+extern int g_rlcmac_log_cat[_OSMO_GPRS_RLCMAC_LOGC_MAX];
+
+#define LOGRLCMAC(lvl, fmt, args...) LOGP(g_rlcmac_log_cat[OSMO_GPRS_RLCMAC_LOGC_RLCMAC], lvl, fmt, ## args)
+#define LOGRLCMACC(lvl, fmt, args...) LOGPC(g_rlcmac_log_cat[OSMO_GPRS_RLCMAC_LOGC_RLCMAC], lvl, fmt, ## args)
diff --git a/src/rlcmac/misc.c b/src/rlcmac/misc.c
index 0aecbfd..da846de 100644
--- a/src/rlcmac/misc.c
+++ b/src/rlcmac/misc.c
@@ -15,11 +15,16 @@
* GNU General Public License for more details.
*/
+#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
+#include <osmocom/gprs/rlcmac/rlcmac.h>
-int g_log_cat = DLGLOBAL;
+int g_rlcmac_log_cat[_OSMO_GPRS_RLCMAC_LOGC_MAX] = {
+ [0 ... _OSMO_GPRS_RLCMAC_LOGC_MAX - 1] = DLGLOBAL
+};
-void osmo_gprs_rlcmac_set_log_cat(int cat)
+void osmo_gprs_rlcmac_set_log_cat(enum osmo_gprs_rlcmac_log_cat logc, int logc_num)
{
- g_log_cat = cat;
-}
+ OSMO_ASSERT(logc < _OSMO_GPRS_RLCMAC_LOGC_MAX);
+ g_rlcmac_log_cat[logc] = logc_num;
+}
\ No newline at end of file
diff --git a/src/rlcmac/ts_24_008.c b/src/rlcmac/ts_24_008.c
index 1d64499..b9e72e0 100644
--- a/src/rlcmac/ts_24_008.c
+++ b/src/rlcmac/ts_24_008.c
@@ -26,8 +26,7 @@
#include <osmocom/csn1/csn1.h>
#include <osmocom/gprs/rlcmac/gprs_rlcmac.h>
-
-extern int g_log_cat;
+#include <osmocom/gprs/rlcmac/rlcmac_private.h>
/*< MS Classmark 3 IE >*/
#if 0
@@ -364,7 +363,7 @@
LOGPC(DLCSN1, LOGL_INFO, "\n");
if (ret > 0) {
- LOGP(g_log_cat, LOGL_NOTICE, "RAcap: Got %d remaining bits unhandled by decoder at the end of bitvec\n", ret);
+ LOGRLCMAC(LOGL_NOTICE, "RAcap: Got %d remaining bits unhandled by decoder at the end of bitvec\n", ret);
ret = 0;
}
return ret;
@@ -384,7 +383,7 @@
LOGPC(DLCSN1, LOGL_INFO, "\n");
if (ret > 0 || ret == CSN_ERROR_NEED_MORE_BITS_TO_UNPACK) {
- LOGP(g_log_cat, LOGL_ERROR, "Failed to encode MS RA Capability IE: not enough bits "
+ LOGRLCMAC(LOGL_ERROR, "Failed to encode MS RA Capability IE: not enough bits "
"in the output buffer (rc=%d)\n", ret);
ret = CSN_ERROR_NEED_MORE_BITS_TO_UNPACK;
}
diff --git a/src/rlcmac/ts_44_018.c b/src/rlcmac/ts_44_018.c
index 48ab5ea..6c0ce0e 100644
--- a/src/rlcmac/ts_44_018.c
+++ b/src/rlcmac/ts_44_018.c
@@ -26,8 +26,7 @@
#include <osmocom/csn1/csn1.h>
#include <osmocom/gprs/rlcmac/gprs_rlcmac.h>
-
-extern int g_log_cat;
+#include <osmocom/gprs/rlcmac/rlcmac_private.h>
CSN_DESCR_EXTERN(GPRS_Mobile_Allocation_t);
CSN_DESCR_EXTERN(PBCCH_Not_present_t);
@@ -648,7 +647,7 @@
LOGPC(DLCSN1, LOGL_INFO, "\n");
if (ret > 0) {
- LOGP(g_log_cat, LOGL_NOTICE,
+ LOGRLCMAC(LOGL_NOTICE,
"%s: %d remaining bits unhandled by decoder\n",
descr_name, ret);
ret = 0;
diff --git a/src/rlcmac/ts_44_060.c b/src/rlcmac/ts_44_060.c
index fb2dd08..5f87c30 100644
--- a/src/rlcmac/ts_44_060.c
+++ b/src/rlcmac/ts_44_060.c
@@ -30,8 +30,7 @@
#include <osmocom/csn1/csn1.h>
#include <osmocom/gprs/rlcmac/gprs_rlcmac.h>
-
-extern int g_log_cat;
+#include <osmocom/gprs/rlcmac/rlcmac_private.h>
/* Payload type as defined in TS 44.060 / 10.4.7 */
#define PAYLOAD_TYPE_DATA 0
@@ -4476,12 +4475,12 @@
if (payload_type == PAYLOAD_TYPE_DATA)
{
- LOGP(g_log_cat, LOGL_NOTICE, "Payload Type: DATA (0), not implemented\n");
+ LOGRLCMAC(LOGL_NOTICE, "Payload Type: DATA (0), not implemented\n");
return CSN_ERROR_GENERAL;
}
else if (payload_type == PAYLOAD_TYPE_RESERVED)
{
- LOGP(g_log_cat, LOGL_NOTICE, "Payload Type: RESERVED (3)\n");
+ LOGRLCMAC(LOGL_NOTICE, "Payload Type: RESERVED (3)\n");
return CSN_ERROR_GENERAL;
}
@@ -4583,7 +4582,7 @@
LOGPC(DLCSN1, LOGL_INFO, "\n");
if (ret > 0) {
- LOGP(g_log_cat, LOGL_NOTICE, "%s: Got %d remaining bits unhandled by decoder at the end of bitvec\n", msg_type_name, ret);
+ LOGRLCMAC(LOGL_NOTICE, "%s: Got %d remaining bits unhandled by decoder at the end of bitvec\n", msg_type_name, ret);
ret = 0;
}
@@ -4608,12 +4607,12 @@
if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_DATA)
{
- LOGP(g_log_cat, LOGL_NOTICE, "Payload Type: DATA (0), not implemented\n");
+ LOGRLCMAC(LOGL_NOTICE, "Payload Type: DATA (0), not implemented\n");
return CSN_ERROR_GENERAL;
}
else if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_RESERVED)
{
- LOGP(g_log_cat, LOGL_NOTICE, "Payload Type: RESERVED (3)\n");
+ LOGRLCMAC(LOGL_NOTICE, "Payload Type: RESERVED (3)\n");
return CSN_ERROR_GENERAL;
}
/* We can decode the message */
@@ -4795,7 +4794,7 @@
LOGPC(DLCSN1, LOGL_INFO, "\n");
if (ret > 0) {
- LOGP(g_log_cat, LOGL_NOTICE, "%s: Got %d remaining bits unhandled by decoder at the end of bitvec\n", msg_type_name, ret);
+ LOGRLCMAC(LOGL_NOTICE, "%s: Got %d remaining bits unhandled by decoder at the end of bitvec\n", msg_type_name, ret);
ret = 0;
}
@@ -4906,7 +4905,7 @@
LOGPC(DLCSN1, LOGL_INFO, "\n");
if (ret > 0 || ret == CSN_ERROR_NEED_MORE_BITS_TO_UNPACK) {
- LOGP(g_log_cat, LOGL_ERROR, "Failed to encode an Uplink block: not enough bits "
+ LOGRLCMAC(LOGL_ERROR, "Failed to encode an Uplink block: not enough bits "
"in the output buffer (rc=%d)\n", ret);
ret = CSN_ERROR_NEED_MORE_BITS_TO_UNPACK;
}
@@ -4927,12 +4926,12 @@
if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_DATA)
{
- LOGP(g_log_cat, LOGL_NOTICE, "Payload Type: DATA (0), not implemented\n");
+ LOGRLCMAC(LOGL_NOTICE, "Payload Type: DATA (0), not implemented\n");
return CSN_ERROR_GENERAL;
}
else if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_RESERVED)
{
- LOGP(g_log_cat, LOGL_NOTICE, "Payload Type: RESERVED (3)\n");
+ LOGRLCMAC(LOGL_NOTICE, "Payload Type: RESERVED (3)\n");
return CSN_ERROR_GENERAL;
}
/* We can encode the message */
@@ -5116,7 +5115,7 @@
LOGPC(DLCSN1, LOGL_INFO, "\n");
if (ret > 0 || ret == CSN_ERROR_NEED_MORE_BITS_TO_UNPACK) {
- LOGP(g_log_cat, LOGL_ERROR, "Failed to encode a Downlink block: not enough bits "
+ LOGRLCMAC(LOGL_ERROR, "Failed to encode a Downlink block: not enough bits "
"in the output buffer (rc=%d)\n", ret);
ret = CSN_ERROR_NEED_MORE_BITS_TO_UNPACK;
}
@@ -5138,25 +5137,25 @@
data->CV = bitvec_read_field(vector, &readIndex, 4);
data->SI = bitvec_read_field(vector, &readIndex, 1);
data->R = bitvec_read_field(vector, &readIndex, 1);
- LOGPC(g_log_cat, LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE));
- LOGPC(g_log_cat, LOGL_NOTICE, "CV = %u ", (unsigned)(data->CV));
- LOGPC(g_log_cat, LOGL_NOTICE, "SI = %u ", (unsigned)(data->SI));
- LOGPC(g_log_cat, LOGL_NOTICE, "R = %u ", (unsigned)(data->R));
+ LOGRLCMACC(LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE));
+ LOGRLCMACC(LOGL_NOTICE, "CV = %u ", (unsigned)(data->CV));
+ LOGRLCMACC(LOGL_NOTICE, "SI = %u ", (unsigned)(data->SI));
+ LOGRLCMACC(LOGL_NOTICE, "R = %u ", (unsigned)(data->R));
// Octet 1
data->spare = bitvec_read_field(vector, &readIndex, 1);
data->PI = bitvec_read_field(vector, &readIndex, 1);
data->TFI = bitvec_read_field(vector, &readIndex, 5);
data->TI = bitvec_read_field(vector, &readIndex, 1);
- LOGPC(g_log_cat, LOGL_NOTICE, "spare = %u ", (unsigned)(data->spare));
- LOGPC(g_log_cat, LOGL_NOTICE, "PI = %u ", (unsigned)(data->PI));
- LOGPC(g_log_cat, LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI));
- LOGPC(g_log_cat, LOGL_NOTICE, "TI = %u ", (unsigned)(data->TI));
+ LOGRLCMACC(LOGL_NOTICE, "spare = %u ", (unsigned)(data->spare));
+ LOGRLCMACC(LOGL_NOTICE, "PI = %u ", (unsigned)(data->PI));
+ LOGRLCMACC(LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI));
+ LOGRLCMACC(LOGL_NOTICE, "TI = %u ", (unsigned)(data->TI));
// Octet 2
data->BSN = bitvec_read_field(vector, &readIndex, 7);
data->E_1 = bitvec_read_field(vector, &readIndex, 1);
- LOGPC(g_log_cat, LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN));
- LOGPC(g_log_cat, LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1));
+ LOGRLCMACC(LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN));
+ LOGRLCMACC(LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1));
if (data->E_1 == 0) // Extension octet follows immediately
@@ -5168,37 +5167,37 @@
data->LENGTH_INDICATOR[i] = bitvec_read_field(vector, &readIndex, 6);
data->M[i] = bitvec_read_field(vector, &readIndex, 1);
data->E[i] = bitvec_read_field(vector, &readIndex, 1);
- LOGPC(g_log_cat, LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i]));
- LOGPC(g_log_cat, LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i]));
- LOGPC(g_log_cat, LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i]));
+ LOGRLCMACC(LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i]));
+ LOGRLCMACC(LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i]));
+ LOGRLCMACC(LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i]));
i++;
} while((data->M[i-1] == 1)&&(data->E[i-1] == 0));
}
if (data->TI == 1) // TLLI field is present
{
data->TLLI = bitvec_read_field(vector, &readIndex, 32);
- LOGPC(g_log_cat, LOGL_NOTICE, "TLLI = %08x ", data->TLLI);
+ LOGRLCMACC(LOGL_NOTICE, "TLLI = %08x ", data->TLLI);
if (data->PI == 1) // PFI is present if TI field indicates presence of TLLI
{
data->PFI = bitvec_read_field(vector, &readIndex, 7);
data->E_2 = bitvec_read_field(vector, &readIndex, 1);
- LOGPC(g_log_cat, LOGL_NOTICE, "PFI = %u ", (unsigned)(data->PFI));
- LOGPC(g_log_cat, LOGL_NOTICE, "E_2 = %u ", (unsigned)(data->E_2));
+ LOGRLCMACC(LOGL_NOTICE, "PFI = %u ", (unsigned)(data->PFI));
+ LOGRLCMACC(LOGL_NOTICE, "E_2 = %u ", (unsigned)(data->E_2));
}
}
unsigned dataLen = 23 - readIndex/8;
- LOGPC(g_log_cat, LOGL_NOTICE, "DATA[%u] = ", dataLen);
+ LOGRLCMACC(LOGL_NOTICE, "DATA[%u] = ", dataLen);
OSMO_ASSERT(dataLen <= 20);
for (i = 0; i < dataLen; i++)
{
data->RLC_DATA[i] = bitvec_read_field(vector, &readIndex, 8);
- LOGPC(g_log_cat, LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i]));
+ LOGRLCMACC(LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i]));
}
- LOGPC(g_log_cat, LOGL_NOTICE, "\n");
+ LOGRLCMACC(LOGL_NOTICE, "\n");
}
else
{
- LOGP(g_log_cat, LOGL_NOTICE, "Payload Type: RESERVED (3)\n");
+ LOGRLCMAC(LOGL_NOTICE, "Payload Type: RESERVED (3)\n");
return;
}
}
@@ -5215,24 +5214,24 @@
bitvec_write_field(vector, &writeIndex, data->RRBP, 2);
bitvec_write_field(vector, &writeIndex, data->SP, 1);
bitvec_write_field(vector, &writeIndex, data->USF, 3);
- LOGPC(g_log_cat, LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE));
- LOGPC(g_log_cat, LOGL_NOTICE, "RRBP = %u ", (unsigned)(data->RRBP));
- LOGPC(g_log_cat, LOGL_NOTICE, "SP = %u ", (unsigned)(data->SP));
- LOGPC(g_log_cat, LOGL_NOTICE, "USF = %u ", (unsigned)(data->USF));
+ LOGRLCMACC(LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE));
+ LOGRLCMACC(LOGL_NOTICE, "RRBP = %u ", (unsigned)(data->RRBP));
+ LOGRLCMACC(LOGL_NOTICE, "SP = %u ", (unsigned)(data->SP));
+ LOGRLCMACC(LOGL_NOTICE, "USF = %u ", (unsigned)(data->USF));
// Octet 1
bitvec_write_field(vector, &writeIndex, data->PR, 2);
bitvec_write_field(vector, &writeIndex, data->TFI, 5);
bitvec_write_field(vector, &writeIndex, data->FBI, 1);
- LOGPC(g_log_cat, LOGL_NOTICE, "PR = %u ", (unsigned)(data->PR));
- LOGPC(g_log_cat, LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI));
- LOGPC(g_log_cat, LOGL_NOTICE, "FBI = %u ", (unsigned)(data->FBI));
+ LOGRLCMACC(LOGL_NOTICE, "PR = %u ", (unsigned)(data->PR));
+ LOGRLCMACC(LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI));
+ LOGRLCMACC(LOGL_NOTICE, "FBI = %u ", (unsigned)(data->FBI));
// Octet 2
bitvec_write_field(vector, &writeIndex, data->BSN, 7);
bitvec_write_field(vector, &writeIndex, data->E_1, 1);
- LOGPC(g_log_cat, LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN));
- LOGPC(g_log_cat, LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1));
+ LOGRLCMACC(LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN));
+ LOGRLCMACC(LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1));
// Octet 3 (optional)
if (data->E_1 == 0)
@@ -5243,22 +5242,22 @@
bitvec_write_field(vector, &writeIndex, data->LENGTH_INDICATOR[i], 6);
bitvec_write_field(vector, &writeIndex, data->M[i], 1);
bitvec_write_field(vector, &writeIndex, data->E[i], 1);
- LOGPC(g_log_cat, LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i]));
- LOGPC(g_log_cat, LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i]));
- LOGPC(g_log_cat, LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i]));
+ LOGRLCMACC(LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i]));
+ LOGRLCMACC(LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i]));
+ LOGRLCMACC(LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i]));
i++;
}
while ((data->M[i-1] == 1) && (data->E[i-1] == 0));
}
unsigned dataNumOctets = 23 - writeIndex/8;
- LOGPC(g_log_cat, LOGL_NOTICE, "DATA[%u] = ", dataNumOctets);
+ LOGRLCMACC(LOGL_NOTICE, "DATA[%u] = ", dataNumOctets);
OSMO_ASSERT(dataNumOctets <= 20);
for (i = 0; i < dataNumOctets; i++)
{
bitvec_write_field(vector, &writeIndex, data->RLC_DATA[i], 8);
- LOGPC(g_log_cat, LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i]));
+ LOGRLCMACC(LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i]));
}
- LOGPC(g_log_cat, LOGL_NOTICE, "\n");
+ LOGRLCMACC(LOGL_NOTICE, "\n");
}
}
To view, visit change 31075. To unsubscribe, or for help writing mail filters, visit settings.