From a4bf73e74d9951bfcef5c064cd8196ddbdfba28b Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Tue, 23 Jan 2024 04:24:05 +0700 Subject: [PATCH] mobile: add a separate logging category for CSD Change-Id: If9db0759aeb4324ace9ae258c852787f37897d83 Related: OS#4396 --- .../include/osmocom/bb/common/logging.h | 1 + src/host/layer23/src/common/logging.c | 6 +++++ src/host/layer23/src/mobile/tch_data.c | 26 +++++++++---------- src/host/layer23/src/mobile/tch_data_sock.c | 12 ++++----- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/host/layer23/include/osmocom/bb/common/logging.h b/src/host/layer23/include/osmocom/bb/common/logging.h index 40a7e81de..3920d2e0b 100644 --- a/src/host/layer23/include/osmocom/bb/common/logging.h +++ b/src/host/layer23/include/osmocom/bb/common/logging.h @@ -28,6 +28,7 @@ enum { DPRIM, DLUA, DGAPK, + DCSD, DTUN, DRLCMAC, DLLC, diff --git a/src/host/layer23/src/common/logging.c b/src/host/layer23/src/common/logging.c index 040136076..283b7f1a4 100644 --- a/src/host/layer23/src/common/logging.c +++ b/src/host/layer23/src/common/logging.c @@ -159,6 +159,12 @@ static const struct log_info_cat default_categories[] = { .color = "\033[0;36m", .enabled = 1, .loglevel = LOGL_DEBUG, }, + [DCSD] = { + .name = "DCSD", + .description = "Circuit Switched Data", + .color = "\033[0;36m", + .enabled = 1, .loglevel = LOGL_DEBUG, + }, [DTUN] = { .name = "DTUN", .description = "Tunnel interface", diff --git a/src/host/layer23/src/mobile/tch_data.c b/src/host/layer23/src/mobile/tch_data.c index 6ee89dcf1..7169efadb 100644 --- a/src/host/layer23/src/mobile/tch_data.c +++ b/src/host/layer23/src/mobile/tch_data.c @@ -81,7 +81,7 @@ static void tch_soft_uart_rx_cb(void *priv, struct msgb *msg, unsigned int flags { struct tch_data_state *state = (struct tch_data_state *)priv; - LOGP(DL1C, LOGL_DEBUG, "%s(): [flags=0x%08x] %s\n", + LOGP(DCSD, LOGL_DEBUG, "%s(): [flags=0x%08x] %s\n", __func__, flags, msgb_hexdump(msg)); if (state->sock != NULL && msgb_length(msg) > 0) @@ -96,7 +96,7 @@ static void tch_soft_uart_tx_cb(void *priv, struct msgb *msg) tch_csd_sock_recv(state->sock, msg); - LOGP(DL1C, LOGL_DEBUG, "%s(): [n_bytes=%u/%u] %s\n", + LOGP(DCSD, LOGL_DEBUG, "%s(): [n_bytes=%u/%u] %s\n", __func__, msg->len, msg->data_len, msgb_hexdump(msg)); } @@ -166,7 +166,7 @@ static void tch_v110_ta_tx_cb(void *priv, ubit_t *buf, size_t buf_size) tch_csd_sock_recv(state->sock, msg); if (msgb_length(msg) < buf_size) { - LOGP(DL1C, LOGL_NOTICE, + LOGP(DCSD, LOGL_NOTICE, "%s(): not enough bytes for sync Tx (%u < %zu)\n", __func__, msgb_length(msg), buf_size); } @@ -189,7 +189,7 @@ static void tch_v110_ta_async_tx_cb(void *priv, ubit_t *buf, size_t buf_size) static void tch_v110_ta_status_update_cb(void *priv, unsigned int status) { - LOGP(DL1C, LOGL_DEBUG, "%s(): [status=0x%08x]\n", __func__, status); + LOGP(DCSD, LOGL_DEBUG, "%s(): [status=0x%08x]\n", __func__, status); /* TODO: update status lines of the soft-UART (if state.suart != NULL) */ } @@ -233,7 +233,7 @@ struct osmo_v110_ta *tch_v110_ta_alloc(struct osmocom_ms *ms, * signalling rate shall be adapted to a synchronous 600 bit/s stream. */ case BCAP_RATE(GSM48_BCAP_IR_8k, GSM48_BCAP_UR_300): default: - LOGP(DCC, LOGL_ERROR, + LOGP(DCSD, LOGL_ERROR, "%s(): IR 0x%02x / UR 0x%02x combination is not supported\n", __func__, bcap->data.interm_rate, bcap->data.user_rate); return NULL; @@ -367,20 +367,20 @@ static int tch_csd_tx_to_l1(struct osmocom_ms *ms) static int tch_data_check_bcap(const struct gsm_mncc_bearer_cap *bcap) { if (bcap == NULL) { - LOGP(DL1C, LOGL_ERROR, + LOGP(DCSD, LOGL_ERROR, "%s(): CC transaction without BCap\n", __func__); return -ENODEV; } if (bcap->mode != GSM48_BCAP_TMOD_CIRCUIT) { - LOGP(DCC, LOGL_ERROR, + LOGP(DCSD, LOGL_ERROR, "%s(): Transfer mode 0x%02x is not supported\n", __func__, bcap->mode); return -ENOTSUP; } if (bcap->coding != GSM48_BCAP_CODING_GSM_STD) { - LOGP(DCC, LOGL_ERROR, + LOGP(DCSD, LOGL_ERROR, "%s(): Coding standard 0x%02x is not supported\n", __func__, bcap->coding); return -ENOTSUP; @@ -392,26 +392,26 @@ static int tch_data_check_bcap(const struct gsm_mncc_bearer_cap *bcap) case GSM48_BCAP_ITCAP_FAX_G3: break; default: - LOGP(DCC, LOGL_ERROR, + LOGP(DCSD, LOGL_ERROR, "%s(): Information transfer capability 0x%02x is not supported\n", __func__, bcap->transfer); return -ENOTSUP; } if (bcap->data.rate_adaption != GSM48_BCAP_RA_V110_X30) { - LOGP(DCC, LOGL_ERROR, + LOGP(DCSD, LOGL_ERROR, "%s(): Rate adaption (octet 5) 0x%02x is not supported\n", __func__, bcap->data.rate_adaption); return -ENOTSUP; } if (bcap->data.sig_access != GSM48_BCAP_SA_I440_I450) { - LOGP(DCC, LOGL_ERROR, + LOGP(DCSD, LOGL_ERROR, "%s(): Signalling access protocol (octet 5) 0x%02x is not supported\n", __func__, bcap->data.sig_access); return -ENOTSUP; } if (bcap->data.transp != GSM48_BCAP_TR_TRANSP) { - LOGP(DCC, LOGL_ERROR, + LOGP(DCSD, LOGL_ERROR, "%s(): only transparent calls are supported so far\n", __func__); return -ENOTSUP; @@ -514,7 +514,7 @@ void tch_csd_sock_state_cb(struct osmocom_ms *ms, bool connected) struct tch_data_state *state = NULL; if (ms->tch_state == NULL || ms->tch_state->is_voice) { - LOGP(DCC, LOGL_INFO, "No data call is ongoing, " + LOGP(DCSD, LOGL_INFO, "No data call is ongoing, " "ignoring [dis]connection event for CSD socket\n"); return; } diff --git a/src/host/layer23/src/mobile/tch_data_sock.c b/src/host/layer23/src/mobile/tch_data_sock.c index 7bfebf3e7..7ce5a4f1b 100644 --- a/src/host/layer23/src/mobile/tch_data_sock.c +++ b/src/host/layer23/src/mobile/tch_data_sock.c @@ -51,7 +51,7 @@ static void tch_csd_sock_close(struct tch_csd_sock_state *state) { struct osmo_fd *bfd = &state->conn_bfd; - LOGP(DMOB, LOGL_NOTICE, "TCH CSD sock has closed connection\n"); + LOGP(DCSD, LOGL_NOTICE, "TCH CSD sock has closed connection\n"); tch_csd_sock_state_cb(state->ms, false); @@ -155,25 +155,25 @@ static int tch_csd_sock_accept(struct osmo_fd *bfd, unsigned int flags) len = sizeof(un_addr); rc = accept(bfd->fd, (struct sockaddr *)&un_addr, &len); if (rc < 0) { - LOGP(DMOB, LOGL_ERROR, "Failed to accept() a new connection\n"); + LOGP(DCSD, LOGL_ERROR, "Failed to accept() a new connection\n"); return -1; } if (conn_bfd->fd >= 0) { - LOGP(DMOB, LOGL_NOTICE, "TCH CSD sock already has an active connection\n"); + LOGP(DCSD, LOGL_NOTICE, "TCH CSD sock already has an active connection\n"); close(rc); /* reject this connection request */ return 0; } osmo_fd_setup(conn_bfd, rc, OSMO_FD_READ, &tch_csd_sock_cb, state, 0); if (osmo_fd_register(conn_bfd) != 0) { - LOGP(DMOB, LOGL_ERROR, "osmo_fd_register() failed\n"); + LOGP(DCSD, LOGL_ERROR, "osmo_fd_register() failed\n"); close(conn_bfd->fd); conn_bfd->fd = -1; return -1; } - LOGP(DMOB, LOGL_NOTICE, "TCH CSD sock got a connection\n"); + LOGP(DCSD, LOGL_NOTICE, "TCH CSD sock got a connection\n"); tch_csd_sock_state_cb(state->ms, true); @@ -200,7 +200,7 @@ struct tch_csd_sock_state *tch_csd_sock_init(struct osmocom_ms *ms) rc = osmo_sock_unix_init_ofd(bfd, SOCK_STREAM, 0, sock_path, OSMO_SOCK_F_BIND); if (rc < 0) { - LOGP(DMOB, LOGL_ERROR, "Could not create unix socket: %s\n", strerror(errno)); + LOGP(DCSD, LOGL_ERROR, "Could not create unix socket: %s\n", strerror(errno)); talloc_free(state); return NULL; }